Browse Source

feat(app):
1、支付相关
2、bug修复

wzq 1 month ago
parent
commit
a6a0b5a475
12 changed files with 584 additions and 542 deletions
  1. 4 0
      national-motion-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 12 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/OrderController.java
  3. 2 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/form/UserPayForm.java
  4. 9 2
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/WeChatPayService.java
  5. 489 491
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java
  6. 32 32
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/config/WechatConstants.java
  7. 3 3
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/pay/config/WechatUrlConstants.java
  8. 2 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppSitePriceRulesMapper.xml
  9. 1 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppSitePlaceService.java
  10. 3 5
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSitePlaceServiceImpl.java
  11. 26 4
      national-motion-module-system/national-motion-system-start/src/main/resources/redisson.yml
  12. 1 1
      pom.xml

+ 4 - 0
national-motion-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -106,6 +106,10 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/app/user/loginByCode", "anon");//APP首页接口
         filterChainDefinitionMap.put("/app/esign/signCallback", "anon");//APP首页接口
 
+        filterChainDefinitionMap.put("/applet/wechatPayNotify", "anon");//支付回调
+        filterChainDefinitionMap.put("/applet/refundOrderNotify", "anon");//退款回调
+
+
 //        filterChainDefinitionMap.put("/app/user/**", "anon");//小程序相关
 
         //filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token

+ 12 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/OrderController.java

@@ -133,7 +133,7 @@ public class OrderController {
      * @return
      */
     @Operation(summary = "支付回调")
-    @PostMapping("/wechatPayNotify")
+    @RequestMapping("/wechatPayNotify")
     public Map<String, String> wechatPayNotify(HttpServletRequest request) {
         return appOrderService.wechatPayNotify(request);
     }
@@ -182,6 +182,17 @@ public class OrderController {
         return Result.OK(appOrderService.refundOrder(orderCode));
     }
 
+    /**
+     * 订单退款
+     * @param request
+     * @return
+     */
+    @Operation(summary = "订单退款回调")
+    @RequestMapping("/refundOrderNotify")
+    public Result<String> refundOrderNotify(HttpServletRequest request){
+        return Result.OK();
+    }
+
     /**
      * 订单-小程序支付后回显信息
      *

+ 2 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/form/UserPayForm.java

@@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 import java.io.Serializable;
+import java.util.Map;
 
 @Data
 @Accessors(chain = true)
@@ -22,5 +23,5 @@ public class UserPayForm implements Serializable {
     private String orderCode;
 
     @Schema(description = "JsApi参数")
-    private String params;
+    private Map<String,String> params;
 }

+ 9 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/WeChatPayService.java

@@ -4,12 +4,15 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.aliyun.oss.ServiceException;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.modules.pay.config.WechatConstants;
 import org.jeecg.modules.pay.config.WechatUrlConstants;
 import org.jeecg.modules.pay.util.WechatPayV3Utils;
+import org.jeecg.modules.system.app.entity.AppOrder;
+import org.jeecg.modules.system.app.mapper.AppOrderMapper;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -34,6 +37,9 @@ public class WeChatPayService {
     @Resource
     private WechatPayV3Utils wechatPayV3Utils;
 
+    @Resource
+    private AppOrderMapper appOrderMapper;
+
 
     /**
      * 小程序支付拉起
@@ -46,6 +52,7 @@ public class WeChatPayService {
 
         //发起请求
         JSONObject res = wechatPayV3Utils.sendPost(WechatUrlConstants.PAY_V3_JSAPI, params);
+        log.info("wechatPay res:{}", res.toString());
         if (res == null || StringUtils.isEmpty(res.getString("prepay_id"))) {
             throw new ServiceException("支付发起失败");
         }
@@ -169,9 +176,9 @@ public class WeChatPayService {
 
         // 处理支付成功后的业务 例如 将订单状态修改为已支付 具体参数键值可参考文档 注意!!! 微信可能会多次发送重复的通知 因此要判断业务是否已经处理过了 避免重复处理
         try {
-            String out_trade_no = res.getString("out_trade_no");
-
+            String orderCode = res.getString("out_trade_no");
             //查询订单,判断是否已修改未已支付状态
+            AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getOrderCode, orderCode).last("limit 1"));
 
             result.put("code", "SUCCESS");
             result.put("message", "OK");

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

@@ -218,7 +218,7 @@ public class OrderServiceImpl implements IOrderService {
             });
         });
         AppSitePlace appSitePlace = appSitePlaceMapper.selectById(placeId);
-        previewOrderPlaceSchool.setName(appSitePlace.getName())
+        previewOrderPlaceSchool.setName(appSite.getName())
                 .setId(appSitePlace.getId())
                 .setTimeSlot(timeSlot);
         if (StringUtils.isNotEmpty(appSitePlace.getInsureIds())) {
@@ -492,584 +492,582 @@ public class OrderServiceImpl implements IOrderService {
         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());
+        //订单内容
+        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();
+                    String productId = createOrderForm.getProductIds();
 
-                        productKey = "ORDER_TYPE_1_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
-                        stockKey = "ORDER_TYPE_1_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
+                    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);
-                        // 缓存没有商品库存,查询数据库
-                        if (stock == null) {
-                            AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
-                            if (Objects.isNull(product)) {
-                                throw new JeecgBootException("订单提交失败,商品已下架");
-                            }
-                            redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product),60*60*24,TimeUnit.SECONDS);
-                            // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
-                            stock = product.getTicketNum();
-                            redisTemplate.opsForValue().set(stockKey, stock,60*60*24,TimeUnit.SECONDS);
+                    // 查询库存
+                    Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
+                    // 缓存没有商品库存,查询数据库
+                    if (stock == null) {
+                        AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
+                        if (Objects.isNull(product)) {
+                            throw new JeecgBootException("订单提交失败,商品已下架");
                         }
+                        redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product), 60 * 60 * 24, TimeUnit.SECONDS);
+                        // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
+                        stock = product.getTicketNum();
+                        redisTemplate.opsForValue().set(stockKey, stock, 60 * 60 * 24, TimeUnit.SECONDS);
+                    }
 
-                        // 检查库存是否足够
-                        if (stock < count) {
-                            throw new JeecgBootException("订单提交失败,库存不足");
-                        }
+                    // 检查库存是否足够
+                    if (stock < count) {
+                        throw new JeecgBootException("订单提交失败,库存不足");
+                    }
+
+                    // 更新数据库中的库存数据
+                    int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
+                            .eq(AppSitePriceRules::getId, productId)
+                            .set(AppSitePriceRules::getTicketNum, stock - count));
+                    if (row > 0) {
+                        // 更新Redis中缓存的商品库存数据
+                        redisTemplate.opsForValue().decrement(stockKey, count);
+                    }
+                    // 库存扣减完,创建订单
+                    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())
+                            .setPrice(totalPrice)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(user.getId())
+                            .setUpdateBy(user.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+                    //使用人
+                    List<String> ids = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
+                    for (String id : ids) {
+                        FamilyMembers familyMembers = familyMembersMapper.selectById(id);
+                        if (Objects.isNull(familyMembers)) {
 
-                        // 更新数据库中的库存数据
-                        int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
-                                .eq(AppSitePriceRules::getId, productId)
-                                .set(AppSitePriceRules::getTicketNum, stock - count));
-                        if (row > 0) {
-                            // 更新Redis中缓存的商品库存数据
-                            redisTemplate.opsForValue().decrement(stockKey, count);
                         }
-                        // 库存扣减完,创建订单
-                        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())
-                                .setPrice(totalPrice)
-                                .setCreateTime(new Date())
-                                .setUpdateTime(new Date())
-                                .setCreateBy(user.getId())
-                                .setUpdateBy(user.getId())
-                                .setStatus(CommonConstant.STATUS_NORMAL)
+
+                        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 = date + " " + endTime;
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo
+                                .setProductId(priceRule.getId())
+                                .setProductName("学校场地预约")
+                                .setType(CommonConstant.ORDER_PRO_INFO_TYPE_1)
+                                .setUseDateStr(date)
+                                .setFrameTimeStr(startTime + "-" + endTime)
+                                .setExpireTime(expireTime)
+                                .setOriginalPrice(priceRule.getOriginalPrice())
+                                .setProductImage(appSitePlace.getCover())
+                                .setAddress(appSite.getAddress())
+                                .setPrice(priceRule.getSellingPrice())
+                                .setOrderStatus(0)
+                                .setQuantity(1)
+                                .setFamilyUserId(id)
+                                .setUserName(familyMembers.getFullName())
+                                .setUserPhone(familyMembers.getPhone())
+                                .setStatus(CommonConstant.STATUS_0_INT)
                                 .setDelFlag(CommonConstant.DEL_FLAG_0);
-                        //使用人
-                        List<String> ids = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
-                        for (String id : ids) {
-                            FamilyMembers familyMembers = familyMembersMapper.selectById(id);
-
-                            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 = date + " " + endTime;
-                            AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
-                            appOrderProInfo
-                                    .setProductId(priceRule.getId())
-                                    .setProductName("学校场地预约")
-                                    .setType(CommonConstant.ORDER_PRO_INFO_TYPE_1)
-                                    .setUseDateStr(date)
-                                    .setFrameTimeStr(startTime + "-" + endTime)
-                                    .setExpireTime(expireTime)
-                                    .setOriginalPrice(priceRule.getOriginalPrice())
-                                    .setProductImage(appSitePlace.getCover())
-                                    .setAddress(appSite.getAddress())
-                                    .setPrice(priceRule.getSellingPrice())
-                                    .setOrderStatus(0)
-                                    .setQuantity(1)
-                                    .setFamilyUserId(id)
-                                    .setUserName(familyMembers.getFullName())
-                                    .setUserPhone(familyMembers.getPhone())
-                                    .setStatus(CommonConstant.STATUS_0_INT)
-                                    .setDelFlag(CommonConstant.DEL_FLAG_0);
-
-                            proInfoList.add(appOrderProInfo);
+
+                        proInfoList.add(appOrderProInfo);
 //                        appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getId,appSite.getId())).forEach(appDevice -> {
 //                            addUser(priceRule.getDateOfSale(),appDevice.getDeviceSerial(),familyMembers.getFullName(),id);
 //                        });
-                        }
                     }
+                }
 
-                    //包场
-                    if (createOrderForm.getOrderType() == 1) {
+                //包场
+                if (createOrderForm.getOrderType() == 1) {
 
-                        List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
+                    List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
 
-                        //订单总价(商品的售价总和)
-                        BigDecimal sumPrice = new BigDecimal(0);
+                    //订单总价(商品的售价总和)
+                    BigDecimal sumPrice = new BigDecimal(0);
 
-                        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 (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());
 
                         appOrder.setOrgCode(appSite.getOrgCode());
 
-                            String date = list.get(i).split("\\|")[1];
-                            String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
-                            String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
-                            String expireTime = date + " " + endTime;
-
-                            AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
-                            appOrderProInfo.setProductId(list.get(i).split("\\|")[0]);
-                            appOrderProInfo.setProductName(date + " " + startTime + "-" + endTime + "|" + appSitePlace.getName());
-                            appOrderProInfo.setProductImage(appSitePlace.getCover());
-                            appOrderProInfo.setExpireTime(expireTime);
-                            appOrderProInfo.setAddress(appSite.getAddress());
-                            appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_2);
-                            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);
-                            appOrder.setOrgCode(appSitePlace.getOrgCode())
-                                    .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
-
-                            sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        }
+                        String date = list.get(i).split("\\|")[1];
+                        String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
+                        String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
+                        String expireTime = date + " " + endTime;
 
-                        //计算订单总价
-                        totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
-
-                        appOrder
-                                .setType(CommonConstant.ORDER_TYPE_0)
-                                .setOriginalPrice(sumPrice)
-                                .setCreateTime(new Date())
-                                .setUpdateTime(new Date())
-                                .setCreateBy(user.getId())
-                                .setUpdateBy(user.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());
+                        AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                        appOrderProInfo.setProductId(list.get(i).split("\\|")[0]);
+                        appOrderProInfo.setProductName(date + " " + startTime + "-" + endTime + "|" + appSitePlace.getName());
+                        appOrderProInfo.setProductImage(appSitePlace.getCover());
+                        appOrderProInfo.setExpireTime(expireTime);
+                        appOrderProInfo.setAddress(appSite.getAddress());
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_2);
+                        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);
 
-                        //订单总价(商品的售价总和)
-                        BigDecimal sumPrice = new BigDecimal(0);
-                        //团购优惠
-                        BigDecimal tDiscounts = new BigDecimal(0);
-
-                        for (int i = 1; i <= createOrderForm.getAmount(); i++) {
-
-                            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 = date + " " + endTime;
-
-                            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_3);
-                            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())).setScale(2, BigDecimal.ROUND_HALF_UP);
-                            sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        }
+                        proInfoList.add(appOrderProInfo);
+                        appOrder.setOrgCode(appSitePlace.getOrgCode())
+                                .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
 
-                        //计算订单总价
-                        totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
-
-                        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(user.getId())
-                                .setUpdateBy(user.getId())
-                                .setStatus(CommonConstant.STATUS_NORMAL)
-                                .setDelFlag(CommonConstant.DEL_FLAG_0);
+                        sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
                     }
-                    break;
-                //赛事
-                case 1:
-                    //个人赛
-                    AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
-                    AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
-                    AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
 
+                    //计算订单总价
+                    totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
+
+                    appOrder
+                            .setType(CommonConstant.ORDER_TYPE_0)
+                            .setOriginalPrice(sumPrice)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(user.getId())
+                            .setUpdateBy(user.getId())
+                            .setStatus(CommonConstant.STATUS_NORMAL)
+                            .setDelFlag(CommonConstant.DEL_FLAG_0);
+                }
 
-                    appOrder.setOrgCode(appGamePriceRules.getOrgCode());
-                    appOrder.setTenantId(appGamePriceRules.getTenantId());
+                //无固定场
+                if (createOrderForm.getOrderType() == 2) {
+                    AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                    AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
+                    AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
 
                     //订单总价(商品的售价总和)
                     BigDecimal sumPrice = new BigDecimal(0);
+                    //团购优惠
+                    BigDecimal tDiscounts = new BigDecimal(0);
 
                     for (int i = 1; i <= createOrderForm.getAmount(); i++) {
 
-                        String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
-                        FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
+                        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 = date + " " + endTime;
+
                         AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
                         appOrderProInfo.setProductId(createOrderForm.getProductIds());
-                        appOrderProInfo.setProductName(appGame.getName());
-                        appOrderProInfo.setAddress(appGame.getAddress());
-                        if (createOrderForm.getOrderType() == 3) {
-                            appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
-                        }
-                        if (createOrderForm.getOrderType() == 4) {
-                            appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_5);
-                        }
-                        appOrderProInfo.setFrameTimeStr(appGame.getStartTime() + "-" + appGame.getEndTime());
-                        appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
-                        appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
-                        appOrderProInfo.setPrice(appGamePriceRules.getSellingPrice());
+                        appOrderProInfo.setProductName(appSitePlace.getName());
+                        appOrderProInfo.setProductImage(appSitePlace.getCover());
+                        appOrderProInfo.setAddress(appSite.getAddress());
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_3);
+                        appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
+                        appOrderProInfo.setExpireTime(expireTime);
+                        appOrderProInfo.setOriginalPrice(priceRule.getOriginalPrice());
+                        appOrderProInfo.setPrice(priceRule.getSellingPrice());
                         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()).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        tDiscounts = tDiscounts.add(priceRule.getOriginalPrice().subtract(priceRule.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
                     }
+
                     //计算订单总价
                     totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
 
                     appOrder
-                            .setType(CommonConstant.ORDER_TYPE_1)
-                            .setAddressSiteId(appGame.getSiteId())
+                            .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(user.getId())
                             .setUpdateBy(user.getId())
                             .setStatus(CommonConstant.STATUS_NORMAL)
                             .setDelFlag(CommonConstant.DEL_FLAG_0);
-                    if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
-                        appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
-                    }
-                    break;
-                //课程
-                case 2:
-                    //课程
-                    AppCourses appCourse = appCoursesMapper.selectById(appOrder.getProductIds());
-                    List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
-                    AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
+                }
+                break;
+            //赛事
+            case 1:
+                //个人赛
+                AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
+                AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
+                AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
 
-                    String productId = createOrderForm.getProductIds();
 
-                    productKey = "ORDER_TYPE_5_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
-                    stockKey = "ORDER_TYPE_5_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
+                appOrder.setOrgCode(appGamePriceRules.getOrgCode());
+                appOrder.setTenantId(appGamePriceRules.getTenantId());
 
-                    // 查询库存
-                    Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
-                    // 缓存没有商品库存,查询数据库
-                    if (stock == null) {
-                        AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
-                        if (Objects.isNull(product)) {
-                            throw new JeecgBootException("订单提交失败,商品已下架");
-                        }
-                        redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product));
-                        // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
-                        stock = product.getTicketNum();
-                        redisTemplate.opsForValue().set(stockKey, stock);
-                    }
+                //订单总价(商品的售价总和)
+                BigDecimal sumPrice = new BigDecimal(0);
 
-                    // 检查库存是否足够
-                    if (stock < count) {
-                        throw new JeecgBootException("订单提交失败,库存不足");
-                    }
+                for (int i = 1; i <= createOrderForm.getAmount(); i++) {
 
-                    // 更新数据库中的库存数据
-                    int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
-                            .eq(AppSitePriceRules::getId, productId)
-                            .set(AppSitePriceRules::getTicketNum, stock - count));
-                    if (row > 0) {
-                        // 更新Redis中缓存的商品库存数据
-                        redisTemplate.opsForValue().decrement(stockKey, count);
+                    String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
+                    FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
+                    AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
+                    appOrderProInfo.setProductId(createOrderForm.getProductIds());
+                    appOrderProInfo.setProductName(appGame.getName());
+                    appOrderProInfo.setAddress(appGame.getAddress());
+                    if (createOrderForm.getOrderType() == 3) {
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
                     }
-
-                    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());
+                    if (createOrderForm.getOrderType() == 4) {
+                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_5);
                     }
+                    appOrderProInfo.setFrameTimeStr(appGame.getStartTime() + "-" + appGame.getEndTime());
+                    appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
+                    appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
+                    appOrderProInfo.setPrice(appGamePriceRules.getSellingPrice());
+                    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);
 
-                    //订单总价(商品的售价总和)
-                    BigDecimal sumCoursePrice = new BigDecimal(0);
-
-                    //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
-                    BigDecimal sDiscounts = new BigDecimal(0);
-                    BigDecimal tDiscounts = new BigDecimal(0);
-
-                    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(appCourse.getName());
-                        appOrderProInfo.setAddress(appSite.getAddress());
-                        appOrderProInfo.setProductImage(appCourse.getCover());
-                        appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
-                        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.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)) {
-                            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 (createOrderForm.getOrFreeOrder() == 1) {
-                            Boolean flag = checkOrderOrFree(user.getId(), appCourse.getCategoryId());
-                            if (!flag && i == 1) {
-                                //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
-                                sDiscounts = sDiscounts.add(appCourse.getSellingPrice());
-                                appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
-                                appOrder.setContractNo(null);
-                                //试听优惠
-                                appOrder.setSDiscounts(sDiscounts);
-                            }
-                        }
+                    proInfoList.add(appOrderProInfo);
 
-                        proInfoList.add(appOrderProInfo);
+                    sumPrice = sumPrice.add(appGamePriceRules.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
+                }
+                //计算订单总价
+                totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
 
-                        tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
+                appOrder
+                        .setType(CommonConstant.ORDER_TYPE_1)
+                        .setAddressSiteId(appGame.getSiteId())
+                        .setOriginalPrice(sumPrice)
+                        .setCreateTime(new Date())
+                        .setUpdateTime(new Date())
+                        .setCreateBy(user.getId())
+                        .setUpdateBy(user.getId())
+                        .setStatus(CommonConstant.STATUS_NORMAL)
+                        .setDelFlag(CommonConstant.DEL_FLAG_0);
+                if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
+                    appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
+                }
+                break;
+            //课程
+            case 2:
+                //课程
+                AppCourses appCourse = appCoursesMapper.selectById(appOrder.getProductIds());
+                List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
+                AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
+
+                String productId = createOrderForm.getProductIds();
+
+                productKey = "ORDER_TYPE_5_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
+                stockKey = "ORDER_TYPE_5_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
+
+                // 查询库存
+                Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
+                // 缓存没有商品库存,查询数据库
+                if (stock == null) {
+                    AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
+                    if (Objects.isNull(product)) {
+                        throw new JeecgBootException("订单提交失败,商品已下架");
                     }
+                    redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product));
+                    // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
+                    stock = product.getTicketNum();
+                    redisTemplate.opsForValue().set(stockKey, stock);
+                }
 
-                    //计算订单总价
-                    totalPrice = totalPrice.add(sumCoursePrice).setScale(2, BigDecimal.ROUND_HALF_UP);
+                // 检查库存是否足够
+                if (stock < count) {
+                    throw new JeecgBootException("订单提交失败,库存不足");
+                }
 
-                    //团购优惠
-                    appOrder.setTDiscounts(tDiscounts);
-                    //原订单总价
-                    appOrder.setOriginalPrice(sumCoursePrice);
-                    //使用人IDs
-                    appOrder.setFamilyIds(createOrderForm.getFamilyIds());
-
-                    appOrder.setAddressSiteId(appSite.getId());
-                    break;
-            }
+                // 更新数据库中的库存数据
+                int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
+                        .eq(AppSitePriceRules::getId, productId)
+                        .set(AppSitePriceRules::getTicketNum, stock - count));
+                if (row > 0) {
+                    // 更新Redis中缓存的商品库存数据
+                    redisTemplate.opsForValue().decrement(stockKey, count);
+                }
 
+                appOrder.setType(CommonConstant.ORDER_TYPE_2);
+                appOrder.setOrgCode(appCourse.getOrgCode());
+                appOrder.setTenantId(appCourse.getTenantId());
 
-            //构建保单内容
-            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()).setScale(2, BigDecimal.ROUND_HALF_UP);
+                //合同编号
+                AppContractInfo appContractInfo = appContractInfoMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery()
+                        .eq(AppContractInfo::getOrgCode, appOrder.getOrgCode()).eq(AppContractInfo::getDelFlag, 0));
+                if (ObjectUtil.isNotEmpty(appContractInfo)) {
+                    appOrder.setContractNo(appContractInfo.getId());
                 }
-                //计算总价 = 订单金额 + 保单金额
-                totalPrice = totalPrice.add(sumPrice);
-            }
-            appOrder.setPrice(totalPrice);
-            appOrderMapper.insert(appOrder);
-            if(appOrder.getType() == 2){
-                saveSignFlowRecord(appOrder);
-            }
 
-            if (!insureOrderInfoList.isEmpty()) {
-                //保存保险
-                for (InsureOrderInfo insureOrderInfo : insureOrderInfoList) {
-                    insureOrderInfo.setOrderId(appOrder.getId());
-                    insureOrderInfoMapper.insert(insureOrderInfo);
+                //订单总价(商品的售价总和)
+                BigDecimal sumCoursePrice = new BigDecimal(0);
 
-                    AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
-                    appOrderProInfo.setProductId(insureOrderInfo.getId());
-                    appOrderProInfo.setProductName(insureOrderInfo.getInsureName());
-                    appOrderProInfo.setProductImage(insureOrderInfo.getCoverImg());
-                    appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_7);
+                //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
+                BigDecimal sDiscounts = new BigDecimal(0);
+                BigDecimal tDiscounts = new BigDecimal(0);
+
+                for (int i = 1; i <= createOrderForm.getAmount(); i++) {
 
-                    appOrderProInfo.setPrice(insureOrderInfo.getMoney());
+                    String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
+                    FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
+                    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_6);
+                    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.setOrderStatus(0);
                     appOrderProInfo.setQuantity(1);
-                    FamilyMembers familyMembers = familyMembersMapper.selectById(insureOrderInfo.getFamilyMembersId());
-                    appOrderProInfo.setFamilyUserId(familyMembers.getId());
+                    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)) {
+                        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 (createOrderForm.getOrFreeOrder() == 1) {
+                        Boolean flag = checkOrderOrFree(user.getId(), appCourse.getCategoryId());
+                        if (!flag && i == 1) {
+                            //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
+                            sDiscounts = sDiscounts.add(appCourse.getSellingPrice());
+                            appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
+                            appOrder.setContractNo(null);
+                            //试听优惠
+                            appOrder.setSDiscounts(sDiscounts);
+                        }
+                    }
+
                     proInfoList.add(appOrderProInfo);
+
+                    tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
+
+                //计算订单总价
+                totalPrice = totalPrice.add(sumCoursePrice).setScale(2, BigDecimal.ROUND_HALF_UP);
+
+                //团购优惠
+                appOrder.setTDiscounts(tDiscounts);
+                //原订单总价
+                appOrder.setOriginalPrice(sumCoursePrice);
+                //使用人IDs
+                appOrder.setFamilyIds(createOrderForm.getFamilyIds());
+
+                appOrder.setAddressSiteId(appSite.getId());
+                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()).setScale(2, BigDecimal.ROUND_HALF_UP);
+            }
+            //计算总价 = 订单金额 + 保单金额
+            totalPrice = totalPrice.add(sumPrice);
+        }
+        appOrder.setPrice(totalPrice);
+        appOrderMapper.insert(appOrder);
+        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_7);
+
+                appOrderProInfo.setPrice(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
+        for (AppOrderProInfo appOrderProInfo : proInfoList) {
+            appOrderProInfo
+                    .setOrderId(appOrder.getId())
+                    .setOrderCode(appOrder.getOrderCode())
+                    //生成10位随机券号
+                    .setTicketNo(RandomUtil.randomNumbers(10))
+            ;
+            appOrderProInfoMapper.insert(appOrderProInfo);
+            if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_7)) {
+                //订单券号记录
+                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())
+                        .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
+                        //过期时间
+                        .setExpireTime(appOrderProInfo.getExpireTime())
                         //生成10位随机券号
-                        .setTicketNo(RandomUtil.randomNumbers(10))
-                ;
-                appOrderProInfoMapper.insert(appOrderProInfo);
-                if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_7)) {
-                    //订单券号记录
-                    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())
-                            .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
-                            //过期时间
-                            .setExpireTime(appOrderProInfo.getExpireTime())
-                            //生成10位随机券号
-                            .setTicketNo(appOrderProInfo.getTicketNo())
-                            .setIsinStatus(CommonConstant.ISIN_STATUS_1);
-                    appIsinMapper.insert(appIsin);
-                }
-                if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_1)) {
-                    appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode, appOrder.getOrgCode())).forEach(appDevice -> {
-                        try {
-                            String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
-                                    appDevice.getDeviceSerial(),
-                                    appOrderProInfo.getUserName(),
-                                    appOrderProInfo.getId());
-                            String addFace = addFace(appDevice.getDeviceSerial(), appOrderProInfo.getId(),
-                                    familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId()).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("设备录入用户信息失败!请联系管理员");
-                        } catch (Exception e) {
+                        .setTicketNo(appOrderProInfo.getTicketNo())
+                        .setIsinStatus(CommonConstant.ISIN_STATUS_1);
+                appIsinMapper.insert(appIsin);
+            }
+            if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_1)) {
+                appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode, appOrder.getOrgCode())).forEach(appDevice -> {
+                    try {
+                        String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
+                                appDevice.getDeviceSerial(),
+                                appOrderProInfo.getUserName(),
+                                appOrderProInfo.getId());
+                        String addFace = addFace(appDevice.getDeviceSerial(), appOrderProInfo.getId(),
+                                familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId()).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("设备录入用户信息失败!请联系管理员");
-                        }
-                    });
-                }
+                    } catch (Exception e) {
+                        throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
+                    }
+                });
             }
+        }
 
-            //保存核销记录
-            if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
-                for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
-                    appCoursesVerificationRecord.setOrderId(appOrder.getId());
-                    appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
-                    appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
-                }
+        //保存核销记录
+        if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
+            for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
+                appCoursesVerificationRecord.setOrderId(appOrder.getId());
+                appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
+                appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
             }
+        }
 
-            //构建支付表单返回给前端支撑JsApi支付调用
-            UserPayForm payForm = new UserPayForm();
-            payForm
-                    .setOrderId(appOrder.getId())
-                    .setOrderCode(orderCode)
-            ;
-            Calendar calendar = Calendar.getInstance();
-            calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
-
-            //构建微信支付参数
-            JSONObject params = new JSONObject();
-            params.put("sub_appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
-            params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
-            params.put("description", "胶片订单业务"); //商品描述
-            params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
-            params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
-            params.put("attach", appOrder.getOrderCode()); //附加数据 选填
-            // 在查询API和支付通知中原样返回 可作为自定义参数使用
-            params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
-            params.put("trade_type", "JSAPI"); //支付类型
-            //分账必传参数
-            params.put("profit_sharing", "Y");
-
-            //订单金额信息
-            JSONObject amount_json = new JSONObject();
-            //支付金额 单位:分
-//        amount_json.put("total", Integer.parseInt(amount_fee(Double.valueOf("0.1"))));
-            amount_json.put("total", Integer.parseInt(amount_fee(appOrder.getPrice())));
-            params.put("amount", amount_json);
-
-            //支付者信息
-            JSONObject payer = new JSONObject();
-            //用户在小程序侧的openid
-            payer.put("openid", sysUser.getOpenid());
-            params.put("payer", payer);
-
-            //拉起支付
-//        Map<String, String> result = weChatPayService.wechatPay(params);
-
-
-            String sub_appid = "wx62ba790ae7983d34";
-            String user_id = "oWL7G6MsNrimSKUgr2ezEXgEp4Po";
-
-
-            //预支付订单,返回构建小程序支付拉起参数
-
-            //发布任务到redission延迟队列
-            String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
-            redissonDelayQueue.offerTask(task, 60 * 15);
-
-            return payForm;
+        //构建支付表单返回给前端支撑JsApi支付调用
+        UserPayForm payForm = new UserPayForm();
+        payForm
+                .setOrderId(appOrder.getId())
+                .setOrderCode(orderCode)
+        ;
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
+
+        //构建微信支付参数
+        JSONObject params = new JSONObject();
+        params.put("appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
+//        params.put("sub_appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
+        params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
+        params.put("description", "全龄运动"); //商品描述
+        params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
+        params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
+        params.put("attach", appOrder.getOrderCode()); //附加数据 选填
+        // 在查询API和支付通知中原样返回 可作为自定义参数使用
+        params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
+
+        //分账必传参数
+        JSONObject settleInfo = new JSONObject();
+        settleInfo.put("profit_sharing", Boolean.TRUE);
+        params.put("settle_info", settleInfo);
+
+        //订单金额信息
+        JSONObject amount_json = new JSONObject();
+        //支付金额 单位:分
+        amount_json.put("total", Integer.parseInt(amount_fee(new BigDecimal("0.01"))));//测试0.01元
+//        amount_json.put("total", Integer.parseInt(amount_fee(appOrder.getPrice())));
+        params.put("amount", amount_json);
+
+        //支付者信息
+        JSONObject payer = new JSONObject();
+        //用户在小程序侧的openid
+        payer.put("openid", sysUser.getOpenid());
+        params.put("payer", payer);
+
+        //拉起支付-返回JSAPI参数
+        Map<String, String> result = weChatPayService.wechatPay(params);
+        payForm.setParams(result);
+
+        //发布任务到redission延迟队列
+        String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
+        redissonDelayQueue.offerTask(task, 60 * 15);
+
+        return payForm;
 
     }
 

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

@@ -8,51 +8,51 @@ package org.jeecg.modules.pay.config;
 public class WechatConstants {
 
     //微信支付商户号
-    public static final String WECHAT_MCH_ID = "1523499681";
+    public static final String WECHAT_MCH_ID = "1725633528";
 
     //微信商户平台v2密钥
-    public static final String WECHAT_MCH_SECRET_V2 = "";
+    public static final String WECHAT_MCH_SECRET_V2 = "zxLgd8V5mGmUAZ8WPYsFERCZU8axviXd";
 
     //微信商户平台v3密钥
-    public static final String WECHAT_MCH_SECRET_V3 = "b63646f9b01e573c5bed89dc0f21039e";
+    public static final String WECHAT_MCH_SECRET_V3 = "UgGn46U6R5QUOoSxueDmVnE9VoqP82DY";
 
     //微信商户平台商户API证书序列号
-    public static final String WECHAT_MCH_SERIAL_NUM = "6CDB06258529D6EA00DE5C0AD9D09A5789EBF735";
+    public static final String WECHAT_MCH_SERIAL_NUM = "374BD3D18A29DFADDF5651BEDA26C35885CB3BB4";
 
     //微信商户平台证书私钥 即证书中的apiclient_key.pem文件中的内容 可以直接写在这里 也可以用流读取文件
     public static final String WECHAT_MCH_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----\n" +
-            "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD6iXfH9KYx9qEL\n" +
-            "peWSx104M7lne8jRBit6WR2mvIWNN8xIFhnt1xZYQq21AM4g6rQCDSI+4b0Fql3p\n" +
-            "ts5PDV/uFZno5A3eKw/wJs8MPd25oIS17bUfzuvLUEA50aQaySk06ggeBd7kBHzH\n" +
-            "Vynwqv0hA9GnYANFD6tKescHHSjKl5OfNIxYDnCgt4mxJpVBCS8AdSi6iTXdfwAW\n" +
-            "l5pazkV+j0GeI6u/HeRFfhFD2VreI4/QYLyUAgJqey81QJOhinolVx99igDg17t/\n" +
-            "y9bcvtsz3nmNx2hbg9C64Tb/TyUzhcIDza/Cx5aUoHDQo44fJsHUv6oVQfzNiUh2\n" +
-            "T0ar+MTPAgMBAAECggEABJ05hoY79Vmcd7Fze/OOBPX26S//b9IUROmVQTfhocsw\n" +
-            "SPeXPKkkcTWxK087fKG19P+27L+NkqgjmKVUQWJ2rNTbA84Hb1sNrReZ4pjVF5Ec\n" +
-            "QJmDJ3XRI+pzdF0nD5M63g2dXqgvBbYLckRpslQD23LNjq6XANOcDQAb4EaqNKjy\n" +
-            "q9NTLDDL5CnkkO6cTGfuXhpa3x5XdwT9rLh9PGFUCEkNNvyT7zX/M+z+2DONEiTQ\n" +
-            "4WasNV3f0VPPZ87O2TdjtvwXWke3s50xY4wiYZ5ZLjAyDCPkDGN6AQ6EOmN2GC6y\n" +
-            "29FQZwt6rw/Gj2OIaeq53hylMZt9tlVHfvnkkEHv+QKBgQD/+u9vnemPOu4DRMLy\n" +
-            "a9W4+wSDy7F/dUfR+r5uMC95GqhdWRTMOe//+16XancSIDRhkqCi6LM2uRJTu85w\n" +
-            "/a3gWriLFgUdAeT2FBAIlFo3hkwvQM+PlTJi/7OXLaAShW+AGHPm8brwR8vcP4cp\n" +
-            "UEhHxb6bzuR1r1SA0NXtl9FkJQKBgQD6jmzGS2+7pyiZ+S78whBNFFh4gSTKsRR2\n" +
-            "Eg6hRW/WcNJso7JqfOwN4HT/2iX9uYEY/E62MA/54x533shRuGJyr7lxwQI+J0uj\n" +
-            "imBoUSV6NJjQssmR4BUcLFO9vqk+cogk9vq3/CFHzXmr3M87kOhHZupL8PUb1avN\n" +
-            "UZ0T50uY4wKBgQCkyRiMJP7uyoPgLMrGnm6mN0mvwlgQciJ65UzjyDc3YdbSyP7f\n" +
-            "fcinZF1/YfUnAP5XdbndRang54EJ0FPUXyoozJ4SQ2mlQ8vuMfokW8Q8DENNBA7a\n" +
-            "IrSeEHe/MYrjgWzG7HboS+MIvV9Z+Ld8/Aab1Yuf568gp27hwg6Fdf9A1QKBgApm\n" +
-            "Ht2cA+cl6Ol7Dhgvdb29Om7F7WD8OH0uAq1u1FVyGUmpAZ6p0KJCzphP1YPSTyla\n" +
-            "T2oAVKlqY7lV5bp+jJd185xlBlLODrWa6KVruMJ5rF39DaCgTD//FvqpDx0oY74l\n" +
-            "AgLg1ADG5mXbpD40pW9RNigwt/uPwrGi0YIh92FBAoGBAMPfRnfiEXy/JLica4/L\n" +
-            "IOq+hhy/zpskSUu0jJZU8/G2YnlcOpw1SylTPVYrLJP8F5W0O/W9hdEl7935g6tG\n" +
-            "ixsK7QnS/AvCJaG+gOe/FaAyewk5LHKJ8WaLeh1QjxbmFgiExYLf7qNlkaUveHEK\n" +
-            "rJ5ZgP1qxeXFkhECXR0/QW49\n" +
+            "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCvPhewCxy8aL/O\n" +
+            "RWB7TTdZAsqmHSsuKFEtLOYng6VfEpCJ7Y/GyV2EWzmko//2GHsYVcCCR8Kw+NCf\n" +
+            "cNJsPL4gGGUPXRePebfjPyBgc0TC7rFE0XMh62HXkhosTcRmVrQwzSVWx+T05nwQ\n" +
+            "gVY7V84yAlhXTe6qgAflkzphjnr43nz1Qlqa6leMZa5gzhriqEQDwux0XJVIFm4R\n" +
+            "qZlpSk8tu9k5y+1wKJNytEEYw/q40fwryqT08JKZ78bBTprTp29M97ntvRtrqyeY\n" +
+            "ENLrII8hibaRhhGcGNHsnukLrNK4a78zTF3GRA0YWQkXqWPlJvlV1op4gPdABSGb\n" +
+            "bitJb1XLAgMBAAECggEAZOw+mh0cNImjBPlBgmFK4dFQwfAEgTWo4np8Jf+UCrfX\n" +
+            "VAfjiJlJaUNcZCwq6iDZK3+fOah4QJFbHKfOF5W37SX/daSoP/HabF5bmBBqZlUu\n" +
+            "9DInuz4jABJdTmyPEl0WsxBCU8MVYdEnXB4QemasEnL1S3pPXBQV+CodMjfrLE2J\n" +
+            "kWPvRHPoJPrsI43/y5cYRnN1fGGMLe7yy8JpssWqSXNybdt7EiVcawFC5KzYVwU7\n" +
+            "CfTtAlLr0t66IHyMjobjPAz8YvTPS/3BOCd10tFJRHIoft0rRF3glNn1lrRShMQ+\n" +
+            "VERvF62lWRhy8S+dDBc2XJMKYbichis98aRHoie9UQKBgQDgFnIlMvjO41aVP/iE\n" +
+            "UNcq46Nym/V5SurXcERP14CU68TLyrQkxcSRi2KMDHBYE/eXoRztVg2sKSh6XKHq\n" +
+            "5by65Ipr9iYt10LWqnJHta26NzreVkPwBxiOGkHxPJsucOkE8iZehMy1rth77CFo\n" +
+            "MMO7Ow9rXuLipHxVbTucmHHg2QKBgQDIMubppbLs4e58bkWKkSVjSm9x0NAMNYbn\n" +
+            "6p7ULgZ+VqCDO+y6SDAFWMMin5MNuTzx94HqK6e/QhpYktVIDvBXv+psHeBsf80e\n" +
+            "kTGEwax1Am5kNoa5UIPWHPgnTcASPzQU0hOIN+QIxmuBIhl1EdvGcEjm+YdNb0Pi\n" +
+            "ajyPXd9FQwKBgHsz3A4XuDQHSdNFGJ2m1KYAAh1BIfVN+0/3qZc8JLW76rcg+2o8\n" +
+            "UZazy7q0HBBQ6g+zxPO4HExLVLXxuBQtu1YF0RUKgHMzpsvfanWCrcF0HCmhxDhz\n" +
+            "rkxyo06+w5MFARh3CiFtYh+BwgRgDv350aNfFVszEAsL5FATfnLaXcIBAoGBALFX\n" +
+            "3hPl091husiBSpsYPr15J8X0Cwh1tj7lKLOe3eO2y1PVlrvhzKA/5ARcxYCnsiRK\n" +
+            "c8xDxcJ4RSxnTgYaLbAd8wS5Zp/WipbkWbBXfHTepXmij6/DcjYOzYjLqDTBxloX\n" +
+            "SnQlxpw7YOowkcqR+lUMDJiHPONMiB8equz5ZBpPAoGAYzCkfH4OU3tXCnnYd6mR\n" +
+            "mgcdPpCGSWSYtt+dA8xtaQqFSaTIWFigEVXZn4aWKDZtOTOsm+8qMEWjuo8hbT+p\n" +
+            "+EJOTwyIPgFmaFcegLMTjo0atYP0ma01a4p45RCl5ZFWuPAD/O/4PwHlGtaekgcM\n" +
+            "bJpFz2T7LShklvgAcQk9wbA=\n" +
             "-----END PRIVATE KEY-----\n";
 
     //微信小程序appid
-    public static final String WECHAT_MP_APPID = "wx9b0396a7507e3d66";
+    public static final String WECHAT_MP_APPID = "wx6260718c6fd46efb";
 
     //微信小程序密钥
-    public static final String WECHAT_MP_SECRET = "22b78f76ab5282030ffa08208b223efd";
+    public static final String WECHAT_MP_SECRET = "";
 
 }

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

@@ -2,7 +2,7 @@ package org.jeecg.modules.pay.config;
 
 /**
  * @author wangzhiqiang
- * @Date 2022/12/22
+ * @Date 2025/08/21
  * @Desc 微信相关接口请求地址 其中最后四个通知接口地址,是自己服务器的接口地址,必须为外网可访问的url,不能携带参数。 公网域名必须为https,如果是走专线接入,使用专线NAT IP或者私有回调域名可使用http。
  */
 public class WechatUrlConstants {
@@ -34,9 +34,9 @@ public class WechatUrlConstants {
     public final static String PAY_V2_REFUND_NOTIFY = "https://xxx.com/api/wechatPay/wechatRefundNotify";
 
     //微信支付v3 支付通知接口地址
-    public final static String PAY_V3_NOTIFY = "https://barcodeapp.gzspy.org.cn/applet/wechatPayNotify";
+    public final static String PAY_V3_NOTIFY = "https://610cfedc.r28.cpolar.top/jeecg-boot/app/order/wechatPayNotify";
 
     //微信支付v3 退款通知接口地址
-    public final static String PAY_V3_REFUND_NOTIFY = "https://xxx.com/api/wechatPay/v3/wechatRefundNotify";
+    public final static String PAY_V3_REFUND_NOTIFY = "https://610cfedc.r28.cpolar.top/jeecg-boot/app/order/refundOrderNotify";
 
 }

+ 2 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppSitePriceRulesMapper.xml

@@ -66,7 +66,8 @@
         FROM
             `nm_site_price_rules`
         WHERE
-            date_of_sale = #{startTime}
+            del_flag = 0
+           AND date_of_sale = #{startTime}
           AND site_place_id = #{placeId};
     </select>
     <select id="previewOrderPlaceGymnasiumChartered" resultType="org.jeecg.modules.app.vo.OrderVO$PreviewOrderTimePeriod">

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppSitePlaceService.java

@@ -114,7 +114,7 @@ public interface IAppSitePlaceService extends IService<AppSitePlace> {
 
     boolean addSchoolPlace(SchoolPlaceAddDTO schoolPlaceAddDTO);
 
-    SchoolPlaceAddDTO querySchoolPlace(String tenantId);
+    SchoolPlaceAddDTO querySchoolPlace(String orgCode);
 
     AppSitePlaceParkDTO queryPack(String siteId);
 

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

@@ -711,7 +711,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
     public boolean addSchoolPlace(SchoolPlaceAddDTO schoolPlaceAddDTO) {
 
         //部门ID查询学校场地
-        AppSite site = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getTenantId, schoolPlaceAddDTO.getTenantId()));
+        AppSite site = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getTenantId, schoolPlaceAddDTO.getTenantId()).last("limit 1"));
 
         //根据学校查询场地
         AppSitePlace appSitePlace = baseMapper.selectOne(Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getTenantId, site.getTenantId()));
@@ -806,7 +806,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                 }
             }
             //存放开放时段列表(删除再新增)
-            appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().gt(AppSitePriceRules::getDateOfSale, currDate).eq(AppSitePriceRules::getTenantId, site.getTenantId()));
+            appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().gt(AppSitePriceRules::getDateOfSale, currDate).eq(AppSitePriceRules::getOrgCode, site.getOrgCode()));
             appSitePriceRulesMapper.insertList(appSitePriceRulesList);
 
             appSiteMapper.updateById(site);
@@ -814,7 +814,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
         //修改学校场地开放信息
         appSitePlace
                 .setCover(schoolPlaceAddDTO.getCover().split( ",")[0])
-                //todo 设置意外保险字段
+                // 设置意外保险字段
                 .setInsureIds(schoolPlaceAddDTO.getInsureIds())
                 .setReminder(schoolPlaceAddDTO.getReminder());
         return this.updateById(appSitePlace);
@@ -840,8 +840,6 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                 .setTenantId(site.getTenantId())
                 .setTeachingDay(site.getTeachingDay())
                 .setNoTeachingDay(site.getNoTeachingDay())
-
-                .setHavePermission(Boolean.FALSE)
         ;
 
         if (ObjectUtils.isNotEmpty(appSitePlace)) {

+ 26 - 4
national-motion-module-system/national-motion-system-start/src/main/resources/redisson.yml

@@ -1,20 +1,42 @@
 singleServerConfig:
+  #连接空闲超时,单位:毫秒
   idleConnectionTimeout: 10000
+  pingTimeout: 1000
+  #连接超时,单位:毫秒
   connectTimeout: 10000
+  #命令等待超时,单位:毫秒
   timeout: 3000
+  #命令失败重试次数
   retryAttempts: 3
+  #命令重试发送时间间隔,单位:毫秒
   retryInterval: 1500
-  password: RUw3C4tAF0aE4PVC
+  #重新连接时间间隔,单位:毫秒
+  reconnectionTimeout: 3000
+  #执行失败最大次数
+  failedAttempts: 3
+  #单个连接最大订阅数量
   subscriptionsPerConnection: 5
+  #客户端名称
   clientName: null
+  #地址
   address: "redis://47.109.67.112:6379"
+  #数据库编号
+  database: 0
+  #密码
+  password: RUw3C4tAF0aE4PVC
+  #发布和订阅连接的最小空闲连接数
   subscriptionConnectionMinimumIdleSize: 1
+  #发布和订阅连接池大小
   subscriptionConnectionPoolSize: 50
+  #最小空闲连接数
   connectionMinimumIdleSize: 32
+  #连接池大小
   connectionPoolSize: 64
-  database: 1
-  dnsMonitoringInterval: 5000
+  #是否启用DNS监测
+  #dnsMonitoring: false
+  #DNS监测时间间隔,单位:毫秒
+  #dnsMonitoringInterval: 5000
 threads: 0
 nettyThreads: 0
 codec: !<org.redisson.codec.JsonJacksonCodec> {}
-transportMode: "NIO"
+transportMode : "NIO"

+ 1 - 1
pom.xml

@@ -75,7 +75,7 @@
 
 		<httpclient.version>4.5.13</httpclient.version>
 		<gson.version>2.10</gson.version>
-		<redission.version>3.48.0</redission.version>
+		<redission.version>3.17.6</redission.version>
 		<wechatpay.version>0.4.7</wechatpay.version>
 	</properties>
 	<modules>