ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java
@@ -38,7 +38,7 @@ private Long id; @ApiModelProperty(value = "变动类型(1-消费,2-返佣,3-拉新,4-每日分享,5-每日签到,6-使用时长, 7-注册积分, 8-门店业绩," + "9-门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人)") "9-门店返佣,14-下级门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人)") @TableField("type") private Integer type; ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/enums/PointChangeType.java
File was renamed from ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java @@ -1,4 +1,4 @@ package com.ruoyi.account.enums; package com.ruoyi.other.api.enums; import lombok.Getter; @@ -14,6 +14,7 @@ REGISTER(7, "注册积分"), SHOP_ACHIEVEMENT(8, "门店业绩"), SHOP_REBATE(9, "门店返佣"), JUNIOR_SHOP_REBATE(14, "下级门店返佣"), TECHNICIAN_ACHIEVEMENT(10, "技师业绩"), EXCHANGE_GOODS(11, "兑换商品"), OTHER_GIFT(12, "他人赠送"), ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/enums/WithdrawalAuditStatus.java
File was renamed from ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java @@ -1,4 +1,4 @@ package com.ruoyi.account.enums; package com.ruoyi.other.api.enums; import lombok.Getter; ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserPoint; import com.ruoyi.account.enums.PointChangeType; import com.ruoyi.other.api.enums.PointChangeType; import com.ruoyi.account.mapper.UserPointMapper; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.PointSettingService; @@ -19,7 +19,6 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.PhoneNumberValidator; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.PointSetting; import com.ruoyi.other.api.domain.Shop; ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java
@@ -1,7 +1,7 @@ package com.ruoyi.account.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.account.enums.WithdrawalAuditStatus; import com.ruoyi.other.api.enums.WithdrawalAuditStatus; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.WithdrawalRequests; import com.ruoyi.account.service.AppUserService; ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java
@@ -1,7 +1,9 @@ package com.ruoyi.other.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.other.api.domain.ShopPoint; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -15,6 +17,9 @@ */ public interface ShopPointMapper extends BaseMapper<ShopPoint> { List<ShopPoint> findLatestChangeByType(ShopPoint shopPoint); List<ShopPoint> selectShopPointList(@Param("shopPoint") ShopPoint shopPoint); IPage<ShopPoint> queryShpointPage(@Param("page") IPage<ShopPoint> page,@Param("shopPoint") ShopPoint shopPoint); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
@@ -1,22 +1,16 @@ 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.api.enums.PointChangeType; import com.ruoyi.other.mapper.ShopPointMapper; 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.Map; import java.util.stream.Collectors; /** @@ -29,62 +23,28 @@ */ @Service public class ShopPointServiceImpl extends ServiceImpl<ShopPointMapper, ShopPoint> implements ShopPointService { @Resource private ShopPointMapper shopPointMapper; @Resource private ShopService shopService; @Override public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) { String shopName = shopPoint.getShopName(); String phone = shopPoint.getPhone(); String shopLeaderName = shopPoint.getShopLeaderName(); 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()); if (CollectionUtils.isEmpty(shopIds)) { return new ShopPointStatistics(); } shopPoint.setShopIds(shopIds); List<ShopPoint> shopPoints = this.baseMapper.selectShopPointList(shopPoint); Map<Integer, Integer> shopPointMap = shopPoints.stream() .collect(Collectors.groupingBy( ShopPoint::getType, Collectors.summingInt(ShopPoint::getVariablePoint) )); ShopPointStatistics shopPointStatistics = new ShopPointStatistics(); 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()); int sPoint = shopPointMap.getOrDefault(PointChangeType.SHOP_ACHIEVEMENT.getCode(), 0); int shopCommissionPoint = shopPointMap.getOrDefault(PointChangeType.SHOP_REBATE.getCode(), 0); int subShopCommissionPoint = shopPointMap.getOrDefault(PointChangeType.JUNIOR_SHOP_REBATE.getCode(), 0); shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint); shopPointStatistics.setShopPoint(sPoint); shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint); 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()); } IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); shopPointStatistics.setShopPointIPage(shopPointIPage); return shopPointStatistics; } } ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
@@ -2,47 +2,41 @@ <!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"> <sql id="ShopPointList"> SELECT id, shop_id, type, historical_point, variable_point, create_time, create_user_id, object_id ts.`name`, ts.shop_manager, ts.phone, tsp.type, tsp.create_time, tsp.variable_point FROM ( SELECT id, shop_id, type, historical_point, variable_point, create_time, create_user_id, object_id, ROW_NUMBER() OVER ( PARTITION BY type,create_user_id ORDER BY create_time DESC ) AS rn FROM t_shop_point t_shop_point tsp LEFT JOIN t_shop ts ON tsp.shop_id = ts.id <where> <if test="shopPoint.shopName != null and shopPoint.shopName != ''"> AND ts.`name` LIKE concat('%',#{shopPoint.shopName},'%') </if> <if test="shopPoint.shopLeaderName != null and shopPoint.shopLeaderName != ''"> AND ts.shop_manager LIKE concat('%',#{shopPoint.shopLeaderName},'%') </if> <if test="shopPoint.phone != null and shopPoint.phone != ''"> AND ts.phone LIKE concat('%',#{shopPoint.phone},'%') </if> <if test="shopPoint.type != null"> AND tsp.type = #{shopPoint.type} </if> <if test="shopPoint.startTime !=null and shopPoint.endTime !=null"> AND tsp.create_time BETWEEN #{shopPoint.startTime} AND #{shopPoint.endTime} </if> <where> <if test="shopIds != null and shopIds.size() > 0"> AND shop_id IN <foreach collection="shopIds" item="shopId" open="(" close=")" separator=","> #{shopId} </foreach> </if> <if test="type != null"> AND `type` = #{type} </if> <if test="startTime != null and endTime != null"> AND create_time BETWEEN #{startTime} AND #{endTime} </if> </where> ) AS subquery WHERE rn = 1 </where> </sql> <select id="selectShopPointList" resultType="com.ruoyi.other.api.domain.ShopPoint"> <include refid="ShopPointList"/> </select> <select id="queryShpointPage" resultType="com.ruoyi.other.api.domain.ShopPoint"> <include refid="ShopPointList"/> </select> </mapper>