ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java
@@ -86,5 +86,9 @@ @ApiModelProperty(value = "用户电话") @TableField(exist = false) private String userPhone; @ApiModelProperty(value = "会员信息") @TableField(exist = false) private VipSettingDto vipSettingDto; } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
@@ -179,11 +179,23 @@ @TableField("total_register_point") private Integer totalRegisterPoint; @ApiModelProperty(value = "做工积分总数") @TableField("total_work_point") private Integer totalWorkPoint; // @ApiModelProperty(value = "做工积分总数") // @TableField("total_work_point") // private Integer totalWorkPoint; @ApiModelProperty(value = "业绩积分总数") @ApiModelProperty(value = "每日分享积分") @TableField("total_share_point") private Integer totalSharePoint; @ApiModelProperty(value = "每日签到积分") @TableField("total_sign_point") private Integer totalSignPoint; @ApiModelProperty(value = "使用时长积分") @TableField("total_hour_point") private Integer totalHourPoint; @ApiModelProperty(value = "技师业绩积分总数") @TableField("total_performance_point") private Integer totalPerformancePoint; ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java
@@ -37,7 +37,8 @@ @TableId("id") private Long id; @ApiModelProperty(value = "变动类型(1=消费积分,2=返佣积分,3=拉新人积分,4=兑换商品 5 = 门店业绩积分 6 =门店返佣积分7=技师业绩积分8 =转赠积分 9 =做工积分 10 =注册积分)") @ApiModelProperty(value = "变动类型(1-消费,2-返佣,3-拉新,4-每日分享,5-每日签到,6-使用时长, 7-注册积分, 8-门店业绩," + "9-门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人)") @TableField("type") private Integer type; ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/VipSettingDto.java
New file @@ -0,0 +1,150 @@ package com.ruoyi.account.api.model; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; /** * <p> * * </p> * * @author luodangjia * @since 2024-11-20 */ @Data @EqualsAndHashCode(callSuper = false) @TableName("t_vip_setting") @ApiModel(value="VipSetting对象", description="") public class VipSettingDto implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "1-7对应会员") @TableId("id") private Integer id; @ApiModelProperty(value = "会员名称") @TableField("vip_name") private String vipName; @ApiModelProperty(value = "会员专属权益") @TableField("vip_info") private String vipInfo; @ApiModelProperty(value = "1级会员专用 自动解绑推广人天数: 达到设置天数未成为黄金会员自动解绑推广人") @TableField("vip_cancel_day") private Integer vipCancelDay; @ApiModelProperty(value = "1级会员专用 可更换绑定人天数:用户在达到设置的天数未下单商品,可以更换绑定人") @TableField("vip_change_day") private Integer vipChangeDay; @ApiModelProperty(value = "钱包提现权限:1开0关") @TableField("vip_withdrawal_role") private Integer vipWithdrawalRole; @ApiModelProperty(value = "钱包提现权限:1开0关") @TableField("vip_agent_level_up_role") private Integer vipAgentLevelUpRole; @ApiModelProperty(value = "最低提现门槛") @TableField("vip_withdrawal_min_amount") private BigDecimal vipWithdrawalMinAmount; @ApiModelProperty(value = "提现手续费") @TableField("vip_withdrawal_fee") private BigDecimal vipWithdrawalFee; @ApiModelProperty(value = "积分转赠权限 1开0关") @TableField("vip_gift_role") private Integer vipGiftRole; @ApiModelProperty(value = "达成会员等级所需消费积分数量") @TableField("vip_level_up_shop") private Integer vipLevelUpShop; @ApiModelProperty(value = "通过消费积分达成会员等级的开关 1开0关") @TableField("vip_level_up_shop_role") private Integer vipLevelUpShopRole; @ApiModelProperty(value = "达成会员等级所需的返佣积分数量") @TableField("vip_level_up_share") private Integer vipLevelUpShare; @ApiModelProperty(value = "通过返佣积分达成会员等级的开关 1开0关") @TableField("vip_level_up_share_role") private Integer vipLevelUpShareRole; @ApiModelProperty(value = "达成会员等级所需的直推人数(包括钻石和代理)") @TableField("vip_direct_num") private Integer vipDirectNum; @ApiModelProperty(value = "达成会员等级所需的团队数量") @TableField("vip_team_num") private Integer vipTeamNum; @ApiModelProperty(value = "通过直推用户或团队数量的方式达成会员等级的开关 1开0关") @TableField("vip_level_up_num_role") private Integer vipLevelUpNumRole; @ApiModelProperty(value = "达成会员等级所需准代理数(达成总代和合伙人用到)") @TableField("vip_direct_vip_num") private Integer vipDirectVipNum; @ApiModelProperty(value = "达成会员等级所需总代数量(达成合伙人用到)") @TableField("vip_team_vip_num") private Integer vipTeamVipNum; @ApiModelProperty(value = "达成会员等级所需开店数量") @TableField("vip_open_shop_num") private Integer vipOpenShopNum; @ApiModelProperty(value = "消费积分保级周期(天)") @TableField("keep_buy_day") private Integer keepBuyDay; @ApiModelProperty(value = "消费积分保级的积分阈值(分))") @TableField("keep_buy_point") private Integer keepBuyPoint; @ApiModelProperty(value = "返佣积分保的周期(天)") @TableField("keep_share_day") private Integer keepShareDay; @ApiModelProperty(value = "返佣积分保级的积分阈值(分)") @TableField("keep_share_point") private Integer keepSharePoint; @ApiModelProperty(value = "门店业绩积分保级的周期(天)") @TableField("keep_shop_day") private Integer keepShopDay; @ApiModelProperty(value = "门店业绩积分保级的积分阈值(分)") @TableField("keep_shop_point") private Integer keepShopPoint; @ApiModelProperty(value = "会员等级是否必须达到代理: 0-否 1-是") @TableField("vip_level_up_proxy_role") private Integer vipLevelUpProxyRole; @ApiModelProperty(value = "指定会员升级商品") @TableField("good_ids") private String goodIds; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java
@@ -150,4 +150,5 @@ private List<Goods> goodsList; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
@@ -3,17 +3,19 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.dto.AgentQuery; import com.ruoyi.account.api.model.VipSettingDto; import com.ruoyi.account.service.AgentApplicationService; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserChangeLogService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.api.feignClient.VipSettingClient; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.web.bind.annotation.*; @@ -49,11 +51,17 @@ return R.ok(agentApplicationService.pageList(agentQuery)); } @Resource private VipSettingClient vipSettingClient; @GetMapping("/detail") @ApiOperation(value = "会员申请详情", tags = {"会员中心-小程序"}) public R<AgentApplication> detail(@RequestParam Long id) { return R.ok(agentApplicationService.getById(id)); R<VipSetting> vipSetting = vipSettingClient.getVipSetting(id.intValue()); VipSettingDto vipSettingDto = new VipSettingDto(); BeanUtils.copyProperties(vipSetting.getData(),vipSettingDto); AgentApplication byId = agentApplicationService.getById(id); byId.setVipSettingDto(vipSettingDto); return R.ok(byId); } @Resource private UserChangeLogService userChangeLogService; ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -34,6 +34,7 @@ import javax.annotation.Resource; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -564,6 +565,32 @@ //消费总金额 return R.ok(byId); } @Resource private UserChangeLogService userChangeLogService; @GetMapping("/change/vip") @ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"}) public R<Page<AppUser>> changevip(Long id,Integer vipId) { AppUser byId = appUserService.getById(id); UserChangeLog userChangeLog = new UserChangeLog(); userChangeLog.setCreateTime(LocalDateTime.now()); userChangeLog.setAppUserId(byId.getId()); userChangeLog.setBeforeVipId(byId.getVipId()); userChangeLog.setAfterVipId(vipId); if (userChangeLog.getBeforeVipId()>userChangeLog.getAfterVipId()) { userChangeLog.setChangeType(0); }else { userChangeLog.setChangeType(1); } userChangeLogService.save(userChangeLog); byId.setVipId(vipId); appUserService.updateById(byId); return R.ok(); } @GetMapping("/bottom") @ApiOperation(value = "用户列表-绑定下级列表", tags = {"管理后台"}) public R<Page<AppUser>> bottom(Long id,Integer pageNum,Integer pageSize) ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java
@@ -4,17 +4,20 @@ @Getter public enum PointChangeType { CONSUME(1, "消费积分"), COMMISSION_RETURN(2, "返佣积分"), NEW_USER_REFERRAL(3, "拉新人积分"), EXCHANGE_GOODS(4, "兑换商品"), STORE_PERFORMANCE(5, "门店业绩积分"), STORE_COMMISSION_RETURN(6, "门店返佣积分"), TECHNICIAN_PERFORMANCE(7, "技师业绩积分"), TRANSFER_POINTS(8, "转赠积分"), WORK_PERFORMANCE(9, "做工积分"), REGISTRATION(10, "注册积分"); // 1-消费,2-返佣,3-拉新,4-每日分享,5-每日签到,6-使用时长, 7-注册积分, 8-门店业绩,9-门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人 CONSUME(1, "消费"), REBATE(2, "返佣"), PULL_NEW(3, "拉新"), SHARE(4, "每日分享"), SIGN_IN(5, "每日签到"), USE_TIME(6, "使用时长"), REGISTER(7, "注册积分"), SHOP_ACHIEVEMENT(8, "门店业绩"), SHOP_REBATE(9, "门店返佣"), TECHNICIAN_ACHIEVEMENT(10, "技师业绩"), EXCHANGE_GOODS(11, "兑换商品"), OTHER_GIFT(12, "他人赠送"), GIFT(13, "赠与他人"); private final int code; private final String description; 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,7 +1,9 @@ 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 org.apache.ibatis.annotations.Param; import java.util.List; @@ -17,6 +19,7 @@ List<UserPoint> findLatestUserPointByTypeForUser(Long userId); List<UserPoint> findLatestChangeByType(UserPoint userPoint); IPage<UserPoint> queryUserPointPage(@Param("page") IPage<UserPoint> page,@Param("userPoint") UserPoint userPoint); List<UserPoint> selectUserPoint(@Param("userPoint") 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
@@ -16,12 +16,15 @@ import com.ruoyi.account.vo.UserPointDetailVO; import com.ruoyi.account.vo.UserPointStatistics; import com.ruoyi.account.vo.UserPointVO; 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; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.api.feignClient.ShopClient; import com.ruoyi.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -55,6 +58,8 @@ private PointSettingService pointSettingService; @Resource private UserPointMapper userPointMapper; @Resource private ShopClient shopClient; @Override public UserPointVO getUserPoint(Long userId) { @@ -69,9 +74,9 @@ userPointVO.setConsumePoint(appUser.getLavePoint()); userPointVO.setShopPoint(appUser.getShopPoint()); userPointVO.setSharePoint(appUser.getSharePoint()); userPointVO.setPullNewPoint(userBalanceMap.get(PointChangeType.NEW_USER_REFERRAL.getCode())); userPointVO.setShopAchievementPoint(userBalanceMap.get(PointChangeType.STORE_PERFORMANCE.getCode())); userPointVO.setShopSharePoint(userBalanceMap.get(PointChangeType.STORE_COMMISSION_RETURN.getCode())); userPointVO.setPullNewPoint(userBalanceMap.get(PointChangeType.PULL_NEW.getCode())); userPointVO.setShopAchievementPoint(userBalanceMap.get(PointChangeType.SHOP_ACHIEVEMENT.getCode())); userPointVO.setShopSharePoint(userBalanceMap.get(PointChangeType.SHOP_REBATE.getCode())); userPointVO.setGiftPoint(vipSetting.getVipGiftRole() == 1 && vipSetting.getId() == 1 ? 1 : 0); return userPointVO; } @@ -117,30 +122,15 @@ if (appUser == null) { throw new ServiceException("用户未找到"); } Integer totalPoint = appUser.getLavePoint(); PointSetting pointSetting = pointSettingService.getPointSettingByAppUserId(userid); if (pointSetting == null) { throw new ServiceException("积分设置未找到"); } Integer buyPointOpen = pointSetting.getBuyPointOpen(); // 可转赠积分总数 int adjustedPoint = getAdjustedPoint(pointSetting, appUser); UserPoint userPoint = new UserPoint(); userPoint.setAppUserId(userid); List<UserPoint> userPointList = userPointMapper.findLatestChangeByType(userPoint); Map<Integer, Integer> userBalanceMap = userPointList.stream() .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.CONSUME.getCode(), buyPointOpen == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.COMMISSION_RETURN.getCode(), pointSetting.getSharePointOpen() == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.STORE_COMMISSION_RETURN.getCode(), pointSetting.getShopSharePointOpen() == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.STORE_PERFORMANCE.getCode(), pointSetting.getShopPointOpen() == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.TECHNICIAN_PERFORMANCE.getCode(), pointSetting.getPersonPointOpen() == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.NEW_USER_REFERRAL.getCode(), pointSetting.getGetNewPointOpen() == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.REGISTRATION.getCode(), pointSetting.getGetRegisPointOpen() == 0); totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.WORK_PERFORMANCE.getCode(), pointSetting.getWorkPointOpen() == 0); if (point.compareTo(new BigDecimal(totalPoint)) > 0) { if (point.compareTo(new BigDecimal(adjustedPoint)) > 0) { throw new ServiceException("转赠积分不足"); } @@ -157,85 +147,107 @@ log.info("积分转赠完成,用户ID: {}, 新积分: {}", appUserForPhoe.getId(), appUserForPhoe.getLavePoint()); } private int getAdjustedPoint(Map<Integer, Integer> userBalanceMap, int pointTypeCode, boolean isOpen) { return isOpen ? 0 : Optional.ofNullable(userBalanceMap.get(pointTypeCode)).orElse(0); /** * 获取可转赠积分 * @param pointSetting 积分设置 * @param appUser 用户 * @return */ private int getAdjustedPoint(PointSetting pointSetting, AppUser appUser) { int transferPoint = 0; // 消费积分数 Integer buyPointGift = pointSetting.getBuyPointGift(); if (buyPointGift == 1){ transferPoint += appUser.getShopPoint(); } // 返佣积分 Integer sharePointOpen = pointSetting.getSharePointGift(); if (sharePointOpen == 1){ transferPoint += appUser.getSharePoint(); } // 门店返佣积分 Integer shopSharePointGift = pointSetting.getShopSharePointGift(); R<List<Shop>> shops = shopClient.getShopByUserIds(Collections.singletonList(appUser.getId())); List<Shop> shopList = shops.getData(); if (CollectionUtils.isEmpty(shopList)) { throw new ServiceException("未找到门店"); } if (shopSharePointGift == 1){ transferPoint += shopList.stream().mapToInt(Shop::getSharePoint).sum(); } // 门店业绩积分 Integer shopPointOpen = pointSetting.getShopPointGift(); if (shopPointOpen == 1){ transferPoint += shopList.stream().mapToInt(Shop::getShopPoint).sum(); } // 技师业绩积分 Integer personPointOpen = pointSetting.getPersonPointGift(); if (personPointOpen == 1){ transferPoint += appUser.getTotalPerformancePoint(); } // 拉新积分 Integer getNewPointOpen = pointSetting.getGetNewPointGift(); if (getNewPointOpen == 1){ transferPoint += appUser.getTotalInvitePoint(); } // 注册积分 Integer getRegisPointGift = pointSetting.getGetRegisPointGift(); if (getRegisPointGift == 1){ transferPoint += appUser.getTotalRegisterPoint(); } // 做工积分 Integer workPointOpen = pointSetting.getWorkPointGift(); if (workPointOpen == 1){ transferPoint += appUser.getTotalSharePoint() + appUser.getTotalSignPoint() + appUser.getTotalHourPoint(); } return transferPoint; } @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 = this.baseMapper.selectUserPoint(userPoint); Map<Integer, Integer> userBalanceMap = userPointList.stream() .collect(Collectors.groupingBy( UserPoint::getType, Collectors.summingInt(UserPoint::getVariablePoint) )); List<UserPoint> userPointList = userPointMapper.findLatestChangeByType(userPoint); int consumePoint = userBalanceMap.getOrDefault(PointChangeType.CONSUME.getCode(), 0); int sharePoint = userBalanceMap.getOrDefault(PointChangeType.REBATE.getCode(), 0); int pullNewPoint = userBalanceMap.getOrDefault(PointChangeType.PULL_NEW.getCode(), 0); int registerPoint = userBalanceMap.getOrDefault(PointChangeType.REGISTER.getCode(), 0); Map<Integer, Integer> userBalanceMap = userPointList.stream() .collect(Collectors.groupingBy( UserPoint::getType, Collectors.summingInt(UserPoint::getBalance) )); // 做工积分:签到积分 + 每日分享积分 + 每日签到积分 + 每日使用时长积分 int share = userBalanceMap.getOrDefault(PointChangeType.SHARE.getCode(), 0); int signIn = userBalanceMap.getOrDefault(PointChangeType.SIGN_IN.getCode(), 0); int useTime = userBalanceMap.getOrDefault(PointChangeType.USE_TIME.getCode(), 0); int workPoint = share + signIn + useTime; 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); } int shopAchievementPoint = userBalanceMap.getOrDefault(PointChangeType.TECHNICIAN_ACHIEVEMENT.getCode(), 0); //总积分 int totalPoint = consumePoint+sharePoint+pullNewPoint+registerPoint+workPoint+shopAchievementPoint; 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; } @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,38 @@ WHERE t1.app_user_id = #{userId} </select> <select id="findLatestChangeByType" resultType="com.ruoyi.account.api.model.UserPoint"> <sql id="userPointList"> 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="userPoint.userName != null and userPoint.userName != ''"> AND tau.`name` LIKE concat('%',#{userPoint.userName},'%') </if> <if test="userPoint.phone != null and userPoint.phone != ''"> AND tau.phone LIKE concat('%',#{userPoint.phone},'%') </if> <if test="userPoint.type != null and userPoint.type != ''"> AND tup.type = #{userPoint.type} </if> <if test="userPoint.startTime != null and userPoint.endTime != null"> AND tup.create_time BETWEEN #{userPoint.startTime} AND #{userPoint.endTime} </if> </where> </sql> <select id="queryUserPointPage" resultType="com.ruoyi.account.api.model.UserPoint"> <include refid="userPointList"/> </select> <select id="selectUserPoint" resultType="com.ruoyi.account.api.model.UserPoint"> <include refid="userPointList"/> </select> </mapper> ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -8,6 +8,7 @@ import com.ruoyi.account.api.model.UserAddress; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.enums.OrderStatus; @@ -19,9 +20,11 @@ import com.ruoyi.other.api.feignClient.BaseSettingClient; import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.*; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.constraints.NotBlank; import java.time.LocalDateTime; import java.util.List; @@ -223,17 +226,9 @@ @ResponseBody @GetMapping("/getOrderPageList") @ApiOperation(value = "获取订单列表", tags = {"管理后台-订单管理", "门店后台-订单管理"}) public TableDataInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList){ startPage(); List<OrderPageListVo> list = orderService.getOrderPageList(orderPageList); return getDataTable(list); } @ResponseBody @PutMapping("/confirmDelivery/{orderId}") @ApiOperation(value = "已发货操作", tags = {"管理后台-订单管理"}) public R confirmDelivery(@PathVariable("orderId") String orderId, String code){ @@ -241,14 +236,12 @@ } @ResponseBody @PutMapping("/cancelOrder/{orderId}") @ApiOperation(value = "取消订单操作", tags = {"管理后台-订单管理"}) public R cancelOrder(@PathVariable("orderId") Long orderId){ return orderService.cancelOrder(orderId); } @ResponseBody @PutMapping("/receivingOperation/{orderId}") @ApiOperation(value = "收货操作", tags = {"管理后台-订单管理"}) public R receivingOperation(@PathVariable("orderId") Long orderId){ @@ -256,7 +249,6 @@ } @ResponseBody @GetMapping("/getOrderInfo/{orderId}") @ApiOperation(value = "查询订单详情", tags = {"管理后台-订单管理"}) public R<OrderInfoVo> getOrderInfo(@PathVariable("orderId") Long orderId){ @@ -265,6 +257,10 @@ } @GetMapping("/getOrderPageList") // @ApiOperation(value = "获取订单列表", tags = {"管理后台-订单管理", "门店后台-订单管理"}) public R<PageInfo<OrderPageListVo>> getOrderPageList(OrderPageList orderPageList){ return R.ok(orderService.getOrderPageList(orderPageList)); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.model.Order; @@ -130,10 +131,8 @@ @ResponseBody @GetMapping("/getOrderRefundPassList") @ApiOperation(value = "获取售后列表数据", tags = {"管理后台-售后管理", "门店后台-售后管理"}) public TableDataInfo<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo){ startPage(); List<OrderRefundPassList> orderRefundPassList = refundPassService.getOrderRefundPassList(refundPassListVo); return getDataTable(orderRefundPassList); public R<PageInfo<OrderRefundPassList>> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo){ return R.ok(refundPassService.getOrderRefundPassList(refundPassListVo)); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
@@ -1,6 +1,7 @@ package com.ruoyi.order.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.vo.OrderPageList; import com.ruoyi.order.vo.OrderPageListVo; import com.ruoyi.order.vo.OrderVO; @@ -29,5 +30,5 @@ * @param orderPageList * @return */ List<OrderPageListVo> getOrderPageList(@Param("item") OrderPageList orderPageList); List<OrderPageListVo> getOrderPageList(PageInfo<OrderPageListVo> pageInfo, @Param("item") OrderPageList orderPageList); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/RefundPassMapper.java
@@ -1,6 +1,7 @@ package com.ruoyi.order.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.model.RefundPass; import com.ruoyi.order.vo.OrderRefundPassList; import org.apache.ibatis.annotations.Param; @@ -26,7 +27,7 @@ * @param status 售后状态 * @return */ List<OrderRefundPassList> getOrderRefundPassList(@Param("code") String code, @Param("appUserIds") List<Long> appUserIds, List<OrderRefundPassList> getOrderRefundPassList(PageInfo<OrderRefundPassList> pageInfo, @Param("code") String code, @Param("appUserIds") List<Long> appUserIds, @Param("shopId") Integer shopId, @Param("refundMethod") Integer refundMethod, @Param("status") Integer status); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.model.Order; import com.ruoyi.order.vo.*; import org.springframework.web.bind.annotation.PathVariable; @@ -31,7 +32,7 @@ * @param orderPageList * @return */ List<OrderPageListVo> getOrderPageList(OrderPageList orderPageList); PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList); /** ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/RefundPassService.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.model.RefundPass; import com.ruoyi.order.vo.ApplyRefundPass; import com.ruoyi.order.vo.OrderRefundPassList; @@ -34,7 +35,7 @@ * 管理后台获取售后管理列表数据 * @return */ List<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo); PageInfo<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo); /** ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.enums.OrderStatus; import com.ruoyi.order.mapper.OrderGoodMapper; @@ -262,7 +263,7 @@ * @return */ @Override public List<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) { public PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) { Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); if(2 == sysUser.getRoleType()){ @@ -293,14 +294,16 @@ } } List<OrderPageListVo> list = this.baseMapper.getOrderPageList(orderPageList); PageInfo<OrderPageListVo> pageInfo = new PageInfo(orderPageList.getPageCurr(), orderPageList.getPageSize()); List<OrderPageListVo> list = this.baseMapper.getOrderPageList(pageInfo, orderPageList); for (OrderPageListVo orderPageListVo : list) { Long appUserId = orderPageListVo.getAppUserId(); AppUser appUser = appUserClient.getAppUserById(appUserId); orderPageListVo.setUserName(appUser.getName()); orderPageListVo.setPhone(appUser.getPhone()); } return list; return pageInfo.setRecords(list); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
@@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.mapper.RefundPassMapper; import com.ruoyi.order.model.Order; @@ -107,7 +108,7 @@ * @return */ @Override public List<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo) { public PageInfo<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo) { Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); Integer shopId = null; @@ -127,13 +128,14 @@ List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); appUserIds.addAll(collect); } List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); PageInfo<OrderRefundPassList> pageInfo = new PageInfo(refundPassListVo.getPageCurr(), refundPassListVo.getPageSize()); List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); for (OrderRefundPassList refundPassList : orderRefundPassList) { AppUser appUser = appUserClient.getAppUserById(refundPassList.getAppUserId()); refundPassList.setUserName(appUser.getName()); refundPassList.setPhone(appUser.getPhone()); } return orderRefundPassList; return pageInfo.setRecords(orderRefundPassList); } 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) { ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsBargainPriceServiceImpl.java
@@ -101,6 +101,6 @@ @Override public IPage<GoodsBargainPrice> queryGoodsBargainPricePage(Page<GoodsBargainPrice> page, GoodsBargainPrice goodsBargainPrice) { return null; return this.baseMapper.queryGoodsBargainPricePage(page,goodsBargainPrice); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java
@@ -10,6 +10,7 @@ import com.ruoyi.other.service.ShopService; import com.ruoyi.other.vo.ShopCommissionStatisticsVO; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.List; ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopCommissionStatisticsVO.java
@@ -16,25 +16,25 @@ * 总金额 */ @ApiModelProperty(value = "总金额") private BigDecimal totalAmount; private BigDecimal totalAmount = BigDecimal.ZERO; /** * 分佣总金额 */ @ApiModelProperty(value = "分佣总金额") private BigDecimal totalCommission; private BigDecimal totalCommission = BigDecimal.ZERO; /** * 服务费总计 */ @ApiModelProperty(value = "服务费总计") private BigDecimal totalServiceCharge; private BigDecimal totalServiceCharge = BigDecimal.ZERO; /** * 下级门店分佣总金额 */ @ApiModelProperty(value = "下级门店分佣总金额") private BigDecimal totalSubordinateCommission; private BigDecimal totalSubordinateCommission = BigDecimal.ZERO; private IPage<ShopBalanceStatement> statementIPage; } ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml
@@ -15,20 +15,22 @@ object_id FROM ( SELECT id, shop_id, type, historical_balance, variable_amount, balance, 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_balance_statement SELECT id, shop_id, type, historical_balance, variable_amount, balance, 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_balance_statement ) AS subquery WHERE rn = 1 </select> <select id="queryShopBalanceStatementPage" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement"> SELECT