2 Commits e0853c8b13 ... 2feffbd409

Author SHA1 Message Date
  SheepHy 2feffbd409 Merge remote-tracking branch 'origin/master' 1 week ago
  SheepHy e081d69d84 feat(national-motion): 添加上课地址字段并优化订单相关功能 1 week ago

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

@@ -151,7 +151,7 @@ public class DetailServiceImpl implements IDetailService {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         List<PlaceInfoVO.CourseInfoVO> courseInfoVOList = new ArrayList<>();
         appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery()
-                .eq(AppCourses::getSiteId, id)
+                .eq(AppCourses::getAddressSiteId, id)
                 .like(AppCourses::getCategoryId, categoryId)
                 .eq(AppCourses::getStatus, 0)
                 .eq(AppCourses::getDelFlag, 0)).forEach(appCourses -> {

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.app.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.log4j.Log4j2;
 import org.apache.shiro.SecurityUtils;
@@ -21,6 +22,7 @@ import java.time.LocalDate;
 import java.time.ZoneId;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
 
 @Service
 @Log4j2
@@ -155,16 +157,27 @@ public class OrderServiceImpl implements IOrderService {
         AppOrder appOrder = new AppOrder();
         switch(type){
             case "0":
-                AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectById(id.get(0));
-                if(appSitePriceRules.getType() == 0){
-                    appOrder.setOrderStatus(0)
+                List<AppSitePriceRules> priceRules = appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
+                        .in(AppSitePriceRules::getId, id));
+                BigDecimal totalPrice = priceRules.stream()
+                        .map(AppSitePriceRules::getSellingPrice)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                if(priceRules.get(0).getType() == 0){
+                    if(totalPrice.compareTo(BigDecimal.ZERO) == 0){
+                        appOrder.setPayType(3)
+                                .setOrderStatus(2);
+                    }else {
+                        appOrder.setPayType(2)
+                                .setOrderStatus(1);
+                    }
+                    appOrder.setOrderCode(generateOrderNumber(0))
+                            .setOrderCode(priceRules.get(0).getOrgCode())
+                            .setTenantId(priceRules.get(0).getTenantId())
+                            .setProductIds(priceRules.get(0).getSitePlaceId())
                             .setType(0)
-                            .setProductIds("")
                             .setUserId(userId)
-                            .setStatus(0)
-                            .setDelFlag(0)
-                            .setCreateTime(new Date())
-                            .setUpdateTime(new Date());
+                            .setOriginalPrice(totalPrice);
+//                            .setPrice(totalPrice)
                 }
                 break;
             case "1":
@@ -175,4 +188,20 @@ public class OrderServiceImpl implements IOrderService {
         appOrderMapper.insert(appOrder);
         return "";
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 订单编号生成逻辑
+     * @Date 17:18 2025/7/15
+     * @return
+     **/
+    private String generateOrderNumber(int type) {
+        String format = DateUtil.format(new Date(), "yyyyMMddHHmmss");
+        int nextInt = ThreadLocalRandom.current().nextInt(1000, 10000);
+        if(type == 0){
+            return "D" + format + nextInt;
+        }else {
+            return "T" + format + nextInt;
+        }
+    }
 }

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

@@ -36,6 +36,9 @@ public class AppCourses implements Serializable {
     @Excel(name = "部门编码", width = 15)
     @Schema(description = "部门编码")
     private java.lang.String orgCode;
+    @Excel(name = "上课地址", width = 15)
+    @Schema(description = "上课地址")
+    private java.lang.String addressSiteId;
     /**教练id(关联用户表)*/
     @Excel(name = "教练id(关联用户表)", width = 15)
     @Schema(description = "教练id(关联用户表)")

+ 3 - 6
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppOrder.java

@@ -13,6 +13,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -57,18 +58,14 @@ public class AppOrder implements Serializable {
 	@Excel(name = "用户id", width = 15)
     @Schema(description = "用户id")
     private String userId;
-    /**订单人员信息表ids*/
-    @Excel(name = "订单人员", width = 15)
-    @Schema(description = "订单人员")
-    private String peoples;
 	/**原订单总价*/
 	@Excel(name = "原订单总价", width = 15)
     @Schema(description = "原订单总价")
-    private String originalPrice;
+    private BigDecimal originalPrice;
 	/**实际支付价*/
 	@Excel(name = "实际支付价", width = 15)
     @Schema(description = "实际支付价")
-    private String price;
+    private BigDecimal price;
 	/**优惠信息*/
 	@Excel(name = "优惠信息", width = 15)
     @Schema(description = "优惠信息")

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

@@ -65,7 +65,7 @@
         WHERE
             a.STATUS = 0
           AND a.del_flag = 0
-          AND a.id = #{id}
+          AND a.address_site_id = #{id}
         GROUP BY
             a.id,
             a.NAME,

+ 3 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -154,7 +154,8 @@ public class SysUserController {
 		Result<SysUser> result = new Result<SysUser>();
 		String selectedRoles = jsonObject.getString("selectedroles");
 		String selectedDeparts = jsonObject.getString("selecteddeparts");
-        SysDepart departById = sysDepartService.getDepartById(selectedDeparts);
+        List<String> stream = List.of(selectedDeparts.split(","));
+        SysDepart departById = sysDepartService.getDepartById(stream.get(0));
         try {
 			SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
 			user.setCreateTime(new Date());//设置创建时间
@@ -165,6 +166,7 @@ public class SysUserController {
 			user.setStatus(1);
 			user.setDelFlag(CommonConstant.DEL_FLAG_0);
 			//用户表字段org_code不能在这里设置他的值
+
             user.setOrgCode(departById.getOrgCode());
 			// 保存用户走一个service 保证事务
             //获取租户ids