3 Commits 84ad2ec895 ... 3df343779d

Author SHA1 Message Date
  xw 3df343779d . 1 day ago
  xw acc3c6d137 feat(payment): 优化退款审核逻辑与分账处理 1 day ago
  xw 3def66c40c 更新权限 1 day ago

+ 0 - 1
fs-admin/src/main/java/com/fs/his/controller/FsCompanyController.java

@@ -245,7 +245,6 @@ public class FsCompanyController extends BaseController {
     /**
      * 获取公司分账配置详细信息
      */
-    @PreAuthorize("@ss.hasPermi('his:companyDivConfig:query')")
     @GetMapping(value = "/getDivConfig/{companyId}")
     public AjaxResult getDivConfig(@PathVariable("companyId") Long companyId)
     {

+ 4 - 4
fs-admin/src/main/java/com/fs/hisStore/controller/FsStorePaymentScrmController.java

@@ -197,10 +197,10 @@ public class FsStorePaymentScrmController extends BaseController
             return R.error("非法操作");
         }
 
-        // 检查退款审核状态
-        if(payment.getRefundAuditStatus() == null || payment.getRefundAuditStatus() != 1){
-            return R.error("退款申请尚未审核或审核未通过,不能执行退款");
-        }
+//        // 检查退款审核状态
+//        if(payment.getRefundAuditStatus() == null || payment.getRefundAuditStatus() != 1){
+//            return R.error("退款申请尚未审核或审核未通过,不能执行退款");
+//        }
 
         if(fsStorePayment.getRefundMoney().compareTo(new BigDecimal(0))<1){
             return R.error("退款金额必须大于0");

+ 26 - 4
fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/utils/HuiFuUtils.java

@@ -11,10 +11,8 @@ import com.fs.company.service.ICompanyDivConfigService;
 import com.fs.company.service.ICompanyDivItemService;
 import com.fs.company.service.impl.CompanyDivConfigServiceImpl;
 import com.fs.company.vo.CompanyDivConfigVo;
-import com.fs.his.domain.FsPackageOrder;
-import com.fs.his.domain.FsPayConfig;
-import com.fs.his.domain.FsStoreOrder;
-import com.fs.his.domain.FsStorePayment;
+import com.fs.his.domain.*;
+import com.fs.his.mapper.FsHfpayConfigMapper;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
@@ -41,7 +39,17 @@ public class HuiFuUtils {
         SysConfigMapper sysConfigMapper= SpringUtils.getBean(SysConfigMapper.class);
         SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
         FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+        
+        // 根据appId动态获取主商户号
         String defaultHuifuId = fsPayConfig.getHuifuId();
+        if (StringUtils.isNotBlank(huiFuCreateOrder.getAppId())) {
+            // 如果有appId,查询对应的汇付支付配置
+            FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
+            FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(huiFuCreateOrder.getAppId());
+            if (fsHfpayConfig != null && StringUtils.isNotBlank(fsHfpayConfig.getHuifuId())) {
+                defaultHuifuId = fsHfpayConfig.getHuifuId();
+            }
+        }
         //查询是否开启分账
         if (companyId !=null){
 
@@ -90,6 +98,13 @@ public class HuiFuUtils {
                                     defaultAccount.put("percentage_div", String.format("%.2f", 100f - total));
                                     defaultAccount.put("huifu_id", defaultHuifuId);
                                     acctInfos.add(defaultAccount);
+                                } else {
+                                    // 即使没有其他分账接收方,也要包含主商户号,分账比例为0
+                                    acctInfos = new ArrayList<>();
+                                    Map<String, Object> defaultAccount = new HashMap<>();
+                                    defaultAccount.put("percentage_div", "0.00");
+                                    defaultAccount.put("huifu_id", defaultHuifuId);
+                                    acctInfos.add(defaultAccount);
                                 }
 
 
@@ -126,6 +141,13 @@ public class HuiFuUtils {
                                         defaultAccount.put("huifu_id", defaultHuifuId);
                                         acctInfos.add(defaultAccount);
                                     }
+                                } else {
+                                    // 即使没有其他分账接收方,也要包含主商户号,分账金额为0
+                                    acctInfos = new ArrayList<>();
+                                    Map<String, Object> defaultAccount = new HashMap<>();
+                                    defaultAccount.put("div_amt", "0.00");
+                                    defaultAccount.put("huifu_id", defaultHuifuId);
+                                    acctInfos.add(defaultAccount);
                                 }
 
                             }

+ 35 - 0
fs-service/src/main/java/com/fs/sop/service/impl/SopUserLogsServiceImpl.java

@@ -129,6 +129,41 @@ public class SopUserLogsServiceImpl  implements ISopUserLogsService {
         //删除营期详情用户
         sopUserLogsInfoMapper.deleteSopUserLogsInfoByUserLogsIds(ids);
 
+        // 查询被删除营期的chatId,并更新qw_sop表
+        List<SopUserLogs> deletedLogs = sopUserLogsMapper.getSopUserLogsInfoById(ids);
+        if (deletedLogs != null && !deletedLogs.isEmpty()) {
+            // 按sopId分组,收集要删除的chatId
+            Map<String, List<String>> sopChatMap = new HashMap<>();
+            for (SopUserLogs log : deletedLogs) {
+                if (!StringUtil.strIsNullOrEmpty(log.getChatId())) {
+                    sopChatMap.computeIfAbsent(log.getSopId(), k -> new ArrayList<>())
+                            .add(log.getChatId());
+                }
+            }
+            
+            // 更新每个sop的chatId,移除已删除的chatId
+            for (Map.Entry<String, List<String>> entry : sopChatMap.entrySet()) {
+                String sopId = entry.getKey();
+                List<String> deletedChatIds = entry.getValue();
+                
+                // 查询当前sop的chatId
+                QwSop qwSop = sopMapper.selectQwSopById(sopId);
+                if (qwSop != null && !StringUtil.strIsNullOrEmpty(qwSop.getChatId())) {
+                    // 将chatId字符串转为列表
+                    List<String> currentChatIds = new ArrayList<>(Arrays.asList(qwSop.getChatId().split(",")));
+                    
+                    // 移除被删除的chatId
+                    currentChatIds.removeAll(deletedChatIds);
+                    
+                    // 更新sop的chatId
+                    QwSop updateSop = new QwSop();
+                    updateSop.setId(sopId);
+                    updateSop.setChatId(currentChatIds.isEmpty() ? "" : String.join(",", currentChatIds));
+                    sopMapper.updateQwSop(updateSop);
+                }
+            }
+        }
+
         return sopUserLogsMapper.deleteSopUserLogsByIds(ids);
     }