From 5aad929b87cba3e2accfd3f243fa70af180937d2 Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期二, 17 十二月 2024 09:10:28 +0800
Subject: [PATCH] 1
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java | 6
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java | 69 +++++++++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RedPackegeSetDto.java | 11 ++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopPointService.java | 3
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml | 42 ++++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java | 59 +++++++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopPointStatistics.java | 3
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java | 41 +++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java | 4
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/excel/ShopPointEX.java | 37 +++++++
10 files changed, 264 insertions(+), 11 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java
index 86ada89..49eda6f 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java
@@ -3,14 +3,17 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
+import java.util.List;
/**
* <p>
@@ -42,11 +45,11 @@
@ApiModelProperty(value = "历史余额")
@TableField("historical_point")
- private BigDecimal historicalPoint;
+ private Integer historicalPoint;
@ApiModelProperty(value = "变动金额")
@TableField("variable_point")
- private BigDecimal variablePoint;
+ private Integer variablePoint;
@ApiModelProperty(value = "变动时间")
@TableField("create_time")
@@ -60,5 +63,39 @@
@TableField("object_id")
private Long objectId;
+ @ApiModelProperty(value = "门店名称")
+ @TableField(exist = false)
+ private String shopName;
+
+ @ApiModelProperty(value = "店长姓名")
+ @TableField(exist = false)
+ private String shopLeaderName;
+
+ @ApiModelProperty(value = "联系电话")
+ @TableField(exist = false)
+ private String phone;
+
+ @TableField(exist = false)
+ private List<Integer> shopIds;
+
+ @ApiModelProperty(value = "开始时间")
+ @TableField(exist = false)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime startTime;
+
+ @ApiModelProperty(value = "结束时间")
+ @TableField(exist = false)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime endTime;
+
+ @TableField(exist = false)
+ private List<Long> userIds;
+ @TableField(exist = false)
+ private Integer pageNum;
+ @TableField(exist = false)
+ private Integer pageSize;
+
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
index 5b5b1f6..96bf652 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
@@ -4,6 +4,7 @@
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.RedPackegeSet;
+import com.ruoyi.other.dto.RedPackegeSetDto;
import com.ruoyi.other.service.RedPackegeSetService;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
@@ -58,8 +59,9 @@
@ApiOperation(value = "添加红包配置", tags = {"管理后台-活动管理-签到红包"})
@PostMapping("/addRedPackegeSet")
@Transactional(rollbackFor = Exception.class)
- public R<Void> addRedPackegeSet(@RequestBody List<RedPackegeSet> redPackegeSets){
- for (RedPackegeSet redPackegeSet : redPackegeSets) {
+ public R<Void> addRedPackegeSet(@RequestBody RedPackegeSetDto redPackegeSets){
+ List<RedPackegeSet> redPackegeSetList = redPackegeSets.getRedPackegeSets();
+ for (RedPackegeSet redPackegeSet : redPackegeSetList) {
RedPackegeSet one = redPackegeSetService.getOne(null);
if (one==null){
redPackegeSet.setId(1);
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
index 380d4ba..9833fce 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
@@ -1,12 +1,25 @@
package com.ruoyi.other.controller;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.bean.BeanUtils;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.other.api.domain.ShopPoint;
+import com.ruoyi.other.excel.ShopPointEX;
import com.ruoyi.other.service.ShopPointService;
+import com.ruoyi.other.vo.ShopPointStatistics;
import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
/**
* <p>
@@ -27,8 +40,50 @@
/**
* 门店积分统计
*/
- public Object statistics() {
- return shopPointService.statistics();
+ @GetMapping("/statistics")
+ @ApiModelProperty("门店积分统计")
+ public R<ShopPointStatistics> statistics(ShopPoint shopPoint) {
+ ShopPointStatistics statistics = shopPointService.statistics(Page.of(shopPoint.getPageNum(), shopPoint.getPageSize()), shopPoint);
+ return R.ok(statistics);
+ }
+
+ /**
+ * 导出门店积分统计
+ */
+ @GetMapping("/export")
+ @ApiModelProperty("导出门店积分统计")
+ public void export(HttpServletResponse response , ShopPoint shopPoint) {
+ ShopPointStatistics statistics = shopPointService.statistics(Page.of(1, Integer.MAX_VALUE), shopPoint);
+ if (statistics!=null){
+ IPage<ShopPoint> shopPointIPage = statistics.getShopPointIPage();
+ List<ShopPointEX> shopPointEXList = new ArrayList<>();
+ if (shopPointIPage!=null){
+ List<ShopPoint> records = shopPointIPage.getRecords();
+ if (records!=null){
+ for (ShopPoint record : records) {
+ ShopPointEX shopPointEX = new ShopPointEX();
+ BeanUtils.copyBeanProp(shopPointEX, record);
+ Integer type = record.getType();
+ switch (type) {
+ case 1:
+ shopPointEX.setType("门店业绩");
+ break;
+ case 2:
+ shopPointEX.setType("门店返佣");
+ break;
+ default:
+ shopPointEX.setType("下级门店返佣");
+ break;
+ }
+ shopPointEXList.add(shopPointEX);
+ }
+ }
+
+ ExcelUtil<ShopPointEX> util = new ExcelUtil<>(ShopPointEX.class);
+ util.exportExcel(response, shopPointEXList, "用户积分统计");
+ }
+ }
+
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RedPackegeSetDto.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RedPackegeSetDto.java
new file mode 100644
index 0000000..9744a8d
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RedPackegeSetDto.java
@@ -0,0 +1,11 @@
+package com.ruoyi.other.dto;
+
+import com.ruoyi.other.api.domain.RedPackegeSet;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class RedPackegeSetDto {
+ private List<RedPackegeSet> redPackegeSets;
+}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/excel/ShopPointEX.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/excel/ShopPointEX.java
new file mode 100644
index 0000000..7376059
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/excel/ShopPointEX.java
@@ -0,0 +1,37 @@
+package com.ruoyi.other.excel;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class ShopPointEX {
+ @Excel(name = "变动类型")
+ private String type;
+
+ @Excel(name = "历史余额")
+ private Integer historicalPoint;
+
+ @Excel(name = "变动金额")
+ private Integer variablePoint;
+
+ @Excel(name = "变动时间")
+ private LocalDateTime createTime;
+
+ @Excel(name = "变动用户id")
+ private Long createUserId;
+
+ @Excel(name = "关联对象id")
+ private Long objectId;
+
+ @Excel(name = "门店名称")
+ private String shopName;
+
+ @Excel(name = "店长姓名")
+ private String shopLeaderName;
+
+ @Excel(name = "联系电话")
+ private String phone;
+
+}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java
index f1e5685..02355d9 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.other.api.domain.ShopPoint;
+import java.util.List;
+
/**
* <p>
* Mapper 接口
@@ -13,4 +15,6 @@
*/
public interface ShopPointMapper extends BaseMapper<ShopPoint> {
+ List<ShopPoint> findLatestChangeByType(ShopPoint shopPoint);
+
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopPointService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopPointService.java
index efcf878..521a1b9 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopPointService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopPointService.java
@@ -1,5 +1,6 @@
package com.ruoyi.other.service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.other.api.domain.ShopPoint;
import com.ruoyi.other.vo.ShopPointStatistics;
@@ -14,5 +15,5 @@
*/
public interface ShopPointService extends IService<ShopPoint> {
- ShopPointStatistics statistics();
+ ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint);
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
index accf87f..9e2354a 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
@@ -1,15 +1,27 @@
package com.ruoyi.other.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.mapper.ShopPointMapper;
import com.ruoyi.other.api.domain.ShopPoint;
import com.ruoyi.other.service.ShopPointService;
+import com.ruoyi.other.service.ShopService;
import com.ruoyi.other.vo.ShopPointStatistics;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
/**
* <p>
- * 服务实现类
+ * 服务实现类
* </p>
*
* @author luodangjia
@@ -17,10 +29,61 @@
*/
@Service
public class ShopPointServiceImpl extends ServiceImpl<ShopPointMapper, ShopPoint> implements ShopPointService {
+ @Resource
+ private ShopPointMapper shopPointMapper;
+ @Resource
+ private ShopService shopService;
@Override
- public ShopPointStatistics statistics() {
+ public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) {
+
+ String shopName = shopPoint.getShopName();
+ String phone = shopPoint.getPhone();
+ String shopLeaderName = shopPoint.getShopLeaderName();
+ if (StringUtils.isNotEmpty(shopName) || StringUtils.isNotEmpty(phone) || StringUtils.isNotEmpty(shopLeaderName)) {
+ List<Integer> shopIds = shopService.listObjs(new LambdaQueryWrapper<Shop>()
+ .select(Shop::getId)
+ .like(StringUtils.isNotEmpty(shopName), Shop::getName, shopName)
+ .like(StringUtils.isNotEmpty(phone), Shop::getPhone, phone)
+ .like(StringUtils.isNotEmpty(shopLeaderName), Shop::getShopManager, shopLeaderName))
+ .stream().map(o -> (Integer) o).collect(Collectors.toList());
+
+ shopPoint.setShopIds(shopIds);
+ }
+
+
ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
- return null;
+ List<ShopPoint> latestChangeByType = shopPointMapper.findLatestChangeByType(shopPoint);
+ for (ShopPoint sp : latestChangeByType) {
+ switch (sp.getType()) {
+ case 1:
+ shopPointStatistics.setShopPoint(sp.getVariablePoint());
+ break;
+ case 2:
+ shopPointStatistics.setShopCommissionPoint(sp.getVariablePoint());
+ break;
+ case 3:
+ shopPointStatistics.setSubShopCommissionPoint(sp.getVariablePoint());
+ break;
+ }
+ }
+ shopPointStatistics.setTotalPoint(shopPointStatistics.getShopPoint() + shopPointStatistics.getShopCommissionPoint() + shopPointStatistics.getSubShopCommissionPoint());
+
+
+ boolean condition = shopPoint.getStartTime() != null && shopPoint.getEndTime() != null;
+ IPage<ShopPoint> shopPointIPage = page(page, new LambdaQueryWrapper<ShopPoint>()
+ .in(!CollectionUtils.isEmpty(shopPoint.getShopIds()), ShopPoint::getShopId, shopPoint.getShopIds())
+ .eq(shopPoint.getType() != null, ShopPoint::getType, shopPoint.getType())
+ .between(condition, ShopPoint::getCreateTime, shopPoint.getStartTime(), shopPoint.getEndTime())
+ .orderByDesc(ShopPoint::getCreateTime));
+ List<ShopPoint> shopPoints = shopPointIPage.getRecords();
+ for (ShopPoint sp : shopPoints) {
+ Shop shop = shopService.getById(sp.getShopId());
+ sp.setShopName(shop.getName());
+ sp.setShopLeaderName(shop.getShopManager());
+ sp.setPhone(shop.getPhone());
+ }
+ shopPointStatistics.setShopPointIPage(shopPointIPage);
+ return shopPointStatistics;
}
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopPointStatistics.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopPointStatistics.java
index 6cae81e..79f8376 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopPointStatistics.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopPointStatistics.java
@@ -1,5 +1,6 @@
package com.ruoyi.other.vo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.other.api.domain.ShopPoint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -35,5 +36,5 @@
@ApiModelProperty("下级门店返佣积分")
private Integer subShopCommissionPoint;
- private List<ShopPoint> shopPointList;
+ private IPage<ShopPoint> shopPointIPage;
}
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
new file mode 100644
index 0000000..6cf12a0
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
@@ -0,0 +1,42 @@
+<?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="com.ruoyi.other.mapper.ShopPointMapper">
+
+ <select id="findLatestChangeByType" resultType="com.ruoyi.other.api.domain.ShopPoint">
+ SELECT
+ id,
+ shop_id,
+ type,
+ historical_point,
+ variable_point,
+ create_time,
+ create_user_id,
+ object_id
+ FROM
+ (
+ SELECT
+ id,
+ shop_id,
+ type,
+ historical_point,
+ variable_point,
+ create_time,
+ create_user_id,
+ object_id,
+ ROW_NUMBER() OVER ( PARTITION BY type ORDER BY create_time DESC ) AS rn
+ FROM
+ t_shop_point
+
+ <where>
+ <if test="shopIds != null and shopIds.size() > 0">
+ AND shop_id IN
+ <foreach collection="shopIds" item="shopId" open="(" close=")" separator=",">
+ #{shopId}
+ </foreach>
+ </if>
+ </where>
+ ) AS subquery
+ WHERE
+ rn = 1
+ </select>
+</mapper>
\ No newline at end of file
--
Gitblit v1.7.1