Browse Source

修复bug

zhangxin 4 days ago
parent
commit
77b87b6f1b

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

@@ -21,15 +21,21 @@ import org.jeecg.modules.app.vo.LoginUserVO;
 import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
 import org.jeecg.modules.system.app.entity.FamilyMembers;
+import org.jeecg.modules.system.app.entity.StatisticsInfo;
 import org.jeecg.modules.system.app.mapper.FamilyMembersMapper;
+import org.jeecg.modules.system.app.mapper.StatisticsInfoMapper;
 import org.jeecg.modules.system.entity.*;
 import org.jeecg.modules.system.mapper.*;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
@@ -58,7 +64,11 @@ public class UserServiceImpl implements IUserService {
     @Resource
     private RedisUtil redisUtil;
 
+    @Autowired
+    StatisticsInfoMapper statisticsInfoMapper;
+
     @Override
+    @Transactional
     public LoginUserVO wechatLogin(String code) {
         try {
             WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
@@ -87,6 +97,28 @@ public class UserServiceImpl implements IUserService {
                         throw new JeecgBootException("登录失败", SC_INTERNAL_SERVER_ERROR_500);
                 }
                 familyMembersMapper.insert(new FamilyMembers().setDelFlag(0).setUserId(user.getId()).setUserType(0).setRealNameStatus(0));
+                int dateAsInt = Integer.parseInt(
+                        LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+                );
+                //查询当天是否有平台统计信息
+                StatisticsInfo statisticsInfo= statisticsInfoMapper.findByOrgCode("A01",dateAsInt);
+                SysDepart byOrgCode = sysDepartMapper.findByOrgCode("A01");
+                if (byOrgCode==null){
+                    throw new JeecgBootException("登录失败,平台部门不存在", SC_INTERNAL_SERVER_ERROR_500);
+                }
+                if (statisticsInfo==null){
+                    statisticsInfo=new StatisticsInfo();
+                    statisticsInfo.setDateDaily(dateAsInt);
+                    statisticsInfo.setOrgCode(byOrgCode.getOrgCode());
+                    statisticsInfo.setDeptId(byOrgCode.getId());
+                    statisticsInfo.setAddNumber(1);
+                    statisticsInfo.setUpdateTime(new Date());
+                    statisticsInfo.setCreateTime(new Date());
+                }else {
+                    statisticsInfo.setAddNumber(statisticsInfo.getAddNumber()+1);
+                    statisticsInfo.setUpdateTime(new Date());
+                }
+                statisticsInfoMapper.insert(statisticsInfo);
             }
             return generateLoginUserVO(user);
         } catch (WxErrorException e) {

+ 17 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/separateAccounts/SeparateAccountsController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
@@ -19,8 +20,10 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
 import java.util.Arrays;
- /**
+
+/**
  * @Description: 分账管理
  * @Author: jeecg-boot
  * @Date:   2025-07-10
@@ -67,11 +70,15 @@ public class SeparateAccountsController extends JeecgController<SeparateAccounts
 	@Operation(summary="分账管理-添加")
 	@RequiresPermissions("separateAccounts:nm_separate_accounts:add")
 	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody SeparateAccounts separateAccounts) {
+	public Result<String> add(@Valid @RequestBody SeparateAccounts separateAccounts) {
+		SeparateAccounts separateAccountsOld =separateAccountsService.findByDeptId(separateAccounts.getDeptId(),null);
+		if (separateAccountsOld!=null){
+			return Result.error("添加失败,该商铺分账已存在");
+		}
 		separateAccountsService.save(separateAccounts);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -83,6 +90,13 @@ public class SeparateAccountsController extends JeecgController<SeparateAccounts
 	@RequiresPermissions("separateAccounts:nm_separate_accounts:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
 	public Result<String> edit(@RequestBody SeparateAccounts separateAccounts) {
+		if (StringUtils.isEmpty(separateAccounts.getId())){
+			return Result.error("添加失败,请选择商户");
+		}
+		SeparateAccounts separateAccountsOld =separateAccountsService.findByDeptId(separateAccounts.getDeptId(),separateAccounts.getId());
+		if (separateAccountsOld!=null){
+			return Result.error("添加失败,该商铺分账已存在");
+		}
 		separateAccountsService.updateById(separateAccounts);
 		return Result.OK("编辑成功!");
 	}

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

@@ -12,6 +12,9 @@ import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
@@ -37,18 +40,25 @@ public class SeparateAccounts implements Serializable {
 	/**关联的商户信息*/
 	@Excel(name = "关联的商户信息", width = 15)
     @Schema(description = "关联的商户信息")
+    @NotBlank(message = "商户不允许为空")
     private String deptId;
 	/**平台分账比例 单位%*/
 	@Excel(name = "平台分账比例 单位%", width = 15)
     @Schema(description = "平台分账比例 单位%")
+    @NotNull(message = "累计总金额不能为空")
+    @DecimalMin(value = "0.00", message = "累计总金额不能小于0")
     private BigDecimal ptSeparateAccounts;
 	/**商家分账比例 单位%*/
 	@Excel(name = "商家分账比例 单位%", width = 15)
     @Schema(description = "商家分账比例 单位%")
+    @NotNull(message = "累计总金额不能为空")
+    @DecimalMin(value = "0.00", message = "累计总金额不能小于0")
     private BigDecimal shSeparateAccounts;
     /**商家分账比例 单位%*/
     @Excel(name = "商家分账比例 单位%", width = 15)
     @Schema(description = "商家分账比例 单位%")
+    @NotNull(message = "累计总金额不能为空")
+    @DecimalMin(value = "0.00", message = "累计总金额不能小于0")
     private BigDecimal mdSeparateAccounts;
 	/**分账状态 0-启用 1-停用  默认启用*/
 	@Excel(name = "分账状态 0-启用 1-停用  默认启用", width = 15)

+ 2 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/SeparateAccountsMapper.java

@@ -17,4 +17,6 @@ import org.jeecg.modules.system.app.entity.SeparateAccounts;
 public interface SeparateAccountsMapper extends BaseMapper<SeparateAccounts> {
 
     IPage<FindAccountResponseDTO> findPage(@Param("page") Page<FindAccountResponseDTO> page, @Param("findAccountRequestDTO") FindAccountRequestDTO findAccountRequestDTO);
+
+    SeparateAccounts findByDeptId(@Param("deptId") String deptId,@Param("id") String id);
 }

+ 21 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/StatisticsInfoMapper.java

@@ -0,0 +1,21 @@
+package org.jeecg.modules.system.app.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.system.app.entity.StatisticsInfo;
+
+/**
+ * @Description: 首页统计表
+ * @Author: jeecg-boot
+ * @Date:   2025-08-18
+ * @Version: V1.0
+ */
+public interface StatisticsInfoMapper extends BaseMapper<StatisticsInfo> {
+
+    @Select("select * from nm_statistics_info where org_code =#{orgCode} and date_daily =#{dateDaily}")
+    StatisticsInfo findByOrgCode(@Param("orgCode") String orgCode ,@Param("dateDaily")  Integer dateDaily);
+
+    @Select("select * from nm_statistics_info where org_code =#{orgCode} order by  date_daily desc limit 1")
+    StatisticsInfo findByCode(String orgCode);
+}

+ 6 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/SeparateAccountsMapper.xml

@@ -17,4 +17,10 @@
         </if>
         </if>
     </select>
+    <select id="findByDeptId" resultType="org.jeecg.modules.system.app.entity.SeparateAccounts">
+        select * from nm_separate_accounts where dept_id =#{deptId} AND del_flag =0
+        <if test="id !=null and id!=''">
+            AND id != #{id}
+        </if>
+    </select>
 </mapper>

+ 5 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/StatisticsInfoMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.system.app.mapper.StatisticsInfoMapper">
+
+</mapper>

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

@@ -17,4 +17,5 @@ public interface ISeparateAccountsService extends IService<SeparateAccounts> {
 
     IPage<FindAccountResponseDTO> findPage(Page<FindAccountResponseDTO> page, FindAccountRequestDTO findAccountRequestDTO);
 
+    SeparateAccounts findByDeptId(String deptId,  String id);
 }

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

@@ -30,4 +30,9 @@ public class SeparateAccountsServiceImpl extends ServiceImpl<SeparateAccountsMap
 
         return separateAccountsMapper.findPage(page,findAccountRequestDTO);
     }
+
+    @Override
+    public SeparateAccounts findByDeptId(String deptId, String id) {
+        return separateAccountsMapper.findByDeptId(deptId,id);
+    }
 }