Преглед изворни кода

feat(order): 实现订单改价功能

- 新增订单改价接口,支持管理员对订单进行价格调整
- 完善订单改价业务逻辑,包括订单状态更新和价格重新计算
-优化订单创建流程,确保改价后订单信息准确无误
-修复分账金额计算逻辑,提高支付处理准确性- 调整异步线程池配置参数,提升系统并发处理能力- 增加相关服务注入和工具类引用,完善功能实现依赖
wzq пре 2 дана
родитељ
комит
d902cdab94
12 измењених фајлова са 1090 додато и 19 уклоњено
  1. 4 0
      national-motion-base-core/src/main/java/org/jeecg/async/DirectCompletableFutureService.java
  2. 2 0
      national-motion-base-core/src/main/java/org/jeecg/async/ThreadPoolProperties.java
  3. 5 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IOrderService.java
  4. 912 7
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java
  5. 2 2
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/config/WechatUrlConstants.java
  6. 16 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/paytest/payController.java
  7. 1 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/unionPay/SM3Util.java
  8. 67 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppOrderController.java
  9. 41 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/PriceChangeForm.java
  10. 3 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppOrderService.java
  11. 22 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppOrderServiceImpl.java
  12. 15 6
      national-motion-module-system/national-motion-system-start/src/main/resources/application-dev.yml

+ 4 - 0
national-motion-base-core/src/main/java/org/jeecg/async/DirectCompletableFutureService.java

@@ -1,16 +1,19 @@
 package org.jeecg.async;
 
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ThreadPoolExecutor;
 
 /**
  * 使用 CompletableFuture 进行异步任务处理
  */
+@Slf4j
 @Service
 @AllArgsConstructor
 public class DirectCompletableFutureService {
@@ -39,6 +42,7 @@ public class DirectCompletableFutureService {
         // 使用 runAsync 并指定自定义线程池
         return CompletableFuture.runAsync(() -> {
             // 异步任务逻辑
+            System.out.println("执行线程: " + Thread.currentThread().getName());
             System.out.println("执行无返回值任务");
         }, businessTaskExecutor);
     }

+ 2 - 0
national-motion-base-core/src/main/java/org/jeecg/async/ThreadPoolProperties.java

@@ -1,5 +1,6 @@
 package org.jeecg.async;
 
+import lombok.ToString;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
@@ -8,6 +9,7 @@ import org.springframework.stereotype.Component;
  * 支持在application.yml中动态配置
  */
 @Component
+@ToString
 @ConfigurationProperties(prefix = "async.thread-pool")
 public class ThreadPoolProperties {
     

+ 5 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IOrderService.java

@@ -11,6 +11,9 @@ import org.jeecg.modules.app.vo.OrderVO;
 import org.jeecg.modules.app.vo.PageOrdersVO;
 import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
 import org.jeecg.modules.system.app.entity.AppOrder;
+import org.jeecg.modules.system.app.form.PriceChangeForm;
+import org.jeecg.modules.system.entity.SysUser;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -77,6 +80,8 @@ public interface IOrderService extends IService<AppOrder>{
 
     UserPayForm createOrder(CreateOrderForm createOrderForm) throws IOException;
 
+    UserPayForm orderChangePrice(SysUser sysUser, PriceChangeForm priceChangeForm);
+
     /**
      * @Author SheepHy
      * @Description 体育馆无固定场-预览页

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

@@ -36,12 +36,11 @@ import org.jeecg.modules.app.vo.PageOrdersVO;
 import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
 import org.jeecg.modules.pay.config.RatiosUtil;
 import org.jeecg.modules.pay.config.WechatConstants;
-import org.jeecg.modules.pay.config.WechatPayV3Utils;
 import org.jeecg.modules.pay.config.WechatUrlConstants;
 import org.jeecg.modules.rabbitmq.DelayedMessageService;
-import org.jeecg.modules.redission.RedissonDelayQueue;
 import org.jeecg.modules.system.app.dto.receiptPaymentDetails.ReceiptPaymentDetailsInfoVo;
 import org.jeecg.modules.system.app.entity.*;
+import org.jeecg.modules.system.app.form.PriceChangeForm;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.entity.SysUser;
@@ -68,7 +67,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantLock;
 import java.util.stream.Collectors;
 
 import static org.jeecg.modules.hikiot.HikiotTool.addFace;
@@ -1017,6 +1015,7 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
                             appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
                             appOrderProInfo.setPrice(BigDecimal.ZERO);
                             appOrder.setContractNo(null);
+                            appOrder.setOrderStatus(1);
                             //试听优惠
                             appOrder.setSDiscounts(sDiscounts);
                             appOrder.setOrderOrFree(CommonConstant.STATUS_1_INT);
@@ -1269,21 +1268,21 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
                 //分账金额(支付金额-保险金额)
                 BigDecimal price = appOrder.getPrice().subtract(insurePrice);
                 //微信手续费,不足1分按1分算(当计算值小于0.01时强制提升至0.01)
-                BigDecimal FEE = calculate(price, new BigDecimal("0.006"));
+//                BigDecimal FEE = calculate(price, new BigDecimal("0.006"));
 
-                price = price.subtract(FEE);
+//                price = price.subtract(FEE);
 
                 //商户(分账给平台)
                 if (depart.getSystemType() == 1) {
                     BigDecimal[] allocate = RatiosUtil.allocate(price, new BigDecimal[]{SH, PT});
-                    if ((appOrder.getPrice().subtract(FEE)).multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(insurePrice)) < 0) {
+                    if (appOrder.getPrice().multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(insurePrice)) < 0) {
                         throw new JeecgBootException("订单金额不支持分账,无法下单!");
                     }
                 }
                 //门店(分账给平台及商户)
                 if (depart.getSystemType() == 2) {
                     BigDecimal[] allocate = RatiosUtil.allocate(price, MD, SH, PT);
-                    if ((appOrder.getPrice().subtract(FEE)).multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(allocate[2]).add(insurePrice)) < 0) {
+                    if (appOrder.getPrice().multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(allocate[2]).add(insurePrice)) < 0) {
                         throw new JeecgBootException("订单金额不支持分账,无法下单!");
                     }
                 }
@@ -1298,7 +1297,909 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
 
             //发送延迟消息
             delayedMessageService.sendOrderMessage(appOrder.getId());
+        }
+        return payForm;
+    }
+
+    /**
+     * 改价创建订单
+     *
+     * @return 支付订单对象
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public UserPayForm orderChangePrice(SysUser sysUser,PriceChangeForm priceChangeForm){
+
+        AppOrder order = appOrderMapper.selectById(priceChangeForm.getOrderId());
+        if (ObjectUtil.isEmpty(order)) {
+            throw new JeecgBootException("订单不存在!");
+        }
+        //根据订单构建改价后的订单信息(总金额 = 子订单金额 + 保险)
+        CreateOrderForm createOrderForm = new CreateOrderForm();
+        createOrderForm.setType(order.getType());
+        createOrderForm.setOrderType(order.getOrderType());
+        createOrderForm.setOrFreeOrder(order.getOrderOrFree());
+        createOrderForm.setAmount(order.getAmount());
+        createOrderForm.setFamilyIds(order.getFamilyIds());
+        createOrderForm.setGameCertificationForm(order.getGameCertification());
+        //构建商品IDs
+        List<PriceChangeForm.OrderItemForm> orderItemList = priceChangeForm.getOrderItemList();
+        String productIds = orderItemList.stream().map(PriceChangeForm.OrderItemForm::getProductId)
+                .collect(Collectors.joining(","));
+        createOrderForm.setProductIds(productIds);
+        //构建保险表单
+        List<InsureOrderInfo> insureOrderInfos =
+                insureOrderInfoMapper.selectList(Wrappers.<InsureOrderInfo>lambdaQuery().eq(InsureOrderInfo::getOrderId,
+                order.getId()));
+
+        String familyMembersIds = insureOrderInfos.stream().map(InsureOrderInfo::getFamilyMembersId).collect(Collectors.joining(","));
+
+        InsurePrice insurePrices = insurePriceMapper.selectOne(Wrappers.lambdaQuery(InsurePrice.class).eq(InsurePrice::getInsureId,
+                insureOrderInfos.get(0).getInsureId()));
+
+
+        InsureOrderInfoForm insureOrderInfoForms = new InsureOrderInfoForm();
+        insureOrderInfoForms.setInsureId(insureOrderInfos.get(0).getInsureId());
+        insureOrderInfoForms.setAssertStartTime(insureOrderInfos.get(0).getAssertStartTime());
+        insureOrderInfoForms.setAssertEndTime(insureOrderInfos.get(0).getAssertEndTime());
+        insureOrderInfoForms.setInsurePriceId(insurePrices.getId());
+        insureOrderInfoForms.setFamilyMembersIds(familyMembersIds);
+
+        createOrderForm.setInsureOrderInfoForm(insureOrderInfoForms);
+
+        String orderCode = generateOrderNumber(0);
+
+        //创建订单
+        AppOrder appOrder = new AppOrder();
+        appOrder
+                .setOrderType(createOrderForm.getOrderType())
+                .setOrderCode(orderCode)
+                .setUserId(sysUser.getId())
+                .setUserOpenId(sysUser.getOpenid())
+                .setUserPhone(sysUser.getPhone())
+                .setOrderStatus(0)
+                .setProductIds(createOrderForm.getProductIds())
+                .setAmount(createOrderForm.getAmount())
+        ;
+        BigDecimal totalPrice = BigDecimal.ZERO;
+
+        List<AppOrderProInfo> proInfoList = new ArrayList<>();
+
+        List<InsureOrderInfo> insureOrderInfoList = new ArrayList<>();
+
+        List<AppCoursesVerificationRecord> appCoursesVerificationRecordList = new ArrayList<>();
+
+        String productKey = ""; // ORDER_TYPE_1_PRODUCT_N001
+        String stockKey = ""; // ORDER_TYPE_1_PRODUCT_STOCK_N001
+
+        //订单内容
+        switch (createOrderForm.getType()) {
+            //场地(学校,包场,无固定场)
+            case 0:
+                //学校
+                if (createOrderForm.getOrderType() == 0) {
+                    AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                    AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
+                    AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
+
+                    String productId = createOrderForm.getProductIds();
+
+                    //改价
+                    for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
+                        if (orderItemForm.getProductId().equals(productId)){
+                            priceRule.setSellingPrice(orderItemForm.getOriginalPrice());
+                        }
+                    }
+
+                    //判断是否已下单
+                    List<String> familyIds = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
+                    AppOrderProInfo proInfo = appOrderProInfoMapper.selectOne(Wrappers.<AppOrderProInfo>lambdaQuery()
+                            .eq(AppOrderProInfo::getProductId, productId)
+                            .in(AppOrderProInfo::getFamilyUserId, familyIds)
+                            .last("limit 1")
+                    );
+                    if (ObjectUtil.isNotEmpty(proInfo)) {
+                        String userName = proInfo.getUserName();
+                        throw new JeecgBootException(userName + "已预约过该场地的同一日期和时段,无需重复预约,请直接进场。");
+                    }
+
+                    productKey = "ORDER_TYPE_1_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
+                    stockKey = "ORDER_TYPE_1_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
+
+                    // 查询库存
+                    Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
+                    //使用人
+                    List<String> ids = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
+                    log.info("学校场地预约商品库存数量:{}", stock);
+                    // 缓存没有商品库存,查询数据库
+                    if (stock == null || stock == 0 || stock < ids.size()) {
+                        AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
+                        if (Objects.isNull(product)) {
+                            throw new JeecgBootException("订单提交失败,商品已下架");
+                        }
+                        redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product), 60 * 60 * 24, TimeUnit.SECONDS);
+                        // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
+                        if (product.getTicketNum() == null) {
+                            throw new JeecgBootException("订单提交失败,当前商品库存为空");
+                        }
+                        stock = product.getTicketNum();
+                        redisTemplate.opsForValue().set(stockKey, stock, 60 * 60 * 24, TimeUnit.SECONDS);
+                    }
+                    // 检查库存是否足够
+                    if (stock < ids.size()) {
+                        throw new JeecgBootException("订单提交失败,库存不足");
+                    }
+                    // 更新数据库中的库存数据
+                    log.info("更新学校场地数据库中的库存数据:{}", stock - ids.size());
+                    int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
+                            .eq(AppSitePriceRules::getId, productId)
+                            .set(AppSitePriceRules::getTicketNum, (stock - ids.size())));
+                    if (row > 0) {
+                        // 更新Redis中缓存的商品库存数据
+                        redisTemplate.opsForValue().decrement(stockKey, ids.size());
+                    }
+                    // 库存扣减完,创建订单
+                    appOrder
+                            .setPayType(3)
+                            .setOrderStatus(1)
+                            .setOrgCode(appSite.getOrgCode())
+                            .setTenantId(appSite.getTenantId())
+                            .setType(CommonConstant.ORDER_TYPE_0)
+                            //使用人IDs
+                            .setFamilyIds(createOrderForm.getFamilyIds())
+                            .setOriginalPrice(priceRule.getSellingPrice())
+                            .setAddressSiteId(appSite.getId())
+                            .setOrProfitSharing(0)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(sysUser.getId())
+                            .setUpdateBy(sysUser.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                    for (String id : ids) {
+                        FamilyMembers familyMembers = familyMembersMapper.selectById(id);
+                        if (Objects.isNull(familyMembers)) {
+                            throw new JeecgBootException("订单提交失败,用户不存在");
+                        }
+                        String date = DateUtil.format(priceRule.getDateOfSale(), "yyyy-MM-dd");
+                        String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
+                        String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
+                        String expireTime;
+                        if (priceRule.getEndTime() != null) {
+                            expireTime = date + " " + endTime;
+                        } else {
+                            expireTime = date;
+                        }
+                        if (startTime == null) {
+                            startTime = DateUtil.format(new Date(), "yyyy-MM-dd");
+                        }
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo
+                                .setProductId(priceRule.getId())
+                                .setProductName("学校场地预约")
+                                .setType(CommonConstant.ORDER_PRO_INFO_TYPE_0)
+                                .setUseDateStr(date)
+                                .setFrameTimeStr(startTime + "-" + endTime)
+                                .setExpireTime(expireTime)
+                                .setOriginalPrice(priceRule.getOriginalPrice())
+                                .setProductImage(appSitePlace.getCover())
+                                .setAddress(appSite.getAddress())
+                                .setPrice(priceRule.getSellingPrice())
+                                .setOrderStatus(1)
+                                .setQuantity(1)
+                                .setFamilyUserId(id)
+                                .setSiteId(appOrder.getAddressSiteId())
+                                .setUserName(familyMembers.getFullName())
+                                .setUserPhone(familyMembers.getPhone())
+                                .setStatus(CommonConstant.STATUS_0_INT)
+                                .setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                        proInfoList.add(appOrderProInfo);
+                    }
+                }
+
+                //包场
+                if (createOrderForm.getOrderType() == 1) {
+
+                    List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
+
+                    //订单总价(商品的售价总和)
+                    BigDecimal sumPrice = BigDecimal.ZERO;
+
+                    for (int i = 0; i < list.size(); i++) {
+                        AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(list.get(i).split("\\|")[0]);
+                        AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
+                        AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
+
+                        //改价
+                        for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
+                            if (orderItemForm.getProductId().equals(priceRule.getId())){
+                                priceRule.setSellingPrice(orderItemForm.getOriginalPrice());
+                            }
+                        }
+
+                        appOrder.setOrgCode(appSite.getOrgCode());
+
+                        String date = list.get(i).split("\\|")[1];
+                        String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm");
+                        String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm");
+                        String expireTime = date + " " + endTime;
+
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo.setProductId(list.get(i).split("\\|")[0]);
+                        appOrderProInfo.setProductName(date.substring(5) + " " + startTime + "-" + endTime + "|" + appSitePlace.getName());
+                        appOrderProInfo.setProductImage(appSitePlace.getCover());
+                        appOrderProInfo.setExpireTime(expireTime);
+                        appOrderProInfo.setUseDateStr(date.substring(5));
+                        appOrderProInfo.setAddress(appSite.getName());
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_1);
+                        appOrderProInfo.setProductImage(appSite.getCover());
+                        appOrderProInfo.setOriginalPrice(priceRule.getSellingPrice());
+                        appOrderProInfo.setPrice(priceRule.getSellingPrice());
+                        appOrderProInfo.setOrderStatus(0);
+                        appOrderProInfo.setQuantity(1);
+                        appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
+                        appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                        proInfoList.add(appOrderProInfo);
+                        appOrder.setOrgCode(appSitePlace.getOrgCode())
+                                .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
+
+                        sumPrice = sumPrice.add(appOrderProInfo.getPrice());
+                    }
+
+                    //计算订单总价
+                    totalPrice = totalPrice.add(sumPrice);
+
+                    List<String> collect = list.stream().map(e -> e.split("\\|")[0]).collect(Collectors.toList());
+                    String ids = String.join(",", collect);
+                    appOrder
+                            .setProductIds(ids)
+                            .setType(CommonConstant.ORDER_TYPE_0)
+                            .setOriginalPrice(sumPrice)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(sysUser.getId())
+                            .setUpdateBy(sysUser.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+                }
+
+                //无固定场
+                if (createOrderForm.getOrderType() == 2) {
+                    AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                    AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
+                    AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
+
+                    //改价
+                    for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
+                        if (orderItemForm.getProductId().equals(priceRule.getSellingPrice())){
+                            priceRule.setSellingPrice(orderItemForm.getOriginalPrice());
+                        }
+                    }
+
+                    //订单总价(商品的售价总和)
+                    BigDecimal sumPrice = BigDecimal.ZERO;
+                    ;
+                    //团购优惠
+                    BigDecimal tDiscounts = BigDecimal.ZERO;
+                    ;
+
+                    for (int i = 1; i <= createOrderForm.getAmount(); i++) {
+
+                        //门店的营业时间
+                        Integer indate = appSitePlace.getIndate();
+                        String date = DateUtil.format(Date.from(LocalDate.now().plusDays(indate).atStartOfDay(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd");
+                        String startTime = DateUtil.format(appSite.getStartTime(), "HH:mm");
+                        String endTime = DateUtil.format(appSite.getEndTime(), "HH:mm");
+                        String expireTime = date + " " + endTime;
+                        if (null == appSite.getStartTime()) {
+                            startTime = "00:00";
+                        }
+                        if (null == appSite.getEndTime()) {
+                            endTime = "23:59";
+                        }
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo.setProductId(createOrderForm.getProductIds());
+                        appOrderProInfo.setProductName(appSitePlace.getName());
+                        appOrderProInfo.setProductImage(appSitePlace.getCover());
+                        appOrderProInfo.setAddress(appSite.getAddress());
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_2);
+                        appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
+                        appOrderProInfo.setExpireTime(expireTime);
+                        appOrderProInfo.setOriginalPrice(priceRule.getOriginalPrice());
+                        appOrderProInfo.setPrice(priceRule.getSellingPrice());
+                        appOrderProInfo.setOrderStatus(0);
+                        appOrderProInfo.setQuantity(1);
+                        appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
+                        appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                        proInfoList.add(appOrderProInfo);
+                        tDiscounts = tDiscounts.add(priceRule.getOriginalPrice().subtract(priceRule.getSellingPrice()));
+                        sumPrice = sumPrice.add(priceRule.getSellingPrice());
+                    }
+
+                    //计算订单总价
+                    totalPrice = totalPrice.add(sumPrice);
+
+                    appOrder
+                            .setOrgCode(appSite.getOrgCode())
+                            .setTenantId(appSite.getTenantId())
+                            .setType(CommonConstant.ORDER_TYPE_0)
+                            .setTDiscounts(tDiscounts)
+                            .setOriginalPrice(sumPrice)
+                            .setAddressSiteId(appSite.getId())
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(sysUser.getId())
+                            .setUpdateBy(sysUser.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+                }
+                break;
+            //赛事
+            case 1:
+                //个人赛
+                if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_3)) {
+                    AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
+                    AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
+
+                    //改价
+                    for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
+                        if (orderItemForm.getProductId().equals(appGamePriceRules.getSellingPrice())){
+                            appGamePriceRules.setSellingPrice(orderItemForm.getOriginalPrice());
+                        }
+                    }
+
+                    appOrder.setOrgCode(appGamePriceRules.getOrgCode());
+                    appOrder.setTenantId(appGamePriceRules.getTenantId());
+
+                    String startTime = DateUtil.format(appGame.getStartTime(), "HH:mm");
+                    String endTime = DateUtil.format(appGame.getEndTime(), "HH:mm");
+
+                    //订单总价(商品的售价总和)
+                    BigDecimal sumPrice = BigDecimal.ZERO;
+
+                    for (int i = 1; i <= createOrderForm.getAmount(); i++) {
+
+                        String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
+                        FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo.setProductId(createOrderForm.getProductIds());
+                        appOrderProInfo.setProductName(appGame.getName());
+                        if (appGame.getSiteType() == 1) {
+                            appOrderProInfo.setAddress(appGameMapper.selectById(appGame.getId()).getAddress());
+                        } else {
+                            appOrderProInfo.setAddress(appSiteMapper.selectById(appGame.getSiteId()).getAddress());
+                        }
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_3);
+                        appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
+                        appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
+                        appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
+                        appOrderProInfo.setPrice(appGamePriceRules.getSellingPrice());
+                        appOrderProInfo.setProductImage(appGame.getCover());
+                        appOrderProInfo.setOrderStatus(0);
+                        appOrderProInfo.setQuantity(1);
+                        appOrderProInfo.setFamilyUserId(familyUserId);
+                        appOrderProInfo.setUserName(familyMembers.getFullName());
+                        appOrderProInfo.setUserPhone(familyMembers.getPhone());
+                        appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
+                        appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                        proInfoList.add(appOrderProInfo);
+
+                        sumPrice = sumPrice.add(appGamePriceRules.getSellingPrice());
+                    }
+                    //计算订单总价
+                    totalPrice = totalPrice.add(sumPrice);
+
+                    appOrder
+                            .setType(CommonConstant.ORDER_TYPE_1)
+                            .setOriginalPrice(sumPrice)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(sysUser.getId())
+                            .setUpdateBy(sysUser.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+                    if (ObjectUtil.isNotEmpty(appGame.getSiteId())) {
+                        appOrder.setAddressSiteId(appGame.getSiteId());
+                    }
+                    if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
+                        appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
+                    }
+                }
+                if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)) {
+                    AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
+                    AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
+
+                    //改价
+                    for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
+                        if (orderItemForm.getProductId().equals(appGamePriceRules.getSellingPrice())){
+                            appGamePriceRules.setSellingPrice(orderItemForm.getOriginalPrice());
+                        }
+                    }
+
+                    String startTime = DateUtil.format(appGame.getStartTime(), "HH:mm:ss");
+                    String endTime = DateUtil.format(appGame.getEndTime(), "HH:mm:ss");
+
+                    appOrder.setOrgCode(appGamePriceRules.getOrgCode());
+                    appOrder.setTenantId(appGamePriceRules.getTenantId());
+
+                    //订单总价(商品的售价总和)
+                    BigDecimal sumPrice = appGamePriceRules.getSellingPrice();
+
+                    List<String> familyIds = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
+                    String ticketNo = RandomUtil.randomNumbers(10);
+                    for (String familyId : familyIds) {
+                        FamilyMembers familyMembers = familyMembersMapper.selectById(familyId);
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo.setProductId(createOrderForm.getProductIds());
+                        appOrderProInfo.setProductName(appGame.getName());
+                        if (appGame.getSiteType() == 1) {
+                            appOrderProInfo.setAddress(appGameMapper.selectById(appGame.getId()).getAddress());
+                        } else {
+                            appOrderProInfo.setAddress(appSiteMapper.selectById(appGame.getSiteId()).getAddress());
+                        }
+                        appOrderProInfo.setTicketNo(ticketNo);
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
+                        appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
+                        appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
+                        appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
+                        appOrderProInfo.setPrice(BigDecimal.ZERO);
+                        appOrderProInfo.setProductImage(appGame.getCover());
+                        appOrderProInfo.setOrderStatus(0);
+                        appOrderProInfo.setQuantity(1);
+                        appOrderProInfo.setFamilyUserId(familyId);
+                        appOrderProInfo.setUserName(familyMembers.getFullName());
+                        appOrderProInfo.setUserPhone(familyMembers.getPhone());
+                        appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
+                        appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                        proInfoList.add(appOrderProInfo);
+                    }
+                    //计算订单总价
+                    totalPrice = totalPrice.add(sumPrice);
+
+                    appOrder
+                            .setType(CommonConstant.ORDER_TYPE_1)
+                            .setOriginalPrice(sumPrice)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(sysUser.getId())
+                            .setUpdateBy(sysUser.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+                    if (ObjectUtil.isNotEmpty(appGame.getSiteId())) {
+                        appOrder.setAddressSiteId(appGame.getSiteId());
+                    }
+                    if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
+                        appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
+                    }
+                }
+                break;
+            //课程
+            case 2:
+                //课程
+                AppCourses appCourse = appCoursesMapper.selectById(appOrder.getProductIds());
+                if (ObjectUtil.isEmpty(appCourse)) {
+                    log.error("当前课程不存在!");
+                    throw new JeecgBootException("当前课程已下架!");
+                }
+
+                //改价
+                for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
+                    if (orderItemForm.getProductId().equals(appCourse.getSellingPrice())){
+                        appCourse.setSellingPrice(orderItemForm.getOriginalPrice());
+                    }
+                }
+
+                List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
+                AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
+                appOrder.setOrderOrFree(createOrderForm.getOrFreeOrder());
+                appOrder.setType(CommonConstant.ORDER_TYPE_2);
+                appOrder.setOrgCode(appCourse.getOrgCode());
+                appOrder.setTenantId(appCourse.getTenantId());
+
+                //合同编号
+                AppContractInfo appContractInfo = appContractInfoMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery()
+                        .eq(AppContractInfo::getOrgCode, appOrder.getOrgCode()).eq(AppContractInfo::getDelFlag, 0));
+                if (ObjectUtil.isNotEmpty(appContractInfo)) {
+                    appOrder.setContractNo(appContractInfo.getId());
+                }
+
+                //订单总价(商品的售价总和)
+                BigDecimal sumCoursePrice = BigDecimal.ZERO;
+
+                //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
+                BigDecimal sDiscounts = BigDecimal.ZERO;
+                BigDecimal tDiscounts = BigDecimal.ZERO;
+
+                for (int i = 1; i <= createOrderForm.getAmount(); i++) {
+
+                    String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
+                    FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
+
+                    //判断当前课程是否已下过单
+                    List<AppOrderProInfo> infos = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery()
+                            .eq(AppOrderProInfo::getProductId, appCourse.getId())
+                            .eq(AppOrderProInfo::getFamilyUserId, familyUserId)
+                    );
+                    List<AppOrderProInfo> infoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery()
+                            .eq(AppOrderProInfo::getProductId, appCourse.getId())
+                            .eq(AppOrderProInfo::getFamilyUserId, familyUserId)
+                            .eq(AppOrderProInfo::getOrFreePro, CommonConstant.STATUS_0_INT)
+                            .notIn(AppOrderProInfo::getOrderStatus, CommonConstant.ORDER_STATUS_4, CommonConstant.ORDER_STATUS_5, CommonConstant.ORDER_STATUS_6)
+                    );
+
+                    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) && !Objects.equals(info.getOrderStatus(), CommonConstant.ORDER_PRO_INFO_TYPE_4))
+                                .collect(Collectors.toList());
+                        if (ObjectUtil.isNotEmpty(freeProList)) {
+                            throw new JeecgBootException("当前试听课课程已下过单,请勿重复下单");
+                        }
+                    }
+                    AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                    appOrderProInfo.setProductId(createOrderForm.getProductIds());
+                    appOrderProInfo.setProductName(appCourse.getName());
+                    appOrderProInfo.setAddress(appSite.getAddress());
+                    appOrderProInfo.setProductImage(appCourse.getCover());
+                    appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_5);
+                    appOrderProInfo.setFrameTimeStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd") + "-" + DateUtil.format(appCourse.getEndTime(), "MM-dd"));
+                    appOrderProInfo.setExpireTime(DateUtil.format(appCourse.getEndTime(), "yyyy-MM-dd"));
+                    appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
+                    appOrderProInfo.setPrice(appCourse.getSellingPrice());
+                    appOrderProInfo.setUseDateStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd"));
+                    appOrderProInfo.setOrderStatus(0);
+                    appOrderProInfo.setQuantity(1);
+                    appOrderProInfo.setFamilyUserId(familyUserId);
+                    appOrderProInfo.setUserName(familyMembers.getFullName());
+                    appOrderProInfo.setUserPhone(familyMembers.getPhone());
+                    appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
+                    appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                    //创建核销记录
+                    if (CollUtil.isNotEmpty(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());
+                            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 (createOrderForm.getOrFreeOrder() == 1) {
+                        Boolean flag = checkOrderOrFree(sysUser.getId(), appCourse.getCategoryId());
+                        if (flag && i == 1) {
+                            //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
+                            sDiscounts = sDiscounts.add(appCourse.getOriginalPrice());
+                            appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
+                            appOrderProInfo.setOrderStatus(1);
+                            appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
+                            appOrderProInfo.setPrice(BigDecimal.ZERO);
+                            appOrder.setContractNo(null);
+                            //试听优惠
+                            appOrder.setSDiscounts(sDiscounts);
+                            appOrder.setOrderOrFree(CommonConstant.STATUS_1_INT);
+                            appOrder.setOrProfitSharing(0);
+                        }
+                    }
+                    proInfoList.add(appOrderProInfo);
+
+                    tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice()));
+                    if (createOrderForm.getOrFreeOrder() == 1) {
+                        tDiscounts = BigDecimal.ZERO;
+                    }
+                    sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice());
+                    if (createOrderForm.getOrFreeOrder() == 1) {
+                        sumCoursePrice = BigDecimal.ZERO;
+                    }
+                }
+
+                //计算订单总价
+                totalPrice = totalPrice.add(sumCoursePrice);
+
+                //团购优惠
+                appOrder.setTDiscounts(tDiscounts);
+                if (createOrderForm.getOrFreeOrder() == 1) {
+                    //团购优惠
+                    appOrder.setTDiscounts(BigDecimal.ZERO);
+                }
+                //使用人IDs
+                appOrder.setFamilyIds(createOrderForm.getFamilyIds());
+
+                appOrder.setAddressSiteId(appCourse.getAddressSiteId());
+                break;
+        }
+
+        //构建保单内容
+        InsureOrderInfoForm insureOrderInfoForm = createOrderForm.getInsureOrderInfoForm();
+        if (ObjectUtils.isNotEmpty(insureOrderInfoForm)) {
+            List<String> ids = Arrays.stream(insureOrderInfoForm.getFamilyMembersIds().split(",")).collect(Collectors.toList());
+            AppInsure appInsure = appInsureMapper.selectById(insureOrderInfoForm.getInsureId());
+            DictAnnotationUtil.translateDict(appInsure);
+            //保单总价
+            BigDecimal sumPrice = new BigDecimal(0);
+            for (String id : ids) {
+
+                //查询保单价格
+                InsurePrice insurePrice = insurePriceMapper.selectById(insureOrderInfoForm.getInsurePriceId());
+                FamilyMembers members = familyMembersMapper.selectById(id);
+
+                //创建保单
+                InsureOrderInfo insureOrderInfo = new InsureOrderInfo();
+                insureOrderInfo
+                        .setOrderId(appOrder.getId())
+                        .setBdOrderNo(generateOrderNumber(2))
+                        .setInsureName(appInsure.getName())
+                        .setCoverImg(appInsure.getCoverImg())
+                        .setInsureCompany(appInsure.getInsuranceName_dictText())
+                        .setInsureId(appInsure.getId())
+                        .setMoney(insurePrice.getInsurePrice())
+                        .setFamilyMembersId(id)
+                        .setFamilyUserName(members.getFullName())
+                        .setAssertStartTime(insureOrderInfoForm.getAssertStartTime())
+                        .setAssertEndTime(insureOrderInfoForm.getAssertEndTime())
+                        .setIsEnterSystem(CommonConstant.STATUS_0_INT)
+                ;
+                insureOrderInfoList.add(insureOrderInfo);
+
+                sumPrice = sumPrice.add(insurePrice.getInsurePrice());
+            }
+            //计算总价 = 订单金额 + 保单金额
+            totalPrice = totalPrice.add(sumPrice);
+        }
+        //原订单总价
+        appOrder.setOriginalPrice(totalPrice);
+        appOrder.setPrice(totalPrice);
+        appOrderMapper.insert(appOrder);
+        if (appOrder.getOrderType() == 5 && appOrder.getOrderOrFree() == 0) {
+            saveSignFlowRecord(appOrder);
+        }
+        if (!insureOrderInfoList.isEmpty()) {
+            //保存保险
+            for (InsureOrderInfo insureOrderInfo : insureOrderInfoList) {
+                insureOrderInfo.setOrderId(appOrder.getId());
+                insureOrderInfoMapper.insert(insureOrderInfo);
+
+                AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                appOrderProInfo.setProductId(insureOrderInfo.getId());
+                appOrderProInfo.setProductName(insureOrderInfo.getInsureName());
+                appOrderProInfo.setProductImage(insureOrderInfo.getCoverImg());
+                appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
+
+                appOrderProInfo.setPrice(insureOrderInfo.getMoney());
+                appOrderProInfo.setOriginalPrice(insureOrderInfo.getMoney());
+                appOrderProInfo.setQuantity(1);
+                FamilyMembers familyMembers = familyMembersMapper.selectById(insureOrderInfo.getFamilyMembersId());
+                appOrderProInfo.setFamilyUserId(familyMembers.getId());
+                appOrderProInfo.setUserName(familyMembers.getFullName());
+                appOrderProInfo.setUserPhone(familyMembers.getPhone());
+                appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
+                appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
+
+                proInfoList.add(appOrderProInfo);
+            }
+        }
+
+        for (AppOrderProInfo appOrderProInfo : proInfoList) {
+            appOrderProInfo
+                    .setOrderId(appOrder.getId())
+                    .setOrderCode(appOrder.getOrderCode());
+            if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)) {
+                appOrderProInfo.setTicketNo(RandomUtil.randomNumbers(10));
+            }
+            if (appOrderProInfoMapper.insert(appOrderProInfo) > 0) {
+                if (appOrderProInfo.getType() == 5) {
+                    AppSite appSite = appSiteMapper.selectById(appCoursesMapper.selectById(appOrderProInfo.getProductId()).getAddressSiteId());
+                    if (null != appSite &&
+                            appSite.getType() == 0) {
+                        FamilyMembers familyMembers = familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId());
+                        for (AppDevice appDevice : appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getSiteId, appSite.getId()))) {
+                            if (null != appDevice) {
+                                JsonObject addUserJson = JsonParser.parseString(addUser(new Date(),
+                                        appDevice.getDeviceSerial(),
+                                        appOrderProInfo.getUserName(),
+                                        familyMembers.getId(), new DateTime(appOrderProInfo.getExpireTime()))).getAsJsonObject();
+                                JsonObject addFaceJson = JsonParser.parseString(addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
+                                        familyMembers.getRealNameImg())).getAsJsonObject();
+                                if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0) {
+                                    throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_6)) {
+                //订单券号记录
+                AppIsin appIsin = new AppIsin();
+                appIsin
+                        .setOrderId(appOrder.getId())
+                        .setOrgCode(appOrder.getOrgCode())
+                        .setOrderCode(appOrder.getOrderCode())
+                        .setOrderProInfoId(appOrderProInfo.getId())
+                        .setFamilyId(appOrderProInfo.getFamilyUserId())
+                        .setFamilyUserName(appOrderProInfo.getUserName())
+                        .setUserPhone(appOrderProInfo.getUserPhone())
+                        //过期时间
+                        .setExpireTime(appOrderProInfo.getExpireTime())
+                        //生成10位随机券号
+                        .setTicketNo(appOrderProInfo.getTicketNo())
+                        .setIsinStatus(CommonConstant.ISIN_STATUS_0);
+                if (appOrder.getType() == 0) {
+                    String s = createOrderForm.getProductIds().split(",")[0];
+                    String priceRuleId = s.split("\\|")[0];
+                    AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(priceRuleId);
+                    AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
+                    AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
+                    appIsin.setUseAddress(appSite.getName());
+                }
+                if (appOrder.getType() == 1) {
+                    AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
+                    appIsin.setUseAddress(sysDepartMapper.selectOne(Wrappers.<SysDepart>lambdaQuery().eq(SysDepart::getOrgCode, appGame.getOrgCode())).getDepartName());
+                }
+                if (appOrder.getType() == 2) {
+                    AppSite appSite = appSiteMapper.selectById(appCoursesMapper.selectById(appOrderProInfo.getProductId()).getAddressSiteId());
+                    appIsin.setUseAddress(appSite.getName());
+
+                    //判断当前课程是否是在学校上课
+                    if (appSite.getType() == 0) {
+                        //查询当前课程的课时
+                        AppCourses appCourses = appCoursesMapper.selectById(appOrderProInfo.getProductId());
+                        List<AppCoursesPriceRules> appCoursesPriceRules = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId,
+                                appCourses.getId()));
+                        for (AppCoursesPriceRules appCoursesPriceRule : appCoursesPriceRules) {
+                            AppIsin appIsinInfo = new AppIsin();
+                            appIsinInfo
+                                    .setOrderId(appOrder.getId())
+                                    .setOrgCode(appOrder.getOrgCode())
+                                    .setOrderCode(appOrder.getOrderCode())
+                                    .setOrderProInfoId(appOrderProInfo.getId())
+                                    .setCoursePriceRuleId(appCoursesPriceRule.getId())
+                                    .setFamilyId(appOrderProInfo.getFamilyUserId())
+                                    .setFamilyUserName(appOrderProInfo.getUserName())
+                                    .setTicketNo(appOrderProInfo.getTicketNo())
+                                    .setIsinStatus(CommonConstant.ISIN_STATUS_0);
+                            appIsinMapper.insert(appIsinInfo);
+                        }
+                    }
+                }
+                appIsinMapper.insert(appIsin);
+            }
+            if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_0)) {
+                FamilyMembers familyMembers = familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId());
+                for (AppDevice appDevice : appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode, appOrder.getOrgCode()))) {
+                    String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
+                            appDevice.getDeviceSerial(),
+                            appOrderProInfo.getUserName(),
+                            familyMembers.getId(), null);
+                    String addFace = addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
+                            familyMembers.getRealNameImg());
+                    JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();
+                    JsonObject addFaceJson = JsonParser.parseString(addFace).getAsJsonObject();
+                    if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0)
+                        throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
+                }
+            }
+        }
+
+        //保存核销记录
+        if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
+            for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
+                appCoursesVerificationRecord.setOrderId(appOrder.getId());
+                appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
+                appCoursesVerificationRecord.setOrgCode(appOrder.getOrgCode());
+                appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
+            }
+        }
+
+        //构建支付表单返回给前端支撑JsApi支付调用
+        UserPayForm payForm = new UserPayForm();
+        payForm.setOrderId(appOrder.getId()).setOrderCode(orderCode);
+
+        //判断是否试听课(试听课不走订单)
+        if ((ObjectUtil.isNotEmpty(appOrder.getOrderOrFree()) && appOrder.getOrderOrFree() == 1) || appOrder.getPrice().compareTo(BigDecimal.ZERO) == 0) {
+            payForm.setOrPayOrder(0);
+        } else {
+            //分账能否成功,判断是否可以下单
+            List<AppOrderProInfo> orderProInfoList =
+                    proInfoList.stream().filter(appOrderProInfo -> Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_6)).collect(Collectors.toList());
+            BigDecimal insurePrice = BigDecimal.ZERO;
+            if (CollUtil.isNotEmpty(orderProInfoList)) {
+                BigDecimal reduce = orderProInfoList.stream().map(AppOrderProInfo::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
+                insurePrice = insurePrice.add(reduce);
+            }
+            //创建预分账详情
+            String orgCode = appOrder.getOrgCode();
+            SysDepart depart = sysDepartMapper.selectOne(Wrappers.lambdaQuery(SysDepart.class).eq(SysDepart::getOrgCode, orgCode).last("limit 1"));
+            String deptId = depart.getId();
+            if (depart.getSystemType() == 2) {
+                deptId = depart.getParentId();
+            }
+            if (depart.getSystemType() != 0) {
+                SeparateAccounts separateAccounts = separateAccountsMapper.selectOne(Wrappers.lambdaQuery(SeparateAccounts.class).eq(SeparateAccounts::getDeptId, deptId));
+                if (ObjectUtil.isEmpty(separateAccounts)) {
+                    throw new JeecgBootException("商户信息未配置!请联系管理员");
+                }
+                //获取分账比例
+                BigDecimal PT = separateAccounts.getPtSeparateAccounts();
+                BigDecimal SH = separateAccounts.getShSeparateAccounts();
+                BigDecimal MD = separateAccounts.getMdSeparateAccounts();
+                //分账金额(支付金额-保险金额)
+                BigDecimal price = appOrder.getPrice().subtract(insurePrice);
+                //微信手续费,不足1分按1分算(当计算值小于0.01时强制提升至0.01)
+//                BigDecimal FEE = calculate(price, new BigDecimal("0.006"));
+
+//                price = price.subtract(FEE);
+
+                //商户(分账给平台)
+                if (depart.getSystemType() == 1) {
+                    BigDecimal[] allocate = RatiosUtil.allocate(price, new BigDecimal[]{SH, PT});
+                    if (appOrder.getPrice().multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(insurePrice)) < 0) {
+                        throw new JeecgBootException("订单金额不支持分账,无法下单!");
+                    }
+                }
+                //门店(分账给平台及商户)
+                if (depart.getSystemType() == 2) {
+                    BigDecimal[] allocate = RatiosUtil.allocate(price, MD, SH, PT);
+                    if (appOrder.getPrice().multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(allocate[2]).add(insurePrice)) < 0) {
+                        throw new JeecgBootException("订单金额不支持分账,无法下单!");
+                    }
+                }
+            }
+
+            Map<String, String> result = payment(appOrder.getId());
+            payForm.setParams(result);
 
+            //发布任务到redission延迟队列(16分钟)
+//            String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
+//            redissonDelayQueue.offerTask(task, 60 * 16);
+
+            //发送延迟消息
+            delayedMessageService.sendOrderMessage(appOrder.getId());
         }
         return payForm;
     }
@@ -1713,6 +2614,10 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
 
         AppOrderProInfo proInfo = appOrderProInfoMapper.selectOne(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, orderId).eq(AppOrderProInfo::getTicketNo, ticketNo));
 
+        if (null == proInfo) {
+            return list;
+        }
+
         String familyUserId = proInfo.getFamilyUserId();
         String appCourseId = proInfo.getProductId();
 

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/config/WechatUrlConstants.java

@@ -17,10 +17,10 @@ public class WechatUrlConstants {
     public final static String PAY_V3_QUERY_OUT = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}";
 
     //微信支付v3 支付通知接口地址
-    public final static String PAY_V3_NOTIFY = "https://api.qlapp.cn/jeecgboot/app/order/wechatPayNotify";
+    public final static String PAY_V3_NOTIFY = "https://6a34b652.r28.cpolar.top/jeecgboot/app/order/wechatPayNotify";
 
     //微信支付v3 退款通知接口地址
-    public final static String PAY_V3_REFUND_NOTIFY = "https://api.qlapp.cn/jeecgboot/app/order/callback/refundOrderNotify";
+    public final static String PAY_V3_REFUND_NOTIFY = "https://6a34b652.r28.cpolar.top/jeecgboot/app/order/callback/refundOrderNotify";
 
     //服务商 添加分账接收方
     public final static String PAY_V3_RECEIVERS_ADD = "https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add";

+ 16 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/paytest/payController.java

@@ -9,6 +9,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.client.methods.HttpGet;
+import org.jeecg.async.DirectCompletableFutureService;
+import org.jeecg.async.ThreadPoolProperties;
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.modules.pay.config.WechatConstants;
 import org.jeecg.modules.pay.config.WechatPayV3Utils;
@@ -23,6 +26,9 @@ import org.jeecg.modules.pay.serverPay.RsaKit;
 import org.jeecg.modules.rabbitmq.DelayedMessageService;
 import org.jeecg.modules.system.app.entity.AppOrder;
 import org.jeecg.modules.system.app.service.IAppOrderService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -34,6 +40,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
 
 
 @Slf4j
@@ -48,6 +56,8 @@ public class payController {
 
     private final WeChatProfitSharingService weChatProfitSharingService;
 
+    private final DirectCompletableFutureService directCompletableFutureService;
+
     @GetMapping(value = "/getPay")
     public String getPay(String orderSn, int total, String description) {
         PayMerchantUtil payMerchantUtil = new PayMerchantUtil();
@@ -268,9 +278,12 @@ public class payController {
     }
     private final DelayedMessageService delayedMessageService;
     @GetMapping(value = "/test/rabbitTest")
-    public void rabbitTest(@RequestParam("msg") String msg) {
+    public Result<String> rabbitTest(@RequestParam("msg") String msg) throws ExecutionException, InterruptedException {
 //        delayedMessageService.sendOrderExpireMessage(msg);
         log.info("接口调用,发送消息成功");
+        CompletableFuture<String> stringCompletableFuture = directCompletableFutureService.executeTaskWithResult(msg);
+        directCompletableFutureService.executeTaskWithoutResult();
+        return Result.ok(stringCompletableFuture.get());
     }
 
     @GetMapping(value = "/test2")
@@ -280,9 +293,8 @@ public class payController {
                 "\"receivers\":[{\"account\":\"1726971843\",\"amount\":19,\"create_time\":\"2025-10-10T18:08:34+08:00\",\"description\":\"商户:中数未来(广州)信息技术有限公司于订单A01分账所获金额:19\",\"detail_id\":\"36002408162025101037927485682\",\"finish_time\":\"1970-01-01T08:00:00+08:00\",\"result\":\"PENDING\",\"type\":\"MERCHANT_ID\"},{\"account\":\"1726705634\",\"amount\":80,\"create_time\":\"2025-10-10T18:08:34+08:00\",\"description\":\"解冻给分账方\",\"detail_id\":\"36002408162025101037927485683\",\"finish_time\":\"1970-01-01T08:00:00+08:00\",\"result\":\"PENDING\",\"type\":\"MERCHANT_ID\"}],\"state\":\"PROCESSING\",\"sub_mchid\":\"1726705634\",\"transaction_id\":\"4200002834202510107247953928\"}";
 
         WeChatProfitSharingService weChatProfitSharingService = SpringContextUtils.getBean(WeChatProfitSharingService.class);
-        JSONObject jsonObject = weChatProfitSharingService.profitSharings("D202510101728312802", res);
 
-        return jsonObject;
+        return weChatProfitSharingService.profitSharings("D202510101728312802", res);
 
 
 //        //用于证书解密的密钥
@@ -302,7 +314,7 @@ public class payController {
 //        String[] args = {"-k", apiV3key, "-m", mchId, "-f", mchPrivateKeyFilePath,
 //                    "-s", mchSerialNo, "-o", outputFilePath};
 //
-////            CommandLine.run(new CertificateDownloader(), args);
+//            CommandLine.run(new CertificateDownloader(), args);
     }
 
 }

+ 1 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/unionPay/SM3Util.java

@@ -9,6 +9,7 @@ import org.bouncycastle.crypto.digests.SM3Digest;
 import org.bouncycastle.crypto.macs.HMac;
 import org.bouncycastle.crypto.params.KeyParameter;
 import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
+import org.jeecg.async.ThreadPoolProperties;
 import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.modules.pay.config.WeChatProfitSharingService;
 import org.jeecg.modules.pay.config.WechatReceiver;

+ 67 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppOrderController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -13,19 +14,31 @@ import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.app.form.CreateOrderForm;
+import org.jeecg.modules.app.form.InsureOrderInfoForm;
+import org.jeecg.modules.app.form.UserPayForm;
+import org.jeecg.modules.app.service.IOrderService;
 import org.jeecg.modules.pay.config.WeChatProfitSharingService;
 import org.jeecg.modules.system.app.dto.ExportConditionDTO;
 import org.jeecg.modules.system.app.entity.AppOrder;
+import org.jeecg.modules.system.app.entity.InsureOrderInfo;
+import org.jeecg.modules.system.app.entity.InsurePrice;
 import org.jeecg.modules.system.app.form.AppOrderPageForm;
+import org.jeecg.modules.system.app.form.PriceChangeForm;
 import org.jeecg.modules.system.app.form.RefundOrderPageForm;
 import org.jeecg.modules.system.app.service.IAppOrderService;
+import org.jeecg.modules.system.app.service.IInsureOrderInfoService;
+import org.jeecg.modules.system.app.service.IInsurePriceService;
 import org.jeecg.modules.system.app.vo.AppOrderInfoVO;
 import org.jeecg.modules.system.app.vo.ExportConditionVO;
 import org.jeecg.modules.system.app.vo.OrderPageVO;
 import org.jeecg.modules.system.app.vo.RefundOrderPageVO;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -34,6 +47,7 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
@@ -41,6 +55,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 订单表
@@ -57,6 +72,8 @@ public class AppOrderController extends JeecgController<AppOrder, IAppOrderServi
 	private IAppOrderService appOrderService;
     @Autowired
     private WeChatProfitSharingService weChatProfitSharingService;
+    @Autowired
+    private IOrderService orderService;
 	
 	/**
 	 * 分页列表查询
@@ -303,4 +320,54 @@ public class AppOrderController extends JeecgController<AppOrder, IAppOrderServi
         IPage<RefundOrderPageVO> page = appOrderService.refundOrderPageList(refundOrderPageForm);
         return Result.OK(page);
     }
+
+    @Resource
+    private IInsureOrderInfoService insureOrderInfoService;
+    @Resource
+    private IInsurePriceService insurePriceService;
+    @Resource
+    private ISysUserService sysUserService;
+    @Operation(summary = "订单管理-订单改价")
+    @PostMapping(value = "/priceChange")
+    public Result<UserPayForm> priceChange(@RequestBody PriceChangeForm priceChangeForm) {
+
+        AppOrder appOrder = orderService.getById(priceChangeForm.getOrderId());
+        if (ObjectUtil.isEmpty(appOrder)) {
+            throw new JeecgBootException("订单不存在!");
+        }
+        String userId = appOrder.getUserId();
+        SysUser sysUser = sysUserService.getById(userId);
+        //根据订单构建改价后的订单信息(总金额 = 子订单金额 + 保险)
+        CreateOrderForm createOrderForm = new CreateOrderForm();
+        createOrderForm.setType(appOrder.getType());
+        createOrderForm.setOrderType(appOrder.getOrderType());
+        createOrderForm.setOrFreeOrder(appOrder.getOrderOrFree());
+        createOrderForm.setAmount(appOrder.getAmount());
+        createOrderForm.setFamilyIds(appOrder.getFamilyIds());
+        createOrderForm.setGameCertificationForm(appOrder.getGameCertification());
+        //构建商品IDs
+        List<PriceChangeForm.OrderItemForm> orderItemList = priceChangeForm.getOrderItemList();
+        String productIds = orderItemList.stream().map(PriceChangeForm.OrderItemForm::getProductId)
+                .collect(Collectors.joining(","));
+        createOrderForm.setProductIds(productIds);
+        //构建保险表单
+        List<InsureOrderInfo> insureOrderInfoList = insureOrderInfoService.list(Wrappers.<InsureOrderInfo>lambdaQuery().eq(InsureOrderInfo::getOrderId,
+                appOrder.getId()));
+
+        String familyMembersIds = insureOrderInfoList.stream().map(InsureOrderInfo::getFamilyMembersId).collect(Collectors.joining(","));
+
+        InsurePrice insurePrice = insurePriceService.getOne(Wrappers.lambdaQuery(InsurePrice.class).eq(InsurePrice::getInsureId,
+                insureOrderInfoList.get(0).getInsureId()).last("limit 1"));
+
+
+        InsureOrderInfoForm insureOrderInfoForm = new InsureOrderInfoForm();
+        insureOrderInfoForm.setInsureId(insureOrderInfoList.get(0).getInsureId());
+        insureOrderInfoForm.setAssertStartTime(insureOrderInfoList.get(0).getAssertStartTime());
+        insureOrderInfoForm.setAssertEndTime(insureOrderInfoList.get(0).getAssertEndTime());
+        insureOrderInfoForm.setInsurePriceId(insurePrice.getId());
+        insureOrderInfoForm.setFamilyMembersIds(familyMembersIds);
+
+        createOrderForm.setInsureOrderInfoForm(insureOrderInfoForm);
+        return Result.OK(orderService.orderChangePrice(sysUser,priceChangeForm));
+    }
 }

+ 41 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/PriceChangeForm.java

@@ -0,0 +1,41 @@
+package org.jeecg.modules.system.app.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@AllArgsConstructor
+@NoArgsConstructor
+@Schema(description = "订单改价表单对象")
+public class PriceChangeForm implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    private String orderId;
+
+    private BigDecimal price;
+
+    private List<OrderItemForm> orderItemList;
+
+
+    @Data
+    public class OrderItemForm implements Serializable {
+        @Serial
+        private static final long serialVersionUID = 1L;
+
+        private String productId;
+
+        private BigDecimal originalPrice;
+    }
+}

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

@@ -11,6 +11,7 @@ import org.jeecg.modules.system.app.dto.ExportConditionDTO;
 import org.jeecg.modules.system.app.entity.AppGame;
 import org.jeecg.modules.system.app.entity.AppOrder;
 import org.jeecg.modules.system.app.form.AppOrderPageForm;
+import org.jeecg.modules.system.app.form.PriceChangeForm;
 import org.jeecg.modules.system.app.form.RefundOrderPageForm;
 import org.jeecg.modules.system.app.vo.AppOrderInfoVO;
 import org.jeecg.modules.system.app.vo.ExportConditionVO;
@@ -101,4 +102,6 @@ public interface IAppOrderService extends IService<AppOrder> {
     byte[] exportCondition(ExportConditionDTO exportConditionDTO) throws IOException;
 
     IPage<RefundOrderPageVO> refundOrderPageList(RefundOrderPageForm refundOrderPageForm);
+
+    String priceChange(PriceChangeForm priceChangeForm);
 }

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

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
+import com.alipay.api.domain.Person;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,6 +17,8 @@ import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.app.form.CreateOrderForm;
+import org.jeecg.modules.app.form.InsureOrderInfoForm;
 import org.jeecg.modules.app.vo.AppGameScheduleVO;
 import org.jeecg.modules.app.vo.AppOrderProInfoVerifyVO;
 import org.jeecg.modules.app.vo.ScanCodeQueryOrderVO;
@@ -27,6 +30,7 @@ import org.jeecg.modules.system.app.dto.IsinUserInfoDTO;
 import org.jeecg.modules.system.app.dto.VerificationRecordDTO;
 import org.jeecg.modules.system.app.entity.*;
 import org.jeecg.modules.system.app.form.AppOrderPageForm;
+import org.jeecg.modules.system.app.form.PriceChangeForm;
 import org.jeecg.modules.system.app.form.RefundOrderPageForm;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.app.service.IAppOrderService;
@@ -103,6 +107,12 @@ public class AppOrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> i
     @Resource
     private AppOrderRefundsInfoMapper appOrderRefundsInfoMapper;
 
+    @Resource
+    private InsureOrderInfoMapper insureOrderInfoMapper;
+
+    @Resource
+    private InsurePriceMapper insurePriceMapper;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -530,6 +540,18 @@ public class AppOrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> i
         return pages;
     }
 
+    @Override
+    public String priceChange(PriceChangeForm priceChangeForm) {
+
+
+
+
+
+        //修改原订单为已取消
+
+        return "订单改价成功!";
+    }
+
     // 修改 generateExcel 方法返回字节数组
     private byte[] generateExcel(List<Map<String, Object>> dataList) throws IOException {
         Workbook workbook = null;

+ 15 - 6
national-motion-module-system/national-motion-system-start/src/main/resources/application-dev.yml

@@ -413,12 +413,21 @@ http:
       after_inactivity: 30000
 
 # 异步线程池配置
+#async:
+#  thread-pool:
+#    core-pool-size: 10
+#    max-pool-size: 50
+#    queue-capacity: 1000
+#    keep-alive-seconds: 60
+#    thread-name-prefix: "business-async-"
+#    allow-core-thread-timeout: false
+#    await-termination-seconds: 30
 async:
   thread-pool:
-    core-pool-size: 10
-    max-pool-size: 50
-    queue-capacity: 1000
-    keep-alive-seconds: 60
-    thread-name-prefix: "business-async-"
+    core-pool-size: 15
+    max-pool-size: 51
+    queue-capacity: 1001
+    keep-alive-seconds: 61
+    thread-name-prefix: "business-async-1"
     allow-core-thread-timeout: false
-    await-termination-seconds: 30
+    await-termination-seconds: 31