Bläddra i källkod

feat: 售后修复

xdd 1 månad sedan
förälder
incheckning
b52082b7c3

+ 19 - 11
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.store.mapper.FsStoreAfterSalesMapper;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
@@ -181,7 +182,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
     }
 
     @Override
-    @Transactional
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
     public R applyForAfterSales(long userId, FsStoreAfterSalesParam storeAfterSalesParam) {
         logger.info("申请退款请求信息:"+JSONUtil.toJsonStr(storeAfterSalesParam));
         FsStoreOrder order=orderService.selectFsStoreOrderByOrderCode(storeAfterSalesParam.getOrderCode());
@@ -189,15 +190,23 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
             throw new CustomException("非法操作");
         }
 
-        if (order.getCompanyId()==null||order.getCompanyUserId()==null){
-            if (Objects.equals(order.getStatus(), OrderInfoEnum.STATUS_0.getValue())){
-                throw new CustomException("不可申请售后");
-            }
-
-        }
-        if(order.getStatus()==0){
-            return R.error("未支付订单不能申请售后");
+        Set<Integer> notAllowRefundStatusSet = new HashSet<>();
+        notAllowRefundStatusSet.add(-1);
+        notAllowRefundStatusSet.add(-2);
+        notAllowRefundStatusSet.add(-3);
+        notAllowRefundStatusSet.add(0);
+        notAllowRefundStatusSet.add(3);
+        if(notAllowRefundStatusSet.contains(order.getStatus())){
+            throw new CustomException("该订单不可申请售后");
         }
+//        if (order.getCompanyId()==null||order.getCompanyUserId()==null){
+//            if(notAllowRefundStatusSet.contains(order.getStatus())){
+//                throw new CustomException("不可申请售后");
+//            }
+//        }
+//        if(order.getStatus()==0){
+//            return R.error("未支付订单不能申请售后");
+//        }
         if(StringUtils.isEmpty(order.getExtendOrderId())){
             return R.error("仓库未生成订单,暂时不能申请退款,请联系客服");
         }
@@ -307,8 +316,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService
             return R.ok();
         }
         else{
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return R.error(response.getErrorDesc());
+            throw new CustomException(response.getErrorDesc());
         }
 
     }