소스 검색

feat(national-motion-system):增加课程排序功能并优化订单相关逻辑

- 在 AppCoursesRuleDTO 中添加 sort 字段,用于课程排序
- 优化 AppCoursesVerificationRecordServiceImpl 中的订单状态更新逻辑
- 在 AppOrderServiceImpl 中增加对赛事券号核销权限的判断
- 修改 OrderServiceImpl 中的订单创建逻辑,根据订单类型选择合适的课程价格规则
- 新增分账订单信息表和相关字段,为后续的分账功能做准备
wzq 4 일 전
부모
커밋
fd5689ba5b

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

@@ -48,7 +48,6 @@ import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.mapper.SysDepartMapper;
 import org.jeecg.modules.system.mapper.SysUserMapper;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -129,14 +128,12 @@ public class OrderServiceImpl implements IOrderService {
     private WechatPayV3Utils wechatPayV3Utils;
     @Resource
     private EvaluateMapper evaluateMapper;
-
-    @Autowired
-    IReceiptPaymentDetailsInfoService iReceiptPaymentDetailsInfoService;
-
-    @Autowired
-    SysDepartMapper sysDepartMapper;
-    @Autowired
-    SeparateAccountsMapper separateAccountsMapper;
+    @Resource
+    private IReceiptPaymentDetailsInfoService iReceiptPaymentDetailsInfoService;
+    @Resource
+    private SysDepartMapper sysDepartMapper;
+    @Resource
+    private SeparateAccountsMapper separateAccountsMapper;
 
 
     @Override
@@ -630,7 +627,6 @@ public class OrderServiceImpl implements IOrderService {
 
                     //订单总价(商品的售价总和)
                     BigDecimal sumPrice = BigDecimal.ZERO;
-                    ;
 
                     for (int i = 0; i < list.size(); i++) {
                         AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(list.get(i).split("\\|")[0]);
@@ -901,12 +897,15 @@ public class OrderServiceImpl implements IOrderService {
                     List<AppOrderProInfo> infos = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery()
                             .eq(AppOrderProInfo::getProductId, appCourse.getId())
                             .eq(AppOrderProInfo::getFamilyUserId, familyUserId));
-                    List<AppOrderProInfo> infoList = infos.stream().filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT)).collect(Collectors.toList());
+                    List<AppOrderProInfo> infoList = infos.stream().filter(info -> Objects.equals(info.getOrFreePro()
+                            , CommonConstant.STATUS_0_INT) && !Objects.equals(info.getOrderStatus(), CommonConstant.ORDER_PRO_INFO_TYPE_4)).collect(Collectors.toList());
                     if (ObjectUtil.isNotEmpty(infoList)) {
                         throw new JeecgBootException("当前课程已下过单,请勿重复下单");
                     }
                     if (Objects.equals(createOrderForm.getOrFreeOrder(), CommonConstant.STATUS_1_INT)) {
-                        List<AppOrderProInfo> freeProList = infos.stream().filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT)).collect(Collectors.toList());
+                        List<AppOrderProInfo> freeProList = infos.stream()
+                                .filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT) && !Objects.equals(info.getOrderStatus(), CommonConstant.ORDER_PRO_INFO_TYPE_4))
+                                .collect(Collectors.toList());
                         if (ObjectUtil.isNotEmpty(freeProList)) {
                             throw new JeecgBootException("当前试听课课程已下过单,请勿重复下单");
                         }
@@ -931,7 +930,29 @@ public class OrderServiceImpl implements IOrderService {
 
                     //创建核销记录
                     if (CollUtil.isNotEmpty(priceRulesList)) {
-                        for (AppCoursesPriceRules appCoursesPriceRules : priceRulesList) {
+
+                        if (Objects.equals(appOrder.getOrderOrFree(), CommonConstant.STATUS_0_INT)) {
+                            for (AppCoursesPriceRules appCoursesPriceRules : priceRulesList) {
+                                AppCoursesVerificationRecord appCoursesVerificationRecord = new AppCoursesVerificationRecord();
+                                appCoursesVerificationRecord.setCoursesId(appCourse.getId());
+                                appCoursesVerificationRecord.setCoursesPriceRuleId(appCoursesPriceRules.getId());
+                                appCoursesVerificationRecord.setCoursesName(appCoursesPriceRules.getName());
+                                appCoursesVerificationRecord.setCoursesStartTime(appCoursesPriceRules.getStartTime());
+                                appCoursesVerificationRecord.setCoursesEndTime(appCoursesPriceRules.getEndTime());
+                                appCoursesVerificationRecord.setUseUserId(familyUserId);
+                                appCoursesVerificationRecord.setUseUserName(familyMembers.getFullName());
+                                appCoursesVerificationRecord.setUseUserPhone(familyMembers.getPhone());
+                                appCoursesVerificationRecord.setUseUserImage(familyMembers.getRealNameImg());
+                                appCoursesVerificationRecord.setUseUserName(familyMembers.getFullName());
+                                appCoursesVerificationRecord.setVerifyStatus(0);
+                                appCoursesVerificationRecord.setOrPostpone(0);
+                                appCoursesVerificationRecord.setCoursesType(appCoursesPriceRules.getCoursesType());
+                                appCoursesVerificationRecordList.add(appCoursesVerificationRecord);
+                            }
+                        }
+                        if (Objects.equals(appOrder.getOrderOrFree(), CommonConstant.STATUS_1_INT)) {
+                            priceRulesList.sort(Comparator.comparing(AppCoursesPriceRules::getSort));
+                            AppCoursesPriceRules appCoursesPriceRules = priceRulesList.get(0);
                             AppCoursesVerificationRecord appCoursesVerificationRecord = new AppCoursesVerificationRecord();
                             appCoursesVerificationRecord.setCoursesId(appCourse.getId());
                             appCoursesVerificationRecord.setCoursesPriceRuleId(appCoursesPriceRules.getId());
@@ -993,7 +1014,6 @@ public class OrderServiceImpl implements IOrderService {
                 break;
         }
 
-
         //构建保单内容
         InsureOrderInfoForm insureOrderInfoForm = createOrderForm.getInsureOrderInfoForm();
         if (ObjectUtils.isNotEmpty(insureOrderInfoForm)) {
@@ -1094,6 +1114,7 @@ public class OrderServiceImpl implements IOrderService {
                 }
             }
             if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_6)) {
+                AppSite appSite = appSiteMapper.selectById(appCoursesMapper.selectById(appOrderProInfo.getProductId()).getAddressSiteId());
                 //订单券号记录
                 AppIsin appIsin = new AppIsin();
                 appIsin
@@ -1104,7 +1125,7 @@ public class OrderServiceImpl implements IOrderService {
                         .setFamilyId(appOrderProInfo.getFamilyUserId())
                         .setFamilyUserName(appOrderProInfo.getUserName())
                         .setUserPhone(appOrderProInfo.getUserPhone())
-                        .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
+                        .setUseAddress(appSite.getName())
                         //过期时间
                         .setExpireTime(appOrderProInfo.getExpireTime())
                         //生成10位随机券号

+ 4 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppCoursesRuleDTO.java

@@ -32,6 +32,10 @@ public class AppCoursesRuleDTO {
     @Excel(name = "名称", width = 15)
     @Schema(description = "名称")
     private String name;
+
+    @Excel(name = "排序", width = 15)
+    @Schema(description = "排序")
+    private Integer sort;
     /**开始时间*/
     @Excel(name = "开始时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

+ 20 - 14
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoursesVerificationRecordServiceImpl.java

@@ -87,25 +87,31 @@ public class AppCoursesVerificationRecordServiceImpl extends ServiceImpl<AppCour
                 //修改订单状态
                 String useUserId = verificationRecord.getUseUserId();
                 String coursesId = verificationRecord.getCoursesId();
-                AppOrderProInfo orderProInfo = appOrderProInfoMapper.selectOne(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getFamilyUserId, useUserId).eq(AppOrderProInfo::getProductId, coursesId).last("limit 1"));
-                if (ObjectUtil.isNotEmpty(orderProInfo)){
-                    orderProInfo.setOrderStatus(CommonConstant.ORDER_STATUS_2);
-                    appOrderProInfoMapper.updateById(orderProInfo);
-                    String orderId = orderProInfo.getOrderId();
-                    AppOrder appOrder = appOrderMapper.selectById(orderId);
-                    if (ObjectUtil.isNotEmpty(appOrder)){
-                        List<AppOrderProInfo> proInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, orderId)
-                                        .eq(AppOrderProInfo::getOrderStatus, CommonConstant.ORDER_STATUS_2)
-                                .eq(AppOrderProInfo::getType, CommonConstant.ORDER_PRO_INFO_TYPE_5));
-                        if(proInfoList.isEmpty()){
-                            appOrder.setOrderStatus(CommonConstant.ORDER_STATUS_2);
-                            appOrderMapper.updateById(appOrder);
+                List<AppOrderProInfo> orderProInfoList =
+                        appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getFamilyUserId, useUserId).eq(AppOrderProInfo::getProductId, coursesId));
+                if (ObjectUtil.isNotEmpty(orderProInfoList)) {
+                    for (AppOrderProInfo orderProInfo : orderProInfoList) {
+                        orderProInfo.setOrderStatus(CommonConstant.ORDER_STATUS_2);
+                        appOrderProInfoMapper.updateById(orderProInfo);
+                        String orderId = orderProInfo.getOrderId();
+                        AppOrder appOrder = appOrderMapper.selectById(orderId);
+                        if (ObjectUtil.isNotEmpty(appOrder)) {
+                            if (Objects.equals(appOrder.getOrderOrFree(), CommonConstant.STATUS_1_INT)) {
+                                appOrder.setOrderStatus(CommonConstant.ORDER_STATUS_2);
+                                appOrderMapper.updateById(appOrder);
+                            }
+                            List<AppOrderProInfo> proInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, orderId)
+                                    .eq(AppOrderProInfo::getOrderStatus, CommonConstant.ORDER_STATUS_2)
+                                    .eq(AppOrderProInfo::getType, CommonConstant.ORDER_PRO_INFO_TYPE_5));
+                            if (ObjectUtil.isEmpty(proInfoList) && Objects.equals(appOrder.getOrderStatus(), CommonConstant.ORDER_STATUS_1)) {
+                                appOrder.setOrderStatus(CommonConstant.ORDER_STATUS_2);
+                                appOrderMapper.updateById(appOrder);
+                            }
                         }
                     }
                 }else {
                     log.info("未查询到订单信息,表示当前人员属于延课人员不走订单");
                 }
-
             });
         }
         return Boolean.TRUE;

+ 16 - 16
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppOrderServiceImpl.java

@@ -8,10 +8,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
-import org.apache.poi.xssf.usermodel.XSSFPicture;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.CommonConstant;
@@ -38,18 +34,14 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageReader;
-import javax.imageio.stream.ImageInputStream;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.time.LocalDate;
 import java.time.LocalTime;
 import java.util.*;
-import java.util.List;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -323,14 +315,17 @@ public class AppOrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> i
         for (String isinId : isinIds) {
             //查询对应券号
             AppIsin appIsin = appIsinMapper.selectById(isinId);
-            appIsin.setIsinStatus(CommonConstant.ISIN_STATUS_1);
-            appIsin.setVerifyUserId(loginUser.getId());
-            appIsin.setVerifyUserName(loginUser.getUsername());
-            appIsin.setUseTime(DateUtils.getDate());
-            appIsinMapper.updateById(appIsin);
             //修改订单状态
             String orderProInfoId = appIsin.getOrderProInfoId();
             AppOrderProInfo appOrderProInfo = appOrderProInfoMapper.selectById(orderProInfoId);
+
+            if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_3) || Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)) {
+                //判断orgCode长度
+                if (loginUser.getOrgCode().length() > 3) {
+                    throw new JeecgBootException("当前账号无权限核销赛事券号,请切换平台账号进行核验!");
+                }
+            }
+
             if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_5)){
                 appOrderProInfo.setOrderStatus(CommonConstant.ORDER_STATUS_2);
                 appOrderProInfoMapper.updateById(appOrderProInfo);
@@ -346,6 +341,11 @@ public class AppOrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> i
                     }
                 }
             }
+            appIsin.setIsinStatus(CommonConstant.ISIN_STATUS_1);
+            appIsin.setVerifyUserId(loginUser.getId());
+            appIsin.setVerifyUserName(loginUser.getUsername());
+            appIsin.setUseTime(DateUtils.getDate());
+            appIsinMapper.updateById(appIsin);
         }
         return Boolean.TRUE;
     }

+ 25 - 0
updateSql.md

@@ -0,0 +1,25 @@
+-----------------------------2025.9.19
+
+建表:(分账订单信息表)
+CREATE TABLE `nm_profit_sharing_info` (
+`id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
+`order_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单ID',
+`org_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户所属组织',
+`mch_id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户号',
+`mch_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户全称',
+`ratio` date DEFAULT NULL COMMENT '分账比例',
+`pre_amount` int NOT NULL COMMENT '应分账金额(分)',
+`amount` int DEFAULT NULL COMMENT '实际分账金额(分)',
+`status` int DEFAULT NULL COMMENT '分账状态(0-待分账 1-分账成功 2-分账失败)',
+`profit_sharing_time` datetime DEFAULT NULL COMMENT '分账时间',
+`create_time` datetime DEFAULT NULL COMMENT '创建时间',
+`update_time` datetime DEFAULT NULL COMMENT '修改时间',
+`del_flag` int DEFAULT NULL COMMENT '逻辑删除标识(0-正常,1-已删除)',
+PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+sys_depart增加字段:
+ALTER TABLE sys_depart ADD mch_name varchar(255) COMMENT '商户全称(微信商户号主体)' AFTER org_id_card_num;
+ALTER TABLE sys_depart ADD mch_id varchar(32) COMMENT '商户号' AFTER org_id_card_num;
+ALTER TABLE sys_depart ADD appid varchar(64) COMMENT 'appid' AFTER org_id_card_num;
+