zhangxin 4 долоо хоног өмнө
parent
commit
34e074d6b0

+ 16 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/my/AppFamilyMembersController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 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.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
@@ -12,6 +13,8 @@ import org.jeecg.modules.app.dto.AddFamilyMembersDTO;
 import org.jeecg.modules.app.dto.FindFamilyMembersDTO;
 import org.jeecg.modules.system.app.entity.FamilyMembers;
 import org.jeecg.modules.system.app.service.IFamilyMembersService;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -28,6 +31,9 @@ public class AppFamilyMembersController {
     @Autowired
     IFamilyMembersService iFamilyMembersService;
 
+    @Autowired
+    ISysUserService iSysUserService;
+
 
     @GetMapping("/findFamilyMembers")
     @Operation(summary = "分页查询家庭成员")
@@ -41,8 +47,16 @@ public class AppFamilyMembersController {
     @PostMapping("/addFamilyMembers")
     @Operation(summary = "添加家庭成员")
     public Result<String> addFamilyMembers(@Validated @RequestBody AddFamilyMembersDTO addFamilyMembersDTO){
-        LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        addFamilyMembersDTO.setUserId(principal.getId());
+        if (StringUtils.isEmpty(addFamilyMembersDTO.getUserId())){
+            LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId=principal.getId();
+            addFamilyMembersDTO.setUserId(userId);
+        }else {
+            SysUser sysUser = iSysUserService.getById(addFamilyMembersDTO.getUserId());
+            if (sysUser==null||sysUser.getDelFlag()==1){
+                return Result.error("该添加人员未查询到所属用户,无法进行添加");
+            }
+        }
         if (addFamilyMembersDTO.getRealNameStatus()!=1){
             return Result.error("该添加人员未实名,无法进行添加");
         }

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

@@ -10,12 +10,12 @@
             resultType="org.jeecg.modules.system.app.vo.statistics.FindByStatisticsChartVO">
          <![CDATA[
         select
-                b.depart_name,
-                sum(sale_money) as saleMoney,
-                a.dept_id from nm_statistics_info a
-         left join  sys_depart b on a.dept_id =b.id
-         where org_code like CONCAT('',#{orgCode},'%')  and  org_code !=#{orgCode} and date_daily >=#{firstDayInt} and date_daily <= #{dateAsInt}
-        group by  a.dept_id
+                b.name as deptName,
+                COALESCE(SUM(sale_money), 0) as saleMoney,
+                b.id from  nm_site b
+         left join  nm_statistics_info a on a.dept_id =b.tenant_id  and a.date_daily >=#{startTime} and a.date_daily <= #{endTime}
+         where  b.org_code like CONCAT('',#{orgCode},'%')   and b.del_flag =0
+        group by  b.id
         order by  saleMoney desc
          ]]>
     </select>

+ 20 - 23
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/StatisticsInfoServiceImpl.java

@@ -24,7 +24,6 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -91,18 +90,17 @@ public class StatisticsInfoServiceImpl extends ServiceImpl<StatisticsInfoMapper,
     public FindByStatisticsVO findByStatistics(String orgCode, int dateAsInt, int firstDayInt,int yesterdayNum ) {
         StatisticsInfo byOrgCode = statisticsInfoMapper.findByOrgCode(orgCode, dateAsInt);
         FindByStatisticsVO findByStatisticsVO =new FindByStatisticsVO();
-        List<FindByStatisticsChartVO> findByStatisticsChartVOS = new ArrayList<>();
         if(byOrgCode!=null){
-            // 定义日期格式(yyyyMMdd)
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
             BeanUtils.copyProperties(byOrgCode,findByStatisticsVO);
-            findByStatisticsChartVOS = statisticsInfoMapper.findByOrgCodeAndDay(orgCode,dateAsInt,firstDayInt);
-            for (FindByStatisticsChartVO findByStatisticsChartVO : findByStatisticsChartVOS) {
-                Integer dateDaily = findByStatisticsChartVO.getDateDaily();
-                // 解析为 LocalDate
-                LocalDate date = LocalDate.parse(String.valueOf(dateDaily), formatter);
-                findByStatisticsChartVO.setDateDailyDate(date);
-            }
+        }
+        // 定义日期格式(yyyyMMdd)
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        List<FindByStatisticsChartVO>    findByStatisticsChartVOS = statisticsInfoMapper.findByOrgCodeAndDay(orgCode,dateAsInt,firstDayInt);
+        for (FindByStatisticsChartVO findByStatisticsChartVO : findByStatisticsChartVOS) {
+            Integer dateDaily = findByStatisticsChartVO.getDateDaily();
+            // 解析为 LocalDate
+            LocalDate date = LocalDate.parse(String.valueOf(dateDaily), formatter);
+            findByStatisticsChartVO.setDateDailyDate(date);
         }
         StatisticsInfo byOrgCodeOld = statisticsInfoMapper.findByOrgCode(orgCode, yesterdayNum);
         getStatisticsInfo(byOrgCode,byOrgCodeOld,findByStatisticsVO);
@@ -114,17 +112,17 @@ public class StatisticsInfoServiceImpl extends ServiceImpl<StatisticsInfoMapper,
     public List<FindByStatisticsChartVO> findByShopMoneyList(String orgCode,Integer type) {
         LocalDateTime today = LocalDateTime.now();
         /**获取当天的yyyyMMdd时间格式 int类型*/
-        int startTime = Integer.parseInt(
+        int endTime = Integer.parseInt(
                 today.format(DateTimeFormatter.ofPattern("yyyyMMdd"))
         );
         /**获取当月的yyyyMMdd时间格式 int类型*/
-        int endTime = Integer.parseInt(today.format(DateTimeFormatter.ofPattern("yyyyMMdd")));//默认当天
+        int startTime = Integer.parseInt(today.format(DateTimeFormatter.ofPattern("yyyyMMdd")));//默认当天
         if (type==1){//今日
-            endTime = Integer.parseInt(today.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
+            startTime = Integer.parseInt(today.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
         } else if (type==2) {//本周
-            endTime = Integer.parseInt(today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
+            startTime = Integer.parseInt(today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
         }else if (type==3){//本月
-            endTime = Integer.parseInt(today.withDayOfMonth(1).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
+            startTime = Integer.parseInt(today.withDayOfMonth(1).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
         }
         return statisticsInfoMapper.findByShopMoneyList(orgCode,startTime,endTime);
     }
@@ -133,23 +131,22 @@ public class StatisticsInfoServiceImpl extends ServiceImpl<StatisticsInfoMapper,
     public List<FindByShopSumVO> findByShopSumList(String orgCode, Integer type) {
         // 获取当前日期
         LocalDate today = LocalDate.now();
-        LocalDateTime startTime = today.atStartOfDay();
-        // 1. 明天 00:00:00
         LocalDateTime endTime = today.plusDays(1).atStartOfDay();
+        // 1. 今天 00:00:00
+        LocalDateTime startTime =today.atStartOfDay();
         if (type==1){
             // 1. 明天 00:00:00
-            endTime = today.plusDays(1).atStartOfDay();
+            startTime = today.plusDays(1).atStartOfDay();
         } else if (type==2) {
             // 2. 本周第一天(周一)00:00:00
-            endTime = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
+            startTime = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
                     .atStartOfDay();
         } else if (type==3) {
             // 3. 当月第一天 00:00:00
-            endTime = today.with(TemporalAdjusters.firstDayOfMonth())
+            startTime = today.with(TemporalAdjusters.firstDayOfMonth())
                     .atStartOfDay();
         }
-        List<FindByShopSumVO> findByShopSumVOS= appOrderMapper.findByShopSumList(orgCode,startTime,endTime);
-        return null;
+        return appOrderMapper.findByShopSumList(orgCode,startTime,endTime);
     }
 
     private void getStatisticsInfo(StatisticsInfo statisticsInfoNew ,StatisticsInfo statisticsInfoOld,FindByStatisticsVO findByStatisticsVO){

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/vo/statistics/FindByStatisticsChartVO.java

@@ -28,9 +28,9 @@ public class FindByStatisticsChartVO  {
     private LocalDate dateDailyDate;
 
     @Schema(description = "机构编码")
-    private Integer org_code;
+    private String org_code;
     @Schema(description = "商家名称")
-    private Integer DeptName;
+    private String deptName;
     /**销售金额*/
     @Schema(description = "销售金额")
     private BigDecimal saleMoney =BigDecimal.ZERO;