Переглянути джерело

refactor(app): 重构商户信息相关功能

- 修改商户信息保存逻辑,支持通过 AppSite 实体保存
- 优化包场相关功能,包括新增、编辑、删除等操作
- 调整场地信息相关接口,统一命名和逻辑
- 优化数据校验和异常处理
lix 2 тижнів тому
батько
коміт
efde24cac9
11 змінених файлів з 378 додано та 142 видалено
  1. 1 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/api/controller/SystemApiController.java
  2. 9 9
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppSiteController.java
  3. 189 84
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppSitePlaceController.java
  4. 8 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppGameCuDTO.java
  5. 18 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppSiteDTO.java
  6. 16 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppSite.java
  7. 4 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppSitePlaceService.java
  8. 10 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoureseServiceImpl.java
  9. 3 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppGameServiceImpl.java
  10. 90 27
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSitePlaceServiceImpl.java
  11. 30 12
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSiteServiceImpl.java

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

@@ -156,7 +156,7 @@ public class SystemApiController {
      * @param username
      * @return 部门 id
      */
-    @GetMapping("/getDepartIdsByUsername")
+    @GetMapping("/getDepartIdFsByUsername")
     List<String> getDepartIdsByUsername(@RequestParam("username") String username){
         return sysBaseApi.getDepartIdsByUsername(username);
     }

+ 9 - 9
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppSiteController.java

@@ -49,7 +49,7 @@ public class AppSiteController extends JeecgController<AppSite, IAppSiteService>
 	 * @return
 	 */
 	//@AutoLog(value = "场地表-分页列表查询")
-	@Operation(summary="场地表-分页列表查询")
+	@Operation(summary="商户信息补充-分页列表查询")
 	@GetMapping(value = "/list")
 	public Result<IPage<AppSiteDTO>> queryPageList(AppSitePageDTO dto) {
 		return Result.OK(appSiteService.querySitePage(dto));
@@ -61,8 +61,8 @@ public class AppSiteController extends JeecgController<AppSite, IAppSiteService>
 	 * @param appSiteDTO
 	 * @return
 	 */
-	@AutoLog(value = "场地表-添加")
-	@Operation(summary="场地表-添加")
+	@AutoLog(value = "商户信息补充-添加")
+	@Operation(summary="商户信息补充-添加")
 //	@RequiresPermissions("org.jeecg.modules.app:nm_site:add")
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody AppSiteDTO appSiteDTO) {
@@ -75,8 +75,8 @@ public class AppSiteController extends JeecgController<AppSite, IAppSiteService>
 	 * @param appSiteDTO
 	 * @return
 	 */
-	@AutoLog(value = "场地表-编辑")
-	@Operation(summary="场地表-编辑")
+	@AutoLog(value = "商户信息补充-编辑")
+	@Operation(summary="商户信息补充-编辑")
 //	@RequiresPermissions("org.jeecg.modules.app:nm_site:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
 	public Result<String> edit(@RequestBody AppSiteDTO appSiteDTO) {
@@ -89,8 +89,8 @@ public class AppSiteController extends JeecgController<AppSite, IAppSiteService>
 	 * @param id
 	 * @return
 	 */
-	@AutoLog(value = "场地表-通过id删除")
-	@Operation(summary="场地表-通过id删除")
+	@AutoLog(value = "商户信息补充-通过id删除")
+	@Operation(summary="商户信息补充-通过id删除")
 //	@RequiresPermissions("org.jeecg.modules.app:nm_site:delete")
 	@DeleteMapping(value = "/delete")
 	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
@@ -120,7 +120,7 @@ public class AppSiteController extends JeecgController<AppSite, IAppSiteService>
 	 * @return
 	 */
 	//@AutoLog(value = "场地表-通过id查询")
-	@Operation(summary="场地表-通过id查询")
+	@Operation(summary="商户信息补充-通过id查询")
 	@GetMapping(value = "/queryById")
 	public Result<AppSiteDTO> queryById(@RequestParam(name="id",required=true) String id) {
 			return Result.ok(appSiteService.querySiteById(id));
@@ -133,7 +133,7 @@ public class AppSiteController extends JeecgController<AppSite, IAppSiteService>
 	 * @return
 	 */
 	//@AutoLog(value = "场地表-通过orgCode查询")
-	@Operation(summary="场地表-通过orgCode查询")
+	@Operation(summary="商户信息补充-通过orgCode查询")
 	@GetMapping(value = "/querySiteListByOrgCode")
 	public Result<List<AppSiteListVO>> querySiteListByOrgCode(@RequestParam(name="orgCode",required=true) String orgCode) {
 		return Result.ok(appSiteService.querySiteListByOrgCode(orgCode));

+ 189 - 84
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppSitePlaceController.java

@@ -18,99 +18,204 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 /**
  * @Description: 商户场所表
  * @Author: jeecg-boot
- * @Date:   2025-07-09
+ * @Date: 2025-07-09
  * @Version: V1.0
  */
-@Tag(name="商户场所表")
+@Tag(name = "商户场所表")
 @RestController
 @RequestMapping("/app/appSitePlace")
 @Slf4j
 public class AppSitePlaceController extends JeecgController<AppSitePlace, IAppSitePlaceService> {
-	@Autowired
-	private IAppSitePlaceService appSitePlaceService;
-	
-	/**
-	 * 分页列表查询
-	 *
-	 * @param appSitePlace
-	 * @return
-	 */
-	//@AutoLog(value = "商户场所表-分页列表查询")
-	@Operation(summary="商户场所学校、体育馆包场-分页列表查询")
-	@GetMapping(value = "/list")
-	public Result<IPage<AppSitePlaceCuDTO>> queryPageList(AppSitePlacePageDTO appSitePlace) {
-		return Result.OK(appSitePlaceService.querySchoolPage(appSitePlace));
-	}
-	/**
-	 * 分页列表查询
-	 *
-	 * @param appSitePlace
-	 * @return
-	 */
-	//@AutoLog(value = "商户场所表-分页列表查询")
-	@Operation(summary="商户场所无固定场-分页列表查询")
-	@GetMapping(value = "/queryUnfixedPageList")
-	public Result<IPage<AppSitePlaceUnfixedDTO>> queryUnfixedPageList(AppSitePlaceUnfixedPageDTO appSitePlace) {
-		return Result.OK(appSitePlaceService.queryUnfixedPage(appSitePlace));
-	}
-	
-	/**
-	 *   添加
-	 *
-	 * @param appSitePlace
-	 * @return
-	 */
-	@AutoLog(value = "商户场所学校-添加")
-	@Operation(summary="商户场所学校-添加")
+    @Autowired
+    private IAppSitePlaceService appSitePlaceService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param appSitePlace
+     * @return
+     */
+    //@AutoLog(value = "商户场所表-分页列表查询")
+    @Operation(summary = "商户场所学校、体育馆包场-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<AppSitePlaceCuDTO>> queryPageList(AppSitePlacePageDTO appSitePlace) {
+        return Result.OK(appSitePlaceService.querySchoolPage(appSitePlace));
+    }
+
+    /**
+     * 分页列表查询
+     *
+     * @param appSitePlace
+     * @return
+     */
+    //@AutoLog(value = "商户场所表-分页列表查询")
+    @Operation(summary = "商户场所无固定场-分页列表查询")
+    @GetMapping(value = "/queryUnfixedPageList")
+    public Result<IPage<AppSitePlaceUnfixedDTO>> queryUnfixedPageList(AppSitePlaceUnfixedPageDTO appSitePlace) {
+        return Result.OK(appSitePlaceService.queryUnfixedPage(appSitePlace));
+    }
+
+    /**
+     * 添加
+     *
+     * @param appSitePlace
+     * @return
+     */
+    @AutoLog(value = "商户场所学校-添加")
+    @Operation(summary = "商户场所学校-添加")
+//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:add")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody AppSitePlaceSchoolDTO appSitePlace) {
+        Boolean b = appSitePlaceService.saveSchool(appSitePlace);
+        return b ? Result.OK("添加成功!") : Result.error("添加失败!");
+    }
+
+    /**
+     * 添加
+     *
+     * @param unfixedDTO
+     * @return
+     */
+    @AutoLog(value = "商户无固定场所-添加")
+    @Operation(summary = "商户无固定场所-添加")
 //	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:add")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody AppSitePlaceSchoolDTO appSitePlace) {
-		appSitePlaceService.saveSchool(appSitePlace);
-		return Result.OK("添加成功!");
-	}
-	
-	/**
-	 *  编辑
-	 *
-	 * @param appSitePlace
-	 * @return
-	 */
-	@AutoLog(value = "商户场所学校-编辑")
-	@Operation(summary="商户场所学校-编辑")
+    @PostMapping(value = "/addUnfixed")
+    public Result<String> addUnfixed(@RequestBody
+                                     AppSitePlaceUnfixedDTO unfixedDTO) {
+        Boolean b = appSitePlaceService.addUnfixed(unfixedDTO);
+        return b ? Result.OK("添加成功!") : Result.error("添加失败!");
+    }
+    /**
+     * 添加
+     *
+     * @param unfixedDTO
+     * @return
+     */
+    @AutoLog(value = "商户无固定场所-添加")
+    @Operation(summary = "商户无固定场所-添加")
+//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:add")
+    @PostMapping(value = "/savePack")
+    public Result<String> savePack(@RequestBody
+
+                                         AppSitePlaceDTO unfixedDTO) {
+        Boolean b = appSitePlaceService.savePack(unfixedDTO);
+        return b ? Result.OK("添加成功!") : Result.error("添加失败!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param appSitePlace
+     * @return
+     */
+    @AutoLog(value = "商户场所学校-编辑")
+    @Operation(summary = "商户场所学校-编辑")
+//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody AppSitePlaceSchoolDTO appSitePlace) {
+        Boolean b = appSitePlaceService.editSchool(appSitePlace);
+        return b ? Result.OK("编辑成功!") : Result.error("编辑失败!");
+    } /**
+     * 编辑
+     *
+     * @param appSitePlace
+     * @return
+     */
+    @AutoLog(value = "商户场所学校-编辑")
+    @Operation(summary = "商户场所学校-编辑")
 //	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:edit")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody AppSitePlaceSchoolDTO appSitePlace) {
-		appSitePlaceService.editSchool(appSitePlace);
-		return Result.OK("编辑成功!");
-	}
-	
-	/**
-	 *   通过id删除
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "商户场所学校-通过id删除")
-	@Operation(summary="商户场所学校-通过id删除")
+    @RequestMapping(value = "/editPack", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> editPack(@RequestBody
+                                   AppSitePlaceDTO appSitePlace) {
+        Boolean b = appSitePlaceService.editPack(appSitePlace);
+        return b ? Result.OK("编辑成功!") : Result.error("编辑失败!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param unfixedDTO
+     * @return
+     */
+    @AutoLog(value = "c-编辑")
+    @Operation(summary = "商户无固定场所-编辑")
+//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:edit")
+    @RequestMapping(value = "/updateUnfixed", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> updateUnfixed(@RequestBody AppSitePlaceUnfixedDTO unfixedDTO) {
+        Boolean b = appSitePlaceService.updateUnfixed(unfixedDTO);
+        return b ? Result.OK("编辑成功!") : Result.error("编辑失败!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "商户场所学校-通过id删除")
+    @Operation(summary = "商户场所学校-通过id删除")
+//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        appSitePlaceService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "商户无固定场所-通过id删除")
+    @Operation(summary = "商户无固定场所-通过id删除")
 //	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:delete")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		appSitePlaceService.removeById(id);
-		return Result.OK("删除成功!");
-	}
-
-	/**
-	 * 通过id查询
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "商户场所表-通过id查询")
-	@Operation(summary="商户场所学校通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<AppSitePlaceSchoolDTO> queryById(@RequestParam(name="id",required=true) String id) {
-		return Result.OK(appSitePlaceService.querySchoolById( id));
-	}
+    @DeleteMapping(value = "/deleteUnfixed")
+    public Result<String> deleteUnfixed(@RequestParam(name = "id", required = true) String id) {
+        appSitePlaceService.deleteUnfixed(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "商户无固定场所-通过id删除")
+    @Operation(summary = "商户无固定场所-通过id删除")
+//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:delete")
+    @DeleteMapping(value = "/deletePackById")
+    public Result<String> deletePackById(@RequestParam(name = "id", required = true) String id) {
+        appSitePlaceService.deletePackById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "商户场所表-通过id查询")
+    @Operation(summary = "商户场所学校通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<AppSitePlaceSchoolDTO> queryById(@RequestParam(name = "id", required = true) String id) {
+        return Result.OK(appSitePlaceService.querySchoolById(id));
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "商户场所表-通过id查询")
+    @Operation(summary = "商户场所学校通过id查询")
+    @GetMapping(value = "/queryUnfixedById")
+    public Result<AppSitePlaceUnfixedDTO> queryUnfixedById(@RequestParam(name = "id", required = true) String id) {
+        return Result.OK(appSitePlaceService.queryUnfixedById(id));
+    }
 
 //    /**
 //    * 导出excel

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

@@ -26,6 +26,14 @@ import java.util.Date;
 public class AppGameCuDTO {
     @Schema(description = "id")
     private String id;
+    /**部门编码*/
+    @Excel(name = "部门编码", width = 15)
+    @Schema(description = "部门编码")
+    private String orgCode;
+    /**关联部门id*/
+    @Excel(name = "关联部门id", width = 15)
+    @Schema(description = "关联部门id")
+    private String tenantId;
     /**产品名称*/
     @Schema(description = "产品名称")
     private String name;

+ 18 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppSiteDTO.java

@@ -10,6 +10,7 @@ import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -39,6 +40,18 @@ public class AppSiteDTO {
     @Excel(name = "名称", width = 15)
     @Schema(description = "名称")
     private String name;
+    /**省*/
+    @Excel(name = "省", width = 15)
+    @Schema(description = "省")
+    private String province;
+    /**市*/
+    @Excel(name = "市", width = 15)
+    @Schema(description = "市")
+    private String city;
+    /**区县*/
+    @Excel(name = "区县", width = 15)
+    @Schema(description = "区县")
+    private String area;
     /**地址*/
     @Excel(name = "地址", width = 15)
     @Schema(description = "地址")
@@ -51,7 +64,11 @@ public class AppSiteDTO {
     @Excel(name = "经营状态0营业 1休息", width = 15)
     @Schema(description = "经营状态0营业 1休息")
     private Integer runStatus;
-    /**开始营业时间 时间为空则全天*/
+    /**经营类型0全天 1自定义*/
+    @Excel(name = "经营类型0全天 1自定义", width = 15)
+    @Schema(description = "经营类型0全天 1自定义")
+    private Integer runType;
+    /**开始营业时间 */
     @Excel(name = "开始营业时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")

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

@@ -49,6 +49,18 @@ public class AppSite implements Serializable {
 	@Excel(name = "名称", width = 15)
     @Schema(description = "名称")
     private String name;
+	/**省*/
+	@Excel(name = "省", width = 15)
+    @Schema(description = "省")
+    private String province;
+	/**市*/
+	@Excel(name = "市", width = 15)
+    @Schema(description = "市")
+    private String city;
+	/**区县*/
+	@Excel(name = "区县", width = 15)
+    @Schema(description = "区县")
+    private String area;
 	/**地址*/
 	@Excel(name = "地址", width = 15)
     @Schema(description = "地址")
@@ -61,6 +73,10 @@ public class AppSite implements Serializable {
 	@Excel(name = "经营状态0营业 1休息", width = 15)
     @Schema(description = "经营状态0营业 1休息")
     private Integer runStatus;
+	/**经营类型0全天 1自定义*/
+	@Excel(name = "经营类型0全天 1自定义", width = 15)
+    @Schema(description = "经营类型0全天 1自定义")
+    private Integer runType;
     /**开始营业时间 时间为空则全天*/
     @Excel(name = "开始营业时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")

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

@@ -83,25 +83,25 @@ public interface IAppSitePlaceService extends IService<AppSitePlace> {
 
 //体育馆包场
     /**
-     *学校场所新增
+     *包场场所新增
      * @param placeDTO
      * @return
      */
     Boolean savePack(AppSitePlaceDTO placeDTO);
     /**
-     * 学校场所修改
+     * 包场场所修改
      * @param placeDTO
      * @return
      */
     Boolean editPack(AppSitePlaceDTO placeDTO);
     /**
-     * 通过id查询学校场所
+     * 通过id查询包场场所
      * @param id
      * @return
      */
     AppSitePlaceDTO queryPackById(String id);
     /**
-     * 删除学校场所
+     * 包场学校场所
      * @param id
      * @return
      */

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

@@ -15,8 +15,10 @@ import org.jeecg.modules.system.app.dto.AppCoursesPageDTO;
 import org.jeecg.modules.system.app.dto.AppCoursesRuleDTO;
 import org.jeecg.modules.system.app.entity.AppCourses;
 import org.jeecg.modules.system.app.entity.AppCoursesPriceRules;
+import org.jeecg.modules.system.app.entity.AppSite;
 import org.jeecg.modules.system.app.mapper.AppCoursesMapper;
 import org.jeecg.modules.system.app.mapper.AppCoursesPriceRulesMapper;
+import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.app.service.IAppCoureseService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -39,17 +41,20 @@ import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_
 public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCourses> implements IAppCoureseService {
     @Resource
     private AppCoursesPriceRulesMapper priceRulesMapper;
+    @Resource
+    private AppSiteMapper siteMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean saveWitchPriceRules(AppCoursesDTO appCoursesDTO) {
         AppCoursesCuDTO coursesCuDTO = appCoursesDTO.getCourses();
         if (null == coursesCuDTO.getCategoryId()) throw new JeecgBootException("请选择课程类别");
+        AppSite site = siteMapper.selectById(coursesCuDTO.getSiteId());
         AppCourses appCourses = new AppCourses();
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         BeanUtils.copyProperties(coursesCuDTO, appCourses);
-        appCourses.setOrgCode(loginUser.getOrgCode());
-        appCourses.setTenantId(loginUser.getOrgId());
+        appCourses.setOrgCode(site.getOrgCode());
+        appCourses.setTenantId(site.getTenantId());
         appCourses.setUserId(loginUser.getId());
         List<AppCoursesRuleDTO> coursesRuleDTOS= appCoursesDTO.getPriceRulesList();
         //起止时间计算
@@ -86,13 +91,14 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
     @Transactional(rollbackFor = Exception.class)
     public Boolean editWitchPriceRules(AppCoursesCuDTO coursesCuDTO) {
         if (null == coursesCuDTO.getCategoryId()) throw new JeecgBootException("请选择课程类别");
+        AppSite site = siteMapper.selectById(coursesCuDTO.getSiteId());
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         AppCourses dbCourse = baseMapper.selectById(coursesCuDTO.getId());
 //        checkPermission(loginUser, dbCourse);
         AppCourses course = new AppCourses();
         BeanUtils.copyProperties(coursesCuDTO, course);
-        course.setOrgCode(loginUser.getOrgCode());
-        course.setTenantId(loginUser.getOrgId());
+        course.setOrgCode(site.getOrgCode());
+        course.setTenantId(site.getTenantId());
         course.setUserId(loginUser.getId());
         int updateCourseResult = baseMapper.updateById(course);
         if (updateCourseResult < 1) {

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

@@ -15,6 +15,7 @@ import org.jeecg.modules.system.app.entity.AppGameSchedule;
 import org.jeecg.modules.system.app.mapper.AppGameMapper;
 import org.jeecg.modules.system.app.mapper.AppGamePriceRulesMapper;
 import org.jeecg.modules.system.app.mapper.AppGameScheduleMapper;
+import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.app.service.IAppGameService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -40,6 +41,8 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
     private AppGamePriceRulesMapper rulesMapper;
     @Resource
     private AppGameScheduleMapper scheduleMapper;
+    @Resource
+    private AppSiteMapper siteMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)

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

@@ -62,17 +62,18 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
         appSitePlace.setOrgCode(site.getOrgCode());
         appSitePlace.setTenantId(site.getTenantId());
         appSitePlace.setSiteId(site.getId());
+        appSitePlace.setType(SitePlaceTypeEnum.SCHOOL.getCode());
         //时间段提取拼接
         List<AppSiteRuleDTO> siteRuleDTOS = placeDTO.getSiteRuleDTOS();
 
-        List<String>  teachingDay= new ArrayList<>() ;
-        List<String>   noTeachingDay= new ArrayList<>() ;
+        List<String> teachingDay = new ArrayList<>();
+        List<String> noTeachingDay = new ArrayList<>();
         if (!siteRuleDTOS.isEmpty()) {
             siteRuleDTOS.forEach(dto -> {
                 if (dto.getIsTeaching() == 0) {
-                    teachingDay.add(dto.getStartTime() + "-"+dto.getEndTime());
+                    teachingDay.add(dto.getStartTime() + "-" + dto.getEndTime());
                 } else {
-                    noTeachingDay.add(dto.getStartTime() + "-"+dto.getEndTime());
+                    noTeachingDay.add(dto.getStartTime() + "-" + dto.getEndTime());
                 }
             });
         }
@@ -321,7 +322,8 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
 
         return appSitePlaceUnfixedDTO;
     }
-//包场
+
+    //包场
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean savePack(AppSitePlaceDTO placeDTO) {
@@ -332,21 +334,22 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
             AppCategory category = appCategoryMapper.selectById(item.getCategoryId());
             for (int i = 0; i < item.getCount(); i++) {
                 AppSitePlace appSitePlace = new AppSitePlace();
-                BeanUtils.copyProperties(placeCuDTO,appSitePlace);
+                BeanUtils.copyProperties(placeCuDTO, appSitePlace);
                 appSitePlace.setType(SitePlaceTypeEnum.PACKAGE.getCode());
-                appSitePlace.setName(category.getName()+(i+1));
+                appSitePlace.setName(category.getName() + (i + 1));
                 appSitePlace.setOrgCode(site.getOrgCode());
                 appSitePlace.setTenantId(site.getTenantId());
                 int insert = baseMapper.insert(appSitePlace);
                 if (insert < 1) throw new JeecgBootException("包场保存失败", SC_INTERNAL_SERVER_ERROR_500);
                 siteRuleDTOS.stream().filter(rule -> rule.getCategoryId().equals(category.getId())).collect(Collectors.toList()).forEach(rule -> {
                     AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
-                    BeanUtils.copyProperties(rule,appSitePriceRules);
+                    BeanUtils.copyProperties(rule, appSitePriceRules);
                     appSitePriceRules.setSitePlaceId(appSitePlace.getId());
                     appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
                     appSitePriceRules.setTenantId(appSitePlace.getTenantId());
                     int savePriceResult = appSitePriceRulesMapper.insert(appSitePriceRules);
-                    if (savePriceResult < 1) throw new JeecgBootException("包场价格保存失败", SC_INTERNAL_SERVER_ERROR_500);
+                    if (savePriceResult < 1)
+                        throw new JeecgBootException("包场价格保存失败", SC_INTERNAL_SERVER_ERROR_500);
                 });
             }
 
@@ -369,7 +372,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
             throw new JeecgBootException("商户门店不存在", SC_INTERNAL_SERVER_ERROR_500);
         }
 
-        // 查询当前场地的所有包场场
+        // 查询当前场地的所有包场场
         List<AppSitePlace> existingPlaces = baseMapper.selectList(Wrappers.<AppSitePlace>lambdaQuery()
                 .eq(AppSitePlace::getSiteId, site.getId())
                 .eq(AppSitePlace::getType, SitePlaceTypeEnum.PACKAGE.getCode()));
@@ -385,8 +388,6 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
         for (AppSiteCategoryDOT item : siteCategoryDOTS) {
             String categoryId = item.getCategoryId();
             int count = item.getCount();
-            List<AppSiteRuleDTO> rules = ruleMap.getOrDefault(categoryId, Collections.emptyList());
-
             // 查询该分类已有的场地
             List<AppSitePlace> categoryPlaces = existingPlaces.stream()
                     .filter(p -> p.getCategoryId() != null && p.getCategoryId().equals(categoryId))
@@ -428,8 +429,9 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                         throw new JeecgBootException("包场场地更新失败", SC_INTERNAL_SERVER_ERROR_500);
                     }
                 }
-
-                // 更新价格规则
+                //传回的当前场地的包场价格规则
+                List<AppSiteRuleDTO> rules = ruleMap.getOrDefault(categoryId, Collections.emptyList());
+                // 当前场地 更新价格规则
                 List<AppSitePriceRules> priceRules = rules.stream()
                         .map(rule -> {
                             AppSitePriceRules priceRule = new AppSitePriceRules();
@@ -441,17 +443,60 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                         })
                         .collect(Collectors.toList());
 
-                // 删除旧的价格规则
-                appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery()
-                        .eq(AppSitePriceRules::getSitePlaceId, appSitePlace.getId()));
+                // 获取数据库中已有的价格规则
+                List<AppSitePriceRules> dbRules = appSitePriceRulesMapper.selectList(
+                        Wrappers.<AppSitePriceRules>lambdaQuery()
+                                .eq(AppSitePriceRules::getSitePlaceId, appSitePlace.getId())
+                );
+
+                // 构建新旧规则的映射(以 startTime + endTime 作为唯一标识)
+                Map<String, AppSitePriceRules> dbRuleMap = dbRules.stream()
+                        .collect(Collectors.toMap(
+                                rule -> rule.getStartTime() + "-" + rule.getEndTime(),
+                                rule -> rule));
+
+                Map<String, AppSitePriceRules> newRuleMap = priceRules.stream()
+                        .collect(Collectors.toMap(
+                                rule -> rule.getStartTime() + "-" + rule.getEndTime(),
+                                rule -> rule));
+
+                // 找出要删除的旧规则(存在于db,不存在于new)
+                List<AppSitePriceRules> toDelete = dbRules.stream()
+                        .filter(rule -> !newRuleMap.containsKey(rule.getStartTime() + "-" + rule.getEndTime()))
+                        .collect(Collectors.toList());
 
-                // 插入新的价格规则
-                for (AppSitePriceRules priceRule : priceRules) {
-                    int insertResult = appSitePriceRulesMapper.insert(priceRule);
-                    if (insertResult < 1) {
-                        throw new JeecgBootException("包场价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
-                    }
-                }
+                // 找出要新增的规则(存在于new,不存在于db)
+                List<AppSitePriceRules> toAdd = priceRules.stream()
+                        .filter(rule -> !dbRuleMap.containsKey(rule.getStartTime() + "-" + rule.getEndTime()))
+                        .collect(Collectors.toList());
+
+                // 找出需要更新的规则(存在交集且内容不同)
+                List<AppSitePriceRules> toUpdate = priceRules.stream()
+                        .filter(rule -> dbRuleMap.containsKey(rule.getStartTime() + "-" + rule.getEndTime()))
+                        .filter(rule -> {
+                            AppSitePriceRules dbRule = dbRuleMap.get(rule.getStartTime() + "-" + rule.getEndTime());
+                            return !rule.equals(dbRule); // 自定义 equals 或手动比较字段
+                        })
+                        .collect(Collectors.toList());
+
+                // 执行操作
+                toDelete.forEach(rule -> {
+                    int deleteResult = appSitePriceRulesMapper.deleteById(rule.getId());
+                    if (deleteResult < 1)
+                        throw new JeecgBootException("包场价格规则删除失败", SC_INTERNAL_SERVER_ERROR_500);
+                });
+
+                toAdd.forEach(rule -> {
+                    int insertResult = appSitePriceRulesMapper.insert(rule);
+                    if (insertResult < 1)
+                        throw new JeecgBootException("包场价格规则新增失败", SC_INTERNAL_SERVER_ERROR_500);
+                });
+
+                toUpdate.forEach(rule -> {
+                    int updateResult = appSitePriceRulesMapper.updateById(rule);
+                    if (updateResult < 1)
+                        throw new JeecgBootException("包场价格规则更新失败", SC_INTERNAL_SERVER_ERROR_500);
+                });
 
                 updatedPlaceIds.add(appSitePlace.getId());
             }
@@ -466,8 +511,11 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                 }
 
                 // 删除对应的价格规则
-                appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery()
+                int delete = appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery()
                         .eq(AppSitePriceRules::getSitePlaceId, existingPlace.getId()));
+                if (delete < 1) {
+                    throw new JeecgBootException("包场价格规则删除失败", SC_INTERNAL_SERVER_ERROR_500);
+                }
             }
         }
 
@@ -493,12 +541,27 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
             return appSiteCategoryDOT;
         }).collect(Collectors.toList());
 
-        return new AppSitePlaceDTO(placeCuDTO, collect,appSiteCategoryDOTs);
+        return new AppSitePlaceDTO(placeCuDTO, collect, appSiteCategoryDOTs);
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean deletePackById(String id) {
-        return null;
+        AppSitePlace dbPlace = baseMapper.selectById(id);
+        if (null == dbPlace) throw new JeecgBootException("包场数据不存在", SC_INTERNAL_SERVER_ERROR_500);
+        List<AppSitePlace> appSitePlaces = baseMapper.selectList(Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getSiteId, id));
+        appSitePlaces.forEach(appSitePlace -> {
+            int deleteResult = baseMapper.deleteById(appSitePlace.getId());
+            if (deleteResult < 1) {
+                throw new JeecgBootException("包场数据删除失败", SC_INTERNAL_SERVER_ERROR_500);
+            }
+            int delete = appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSitePlaceId, appSitePlace.getId()));
+            if (delete < 1) {
+                throw new JeecgBootException("包场价格规则删除失败", SC_INTERNAL_SERVER_ERROR_500);
+            }
+        });
+
+        return Boolean.TRUE;
     }
 
     /**

+ 30 - 12
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSiteServiceImpl.java

@@ -14,6 +14,8 @@ import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
 import org.jeecg.modules.system.app.service.IAppSiteService;
 import org.jeecg.modules.system.app.vo.AppSiteListVO;
+import org.jeecg.modules.system.entity.SysDepart;
+import org.jeecg.modules.system.mapper.SysDepartMapper;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
@@ -37,6 +39,8 @@ import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_
 public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> implements IAppSiteService {
     @Resource
     private AppSitePriceRulesMapper priceRulesMapper;
+    @Resource
+    private SysDepartMapper sysDepartMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -44,13 +48,23 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
         if (null == siteCuDTO.getType()) throw new JeecgBootException("商户类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         AppSite site = new AppSite();
+        SysDepart departById = sysDepartMapper.getDepartById(siteCuDTO.getTenantId());
+        if (null == departById) throw new JeecgBootException("商户部门不存在", SC_INTERNAL_SERVER_ERROR_500);
+        if (!departById.getOrgType().equals("3")) throw new JeecgBootException("商户部门类型错误", SC_INTERNAL_SERVER_ERROR_500);
         BeanUtils.copyProperties(siteCuDTO, site);
-        site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
-        site.setTenantId(sysUser.getOrgId());
+        if (null == site.getOrgCode())
+            throw new JeecgBootException("商户部门编码不能为空", SC_INTERNAL_SERVER_ERROR_500);
+        if (null == site.getTenantId())
+            throw new JeecgBootException("商户部门id不能为空", SC_INTERNAL_SERVER_ERROR_500);
         int saveSiteResult = baseMapper.insert(site);
         // 如果插入失败,抛出自定义异常提示“场地信息保存失败”
         if (saveSiteResult < 1) {
-            throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
+            throw new JeecgBootException("商户信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
+        }
+        departById.setAddress(site.getProvince()+site.getCity()+site.getArea()+site.getAddress());
+        int updateById = sysDepartMapper.updateById(departById);
+        if (updateById < 1) {
+            throw new JeecgBootException("商户部门信息更新失败");
         }
         // 所有操作成功完成后返回 true
         return Boolean.TRUE;
@@ -63,14 +77,16 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
         BeanUtils.copyProperties(siteCuDTO, site);
         if (null == site.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
         AppSite dbSite = baseMapper.selectById(site.getId());
-        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
+        if (null == dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 //        checkPermission(dbSite,sysUser);
-        site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
-        site.setTenantId(sysUser.getOrgId());
+        if (null == site.getOrgCode())
+            throw new JeecgBootException("商户部门编码不能为空", SC_INTERNAL_SERVER_ERROR_500);
+        if (null == site.getTenantId())
+            throw new JeecgBootException("商户部门id不能为空", SC_INTERNAL_SERVER_ERROR_500);
         int updateSiteResult = baseMapper.updateById(site);
         if (updateSiteResult < 1) {
-            throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
+            throw new JeecgBootException("商户信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
         }
         return Boolean.TRUE;
     }
@@ -78,7 +94,7 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
     @Override
     public AppSiteDTO querySiteById(String id) {
         AppSite dbSite = baseMapper.selectById(id);
-        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
+        if (null == dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
         AppSiteDTO appSiteDTO = new AppSiteDTO();
         BeanUtils.copyProperties(dbSite, appSiteDTO);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -100,11 +116,11 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
     @Transactional(rollbackFor = Exception.class)
     public Boolean deleteSiteById(String id) {
         AppSite dbSite = baseMapper.selectById(id);
-        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
+        if (null == dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 //        checkPermission(dbSite,sysUser);
         int deleteSiteResult = baseMapper.deleteById(id);
-        if (deleteSiteResult<1){
+        if (deleteSiteResult < 1) {
             throw new JeecgBootException("商户信息删除失败", SC_INTERNAL_SERVER_ERROR_500);
         }
         return Boolean.TRUE;
@@ -126,10 +142,12 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
 
     /**
      * 权限校验
+     *
      * @param site
      * @param sysUser
      */
-    private void checkPermission(AppSite site,LoginUser sysUser ){
-        if (!sysUser.getOrgCode().equals(site.getOrgCode())) throw new JeecgBootException("无权限操作", SC_INTERNAL_SERVER_ERROR_500);
+    private void checkPermission(AppSite site, LoginUser sysUser) {
+        if (!sysUser.getOrgCode().equals(site.getOrgCode()))
+            throw new JeecgBootException("无权限操作", SC_INTERNAL_SERVER_ERROR_500);
     }
 }