Browse Source

feat(app): 增加商户分账配置校验逻辑

- 在保存课程价格规则时增加商户分账信息校验- 订单处理流程中加入商户配置检查
- 引入SysDepart和SeparateAccounts相关依赖
- 使用ObjectUtil判断分账配置是否为空
- 抛出自定义异常提示商户信息未配置
wzq 6 days ago
parent
commit
2e4f3ede6b

+ 3 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java

@@ -1229,6 +1229,9 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
 
             if (depart.getSystemType() != 0) {
                 SeparateAccounts separateAccounts = separateAccountsMapper.selectOne(Wrappers.lambdaQuery(SeparateAccounts.class).eq(SeparateAccounts::getDeptId, depart.getId()));
+                if (ObjectUtil.isEmpty(separateAccounts)){
+                    throw new JeecgBootException("商户信息未配置!请联系管理员");
+                }
                 //获取分账比例
                 BigDecimal PT = separateAccounts.getPtSeparateAccounts();
                 BigDecimal SH = separateAccounts.getShSeparateAccounts();

+ 15 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoureseServiceImpl.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.system.app.service.impl;
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -26,6 +27,8 @@ import org.jeecg.modules.system.app.dto.*;
 import org.jeecg.modules.system.app.entity.*;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.app.service.IAppCoureseService;
+import org.jeecg.modules.system.entity.SysDepart;
+import org.jeecg.modules.system.mapper.SysDepartMapper;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -67,18 +70,28 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
     private FamilyMembersMapper familyMembersMapper;
     @Resource
     private AppOrderMapper appOrderMapper;
-
     @Autowired
     WxNotificationService wxNotificationService;
     @Resource
     private AppCoursesMapper appCoursesMapper;
     @Resource
     private AppDeviceMapper appDeviceMapper;
-
+    @Resource
+    private SysDepartMapper sysDepartMapper;
+    @Resource
+    private SeparateAccountsMapper separateAccountsMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean saveWitchPriceRules(AppCoursesDTO appCoursesDTO) {
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        SysDepart depart = sysDepartMapper.selectOne(Wrappers.lambdaQuery(SysDepart.class).eq(SysDepart::getOrgCode, loginUser.getOrgCode()).last("limit 1"));
+        if (depart.getSystemType() != 0) {
+            SeparateAccounts separateAccounts = separateAccountsMapper.selectOne(Wrappers.lambdaQuery(SeparateAccounts.class).eq(SeparateAccounts::getDeptId, depart.getId()));
+            if (ObjectUtil.isEmpty(separateAccounts)) {
+                throw new JeecgBootException("商户分账比例信息未配置!");
+            }
+        }
         AppCoursesCuDTO coursesCuDTO = appCoursesDTO.getCourses();
         if (null == coursesCuDTO.getCategoryId()) throw new JeecgBootException("请选择课程类别");
         AppSite site = siteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getOrgCode, coursesCuDTO.getOrgCode()));