Pu Zhibing
2024-12-18 a823bffa3800426d0a908b9397a8ea7586b5be21
Merge remote-tracking branch 'origin/master'
1 文件已重命名
26个文件已修改
4个文件已删除
2个文件已添加
884 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/enums/PointChangeType.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/enums/WithdrawalAuditStatus.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/excel/BalanceChangeRecordEX.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/excel/UserPointEx.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java 132 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionStatistics.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/BalanceChangeRecordMapper.xml 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/PointSettingDto.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/excel/ShopPointEX.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TechnicianSubscribeMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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/BalanceChangeRecord.java
@@ -5,6 +5,7 @@
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;
@@ -34,12 +35,14 @@
    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("变更后金额")
@@ -49,14 +52,17 @@
    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)
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-门店返佣,14-下级门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人)")
    @TableField("type")
    private Integer type;
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java
@@ -4,6 +4,7 @@
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;
@@ -41,6 +42,7 @@
    @ApiModelProperty(value = "变动类型(1=门店业绩,2=门店返佣,3=下级门店返佣)")
    @TableField("type")
    @Excel(name = "变动类型", readConverterExp = "1=门店业绩,2=门店返佣,3=下级门店返佣")
    private Integer type;
    @ApiModelProperty(value = "历史余额")
@@ -49,10 +51,12 @@
    @ApiModelProperty(value = "变动金额")
    @TableField("variable_point")
    @Excel(name = "变动金额")
    private Integer variablePoint;
    @ApiModelProperty(value = "变动时间")
    @TableField("create_time")
    @Excel(name = "变动时间")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "变动用户id")
@@ -65,14 +69,17 @@
    @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)
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/enums/PointChangeType.java
New file
@@ -0,0 +1,38 @@
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);
    }
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/enums/WithdrawalAuditStatus.java
File was renamed from ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java
@@ -1,4 +1,4 @@
package com.ruoyi.account.enums;
package com.ruoyi.other.api.enums;
import lombok.Getter;
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java
@@ -97,11 +97,11 @@
    @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))
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java
@@ -4,7 +4,6 @@
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;
@@ -15,8 +14,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
@@ -70,41 +67,8 @@
        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, "用户分佣统计");
    }
    
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java
File was deleted
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/excel/BalanceChangeRecordEX.java
File was deleted
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/excel/UserPointEx.java
File was deleted
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalanceChangeRecordMapper.java
@@ -13,8 +13,9 @@
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);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java
@@ -3,6 +3,7 @@
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;
@@ -18,5 +19,7 @@
    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);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
@@ -14,12 +14,15 @@
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
@@ -38,9 +41,14 @@
    @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);
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -7,7 +7,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.account.api.model.UserPoint;
import com.ruoyi.account.enums.PointChangeType;
import com.ruoyi.other.api.enums.PointChangeType;
import com.ruoyi.account.mapper.UserPointMapper;
import com.ruoyi.account.service.AppUserService;
import com.ruoyi.account.service.PointSettingService;
@@ -16,12 +16,14 @@
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 +57,8 @@
    private PointSettingService pointSettingService;
    @Resource
    private UserPointMapper userPointMapper;
    @Resource
    private ShopClient shopClient;
    @Override
    public UserPointVO getUserPoint(Long userId) {
@@ -69,9 +73,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,32 +121,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.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("转赠积分不足");
        }
@@ -159,13 +146,102 @@
        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;
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java
@@ -1,7 +1,7 @@
package com.ruoyi.account.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.account.enums.WithdrawalAuditStatus;
import com.ruoyi.other.api.enums.WithdrawalAuditStatus;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.account.api.model.WithdrawalRequests;
import com.ruoyi.account.service.AppUserService;
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionStatistics.java
@@ -21,7 +21,7 @@
    public CommissionStatistics() {
    }
    public CommissionStatistics(BigDecimal totalCommission, Page<BalanceChangeRecord> changeRecordPage) {
    public CommissionStatistics(BigDecimal totalCommission, IPage<BalanceChangeRecord> changeRecordPage) {
        this.totalCommission = totalCommission;
        this.userPointPage = changeRecordPage;
    }
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/BalanceChangeRecordMapper.xml
@@ -21,14 +21,17 @@
                    </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},'%')
@@ -36,56 +39,16 @@
            <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>
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml
@@ -27,30 +27,38 @@
        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>
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java
@@ -1,16 +1,17 @@
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>
@@ -32,6 +33,19 @@
        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();
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java
@@ -45,6 +45,14 @@
        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);
    }
    /**
     * 导出门店分佣统计
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
@@ -4,10 +4,9 @@
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;
@@ -18,8 +17,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * <p>
@@ -35,6 +32,8 @@
public class ShopPointController {
    @Resource
    private ShopPointService shopPointService;
    @Resource
    private TokenService tokenService;
    /**
@@ -47,6 +46,23 @@
        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);
    }
    /**
     * 导出门店积分统计
     */
@@ -56,37 +72,10 @@
        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(), "用户积分统计");
        }
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
@@ -2,6 +2,7 @@
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;
@@ -105,8 +106,53 @@
        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);
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java
@@ -8,6 +8,7 @@
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;
@@ -32,6 +33,23 @@
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);
    }
    /**
     * 预约列表
@@ -60,7 +78,7 @@
     * 取消服务
     */
    @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>()
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/PointSettingDto.java
New file
@@ -0,0 +1,11 @@
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;
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/excel/ShopPointEX.java
File was deleted
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopPointMapper.java
@@ -1,7 +1,9 @@
package com.ruoyi.other.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.other.api.domain.ShopPoint;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -15,6 +17,9 @@
 */
public interface ShopPointMapper extends BaseMapper<ShopPoint> {
    List<ShopPoint> findLatestChangeByType(ShopPoint shopPoint);
    List<ShopPoint> selectShopPointList(@Param("shopPoint") ShopPoint shopPoint);
    IPage<ShopPoint> queryShpointPage(@Param("page") IPage<ShopPoint> page,@Param("shopPoint") ShopPoint shopPoint);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TechnicianSubscribeMapper.java
@@ -27,6 +27,11 @@
    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);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java
@@ -5,6 +5,7 @@
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;
@@ -22,6 +23,9 @@
     * 查询用于指定门店的相关预约记录
     */
    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);
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
@@ -1,22 +1,16 @@
package com.ruoyi.other.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.mapper.ShopPointMapper;
import com.ruoyi.other.api.domain.ShopPoint;
import com.ruoyi.other.api.enums.PointChangeType;
import com.ruoyi.other.mapper.ShopPointMapper;
import com.ruoyi.other.service.ShopPointService;
import com.ruoyi.other.service.ShopService;
import com.ruoyi.other.vo.ShopPointStatistics;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -29,62 +23,28 @@
 */
@Service
public class ShopPointServiceImpl extends ServiceImpl<ShopPointMapper, ShopPoint> implements ShopPointService {
    @Resource
    private ShopPointMapper shopPointMapper;
    @Resource
    private ShopService shopService;
    @Override
    public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) {
        String shopName = shopPoint.getShopName();
        String phone = shopPoint.getPhone();
        String shopLeaderName = shopPoint.getShopLeaderName();
        List<Integer> shopIds = shopService.listObjs(new LambdaQueryWrapper<Shop>()
                        .select(Shop::getId)
                        .like(StringUtils.isNotEmpty(shopName), Shop::getName, shopName)
                        .like(StringUtils.isNotEmpty(phone), Shop::getPhone, phone)
                        .like(StringUtils.isNotEmpty(shopLeaderName), Shop::getShopManager, shopLeaderName))
                .stream().map(o -> (Integer) o).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(shopIds)) {
            return new ShopPointStatistics();
        }
        shopPoint.setShopIds(shopIds);
        List<ShopPoint> shopPoints = this.baseMapper.selectShopPointList(shopPoint);
        Map<Integer, Integer> shopPointMap = shopPoints.stream()
                .collect(Collectors.groupingBy(
                        ShopPoint::getType,
                        Collectors.summingInt(ShopPoint::getVariablePoint)
                ));
        ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
        List<ShopPoint> latestChangeByType = shopPointMapper.findLatestChangeByType(shopPoint);
        for (ShopPoint sp : latestChangeByType) {
            switch (sp.getType()) {
                case 1:
                    shopPointStatistics.setShopPoint(sp.getVariablePoint());
                    break;
                case 2:
                    shopPointStatistics.setShopCommissionPoint(sp.getVariablePoint());
                    break;
                case 3:
                    shopPointStatistics.setSubShopCommissionPoint(sp.getVariablePoint());
                    break;
            }
        }
        shopPointStatistics.setTotalPoint(shopPointStatistics.getShopPoint() + shopPointStatistics.getShopCommissionPoint() + shopPointStatistics.getSubShopCommissionPoint());
        int sPoint = shopPointMap.getOrDefault(PointChangeType.SHOP_ACHIEVEMENT.getCode(), 0);
        int shopCommissionPoint = shopPointMap.getOrDefault(PointChangeType.SHOP_REBATE.getCode(), 0);
        int subShopCommissionPoint = shopPointMap.getOrDefault(PointChangeType.JUNIOR_SHOP_REBATE.getCode(), 0);
        shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint);
        shopPointStatistics.setShopPoint(sPoint);
        shopPointStatistics.setShopCommissionPoint(shopCommissionPoint);
        shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint);
        boolean condition = shopPoint.getStartTime() != null && shopPoint.getEndTime() != null;
        IPage<ShopPoint> shopPointIPage = page(page, new LambdaQueryWrapper<ShopPoint>()
                .in(!CollectionUtils.isEmpty(shopPoint.getShopIds()), ShopPoint::getShopId, shopPoint.getShopIds())
                .eq(shopPoint.getType() != null, ShopPoint::getType, shopPoint.getType())
                .between(condition, ShopPoint::getCreateTime, shopPoint.getStartTime(), shopPoint.getEndTime())
                .orderByDesc(ShopPoint::getCreateTime));
        List<ShopPoint> shopPoints = shopPointIPage.getRecords();
        for (ShopPoint sp : shopPoints) {
            Shop shop = shopService.getById(sp.getShopId());
            sp.setShopName(shop.getName());
            sp.setShopLeaderName(shop.getShopManager());
            sp.setPhone(shop.getPhone());
        }
        IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint);
        shopPointStatistics.setShopPointIPage(shopPointIPage);
        return shopPointStatistics;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
@@ -41,6 +41,12 @@
        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);
    }
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
@@ -2,47 +2,41 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.other.mapper.ShopPointMapper">
    <select id="findLatestChangeByType" resultType="com.ruoyi.other.api.domain.ShopPoint">
    <sql id="ShopPointList">
        SELECT
            id,
            shop_id,
            type,
            historical_point,
            variable_point,
            create_time,
            create_user_id,
            object_id
        ts.`name` 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>
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml
@@ -26,6 +26,40 @@
        </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 (