|
@@ -10,7 +10,6 @@ import java.util.*;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fs.common.annotation.DataScope;
|
|
import com.fs.common.annotation.DataScope;
|
|
@@ -20,10 +19,15 @@ import com.fs.common.exception.CustomException;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.company.service.ICompanyService;
|
|
import com.fs.company.service.ICompanyService;
|
|
|
|
+import com.fs.erp.constant.AfterSalesOrderStatusEnum;
|
|
|
|
+import com.fs.erp.constant.ErpTypeConstant;
|
|
|
|
+import com.fs.erp.domain.FsJstAftersalePush;
|
|
import com.fs.erp.dto.BaseResponse;
|
|
import com.fs.erp.dto.BaseResponse;
|
|
import com.fs.erp.dto.ErpRefundUpdateRequest;
|
|
import com.fs.erp.dto.ErpRefundUpdateRequest;
|
|
|
|
+import com.fs.erp.mapper.FsJstAftersalePushMapper;
|
|
import com.fs.erp.service.IErpOrderService;
|
|
import com.fs.erp.service.IErpOrderService;
|
|
import com.fs.erp.utils.ErpContextHolder;
|
|
import com.fs.erp.utils.ErpContextHolder;
|
|
|
|
+import com.fs.express.enums.TaskStatusEnum;
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
import com.fs.huifuPay.dto.*;
|
|
import com.fs.huifuPay.dto.*;
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
@@ -51,7 +55,9 @@ import com.hc.openapi.tool.fastjson.JSON;
|
|
import lombok.Synchronized;
|
|
import lombok.Synchronized;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.aop.framework.AopContext;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.fs.store.mapper.FsStoreAfterSalesMapper;
|
|
import com.fs.store.mapper.FsStoreAfterSalesMapper;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -65,6 +71,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
* @date 2022-03-15
|
|
* @date 2022-03-15
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@EnableAspectJAutoProxy(proxyTargetClass = true,exposeProxy = true)
|
|
public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
{
|
|
{
|
|
Logger logger= LoggerFactory.getLogger(getClass());
|
|
Logger logger= LoggerFactory.getLogger(getClass());
|
|
@@ -111,6 +118,8 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FsWarehousesMapper fsWarehousesMapper;
|
|
private FsWarehousesMapper fsWarehousesMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private FsJstAftersalePushMapper fsJstAftersalePushMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -333,9 +342,8 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
- @Synchronized
|
|
|
|
@RepeatSubmit
|
|
@RepeatSubmit
|
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
public R revoke(long userId, Long id) throws ParseException {
|
|
public R revoke(long userId, Long id) throws ParseException {
|
|
FsStoreAfterSales storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(id);
|
|
FsStoreAfterSales storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(id);
|
|
if (storeAfterSales == null) {
|
|
if (storeAfterSales == null) {
|
|
@@ -383,20 +391,21 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fsStoreAfterSalesMapper.updateFsStoreAfterSales(storeAfterSales);
|
|
fsStoreAfterSalesMapper.updateFsStoreAfterSales(storeAfterSales);
|
|
|
|
+
|
|
|
|
+ // erp撤销售后单
|
|
|
|
+ // 如果当前订单是属于jst erp
|
|
|
|
+ if(StringUtils.isNotBlank(order.getStoreHouseCode())){
|
|
|
|
+ String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
|
|
|
|
+ if(StringUtils.equals(erp, ErpTypeConstant.JST_ERP)){
|
|
|
|
+ FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
|
|
|
|
+ fsJstAftersalePush.setOrderId(order.getOrderCode());
|
|
|
|
+ fsJstAftersalePush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
|
|
|
|
+ fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.CLOSED.getIndex()));
|
|
|
|
+ fsJstAftersalePush.setRetryCount(0);
|
|
|
|
+ fsJstAftersalePushMapper.insert(fsJstAftersalePush);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return R.ok();
|
|
return R.ok();
|
|
-// //更新OMS
|
|
|
|
-// ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
|
|
|
|
-// request.setTid(order.getOrderCode());
|
|
|
|
-// request.setOid(order.getOrderCode());
|
|
|
|
-// request.setRefund_state(0);
|
|
|
|
-// BaseResponse response= erpOrderService.refundUpdate(request);
|
|
|
|
-// if(response.getSuccess()){
|
|
|
|
-// return R.ok();
|
|
|
|
-// }
|
|
|
|
-// else{
|
|
|
|
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
-// return R.error(response.getErrorDesc());
|
|
|
|
-// }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -412,6 +421,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
public R addDelivery(FsStoreAfterSalesDeliveryParam param) {
|
|
public R addDelivery(FsStoreAfterSalesDeliveryParam param) {
|
|
FsStoreAfterSales storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
FsStoreAfterSales storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
if (storeAfterSales == null) {
|
|
if (storeAfterSales == null) {
|
|
@@ -434,6 +444,20 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
storeAfterSalesStatus.setOperator(user.getNickname());
|
|
storeAfterSalesStatus.setOperator(user.getNickname());
|
|
afterSalesStatusService.insertFsStoreAfterSalesStatus(storeAfterSalesStatus);
|
|
afterSalesStatusService.insertFsStoreAfterSalesStatus(storeAfterSalesStatus);
|
|
fsStoreAfterSalesMapper.updateFsStoreAfterSales(storeAfterSales);
|
|
fsStoreAfterSalesMapper.updateFsStoreAfterSales(storeAfterSales);
|
|
|
|
+ FsStoreOrder order = fsStoreOrderService.selectFsStoreOrderByOrderCode(storeAfterSales.getOrderCode());
|
|
|
|
+
|
|
|
|
+ // 如果当前订单是属于jst erp
|
|
|
|
+ if(order != null && StringUtils.isNotBlank(order.getStoreHouseCode())){
|
|
|
|
+ String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
|
|
|
|
+ if(StringUtils.equals(erp, ErpTypeConstant.JST_ERP)){
|
|
|
|
+ FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
|
|
|
|
+ fsJstAftersalePush.setOrderId(order.getOrderCode());
|
|
|
|
+ fsJstAftersalePush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
|
|
|
|
+ fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.WAIT_SELLER_CONFIRM_GOODS.getIndex()));
|
|
|
|
+ fsJstAftersalePush.setRetryCount(0);
|
|
|
|
+ fsJstAftersalePushMapper.insert(fsJstAftersalePush);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -552,10 +576,12 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public synchronized R refundMoney(FsStoreAfterSalesRefundParam param) {
|
|
public synchronized R refundMoney(FsStoreAfterSalesRefundParam param) {
|
|
- return refundStoreMoney(param);
|
|
|
|
|
|
+ IFsStoreAfterSalesService fsStoreAfterSalesService = (IFsStoreAfterSalesService) AopContext.currentProxy();
|
|
|
|
+ return fsStoreAfterSalesService.refundStoreMoney(param);
|
|
}
|
|
}
|
|
- @Transactional
|
|
|
|
- R refundStoreMoney(FsStoreAfterSalesRefundParam param){
|
|
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
|
|
+ public R refundStoreMoney(FsStoreAfterSalesRefundParam param){
|
|
FsStoreAfterSales storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
FsStoreAfterSales storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
if (storeAfterSales == null) {
|
|
if (storeAfterSales == null) {
|
|
throw new CustomException("未查询到售后订单信息");
|
|
throw new CustomException("未查询到售后订单信息");
|
|
@@ -682,6 +708,27 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
if(order.getTuiUserId()!=null&&order.getTuiUserId()>0){
|
|
if(order.getTuiUserId()!=null&&order.getTuiUserId()>0){
|
|
userService.subTuiMoney(order);
|
|
userService.subTuiMoney(order);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 财务审核通过,同步到jst erp
|
|
|
|
+ if(StringUtils.isNotBlank(order.getStoreHouseCode())){
|
|
|
|
+ String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
|
|
|
|
+ if(StringUtils.equals(erp, ErpTypeConstant.JST_ERP)){
|
|
|
|
+ FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
|
|
|
|
+ fsJstAftersalePush.setOrderId(order.getOrderCode());
|
|
|
|
+ fsJstAftersalePush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
|
|
|
|
+ fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.SUCCESS.getIndex()));
|
|
|
|
+ fsJstAftersalePush.setRetryCount(0);
|
|
|
|
+ fsJstAftersalePushMapper.insert(fsJstAftersalePush);
|
|
|
|
+
|
|
|
|
+ // 售后单改成已确认
|
|
|
|
+ FsJstAftersalePush aftersaleConfirm = new FsJstAftersalePush();
|
|
|
|
+ aftersaleConfirm.setOrderId(order.getOrderCode());
|
|
|
|
+ aftersaleConfirm.setTaskStatus(TaskStatusEnum.PENDING.getCode());
|
|
|
|
+ aftersaleConfirm.setType(String.valueOf(AfterSalesOrderStatusEnum.CONFIRM.getIndex()));
|
|
|
|
+ aftersaleConfirm.setRetryCount(0);
|
|
|
|
+ fsJstAftersalePushMapper.insert(aftersaleConfirm);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -709,29 +756,37 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
|
|
storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
|
|
storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
|
|
storeAfterSalesStatus.setOperator(param.getOperator());
|
|
storeAfterSalesStatus.setOperator(param.getOperator());
|
|
afterSalesStatusService.insertFsStoreAfterSalesStatus(storeAfterSalesStatus);
|
|
afterSalesStatusService.insertFsStoreAfterSalesStatus(storeAfterSalesStatus);
|
|
- //创建新的OMS订单
|
|
|
|
- if (storeAfterSales.getOrderStatus().equals(OrderInfoEnum.STATUS_1.getValue()) ) {
|
|
|
|
- if(StringUtils.isNotEmpty(order.getExtendOrderId())){
|
|
|
|
- //更新订单code
|
|
|
|
- String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
|
- FsStoreOrder orderMap=new FsStoreOrder();
|
|
|
|
- orderMap.setId(order.getId());
|
|
|
|
- orderMap.setOrderCode(orderSn);
|
|
|
|
- orderService.updateFsStoreOrder(orderMap);
|
|
|
|
- storeAfterSales.setOrderCode(orderSn);
|
|
|
|
- orderItemService.updateFsStoreOrderCode(order.getId(),orderSn);
|
|
|
|
- //生成新的订单
|
|
|
|
- orderService.createOmsOrder(order.getId());
|
|
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotBlank(order.getStoreHouseCode())) {
|
|
|
|
+ String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
|
|
|
|
+ if (StringUtils.equals(erp, ErpTypeConstant.JST_ERP)) {
|
|
|
|
+ FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
|
|
|
|
+ fsJstAftersalePush.setOrderId(order.getOrderCode());
|
|
|
|
+ fsJstAftersalePush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
|
|
|
|
+ fsJstAftersalePush.setType(String.valueOf(AfterSalesOrderStatusEnum.CLOSED.getIndex()));
|
|
|
|
+ fsJstAftersalePush.setRetryCount(0);
|
|
|
|
+ fsJstAftersalePushMapper.insert(fsJstAftersalePush);
|
|
|
|
+ } else {
|
|
|
|
+ //创建新的OMS订单
|
|
|
|
+ if (storeAfterSales.getOrderStatus().equals(OrderInfoEnum.STATUS_1.getValue()) ) {
|
|
|
|
+ if(StringUtils.isNotEmpty(order.getExtendOrderId())){
|
|
|
|
+ //更新订单code
|
|
|
|
+ String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
|
+ FsStoreOrder orderMap=new FsStoreOrder();
|
|
|
|
+ orderMap.setId(order.getId());
|
|
|
|
+ orderMap.setOrderCode(orderSn);
|
|
|
|
+ orderService.updateFsStoreOrder(orderMap);
|
|
|
|
+ storeAfterSales.setOrderCode(orderSn);
|
|
|
|
+ orderItemService.updateFsStoreOrderCode(order.getId(),orderSn);
|
|
|
|
+ //生成新的订单
|
|
|
|
+ orderService.createOmsOrder(order.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
fsStoreAfterSalesMapper.updateFsStoreAfterSales(storeAfterSales);
|
|
fsStoreAfterSalesMapper.updateFsStoreAfterSales(storeAfterSales);
|
|
return R.ok();
|
|
return R.ok();
|
|
-
|
|
|
|
-// ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
|
|
|
|
-// request.setTid(order.getOrderCode());
|
|
|
|
-// request.setOid(order.getOrderCode());
|
|
|
|
-// request.setRefund_state(0);
|
|
|
|
-// erpOrderService.refundUpdate(request);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|