Merge remote-tracking branch 'origin/master'
1 文件已重命名
26个文件已修改
4个文件已删除
2个文件已添加
| | |
| | | @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; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | private Long orderId; |
| | | |
| | | @ApiModelProperty("类型:1充值2提现3红包4分佣5商城购物6订单取消回退") |
| | | @Excel(name = "变更类型", readConverterExp = "1=充值,2=提现,3=红包,4=分佣,5=商城购物,6=订单取消回退") |
| | | private Integer changeType; |
| | | |
| | | @ApiModelProperty("变更前金额") |
| | | private BigDecimal beforeAmount; |
| | | |
| | | @ApiModelProperty("变更金额") |
| | | @Excel(name = "变更数量") |
| | | private BigDecimal changeAmount; |
| | | |
| | | @ApiModelProperty("变更后金额") |
| | |
| | | private Integer delFlag; |
| | | |
| | | @ApiModelProperty("添加时间") |
| | | @Excel(name = "变更时间",dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("消费用户名称") |
| | | @Excel(name = "用户名称") |
| | | private String userName; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("消费用户手机号") |
| | | @Excel(name = "联系电话") |
| | | private String userPhone; |
| | | |
| | | @TableField(exist = false) |
| | |
| | | @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-门店返佣,14-下级门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人)") |
| | | @TableField("type") |
| | | private Integer type; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | |
| | | @ApiModelProperty(value = "变动类型(1=门店业绩,2=门店返佣,3=下级门店返佣)") |
| | | @TableField("type") |
| | | @Excel(name = "变动类型", readConverterExp = "1=门店业绩,2=门店返佣,3=下级门店返佣") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty(value = "历史余额") |
| | |
| | | |
| | | @ApiModelProperty(value = "变动金额") |
| | | @TableField("variable_point") |
| | | @Excel(name = "变动金额") |
| | | private Integer variablePoint; |
| | | |
| | | @ApiModelProperty(value = "变动时间") |
| | | @TableField("create_time") |
| | | @Excel(name = "变动时间") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "变动用户id") |
| | |
| | | |
| | | @ApiModelProperty(value = "门店名称") |
| | | @TableField(exist = false) |
| | | @Excel(name = "门店名称") |
| | | private String shopName; |
| | | |
| | | @ApiModelProperty(value = "店长姓名") |
| | | @TableField(exist = false) |
| | | @Excel(name = "店长姓名") |
| | | private String shopLeaderName; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | @TableField(exist = false) |
| | | @Excel(name = "联系电话") |
| | | private String phone; |
| | | |
| | | @TableField(exist = false) |
New file |
| | |
| | | package com.ruoyi.other.api.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum PointChangeType { |
| | | // 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, "门店返佣"), |
| | | JUNIOR_SHOP_REBATE(14, "下级门店返佣"), |
| | | TECHNICIAN_ACHIEVEMENT(10, "技师业绩"), |
| | | EXCHANGE_GOODS(11, "兑换商品"), |
| | | OTHER_GIFT(12, "他人赠送"), |
| | | GIFT(13, "赠与他人"); |
| | | private final int code; |
| | | private final String description; |
| | | |
| | | PointChangeType(int code, String description) { |
| | | this.code = code; |
| | | this.description = description; |
| | | } |
| | | |
| | | public static PointChangeType fromCode(int code) { |
| | | for (PointChangeType type : values()) { |
| | | if (type.getCode() == code) { |
| | | return type; |
| | | } |
| | | } |
| | | throw new IllegalArgumentException("Invalid code: " + code); |
| | | } |
| | | } |
File was renamed from ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java |
| | |
| | | package com.ruoyi.account.enums; |
| | | package com.ruoyi.other.api.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | |
| | | @ApiOperation(value = "个人信息-修改密码") |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| | | public AjaxResult updatePwd(String username,String oldPassword, String newPassword) |
| | | { |
| | | System.err.println(oldPassword); |
| | | System.err.println(newPassword); |
| | | String username = SecurityUtils.getUsername(); |
| | | // String username = SecurityUtils.getUsername(); |
| | | SysUser user = userService.selectUserByUserName(username); |
| | | String password = user.getPassword(); |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.BalanceChangeRecord; |
| | | import com.ruoyi.account.dto.BalanceQuery; |
| | | import com.ruoyi.account.excel.BalanceChangeRecordEX; |
| | | import com.ruoyi.account.service.BalanceChangeRecordService; |
| | | import com.ruoyi.account.vo.CommissionStatistics; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | CommissionStatistics commissionStatistics1 = balanceChangeRecordService.commissionStatistics(Page.of(1, Integer.MAX_VALUE), balanceChangeRecord); |
| | | IPage<BalanceChangeRecord> userPointPage = commissionStatistics1.getUserPointPage(); |
| | | List<BalanceChangeRecord> userPointList = userPointPage.getRecords(); |
| | | List<BalanceChangeRecordEX> userPointExList = new ArrayList<>(); |
| | | for (BalanceChangeRecord balanceChangeRecord1 : userPointList) { |
| | | BalanceChangeRecordEX balanceChangeRecordEX = new BalanceChangeRecordEX(); |
| | | balanceChangeRecordEX.setUserName(balanceChangeRecord1.getUserName()); |
| | | balanceChangeRecordEX.setPhone(balanceChangeRecord1.getUserPhone()); |
| | | balanceChangeRecordEX.setChangeTime(balanceChangeRecord1.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | balanceChangeRecordEX.setChangeNum(balanceChangeRecord1.getAfterAmount().toString()); |
| | | Integer type = balanceChangeRecord1.getChangeType(); |
| | | // 类型:1充值2提现3红包4分佣5商城购物6订单取消回退 |
| | | switch (type) { |
| | | case 1: |
| | | balanceChangeRecordEX.setType("充值"); |
| | | break; |
| | | case 2: |
| | | balanceChangeRecordEX.setType("提现"); |
| | | break; |
| | | case 3: |
| | | balanceChangeRecordEX.setType("红包"); |
| | | break; |
| | | case 4: |
| | | balanceChangeRecordEX.setType("分佣"); |
| | | break; |
| | | case 5: |
| | | balanceChangeRecordEX.setType("商城购物"); |
| | | break; |
| | | case 6: |
| | | balanceChangeRecordEX.setType("订单取消回退"); |
| | | break; |
| | | default: |
| | | balanceChangeRecordEX.setType("未知积分"); |
| | | } |
| | | userPointExList.add(balanceChangeRecordEX); |
| | | } |
| | | ExcelUtil<BalanceChangeRecordEX> util = new ExcelUtil<>(BalanceChangeRecordEX.class); |
| | | util.exportExcel(response, userPointExList, "用户分佣统计"); |
| | | ExcelUtil<BalanceChangeRecord> util = new ExcelUtil<>(BalanceChangeRecord.class); |
| | | util.exportExcel(response, userPointList, "用户分佣统计"); |
| | | } |
| | | |
| | | |
| | |
| | | public interface BalanceChangeRecordMapper extends BaseMapper<BalanceChangeRecord> { |
| | | IPage<BalanceChangeRecord> pageList(@Param("page") Page<BalanceChangeRecord> page,@Param("agentQuery") BalanceQuery agentQuery); |
| | | |
| | | |
| | | List<BalanceChangeRecord> selectBalanceChangeRecordList(@Param("changeRecord") BalanceChangeRecord balanceChangeRecord); |
| | | |
| | | IPage<BalanceChangeRecord> queryCommissionStatistics(@Param("page") Page<BalanceChangeRecord> page, |
| | | @Param("changeRecord") BalanceChangeRecord changeRecord); |
| | | |
| | | List<UserPoint> findLatestChangeByType(BalanceChangeRecord balanceChangeRecord); |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | List<UserPoint> findLatestUserPointByTypeForUser(Long userId); |
| | | |
| | | IPage<UserPoint> queryUserPointPage(IPage<UserPoint> page, UserPoint userPoint); |
| | | IPage<UserPoint> queryUserPointPage(@Param("page") IPage<UserPoint> page,@Param("userPoint") UserPoint userPoint); |
| | | |
| | | List<UserPoint> selectUserPoint(@Param("userPoint") UserPoint userPoint); |
| | | } |
| | |
| | | import com.ruoyi.account.service.BalanceChangeRecordService; |
| | | import com.ruoyi.account.vo.CommissionStatistics; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.other.api.domain.ShopPoint; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public CommissionStatistics commissionStatistics(Page<BalanceChangeRecord> page, BalanceChangeRecord balanceChangeRecord) { |
| | | List<BalanceChangeRecord> balanceChangeRecordList = this.baseMapper.selectBalanceChangeRecordList(balanceChangeRecord); |
| | | BigDecimal totalCommission = balanceChangeRecordList.stream() |
| | | .filter(item -> !(item.getChangeType().equals(2) && item.getChangeType().equals(5))) |
| | | .map(BalanceChangeRecord::getChangeAmount) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | .setScale(2, RoundingMode.HALF_UP); |
| | | |
| | | IPage<BalanceChangeRecord> balanceChangeRecordIPage = this.baseMapper.queryCommissionStatistics(page, balanceChangeRecord); |
| | | // return new CommissionStatistics(totalCommission, changeRecordPage); |
| | | return null; |
| | | return new CommissionStatistics(totalCommission, balanceChangeRecordIPage); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private PointSettingService pointSettingService; |
| | | @Resource |
| | | private UserPointMapper userPointMapper; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | |
| | | @Override |
| | | public UserPointVO getUserPoint(Long userId) { |
| | |
| | | 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; |
| | | } |
| | |
| | | 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.indLatestChangeByType(userPoint); |
| | | // TODO 完善 |
| | | List<UserPoint> userPointList = new ArrayList<>(); |
| | | 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("转赠积分不足"); |
| | | } |
| | | |
| | |
| | | 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) { |
| | | return null; |
| | | List<UserPoint> userPointList = this.baseMapper.selectUserPoint(userPoint); |
| | | Map<Integer, Integer> userBalanceMap = userPointList.stream() |
| | | .collect(Collectors.groupingBy( |
| | | UserPoint::getType, |
| | | Collectors.summingInt(UserPoint::getVariablePoint) |
| | | )); |
| | | |
| | | 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); |
| | | |
| | | // 做工积分:签到积分 + 每日分享积分 + 每日签到积分 + 每日使用时长积分 |
| | | 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 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; |
| | | } |
| | | |
| | | |
| | |
| | | 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; |
| | |
| | | |
| | | public CommissionStatistics() { |
| | | } |
| | | public CommissionStatistics(BigDecimal totalCommission, Page<BalanceChangeRecord> changeRecordPage) { |
| | | public CommissionStatistics(BigDecimal totalCommission, IPage<BalanceChangeRecord> changeRecordPage) { |
| | | this.totalCommission = totalCommission; |
| | | this.userPointPage = changeRecordPage; |
| | | } |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="queryCommissionStatistics" resultType="com.ruoyi.account.api.model.BalanceChangeRecord"> |
| | | |
| | | <sql id="balanceChangeRecordList"> |
| | | SELECT |
| | | tcr.*, |
| | | tau.`name` userName, |
| | | tau.phone userPhone |
| | | tau.phone userPhone, |
| | | tbcr.change_type, |
| | | tbcr.create_time, |
| | | tbcr.change_amount |
| | | FROM |
| | | t_balance_change_record tcr |
| | | LEFT JOIN t_app_user tau ON tcr.app_user_id = tau.id |
| | | t_balance_change_record tbcr |
| | | LEFT JOIN t_app_user tau ON tbcr.app_user_id = tau.id |
| | | <where> |
| | | <if test="changeRecord.userName != null and changeRecord.userName != ''"> |
| | | and tau.name like concat('%',#{changeRecord.userName},'%') |
| | |
| | | <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} |
| | | and DATE(tbcr.create_time) between #{changeRecord.startTime} and #{changeRecord.endTime} |
| | | </if> |
| | | </where> |
| | | </sql> |
| | | |
| | | <select id="selectBalanceChangeRecordList" resultType="com.ruoyi.account.api.model.BalanceChangeRecord"> |
| | | <include refid="balanceChangeRecordList"/> |
| | | </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 id="queryCommissionStatistics" resultType="com.ruoyi.account.api.model.BalanceChangeRecord"> |
| | | <include refid="balanceChangeRecordList"/> |
| | | </select> |
| | | </mapper> |
| | |
| | | WHERE |
| | | t1.app_user_id = #{userId} |
| | | </select> |
| | | <select id="queryUserPointPage" resultType="com.ruoyi.account.api.model.UserPoint"> |
| | | |
| | | <sql id="userPointList"> |
| | | SELECT |
| | | tau.`name` userName, |
| | | tau.phone, |
| | | tup.type, |
| | | tup.create_time, |
| | | tup.variable_point |
| | | 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 |
| | | 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 test="userPoint.userName != null and userPoint.userName != ''"> |
| | | AND tau.`name` LIKE concat('%',#{userPoint.userName},'%') |
| | | </if> |
| | | <if test="phone != null and phone != ''"> |
| | | AND tau.phone LIKE concat('%',#{phone},'%') |
| | | <if test="userPoint.phone != null and userPoint.phone != ''"> |
| | | AND tau.phone LIKE concat('%',#{userPoint.phone},'%') |
| | | </if> |
| | | <if test="type != null and type != ''"> |
| | | AND tup.type = #{type} |
| | | <if test="userPoint.type != null and userPoint.type != ''"> |
| | | AND tup.type = #{userPoint.type} |
| | | </if> |
| | | <if test="startTime != null and endTime != null"> |
| | | AND tup.create_time BETWEEN #{startTime} AND #{endTime} |
| | | <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> |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.other.api.domain.PointSetting; |
| | | import com.ruoyi.other.dto.PointSettingDto; |
| | | import com.ruoyi.other.service.PointSettingService; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | PointSetting pointSetting = pointSettingService.getById(id); |
| | | return R.ok(pointSetting); |
| | | } |
| | | @GetMapping("/search") |
| | | @ApiOperation(value = "积分配置查询", tags = {"后台"}) |
| | | public R<List<PointSetting>> search(@RequestParam Integer id) { |
| | | List<PointSetting> list = pointSettingService.list(); |
| | | return R.ok(list); |
| | | } |
| | | @PostMapping("/save") |
| | | @ApiOperation(value = "积分配置", tags = {"后台"}) |
| | | public R<PointSetting> save(@RequestBody PointSettingDto pointSettingDto) { |
| | | pointSettingService.remove(Wrappers.lambdaQuery()); |
| | | pointSettingService.saveBatch(pointSettingDto.getPointSettings()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | ShopCommissionStatisticsVO shopCommissionStatisticsVO = shopBalanceStatementService.shopCommissionStatistics(Page.of(pageNum, pageSize), shopBalanceStatement); |
| | | return R.ok(shopCommissionStatisticsVO); |
| | | } |
| | | @GetMapping("/commissionStatistics/list") |
| | | @ApiOperation(value = "门店余额明细", notes = "门店余额明细", tags = {"门店后台"}) |
| | | public R<ShopCommissionStatisticsVO> shopCommissionStatisticslist(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | ShopBalanceStatement shopBalanceStatement){ |
| | | ShopCommissionStatisticsVO shopCommissionStatisticsVO = shopBalanceStatementService.shopCommissionStatistics(Page.of(pageNum, pageSize), shopBalanceStatement); |
| | | return R.ok(shopCommissionStatisticsVO); |
| | | } |
| | | |
| | | /** |
| | | * 导出门店分佣统计 |
| | |
| | | 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.common.security.service.TokenService; |
| | | 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 javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class ShopPointController { |
| | | @Resource |
| | | private ShopPointService shopPointService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | /** |
| | |
| | | return R.ok(statistics); |
| | | } |
| | | |
| | | @GetMapping("/shop/statistics") |
| | | @ApiOperation(value = "门店积分统计", notes = "门店积分统计", tags = {"门店后台"}) |
| | | public R<ShopPointStatistics> shopstatistics(ShopPoint shopPoint) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | shopPoint.setShopId(objectId); |
| | | ShopPointStatistics statistics = shopPointService.statistics(Page.of(shopPoint.getPageNum(), shopPoint.getPageSize()), shopPoint); |
| | | return R.ok(statistics); |
| | | } |
| | | @GetMapping("/shop/statistics/list") |
| | | @ApiOperation(value = "门店积分统计列表", notes = "门店积分统计", tags = {"门店后台"}) |
| | | public R<Page<ShopPoint>> shopstatisticslist(ShopPoint shopPoint,Integer pageNum,Integer pageSize) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, objectId).eq(ShopPoint::getType, shopPoint.getType()) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | | * 导出门店积分统计 |
| | | */ |
| | |
| | | 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, "用户积分统计"); |
| | | } |
| | | ExcelUtil<ShopPoint> util = new ExcelUtil<>(ShopPoint.class); |
| | | util.exportExcel(response, shopPointIPage.getRecords(), "用户积分统计"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | |
| | | return R.ok(getDataTable(technicianService.getTechnicianListByShopId(shopId,name))); |
| | | } |
| | | |
| | | @GetMapping("/manage/list") |
| | | @ApiOperation(value = "技师列表", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> managelist(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@ApiParam("技师姓名") String name,@ApiParam("技师电话") String phone) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Page<Technician> page = technicianService.lambdaQuery().like(name != null, Technician::getName, name) |
| | | .like(phone != null, Technician::getPhone, phone) |
| | | .eq(Technician::getShopId, objectId) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | @PostMapping("/manage/addorupdate") |
| | | @ApiOperation(value = "添加编辑", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> add(@RequestBody Technician technician) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | technician.setShopId(objectId); |
| | | technicianService.saveOrUpdate(technician); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/manage/delete") |
| | | @ApiOperation(value = "删除", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> delete(@RequestParam Integer id) { |
| | | technicianService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/manage/changeStatus") |
| | | @ApiOperation(value = "上下架", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> changeStatus(@RequestParam Integer id,@RequestParam@ApiParam("状态(1=下架,2=上架)") Integer status) { |
| | | Technician byId = technicianService.getById(id); |
| | | byId.setStatus(status); |
| | | technicianService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | @GetMapping("/manage/changesubscri") |
| | | @ApiOperation(value = "修改预约状态", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> changesubscri(@RequestParam Integer id,@RequestParam@ApiParam("预约状态(1=可预约,2=不可预约)") Integer subscribeStatus) { |
| | | Technician byId = technicianService.getById(id); |
| | | byId.setSubscribeStatus(subscribeStatus); |
| | | technicianService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/getById") |
| | | @ApiOperation(value = "技师详情", tags = {"技师详情-小程序"}) |
| | | @ApiOperation(value = "技师详情", tags = {"技师详情-小程序","门店-技师列表"}) |
| | | public R<Technician> getById(@RequestParam("id") Integer id){ |
| | | Technician byId = technicianService.getById(id); |
| | | return R.ok(byId); |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.domain.TechnicianSubscribe; |
| | | import com.ruoyi.other.service.TechnicianSubscribeService; |
| | |
| | | public class TechnicianSubscribeController extends BaseController { |
| | | @Resource |
| | | private TechnicianSubscribeService technicianSubscribeService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | @GetMapping("/shop/list") |
| | | @ApiOperation(value = "预约列表", tags = {"门店-预约列表"}) |
| | | public TableDataInfo<TechnicianSubscribeVO> shoplist(@ApiParam(value = "状态") Integer status, |
| | | @ApiParam("电话")String phone, |
| | | @ApiParam("姓名")String name, |
| | | @ApiParam("服务方式:1=上门服务,2=到店服务")Integer serviceMode |
| | | ) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | startPage(); |
| | | List<TechnicianSubscribeVO> list = technicianSubscribeService |
| | | .getTechnicianSubscribeByUserAndShop1(Long.valueOf(objectId),status,phone,name,serviceMode); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 预约列表 |
| | |
| | | * 取消服务 |
| | | */ |
| | | @GetMapping("/cancel") |
| | | @ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理,小程序-个人中心-我的预约"}) |
| | | @ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理,小程序-个人中心-我的预约","门店-预约管理"}) |
| | | public R<Void> cancel(@ApiParam(value = "预约id") @RequestParam Long id) { |
| | | |
| | | TechnicianSubscribe subscribe = technicianSubscribeService.getOne(new LambdaQueryWrapper<TechnicianSubscribe>() |
New file |
| | |
| | | package com.ruoyi.other.dto; |
| | | |
| | | import com.ruoyi.other.api.domain.PointSetting; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class PointSettingDto { |
| | | private List<PointSetting> pointSettings; |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | */ |
| | | 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); |
| | | |
| | | |
| | | } |
| | |
| | | List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop( |
| | | @Param("shopId") Long shopId, |
| | | @Param("status") Integer status); |
| | | List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop1( |
| | | @Param("shopId") Long shopId, |
| | | @Param("status") Integer status,@Param("phone")String phone, |
| | | @Param("name")String name, |
| | | @Param("serviceMode")Integer serviceMode); |
| | | IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(@Param("page") Page<TechnicianSubscribe> page, @Param("userId") Long userId, |
| | | @Param("status") Integer status); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.other.api.domain.TechnicianSubscribe; |
| | | import com.ruoyi.other.vo.TechnicianSubscribeVO; |
| | | import io.swagger.annotations.ApiParam; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * 查询用于指定门店的相关预约记录 |
| | | */ |
| | | List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(Long shopId, Integer status); |
| | | List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop1(Long shopId, Integer status ,String phone, |
| | | String name, |
| | | Integer serviceMode); |
| | | |
| | | IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status); |
| | | |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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; |
| | | } |
| | | } |
| | |
| | | return technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(shopId,status); |
| | | } |
| | | @Override |
| | | public List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop1(Long shopId, Integer status ,String phone, |
| | | String name, |
| | | Integer serviceMode) { |
| | | return technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop1(shopId,status,phone,name,serviceMode); |
| | | } |
| | | @Override |
| | | public IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status) { |
| | | return technicianSubscribeMapper.getTechnicianSubscribeByUser(page, userId, status); |
| | | } |
| | |
| | | <!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` shopName, |
| | | ts.shop_manager shopLeaderName, |
| | | 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> |
| | |
| | | </if> |
| | | ORDER BY tts.create_time DESC |
| | | </select> |
| | | <select id="getTechnicianSubscribeByUserAndShop1" resultType="com.ruoyi.other.vo.TechnicianSubscribeVO"> |
| | | SELECT |
| | | CAST(tts.id AS CHAR) id, |
| | | tts.user_address, |
| | | ts.`name` shopName, |
| | | ts.address shopAddress, |
| | | tt.name technicianName, |
| | | ts.longitude, |
| | | ts.latitude, |
| | | tts.subscribe_time, |
| | | tts.service_mode, |
| | | tts.status |
| | | FROM |
| | | t_technician_subscribe tts |
| | | LEFT JOIN t_technician tt ON tts.technician_id = tt.id AND tt.del_flag = 0 |
| | | LEFT JOIN t_shop ts ON tt.shop_id = ts.id AND ts.del_flag = 0 |
| | | WHERE |
| | | ts.id = #{shopId} |
| | | AND tts.del_flag = 0 |
| | | <if test="status != null"> |
| | | AND tts.status = #{status} |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | AND tt.`name` LIKE concat('%', #{name}, '%') |
| | | </if> |
| | | <if test="phone != null and phone != ''"> |
| | | AND tt.`phone` LIKE concat('%', #{phone}, '%') |
| | | </if> |
| | | <if test="serviceMode != null"> |
| | | AND tts.service_mode = #{serviceMode} |
| | | </if> |
| | | |
| | | ORDER BY tts.create_time DESC |
| | | </select> |
| | | |
| | | <select id="getTechnicianSubscribeByUser" resultType="com.ruoyi.other.vo.TechnicianSubscribeVO"> |
| | | SELECT * from ( |