Bladeren bron

feat(course): 添加课程规则数量- 在课程详情页面增加课程规则数量字段
- 通过数据库查询获取课程规则数量,并设置到课程信息对象中refactor(national-motion-module-system): 优化订单相关代码

- 修改订单查询 SQL,增加订单类型和部门名称字段
- 优化订单信息获取逻辑,支持不同订单类型的处理
- 调整订单地址获取方式,修复可能的空指针异常
- 优化订单总价计算逻辑,处理免费订单的情况
- 重构微信支付通知处理代码,提高可读性和可维护性

wzq 3 weken geleden
bovenliggende
commit
7ad9333b97

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

@@ -313,13 +313,13 @@ public class OrderServiceImpl implements IOrderService {
         List<AppSitePriceRules> priceRules = new ArrayList<>();
         list.forEach(priceRule -> {
             AppSitePriceRules appSitePriceRule = appSitePriceRulesMapper.selectById(priceRule);
-            if(null == appSitePriceRule.getSellingPrice()){
+            if (null == appSitePriceRule.getSellingPrice()) {
                 appSitePriceRule.setSellingPrice(BigDecimal.ZERO);
             }
             priceRules.add(appSitePriceRule);
         });
         BigDecimal totalPrice = BigDecimal.ZERO;
-        if(!priceRules.isEmpty()){
+        if (!priceRules.isEmpty()) {
             totalPrice = priceRules.stream()
                     .map(AppSitePriceRules::getSellingPrice)
                     .reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -486,8 +486,6 @@ public class OrderServiceImpl implements IOrderService {
 
         String orderCode = generateOrderNumber(0);
 
-        Integer count = createOrderForm.getAmount();
-
         //创建订单
         AppOrder appOrder = new AppOrder();
         appOrder
@@ -547,7 +545,7 @@ public class OrderServiceImpl implements IOrderService {
                         }
                         redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product), 60 * 60 * 24, TimeUnit.SECONDS);
                         // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
-                        if (product.getTicketNum() == null){
+                        if (product.getTicketNum() == null) {
                             throw new JeecgBootException("订单提交失败,当前商品库存为空");
                         }
                         stock = product.getTicketNum();
@@ -628,7 +626,8 @@ public class OrderServiceImpl implements IOrderService {
                     List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
 
                     //订单总价(商品的售价总和)
-                    BigDecimal sumPrice = new BigDecimal(0);
+                    BigDecimal sumPrice = BigDecimal.ZERO;
+                    ;
 
                     for (int i = 0; i < list.size(); i++) {
                         AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(list.get(i).split("\\|")[0]);
@@ -661,7 +660,7 @@ public class OrderServiceImpl implements IOrderService {
                         appOrder.setOrgCode(appSitePlace.getOrgCode())
                                 .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
 
-                        sumPrice = sumPrice.add(priceRule.getSellingPrice());
+                        sumPrice = sumPrice.add(appOrderProInfo.getPrice());
                     }
 
                     //计算订单总价
@@ -685,9 +684,11 @@ public class OrderServiceImpl implements IOrderService {
                     AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
 
                     //订单总价(商品的售价总和)
-                    BigDecimal sumPrice = new BigDecimal(0);
+                    BigDecimal sumPrice = BigDecimal.ZERO;
+                    ;
                     //团购优惠
-                    BigDecimal tDiscounts = new BigDecimal(0);
+                    BigDecimal tDiscounts = BigDecimal.ZERO;
+                    ;
 
                     for (int i = 1; i <= createOrderForm.getAmount(); i++) {
 
@@ -741,7 +742,7 @@ public class OrderServiceImpl implements IOrderService {
                 //个人赛
                 if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_3)) {
                     AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
-                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getGameId());
+                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
                     AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
 
                     appOrder.setOrgCode(appGamePriceRules.getOrgCode());
@@ -751,9 +752,10 @@ public class OrderServiceImpl implements IOrderService {
                     String endTime = DateUtil.format(appGame.getEndTime(), "HH:mm");
 
                     //订单总价(商品的售价总和)
-                    BigDecimal sumPrice = new BigDecimal(0);
+                    BigDecimal sumPrice = BigDecimal.ZERO;
+                    ;
 
-                for (int i = 1; i <= createOrderForm.getAmount(); i++) {
+                    for (int i = 1; i <= createOrderForm.getAmount(); i++) {
 
                         String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
                         FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
@@ -775,7 +777,7 @@ public class OrderServiceImpl implements IOrderService {
                         appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
                         appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
 
-                    proInfoList.add(appOrderProInfo);
+                        proInfoList.add(appOrderProInfo);
 
                         sumPrice = sumPrice.add(appGamePriceRules.getSellingPrice());
                     }
@@ -796,9 +798,9 @@ public class OrderServiceImpl implements IOrderService {
                         appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
                     }
                 }
-                if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)){
+                if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)) {
                     AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
-                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getGameId());
+                    AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
                     AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
 
 
@@ -840,7 +842,6 @@ public class OrderServiceImpl implements IOrderService {
 
                     appOrder
                             .setType(CommonConstant.ORDER_TYPE_1)
-                            .setAddressSiteId(appGame.getSiteId())
                             .setOriginalPrice(sumPrice)
                             .setCreateTime(new Date())
                             .setUpdateTime(new Date())
@@ -848,6 +849,9 @@ public class OrderServiceImpl implements IOrderService {
                             .setUpdateBy(user.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());
                     }
@@ -872,13 +876,13 @@ public class OrderServiceImpl implements IOrderService {
                 }
 
                 //订单总价(商品的售价总和)
-                BigDecimal sumCoursePrice = new BigDecimal(0);
+                BigDecimal sumCoursePrice = BigDecimal.ZERO;
 
                 //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
-                BigDecimal sDiscounts = new BigDecimal(0);
-                BigDecimal tDiscounts = new BigDecimal(0);
+                BigDecimal sDiscounts = BigDecimal.ZERO;
+                BigDecimal tDiscounts = BigDecimal.ZERO;
 
-                    for (int i = 1; i <= createOrderForm.getAmount(); i++) {
+                for (int i = 1; i <= createOrderForm.getAmount(); i++) {
 
                     String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
                     FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
@@ -934,20 +938,27 @@ public class OrderServiceImpl implements IOrderService {
                         Boolean flag = checkOrderOrFree(user.getId(), appCourse.getCategoryId());
                         if (flag && i == 1) {
                             //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
-                            sDiscounts = sDiscounts.add(appCourse.getSellingPrice());
+                            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);
                         }
                     }
-
-                        proInfoList.add(appOrderProInfo);
+                    proInfoList.add(appOrderProInfo);
 
                     tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice()));
-                    sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice().subtract(sDiscounts));
+                    if (createOrderForm.getOrFreeOrder() == 1) {
+                        tDiscounts = BigDecimal.ZERO;
+                    }
+                    sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice());
+                    if (createOrderForm.getOrFreeOrder() == 1) {
+                        sumCoursePrice = BigDecimal.ZERO;
+                    }
                 }
 
                 //计算订单总价
@@ -955,12 +966,16 @@ public class OrderServiceImpl implements IOrderService {
 
                 //团购优惠
                 appOrder.setTDiscounts(tDiscounts);
+                if (createOrderForm.getOrFreeOrder() == 1) {
+                    //团购优惠
+                    appOrder.setTDiscounts(BigDecimal.ZERO);
+                }
                 //原订单总价
                 appOrder.setOriginalPrice(sumCoursePrice);
                 //使用人IDs
                 appOrder.setFamilyIds(createOrderForm.getFamilyIds());
 
-                appOrder.setAddressSiteId(appSite.getId());
+                appOrder.setAddressSiteId(appCourse.getAddressSiteId());
                 break;
         }
 
@@ -1004,7 +1019,7 @@ public class OrderServiceImpl implements IOrderService {
         }
         appOrder.setPrice(totalPrice);
         appOrderMapper.insert(appOrder);
-        if(appOrder.getOrderType()== 5 && appOrder.getOrderOrFree()==0){
+        if (appOrder.getOrderType() == 5 && appOrder.getOrderOrFree() == 0) {
             saveSignFlowRecord(appOrder);
         }
         if (!insureOrderInfoList.isEmpty()) {
@@ -1038,28 +1053,27 @@ public class OrderServiceImpl implements IOrderService {
                     .setOrderId(appOrder.getId())
                     .setOrderCode(appOrder.getOrderCode())
                     .setTicketNo(RandomUtil.randomNumbers(10));
-            if(appOrderProInfoMapper.insert(appOrderProInfo) > 0){
-                if(appOrderProInfo.getType() == 5){
+            if (appOrderProInfoMapper.insert(appOrderProInfo) > 0) {
+                if (appOrderProInfo.getType() == 5) {
                     AppSite appSite = appSiteMapper.selectById(appCoursesMapper.selectById(appOrderProInfo.getProductId()).getAddressSiteId());
-                    if(null != appSite &&
-                            appSite.getType() == 0){
+                    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){
+                        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();
+                                        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){
+                                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)) {
                 //订单券号记录
@@ -1086,14 +1100,13 @@ public class OrderServiceImpl implements IOrderService {
                     String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
                             appDevice.getDeviceSerial(),
                             appOrderProInfo.getUserName(),
-                            familyMembers.getId(),null);
+                            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("设备录入用户信息失败!请联系管理员");
                 }
-
             }
         }
 
@@ -1116,10 +1129,9 @@ public class OrderServiceImpl implements IOrderService {
         //判断是否试听课(试听课不走订单)
         if (ObjectUtil.isNotEmpty(appOrder.getOrderOrFree()) && appOrder.getOrderOrFree() == 1) {
             payForm.setOrPayOrder(0);
-        }
-        else if (appOrder.getOrderType() == 0){
+        } else if (appOrder.getOrderType() == 0) {
             payForm.setOrPayOrder(0);
-        }else {
+        } else {
             Calendar calendar = Calendar.getInstance();
             calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
@@ -1162,9 +1174,7 @@ public class OrderServiceImpl implements IOrderService {
             String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
             redissonDelayQueue.offerTask(task, 60 * 15);
         }
-
         return payForm;
-
     }
 
     /**
@@ -1292,7 +1302,7 @@ public class OrderServiceImpl implements IOrderService {
 
         AppOrder appOrder = appOrderMapper.selectById(orderId);
         if (ObjectUtil.isEmpty(appOrder)) {
-           throw new JeecgBootException("当前订单不存在!");
+            throw new JeecgBootException("当前订单不存在!");
         }
         appOrderInfoDTO.setId(appOrder.getId());
         appOrderInfoDTO.setOrderCode(appOrder.getOrderCode());
@@ -1319,7 +1329,7 @@ public class OrderServiceImpl implements IOrderService {
                 //商品信息
                 String productIds = appOrder.getProductIds();
                 AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectAllById(productIds);
-                if (ObjectUtil.isEmpty(appSitePriceRules)){
+                if (ObjectUtil.isEmpty(appSitePriceRules)) {
                     log.info("当前学校场地预约商品已下架!{}", productIds);
                     throw new JeecgBootException("当前商品已下架!");
                 }
@@ -1614,7 +1624,7 @@ public class OrderServiceImpl implements IOrderService {
                 appOrder.setOrderStatus(1);
                 appOrderMapper.updateById(appOrder);
                 List<AppOrderProInfo> proInfoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery().eq(AppOrderProInfo::getOrderId, appOrder.getId()));
-                if (CollUtil.isNotEmpty(proInfoList)){
+                if (CollUtil.isNotEmpty(proInfoList)) {
                     for (AppOrderProInfo appOrderProInfo : proInfoList) {
                         appOrderProInfo.setOrderStatus(1);
                         appOrderProInfoMapper.updateById(appOrderProInfo);
@@ -1715,39 +1725,39 @@ public class OrderServiceImpl implements IOrderService {
     public Map<String, String> wechatPayNotify(HttpServletRequest request) {
         Map<String, String> stringStringMap = weChatPayService.wechatPayNotify(request);
         //对订单进行封账金额统计
-        if (stringStringMap!=null
+        if (stringStringMap != null
                 && stringStringMap.containsKey("code")
                 && "SUCCESS".equals(stringStringMap.get("code"))
                 && stringStringMap.containsKey("orderCode")
-               ){
+        ) {
             String orderCode = stringStringMap.get("orderCode");
-            if(StringUtils.isEmpty(orderCode)){
-                log.error("微信支付成功通知成功,订单编号为空,通知失败:"+JSONObject.toJSONString(stringStringMap));
+            if (StringUtils.isEmpty(orderCode)) {
+                log.error("微信支付成功通知成功,订单编号为空,通知失败:" + JSONObject.toJSONString(stringStringMap));
                 throw new JeecgBootException("微信支付成功通知成功,订单编号为空,通知失败");
             }
             AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getOrderCode, orderCode).last("limit 1"));
-            if (appOrder==null){
-                log.error("微信支付成功通知成功,订单未查询到,通知失败:"+JSONObject.toJSONString(stringStringMap));
+            if (appOrder == null) {
+                log.error("微信支付成功通知成功,订单未查询到,通知失败:" + JSONObject.toJSONString(stringStringMap));
                 throw new JeecgBootException("微信支付成功通知成功,订单未查询到,通知失败");
             }
-            log.info("支付成功消息通知,订单信息:"+JSONObject.toJSONString(appOrder));
-            if (StringUtils.isEmpty(appOrder.getOrgCode())){
+            log.info("支付成功消息通知,订单信息:" + JSONObject.toJSONString(appOrder));
+            if (StringUtils.isEmpty(appOrder.getOrgCode())) {
                 log.error("微信支付成功通知成功,订单属于未知机构,通知失败");
                 return stringStringMap;
             }
-            if (appOrder.getType()!=null&&appOrder.getType()!=2){
-                BigDecimal priceSum= appOrderProInfoMapper.findByOrderId(appOrder.getId());
-                if (priceSum==null||priceSum.compareTo(BigDecimal.ZERO)==0){
-                    log.error("微信支付成功通知成功,订单明细订单金额为0,不进行分账,orderId:"+appOrder.getId());
+            if (appOrder.getType() != null && appOrder.getType() != 2) {
+                BigDecimal priceSum = appOrderProInfoMapper.findByOrderId(appOrder.getId());
+                if (priceSum == null || priceSum.compareTo(BigDecimal.ZERO) == 0) {
+                    log.error("微信支付成功通知成功,订单明细订单金额为0,不进行分账,orderId:" + appOrder.getId());
                     return stringStringMap;
                 }
-                SysDepart sysDepart= sysDepartMapper.findByOrgCodeAndParentId(appOrder.getOrgCode());
-                if (sysDepart==null){
+                SysDepart sysDepart = sysDepartMapper.findByOrgCodeAndParentId(appOrder.getOrgCode());
+                if (sysDepart == null) {
                     log.error("微信支付成功通知成功,未查询到部门信息,该订单属于未知订单");
                     return stringStringMap;
                 }
                 SysDepart byOrgCode = sysDepartMapper.findByOrgCode("A01");
-                if (byOrgCode==null){
+                if (byOrgCode == null) {
                     log.error("微信支付成功通知成功,未查询到观头信息,该订单属于无法分账");
                     return stringStringMap;
                 }
@@ -1759,26 +1769,26 @@ public class OrderServiceImpl implements IOrderService {
                 receiptPaymentDetailsInfoVo.setCreateTime(new Date());
                 receiptPaymentDetailsInfoVo.setUpdateTime(new Date());
                 receiptPaymentDetailsInfoVo.setOrderId(appOrder.getId());
-                if (separateAccounts==null){
+                if (separateAccounts == null) {
                     //需要按照默认比例分账 -暂时未处理。
                     log.error("微信支付成功通知成功,未查询到分账信息,不进行分账");
                     return stringStringMap;
                 }
-                BigDecimal shBigDecimal =BigDecimal.ZERO;
+                BigDecimal shBigDecimal = BigDecimal.ZERO;
                 try {
                     shBigDecimal = getBigDecimal(priceSum, separateAccounts.getShSeparateAccounts());
                 } catch (Exception e) {
                     log.error("百分比计算错误", e);
                 }
-                BigDecimal ptBigDecimal =BigDecimal.ZERO;
+                BigDecimal ptBigDecimal = BigDecimal.ZERO;
                 try {
                     ptBigDecimal = getBigDecimal(priceSum, separateAccounts.getPtSeparateAccounts());
                 } catch (Exception e) {
                     log.error("百分比计算错误", e);
                 }
-                log.info("支付成功消息通知,门店添加明细:"+JSONObject.toJSONString(receiptPaymentDetailsInfoVo));
+                log.info("支付成功消息通知,门店添加明细:" + JSONObject.toJSONString(receiptPaymentDetailsInfoVo));
                 BigDecimal mdBigDecimal = priceSum.subtract(shBigDecimal).subtract(ptBigDecimal).setScale(2, RoundingMode.HALF_UP);
-                log.info("支付成功消息通知,金额:"+mdBigDecimal+";"+shBigDecimal+";"+ptBigDecimal);
+                log.info("支付成功消息通知,金额:" + mdBigDecimal + ";" + shBigDecimal + ";" + ptBigDecimal);
                 ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVoMd = getChangeMoney(receiptPaymentDetailsInfoVo, appOrder.getOrgCode(), appOrder.getTenantId(), 2, mdBigDecimal);
                 ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVoSh = getChangeMoney(receiptPaymentDetailsInfoVo, sysDepart.getOrgCode(), sysDepart.getId(), 1, shBigDecimal);
                 ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVoPt = getChangeMoney(receiptPaymentDetailsInfoVo, byOrgCode.getOrgCode(), byOrgCode.getId(), 0, ptBigDecimal);
@@ -1792,18 +1802,18 @@ public class OrderServiceImpl implements IOrderService {
     }
 
 
-
-    private ReceiptPaymentDetailsInfoVo  getChangeMoney(ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVo,String orgCode,String deptId,Integer deptType,BigDecimal changeMoney){
+    private ReceiptPaymentDetailsInfoVo getChangeMoney(ReceiptPaymentDetailsInfoVo receiptPaymentDetailsInfoVo, String orgCode, String deptId, Integer deptType, BigDecimal changeMoney) {
         receiptPaymentDetailsInfoVo.setDeptId(deptId);
         receiptPaymentDetailsInfoVo.setDeptType(deptType);
         receiptPaymentDetailsInfoVo.setOrgCode(orgCode);
         receiptPaymentDetailsInfoVo.setChangeMoney(changeMoney);
         return receiptPaymentDetailsInfoVo;
     }
-    private BigDecimal getBigDecimal(BigDecimal priceSum,BigDecimal proportion){
-        if (proportion==null){
+
+    private BigDecimal getBigDecimal(BigDecimal priceSum, BigDecimal proportion) {
+        if (proportion == null) {
             return BigDecimal.ZERO;
-        }else {
+        } else {
             if (proportion.compareTo(BigDecimal.ZERO) == 0) {
                 return BigDecimal.ZERO;
             } else {   // 将百分比转换为小数(例如:50% -> 0.5)
@@ -1866,7 +1876,7 @@ public class OrderServiceImpl implements IOrderService {
     private Boolean checkOrderOrFree(String userId, String categoryId) {
         //查询当前用户的所有课程订单
         List<AppOrder> appOrders = appOrderMapper.selectList(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getUserId, userId).eq(AppOrder::getType, CommonConstant.ORDER_TYPE_2));
-        if (CollUtil.isNotEmpty(appOrders)){
+        if (CollUtil.isNotEmpty(appOrders)) {
             for (AppOrder appOrder : appOrders) {
                 AppCourses appCours = appCoursesMapper.selectById(appOrder.getProductIds());
                 if (appCours.getCategoryId().equals(categoryId)) {

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

@@ -6,14 +6,17 @@
         SELECT b.* FROM (SELECT
         o.id,
         o.order_code,
+        o.order_type,
         o.create_time,
         s.`name` siteName,
+        f.depart_name departName,
         o.amount,
         o.price,
         GROUP_CONCAT( DISTINCT opi.user_phone ) userPhone
         FROM
         nm_order o
-        LEFT JOIN nm_site s ON s.org_code = o.org_code
+        LEFT JOIN nm_site s ON s.id = o.address_site_id
+        LEFT JOIN sys_depart f ON f.org_code = s.org_code
         LEFT JOIN nm_order_pro_info opi ON opi.order_id = o.id
         <where>
             o.del_flag = 0

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

@@ -142,19 +142,21 @@ public class AppOrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> i
         if (appOrder.getType() == 1){
             AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(appOrder.getProductIds());
             if (ObjectUtil.isNotEmpty(appGamePriceRules)){
-                AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
+                AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
                 if (ObjectUtil.isNotEmpty(appGame)){
                     if (ObjectUtil.isNotEmpty(site) && appGame.getSiteType() == 0){
                         appOrderInfoVO.setSiteName(site.getName());
                         appOrderInfoVO.setAddress(appGame.getAddress());
                     }else {
-                        appOrderInfoVO.setAddress(appGame.getAddress());
+                        appOrderInfoVO.setAddress(appGame.getSiteAddress());
                     }
                 }
             }
         }else {
-            appOrderInfoVO.setSiteName(site.getName());
-            appOrderInfoVO.setAddress(site.getAddress());
+            String addressSiteId = appOrder.getAddressSiteId();
+            AppSite appSite = appSiteMapper.selectById(addressSiteId);
+            appOrderInfoVO.setSiteName(appSite.getName());
+            appOrderInfoVO.setAddress(appSite.getAddress());
         }
         //付款信息
         if (appOrder.getOrderStatus() > 0) {

+ 6 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/vo/OrderPageVO.java

@@ -30,6 +30,9 @@ public class OrderPageVO implements Serializable {
     @Schema(description = "订单号")
     private String orderCode;
 
+    @Schema(description = "平台名称")
+    private Integer orderType;
+
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @Schema(description = "创建时间")
@@ -38,6 +41,9 @@ public class OrderPageVO implements Serializable {
     @Schema(description = "店铺名称")
     private String siteName;
 
+    @Schema(description = "平台名称")
+    private String departName;
+
     @Schema(description = "商品数量")
     private Integer Amount;