Explorar o código

update:已经有未处理的申请退款 不允许再申请了

ct hai 2 semanas
pai
achega
a311d876f3

+ 2 - 0
fs-service/src/main/java/com/fs/his/mapper/FsStoreAfterSalesMapper.java

@@ -294,4 +294,6 @@ public interface FsStoreAfterSalesMapper
     List<FsStoreOrderStatisticsVO> selectFsPackageOrderStatisticsList(@Param("maps")FsStoreStatisticsParam param);
 
     List<JSONObject> selectFsStoreAfterSales(Map<String, Object> map);
+
+    List<FsStoreAfterSales> selectFsStoreAfterSalesByOrderIdUnFinish(@Param("orderId")Long orderId);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/service/IFsStoreAfterSalesService.java

@@ -108,4 +108,6 @@ public interface IFsStoreAfterSalesService
     List<FsStoreOrderStatisticsVO> selectFsStoreAfterSalesServiceStatisticsList(FsStoreStatisticsParam param);
 
     List<JSONObject> selectFsStoreAfterSales(Map<String, Object> map);
+
+    List<FsStoreAfterSales> selectFsStoreAfterSalesByOrderIdUnFinish(Long orderId);
 }

+ 10 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -650,6 +650,11 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         if (!order.getUserId().equals(uesrId)) {
             throw new CustomException("非法操作");
         }
+        //查询是否已经存在未处理的售后
+        List<FsStoreAfterSales> unFinishList = fsStoreAfterSalesMapper.selectFsStoreAfterSalesByOrderIdUnFinish(order.getOrderId());
+        if (unFinishList != null && !unFinishList.isEmpty()) {
+            throw new CustomException("已有未处理售后订单,订单不可提交售后");
+        }
         if (!CloudHostUtils.hasCloudHostName("金牛明医") && order.getOrderType().equals(2)) {
             return R.error("中药订单不允许发起售后");
         }
@@ -999,4 +1004,9 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     public List<JSONObject> selectFsStoreAfterSales(Map<String, Object> map) {
         return fsStoreAfterSalesMapper.selectFsStoreAfterSales(map);
     }
+
+    @Override
+    public List<FsStoreAfterSales> selectFsStoreAfterSalesByOrderIdUnFinish(Long orderId) {
+        return fsStoreAfterSalesMapper.selectFsStoreAfterSalesByOrderIdUnFinish(orderId);
+    }
 }

+ 15 - 3
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -1823,8 +1823,15 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
         if (order.getStatus() < 0) {
             throw new CustomException("订单不可提交售后");
         }
+        Long orderId = order.getOrderId();
+        //查询是否已经存在未处理的售后
+        List<FsStoreAfterSales> unFinishList = fsStoreAfterSalesService.selectFsStoreAfterSalesByOrderIdUnFinish(orderId);
+        if (unFinishList != null && !unFinishList.isEmpty()) {
+            throw new CustomException("已有未处理售后订单,订单不可提交售后");
+        }
+
         FsStoreAfterSales fsStoreAfterSales = new FsStoreAfterSales();
-        fsStoreAfterSales.setOrderId(order.getOrderId());
+        fsStoreAfterSales.setOrderId(orderId);
         fsStoreAfterSales.setStoreId(order.getStoreId());
         fsStoreAfterSales.setRefundAmount(order.getPayMoney());
         fsStoreAfterSales.setCreateTime(DateUtils.getNowDate());
@@ -1847,7 +1854,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
         fsStoreAfterSales.setCompanyUserId(order.getCompanyUserId());
         fsStoreAfterSales.setIsDel(0);
         fsStoreAfterSalesService.insertFsStoreAfterSales(fsStoreAfterSales);
-        List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemMapper.selectFsStoreOrderItemListByOrderId(order.getOrderId());
+        List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemMapper.selectFsStoreOrderItemListByOrderId(orderId);
         for (FsStoreOrderItem fsStoreOrderItem : fsStoreOrderItems) {
             FsStoreAfterSalesItem item = new FsStoreAfterSalesItem();
             item.setAfterSalesId(fsStoreAfterSales.getId());
@@ -1865,7 +1872,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
         logs.setChangeMessage("平台提交售后");
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
         //添加订单日志
-        fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.REFUND_ORDER_PLATFORM.getValue(),
+        fsStoreOrderLogsService.create(orderId, FsStoreOrderLogEnum.REFUND_ORDER_PLATFORM.getValue(),
                 fsStoreOrderSalesParam.getOperator() + " " +FsStoreOrderLogEnum.REFUND_ORDER_PLATFORM.getDesc());
         //判断是否开启erp
         FsSysConfig sysConfig = configUtil.getSysConfig();
@@ -4090,6 +4097,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
         if (order.getStatus() < 0) {
             throw new CustomException("订单不可提交售后");
         }
+        //查询是否已经存在未处理的售后
+        List<FsStoreAfterSales> unFinishList = fsStoreAfterSalesService.selectFsStoreAfterSalesByOrderIdUnFinish(order.getOrderId());
+        if (unFinishList != null && !unFinishList.isEmpty()) {
+            throw new CustomException("已有未处理售后订单,订单不可提交售后");
+        }
         //判断总退款金额是否小于等于实付金额
         BigDecimal refundAmount = param.getRefundAmount();
         if (refundAmount.compareTo(order.getPayMoney())>0){

+ 3 - 0
fs-service/src/main/resources/mapper/his/FsStoreAfterSalesMapper.xml

@@ -98,6 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ) t
         GROUP BY t.type
     </select>
+    <select id="selectFsStoreAfterSalesByOrderIdUnFinish" resultType="com.fs.his.domain.FsStoreAfterSales">
+        SELECT * FROM fs_store_after_sales WHERE order_id = #{orderId} AND `status` &lt; 4 and is_del = 0
+    </select>
 
     <insert id="insertFsStoreAfterSales" parameterType="FsStoreAfterSales" useGeneratedKeys="true" keyProperty="id">
         insert into fs_store_after_sales