Sfoglia il codice sorgente

商家经营数据

jyc 3 mesi fa
parent
commit
c5ba0b5de8

+ 2 - 1
alien-entity/src/main/java/shop/alien/entity/store/LifeGroupBuyCount.java

@@ -1,5 +1,6 @@
 package shop.alien.entity.store;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -21,7 +22,7 @@ public class LifeGroupBuyCount {
     /**
      * 主键id
      */
-    @TableId
+    @TableId(value = "id", type = IdType.AUTO)
     private Integer id;
 
     /**

+ 11 - 11
alien-store/src/main/java/shop/alien/store/controller/LifeGroupBuyCountController.java

@@ -1,6 +1,5 @@
 package shop.alien.store.controller;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -9,11 +8,12 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
-import shop.alien.entity.store.LifeGroupBuyCount;
-import shop.alien.entity.store.dto.LifeGroupBuyDto;
-import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
+import shop.alien.entity.store.vo.LifeGroupBuyCountDateVo;
+import shop.alien.entity.store.vo.LifeGroupBuyCountVo;
 import shop.alien.store.service.LifeGroupBuyCountService;
 
+import java.util.List;
+
 /**
  * 团购统计
  */
@@ -29,13 +29,13 @@ public class LifeGroupBuyCountController {
 
     @ApiOperation("插入团购统计")
     @PostMapping("/insertGroupBuyCount")
-    public R insertGroupBuyCount(@RequestBody LifeGroupBuyCount lifeGroupBuyCount) {
-        log.info("LifeGroupBuyCountController.insertGroupBuyCount?lifeGroupBuyCount={}", lifeGroupBuyCount.toString());
+    public R insertGroupBuyCount(@RequestParam(value = "storeId") Integer storeId,@RequestParam(value = "groupId") Integer groupId,@RequestParam(value = "userId") Integer userId,@RequestParam(value = "countType") String countType) {
+        log.info("LifeGroupBuyCountController.insertGroupBuyCount?storeId={},groupId={},userId={},countType={}", storeId,groupId,userId,countType);
         try {
-            lifeGroupBuyCountService.insertGroupBuyCount(lifeGroupBuyCount);
+            lifeGroupBuyCountService.insertGroupBuyCount(storeId, groupId, userId, countType);
             return R.success("成功");
         }catch (Exception e){
-            log.error("LifeGroupBuyCountController.insertGroupBuyCount?lifeGroupBuyCount={}", lifeGroupBuyCount.toString(), e);
+            log.error("LifeGroupBuyCountController.insertGroupBuyCount?storeId={},groupId={},userId={},countType={}", storeId,groupId,userId,countType,e);
             return R.fail("失败");
         }
     }
@@ -43,7 +43,7 @@ public class LifeGroupBuyCountController {
     @ApiOperation("团购统计-经营数据")
     @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "String", paramType = "query", required = true)})
     @GetMapping("/getJysj")
-    private R getJysj(@RequestParam(value = "storeId") String storeId) {
+    private R<List<LifeGroupBuyCountVo>> getJysj(@RequestParam(value = "storeId") String storeId) {
         log.info("LifeGroupBuyCountController.getJysj?storeId={}", storeId);
         return R.data(lifeGroupBuyCountService.getJysj(storeId));
     }
@@ -51,7 +51,7 @@ public class LifeGroupBuyCountController {
     @ApiOperation("团购统计-商品核心指标趋势")
     @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "String", paramType = "query", required = true)})
     @GetMapping("/getSphxzb")
-    private R getSphxzb(@RequestParam(value = "storeId") String storeId) {
+    private R<List<LifeGroupBuyCountDateVo>> getSphxzb(@RequestParam(value = "storeId") String storeId) {
         log.info("LifeGroupBuyCountController.getSphxzb?storeId={}", storeId);
         return R.data(lifeGroupBuyCountService.getSphxzb(storeId));
     }
@@ -59,7 +59,7 @@ public class LifeGroupBuyCountController {
     @ApiOperation("团购统计-单品指标排名")
     @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "String", paramType = "query", required = true)})
     @GetMapping("/getDpzbpm")
-    private R getDpzbpm(@RequestParam(value = "storeId") String storeId) {
+    private R<List<LifeGroupBuyCountDateVo>> getDpzbpm(@RequestParam(value = "storeId") String storeId) {
         log.info("LifeGroupBuyCountController.getDpzbpm?storeId={}", storeId);
         return R.data(lifeGroupBuyCountService.getDpzbpm(storeId));
     }

+ 2 - 1
alien-store/src/main/java/shop/alien/store/service/LifeGroupBuyCountService.java

@@ -1,6 +1,7 @@
 package shop.alien.store.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.bind.annotation.RequestParam;
 import shop.alien.entity.store.LifeGroupBuyCount;
 import shop.alien.entity.store.vo.LifeGroupBuyCountDateVo;
 import shop.alien.entity.store.vo.LifeGroupBuyCountVo;
@@ -12,7 +13,7 @@ import java.util.List;
  */
 public interface LifeGroupBuyCountService extends IService<LifeGroupBuyCount> {
 
-    void insertGroupBuyCount(LifeGroupBuyCount lifeGroupBuyCount);
+    void insertGroupBuyCount(Integer storeId, Integer groupId, Integer userId, String countType);
 
     List<LifeGroupBuyCountVo> getJysj(String storeId);
 

+ 16 - 10
alien-store/src/main/java/shop/alien/store/service/impl/LifeGroupBuyCountServiceImpl.java

@@ -38,25 +38,31 @@ public class LifeGroupBuyCountServiceImpl extends ServiceImpl<LifeGroupBuyCountM
     private LifeUserOrderMapper lifeUserOrderMapper;
 
     @Override
-    public void insertGroupBuyCount(LifeGroupBuyCount lifeGroupBuyCount) {
+    public void insertGroupBuyCount(Integer storeId, Integer groupId, Integer userId, String countType) {
         LambdaQueryWrapper<LifeGroupBuyCount> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(LifeGroupBuyCount::getCountType, lifeGroupBuyCount.getCountType())
-                .eq(LifeGroupBuyCount::getStoreId, lifeGroupBuyCount.getStoreId())
-                .eq(LifeGroupBuyCount::getGroupId, lifeGroupBuyCount.getGroupId())
-                .eq(LifeGroupBuyCount::getUserId, lifeGroupBuyCount.getUserId())
+        queryWrapper.eq(LifeGroupBuyCount::getCountType, countType)
+                .eq(LifeGroupBuyCount::getStoreId, storeId)
+                .eq(LifeGroupBuyCount::getGroupId, groupId)
+                .eq(LifeGroupBuyCount::getUserId, userId)
                 .eq(LifeGroupBuyCount::getCountDate, DateUtils.format(new Date(), "yyyy-MM-dd"));
         Integer count = lifeGroupBuyCountMapper.selectCount(queryWrapper);
         if (count > 0) {
             List<LifeGroupBuyCount> lifeGroupBuyCounts = lifeGroupBuyCountMapper.selectList(queryWrapper);
             LambdaUpdateWrapper<LifeGroupBuyCount> updateWrapper = new LambdaUpdateWrapper<>();
-            updateWrapper.eq(LifeGroupBuyCount::getCountType, lifeGroupBuyCount.getCountType())
-                    .eq(LifeGroupBuyCount::getStoreId, lifeGroupBuyCount.getStoreId())
-                    .eq(LifeGroupBuyCount::getGroupId, lifeGroupBuyCount.getGroupId())
-                    .eq(LifeGroupBuyCount::getUserId, lifeGroupBuyCount.getUserId())
+            updateWrapper.eq(LifeGroupBuyCount::getCountType, countType)
+                    .eq(LifeGroupBuyCount::getStoreId, storeId)
+                    .eq(LifeGroupBuyCount::getGroupId, groupId)
+                    .eq(LifeGroupBuyCount::getUserId, userId)
                     .eq(LifeGroupBuyCount::getCountDate, DateUtils.format(new Date(), "yyyy-MM-dd"))
                     .set(LifeGroupBuyCount::getCountNum, lifeGroupBuyCounts.get(0).getCountNum() + 1);
-            lifeGroupBuyCountMapper.update(null, queryWrapper);
+            lifeGroupBuyCountMapper.update(null, updateWrapper);
         } else {
+            LifeGroupBuyCount lifeGroupBuyCount = new LifeGroupBuyCount();
+            lifeGroupBuyCount.setCountDate(new Date());
+            lifeGroupBuyCount.setCountType(countType);
+            lifeGroupBuyCount.setStoreId(storeId);
+            lifeGroupBuyCount.setGroupId(groupId);
+            lifeGroupBuyCount.setUserId(userId);
             lifeGroupBuyCount.setCountNum(1);
             lifeGroupBuyCountMapper.insert(lifeGroupBuyCount);
         }