|
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime; |
|
|
|
import cn.hutool.core.date.DateUnit; |
|
|
|
import cn.hutool.core.date.DateUnit; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.zbkj.common.constants.*; |
|
|
|
import com.zbkj.common.constants.*; |
|
|
|
import com.zbkj.common.exception.CrmebException; |
|
|
|
import com.zbkj.common.exception.CrmebException; |
|
|
|
import com.zbkj.common.model.product.StoreProduct; |
|
|
|
import com.zbkj.common.model.product.StoreProduct; |
|
|
|
@ -27,9 +28,11 @@ import com.zbkj.common.model.order.StoreOrderInfo; |
|
|
|
import com.zbkj.common.model.product.StoreProductAttrValue; |
|
|
|
import com.zbkj.common.model.product.StoreProductAttrValue; |
|
|
|
import com.zbkj.common.model.system.SystemAdmin; |
|
|
|
import com.zbkj.common.model.system.SystemAdmin; |
|
|
|
import com.zbkj.common.vo.ShopOrderPayVo; |
|
|
|
import com.zbkj.common.vo.ShopOrderPayVo; |
|
|
|
|
|
|
|
import com.zbkj.common.vo.WxRefundQueryResponseVo; |
|
|
|
import com.zbkj.common.vo.WxRefundResponseVo; |
|
|
|
import com.zbkj.common.vo.WxRefundResponseVo; |
|
|
|
import com.zbkj.service.delete.OrderUtils; |
|
|
|
import com.zbkj.service.delete.OrderUtils; |
|
|
|
import com.zbkj.service.service.*; |
|
|
|
import com.zbkj.service.service.*; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
@ -56,6 +59,7 @@ import java.util.stream.Collectors; |
|
|
|
* +---------------------------------------------------------------------- |
|
|
|
* +---------------------------------------------------------------------- |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class StoreOrderTaskServiceImpl implements StoreOrderTaskService { |
|
|
|
public class StoreOrderTaskServiceImpl implements StoreOrderTaskService { |
|
|
|
//日志
|
|
|
|
//日志
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(StoreOrderTaskServiceImpl.class); |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(StoreOrderTaskServiceImpl.class); |
|
|
|
@ -361,9 +365,7 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService { |
|
|
|
List<UserIntegralRecord> addIntegralList = integralRecordList.stream().filter(e -> ObjectUtil.isNull(e.getId())).collect(Collectors.toList()); |
|
|
|
List<UserIntegralRecord> addIntegralList = integralRecordList.stream().filter(e -> ObjectUtil.isNull(e.getId())).collect(Collectors.toList()); |
|
|
|
List<UserIntegralRecord> updateIntegralList = integralRecordList.stream().filter(e -> ObjectUtil.isNotNull(e.getId())).collect(Collectors.toList()); |
|
|
|
List<UserIntegralRecord> updateIntegralList = integralRecordList.stream().filter(e -> ObjectUtil.isNotNull(e.getId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
StoreOrder tempOrder = new StoreOrder(); |
|
|
|
|
|
|
|
tempOrder.setId(storeOrder.getId()); |
|
|
|
|
|
|
|
tempOrder.setRefundStatus(2); |
|
|
|
|
|
|
|
// 佣金处理:只处理冻结期佣金
|
|
|
|
// 佣金处理:只处理冻结期佣金
|
|
|
|
// 查询佣金记录
|
|
|
|
// 查询佣金记录
|
|
|
|
List<UserBrokerageRecord> brokerageRecordList = CollUtil.newArrayList(); |
|
|
|
List<UserBrokerageRecord> brokerageRecordList = CollUtil.newArrayList(); |
|
|
|
@ -389,16 +391,15 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService { |
|
|
|
return Boolean.FALSE; |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
/* }*/ |
|
|
|
/* }*/ |
|
|
|
String mdbRefundNo = createAfterSale(storeOrder, user); |
|
|
|
boolean mdbRefundNo = createAfterSale(storeOrder, user); |
|
|
|
if (StrUtil.isNotBlank(mdbRefundNo)) { |
|
|
|
if (!mdbRefundNo) { |
|
|
|
storeOrder.setAfterSalesStatus("已退款"); |
|
|
|
logger.error("查询创建/退款查询失败,订单号:{} " ,storeOrder.getOrderId()); |
|
|
|
storeOrder.setRefundStatus(2); |
|
|
|
|
|
|
|
storeOrder.setMdbRefundNo(mdbRefundNo); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
logger.error("买单吧查询创建/退款查询失败,订单号:{} " ,storeOrder.getOrderId()); |
|
|
|
|
|
|
|
return Boolean.FALSE; |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
Boolean execute = transactionTemplate.execute(e -> { |
|
|
|
Boolean execute = transactionTemplate.execute(e -> { |
|
|
|
|
|
|
|
storeOrder.setAfterSalesStatus("已退款"); |
|
|
|
|
|
|
|
storeOrder.setRefundStatus(2); |
|
|
|
|
|
|
|
storeOrderService.updateById(storeOrder); |
|
|
|
//写订单日志
|
|
|
|
//写订单日志
|
|
|
|
storeOrderStatusService.saveRefund(storeOrder.getId(), storeOrder.getRefundPrice(), "成功"); |
|
|
|
storeOrderStatusService.saveRefund(storeOrder.getId(), storeOrder.getRefundPrice(), "成功"); |
|
|
|
|
|
|
|
|
|
|
|
@ -428,7 +429,7 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService { |
|
|
|
throw new CrmebException("回滚库存失败"); |
|
|
|
throw new CrmebException("回滚库存失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
storeOrderService.updateById(tempOrder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 拼团状态处理
|
|
|
|
// 拼团状态处理
|
|
|
|
if (storeOrder.getCombinationId() > 0) { |
|
|
|
if (storeOrder.getCombinationId() > 0) { |
|
|
|
@ -458,12 +459,22 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService { |
|
|
|
return execute; |
|
|
|
return execute; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String createAfterSale(StoreOrder storeOrder, User user) { |
|
|
|
private boolean createAfterSale(StoreOrder storeOrder, User user) { |
|
|
|
// WxRefundResponseVo wxRefundResponseVo = wechatNewService.payRefundQuery(storeOrder);
|
|
|
|
WxRefundQueryResponseVo vo=null; |
|
|
|
// StoreOrderRefundRequest request = new StoreOrderRefundRequest();
|
|
|
|
try { |
|
|
|
// request.setAmount(storeOrder.getRefundPrice());
|
|
|
|
vo =wechatNewService.payRefundQuery(storeOrder); |
|
|
|
// storeOrderRefundService.refund(request, storeOrder);
|
|
|
|
}catch(Exception e){ |
|
|
|
return null; |
|
|
|
log.error("查询创建/退款查询失败,订单号:{} " ,storeOrder.getOrderId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("查询创建/退款查询结果:{}" , JSON.toJSONString(vo)); |
|
|
|
|
|
|
|
if (vo==null || !"SUCCESS".equals(vo.getRefundStatus0())){ |
|
|
|
|
|
|
|
StoreOrderRefundRequest request = new StoreOrderRefundRequest(); |
|
|
|
|
|
|
|
request.setAmount(storeOrder.getRefundPrice()); |
|
|
|
|
|
|
|
storeOrderRefundService.refund(request, storeOrder); |
|
|
|
|
|
|
|
//创建申请退款后继续返回false 等下次定时任务扫描 重新查询退款成功状态返回true
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|