|
@@ -489,18 +489,73 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
// 团购订单申请退款时先把占的名额还回去,SQL 内部只对未成团的团生效,已成团的不会动
|
|
// 团购订单申请退款时先把占的名额还回去,SQL 内部只对未成团的团生效,已成团的不会动
|
|
|
releaseGroupSlotIfNeeded(order);
|
|
releaseGroupSlotIfNeeded(order);
|
|
|
if (StringUtils.isNotBlank(order.getExtendOrderId())){
|
|
if (StringUtils.isNotBlank(order.getExtendOrderId())){
|
|
|
- BaseResponse response=erpOrderService.refundUpdateScrm(request);
|
|
|
|
|
- if(response.getSuccess()){
|
|
|
|
|
- return R.ok();
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
|
|
+ boolean jstCheckEnabled = isStoreJstOrderCheckEnabled();
|
|
|
|
|
+ try {
|
|
|
|
|
+ BaseResponse response = erpOrderService.refundUpdateScrm(request);
|
|
|
|
|
+ if (response.getSuccess()) {
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (jstCheckEnabled) {
|
|
|
|
|
+ markErpException(storeAfterSales.getId(), userId, response.getErrorDesc());
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return R.error(response.getErrorDesc());
|
|
return R.error(response.getErrorDesc());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("聚水潭售后同步异常,orderCode={},afterSalesId={}",
|
|
|
|
|
+ order.getOrderCode(), storeAfterSales.getId(), e);
|
|
|
|
|
+ if (jstCheckEnabled) {
|
|
|
|
|
+ markErpException(storeAfterSales.getId(), userId, e.getMessage());
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
+ return R.error("聚水潭订单同步失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否开启商城聚水潭订单校验(未取消校验时开启)
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isStoreJstOrderCheckEnabled() {
|
|
|
|
|
+ StoreConfig config = loadHisStoreConfig();
|
|
|
|
|
+ return Boolean.TRUE.equals(config.getCancelStoreJstOrderCheck());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private StoreConfig loadHisStoreConfig() {
|
|
|
|
|
+ String json = configService.selectConfigByKey("his.store");
|
|
|
|
|
+ if (StringUtils.isBlank(json)) {
|
|
|
|
|
+ return new StoreConfig();
|
|
|
|
|
+ }
|
|
|
|
|
+ return JSONUtil.toBean(json, StoreConfig.class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 标记售后单 ERP 异常并记录操作日志
|
|
|
|
|
+ */
|
|
|
|
|
+ private void markErpException(Long afterSalesId, Long userId, String errorMsg) {
|
|
|
|
|
+ FsStoreAfterSalesScrm update = new FsStoreAfterSalesScrm();
|
|
|
|
|
+ update.setId(afterSalesId);
|
|
|
|
|
+ update.setErpExceptionStatus(1);
|
|
|
|
|
+ fsStoreAfterSalesMapper.updateFsStoreAfterSales(update);
|
|
|
|
|
+
|
|
|
|
|
+ FsStoreAfterSalesStatusScrm storeAfterSalesStatus = new FsStoreAfterSalesStatusScrm();
|
|
|
|
|
+ storeAfterSalesStatus.setStoreAfterSalesId(afterSalesId);
|
|
|
|
|
+ storeAfterSalesStatus.setChangeType(0);
|
|
|
|
|
+ String message = "聚水潭订单同步异常"
|
|
|
|
|
+ + (StringUtils.isNotBlank(errorMsg) ? ":" + errorMsg : "");
|
|
|
|
|
+ storeAfterSalesStatus.setChangeMessage(message);
|
|
|
|
|
+ storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ FsUserScrm user = userService.selectFsUserById(userId);
|
|
|
|
|
+ if (user != null) {
|
|
|
|
|
+ storeAfterSalesStatus.setOperator(user.getNickname());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ afterSalesStatusService.insertFsStoreAfterSalesStatus(storeAfterSalesStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 团购订单申请退款时还回占的名额。
|
|
* 团购订单申请退款时还回占的名额。
|
|
|
* <p>仅对 orderType=8 且已有 groupBuyId 的订单生效;
|
|
* <p>仅对 orderType=8 且已有 groupBuyId 的订单生效;
|
|
@@ -1284,6 +1339,36 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
return fsStoreAfterSalesMapper.selectFsStoreAfterSalesVOByOrderCode(orderCode);
|
|
return fsStoreAfterSalesMapper.selectFsStoreAfterSalesVOByOrderCode(orderCode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R updateErpExceptionStatus(FsStoreAfterSalesErpStatusParam param) {
|
|
|
|
|
+ if (param.getSalesId() == null) {
|
|
|
|
|
+ return R.error("售后单ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (param.getErpExceptionStatus() == null
|
|
|
|
|
+ || (param.getErpExceptionStatus() != 1 && param.getErpExceptionStatus() != 2)) {
|
|
|
|
|
+ return R.error("ERP异常状态无效");
|
|
|
|
|
+ }
|
|
|
|
|
+ FsStoreAfterSalesScrm storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
|
|
|
+ if (storeAfterSales == null) {
|
|
|
|
|
+ return R.error("未查询到售后订单信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ FsStoreAfterSalesScrm update = new FsStoreAfterSalesScrm();
|
|
|
|
|
+ update.setId(param.getSalesId());
|
|
|
|
|
+ update.setErpExceptionStatus(param.getErpExceptionStatus());
|
|
|
|
|
+ fsStoreAfterSalesMapper.updateFsStoreAfterSales(update);
|
|
|
|
|
+
|
|
|
|
|
+ FsStoreAfterSalesStatusScrm storeAfterSalesStatus = new FsStoreAfterSalesStatusScrm();
|
|
|
|
|
+ storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId());
|
|
|
|
|
+ storeAfterSalesStatus.setChangeType(0);
|
|
|
|
|
+ storeAfterSalesStatus.setChangeMessage(param.getErpExceptionStatus() == 2
|
|
|
|
|
+ ? "ERP订单状态确认:通过"
|
|
|
|
|
+ : "ERP订单状态确认:不通过");
|
|
|
|
|
+ storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
|
|
|
|
|
+ storeAfterSalesStatus.setOperator(param.getOperator());
|
|
|
|
|
+ afterSalesStatusService.insertFsStoreAfterSalesStatus(storeAfterSalesStatus);
|
|
|
|
|
+ return R.ok("操作成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public R audit1(FsStoreAfterSalesAudit1Param param) {
|
|
public R audit1(FsStoreAfterSalesAudit1Param param) {
|
|
|
FsStoreAfterSalesScrm storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
FsStoreAfterSalesScrm storeAfterSales = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(param.getSalesId());
|
|
@@ -1293,6 +1378,9 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
if (!storeAfterSales.getStatus().equals(AfterStatusEnum.STATUS_0.getValue())) {
|
|
if (!storeAfterSales.getStatus().equals(AfterStatusEnum.STATUS_0.getValue())) {
|
|
|
throw new CustomException("非法操作");
|
|
throw new CustomException("非法操作");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (storeAfterSales.getErpExceptionStatus() != null && storeAfterSales.getErpExceptionStatus() == 1) {
|
|
|
|
|
+ throw new CustomException("订单ERP异常未处理,请先确认ERP订单状态");
|
|
|
|
|
+ }
|
|
|
//仅退款
|
|
//仅退款
|
|
|
if(storeAfterSales.getServiceType().equals(0)){
|
|
if(storeAfterSales.getServiceType().equals(0)){
|
|
|
//仅退款未发货处理
|
|
//仅退款未发货处理
|