Pu Zhibing
2024-12-18 6b3a3251bc06b081903dfe94134f034608c18ba4
Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng

 Conflicts:
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
39个文件已修改
5个文件已添加
1317 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/VipSettingDto.java 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsBargainPrice.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/LogisticsSetDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserChangeLogController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | 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/mapper/AppUserMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalanceChangeRecordMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionStatistics.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml 32 ●●●●● 补丁 | 查看 | 原始文档 | 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 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsBargainPriceMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsBargainPriceService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopBalanceStatementService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsBargainPriceServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopCommissionStatisticsVO.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsBargainPriceMapper.xml 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java
@@ -86,5 +86,9 @@
    @ApiModelProperty(value = "用户电话")
    @TableField(exist = false)
    private String userPhone;
    @ApiModelProperty(value = "会员信息")
    @TableField(exist = false)
    private VipSettingDto vipSettingDto;
}
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
@@ -171,6 +171,22 @@
    @TableField("total_distribution_amount")
    private BigDecimal totalDistributionAmount;
    @ApiModelProperty(value = "拉新人积分总数")
    @TableField("total_invite_point")
    private Integer totalInvitePoint;
    @ApiModelProperty(value = "注册积分总数")
    @TableField("total_register_point")
    private Integer totalRegisterPoint;
    @ApiModelProperty(value = "做工积分总数")
    @TableField("total_work_point")
    private Integer totalWorkPoint;
    @ApiModelProperty(value = "业绩积分总数")
    @TableField("total_performance_point")
    private Integer totalPerformancePoint;
    @ApiModelProperty(value = "剩余积分")
    @TableField("lave_point")
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/VipSettingDto.java
New file
@@ -0,0 +1,150 @@
package com.ruoyi.account.api.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
 * <p>
 *
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_vip_setting")
@ApiModel(value="VipSetting对象", description="")
public class VipSettingDto implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "1-7对应会员")
    @TableId("id")
    private Integer id;
    @ApiModelProperty(value = "会员名称")
    @TableField("vip_name")
    private String vipName;
    @ApiModelProperty(value = "会员专属权益")
    @TableField("vip_info")
    private String vipInfo;
    @ApiModelProperty(value = "1级会员专用 自动解绑推广人天数: 达到设置天数未成为黄金会员自动解绑推广人")
    @TableField("vip_cancel_day")
    private Integer vipCancelDay;
    @ApiModelProperty(value = "1级会员专用 可更换绑定人天数:用户在达到设置的天数未下单商品,可以更换绑定人")
    @TableField("vip_change_day")
    private Integer vipChangeDay;
    @ApiModelProperty(value = "钱包提现权限:1开0关")
    @TableField("vip_withdrawal_role")
    private Integer vipWithdrawalRole;
    @ApiModelProperty(value = "钱包提现权限:1开0关")
    @TableField("vip_agent_level_up_role")
    private Integer vipAgentLevelUpRole;
    @ApiModelProperty(value = "最低提现门槛")
    @TableField("vip_withdrawal_min_amount")
    private BigDecimal vipWithdrawalMinAmount;
    @ApiModelProperty(value = "提现手续费")
    @TableField("vip_withdrawal_fee")
    private BigDecimal vipWithdrawalFee;
    @ApiModelProperty(value = "积分转赠权限 1开0关")
    @TableField("vip_gift_role")
    private Integer vipGiftRole;
    @ApiModelProperty(value = "达成会员等级所需消费积分数量")
    @TableField("vip_level_up_shop")
    private Integer vipLevelUpShop;
    @ApiModelProperty(value = "通过消费积分达成会员等级的开关 1开0关")
    @TableField("vip_level_up_shop_role")
    private Integer vipLevelUpShopRole;
    @ApiModelProperty(value = "达成会员等级所需的返佣积分数量")
    @TableField("vip_level_up_share")
    private Integer vipLevelUpShare;
    @ApiModelProperty(value = "通过返佣积分达成会员等级的开关 1开0关")
    @TableField("vip_level_up_share_role")
    private Integer vipLevelUpShareRole;
    @ApiModelProperty(value = "达成会员等级所需的直推人数(包括钻石和代理)")
    @TableField("vip_direct_num")
    private Integer vipDirectNum;
    @ApiModelProperty(value = "达成会员等级所需的团队数量")
    @TableField("vip_team_num")
    private Integer vipTeamNum;
    @ApiModelProperty(value = "通过直推用户或团队数量的方式达成会员等级的开关 1开0关")
    @TableField("vip_level_up_num_role")
    private Integer vipLevelUpNumRole;
    @ApiModelProperty(value = "达成会员等级所需准代理数(达成总代和合伙人用到)")
    @TableField("vip_direct_vip_num")
    private Integer vipDirectVipNum;
    @ApiModelProperty(value = "达成会员等级所需总代数量(达成合伙人用到)")
    @TableField("vip_team_vip_num")
    private Integer vipTeamVipNum;
    @ApiModelProperty(value = "达成会员等级所需开店数量")
    @TableField("vip_open_shop_num")
    private Integer vipOpenShopNum;
    @ApiModelProperty(value = "消费积分保级周期(天)")
    @TableField("keep_buy_day")
    private Integer keepBuyDay;
    @ApiModelProperty(value = "消费积分保级的积分阈值(分))")
    @TableField("keep_buy_point")
    private Integer keepBuyPoint;
    @ApiModelProperty(value = "返佣积分保的周期(天)")
    @TableField("keep_share_day")
    private Integer keepShareDay;
    @ApiModelProperty(value = "返佣积分保级的积分阈值(分)")
    @TableField("keep_share_point")
    private Integer keepSharePoint;
    @ApiModelProperty(value = "门店业绩积分保级的周期(天)")
    @TableField("keep_shop_day")
    private Integer keepShopDay;
    @ApiModelProperty(value = "门店业绩积分保级的积分阈值(分)")
    @TableField("keep_shop_point")
    private Integer keepShopPoint;
    @ApiModelProperty(value = "会员等级是否必须达到代理: 0-否 1-是")
    @TableField("vip_level_up_proxy_role")
    private Integer vipLevelUpProxyRole;
    @ApiModelProperty(value = "指定会员升级商品")
    @TableField("good_ids")
    private String goodIds;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java
@@ -139,6 +139,12 @@
    @ApiModelProperty(value = "地区价格")
    private List<GoodsArea> goodsAreaList;
    @TableField(exist = false)
    private String categoryName;
    @TableField(exist = false)
    private Integer showStatus;
    public String getIdStr() {
        return String.valueOf(id);
    }
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsBargainPrice.java
@@ -44,7 +44,7 @@
    @ApiModelProperty(value = "审核人id")
    @TableField("audit_user_id")
    private Integer auditUserId;
    private Long auditUserId;
    @ApiModelProperty(value = "审核时间")
    @TableField("audit_time")
@@ -78,6 +78,10 @@
    @TableField(exist = false)
    private String categoryName;
    @ApiModelProperty(value = "分类id")
    @TableField(exist = false)
    private Integer categoryId;
    @ApiModelProperty(value = "门店名称")
    @TableField(exist = false)
    private String shopName;
@@ -90,4 +94,8 @@
    @TableField(exist = false)
    private String ownerPhone;
    @ApiModelProperty(value = "商品类型")
    @TableField(exist = false)
    private Integer goodsType;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java
@@ -3,10 +3,13 @@
import com.baomidou.mybatisplus.annotation.TableField;
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;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -36,8 +39,9 @@
    @TableField("shop_id")
    private Integer shopId;
    @ApiModelProperty(value = "变动类型(1=返佣,2=提现)")
    @ApiModelProperty(value = "变动类型(1=门店分佣,2=下级门店分佣,3=门店服务费)")
    @TableField("type")
    @Excel(name = "变更类型",readConverterExp = "1=门店分佣,2=下级门店分佣,3=门店服务费")
    private Integer type;
    @ApiModelProperty(value = "历史余额")
@@ -48,8 +52,14 @@
    @TableField("variable_amount")
    private BigDecimal variableAmount;
    @ApiModelProperty(value = "变动后余额")
    @TableField("balance")
    @Excel(name = "变更后数量")
    private BigDecimal balance;
    @ApiModelProperty(value = "变动时间")
    @TableField("create_time")
    @Excel(name = "变更时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "变动用户id")
@@ -60,5 +70,30 @@
    @TableField("object_id")
    private Long objectId;
    @ApiModelProperty(value = "门店名称")
    @TableField(exist = false)
    @Excel(name = "门店名称")
    private String shopName;
    @ApiModelProperty(value = "店长名称")
    @TableField(exist = false)
    @Excel(name = "店长名称")
    private String shopManagerName;
    @ApiModelProperty(value = "联系电话")
    @TableField(exist = false)
    @Excel(name = "联系电话")
    private String phone;
    @ApiModelProperty(value = "开始时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String startTime;
    @ApiModelProperty(value = "结束时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String endTime;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java
@@ -150,4 +150,5 @@
    private List<Goods> goodsList;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/LogisticsSetDto.java
@@ -34,6 +34,6 @@
    /**
     * 包邮会员等级要求:1普通会员,2黄金会员,3钻石会员,4准代理,5代理,6总代,7合伙人
     */
    @ApiModelProperty(value = "包邮会员等级要求:1普通会员,2黄金会员,3钻石会员,4准代理,5代理,6总代,7合伙人")
    private Integer freeVip;
    @ApiModelProperty(value = "包邮会员等级要求:0全部 1普通会员,2黄金会员,3钻石会员,4准代理,5代理,6总代,7合伙人")
    private String freeVip;
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
@@ -3,17 +3,19 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.model.AgentApplication;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.account.api.model.UserChangeLog;
import com.ruoyi.account.dto.AgentQuery;
import com.ruoyi.account.api.model.VipSettingDto;
import com.ruoyi.account.service.AgentApplicationService;
import com.ruoyi.account.service.AppUserService;
import com.ruoyi.account.service.UserChangeLogService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.other.api.domain.VipSetting;
import com.ruoyi.other.api.feignClient.VipSettingClient;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
@@ -49,11 +51,17 @@
        return R.ok(agentApplicationService.pageList(agentQuery));
    }
    @Resource
    private VipSettingClient vipSettingClient;
    @GetMapping("/detail")
    @ApiOperation(value = "会员申请详情", tags = {"会员中心-小程序"})
    public R<AgentApplication> detail(@RequestParam Long id) {
        return R.ok(agentApplicationService.getById(id));
        R<VipSetting> vipSetting = vipSettingClient.getVipSetting(id.intValue());
        VipSettingDto vipSettingDto = new VipSettingDto();
        BeanUtils.copyProperties(vipSetting.getData(),vipSettingDto);
        AgentApplication byId = agentApplicationService.getById(id);
        byId.setVipSettingDto(vipSettingDto);
        return R.ok(byId);
    }
    @Resource
    private UserChangeLogService userChangeLogService;
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -34,6 +34,7 @@
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -415,9 +416,10 @@
        for (Order datum : listR.getData()) {
            userIds.add(datum.getAppUserId());
        }
        IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageNum, pageSize, appUser,objectId);
        IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageNum, pageSize, appUser,objectId,userIds);
        return R.ok(appuserPage);
    }
    @GetMapping("/danger/info")
@@ -480,6 +482,52 @@
        appUserService.updateById(byId);
        return R.ok();
    }
    @GetMapping("/select")
    @ApiOperation(value = "用户列表-查询绑定人", tags = {"管理后台"})
    public R<AppUser> select(String phone)
    {
        AppUser byId = appUserService.lambdaQuery().eq(AppUser::getPhone,phone).one();
        if (byId==null){
            return R.fail("搜索失败,手机号错误。");
        }
        return R.ok(byId);
    }
    @GetMapping("/change/bind")
    @ApiOperation(value = "用户列表-更换绑定人", tags = {"管理后台"})
    public R<AppUser> select(Long id,Long inviteId)
    {
        AppUser byId = appUserService.getById(id);
        byId.setInviteUserId(inviteId);
        byId.setTopInviteId(getTop(inviteId));
        appUserService.updateById(byId);
        return R.ok();
    }
    @GetMapping("/change/shop")
    @ApiOperation(value = "用户列表-更换门店", tags = {"管理后台"})
    public R<AppUser> shop(Long id,Long shopId)
    {
        AppUser byId = appUserService.getById(id);
        byId.setShopId(shopId);
        appUserService.updateById(byId);
        return R.ok();
    }
    public  Long getTop(Long inviteId){
        AppUser byId = appUserService.getById(inviteId);
        if (byId!=null){
            return getTop(byId.getInviteUserId());
        }else {
            return inviteId;
        }
    }
    @Resource
    private ShopClient shopClient;
    @Resource
@@ -514,8 +562,35 @@
        if (lastOrder.getData()!=null){
            byId.setLastOrderTime(lastOrder.getData().getCreateTime());
        }
        //消费总金额
        return R.ok(byId);
    }
    @Resource
    private UserChangeLogService userChangeLogService;
    @GetMapping("/change/vip")
    @ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"})
    public R<Page<AppUser>> changevip(Long id,Integer vipId)
    {
        AppUser byId = appUserService.getById(id);
        UserChangeLog userChangeLog = new UserChangeLog();
        userChangeLog.setCreateTime(LocalDateTime.now());
        userChangeLog.setAppUserId(byId.getId());
        userChangeLog.setBeforeVipId(byId.getVipId());
        userChangeLog.setAfterVipId(vipId);
        if (userChangeLog.getBeforeVipId()>userChangeLog.getAfterVipId()) {
            userChangeLog.setChangeType(0);
        }else {
            userChangeLog.setChangeType(1);
        }
        userChangeLogService.save(userChangeLog);
        byId.setVipId(vipId);
        appUserService.updateById(byId);
        return R.ok();
    }
    @GetMapping("/bottom")
    @ApiOperation(value = "用户列表-绑定下级列表", tags = {"管理后台"})
    public R<Page<AppUser>> bottom(Long id,Integer pageNum,Integer pageSize)
@@ -526,6 +601,16 @@
    }
    @GetMapping("/orders")
    @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"})
    public R<List<Order>> orders(Long id)
    {
        R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id);
        return R.ok(listR.getData());
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java
@@ -3,17 +3,14 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.model.BalanceChangeRecord;
import com.ruoyi.account.api.model.UserClickLog;
import com.ruoyi.account.api.model.UserPoint;
import com.ruoyi.account.dto.BalanceQuery;
import com.ruoyi.account.dto.UserCancelQuery;
import com.ruoyi.account.excel.UserPointEx;
import com.ruoyi.account.excel.BalanceChangeRecordEX;
import com.ruoyi.account.service.BalanceChangeRecordService;
import com.ruoyi.account.vo.CommissionStatistics;
import com.ruoyi.account.vo.UserPointStatistics;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -52,77 +49,63 @@
        return R.ok(balanceChangeRecordService.pageList(agentQuery));
    }
//    /**
//     * 用户分佣统计
//     */
//    @GetMapping("/commissionStatistics")
//    @ApiOperation(value = "用户分佣统计", tags = "管理后台-财务统计-用户分佣统计")
//    public R<CommissionStatistics> commissionStatistics(UserPoint userPoint) {
//        userPoint.setType(2);
//        IPage<UserPoint> userPointPage = userPointService.getUserPointPage(Page.of(userPoint.getPageNum(), userPoint.getPageSize()), userPoint);
//        UserPointStatistics statistics = userPointService.getStatistics(userPoint);
//        CommissionStatistics commissionStatistics = new CommissionStatistics();
//        commissionStatistics.setStatistics(statistics);
//        commissionStatistics.setUserPointPage(userPointPage);
//        return R.ok(commissionStatistics);
//    }
    /**
     * 用户分佣统计
     */
    @GetMapping("/commissionStatistics")
    @ApiOperation(value = "用户分佣统计", tags = "管理后台-财务统计-用户分佣统计")
    public R<CommissionStatistics> commissionStatistics(@ApiParam("页码") @RequestParam Integer pageNum,
                                                        @ApiParam("每一页数据大小") Integer pageSize,
                                                        BalanceChangeRecord balanceChangeRecord) {
        CommissionStatistics commissionStatistics1 = balanceChangeRecordService.commissionStatistics(Page.of(pageNum, pageSize), balanceChangeRecord);
        return R.ok(commissionStatistics1);
    }
//
//    /**
//     * 导出用户分佣统计
//     */
//    @GetMapping("/commissionExport")
//    @ApiOperation(value = "用户分佣统计导出", tags = "管理后台-财务统计-用户分佣统计")
//    public void commissionExport(HttpServletResponse response, UserPoint userPoint) {
//        userPoint.setType(2);
//        IPage<UserPoint> userPointPage = userPointService.getUserPointPage(Page.of(1, Integer.MAX_VALUE), userPoint);
//        List<UserPoint> userPointList = userPointPage.getRecords();
//        List<UserPointEx> userPointExList = new ArrayList<>();
//        for (UserPoint point : userPointList) {
//            UserPointEx userPointEx = new UserPointEx();
//            userPointEx.setUserName(point.getUserName());
//            userPointEx.setPhone(point.getPhone());
//            userPointEx.setChangeTime(point.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//            userPointEx.setChangeNum(point.getVariablePoint().toString());
//            Integer type = point.getType();
//            switch (type) {
//                case 1:
//                    userPointEx.setType("消费积分");
//                    break;
//                case 2:
//                    userPointEx.setType("返佣积分");
//                    break;
//                case 3:
//                    userPointEx.setType("拉新人积分");
//                    break;
//                case 4:
//                    userPointEx.setType("兑换商品");
//                    break;
//                case 5:
//                    userPointEx.setType("门店业绩");
//                    break;
//                case 6:
//                    userPointEx.setType("门店返佣");
//                    break;
//                case 7:
//                    userPointEx.setType("技师业绩");
//                    break;
//                case 8:
//                    userPointEx.setType("转赠积分");
//                    break;
//                case 9:
//                    userPointEx.setType("做工积分");
//                    break;
//                case 10:
//                    userPointEx.setType("注册积分");
//                    break;
//                default:
//                    userPointEx.setType("未知积分");
//            }
//            userPointExList.add(userPointEx);
//        }
//        ExcelUtil<UserPointEx> util = new ExcelUtil<>(UserPointEx.class);
//        util.exportExcel(response, userPointExList, "用户分佣统计");
//    }
    @GetMapping("/commissionExport")
    @ApiOperation(value = "用户分佣统计导出", tags = "管理后台-财务统计-用户分佣统计")
    public void commissionExport(HttpServletResponse response, BalanceChangeRecord balanceChangeRecord) {
        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, "用户分佣统计");
    }
    
    
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserChangeLogController.java
@@ -7,6 +7,7 @@
import com.ruoyi.account.dto.UserChangeQuery;
import com.ruoyi.account.service.UserChangeLogService;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,6 +43,7 @@
    }
    @PostMapping("/page")
    @ApiOperation(value = "会员变更记录", tags = {"后台"})
    public R<IPage<UserChangeLog>> page(@RequestBody UserChangeQuery userChangeLog){
        return R.ok(userChangeLogService.pageList(userChangeLog));
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/excel/BalanceChangeRecordEX.java
New file
@@ -0,0 +1,22 @@
package com.ruoyi.account.excel;
import com.ruoyi.common.core.annotation.Excel;
import lombok.Data;
@Data
public class BalanceChangeRecordEX {
    @Excel(name = "用户名称")
    private String userName;
    @Excel(name = "联系电话")
    private String phone;
    @Excel(name = "变更类型")
    private String type;
    @Excel(name = "变更时间")
    private String changeTime;
    @Excel(name = "变更数量")
    private String changeNum;
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
@@ -28,7 +28,7 @@
    List<NearbyReferrerVo> getNearbyReferrer(@Param("cityCode") String cityCode, @Param("nearbyReferrer") NearbyReferrer nearbyReferrer);
    IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser);
    IPage<AppUser> getAppuserPage1(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser,Integer objectId);
    IPage<AppUser> getAppuserPage1(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser,@Param("objectId")Integer objectId,@Param("userIds")List<Long> userIds);
    
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalanceChangeRecordMapper.java
@@ -4,9 +4,17 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.model.BalanceChangeRecord;
import com.ruoyi.account.api.model.UserPoint;
import com.ruoyi.account.dto.BalanceQuery;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BalanceChangeRecordMapper extends BaseMapper<BalanceChangeRecord> {
    IPage<BalanceChangeRecord> pageList(@Param("page") Page<BalanceChangeRecord> page,@Param("agentQuery") BalanceQuery agentQuery);
    IPage<BalanceChangeRecord> queryCommissionStatistics(@Param("page") Page<BalanceChangeRecord> page,
                                                         @Param("changeRecord") BalanceChangeRecord changeRecord);
    List<UserPoint> findLatestChangeByType(BalanceChangeRecord balanceChangeRecord);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.account.api.model.UserPoint;
import java.util.List;
@@ -17,6 +18,5 @@
    List<UserPoint> findLatestUserPointByTypeForUser(Long userId);
    List<UserPoint> findLatestChangeByType(UserPoint userPoint);
    IPage<UserPoint> queryUserPointPage(IPage<UserPoint> page, UserPoint userPoint);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
@@ -82,5 +82,5 @@
    void onlineRecord();
    IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser);
    IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId);
    IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -670,8 +670,8 @@
        return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser);
    }
    @Override
    public IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId) {
    public IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds) {
        return appUserMapper.getAppuserPage1(new Page<>(pageNum, pageSize), appUser,objectId);
        return appUserMapper.getAppuserPage1(new Page<>(pageNum, pageSize), appUser,objectId,userIds);
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
@@ -39,24 +39,8 @@
    @Override
    public CommissionStatistics commissionStatistics(Page<BalanceChangeRecord> page, BalanceChangeRecord balanceChangeRecord) {
        List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>()
                .like(StringUtils.isNotEmpty(balanceChangeRecord.getUserName()), AppUser::getName, balanceChangeRecord.getUserName())
                .like(StringUtils.isNotEmpty(balanceChangeRecord.getUserPhone()), AppUser::getPhone, balanceChangeRecord.getUserPhone()));
        if (CollectionUtils.isEmpty(appUserList)){
            return new CommissionStatistics();
        }
        List<Long> appUserIds = appUserList.stream().map(AppUser::getId).collect(Collectors.toList());
        BigDecimal totalCommission = appUserList.stream()
                .map(AppUser::getTotalDistributionAmount)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        Page<BalanceChangeRecord> changeRecordPage = page(page, new LambdaQueryWrapper<BalanceChangeRecord>()
                .in(BalanceChangeRecord::getAppUserId, appUserIds)
                .between(balanceChangeRecord.getStartTime() != null && balanceChangeRecord.getEndTime() != null,
                        BalanceChangeRecord::getCreateTime, balanceChangeRecord.getStartTime(), balanceChangeRecord.getEndTime()));
        return new CommissionStatistics(totalCommission, changeRecordPage);
        IPage<BalanceChangeRecord> balanceChangeRecordIPage = this.baseMapper.queryCommissionStatistics(page, balanceChangeRecord);
//        return new CommissionStatistics(totalCommission, changeRecordPage);
        return null;
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -127,7 +127,9 @@
        UserPoint userPoint = new UserPoint();
        userPoint.setAppUserId(userid);
        List<UserPoint> userPointList = userPointMapper.findLatestChangeByType(userPoint);
//        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));
@@ -163,79 +165,12 @@
    @Override
    public UserPointStatistics getStatistics(UserPoint userPoint) {
        try {
            if (StringUtils.isNotEmpty(userPoint.getUserName()) && StringUtils.isNotEmpty(userPoint.getPhone())) {
                List<Long> userIds = appUserService.listObjs(new LambdaQueryWrapper<AppUser>()
                                .select(AppUser::getId)
                                .like(AppUser::getName, userPoint.getUserName())
                                .like(AppUser::getPhone, userPoint.getPhone()))
                        .stream()
                        .map(appUserId -> (Long) appUserId)
                        .collect(Collectors.toList());
                userPoint.setUserIds(userIds);
            }
            List<UserPoint> userPointList = userPointMapper.findLatestChangeByType(userPoint);
            Map<Integer, Integer> userBalanceMap = userPointList.stream()
                    .collect(Collectors.groupingBy(
                            UserPoint::getType,
                            Collectors.summingInt(UserPoint::getBalance)
                    ));
            int consumePoint = userBalanceMap.getOrDefault(PointChangeType.CONSUME.getCode(), 0);
            int sharePoint = userBalanceMap.getOrDefault(PointChangeType.COMMISSION_RETURN.getCode(), 0);
            int pullNewPoint = userBalanceMap.getOrDefault(PointChangeType.NEW_USER_REFERRAL.getCode(), 0);
            int registerPoint = userBalanceMap.getOrDefault(PointChangeType.REGISTRATION.getCode(), 0);
            int workPoint = userBalanceMap.getOrDefault(PointChangeType.WORK_PERFORMANCE.getCode(), 0);
            int shopAchievementPoint = userBalanceMap.getOrDefault(PointChangeType.TECHNICIAN_PERFORMANCE.getCode(), 0);
            int exchangeGoodsPoint = userBalanceMap.getOrDefault(PointChangeType.EXCHANGE_GOODS.getCode(), 0);
            int storeAchievementPoint = userBalanceMap.getOrDefault(PointChangeType.STORE_PERFORMANCE.getCode(), 0);
            int storeCommissionPoint = userBalanceMap.getOrDefault(PointChangeType.STORE_COMMISSION_RETURN.getCode(), 0);
            int transferPoint = userBalanceMap.getOrDefault(PointChangeType.TRANSFER_POINTS.getCode(), 0);
            int totalPoint = consumePoint + sharePoint + pullNewPoint + registerPoint + workPoint + shopAchievementPoint + exchangeGoodsPoint + storeAchievementPoint + storeCommissionPoint + transferPoint;
            UserPointStatistics userPointStatistics = new UserPointStatistics();
            userPointStatistics.setTotalPoint(totalPoint);
            userPointStatistics.setConsumePoint(consumePoint);
            userPointStatistics.setSharePoint(sharePoint);
            userPointStatistics.setPullNewPoint(pullNewPoint);
            userPointStatistics.setRegisterPoint(registerPoint);
            userPointStatistics.setWorkPoint(workPoint);
            userPointStatistics.setShopAchievementPoint(shopAchievementPoint);
            return userPointStatistics;
        } catch (Exception e) {
            // 记录异常日志
            log.error("获取用户点统计信息时出错", e);
            throw new RuntimeException("获取用户点统计信息时出错", e);
        }
        return null;
    }
    @Override
    public IPage<UserPoint> getUserPointPage(Page<UserPoint> page, UserPoint userPoint) {
        List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>()
                .eq(AppUser::getPhone, userPoint.getPhone())
                .like(AppUser::getName, userPoint.getUserName()));
        if (appUserList.isEmpty()){
            return page;
        }
        List<Long> userIds = appUserList.stream().map(AppUser::getId).collect(Collectors.toList());
        Page<UserPoint> userPointPage = page(page, new LambdaQueryWrapper<UserPoint>()
                .in(UserPoint::getAppUserId, userIds)
                .eq(userPoint.getType() != null, UserPoint::getType, userPoint.getType())
                .between( userPoint.getStartTime()!= null && userPoint.getEndTime() !=null,UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime())
                .orderByDesc(UserPoint::getCreateTime));
        userPointPage.getRecords().forEach(userPoint1 -> appUserList.stream()
                .filter(appUser -> appUser.getId().equals(userPoint1.getAppUserId()))
                .findFirst().ifPresent(appUser -> {
                    userPoint1.setUserName(appUser.getName());
                    userPoint1.setPhone(appUser.getPhone());
                }));
        return userPointPage;
        return this.baseMapper.queryUserPointPage(page, userPoint);
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionStatistics.java
@@ -14,7 +14,7 @@
public class CommissionStatistics {
    @ApiModelProperty(value = "分佣总计")
    private Integer totalCommission;
    private BigDecimal totalCommission;
    @ApiModelProperty(value = "分页数据", required = true)
    private IPage<BalanceChangeRecord> userPointPage;
@@ -22,6 +22,7 @@
    public CommissionStatistics() {
    }
    public CommissionStatistics(BigDecimal totalCommission, Page<BalanceChangeRecord> changeRecordPage) {
        this.totalCommission = totalCommission;
        this.userPointPage = changeRecordPage;
    }
}
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
@@ -79,4 +79,36 @@
        order by ta.is_danger desc
    </select>
    <select id="getAppuserPage1" resultType="com.ruoyi.account.api.model.AppUser">
        SELECT ta.id, ta.`name`, ta.vip_id, ta.shop_id
        FROM t_app_user ta
        <where>
            ta.del_flag = 0
            <if test="null != appUser.name and '' != appUser.name">
                and ta.`name` like CONCAT('%',#{appUser.name},'%')
            </if>
            <if test="null != appUser.phone and '' != appUser.phone">
                and ta.phone like CONCAT('%',#{appUser.phone},'%')
            </if>
            <if test="null != appUser.status">
                and ta.status = #{appUser.status}
            </if>
            <if test="null != appUser.vipId">
                and ta.vip_id = #{appUser.vipId}
            </if>
            <if test="null != appUser.shopIds and appUser.shopIds.size() > 0">
                and ta.shop_id in
                <foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")">
                    #{shopId}
                </foreach>
            </if>
            and ( ta.id
             in
            (
            <foreach collection="userIds" item="userId" open="(" separator="," close=")">
                #{userId}
            </foreach>
            ) or ta.shop_id = #{objectId} )
        </where>
    </select>
</mapper>
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/BalanceChangeRecordMapper.xml
@@ -21,4 +21,71 @@
                    </if>
                </where>
    </select>
    <select id="queryCommissionStatistics" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
        SELECT
            tcr.*,
            tau.`name` userName,
            tau.phone userPhone
        FROM
            t_balance_change_record tcr
                LEFT JOIN t_app_user tau ON tcr.app_user_id = tau.id
        <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>
    </select>
    <select id="findLatestChangeByType" resultType="com.ruoyi.account.api.model.UserPoint">
        SELECT
            id,
            app_user_id,
            order_id,
            change_type,
            before_amount,
            change_amount,
            after_amount,
            del_flag,
            create_time
        FROM
            (
                SELECT
                    id,
                    app_user_id,
                    order_id,
                    change_type,
                    before_amount,
                    change_amount,
                    after_amount,
                    del_flag,
                    create_time,
                    ROW_NUMBER() OVER ( PARTITION BY change_type, app_user_id ORDER BY create_time DESC ) rn
                FROM
                    t_balance_change_record
        <where>
            <if test="changeRecord.userName != null and changeRecord.userName != ''">
                and tau.name like concat('%',#{changeRecord.userName},'%')
            </if>
            <if test="changeRecord.userPhone != null and changeRecord.userPhone != ''">
                and tau.phone like concat('%',#{changeRecord.userPhone},'%')
            </if>
            <if test="changeRecord.changeType != null">
                and tcr.change_type = #{changeRecord.changeType}
            </if>
            <if test="changeRecord.startTime != null and changeRecord.endTime != null">
                and DATE(tcr.create_time) between  #{changeRecord.startTime} and #{changeRecord.endTime}
            </if>
        </where>
            ) AS subquery
        WHERE
            rn = 1
    </select>
</mapper>
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml
@@ -27,46 +27,30 @@
        WHERE
            t1.app_user_id = #{userId}
    </select>
    <select id="findLatestChangeByType" resultType="com.ruoyi.account.api.model.UserPoint">
    <select id="queryUserPointPage" resultType="com.ruoyi.account.api.model.UserPoint">
        SELECT
            id,
            type,
            historical_point,
            variable_point,
            balance,
            create_time,
            app_user_id,
            object_id
        FROM (
                 SELECT
                     id,
                     type,
                     historical_point,
                     variable_point,
                     balance,
                     create_time,
                     app_user_id,
                     object_id,
                     ROW_NUMBER() OVER (PARTITION BY `type`,app_user_id ORDER BY create_time DESC) AS rn
                 FROM
                     t_user_point
                 <where>
                         <if test="startTime != null and endTime != null">
                             create_time BETWEEN #{startTime} AND #{endTime}
                         </if>
                         <if test="type != null">
                             AND `type` = #{type}
                         </if>
                         <if test="userIds != null and userIds.size !=0">
                             AND app_user_id IN
                             <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
                                 #{item}
                             </foreach>
                         </if>
                 </where>
        ) AS subquery
        WHERE
            rn = 1
            tau.`name` userName,
            tau.phone,
            tup.type,
            tup.create_time,
            tup.variable_point
        FROM
            t_user_point tup
                LEFT JOIN t_app_user tau ON tup.app_user_id = tau.id
        <where>
            <if test="userName != null and userName != ''">
                AND tau.`name` LIKE concat('%',#{userName},'%')
            </if>
            <if test="phone != null and phone != ''">
                AND tau.phone LIKE concat('%',#{phone},'%')
            </if>
            <if test="type != null and type != ''">
                AND tup.type = #{type}
            </if>
            <if test="startTime != null and endTime != null">
                AND tup.create_time BETWEEN #{startTime} AND #{endTime}
            </if>
        </where>
    </select>
</mapper>
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -20,9 +20,11 @@
import com.ruoyi.other.api.feignClient.BaseSettingClient;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.List;
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
@@ -127,6 +127,7 @@
        couponInfo.setShelfStatus(0);
        List<String> goodsNameList = couponInfo.getGoodsNameList();
        couponInfo.setGoodsNameJson(JSON.toJSONString(goodsNameList));
        couponInfo.setShelfStatus(1);
        couponInfoService.save(couponInfo);
        return R.ok();
    }
@@ -187,6 +188,7 @@
    @GetMapping("/getReceiveRecord")
    public R<IPage<UserCoupon>> getReceiveRecord(@ApiParam("页码") @RequestParam Integer pageNum, @ApiParam("大小") Integer pageSize,UserCoupon userCoupon) {
        // TODO 待完善
        return null;
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java
@@ -2,33 +2,25 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
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.other.api.domain.*;
import com.ruoyi.other.api.domain.GoodsBargainPrice;
import com.ruoyi.other.api.domain.GoodsBargainPriceDetail;
import com.ruoyi.other.api.vo.GetGoodsBargainPrice;
import com.ruoyi.other.service.*;
import com.ruoyi.other.service.GoodsBargainPriceDetailService;
import com.ruoyi.other.service.GoodsBargainPriceService;
import com.ruoyi.other.vo.AddGoodsBargainPriceVo;
import com.ruoyi.other.vo.GoodsBargainPriceInfo;
import com.ruoyi.other.vo.ShopGoodsList;
import com.ruoyi.other.vo.ShopGoodsListVo;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.*;
import io.swagger.models.auth.In;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
import static com.alibaba.nacos.shaded.org.checkerframework.checker.units.UnitsTools.g;
/**
 * <p>
@@ -51,18 +43,6 @@
    @Resource
    private TokenService tokenService;
    @Resource
    private GoodsService goodsService;
    @Resource
    private GoodsCategoryService goodsCategoryService;
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private ShopService shopService;
    /**
@@ -156,46 +136,21 @@
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表", tags = {"管理后台-商品管理-门店特殊售价"})
    public R<Page<GoodsBargainPrice>> list(@ApiParam("页码") @RequestParam(value = "pageNum", required = false) Integer pageNum,
    public R<IPage<GoodsBargainPrice>> list(@ApiParam("页码") @RequestParam(value = "pageNum", required = false) Integer pageNum,
                                           @ApiParam("每页数量") @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                           @ApiParam("商品id") @RequestParam(value = "goodsId", required = false) Integer goodsId,
                                           @ApiParam("商品名称") @RequestParam(value = "goodsName", required = false) String goodsName,
                                           @ApiParam("商品类型") @RequestParam(value = "goodsType", required = false) Integer goodsType,
                                           @ApiParam("所属分类") @RequestParam(value = "categoryId", required = false) Integer categoryId,
                                           @ApiParam("审核状态") @RequestParam(value = "auditStatus", required = false) Integer auditStatus) {
        List<Goods> goodsList = goodsService.list(new LambdaQueryWrapper<Goods>()
                .eq(StringUtils.isNotEmpty(goodsName), Goods::getName, goodsName)
                .eq(goodsType != null, Goods::getType, goodsType)
                .eq(categoryId != null, Goods::getGoodsCategoryId, categoryId));
        List<Integer> goodsIds = goodsList.stream().map(Goods::getId).collect(Collectors.toList());
        if (goodsId != null){
            goodsIds.add(goodsId);
        }
        Page<GoodsBargainPrice> page = goodsBargainPriceService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsBargainPrice>()
                .eq(!CollectionUtils.isEmpty(goodsIds), GoodsBargainPrice::getGoodsId, goodsId)
                .eq(auditStatus != null, GoodsBargainPrice::getAuditStatus, auditStatus));
        page.getRecords().forEach(goodsBargainPrice -> goodsList.stream()
                .filter(goods -> goods.getId().equals(goodsBargainPrice.getGoodsId()))
                .findFirst().ifPresent(g -> {
                    GoodsCategory goodsCategory = goodsCategoryService.getById(g.getGoodsCategoryId());
                    Integer shopId = goodsBargainPrice.getShopId();
                    Shop shop = shopService.getById(shopId);
                    R<AppUser> r = appUserClient.getAppUserByPhone1(shop.getPhone());
                    if (R.isError(r)){
                        throw new RuntimeException("获取店长信息失败");
                    }
                    goodsBargainPrice.setOwnerName(r.getData().getName());
                    goodsBargainPrice.setOwnerPhone(shop.getPhone());
                    goodsBargainPrice.setShopName(shop.getName());
                    goodsBargainPrice.setGoodsName(g.getName());
                    goodsBargainPrice.setCategoryName(goodsCategory.getName());
                }));
        return R.ok(page);
        GoodsBargainPrice bargainPrice = new GoodsBargainPrice();
        bargainPrice.setGoodsName(goodsName);
        bargainPrice.setGoodsId(goodsId);
        bargainPrice.setGoodsType(goodsType);
        bargainPrice.setCategoryId(categoryId);
        bargainPrice.setAuditStatus(auditStatus);
        IPage<GoodsBargainPrice> goodsBargainPriceIPage = goodsBargainPriceService.queryGoodsBargainPricePage(Page.of(pageNum, pageSize), bargainPrice);
        return R.ok(goodsBargainPriceIPage);
    }
    
    
@@ -221,5 +176,23 @@
    public R addGoodsBargainPrice(@RequestBody AddGoodsBargainPriceVo vo){
        return goodsBargainPriceService.addGoodsBargainPrice(vo);
    }
    /**
     * 审核商品
     */
    @PostMapping("/auditGoods")
    @ApiOperation(value = "审核商品", tags = {"管理后台-商品管理-门店特殊售价"})
    public R<Void> auditGoods(@RequestBody GoodsBargainPrice goodsBargainPrice) {
        LoginUser loginUser = tokenService.getLoginUser();
        Integer id = goodsBargainPrice.getId();
        GoodsBargainPrice bargainPrice = goodsBargainPriceService.getById(id);
        bargainPrice.setAuditStatus(goodsBargainPrice.getAuditStatus());
        bargainPrice.setAuditMsg(goodsBargainPrice.getAuditMsg());
        bargainPrice.setAuditUserId(loginUser.getUserid());
        bargainPrice.setAuditTime(LocalDateTime.now());
        goodsBargainPriceService.updateById(bargainPrice);
        return R.ok();
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
@@ -101,18 +102,20 @@
     */
    @GetMapping("/list")
    @ApiOperation(value = "评论列表", tags = {"管理后台-商品管理-评价管理"})
    public R<List<GoodsEvaluate>> list(GoodsEvaluate goodsEvaluate){
        List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery()
                .like(StringUtils.isNotEmpty(goodsEvaluate.getGoodsName()),GoodsEvaluate::getGoodsName, goodsEvaluate.getComment())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getUserName()),GoodsEvaluate::getUserName, goodsEvaluate.getUserName())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getPhone()),GoodsEvaluate::getPhone, goodsEvaluate.getPhone())
                .eq(goodsEvaluate.getStatus()!=null,GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
                .orderByDesc(GoodsEvaluate::getCreateTime)
                .list();
    public R<Page<GoodsEvaluate>> list(@ApiParam("页码") @RequestParam Integer pageNum,
                                       @ApiParam("每一页数据大小") Integer pageSize,
                                       GoodsEvaluate goodsEvaluate){
        Page<GoodsEvaluate> page = goodsEvaluateService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsEvaluate>()
                .like(StringUtils.isNotEmpty(goodsEvaluate.getGoodsName()), GoodsEvaluate::getGoodsName, goodsEvaluate.getComment())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getUserName()), GoodsEvaluate::getUserName, goodsEvaluate.getUserName())
                .like(StringUtils.isNotEmpty(goodsEvaluate.getPhone()), GoodsEvaluate::getPhone, goodsEvaluate.getPhone())
                .eq(goodsEvaluate.getStatus() != null, GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
                .orderByDesc(GoodsEvaluate::getCreateTime));
        list.forEach(this::buildDetail);
        return R.ok(list);
        page.getRecords().forEach(this::buildDetail);
        return R.ok(page);
    }
    private void buildDetail(GoodsEvaluate item) {
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java
@@ -111,11 +111,11 @@
            LocalDateTime now = LocalDateTime.now();
            LocalDateTime endTime = record.getEndTime();
            if (endTime.isBefore(now)){
                record.setStatus(2); //已结束
                record.setStatus(3); //已结束
            }else if (startTime.isBefore(now)){
                record.setStatus(1); // 已开始
                record.setStatus(2); // 已开始
            }else {
                record.setStatus(0); // 未开始
                record.setStatus(1); // 未开始
            }
        }
        return R.ok(IPage);
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java
@@ -1,8 +1,23 @@
package com.ruoyi.other.controller;
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.poi.ExcelUtil;
import com.ruoyi.other.api.domain.ShopBalanceStatement;
import com.ruoyi.other.service.ShopBalanceStatementService;
import com.ruoyi.other.vo.ShopCommissionStatisticsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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 javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
 * <p>
@@ -14,7 +29,34 @@
 */
@RestController
@RequestMapping("/shop-balance-statement")
@Api(tags = "管理后台-财务统计-门店分佣统计")
public class ShopBalanceStatementController {
    @Resource
    private ShopBalanceStatementService shopBalanceStatementService;
    /**
     * 门店分佣统计
     */
    @GetMapping("/commissionStatistics")
    @ApiOperation("门店分佣统计")
    public R<ShopCommissionStatisticsVO> shopCommissionStatistics(@ApiParam("页码") @RequestParam Integer pageNum,
                                                                  @ApiParam("每一页数据大小") Integer pageSize,
                                                                  ShopBalanceStatement shopBalanceStatement){
        ShopCommissionStatisticsVO shopCommissionStatisticsVO = shopBalanceStatementService.shopCommissionStatistics(Page.of(pageNum, pageSize), shopBalanceStatement);
        return R.ok(shopCommissionStatisticsVO);
    }
    /**
     * 导出门店分佣统计
     */
    @GetMapping("/export")
    @ApiOperation("导出门店分佣统计")
    public void export(HttpServletResponse response , ShopBalanceStatement shopBalanceStatement){
        ShopCommissionStatisticsVO shopCommissionStatisticsVO = shopBalanceStatementService.shopCommissionStatistics(Page.of(1, Integer.MAX_VALUE), shopBalanceStatement);
        IPage<ShopBalanceStatement> statementIPage = shopCommissionStatisticsVO.getStatementIPage();
        ExcelUtil<ShopBalanceStatement> util = new ExcelUtil<>(ShopBalanceStatement.class);
        util.exportExcel(response, statementIPage.getRecords(), "用户积分统计");
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
@@ -11,7 +11,7 @@
import com.ruoyi.other.service.ShopPointService;
import com.ruoyi.other.vo.ShopPointStatistics;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -41,7 +41,7 @@
     * 门店积分统计
     */
    @GetMapping("/statistics")
    @ApiModelProperty("门店积分统计")
    @ApiOperation(value = "门店积分统计")
    public R<ShopPointStatistics> statistics(ShopPoint shopPoint) {
        ShopPointStatistics statistics = shopPointService.statistics(Page.of(shopPoint.getPageNum(), shopPoint.getPageSize()), shopPoint);
        return R.ok(statistics);
@@ -51,7 +51,7 @@
     * 导出门店积分统计
     */
    @GetMapping("/export")
    @ApiModelProperty("导出门店积分统计")
    @ApiOperation(value = "导出门店积分统计")
    public void export(HttpServletResponse response , ShopPoint shopPoint) {
        ShopPointStatistics statistics = shopPointService.statistics(Page.of(1, Integer.MAX_VALUE), shopPoint);
        if (statistics!=null){
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java
@@ -6,17 +6,18 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.other.api.domain.ShopWithdraw;
import com.ruoyi.other.service.ShopService;
import com.ruoyi.other.service.ShopWithdrawService;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
 * <p>
@@ -35,11 +36,13 @@
    private ShopWithdrawService shopWithdrawService;
    @Resource
    private ShopService shopService;
    @Resource
    private TokenService tokenService;
    /**
     * 提现申请列表
     */
    @RequestMapping("/list")
    @GetMapping("/list")
    @ApiOperation("提现申请列表")
    public R<IPage<ShopWithdraw>> list(@ApiParam("页码") @RequestParam Integer pageNum,
                         @ApiParam("每一页数据大小") Integer pageSize,
@@ -51,6 +54,24 @@
        return R.ok(page);
    }
    /**
     * 审核
     */
    @PostMapping("/audit")
    @ApiOperation("审核")
    public R<Void> audit(@RequestBody ShopWithdraw shopWithdraw) {
        LoginUser loginUser = tokenService.getLoginUser();
        ShopWithdraw shopWithdraw1 = shopWithdrawService.getById(shopWithdraw.getId());
        shopWithdraw1.setAuditStatus(shopWithdraw.getAuditStatus());
        shopWithdraw1.setAuditUserId(loginUser.getUserid());
        shopWithdraw1.setAuditTime(LocalDateTime.now());
        shopWithdraw1.setAuditMsg(shopWithdraw.getAuditMsg());
        shopWithdrawService.updateById(shopWithdraw1);
        return R.ok();
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsBargainPriceMapper.java
@@ -1,7 +1,10 @@
package com.ruoyi.other.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.other.api.domain.GoodsBargainPrice;
import org.apache.ibatis.annotations.Param;
/**
 * <p>
@@ -13,4 +16,6 @@
 */
public interface GoodsBargainPriceMapper extends BaseMapper<GoodsBargainPrice> {
    IPage<GoodsBargainPrice> queryGoodsBargainPricePage(@Param("page") Page<GoodsBargainPrice> page,@Param("gp") GoodsBargainPrice goodsBargainPrice);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java
@@ -1,16 +1,23 @@
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.ShopBalanceStatement;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <p>
 *  Mapper 接口
 * Mapper 接口
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
public interface ShopBalanceStatementMapper extends BaseMapper<ShopBalanceStatement> {
    List<ShopBalanceStatement> findLatestChangeByType(ShopBalanceStatement shopBalanceStatement);
    IPage<ShopBalanceStatement> queryShopBalanceStatementPage(@Param("page") IPage<ShopBalanceStatement> page,
                                                              @Param("bs") ShopBalanceStatement shopBalanceStatement);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsBargainPriceService.java
@@ -1,5 +1,7 @@
package com.ruoyi.other.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.GoodsBargainPrice;
@@ -34,4 +36,6 @@
     */
    R addGoodsBargainPrice(AddGoodsBargainPriceVo vo);
    IPage<GoodsBargainPrice> queryGoodsBargainPricePage(Page<GoodsBargainPrice> page,GoodsBargainPrice goodsBargainPrice);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopBalanceStatementService.java
@@ -1,7 +1,9 @@
package com.ruoyi.other.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.other.api.domain.ShopBalanceStatement;
import com.ruoyi.other.vo.ShopCommissionStatisticsVO;
/**
 * <p>
@@ -12,5 +14,5 @@
 * @since 2024-11-20
 */
public interface ShopBalanceStatementService extends IService<ShopBalanceStatement> {
    ShopCommissionStatisticsVO shopCommissionStatistics(IPage<ShopBalanceStatement> page, ShopBalanceStatement shopBalanceStatement);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsBargainPriceServiceImpl.java
@@ -1,6 +1,8 @@
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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.service.TokenService;
@@ -96,4 +98,9 @@
        goodsBargainPriceDetailService.saveBatch(list);
        return R.ok();
    }
    @Override
    public IPage<GoodsBargainPrice> queryGoodsBargainPricePage(Page<GoodsBargainPrice> page, GoodsBargainPrice goodsBargainPrice) {
        return this.baseMapper.queryGoodsBargainPricePage(page,goodsBargainPrice);
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -28,7 +28,10 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -169,38 +172,55 @@
            if (CollectionUtils.isEmpty(goodsShopList)){
                throw new NullPointerException("请选择指定门店");
            }
            for (GoodsShop goodsShop : goodsShopList) {
                goodsShop.setGoodsId(goods.getId());
                goodsShop.setId(null);
            }
            goodsShopService.saveBatch(goodsShopList);
            saveGoodsShopList(goodsShopList, goods.getId());
        }
        // 指定用户
        List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList();
        if (!CollectionUtils.isEmpty(goodsAppUserList)){
            for (GoodsAppUser goodsAppUser : goodsAppUserList) {
                goodsAppUser.setId(null );
                goodsAppUser.setGoodsId(goods.getId());
            }
            goodsAppUserService.saveBatch(goodsAppUserList);
            saveGoodsAppUserList(goodsAppUserList, goods.getId());
        }
        // 会员价格配置
        List<GoodsVip> goodsVipList = goods.getGoodsVipList();
        for (GoodsVip goodsVip : goodsVipList) {
            goodsVip.setId(null);
            goodsVip.setGoodsId(goods.getId());
        }
        goodsVipService.saveBatch(goodsVipList);
        saveGoodsVipList(goodsVipList, goods.getId());
        // 特殊地区售价设置
        List<GoodsArea> goodsAreaList = goods.getGoodsAreaList();
        if (!CollectionUtils.isEmpty(goodsAreaList)){
            saveGoodsAreaList(goodsAreaList, goods.getId());
        }
    }
    @Override
    public void updateManageGoods(Goods goods) {
        goodsMapper.updateById(goods);
        // 指定门店
        List<GoodsShop> goodsShopList = goods.getGoodsShopList();
        saveGoodsShopList(goodsShopList, goods.getId());
        // 指定用户
        List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList();
        saveGoodsAppUserList(goodsAppUserList, goods.getId());
        // 会员价格配置
        List<GoodsVip> goodsVipList = goods.getGoodsVipList();
        saveGoodsVipList(goodsVipList, goods.getId());
        // 特殊地区售价设置
        List<GoodsArea> goodsAreaList = goods.getGoodsAreaList();
        saveGoodsAreaList(goodsAreaList, goods.getId());
    }
    private void saveGoodsAreaList(List<GoodsArea> goodsAreaList, Integer id) {
        goodsAreaService.remove(new LambdaQueryWrapper<GoodsArea>()
                .eq(GoodsArea::getGoodsId, id));
        if (!CollectionUtils.isEmpty(goodsAreaList)){
            for (GoodsArea goodsArea : goodsAreaList) {
                List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList();
                for (GoodsArea area : goodsAreaList1) {
                    area.setGoodsId(goods.getId());
                    area.setGoodsId(id);
                    area.setProvince(goodsArea.getProvince());
                    area.setCity(goodsArea.getCity());
                    area.setDistricts(goodsArea.getDistricts());
@@ -211,41 +231,40 @@
                goodsAreaService.saveBatch(goodsAreaList1);
            }
        }
    }
    @Override
    public void updateManageGoods(Goods goods) {
        goodsMapper.updateById(goods);
        // 指定门店
        List<GoodsShop> goodsShopList = goods.getGoodsShopList();
        goodsShopService.updateBatchById(goodsShopList);
    private void saveGoodsVipList(List<GoodsVip> goodsVipList, Integer id) {
        goodsVipService.remove(new LambdaQueryWrapper<GoodsVip>()
                .eq(GoodsVip::getGoodsId, id));
        goodsVipList.forEach(item -> {
            item.setId(null);
            item.setGoodsId(id);
        });
        goodsVipService.saveBatch(goodsVipList);
    }
        // 指定用户
        List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList();
        goodsAppUserService.updateBatchById(goodsAppUserList);
        // 会员价格配置
        List<GoodsVip> goodsVipList = goods.getGoodsVipList();
        goodsVipService.updateBatchById(goodsVipList);
        // 特殊地区售价设置
        List<GoodsArea> goodsAreaList = goods.getGoodsAreaList();
        if (!CollectionUtils.isEmpty(goodsAreaList)){
            for (GoodsArea goodsArea : goodsAreaList) {
                List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList();
                for (GoodsArea area : goodsAreaList1) {
                    area.setGoodsId(goods.getId());
                    area.setProvince(goodsArea.getProvince());
                    area.setCity(goodsArea.getCity());
                    area.setDistricts(goodsArea.getDistricts());
                    area.setProvinceCode(goodsArea.getProvinceCode());
                    area.setCityCode(goodsArea.getCityCode());
                    area.setDistrictsCode(goodsArea.getDistrictsCode());
                }
                goodsAreaService.updateBatchById(goodsAreaList1);
    private void saveGoodsAppUserList(List<GoodsAppUser> goodsAppUserList, Integer id) {
        goodsAppUserService.remove(new LambdaQueryWrapper<GoodsAppUser>()
                .eq(GoodsAppUser::getGoodsId, id));
        if (!CollectionUtils.isEmpty(goodsAppUserList)){
            for (GoodsAppUser goodsAppUser : goodsAppUserList) {
                goodsAppUser.setId(null );
                goodsAppUser.setGoodsId(id);
            }
        }
        goodsAppUserService.saveBatch(goodsAppUserList);
    }
    private void saveGoodsShopList(List<GoodsShop> goodsShopList, Integer goodsId) {
        goodsShopService.remove(new LambdaQueryWrapper<GoodsShop>()
                .eq(GoodsShop::getGoodsId, goodsId));
        if (!CollectionUtils.isEmpty(goodsShopList)){
            for (GoodsShop goodsShop : goodsShopList) {
                goodsShop.setGoodsId(goodsId);
                goodsShop.setId(null);
            }
        }
        goodsShopService.saveBatch(goodsShopList);
    }
    @Override
@@ -322,6 +341,9 @@
    private List<VipSetting> getVipSettings(Stream<Integer> goodsVipList) {
        List<Integer> vipIds = goodsVipList.collect(Collectors.toList());
        if (CollectionUtils.isEmpty(vipIds)){
            return new ArrayList<>();
        }
        return vipSettingService.listByIds(vipIds);
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java
@@ -1,10 +1,20 @@
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.other.api.domain.Shop;
import com.ruoyi.other.mapper.ShopBalanceStatementMapper;
import com.ruoyi.other.api.domain.ShopBalanceStatement;
import com.ruoyi.other.service.ShopBalanceStatementService;
import com.ruoyi.other.service.ShopService;
import com.ruoyi.other.vo.ShopCommissionStatisticsVO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
 * <p>
@@ -16,5 +26,35 @@
 */
@Service
public class ShopBalanceStatementServiceImpl extends ServiceImpl<ShopBalanceStatementMapper, ShopBalanceStatement> implements ShopBalanceStatementService {
    @Resource
    private ShopBalanceStatementMapper shopBalanceStatementMapper;
    @Resource
    private ShopService shopService;
    @Override
    public ShopCommissionStatisticsVO shopCommissionStatistics(IPage<ShopBalanceStatement> page, ShopBalanceStatement shopBalanceStatement) {
        List<ShopBalanceStatement> latestChangeByType = shopBalanceStatementMapper.findLatestChangeByType(shopBalanceStatement);
        ShopCommissionStatisticsVO shopCommissionStatisticsVO = new ShopCommissionStatisticsVO();
        for (ShopBalanceStatement sp : latestChangeByType) {
            switch (sp.getType()) {
                case 1:
                    shopCommissionStatisticsVO.setTotalCommission(sp.getBalance());
                    break;
                case 2:
                    shopCommissionStatisticsVO.setTotalSubordinateCommission(sp.getBalance());
                    break;
                case 3:
                    shopCommissionStatisticsVO.setTotalServiceCharge(sp.getBalance());
                    break;
           }
        }
        shopCommissionStatisticsVO.setTotalAmount(shopCommissionStatisticsVO.getTotalCommission()
                .add(shopCommissionStatisticsVO.getTotalSubordinateCommission())
                .add(shopCommissionStatisticsVO.getTotalServiceCharge()));
        IPage<ShopBalanceStatement> statementIPage = this.baseMapper.queryShopBalanceStatementPage(page, shopBalanceStatement);
        shopCommissionStatisticsVO.setStatementIPage(statementIPage);
        return shopCommissionStatisticsVO;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopCommissionStatisticsVO.java
New file
@@ -0,0 +1,40 @@
package com.ruoyi.other.vo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.other.api.domain.ShopBalanceStatement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel("门店分佣统计")
public class ShopCommissionStatisticsVO {
    /**
     * 总金额
     */
    @ApiModelProperty(value = "总金额")
    private BigDecimal totalAmount = BigDecimal.ZERO;
    /**
     * 分佣总金额
     */
    @ApiModelProperty(value = "分佣总金额")
    private BigDecimal totalCommission = BigDecimal.ZERO;
    /**
     * 服务费总计
     */
    @ApiModelProperty(value = "服务费总计")
    private BigDecimal totalServiceCharge = BigDecimal.ZERO;
    /**
     * 下级门店分佣总金额
     */
    @ApiModelProperty(value = "下级门店分佣总金额")
    private BigDecimal totalSubordinateCommission = BigDecimal.ZERO;
    private IPage<ShopBalanceStatement> statementIPage;
}
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsBargainPriceMapper.xml
New file
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.other.mapper.GoodsBargainPriceMapper">
    <select id="queryGoodsBargainPricePage" resultType="com.ruoyi.other.api.domain.GoodsBargainPrice">
        SELECT
            tgbp.*,
            tg.`name` AS goodsName,
            tgc.`name` AS categoryName,
            ts.`name` AS shop_name,
            ts.shop_manager AS ownerName,
            ts.phone AS ownerPhone
        FROM
            t_goods_bargain_price tgbp
                INNER JOIN t_goods tg ON tgbp.goods_id = tg.id and tg.del_flag = 0
                INNER JOIN t_shop ts ON tgbp.shop_id = ts.id and tg.del_flag = 0
                LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id
        where tgbp.del_flag = 0
        <if test="gp.goodsId != null">
            and tgbp.goods_id = #{gp.goodsId}
        </if>
        <if test="gp.goodsName != null and gp.goodsName != ''">
            and tg.`name` like concat('%',#{gp.goodsName},'%')
        </if>
        <if test="gp.goodsType != null and gp.goodsType != ''">
            and tg.`type` = #{gp.goodsType}
        </if>
        <if test="gp.categoryId != null and gp.categoryId != ''">
            and tg.goods_category_id = #{gp.categoryId}
        </if>
        <if test="gp.auditStatus != null and gp.auditStatus != ''">
            and tgbp.audit_status = #{gp.auditStatus}
        </if>
    </select>
</mapper>
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
@@ -57,7 +57,6 @@
        tg.purchase_limit maxNum,
        tg.home_page_picture,
        tg.original_price,
        tgs.selling_price,
        tg.sale_num,
        tg.`type` goodsType,
        tsai.start_time,
@@ -66,15 +65,37 @@
        FROM
        t_seckill_activity_info tsai
        LEFT JOIN t_goods tg ON tsai.good_id = tg.id
        LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id
        LEFT JOIN t_goods_category tgc ON tgc.id = tg.goods_category_id
        WHERE tsai.end_time >= NOW() AND tsai.del_flag = 0
        WHERE tsai.del_flag = 0
        <if test="goods.name != null and goods.name != ''">
            AND tg.`name` LIKE concat('%',#{goods.name},'%')
        </if>
        <if test="goods.goodsCategoryId != null">
            AND tg.goods_category_id = #{goods.goodsCategoryId}
        </if>
        <if test="goods.categoryName != null and goods.categoryName != ''">
            AND tgc.name = #{goods.categoryName}
        </if>
        <if test="goods.showStatus != null">
            AND tsai.is_shelves = #{goods.showStatus}
        </if>
        <if test="goods.type != null">
            AND tg.type = #{goods.type}
        </if>
        <if test="goods.status != null and goods.status ==1">
            AND tsai.start_time <![CDATA[>]]> NOW()
        </if>
        <if test="goods.status != null and goods.status ==2">
            AND tsai.start_time <![CDATA[<=]]> NOW() AND tsai.end_time <![CDATA[>]]> NOW()
        </if>
        <if test="goods.status != null and goods.status ==3">
            AND tsai.end_time <![CDATA[<]]> NOW()
        </if>
        <if test="goods.vipId != null">
            AND find_in_set(#{goods.vipId},tgs.vip) > 0
        </if>
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml
New file
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.other.mapper.ShopBalanceStatementMapper">
    <select id="findLatestChangeByType" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement">
        SELECT
            id,
            shop_id,
            type,
            historical_balance,
            variable_amount,
            balance,
            create_time,
            create_user_id,
            object_id
        FROM
            (
            SELECT
                id,
                shop_id,
                type,
                historical_balance,
                variable_amount,
                balance,
                create_time,
                create_user_id,
                object_id,
                ROW_NUMBER() OVER ( PARTITION BY type, create_user_id ORDER BY create_time DESC ) AS rn
            FROM
                t_shop_balance_statement
            ) AS subquery
        WHERE
            rn = 1
    </select>
    <select id="queryShopBalanceStatementPage" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement">
        SELECT
            tsbs.*,
            ts.`name` shopName,
            ts.shop_manager shopManagerName,
            ts.phone
        FROM
            t_shop_balance_statement tsbs
                INNER JOIN t_shop ts ON ts.id = tsbs.shop_id AND ts.del_flag = 0
        <where>
            <if test="bs.shopName != null and bs.shopName != ''">
                AND ts.`name` like concat('%', #{bs.shopName}, '%')
            </if>
            <if test="bs.shopManagerName != null and bs.shopManagerName != ''">
                AND ts.shop_manager like concat('%', #{bs.shopManagerName}, '%')
            </if>
            <if test="bs.phone != null and bs.phone != ''">
                AND ts.phone like concat('%', #{bs.phone}, '%')
            </if>
            <if test="bs.type != null">
                AND tsbs.type = #{bs.type}
            </if>
            <if test="bs.startTime != null and bs.endTime != null">
                AND tsbs.create_time BETWEEN #{bs.startTime} AND #{bs.endTime}
            </if>
        </where>
    </select>
</mapper>
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
@@ -23,7 +23,7 @@
                    create_time,
                    create_user_id,
                    object_id,
                    ROW_NUMBER() OVER ( PARTITION BY type ORDER BY create_time DESC ) AS rn
                    ROW_NUMBER() OVER ( PARTITION BY type,create_user_id ORDER BY create_time DESC ) AS rn
                FROM
                    t_shop_point