puzhibing
2024-12-18 543e0a9c357e9354cd47eba36e8a2e6b9582ecd0
Merge remote-tracking branch 'origin/master'
8个文件已修改
212 ■■■■■ 已修改文件
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalanceChangeRecordMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/BalanceChangeRecordMapper.xml 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalanceChangeRecordMapper.java
@@ -4,12 +4,17 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.model.BalanceChangeRecord;
import com.ruoyi.account.api.model.UserPoint;
import com.ruoyi.account.dto.BalanceQuery;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BalanceChangeRecordMapper extends BaseMapper<BalanceChangeRecord> {
    IPage<BalanceChangeRecord> pageList(@Param("page") Page<BalanceChangeRecord> page,@Param("agentQuery") BalanceQuery agentQuery);
    IPage<BalanceChangeRecord> queryCommissionStatistics(@Param("page") Page<BalanceChangeRecord> page,
                                                         @Param("changeRecord") BalanceChangeRecord changeRecord);
    List<UserPoint> findLatestChangeByType(BalanceChangeRecord balanceChangeRecord);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.account.api.model.UserPoint;
import java.util.List;
@@ -17,6 +18,5 @@
    List<UserPoint> findLatestUserPointByTypeForUser(Long userId);
    List<UserPoint> findLatestChangeByType(UserPoint userPoint);
    IPage<UserPoint> queryUserPointPage(IPage<UserPoint> page, UserPoint userPoint);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
@@ -38,6 +38,7 @@
    @Override
    public CommissionStatistics commissionStatistics(Page<BalanceChangeRecord> page, BalanceChangeRecord balanceChangeRecord) {
        IPage<BalanceChangeRecord> balanceChangeRecordIPage = this.baseMapper.queryCommissionStatistics(page, balanceChangeRecord);
//        return new CommissionStatistics(totalCommission, changeRecordPage);
        return null;
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -163,79 +163,12 @@
    @Override
    public UserPointStatistics getStatistics(UserPoint userPoint) {
        try {
            if (StringUtils.isNotEmpty(userPoint.getUserName()) && StringUtils.isNotEmpty(userPoint.getPhone())) {
                List<Long> userIds = appUserService.listObjs(new LambdaQueryWrapper<AppUser>()
                                .select(AppUser::getId)
                                .like(AppUser::getName, userPoint.getUserName())
                                .like(AppUser::getPhone, userPoint.getPhone()))
                        .stream()
                        .map(appUserId -> (Long) appUserId)
                        .collect(Collectors.toList());
                userPoint.setUserIds(userIds);
            }
            List<UserPoint> userPointList = userPointMapper.findLatestChangeByType(userPoint);
            Map<Integer, Integer> userBalanceMap = userPointList.stream()
                    .collect(Collectors.groupingBy(
                            UserPoint::getType,
                            Collectors.summingInt(UserPoint::getBalance)
                    ));
            int consumePoint = userBalanceMap.getOrDefault(PointChangeType.CONSUME.getCode(), 0);
            int sharePoint = userBalanceMap.getOrDefault(PointChangeType.COMMISSION_RETURN.getCode(), 0);
            int pullNewPoint = userBalanceMap.getOrDefault(PointChangeType.NEW_USER_REFERRAL.getCode(), 0);
            int registerPoint = userBalanceMap.getOrDefault(PointChangeType.REGISTRATION.getCode(), 0);
            int workPoint = userBalanceMap.getOrDefault(PointChangeType.WORK_PERFORMANCE.getCode(), 0);
            int shopAchievementPoint = userBalanceMap.getOrDefault(PointChangeType.TECHNICIAN_PERFORMANCE.getCode(), 0);
            int exchangeGoodsPoint = userBalanceMap.getOrDefault(PointChangeType.EXCHANGE_GOODS.getCode(), 0);
            int storeAchievementPoint = userBalanceMap.getOrDefault(PointChangeType.STORE_PERFORMANCE.getCode(), 0);
            int storeCommissionPoint = userBalanceMap.getOrDefault(PointChangeType.STORE_COMMISSION_RETURN.getCode(), 0);
            int transferPoint = userBalanceMap.getOrDefault(PointChangeType.TRANSFER_POINTS.getCode(), 0);
            int totalPoint = consumePoint + sharePoint + pullNewPoint + registerPoint + workPoint + shopAchievementPoint + exchangeGoodsPoint + storeAchievementPoint + storeCommissionPoint + transferPoint;
            UserPointStatistics userPointStatistics = new UserPointStatistics();
            userPointStatistics.setTotalPoint(totalPoint);
            userPointStatistics.setConsumePoint(consumePoint);
            userPointStatistics.setSharePoint(sharePoint);
            userPointStatistics.setPullNewPoint(pullNewPoint);
            userPointStatistics.setRegisterPoint(registerPoint);
            userPointStatistics.setWorkPoint(workPoint);
            userPointStatistics.setShopAchievementPoint(shopAchievementPoint);
            return userPointStatistics;
        } catch (Exception e) {
            // 记录异常日志
            log.error("获取用户点统计信息时出错", e);
            throw new RuntimeException("获取用户点统计信息时出错", e);
        }
        return null;
    }
    @Override
    public IPage<UserPoint> getUserPointPage(Page<UserPoint> page, UserPoint userPoint) {
        List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>()
                .eq(AppUser::getPhone, userPoint.getPhone())
                .like(AppUser::getName, userPoint.getUserName()));
        if (appUserList.isEmpty()){
            return page;
        }
        List<Long> userIds = appUserList.stream().map(AppUser::getId).collect(Collectors.toList());
        Page<UserPoint> userPointPage = page(page, new LambdaQueryWrapper<UserPoint>()
                .in(UserPoint::getAppUserId, userIds)
                .eq(userPoint.getType() != null, UserPoint::getType, userPoint.getType())
                .between( userPoint.getStartTime()!= null && userPoint.getEndTime() !=null,UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime())
                .orderByDesc(UserPoint::getCreateTime));
        userPointPage.getRecords().forEach(userPoint1 -> appUserList.stream()
                .filter(appUser -> appUser.getId().equals(userPoint1.getAppUserId()))
                .findFirst().ifPresent(appUser -> {
                    userPoint1.setUserName(appUser.getName());
                    userPoint1.setPhone(appUser.getPhone());
                }));
        return userPointPage;
        return this.baseMapper.queryUserPointPage(page, userPoint);
    }
}
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/BalanceChangeRecordMapper.xml
@@ -44,4 +44,48 @@
            </if>
        </where>
    </select>
    <select id="findLatestChangeByType" resultType="com.ruoyi.account.api.model.UserPoint">
        SELECT
            id,
            app_user_id,
            order_id,
            change_type,
            before_amount,
            change_amount,
            after_amount,
            del_flag,
            create_time
        FROM
            (
                SELECT
                    id,
                    app_user_id,
                    order_id,
                    change_type,
                    before_amount,
                    change_amount,
                    after_amount,
                    del_flag,
                    create_time,
                    ROW_NUMBER() OVER ( PARTITION BY change_type, app_user_id ORDER BY create_time DESC ) rn
                FROM
                    t_balance_change_record
        <where>
            <if test="changeRecord.userName != null and changeRecord.userName != ''">
                and tau.name like concat('%',#{changeRecord.userName},'%')
            </if>
            <if test="changeRecord.userPhone != null and changeRecord.userPhone != ''">
                and tau.phone like concat('%',#{changeRecord.userPhone},'%')
            </if>
            <if test="changeRecord.changeType != null">
                and tcr.change_type = #{changeRecord.changeType}
            </if>
            <if test="changeRecord.startTime != null and changeRecord.endTime != null">
                and DATE(tcr.create_time) between  #{changeRecord.startTime} and #{changeRecord.endTime}
            </if>
        </where>
            ) AS subquery
        WHERE
            rn = 1
    </select>
</mapper>
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml
@@ -27,46 +27,30 @@
        WHERE
            t1.app_user_id = #{userId}
    </select>
    <select id="findLatestChangeByType" resultType="com.ruoyi.account.api.model.UserPoint">
    <select id="queryUserPointPage" resultType="com.ruoyi.account.api.model.UserPoint">
        SELECT
            id,
            type,
            historical_point,
            variable_point,
            balance,
            create_time,
            app_user_id,
            object_id
        FROM (
                 SELECT
                     id,
                     type,
                     historical_point,
                     variable_point,
                     balance,
                     create_time,
                     app_user_id,
                     object_id,
                     ROW_NUMBER() OVER (PARTITION BY `type`,app_user_id ORDER BY create_time DESC) AS rn
                 FROM
                     t_user_point
                 <where>
                         <if test="startTime != null and endTime != null">
                             create_time BETWEEN #{startTime} AND #{endTime}
                         </if>
                         <if test="type != null">
                             AND `type` = #{type}
                         </if>
                         <if test="userIds != null and userIds.size !=0">
                             AND app_user_id IN
                             <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
                                 #{item}
                             </foreach>
                         </if>
                 </where>
        ) AS subquery
        WHERE
            rn = 1
            tau.`name` userName,
            tau.phone,
            tup.type,
            tup.create_time,
            tup.variable_point
        FROM
            t_user_point tup
                LEFT JOIN t_app_user tau ON tup.app_user_id = tau.id
        <where>
            <if test="userName != null and userName != ''">
                AND tau.`name` LIKE concat('%',#{userName},'%')
            </if>
            <if test="phone != null and phone != ''">
                AND tau.phone LIKE concat('%',#{phone},'%')
            </if>
            <if test="type != null and type != ''">
                AND tup.type = #{type}
            </if>
            <if test="startTime != null and endTime != null">
                AND tup.create_time BETWEEN #{startTime} AND #{endTime}
            </if>
        </where>
    </select>
</mapper>
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
@@ -127,6 +127,7 @@
        couponInfo.setShelfStatus(0);
        List<String> goodsNameList = couponInfo.getGoodsNameList();
        couponInfo.setGoodsNameJson(JSON.toJSONString(goodsNameList));
        couponInfo.setShelfStatus(1);
        couponInfoService.save(couponInfo);
        return R.ok();
    }
@@ -187,6 +188,7 @@
    @GetMapping("/getReceiveRecord")
    public R<IPage<UserCoupon>> getReceiveRecord(@ApiParam("页码") @RequestParam Integer pageNum, @ApiParam("大小") Integer pageSize,UserCoupon userCoupon) {
        // TODO 待完善
        return null;
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
@@ -101,18 +102,20 @@
     */
    @GetMapping("/list")
    @ApiOperation(value = "评论列表", tags = {"管理后台-商品管理-评价管理"})
    public R<List<GoodsEvaluate>> list(GoodsEvaluate goodsEvaluate){
        List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery()
                .like(StringUtils.isNotEmpty(goodsEvaluate.getGoodsName()),GoodsEvaluate::getGoodsName, goodsEvaluate.getComment())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getUserName()),GoodsEvaluate::getUserName, goodsEvaluate.getUserName())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getPhone()),GoodsEvaluate::getPhone, goodsEvaluate.getPhone())
                .eq(goodsEvaluate.getStatus()!=null,GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
                .orderByDesc(GoodsEvaluate::getCreateTime)
                .list();
    public R<Page<GoodsEvaluate>> list(@ApiParam("页码") @RequestParam Integer pageNum,
                                       @ApiParam("每一页数据大小") Integer pageSize,
                                       GoodsEvaluate goodsEvaluate){
        Page<GoodsEvaluate> page = goodsEvaluateService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsEvaluate>()
                .like(StringUtils.isNotEmpty(goodsEvaluate.getGoodsName()), GoodsEvaluate::getGoodsName, goodsEvaluate.getComment())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getUserName()), GoodsEvaluate::getUserName, goodsEvaluate.getUserName())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getPhone()), GoodsEvaluate::getPhone, goodsEvaluate.getPhone())
                .eq(goodsEvaluate.getStatus() != null, GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
                .orderByDesc(GoodsEvaluate::getCreateTime));
        list.forEach(this::buildDetail);
        return R.ok(list);
        page.getRecords().forEach(this::buildDetail);
        return R.ok(page);
    }
    private void buildDetail(GoodsEvaluate item) {