From 49f2eff2cf52e0f1719dfad43cafff11b378252c Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 20 十二月 2024 18:14:26 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java | 6 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 108 - ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java | 4 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/ShopBalanceDto.java | 21 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java | 4 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java | 5 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 33 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/AuthPassStatus.java | 18 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 18 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml | 18 ruoyi-modules/ruoyi-system/pom.xml | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java | 5 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java | 6 ruoyi-service/pom.xml | 2 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java | 4 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AgentApplicationServiceImpl.java | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionDetail.java | 72 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmDelivery.java | 18 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java | 5 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java | 3 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java | 6 ruoyi-service/ruoyi-order/pom.xml | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java | 43 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderStatistics.java | 60 + ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java | 116 +- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatisticsDetail.java | 54 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java | 16 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 1066 +++++++++++++------------ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatisticsDetail.java | 70 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Banner.java | 4 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 19 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/RefundPassInfo.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java | 14 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopStatistics.java | 89 ++ ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml | 10 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml | 51 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatistics.java | 27 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 50 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java | 8 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java | 24 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java | 2 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java | 5 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java | 108 ++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java | 6 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RechargeDto.java | 16 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatistics.java | 75 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java | 80 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java | 49 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalanceChangeRecordService.java | 4 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java | 2 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java | 4 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java | 9 ruoyi-service/ruoyi-other/pom.xml | 12 ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml | 36 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java | 8 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java | 2 61 files changed, 1,730 insertions(+), 783 deletions(-) diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java index 9499843..1e4f31e 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java @@ -179,6 +179,22 @@ @TableField("total_register_point") private Integer totalRegisterPoint; + @ApiModelProperty(value = "门店业绩积分") + @TableField("shop_achievement_point") + private Integer shopAchievementPoint; + + @ApiModelProperty(value = "门店返佣积分") + @TableField("shop_share_point") + private Integer shopSharePoint; + + @ApiModelProperty(value = "门店服务费(门店核销获得)") + @TableField("shop_service_fee") + private BigDecimal shopServiceFee; + + @ApiModelProperty(value = "门店返佣金额(绑定用户消费后返佣)") + @TableField("shop_commission") + private BigDecimal shopCommission; + // @ApiModelProperty(value = "做工积分总数") // @TableField("total_work_point") // private Integer totalWorkPoint; @@ -200,13 +216,13 @@ private Integer totalPerformancePoint; - @ApiModelProperty(value = "剩余积分") - @TableField("lave_point") - private Integer lavePoint; - @ApiModelProperty(value = "总积分") @TableField("total_point") private Integer totalPoint; + + @ApiModelProperty(value = "剩余积分(可用于消费的积分)") + @TableField("lave_point") + private Integer lavePoint; @ApiModelProperty(value = "是否可更换推广人(0=否,1=是)") @TableField("change_promoter") diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java index 44f58b2..15ee0ab 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java @@ -81,4 +81,8 @@ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime endTime; + @ApiModelProperty(value = "门店名称") + @TableField(exist = false) + private String shopName; + } diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java index ad2a4a3..a1c7158 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java @@ -66,6 +66,10 @@ @TableField("object_id") private Long objectId; + @ApiModelProperty(value = "拓展字段") + @TableField("extention") + private String extention; + @ApiModelProperty(value = "用户名称") @TableField(exist = false) private String userName; diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java index da4c39e..9e0fa5d 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java @@ -29,6 +29,8 @@ @ApiModelProperty(value = "主键") @TableId(value = "id", type = IdType.AUTO) private Long id; + @TableField(exist = false) + private String idStr; @ApiModelProperty(value = "删除标志(0=否,1=是)") @TableField("del_flag") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Banner.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Banner.java index 9bab6e6..1a47a93 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Banner.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Banner.java @@ -37,6 +37,10 @@ @TableField("name") private String name; + @ApiModelProperty(value = "1图片2视频") + @TableField("content_type") + private Integer contentType; + @ApiModelProperty(value = "跳转类型(1=无跳转,2=外部链接,3=商品详情,4=秒杀商品详情,5=领券中心)") @TableField("jump_type") private Integer jumpType; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java index 37a518d..9b4068a 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java @@ -110,10 +110,6 @@ @TableField("server_point") private Integer serverPoint; - @ApiModelProperty(value = "下级门店返佣积分") - @TableField("lower_level_rebate_points") - private Integer lowerLevelRebatePoints; - @ApiModelProperty(value = "门店已用积分") @TableField("use_point") private Integer usePoint; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java index 377b1c6..9a97e0a 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java @@ -41,7 +41,7 @@ @ApiModelProperty(value = "变动类型(1=门店分佣,2=下级门店分佣,3=门店服务费)") @TableField("type") - @Excel(name = "变更类型",readConverterExp = "1=门店分佣,2=下级门店分佣,3=门店服务费") + @Excel(name = "变更类型",readConverterExp = "1=门店分佣,2=下级门店分佣,3=门店服务费,4=关联用户分佣") private Integer type; @ApiModelProperty(value = "历史余额") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java index cf885bf..8082908 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java @@ -56,6 +56,7 @@ @ApiModelProperty(value = "变动时间") @TableField("create_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "变动时间") private LocalDateTime createTime; @@ -67,6 +68,10 @@ @TableField("object_id") private Long objectId; + @ApiModelProperty(value = "订单号") + @TableField("order_num") + private String orderNum; + @ApiModelProperty(value = "门店名称") @TableField(exist = false) @Excel(name = "门店名称") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java index 8319da3..1c2144f 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java @@ -2,6 +2,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.domain.ShopBalanceStatement; import com.ruoyi.other.api.feignClient.ShopClient; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.openfeign.FallbackFactory; @@ -38,6 +39,11 @@ public R<Set<Integer>> getShopIdByName(String shopName) { return R.fail("根据门店名称获取门店id失败:" + cause.getMessage()); } + + @Override + public R<List<ShopBalanceStatement>> getShopBalanceStatementList(ShopBalanceStatement shopBalanceStatement) { + return R.fail(); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java index cf409f1..3019063 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.domain.ShopBalanceStatement; import com.ruoyi.other.api.factory.ShopClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -42,8 +43,11 @@ R<Shop> getShopByPhone(@RequestParam("phone") String phone); @PostMapping("/getShopByUserIds") - public R<List<Shop>> getShopByUserIds(@RequestBody List<Long> userIds); + R<List<Shop>> getShopByUserIds(@RequestBody List<Long> userIds); @GetMapping("/getShopIdByName") R<Set<Integer>> getShopIdByName(String shopName); + + @PostMapping("/shop-balance-statement/getList") + R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestBody ShopBalanceStatement shopBalanceStatement); } diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index 99da1f2..ce2efe3 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -102,7 +102,7 @@ <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-spring-boot-starter</artifactId> - <version>4.0.0</version> + <version>4.1.2</version> <exclusions> <exclusion> <artifactId>guava</artifactId> diff --git a/ruoyi-service/pom.xml b/ruoyi-service/pom.xml index a177aa0..9939f3d 100644 --- a/ruoyi-service/pom.xml +++ b/ruoyi-service/pom.xml @@ -38,7 +38,7 @@ <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-spring-boot-starter</artifactId> - <version>4.0.0</version> + <version>4.1.2</version> <exclusions> <exclusion> <artifactId>guava</artifactId> diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java index e0d3393..44a756b 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java @@ -6,6 +6,7 @@ import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.api.model.UserCoupon; import com.ruoyi.account.api.model.UserSignRecord; +import com.ruoyi.account.mapper.AppUserMapper; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserCancellationLogService; import com.ruoyi.account.service.UserCouponService; @@ -33,10 +34,10 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import com.ruoyi.account.vo.*; import com.ruoyi.common.core.web.controller.BaseController; @@ -45,7 +46,7 @@ /** * <p> - * 前端控制器 + * 前端控制器 * </p> * * @author luodangjia @@ -57,580 +58,617 @@ public class AppUserController extends BaseController { + @Resource + private TokenService tokenService; + @Resource + private AppUserService appUserService; + @Resource + private StoreClient storeClient; + @Resource + private UserCouponService userCouponService; - @Resource - private TokenService tokenService; - @Resource - private AppUserService appUserService; - @Resource - private StoreClient storeClient; - @Resource - private UserCouponService userCouponService; - - @Resource - private UserSignRecordService userSignRecordService; - @Resource - private VipSettingClient vipSettingClient; - @Resource - private UserPointService userPointService; - @Resource - private VipSettingService vipSettingService; + @Resource + private UserSignRecordService userSignRecordService; + @Resource + private VipSettingClient vipSettingClient; + @Resource + private UserPointService userPointService; + @Resource + private VipSettingService vipSettingService; + @Resource + private AppUserMapper appUserMapper; - @ResponseBody - @PostMapping("/mobileLogin") - @ApiOperation(value = "手机号登录") - public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){ - return appUserService.mobileLogin(mobileLogin); - } + @ResponseBody + @PostMapping("/mobileLogin") + @ApiOperation(value = "手机号登录") + public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin) { + return appUserService.mobileLogin(mobileLogin); + } + @ResponseBody + @PostMapping("/appletLogin") + @ApiOperation(value = "小程序一键登录") + public R<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin) { + return appUserService.appletLogin(appletLogin); + } + @ResponseBody + @PostMapping("/getAppUserById") + public AppUser getAppUserById(@RequestParam("id") Long id) { + return appUserService.getById(id); + } + + @ResponseBody + @PostMapping("/editAppUserById") + public R<Void> editAppUserById(@RequestBody AppUser appUser) { + appUserService.updateById(appUser); + return R.ok(); + + } + + @ResponseBody + @PostMapping("/getTopUsers") + public R<List<AppUser>> getTopUsers(@RequestBody AppUser appUser) { + List<Integer> vipIds = new ArrayList<>(); + vipIds.add(5); + vipIds.add(6); + vipIds.add(7); + List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list(); + return R.ok(list); + + } + + @ResponseBody + @PostMapping("/getCouponCount") + public R<Long> getCouponCount(@RequestParam("userId") Long userId, @RequestParam("couponId") Integer couponId) { + Long count = userCouponService.lambdaQuery().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getCouponId, couponId).count(); + return R.ok(count); + } + + @ResponseBody + @PostMapping("/getVipCount") + public R<Long> getVipCount(@RequestParam("userId") Long userId, @RequestParam("vipId") Integer vipId) { + Long count = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).eq(AppUser::getVipId, vipId).count(); + return R.ok(count); + } - @ResponseBody - @PostMapping("/appletLogin") - @ApiOperation(value = "小程序一键登录") - public R<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin){ - return appUserService.appletLogin(appletLogin); - } - - - @ResponseBody - @PostMapping("/getAppUserById") - public AppUser getAppUserById(@RequestParam("id") Long id){ - return appUserService.getById(id); - } - - @ResponseBody - @PostMapping("/editAppUserById") - public R<Void> editAppUserById(@RequestBody AppUser appUser) { - appUserService.updateById(appUser); - return R.ok(); - - } - - @ResponseBody - @PostMapping("/getTopUsers") - public R<List<AppUser>> getTopUsers(@RequestBody AppUser appUser) { - List<Integer> vipIds = new ArrayList<>(); - vipIds.add(5); - vipIds.add(6); - vipIds.add(7); - List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list(); - return R.ok(list); - - } - - @ResponseBody - @PostMapping("/getCouponCount") - public R<Long> getCouponCount(@RequestParam("userId")Long userId, @RequestParam("couponId") Integer couponId ){ - Long count = userCouponService.lambdaQuery().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getCouponId, couponId).count(); - return R.ok(count); - } - - @ResponseBody - @PostMapping("/getVipCount") - public R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId ){ - Long count = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).eq(AppUser::getVipId, vipId).count(); - return R.ok(count); - } + @ResponseBody + @PostMapping("/getSMSCode") + @ApiOperation(value = "获取短信验证码") + public R getSMSCode(@RequestBody SMSCode smsCode) { + return appUserService.getSMSCode(smsCode); + } - - - @ResponseBody - @PostMapping("/getSMSCode") - @ApiOperation(value = "获取短信验证码") - public R getSMSCode(@RequestBody SMSCode smsCode){ - return appUserService.getSMSCode(smsCode); - } + @ResponseBody + @PostMapping("/registerAccount") + @ApiOperation(value = "注册新账号") + public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount) { + return appUserService.registerAccount(registerAccount); + } - - @ResponseBody - @PostMapping("/registerAccount") - @ApiOperation(value = "注册新账号") - public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount){ - return appUserService.registerAccount(registerAccount); - } + @ResponseBody + @GetMapping("/getReferrer/{id}") + @ApiOperation(value = "获取推荐人信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long") + }) + public R<String> getReferrer(@PathVariable("id") Long id) { + AppUser appUser = appUserService.getById(id); + String phone = appUser.getPhone(); + phone = phone.substring(0, 3) + "****" + phone.substring(7); + return R.ok(appUser.getName() + "-" + phone); + } - @ResponseBody - @GetMapping("/getReferrer/{id}") - @ApiOperation(value = "获取推荐人信息") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long") - }) - public R<String> getReferrer(@PathVariable("id") Long id){ - AppUser appUser = appUserService.getById(id); - String phone = appUser.getPhone(); - phone = phone.substring(0, 3) + "****" + phone.substring(7); - return R.ok(appUser.getName() + "-" + phone); - } + @ResponseBody + @GetMapping("/getNearbyReferrer") + @ApiOperation(value = "获取附近推荐人列表") + public TableDataInfo<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer) { + startPage(); + List<NearbyReferrerVo> list = appUserService.getNearbyReferrer(nearbyReferrer); + return getDataTable(list); + } + @ResponseBody + @PostMapping("/info") + @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"}) + public R<AppUser> info() { + Long userId = tokenService.getLoginUserApplet().getUserid(); + AppUser user = appUserService.getById(userId); + return R.ok(user); + } - @ResponseBody - @GetMapping("/getNearbyReferrer") - @ApiOperation(value = "获取附近推荐人列表") - public TableDataInfo<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer){ - startPage(); - List<NearbyReferrerVo> list = appUserService.getNearbyReferrer(nearbyReferrer); - return getDataTable(list); - } + @Resource + private UserCancellationLogService userCancellationLogService; + + @ResponseBody + @GetMapping("/unregis") + @ApiOperation(value = "注销", tags = {"小程序-个人中心首页-我的资料"}) + public R unregis() { + Long userId = tokenService.getLoginUserApplet().getUserid(); + AppUser user = appUserService.getById(userId); + + //添加注销记录 + UserCancellationLog userCancellationLog = new UserCancellationLog(); + userCancellationLog.setAppUserId(user.getId()); + userCancellationLog.setVipId(user.getVipId()); + userCancellationLogService.save(userCancellationLog); - @ResponseBody - @PostMapping("/info") - @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"}) - public R<AppUser> info(){ - Long userId = tokenService.getLoginUserApplet().getUserid(); - AppUser user = appUserService.getById(userId); - return R.ok(user); - } - @Resource - private UserCancellationLogService userCancellationLogService; - - @ResponseBody - @GetMapping("/unregis") - @ApiOperation(value = "注销", tags = {"小程序-个人中心首页-我的资料"}) - public R unregis(){ - Long userId = tokenService.getLoginUserApplet().getUserid(); - AppUser user = appUserService.getById(userId); - - //添加注销记录 - UserCancellationLog userCancellationLog = new UserCancellationLog(); - userCancellationLog.setAppUserId(user.getId()); - userCancellationLog.setVipId(user.getVipId()); - userCancellationLogService.save(userCancellationLog); + return R.ok(); + } - return R.ok(); - } + @ResponseBody + @GetMapping("/recommend") + @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) + public R<AppUser> recommend() { + Long userId = tokenService.getLoginUserApplet().getUserid(); + //获取绑定门店 + AppUser user = appUserService.getById(userId); + if (user.getShopId() != null) { + R<Shop> storeById = storeClient.getStoreById(user.getShopId()); + if (storeById.getData() != null) { + user.setShopName(storeById.getData().getName()); + user.setShopCover(storeById.getData().getHomePicture()); + user.setShopAddress(storeById.getData().getAddress()); + } + } + //获取绑定上级 + if (user.getInviteUserId() != null) { + AppUser byId = appUserService.getById(user.getInviteUserId()); + user.setTopUser(byId); + } + //获取绑定下级列表 + List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, user.getInviteUserId()).list(); + for (AppUser appUser : list) { + Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, 1).count(); + Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getTopInviteId, userId).count(); + Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getTopInviteId, userId).count(); + Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getTopInviteId, userId).count(); + Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getTopInviteId, userId).count(); + Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getTopInviteId, userId).count(); + Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getTopInviteId, userId).count(); + appUser.setCount1(count1); + appUser.setCount2(count2); + appUser.setCount3(count3); + appUser.setCount4(count4); + appUser.setCount5(count5); + appUser.setCount6(count6); + appUser.setCount7(count7); + } + user.setBottomUsers(list); + return R.ok(user); + } - @ResponseBody - @GetMapping("/recommend") - @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) - public R<AppUser> recommend(){ - Long userId = tokenService.getLoginUserApplet().getUserid(); - //获取绑定门店 - AppUser user = appUserService.getById(userId); - if (user.getShopId()!=null){ - R<Shop> storeById = storeClient.getStoreById(user.getShopId()); - if (storeById.getData()!=null){ - user.setShopName(storeById.getData().getName()); - user.setShopCover(storeById.getData().getHomePicture()); - user.setShopAddress(storeById.getData().getAddress()); - } - } - - //获取绑定上级 - if (user.getInviteUserId()!=null) { - AppUser byId = appUserService.getById(user.getInviteUserId()); - user.setTopUser(byId); - } - //获取绑定下级列表 - List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, user.getInviteUserId()).list(); - for (AppUser appUser : list) { - Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, 1).count(); - Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getTopInviteId, userId).count(); - Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getTopInviteId, userId).count(); - Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getTopInviteId, userId).count(); - Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getTopInviteId, userId).count(); - Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getTopInviteId, userId).count(); - Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getTopInviteId, userId).count(); - appUser.setCount1(count1); - appUser.setCount2(count2); - appUser.setCount3(count3); - appUser.setCount4(count4); - appUser.setCount5(count5); - appUser.setCount6(count6); - appUser.setCount7(count7); - } - user.setBottomUsers(list); - - return R.ok(user); - } - - @ResponseBody - @GetMapping("/change") - @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) - public R<AppUser> change(@ApiParam("换绑用户手机号") String phone){ - Long userId1 = tokenService.getLoginUserApplet().getUserid(); + @ResponseBody + @GetMapping("/change") + @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) + public R<AppUser> change(@ApiParam("换绑用户手机号") String phone) { + Long userId1 = tokenService.getLoginUserApplet().getUserid(); AppUser byId = appUserService.getById(userId1); //获取绑定门店 - AppUser user = appUserService.lambdaQuery().eq(AppUser::getPhone,phone).one(); - if (user==null){ - return R.fail("当前手机号未注册"); - } + AppUser user = appUserService.lambdaQuery().eq(AppUser::getPhone, phone).one(); + if (user == null) { + return R.fail("当前手机号未注册"); + } byId.setInviteUserId(user.getId()); - appUserService.updateById(byId); - return R.ok(); - } - + appUserService.updateById(byId); + return R.ok(); + } @GetMapping("/index") - @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) - public R<AppUser> index(){ + @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) + public R<AppUser> index() { System.err.println("=-===="); Long userId = tokenService.getLoginUserApplet().getUserid(); - //当前用户信息 - AppUser user = appUserService.getById(userId); - //当前用户的推荐人信息 - if (user.getInviteUserId()!=null){ - AppUser inviteUser = appUserService.getById(user.getInviteUserId()); - user.setInviteUserName(inviteUser.getName()); - } - //当前绑定门店的店铺信息 - if (user.getShopId()!=null){ - R<Shop> storeById = storeClient.getStoreById(user.getShopId()); - if (storeById.getData()!=null){ - user.setShopName(storeById.getData().getName()); - } - } - Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, 1).count(); - Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getTopInviteId, userId).count(); - Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getTopInviteId, userId).count(); - Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getTopInviteId, userId).count(); - Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getTopInviteId, userId).count(); - Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getTopInviteId, userId).count(); - Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getTopInviteId, userId).count(); - user.setCount1(count1); - user.setCount2(count2); - user.setCount3(count3); - user.setCount4(count4); - user.setCount5(count5); - user.setCount6(count6); - user.setCount7(count7); + //当前用户信息 + AppUser user = appUserService.getById(userId); + //当前用户的推荐人信息 + if (user.getInviteUserId() != null) { + AppUser inviteUser = appUserService.getById(user.getInviteUserId()); + user.setInviteUserName(inviteUser.getName()); + } + //当前绑定门店的店铺信息 + if (user.getShopId() != null) { + R<Shop> storeById = storeClient.getStoreById(user.getShopId()); + if (storeById.getData() != null) { + user.setShopName(storeById.getData().getName()); + } + } + Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, 1).count(); + Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getTopInviteId, userId).count(); + Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getTopInviteId, userId).count(); + Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getTopInviteId, userId).count(); + Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getTopInviteId, userId).count(); + Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getTopInviteId, userId).count(); + Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getTopInviteId, userId).count(); + user.setCount1(count1); + user.setCount2(count2); + user.setCount3(count3); + user.setCount4(count4); + user.setCount5(count5); + user.setCount6(count6); + user.setCount7(count7); List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()).list(); - if (!list.isEmpty()){ + if (!list.isEmpty()) { user.setIsSign(1); - }else { + } else { user.setIsSign(0); } - return R.ok(user); + return R.ok(user); - } + } - @GetMapping("/index/change") - @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"}) - public R<AppUser> indexchange(String avatar,String name){ - Long userId = tokenService.getLoginUserApplet().getUserid(); - //当前用户信息 - AppUser user = appUserService.getById(userId); - user.setName(name); - user.setAvatar(avatar); - appUserService.updateById(user); - return R.ok(); - } - /** - * 获取用户的祖籍列表 - */ - @GetMapping("/getUserAncestorList") - public R<List<AppUser>> getUserAncestorList(Long id){ - List<AppUser> list = appUserService.getUserAncestorList(id,null); - return R.ok(list); - } + @GetMapping("/index/change") + @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"}) + public R<AppUser> indexchange(String avatar, String name) { + Long userId = tokenService.getLoginUserApplet().getUserid(); + //当前用户信息 + AppUser user = appUserService.getById(userId); + user.setName(name); + user.setAvatar(avatar); + appUserService.updateById(user); + return R.ok(); + } - /** - * 获取用户的直帮上级用户 - */ - @ResponseBody - @PostMapping("/getSuperiorLeader") - @ApiOperation(value = "获取用户的直帮上级用户") - public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) { - AppUser superiorLeader = appUserService.getSuperiorLeader(id); - return R.ok(superiorLeader); - } - - - - @ResponseBody - @PostMapping("/onlineRecord") - @ApiOperation(value = "10分钟定时任务调用,记录用户在线时长", tags = {"小程序-个人中心首页"}) - public R onlineRecord(){ - appUserService.onlineRecord(); - return R.ok(); - } - - - - - - /** - * 根据用户名称模糊搜索用户列表 - * @param name - * @return - */ - @PostMapping("/getAppUserByName") - public R<List<AppUser>> getAppUserByName(@RequestParam("name") String name){ - List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) - .like(AppUser::getName, name)); - return R.ok(list); - } - - /** - * 根据用户电话模糊搜索用户列表 - * @param phone - * @return - */ - @PostMapping("/getAppUserByPhone") - public R<List<AppUser>> getAppUserByPhone(@RequestParam("phone") String phone){ - List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) - .like(AppUser::getPhone, phone)); - return R.ok(list); - } + /** + * 获取用户的祖籍列表 + */ + @GetMapping("/getUserAncestorList") + public R<List<AppUser>> getUserAncestorList(Long id) { + List<AppUser> list = appUserService.getUserAncestorList(id, null); + return R.ok(list); + } - /** - * 获取用户列表 - */ - @GetMapping("/getAppuserPage") - @ApiOperation(value = "用户列表", tags = {"管理后台"}) - public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, - @ApiParam("每一页数据大小") Integer pageSize, - AppUser appUser) - { - IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser); - return R.ok(appuserPage); - } - - @GetMapping("/shop/getAppuserPage") - @ApiOperation(value = "用户列表", tags = {"门店后台"}) - public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, - @ApiParam("每一页数据大小") Integer pageSize, - AppUser appUser) - { - Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); - - List<Long> userIds = new ArrayList<>(); - userIds.add(-1L); - //获取在该本店下单的用户ids - R<List<Order>> listR = remoteOrderGoodsClient.byShopId(objectId); - for (Order datum : listR.getData()) { - userIds.add(datum.getAppUserId()); - } - IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageNum, pageSize, appUser,objectId,userIds); - return R.ok(appuserPage); - } + /** + * 获取用户的直帮上级用户 + */ + @ResponseBody + @PostMapping("/getSuperiorLeader") + @ApiOperation(value = "获取用户的直帮上级用户") + public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) { + AppUser superiorLeader = appUserService.getSuperiorLeader(id); + return R.ok(superiorLeader); + } - - @GetMapping("/danger/info") - @ApiOperation(value = "用户列表-保级条件详情", tags = {"管理后台"}) - public R<DangerInfoDto> dangerinfo(Long id) - { - AppUser byId = appUserService.getById(id); - LocalDate now = LocalDate.now(); - R<VipSetting> vipSetting = vipSettingClient.getVipSetting(byId.getVipId()); - VipSetting data = vipSetting.getData(); - DangerInfoDto dangerInfoDto = new DangerInfoDto(); - BeanUtils.copyProperties(data,dangerInfoDto); - List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,1).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); - List<UserPoint> list2 = userPointService.lambdaQuery().eq(UserPoint::getType,2).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); - List<UserPoint> list3 = userPointService.lambdaQuery().eq(UserPoint::getType,5).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); - Integer userKeepBuyPoint = 0; - for (UserPoint userPoint : list1) { - userKeepBuyPoint = userPoint.getVariablePoint()+userKeepBuyPoint; - } - Integer userKeepSharePoint = 0; - for (UserPoint userPoint : list2) { - userKeepSharePoint = userPoint.getVariablePoint()+userKeepSharePoint; - } - Integer userKeepShopPoint = 0; - for (UserPoint userPoint : list3) { - userKeepShopPoint = userPoint.getVariablePoint()+userKeepShopPoint; - } - dangerInfoDto.setUserKeepBuyPoint(userKeepBuyPoint); - dangerInfoDto.setUserKeepSharePoint(userKeepSharePoint); - dangerInfoDto.setUserKeepShopPoint(userKeepShopPoint); - return R.ok(dangerInfoDto); - } + @ResponseBody + @PostMapping("/onlineRecord") + @ApiOperation(value = "10分钟定时任务调用,记录用户在线时长", tags = {"小程序-个人中心首页"}) + public R onlineRecord() { + appUserService.onlineRecord(); + return R.ok(); + } - @GetMapping("/danger/down") - @ApiOperation(value = "用户列表-保级条件降级", tags = {"管理后台"}) - public R down(Long id) - { - AppUser byId = appUserService.getById(id); - byId.setVipId(byId.getVipId()-1); - appUserService.updateById(byId); - //执行降级标记代码 - new Thread(new Runnable() { - @Override - public void run() { - { - vipSettingService.downUsers(); - } - } - } - ).start(); - return R.ok(); - } - @GetMapping("/frozen") - @ApiOperation(value = "用户列表-冻结解冻", tags = {"管理后台"}) - public R frozen(Long id,@ApiParam("1=正常,2=冻结")Integer status) - { - AppUser byId = appUserService.getById(id); - byId.setStatus(status); - appUserService.updateById(byId); - return R.ok(); - } + /** + * 根据用户名称模糊搜索用户列表 + * + * @param name + * @return + */ + @PostMapping("/getAppUserByName") + public R<List<AppUser>> getAppUserByName(@RequestParam("name") String name) { + List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) + .like(AppUser::getName, name)); + return R.ok(list); + } - @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); - } + /** + * 根据用户电话模糊搜索用户列表 + * + * @param phone + * @return + */ + @PostMapping("/getAppUserByPhone") + public R<List<AppUser>> getAppUserByPhone(@RequestParam("phone") String phone) { + List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) + .like(AppUser::getPhone, phone)); + return R.ok(list); + } - @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(); - } + /** + * 获取用户列表 + */ + @GetMapping("/getAppuserPage") + @ApiOperation(value = "用户列表", tags = {"管理后台"}) + public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + AppUser appUser) { + IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser); + return R.ok(appuserPage); + } + + @GetMapping("/shop/getAppuserPage") + @ApiOperation(value = "用户列表", tags = {"门店后台"}) + public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + AppUser appUser) { + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + + List<Long> userIds = new ArrayList<>(); + userIds.add(-1L); + //获取在该本店下单的用户ids + R<List<Order>> listR = remoteOrderGoodsClient.byShopId(objectId); + for (Order datum : listR.getData()) { + userIds.add(datum.getAppUserId()); + } + IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageNum, pageSize, appUser, objectId, userIds); + return R.ok(appuserPage); + } - public Long getTop(Long inviteId){ - AppUser byId = appUserService.getById(inviteId); - if (byId!=null){ - return getTop(byId.getInviteUserId()); - }else { - return inviteId; - } - } + @GetMapping("/danger/info") + @ApiOperation(value = "用户列表-保级条件详情", tags = {"管理后台"}) + public R<DangerInfoDto> dangerinfo(Long id) { + AppUser byId = appUserService.getById(id); + LocalDate now = LocalDate.now(); + R<VipSetting> vipSetting = vipSettingClient.getVipSetting(byId.getVipId()); + VipSetting data = vipSetting.getData(); + DangerInfoDto dangerInfoDto = new DangerInfoDto(); + BeanUtils.copyProperties(data, dangerInfoDto); + List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType, 1).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); + List<UserPoint> list2 = userPointService.lambdaQuery().eq(UserPoint::getType, 2).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); + List<UserPoint> list3 = userPointService.lambdaQuery().eq(UserPoint::getType, 5).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); + Integer userKeepBuyPoint = 0; + for (UserPoint userPoint : list1) { + userKeepBuyPoint = userPoint.getVariablePoint() + userKeepBuyPoint; + } + Integer userKeepSharePoint = 0; + for (UserPoint userPoint : list2) { + userKeepSharePoint = userPoint.getVariablePoint() + userKeepSharePoint; + } + Integer userKeepShopPoint = 0; + for (UserPoint userPoint : list3) { + userKeepShopPoint = userPoint.getVariablePoint() + userKeepShopPoint; + } + dangerInfoDto.setUserKeepBuyPoint(userKeepBuyPoint); + dangerInfoDto.setUserKeepSharePoint(userKeepSharePoint); + dangerInfoDto.setUserKeepShopPoint(userKeepShopPoint); + return R.ok(dangerInfoDto); + } + @GetMapping("/danger/down") + @ApiOperation(value = "用户列表-保级条件降级", tags = {"管理后台"}) + public R down(Long id) { + AppUser byId = appUserService.getById(id); + byId.setVipId(byId.getVipId() - 1); + appUserService.updateById(byId); + //执行降级标记代码 + new Thread(new Runnable() { + @Override + public void run() { + { + vipSettingService.downUsers(); + } + } + } + ).start(); + return R.ok(); + } + + @GetMapping("/frozen") + @ApiOperation(value = "用户列表-冻结解冻", tags = {"管理后台"}) + public R frozen(Long id, @ApiParam("1=正常,2=冻结") Integer status) { + AppUser byId = appUserService.getById(id); + byId.setStatus(status); + 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(); + } - - @Resource - private ShopClient shopClient; - @Resource - private RemoteOrderGoodsClient remoteOrderGoodsClient; - - @GetMapping("/detail") - @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) - public R<AppUser> detail(Long id) - { - AppUser byId = appUserService.getById(id); - if (byId.getShopId()!=null) { - R<Shop> shopById = shopClient.getShopById(Integer.parseInt(String.valueOf(byId.getShopId()))); - if (shopById.getData()!=null) { - byId.setShopName(shopById.getData().getName()); - } - } - R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); - if (shopByUserId.getData()!=null) { - List<String> shopName = new ArrayList<>(); - for (Shop datum : shopByUserId.getData()) { - shopName.add(datum.getName()); - } - byId.setShopNames(shopName); - } - //推广人 - if (byId.getInviteUserId()!=null) { - AppUser byId1 = appUserService.getById(byId.getInviteUserId()); - byId1.setInviteUserName(byId1.getInviteUserName()); - } - //最后下单时间 - R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id); - 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) - { - //绑定下级 - Page<AppUser> page = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).page(Page.of(pageNum, pageSize)); - return R.ok(page); - - } - - @GetMapping("/orders") - @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"}) - public R<List<Order>> orders(Long id) - { - R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id); - return R.ok(listR.getData()); - - } + 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 + private RemoteOrderGoodsClient remoteOrderGoodsClient; + + @GetMapping("/detail") + @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) + public R<AppUser> detail(Long id) { + AppUser byId = appUserService.getById(id); + if (byId.getShopId() != null) { + R<Shop> shopById = shopClient.getShopById(Integer.parseInt(String.valueOf(byId.getShopId()))); + if (shopById.getData() != null) { + byId.setShopName(shopById.getData().getName()); + } + } + R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); + if (shopByUserId.getData() != null) { + List<String> shopName = new ArrayList<>(); + for (Shop datum : shopByUserId.getData()) { + shopName.add(datum.getName()); + } + byId.setShopNames(shopName); + } + //推广人 + if (byId.getInviteUserId() != null) { + AppUser byId1 = appUserService.getById(byId.getInviteUserId()); + byId1.setInviteUserName(byId1.getInviteUserName()); + } + //最后下单时间 + R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id); + 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) { + //绑定下级 + Page<AppUser> page = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).page(Page.of(pageNum, pageSize)); + return R.ok(page); + + } + + @GetMapping("/orders") + @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"}) + public R<List<Order>> orders(Long id) { + R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id); + return R.ok(listR.getData()); + + } + @GetMapping("/listByIds") + List<AppUser> listByIds(@RequestParam("ids") List<Long> ids) { + List<AppUser> appUsers = appUserService.listByIds(ids); + return appUsers; + } + @PostMapping("/getAppUserByPhone1") + public R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone) { + AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) + .eq(AppUser::getPhone, phone)); + return R.ok(appUser); + } + + /** + * 用户统计 + */ + @GetMapping("/statistics") + @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) + public R<UserStatistics> statistics() { + UserStatistics userStatistics = appUserMapper.getUserStatistics(); + return R.ok(userStatistics); + } + + /** + * 用户统计详情 + */ + @GetMapping("/statistics/detail") + @ApiOperation(value = "用户统计详情", tags = {"管理后台-首页统计-用户统计详情"}) + public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) { + UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId); + return R.ok(userStatisticsDetail); + } - @GetMapping("/listByIds") - List<AppUser> listByIds(@RequestParam("ids") List<Long> ids){ - List<AppUser> appUsers = appUserService.listByIds(ids); - return appUsers; - } - - - - @PostMapping("/getAppUserByPhone1") - public R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone){ - AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) - .eq(AppUser::getPhone, phone)); - return R.ok(appUser); - } + /** + * 分佣统计明细 + */ + @GetMapping("/commissionDetail") + @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计") + public R<CommissionDetail> commissionDetail(BalanceChangeRecord balanceChangeRecord) { + List<AppUser> appUserList = Optional.ofNullable(appUserService.list()).orElse(Collections.emptyList()); + + if (appUserList.isEmpty()) { + return R.ok(new CommissionDetail()); + } + + BigDecimal totalCommission = BigDecimal.ZERO; + BigDecimal totalServiceFee = BigDecimal.ZERO; + BigDecimal totalUserCommission = BigDecimal.ZERO; + Map<Integer, BigDecimal> vipCommissions = new HashMap<>(); + + for (AppUser appUser : appUserList) { + totalCommission = totalCommission.add(Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO)); + totalServiceFee = totalServiceFee.add(Optional.ofNullable(appUser.getShopServiceFee()).orElse(BigDecimal.ZERO)); + totalUserCommission = totalUserCommission.add(Optional.ofNullable(appUser.getShopCommission()).orElse(BigDecimal.ZERO)); + + Integer vipId = appUser.getVipId(); + if (vipId != null && vipId >= 1 && vipId <= 7) { + vipCommissions.merge(vipId, Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO), BigDecimal::add); + } + } + + CommissionDetail commissionDetail = new CommissionDetail(); + commissionDetail.setTotalCommission(totalCommission); + commissionDetail.setTotalServiceFee(totalServiceFee); + commissionDetail.setTotalUserCommission(totalUserCommission); + + commissionDetail.setTotalNormalCommission(vipCommissions.getOrDefault(1, BigDecimal.ZERO)); + commissionDetail.setTotalGoldCommission(vipCommissions.getOrDefault(2, BigDecimal.ZERO)); + commissionDetail.setTotalDiamondCommission(vipCommissions.getOrDefault(3, BigDecimal.ZERO)); + commissionDetail.setTotalAgentCommission(vipCommissions.getOrDefault(4, BigDecimal.ZERO)); + commissionDetail.setTotalSuperAgentCommission(vipCommissions.getOrDefault(5, BigDecimal.ZERO)); + commissionDetail.setTotalTopAgentCommission(vipCommissions.getOrDefault(6, BigDecimal.ZERO)); + commissionDetail.setTotalPartnerCommission(vipCommissions.getOrDefault(7, BigDecimal.ZERO)); + + return R.ok(commissionDetail); + } + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java index 440d198..49f11fc 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java @@ -2,10 +2,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.BalanceChangeRecord; import com.ruoyi.account.dto.BalanceQuery; import com.ruoyi.account.service.BalanceChangeRecordService; +import com.ruoyi.account.vo.CommissionDetail; import com.ruoyi.account.vo.CommissionStatistics; +import com.ruoyi.account.vo.WalletStatistics; +import com.ruoyi.account.vo.WalletStatisticsDetail; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.poi.ExcelUtil; import io.swagger.annotations.ApiOperation; @@ -23,54 +27,80 @@ @RestController @RequestMapping("/balanceChangeRecord") public class BalanceChangeRecordController { - - @Resource - private BalanceChangeRecordService balanceChangeRecordService; - - - /** - * 保存账户流水记录 - * @param balanceChangeRecord - * @return - */ - @PostMapping("/saveBalanceChangeRecord") - public R saveBalanceChangeRecord(@RequestBody BalanceChangeRecord balanceChangeRecord){ - balanceChangeRecordService.save(balanceChangeRecord); - return R.ok(); - } - @PostMapping("/page") - @ApiOperation(value = "余额变更明细", tags = {"后台"}) - public R<IPage<BalanceChangeRecord>> page(@RequestBody BalanceQuery agentQuery) { + @Resource + private BalanceChangeRecordService balanceChangeRecordService; - return R.ok(balanceChangeRecordService.pageList(agentQuery)); - } - /** - * 用户分佣统计 - */ - @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); - } -// + /** + * 保存账户流水记录 + * + * @param balanceChangeRecord + * @return + */ + @PostMapping("/saveBalanceChangeRecord") + public R saveBalanceChangeRecord(@RequestBody BalanceChangeRecord balanceChangeRecord) { + balanceChangeRecordService.save(balanceChangeRecord); + return R.ok(); + } + + @PostMapping("/page") + @ApiOperation(value = "余额变更明细", tags = {"后台"}) + public R<IPage<BalanceChangeRecord>> page(@RequestBody BalanceQuery agentQuery) { + + return R.ok(balanceChangeRecordService.pageList(agentQuery)); + } + + /** + * 用户分佣统计 + */ + @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, BalanceChangeRecord balanceChangeRecord) { - CommissionStatistics commissionStatistics1 = balanceChangeRecordService.commissionStatistics(Page.of(1, Integer.MAX_VALUE), balanceChangeRecord); - IPage<BalanceChangeRecord> userPointPage = commissionStatistics1.getUserPointPage(); - List<BalanceChangeRecord> userPointList = userPointPage.getRecords(); - ExcelUtil<BalanceChangeRecord> util = new ExcelUtil<>(BalanceChangeRecord.class); - util.exportExcel(response, userPointList, "用户分佣统计"); - } + @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(); + ExcelUtil<BalanceChangeRecord> util = new ExcelUtil<>(BalanceChangeRecord.class); + util.exportExcel(response, userPointList, "用户分佣统计"); + } - - + + /** + * 钱包统计 + */ + @GetMapping("/walletStatistics") + @ApiOperation(value = "钱包统计", tags = "管理后台-财务统计-钱包统计") + public R<WalletStatistics> walletStatistics(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + BalanceChangeRecord balanceChangeRecord) { + WalletStatistics walletStatistics = balanceChangeRecordService.walletStatistics(Page.of(pageNum, pageSize), balanceChangeRecord); + return R.ok(walletStatistics); + } + + /** + * 钱包统计导出 + */ + @GetMapping("/walletExport") + @ApiOperation(value = "钱包统计导出", tags = "管理后台-财务统计-钱包统计") + public void walletExport(HttpServletResponse response, BalanceChangeRecord balanceChangeRecord) { + WalletStatistics walletStatistics = balanceChangeRecordService.walletStatistics(Page.of(1, Integer.MAX_VALUE), balanceChangeRecord); + IPage<WalletStatisticsDetail> userPointPage = walletStatistics.getPage(); + List<WalletStatisticsDetail> userPointList = userPointPage.getRecords(); + ExcelUtil<WalletStatisticsDetail> util = new ExcelUtil<>(WalletStatisticsDetail.class); + util.exportExcel(response, userPointList, "钱包统计"); + } + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java index adff1d8..9afbe26 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java @@ -130,6 +130,14 @@ return R.ok(userPointPage); } + @GetMapping("/user/list") + @ApiOperation(value = "积分管理-用户积分明细(必传用户id)", tags = "后台") + public R<Page<UserPoint>> userlist(UserPoint userPoint) { + Page<UserPoint> page = userPointService.lambdaQuery().eq(UserPoint::getAppUserId, userPoint.getAppUserId()).orderByDesc(UserPoint::getCreateTime).page(Page.of(userPoint.getPageNum(), userPoint.getPageSize())); + return R.ok(page); + } + + /** * 导出 diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java index 6d9ebf5..2763610 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java @@ -49,7 +49,11 @@ @PostMapping("/page") @ApiOperation(value = "提现申请列表", tags = {"后台"}) public R<IPage<WithdrawalRequests>> page(@RequestBody WithQuery withQuery){ - return R.ok(withdrawalRequestsService.pageList(withQuery)); + IPage<WithdrawalRequests> withdrawalRequestsIPage = withdrawalRequestsService.pageList(withQuery); + for (WithdrawalRequests record : withdrawalRequestsIPage.getRecords()) { + record.setIdStr(record.getId().toString()); + } + return R.ok(withdrawalRequestsIPage); } @PostMapping("/auth") @ApiOperation(value = "提现申请审批", tags = {"后台"}) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java index 9d165d1..97be34d 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java @@ -5,6 +5,8 @@ import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.vo.NearbyReferrer; import com.ruoyi.account.vo.NearbyReferrerVo; +import com.ruoyi.account.vo.UserStatistics; +import com.ruoyi.account.vo.UserStatisticsDetail; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -30,6 +32,10 @@ IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser); IPage<AppUser> getAppuserPage1(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser,@Param("objectId")Integer objectId,@Param("userIds")List<Long> userIds); + UserStatistics getUserStatistics(); + + UserStatisticsDetail getUserStatisticsDetail(Long userId); + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java index 8daeb5c..d8af26a 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserPointMapper.java @@ -17,8 +17,6 @@ */ public interface UserPointMapper extends BaseMapper<UserPoint> { - List<UserPoint> findLatestUserPointByTypeForUser(Long userId); - IPage<UserPoint> queryUserPointPage(@Param("page") IPage<UserPoint> page,@Param("userPoint") UserPoint userPoint); List<UserPoint> selectUserPoint(@Param("userPoint") UserPoint userPoint); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalanceChangeRecordService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalanceChangeRecordService.java index a1cf54f..9727203 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalanceChangeRecordService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalanceChangeRecordService.java @@ -6,9 +6,13 @@ import com.ruoyi.account.api.model.BalanceChangeRecord; import com.ruoyi.account.dto.BalanceQuery; import com.ruoyi.account.vo.CommissionStatistics; +import com.ruoyi.account.vo.WalletStatistics; public interface BalanceChangeRecordService extends IService<BalanceChangeRecord> { IPage<BalanceChangeRecord> pageList(BalanceQuery agentQuery); CommissionStatistics commissionStatistics(Page<BalanceChangeRecord> page, BalanceChangeRecord balanceChangeRecord); + + WalletStatistics walletStatistics(Page<BalanceChangeRecord> of, BalanceChangeRecord balanceChangeRecord); + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java index 064686f..13a6a9a 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java @@ -5,4 +5,6 @@ public interface PointSettingService { PointSetting getPointSettingByAppUserId(Long appUserId); + + PointSetting getPointSettingById(Integer id); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AgentApplicationServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AgentApplicationServiceImpl.java index bb93baa..5c148d8 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AgentApplicationServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AgentApplicationServiceImpl.java @@ -62,7 +62,7 @@ // 直推用户已成为代理数量 List<AppUser> directAgentUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() .eq(AppUser::getInviteUserId, appUser.getId()) - .eq(AppUser::getUserType, 4)); + .eq(AppUser::getVipId, 4)); agentApplication.setDirectAgentNum(directAgentUserList.size()); // 已绑定门店数量 diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java index b9f774b..ee32922 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java @@ -207,7 +207,7 @@ //校验验证码获取频率(1分钟5次) String key = smsCode.getType() + "&" + smsCode.getPhone(); Map<String, Object> cacheMap = redisService.getCacheMap(key); - if(null != cacheMap){ + if(null != cacheMap && cacheMap.size() > 0){ Integer number = Integer.valueOf(cacheMap.get("number").toString()) + 1; Long startTime = Long.valueOf(cacheMap.get("startTime").toString()); if(number > 5 && (System.currentTimeMillis() - startTime) < 60000){ diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java index 1a3ca07..e317ae3 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java @@ -1,26 +1,27 @@ package com.ruoyi.account.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.account.api.model.AppUser; import com.ruoyi.account.api.model.BalanceChangeRecord; -import com.ruoyi.account.api.model.UserClickLog; -import com.ruoyi.account.api.model.WithdrawalRequests; import com.ruoyi.account.dto.BalanceQuery; import com.ruoyi.account.mapper.BalanceChangeRecordMapper; -import com.ruoyi.account.service.AppUserService; 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 com.ruoyi.account.vo.WalletStatistics; +import com.ruoyi.account.vo.WalletStatisticsDetail; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.bean.BeanUtils; +import com.ruoyi.other.api.domain.ShopBalanceStatement; +import com.ruoyi.other.api.feignClient.ShopClient; 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.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -28,15 +29,14 @@ @Service public class BalanceChangeRecordServiceImpl extends ServiceImpl<BalanceChangeRecordMapper, BalanceChangeRecord> implements BalanceChangeRecordService { @Resource - private AppUserService appUserService; + private ShopClient shopClient; @Override public IPage<BalanceChangeRecord> pageList(BalanceQuery agentQuery) { Page<BalanceChangeRecord> page = new Page<>(); page.setCurrent(agentQuery.getPageNum()); page.setSize(agentQuery.getPageSize()); - IPage<BalanceChangeRecord> shopIPage = this.baseMapper.pageList(page, agentQuery); - return shopIPage; + return this.baseMapper.pageList(page, agentQuery); } @Override @@ -51,4 +51,90 @@ IPage<BalanceChangeRecord> balanceChangeRecordIPage = this.baseMapper.queryCommissionStatistics(page, balanceChangeRecord); return new CommissionStatistics(totalCommission, balanceChangeRecordIPage); } + + @Override + public WalletStatistics walletStatistics(Page<BalanceChangeRecord> page, BalanceChangeRecord balanceChangeRecord) { + ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); + shopBalanceStatement.setType(4); + + R<List<ShopBalanceStatement>> r; + try { + r = shopClient.getShopBalanceStatementList(shopBalanceStatement); + } catch (Exception e) { + log.error("获取店铺余额对账单列表时出错", e); + return null; + } + + if (R.isError(r)) { + return null; + } + + List<BalanceChangeRecord> balanceChangeRecordList = this.baseMapper.selectBalanceChangeRecordList(balanceChangeRecord); + + List<WalletStatisticsDetail> walletStatisticsDetailList = new ArrayList<>(); + for (BalanceChangeRecord changeRecord : balanceChangeRecordList) { + WalletStatisticsDetail walletStatisticsDetail = new WalletStatisticsDetail(); + BeanUtils.copyBeanProp(walletStatisticsDetail, changeRecord); + walletStatisticsDetailList.add(walletStatisticsDetail); + } + + walletStatisticsDetailList.addAll(r.getData().stream().map(this::createWalletStatisticsDetail).collect(Collectors.toList())); + + // 按时间排序(倒序) + walletStatisticsDetailList.sort(Comparator.comparing(WalletStatisticsDetail::getCreateTime).reversed()); + + long current = page.getCurrent(); + long size = page.getSize(); + if (current < 1) { + current = 1; + } + int fromIndex = (int) ((current - 1) * size); + int toIndex = (int) Math.min(fromIndex + size, walletStatisticsDetailList.size()); + + if (fromIndex >= walletStatisticsDetailList.size()) { + throw new ServiceException("页面参数无效"); + } + + List<WalletStatisticsDetail> walletStatisticsDetailList2 = walletStatisticsDetailList.subList(fromIndex, toIndex); + + + Map<Integer, BigDecimal> shopCommissionMap = walletStatisticsDetailList.stream() + .collect(Collectors.groupingBy( + WalletStatisticsDetail::getChangeType, + Collectors.reducing( + BigDecimal.ZERO, + WalletStatisticsDetail::getChangeAmount, + BigDecimal::add + ) + )); + + BigDecimal totalRecharge = shopCommissionMap.get(1); + BigDecimal totalWithdraw = shopCommissionMap.get(2); + BigDecimal totalShopWithdraw = shopCommissionMap.get(7); + + + WalletStatistics walletStatistics = new WalletStatistics(); + Page<WalletStatisticsDetail> page1 = new Page<>(); + page1.setRecords(walletStatisticsDetailList2); + page1.setTotal(walletStatisticsDetailList.size()); + page1.setCurrent(current); + page1.setSize(size); + walletStatistics.setPage(page1); + walletStatistics.setTotalRecharge(totalRecharge); + walletStatistics.setTotalWithdraw(totalWithdraw); + walletStatistics.setTotalShopWithdraw(totalShopWithdraw); + return walletStatistics; + } + + private WalletStatisticsDetail createWalletStatisticsDetail(ShopBalanceStatement item) { + WalletStatisticsDetail walletStatisticsDetail = new WalletStatisticsDetail(); + walletStatisticsDetail.setShopName(item.getShopName()); + walletStatisticsDetail.setUserName(item.getShopManagerName()); + walletStatisticsDetail.setUserPhone(item.getPhone()); + walletStatisticsDetail.setChangeType(4); + walletStatisticsDetail.setCreateTime(item.getCreateTime()); + walletStatisticsDetail.setChangeAmount(item.getVariableAmount()); + return walletStatisticsDetail; + } + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java index 50fdd69..42de2ab 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java @@ -26,4 +26,13 @@ } return r.getData(); } + + @Override + public PointSetting getPointSettingById(Integer id) { + R<PointSetting> r = pointSettingClient.getPointSetting(id); + if (!R.isSuccess(r)){ + throw new RuntimeException("获取积分设置失败"); + } + return r.getData(); + } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java index f2fc4eb..05b2c91 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java @@ -7,7 +7,6 @@ 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.other.api.enums.PointChangeType; import com.ruoyi.account.mapper.UserPointMapper; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.PointSettingService; @@ -16,24 +15,23 @@ 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.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.other.api.enums.PointChangeType; import com.ruoyi.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -55,17 +53,10 @@ private VipSettingService vipSettingService; @Resource private PointSettingService pointSettingService; - @Resource - private UserPointMapper userPointMapper; - @Resource - private ShopClient shopClient; @Override public UserPointVO getUserPoint(Long userId) { AppUser appUser = appUserService.getById(userId); - List<UserPoint> userPointList = this.baseMapper.findLatestUserPointByTypeForUser(userId); - Map<Integer, Integer> userBalanceMap = userPointList.stream() - .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userId); UserPointVO userPointVO = new UserPointVO(); @@ -73,10 +64,10 @@ userPointVO.setConsumePoint(appUser.getLavePoint()); userPointVO.setShopPoint(appUser.getShopPoint()); userPointVO.setSharePoint(appUser.getSharePoint()); - 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); + userPointVO.setPullNewPoint(appUser.getTotalInvitePoint()); + userPointVO.setShopAchievementPoint(appUser.getShopAchievementPoint()); + userPointVO.setShopSharePoint(appUser.getShopSharePoint()); + userPointVO.setGiftPoint(vipSetting.getVipGiftRole() == 1 ? 1 : 0); return userPointVO; } @@ -127,7 +118,7 @@ throw new ServiceException("积分设置未找到"); } // 可转赠积分总数 - int adjustedPoint = getAdjustedPoint(pointSetting, appUser); + long adjustedPoint = getAdjustedPoint(pointSetting, appUser); if (point.compareTo(new BigDecimal(adjustedPoint)) > 0) { throw new ServiceException("转赠积分不足"); @@ -143,6 +134,11 @@ appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point.intValue()); appUserService.updateById(appUserForPhoe); + Integer lavePoint = appUser.getLavePoint(); + appUser.setLavePoint(lavePoint - point.intValue()); + Integer totalPoint = appUser.getTotalPoint(); + appUser.setTotalPoint(totalPoint - point.intValue()); + appUserService.updateById(appUser); log.info("积分转赠完成,用户ID: {}, 新积分: {}", appUserForPhoe.getId(), appUserForPhoe.getLavePoint()); } @@ -150,65 +146,39 @@ * 获取可转赠积分 * @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(); + private long getAdjustedPoint(PointSetting pointSetting, AppUser appUser) { + if (pointSetting == null || appUser == null) { + throw new ServiceException("pointSetting和appUser不能为空"); } - // 返佣积分 - Integer sharePointOpen = pointSetting.getSharePointGift(); - if (sharePointOpen == 1){ - transferPoint += appUser.getSharePoint(); - } + long transferPoint = 0; - // 门店返佣积分 - 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(); - } + transferPoint += calculatePoint(pointSetting.getBuyPointGift(), appUser.getShopPoint(), pointSetting.getBuyPoint()); + transferPoint += calculatePoint(pointSetting.getSharePointGift(), appUser.getSharePoint(), pointSetting.getSharePoint()); + transferPoint += calculatePoint(pointSetting.getShopSharePointGift(), appUser.getShopSharePoint(), pointSetting.getShopSharePoint()); + transferPoint += calculatePoint(pointSetting.getShopPointGift(), appUser.getShopAchievementPoint(), pointSetting.getShopPoint()); + transferPoint += calculatePoint(pointSetting.getPersonPointGift(), appUser.getTotalPerformancePoint(), pointSetting.getPersonPoint()); + transferPoint += calculatePoint(pointSetting.getGetNewPointGift(), appUser.getTotalInvitePoint(), pointSetting.getGetNewPoint()); + transferPoint += calculatePoint(pointSetting.getGetRegisPointGift(), appUser.getTotalRegisterPoint(), pointSetting.getRegisPoint()); + transferPoint += calculatePoint(pointSetting.getWorkPointGift(), appUser.getTotalSharePoint() + appUser.getTotalSignPoint() + appUser.getTotalHourPoint(), pointSetting.getWorkPoint()); - // 技师业绩积分 - 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; } + private long calculatePoint(Integer settingValue, double userValue, double pointValue) { + if (settingValue == 1) { + try { + double result = userValue * (pointValue / 100.0); + return Math.round(result); + } catch (ArithmeticException e) { + return 0; + } + } + return 0; + } + + @Override public UserPointStatistics getStatistics(UserPoint userPoint) { diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionDetail.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionDetail.java new file mode 100644 index 0000000..2fd9be1 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/CommissionDetail.java @@ -0,0 +1,72 @@ +package com.ruoyi.account.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@ApiModel(description = "分佣明细") +public class CommissionDetail { + + /** + * 用户获得总分佣金额 + */ + @ApiModelProperty(value = "用户获得总分佣金额") + private BigDecimal totalCommission; + + /** + * 门店获得总服务费用总分佣金额 + */ + @ApiModelProperty(value = "门店获得总服务费用总分佣金额") + private BigDecimal totalServiceFee; + + /** + * 门店获得关联用户总分佣金额 + */ + @ApiModelProperty(value = "门店获得关联用户总分佣金额") + private BigDecimal totalUserCommission; + + /** + * 普通会员获得总分佣金额 + */ + @ApiModelProperty(value = "普通会员获得总分佣金额") + private BigDecimal totalNormalCommission; + + /** + * 黄金会员获得总分佣金额 + */ + @ApiModelProperty(value = "黄金会员获得总分佣金额") + private BigDecimal totalGoldCommission; + + /** + * 钻石会员获得总分佣金额 + */ + @ApiModelProperty(value = "钻石会员获得总分佣金额") + private BigDecimal totalDiamondCommission; + + /** + * 准代理获得总分佣金额 + */ + @ApiModelProperty(value = "准代理获得总分佣金额") + private BigDecimal totalAgentCommission; + + /** + * 代理获得总分佣金额 + */ + @ApiModelProperty(value = "代理获得总分佣金额") + private BigDecimal totalSuperAgentCommission; + + /** + * 总代获得总分佣金额 + */ + @ApiModelProperty(value = "总代获得总分佣金额") + private BigDecimal totalTopAgentCommission; + + /** + * 合伙人获得总分佣金额 + */ + @ApiModelProperty(value = "合伙人获得总分佣金额") + private BigDecimal totalPartnerCommission; +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatistics.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatistics.java new file mode 100644 index 0000000..1c3052c --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatistics.java @@ -0,0 +1,75 @@ +package com.ruoyi.account.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("用户统计") +public class UserStatistics { + /** + * 用户总数 + */ + @ApiModelProperty(value = "用户总数") + private Integer totalUser; + + /** + * 拥有门店用户数 + */ + @ApiModelProperty(value = "拥有门店用户数") + private Integer shopUser; + + /** + * 消费者用户数 + */ + @ApiModelProperty(value = "消费者用户数") + private Integer consumerUser; + + /** + * 普通会员数 + */ + @ApiModelProperty(value = "普通会员数") + private Integer commonUser; + + /** + * 黄金会员数 + */ + @ApiModelProperty(value = "黄金会员数") + private Integer goldUser; + + /** + * 钻石会员数 + */ + @ApiModelProperty(value = "钻石会员数") + private Integer diamondUser; + + /** + * 创业者总数 + */ + @ApiModelProperty(value = "创业者总数") + private Integer entrepreneurUser; + + /** + * 准代理数 + */ + @ApiModelProperty(value = "准代理数") + private Integer proxyUser; + + /** + * 代理数 + */ + @ApiModelProperty(value = "代理数") + private Integer agentUser; + + /** + * 总代数 + */ + @ApiModelProperty(value = "总代数") + private Integer totalAgentUser; + + /** + * 合伙人数 + */ + @ApiModelProperty(value = "合伙人数") + private Integer partnerUser; +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatisticsDetail.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatisticsDetail.java new file mode 100644 index 0000000..3a58836 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatisticsDetail.java @@ -0,0 +1,70 @@ +package com.ruoyi.account.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("用户统计详情") +public class UserStatisticsDetail { + + /** + * 用户获得总积分 + */ + @ApiModelProperty("用户获得总积分") + private Integer totalScore; + + /** + * 消费积分总数 + */ + @ApiModelProperty("消费积分总数") + private Integer consumeScore; + + /** + * 返佣积分总数 + */ + @ApiModelProperty("返佣积分总数") + private Integer rebateScore; + + /** + * 拉新人积分总数 + */ + @ApiModelProperty("拉新人积分总数") + private Integer inviteScore; + + /** + * 注册积分总数 + */ + @ApiModelProperty("注册积分总数") + private Integer registerScore; + + /** + * 做工积分总数 + */ + @ApiModelProperty("做工积分总数") + private Integer workScore; + + /** + * 技师业绩积分总数 + */ + @ApiModelProperty("技师业绩积分总数") + private Integer achievementScore; + + /** + * 用户获得分佣总金额 + */ + @ApiModelProperty("用户获得分佣总金额") + private Integer totalRebate; + + /** + * 充值金额 + */ + @ApiModelProperty("充值金额") + private Integer totalRecharge; + + /** + * 已提现金额 + */ + @ApiModelProperty("已提现金额") + private Integer totalWithdraw; +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatistics.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatistics.java new file mode 100644 index 0000000..c2681cb --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatistics.java @@ -0,0 +1,27 @@ +package com.ruoyi.account.vo; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class WalletStatistics { + + /** + * 用户充值总金额 + */ + private BigDecimal totalRecharge; + + /** + * 用户提现总金额 + */ + private BigDecimal totalWithdraw; + + /** + * 门店提现总金额 + */ + private BigDecimal totalShopWithdraw; + + private IPage<WalletStatisticsDetail> page; +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatisticsDetail.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatisticsDetail.java new file mode 100644 index 0000000..4dba15b --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletStatisticsDetail.java @@ -0,0 +1,54 @@ +package com.ruoyi.account.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class WalletStatisticsDetail { + /** + * 门店名称 + */ + @ApiModelProperty(value = "门店名称") + @Excel(name = "门店名称") + private String shopName; + + /** + * 用户姓名 + */ + @ApiModelProperty(value = "用户姓名") + @Excel(name = "用户姓名") + private String userName; + + /** + * 联系电话 + */ + @ApiModelProperty(value = "联系电话") + @Excel(name = "联系电话") + private String userPhone; + + @ApiModelProperty("类型:1充值2提现3红包4分佣5商城购物6订单取消回退7门店提现") + @Excel(name = "变更类型", readConverterExp = "1=充值,2=提现,3=红包,4=分佣,5=商城购物,6=订单取消回退,7=门店提现") + private Integer changeType; + + /** + * 变更时间 + */ + @ApiModelProperty(value = "变更时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "变更时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + /** + * 变更数量 + */ + @ApiModelProperty(value = "变更数量") + @Excel(name = "变更数量") + private BigDecimal changeAmount; +} diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml index 935fb14..c870ac5 100644 --- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml +++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml @@ -111,4 +111,40 @@ ) or ta.shop_id = #{objectId} ) </where> </select> + <select id="getUserStatistics" resultType="com.ruoyi.account.vo.UserStatistics"> + SELECT + COUNT(*) AS totalUser, + SUM(CASE WHEN tau.user_type = 2 THEN 1 ELSE 0 END) AS shopUser, + SUM(CASE WHEN tau.vip_id <![CDATA[<]]> 4 THEN 1 ELSE 0 END) AS consumerUser, + SUM(CASE WHEN tau.vip_id = 1 THEN 1 ELSE 0 END) AS commonUser, + SUM(CASE WHEN tau.vip_id = 2 THEN 1 ELSE 0 END) AS goldUser, + SUM(CASE WHEN tau.vip_id = 3 THEN 1 ELSE 0 END) AS diamondUser, + SUM(CASE WHEN tau.vip_id <![CDATA[>]]> 3 THEN 1 ELSE 0 END) AS entrepreneurUser, + SUM(CASE WHEN tau.vip_id = 4 THEN 1 ELSE 0 END) AS proxyUser, + SUM(CASE WHEN tau.vip_id = 5 THEN 1 ELSE 0 END) AS agentUser, + SUM(CASE WHEN tau.vip_id = 6 THEN 1 ELSE 0 END) AS totalAgentUser, + SUM(CASE WHEN tau.vip_id = 7 THEN 1 ELSE 0 END) AS partnerUser + FROM + t_app_user tau + </select> + <select id="getUserStatisticsDetail" resultType="com.ruoyi.account.vo.UserStatisticsDetail"> + SELECT + SUM(tau.total_point) totalScore, + SUM(tau.shop_point) consumeScore, + SUM(tau.share_point) rebateScore, + SUM(tau.total_invite_point) inviteScore, + SUM(tau.total_register_point) registerScore, + SUM(tau.total_share_point+tau.total_sign_point+tau.total_hour_point) workScore, + SUM(tau.total_performance_point) achievementScore, + SUM(tau.total_distribution_amount) totalRebate, + SUM(tau.total_recharge_amount) totalRecharge, + SUM(tau.withdrawn_amount) totalWithdraw + FROM + t_app_user tau + <where> + <if test="null != userName and '' != userName"> + and tau.id = #{userId} + </if> + </where> + </select> </mapper> diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml index d054e5e..74192fd 100644 --- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml +++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml @@ -17,16 +17,6 @@ <sql id="Base_Column_List"> id, type, historical_point, variable_point, create_time, app_user_id, object_id </sql> - <select id="findLatestUserPointByTypeForUser" resultType="com.ruoyi.account.api.model.UserPoint"> - SELECT - t1.* - FROM - t_user_point t1 - INNER JOIN ( SELECT type, MAX( create_time ) AS max_create_time FROM t_user_point WHERE app_user_id = #{userId} GROUP BY type ) t2 ON t1.type = t2.type - AND t1.create_time = t2.max_create_time - WHERE - t1.app_user_id = #{userId} - </select> <sql id="userPointList"> SELECT diff --git a/ruoyi-service/ruoyi-order/pom.xml b/ruoyi-service/ruoyi-order/pom.xml index b0095a7..52c2a8b 100644 --- a/ruoyi-service/ruoyi-order/pom.xml +++ b/ruoyi-service/ruoyi-order/pom.xml @@ -136,7 +136,7 @@ <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-spring-boot-starter</artifactId> - <version>4.0.0</version> + <version>4.1.2</version> <exclusions> <exclusion> <artifactId>guava</artifactId> diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java index 76ffe8f..0d1c3de 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java @@ -12,6 +12,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.enums.OrderStatus; +import com.ruoyi.order.mapper.OrderMapper; import com.ruoyi.order.model.Order; import com.ruoyi.order.service.CommissionService; import com.ruoyi.order.service.OrderService; @@ -26,7 +27,11 @@ import javax.annotation.Resource; import javax.validation.constraints.NotBlank; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * <p> @@ -50,6 +55,8 @@ private CommissionService commissionService; @Resource private BaseSettingClient baseSettingClient; + @Resource + private OrderMapper orderMapper; /** @@ -229,10 +236,10 @@ - @PutMapping("/confirmDelivery/{orderId}") + @PostMapping("/confirmDelivery") @ApiOperation(value = "已发货操作", tags = {"管理后台-订单管理"}) - public R confirmDelivery(@PathVariable("orderId") String orderId, String code){ - return orderService.confirmDelivery(orderId, code); + public R confirmDelivery(@RequestBody ConfirmDelivery confirmDelivery){ + return orderService.confirmDelivery(confirmDelivery.getOrderId(), confirmDelivery.getCode()); } @@ -262,5 +269,42 @@ public R<PageInfo<OrderPageListVo>> getOrderPageList(OrderPageList orderPageList){ return R.ok(orderService.getOrderPageList(orderPageList)); } + + /** + * 订单统计 + */ + @GetMapping("/getOrderStatistics") + @ApiOperation(value = "订单统计", tags = {"管理后台-首页统计"}) + public R<OrderStatistics> getOrderStatistics(@RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime){ + + List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>() + .between(Order::getCreateTime, LocalDateTime.parse(startTime), LocalDateTime.parse(endTime))); + Map<String, List<Order>> orderMap = orderList.stream() + .collect(Collectors.groupingBy(o -> o.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + + Map<String, Integer> serviceOrderMap = new HashMap<>(); + Map<String, Integer> singleOrderMap = new HashMap<>(); + Map<String, Integer> totalOrderMap = new HashMap<>(); + + orderMap.forEach((date, orders) -> { + long serviceCount = orders.stream().filter(o -> o.getOrderType() == 1).count(); + long singleCount = orders.stream().filter(o -> o.getOrderType() == 2).count(); + long totalCount = orders.size(); + + serviceOrderMap.put(date, (int) serviceCount); + singleOrderMap.put(date, (int) singleCount); + totalOrderMap.put(date, (int) totalCount); + }); + + OrderStatistics orderStatistics = orderMapper.getOrderStatistics(LocalDateTime.parse(startTime), LocalDateTime.parse(endTime)); + orderStatistics.setServiceOrderMap(serviceOrderMap); + orderStatistics.setSingleOrderMap(singleOrderMap); + orderStatistics.setTotalOrderMap(totalOrderMap); + + return R.ok(orderStatistics); + } + + } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java index e418051..6affa54 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java @@ -11,10 +11,7 @@ import com.ruoyi.order.model.RefundPass; import com.ruoyi.order.service.OrderService; import com.ruoyi.order.service.RefundPassService; -import com.ruoyi.order.vo.ApplyRefundPass; -import com.ruoyi.order.vo.OrderRefundPassList; -import com.ruoyi.order.vo.OrderRefundPassListVo; -import com.ruoyi.order.vo.RefundPassInfo; +import com.ruoyi.order.vo.*; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -137,15 +134,10 @@ @ResponseBody - @PostMapping("/authPassStatus/{id}/{status}") + @PostMapping("/authPassStatus") @ApiOperation(value = "审核售后", tags = {"管理后台-售后管理", "门店后台-售后管理"}) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "售后数据id", required = true, dataType = "long"), - @ApiImplicitParam(name = "status", value = "审核状态(2=同意,3=拒绝)", required = true, dataType = "int"), - @ApiImplicitParam(name = "passRemark", value = "审核备注", required = false, dataType = "string"), - }) - public R authPassStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status, @RequestParam("passRemark") String passRemark){ - return refundPassService.authPassStatus(id, status, passRemark); + public R authPassStatus(@RequestBody AuthPassStatus authPassStatus){ + return refundPassService.authPassStatus(authPassStatus.getId(), authPassStatus.getStatus(), authPassStatus.getPassRemark()); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java index 82eb43a..2353959 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java @@ -4,10 +4,12 @@ import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.order.vo.OrderPageList; import com.ruoyi.order.vo.OrderPageListVo; +import com.ruoyi.order.vo.OrderStatistics; import com.ruoyi.order.vo.OrderVO; import com.ruoyi.order.model.Order; import org.apache.ibatis.annotations.Param; +import java.time.LocalDateTime; import java.util.List; /** @@ -31,4 +33,7 @@ * @return */ List<OrderPageListVo> getOrderPageList(PageInfo<OrderPageListVo> pageInfo, @Param("item") OrderPageList orderPageList); + + OrderStatistics getOrderStatistics(@Param("startTime")LocalDateTime startTime, + @Param("endTime") LocalDateTime endTime); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java index 28ff6a6..0d0cb47 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java @@ -41,7 +41,7 @@ * @param code * @return */ - R confirmDelivery(String orderId, String code); + R confirmDelivery(Long orderId, String code); /** diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index f964675..6e85163 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -130,9 +130,6 @@ orderGoodsVO.setOriginalPrice(goods.getOriginalPrice()); goodsList.add(orderGoodsVO); } - - - // 收货地址 String addressJson = order.getAddressJson(); UserAddress userAddress = new UserAddress(); @@ -140,7 +137,6 @@ userAddress = JSONObject.parseObject(addressJson, UserAddress.class); } - // 优惠券 String couponJson = order.getCouponJson(); CouponInfo couponInfo = new CouponInfo(); @@ -154,7 +150,6 @@ if (StringUtils.isNotEmpty(activityJson)){ orderActivityInfo = JSONObject.parseObject(activityJson, OrderActivityInfo.class); } - OrderDetailVO orderDetailVO = new OrderDetailVO(); if (CollectionUtil.isNotEmpty(orderGoods)){ @@ -314,7 +309,7 @@ * @return */ @Override - public R confirmDelivery(String orderId, String code) { + public R confirmDelivery(Long orderId, String code) { Order order = this.getById(orderId); if(1 == order.getPayStatus()){ return R.fail("订单还未完成支付"); @@ -367,8 +362,10 @@ //余额退款 OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId())); BigDecimal balance = appUser.getBalance(); - appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); - appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); + if(null != orderBalancePayment){ + appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); + appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); + } appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); @@ -457,10 +454,7 @@ VipSetting vipSetting = vipSettingClient.getVipSetting(vipId).getData(); Integer vipLevelUpShopRole = vipSetting.getVipLevelUpShopRole(); Integer vipLevelUpShop = vipSetting.getVipLevelUpShop(); - if(1 == vipLevelUpShopRole && shopPoint < vipLevelUpShop){ - return true; - } - return false; + return 1 == vipLevelUpShopRole && shopPoint < vipLevelUpShop; } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java index 7dd0207..2335be4 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java @@ -219,6 +219,8 @@ refundPassInfo.setRefundReason(refundPass.getRefundReason()); refundPassInfo.setUserRemark(refundPass.getUserRemark()); refundPassInfo.setPics(refundPass.getPics()); + refundPassInfo.setPassStatus(refundPass.getPassStatus()); + refundPassInfo.setPassRemark(refundPass.getPassRemark()); return refundPassInfo; } } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/AuthPassStatus.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/AuthPassStatus.java new file mode 100644 index 0000000..df71cd4 --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/AuthPassStatus.java @@ -0,0 +1,18 @@ +package com.ruoyi.order.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author zhibing.pu + * @date 2024/12/19 14:49 + */ +@Data +public class AuthPassStatus { + @ApiModelProperty("售后数据id") + private Long id; + @ApiModelProperty("审核状态(2=同意,3=拒绝)") + private Integer status; + @ApiModelProperty("审核备注") + private String passRemark; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmDelivery.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmDelivery.java new file mode 100644 index 0000000..f310c4f --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmDelivery.java @@ -0,0 +1,18 @@ +package com.ruoyi.order.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author zhibing.pu + * @date 2024/12/19 14:22 + */ +@Data +@ApiModel +public class ConfirmDelivery { + @ApiModelProperty("订单id") + private Long orderId; + @ApiModelProperty("快递json信息{\"com\":\"shunfeng\",\"num\":\"123456\"}") + private String code; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderStatistics.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderStatistics.java new file mode 100644 index 0000000..9e51514 --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderStatistics.java @@ -0,0 +1,60 @@ +package com.ruoyi.order.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +@ApiModel("订单统计") +public class OrderStatistics { + /** + * 订单总数 + */ + @ApiModelProperty(value = "订单总数") + private Integer total; + + /** + * 服务类型订单数量 + */ + @ApiModelProperty(value = "服务类型订单数量") + private Integer serviceTotal; + + /** + * 单品类型订单数量 + */ + @ApiModelProperty(value = "单品类型订单数量") + private Integer singleTotal; + + /** + * 订单总金额 + */ + @ApiModelProperty(value = "订单总金额") + private Double totalMoney; + + /** + * 服务类型订单总金额 + */ + @ApiModelProperty(value = "服务类型订单总金额") + private Double serviceTotalMoney; + + /** + * 单品类型订单总金额 + */ + @ApiModelProperty(value = "单品类型订单总金额") + private Double singleTotalMoney; + + /** + * 服务类型订单数量map(key:日期,value:数量) + */ + @ApiModelProperty(value = "服务类型订单数量map(key:日期,value:数量)") + private Map<String, Integer> serviceOrderMap; + + @ApiModelProperty(value = "单品类型订单数量map(key:日期,value:数量)") + private Map<String, Integer> singleOrderMap; + + @ApiModelProperty(value = "订单总数map(key:日期,value:数量)") + private Map<String, Integer> totalOrderMap; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/RefundPassInfo.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/RefundPassInfo.java index 36e81d5..6e9c89f 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/RefundPassInfo.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/RefundPassInfo.java @@ -51,7 +51,7 @@ @ApiModelProperty("审核状态(1待审核2同意3拒绝)") private Integer passStatus; @ApiModelProperty("审核注释") - private Integer passRemark; + private String passRemark; @ApiModelProperty("售后申请时间") private String passCreateTime; @ApiModelProperty("售后类型(1退货退款2仅退款)") diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml index f71d000..8ff4fdc 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml @@ -77,4 +77,23 @@ </if> order by create_time desc </select> + <select id="getOrderStatistics" resultType="com.ruoyi.order.vo.OrderStatistics"> + SELECT + count(*), + SUM( CASE WHEN tor.order_type = 1 THEN 1 ELSE 0 END ) a, + SUM( CASE WHEN tor.order_type = 2 THEN 1 ELSE 0 END ) b, + SUM( tor.total_amount ) c, + SUM( CASE WHEN tor.order_type = 1 THEN tor.total_amount ELSE 0 END ), + SUM( CASE WHEN tor.order_type = 2 THEN tor.total_amount ELSE 0 END ) + FROM + t_order tor + <where> + <if test="startTime != null"> + and tor.create_time <![CDATA[>=]]> #{startTime} + </if> + <if test="endTime != null"> + and tor.create_time <![CDATA[<=]]> #{endTime} + </if> + </where> + </select> </mapper> diff --git a/ruoyi-service/ruoyi-other/pom.xml b/ruoyi-service/ruoyi-other/pom.xml index 2288606..50f811c 100644 --- a/ruoyi-service/ruoyi-other/pom.xml +++ b/ruoyi-service/ruoyi-other/pom.xml @@ -126,12 +126,12 @@ <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> </dependency> - <dependency> - <groupId>com.alibaba</groupId> - <artifactId>easyexcel-core</artifactId> - <version>RELEASE</version> - <scope>compile</scope> - </dependency> +<!-- <dependency>--> +<!-- <groupId>com.alibaba</groupId>--> +<!-- <artifactId>easyexcel-core</artifactId>--> +<!-- <version>RELEASE</version>--> +<!-- <scope>compile</scope>--> +<!-- </dependency>--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java index 3493fae..d216f92 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java @@ -8,6 +8,7 @@ import com.ruoyi.other.service.BannerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -29,7 +30,9 @@ private BannerService bannerService; @GetMapping("/list") @ApiOperation(value = "banner列表", tags = {"小程序-banner"}) - public R<List<Banner>> list(String name, Integer jumpType, Integer position){ + public R<List<Banner>> list(@ApiParam("名称") String name, + @ApiParam("跳转类型(1=无跳转,2=外部链接,3=商品详情,4=秒杀商品详情,5=领券中心)") Integer jumpType, + @ApiParam("位置(1=首页,2=商城首页)") Integer position){ List<Banner> list = bannerService.lambdaQuery().like(StringUtils.isNotEmpty(name), Banner::getName, name) .eq(jumpType!=null,Banner::getJumpType, jumpType) .eq(position!=null,Banner::getPosition, position) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java index 2e4356d..c4a9776 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java @@ -77,7 +77,7 @@ - @PostMapping("/getRefundPassSetting") + @GetMapping("/getRefundPassSetting") @ApiOperation(value = "获取售后设置", tags = {"管理后台-售后管理"}) public R<RefundPassSettingVo> getRefundPassSetting(){ BaseSetting one = baseSettingService.getOne(new LambdaQueryWrapper<BaseSetting>().eq(BaseSetting::getId, 5)); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java index c6062e4..9824721 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PointSettingController.java @@ -35,15 +35,14 @@ } @GetMapping("/search") @ApiOperation(value = "积分配置查询", tags = {"后台"}) - public R<List<PointSetting>> search(@RequestParam Integer id) { + public R<List<PointSetting>> search() { 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()); + pointSettingService.saveOrUpdateBatch(pointSettingDto.getPointSettings()); return R.ok(); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java index 038d8f0..9812889 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java @@ -6,6 +6,7 @@ import com.ruoyi.account.api.model.UserClickLog; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.RechargeSet; +import com.ruoyi.other.dto.RechargeDto; import com.ruoyi.other.service.RechargeSetService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -34,9 +35,10 @@ } @PostMapping("/set") @ApiOperation(value = "充值设置", tags = {"后台"}) - public R<List<RechargeSet>> detail(@RequestBody List<RechargeSet> rechargeSets) { - boolean remove = rechargeSetService.remove(Wrappers.lambdaQuery()); - rechargeSetService.saveBatch(rechargeSets); + public R<List<RechargeSet>> detail(@RequestBody RechargeDto rechargeDto) { + List<RechargeSet> list = rechargeSetService.list(); + rechargeSetService.removeBatchByIds(list); + rechargeSetService.saveBatch(rechargeDto.getRechargeSets()); return R.ok(); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java index f9b7729..f2daa57 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java @@ -5,19 +5,24 @@ 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.common.security.service.TokenService; +import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.domain.ShopBalanceStatement; +import com.ruoyi.other.dto.ShopBalanceDto; +import com.ruoyi.other.mapper.ShopBalanceStatementMapper; import com.ruoyi.other.service.ShopBalanceStatementService; +import com.ruoyi.other.service.ShopService; 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 org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.List; +import java.util.List; /** * <p> @@ -33,6 +38,10 @@ public class ShopBalanceStatementController { @Resource private ShopBalanceStatementService shopBalanceStatementService; + @Resource + private TokenService tokenService; + @Resource + private ShopBalanceStatementMapper shopBalanceStatementMapper; /** * 门店分佣统计 @@ -47,12 +56,62 @@ } @GetMapping("/commissionStatistics/list") @ApiOperation(value = "门店余额明细", notes = "门店余额明细", tags = {"门店后台"}) - public R<ShopCommissionStatisticsVO> shopCommissionStatisticslist(@ApiParam("页码") @RequestParam Integer pageNum, + public R<Page<ShopBalanceStatement>> shopCommissionStatisticslist(@ApiParam("页码") @RequestParam Integer pageNum, @ApiParam("每一页数据大小") Integer pageSize, ShopBalanceStatement shopBalanceStatement){ - ShopCommissionStatisticsVO shopCommissionStatisticsVO = shopBalanceStatementService.shopCommissionStatistics(Page.of(pageNum, pageSize), shopBalanceStatement); - return R.ok(shopCommissionStatisticsVO); + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + Page<ShopBalanceStatement> page = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(shopBalanceStatement.getType() != null, ShopBalanceStatement::getType, shopBalanceStatement.getType()) + .orderByDesc(ShopBalanceStatement::getCreateTime) + .page(Page.of(pageNum, pageSize)); + + return R.ok(page); + + } + + @Resource + private ShopService shopService; + @GetMapping("/commissionStatistics/info") + @ApiOperation(value = "门店余额明细上方数据", notes = "门店余额明细", tags = {"门店后台"}) + public R<ShopBalanceDto> shopCommissionStatisticsinfo(){ + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + ShopBalanceDto dto = new ShopBalanceDto(); + List<ShopBalanceStatement> list = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 3).list(); + List<ShopBalanceStatement> list1 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 4).list(); + BigDecimal bigDecimal1 = new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list) { + bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); + } + for (ShopBalanceStatement shopBalanceStatement : list1) { + bigDecimal1 = bigDecimal1.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal1(bigDecimal1); + + BigDecimal bigDecimal2= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list) { + bigDecimal2 = bigDecimal2.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal2(bigDecimal2); + + BigDecimal bigDecimal3= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list1) { + bigDecimal3 = bigDecimal3.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal3(bigDecimal3); + + List<ShopBalanceStatement> list2 = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId,objectId).eq(ShopBalanceStatement::getType, 2).list(); + BigDecimal bigDecimal4= new BigDecimal(0); + for (ShopBalanceStatement shopBalanceStatement : list2) { + bigDecimal4 = bigDecimal4.add(shopBalanceStatement.getVariableAmount()); + } + dto.setBigDecimal4(bigDecimal4); + + Shop byId = shopService.getById(objectId); + dto.setBigDecimal5(byId.getCanWithdrawMoney()); + dto.setBigDecimal6(byId.getWithdrawMoney()); + return R.ok(dto); + } + /** * 导出门店分佣统计 @@ -66,5 +125,12 @@ util.exportExcel(response, statementIPage.getRecords(), "用户积分统计"); } + + + @PostMapping("/getList") + public R<List<ShopBalanceStatement>> getList(@RequestBody ShopBalanceStatement shopBalanceStatement){ + return R.ok(shopBalanceStatementMapper.selectShopBalanceStatementList(shopBalanceStatement)); + } + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java index 607cb6c..24eda68 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java @@ -12,10 +12,12 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.domain.ShopScore; +import com.ruoyi.other.mapper.ShopMapper; import com.ruoyi.other.service.ShopScoreService; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.vo.NearbyShopVO; import com.ruoyi.other.vo.ShopDetailVO; +import com.ruoyi.other.vo.ShopStatistics; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; import com.ruoyi.system.api.model.LoginUser; @@ -23,6 +25,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -55,7 +58,8 @@ private TokenService tokenService; @Resource private SysUserClient sysUserClient; - + @Resource + private ShopMapper shopMapper; @@ -71,7 +75,6 @@ shop.setShopPoint(0); shop.setSharePoint(0); shop.setServerPoint(0); - shop.setLowerLevelRebatePoints(0); shop.setUsePoint(0); shop.setGiveawayAllMoney(BigDecimal.ZERO); shop.setGiveawayMoney(BigDecimal.ZERO); @@ -90,6 +93,15 @@ appUserShop.setShopId(shop.getId()); R<Void> r = appUserClient.addAppUserShop(appUserShop); if (R.isError(r)){ + throw new RuntimeException("添加失败"); + } + AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); + if (appUser == null){ + throw new RuntimeException("添加失败"); + } + appUser.setUserType(2); + R<Void> editAppUserR = appUserClient.editAppUserById(appUser); + if (R.isError(editAppUserR)){ throw new RuntimeException("添加失败"); } return R.ok(); @@ -113,6 +125,10 @@ @PutMapping("/editShop") @ApiOperation(value = "门店管理-编辑门店", tags = {"管理后台-门店管理"}) public R<Void> editShop(@RequestBody Shop shop){ + String phone = shop.getPhone(); + if (!shopService.cheUserByPhone(phone)) { + return R.fail("该手机号未注册"); + } shopService.updateById(shop); return R.ok(); } @@ -194,6 +210,9 @@ R<List<AppUserShop>> r = appUserClient.getAppUserShop(SecurityUtils.getUserId()); if (R.isSuccess(r)){ List<AppUserShop> appUserShopList = r.getData(); + if (CollectionUtils.isEmpty(appUserShopList)){ + return R.ok(new ArrayList<>()); + } List<Integer> shopIds = appUserShopList.stream().map(AppUserShop::getShopId).collect(Collectors.toList()); List<Shop> shopList = shopService.listByIds(shopIds); return R.ok(shopList); @@ -273,5 +292,15 @@ return R.ok(list.stream().map(Shop::getId).collect(Collectors.toSet())); } + /** + * 门店统计 + */ + @GetMapping("/shopStatistics") + @ApiOperation(value = "门店统计", tags = {"管理后台-首页统计"}) + public R<ShopStatistics> shopStatistics(@ApiParam("门店名称") String shopName) { + ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopName); + return R.ok(shopStatistics); + } + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java index 706959a..084043b 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java @@ -58,10 +58,22 @@ @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<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, objectId).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType()) + .like(shopPoint.getOrderNum()!=null,ShopPoint::getOrderNum, shopPoint.getOrderNum()) + .orderByDesc(ShopPoint::getCreateTime) .page(Page.of(pageNum, pageSize)); return R.ok(page); } + @GetMapping("/statistics/list") + @ApiOperation(value = "门店积分明细必传门店id", tags = {"后台"}) + public R<Page<ShopPoint>> statisticslist(ShopPoint shopPoint,Integer pageNum,Integer pageSize) { + Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, shopPoint.getShopId()).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType()) + .like(shopPoint.getOrderNum()!=null,ShopPoint::getOrderNum, shopPoint.getOrderNum()) + .orderByDesc(ShopPoint::getCreateTime) + .page(Page.of(pageNum, pageSize)); + return R.ok(page); + } + /** * 导出门店积分统计 diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java index 0b9afb2..c804805 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java @@ -7,7 +7,9 @@ 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.Shop; import com.ruoyi.other.api.domain.ShopWithdraw; +import com.ruoyi.other.dto.ShopBalanceDto; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.service.ShopWithdrawService; import com.ruoyi.system.api.model.LoginUser; @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -54,6 +57,46 @@ return R.ok(page); } + @GetMapping("/shop/list") + @ApiOperation(value = "提现申请列表", notes = "提现申请列表", tags = {"门店后台"}) + public R<IPage<ShopWithdraw>> shoplist(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + ShopWithdraw shopWithdraw) { + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + Page<ShopWithdraw> page = shopWithdrawService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<ShopWithdraw>() + .eq(ShopWithdraw::getShopId,objectId) + .eq(shopWithdraw.getAuditStatus()!=null,ShopWithdraw::getAuditStatus,shopWithdraw.getAuditStatus()) + .orderByDesc(ShopWithdraw::getCreateTime) + ); + return R.ok(page); + } + + @GetMapping("/shop/info") + @ApiOperation(value = "提现申请列表上方数据", notes = "提现申请列表", tags = {"门店后台"}) + public R<Shop> shopCommissionStatisticsinfo(){ + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + Shop byId = shopService.getById(objectId); + return R.ok(byId); + } + @GetMapping("/shop/with") + @ApiOperation(value = "提现申请", notes = "提现申请列表", tags = {"门店后台"}) + public R<Shop> shopwith(@RequestParam BigDecimal money){ + Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); + Shop byId = shopService.getById(objectId); + if (money.compareTo(byId.getCanWithdrawMoney())>0){ + return R.fail("提现金额不能大于可提现金额"); + } + ShopWithdraw shopWithdraw = new ShopWithdraw(); + shopWithdraw.setShopId(objectId); + shopWithdraw.setMoney(money); + shopWithdraw.setAuditStatus(0); + shopWithdraw.setStatus(1); + shopWithdrawService.save(shopWithdraw); + + return R.ok(byId); + } + + /** * 审核 */ diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RechargeDto.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RechargeDto.java new file mode 100644 index 0000000..e92b73a --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/RechargeDto.java @@ -0,0 +1,16 @@ +package com.ruoyi.other.dto; + +import com.ruoyi.other.api.domain.RechargeSet; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.List; + +/** + * @author zhibing.pu + * @date 2024/12/18 18:03 + */ +@Data +public class RechargeDto { + private List<RechargeSet> rechargeSets; +} diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/ShopBalanceDto.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/ShopBalanceDto.java new file mode 100644 index 0000000..f5600b8 --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/ShopBalanceDto.java @@ -0,0 +1,21 @@ +package com.ruoyi.other.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +@Data +public class ShopBalanceDto { + @ApiModelProperty("分佣总金额") + private BigDecimal bigDecimal1; + @ApiModelProperty("服务费分佣") + private BigDecimal bigDecimal2; + @ApiModelProperty("关联用户分佣") + private BigDecimal bigDecimal3; + @ApiModelProperty("下级门店分佣") + private BigDecimal bigDecimal4; + @ApiModelProperty("可提现金额") + private BigDecimal bigDecimal5; + @ApiModelProperty("已提现金额") + private BigDecimal bigDecimal6; +} diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java index 5bd4e28..fa5bbb4 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopBalanceStatementMapper.java @@ -16,8 +16,10 @@ * @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); + + List<ShopBalanceStatement> selectShopBalanceStatementList(@Param("bs") ShopBalanceStatement shopBalanceStatement); + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java index 5747e23..c8d43d8 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java @@ -6,6 +6,7 @@ import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.vo.NearbyShopVO; import com.ruoyi.other.vo.ShopDetailVO; +import com.ruoyi.other.vo.ShopStatistics; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; @@ -27,4 +28,6 @@ ShopDetailVO selectShopDetail(Integer shopId); + ShopStatistics getShopStatistics(String shopName); + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java index 9e265b5..2276d32 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java @@ -1,19 +1,17 @@ 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.api.domain.ShopPoint; +import com.ruoyi.other.mapper.ShopBalanceStatementMapper; 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.math.BigDecimal; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -26,32 +24,29 @@ */ @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())); + List<ShopBalanceStatement> shopBalanceStatements = this.baseMapper.selectShopBalanceStatementList(shopBalanceStatement); + + Map<Integer, BigDecimal> shopCommissionMap = shopBalanceStatements.stream() + .collect(Collectors.groupingBy( + ShopBalanceStatement::getType, + Collectors.reducing( + BigDecimal.ZERO, + ShopBalanceStatement::getVariableAmount, + BigDecimal::add + ) + )); + + BigDecimal totalCommission = shopCommissionMap.getOrDefault(1,BigDecimal.ZERO); + BigDecimal totalSubordinateCommission = shopCommissionMap.getOrDefault(2,BigDecimal.ZERO); + BigDecimal totalServiceCharge = shopCommissionMap.getOrDefault(3,BigDecimal.ZERO); + + BigDecimal totalAmount = totalCommission.add(totalSubordinateCommission).add(totalServiceCharge); + shopCommissionStatisticsVO.setTotalAmount(totalAmount); IPage<ShopBalanceStatement> statementIPage = this.baseMapper.queryShopBalanceStatementPage(page, shopBalanceStatement); shopCommissionStatisticsVO.setStatementIPage(statementIPage); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopStatistics.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopStatistics.java new file mode 100644 index 0000000..611f7f6 --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/ShopStatistics.java @@ -0,0 +1,89 @@ +package com.ruoyi.other.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("门店统计") +public class ShopStatistics { + + /** + * 门店积分总数 + */ + @ApiModelProperty("门店积分总数") + private Integer totalPoint; + + /** + * 门店返佣积分总数 + */ + @ApiModelProperty("门店返佣积分总数") + private Integer commissionPoint; + + /** + * 门店服务积分总数 + */ + @ApiModelProperty("门店服务积分总数") + private Integer servicePoint; + + /** + * 绑定下级门店返佣积分总数 + */ + @ApiModelProperty("绑定下级门店返佣积分总数") + private Integer bindCommissionPoint; + + /** + * 门店分佣总金额 + */ + @ApiModelProperty("门店分佣总金额") + private Double totalCommissionMoney; + + /** + * 门店分佣金额 + */ + @ApiModelProperty("门店分佣金额") + private Double commissionMoney; + + /** + * 绑定下级分佣金额 + */ + @ApiModelProperty("绑定下级分佣金额") + private Double bindCommissionMoney; + + /** + * 门店服务分佣金额 + */ + @ApiModelProperty("门店服务分佣金额") + private Double serviceCommissionMoney; + + /** + * 门店订单总数 + */ + @ApiModelProperty("门店订单总数") + private Integer totalOrder; + + /** + * 服务订单数 + */ + @ApiModelProperty("服务订单数") + private Integer serviceOrder; + + /** + * 单品-上门自提订单数 + */ + @ApiModelProperty("单品-上门自提订单数") + private Integer goodsOrder; + + /** + * 可提现金额 + */ + @ApiModelProperty("可提现金额") + private Double canWithdrawMoney; + + /** + * 已提现金额 + */ + @ApiModelProperty("已提现金额") + private Double alreadyWithdrawMoney; + +} diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml index cb0fc46..a99e82c 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopBalanceStatementMapper.xml @@ -2,45 +2,15 @@ <!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"> + <sql id="shopBalanceStatementList"> SELECT - id, - shop_id, - type, - historical_balance, - variable_amount, - balance, - create_time, - create_user_id, - object_id + tsbs.*, + ts.`name` shopName, + ts.shop_manager shopManagerName, + ts.phone 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 + t_shop_balance_statement tsbs + INNER JOIN t_shop ts ON ts.id = tsbs.shop_id <where> <if test="bs.shopName != null and bs.shopName != ''"> AND ts.`name` like concat('%', #{bs.shopName}, '%') @@ -58,5 +28,12 @@ AND tsbs.create_time BETWEEN #{bs.startTime} AND #{bs.endTime} </if> </where> + </sql> + + <select id="queryShopBalanceStatementPage" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement"> + <include refid="shopBalanceStatementList"/> + </select> + <select id="selectShopBalanceStatementList" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement"> + <include refid="shopBalanceStatementList"/> </select> </mapper> \ No newline at end of file diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml index 488c812..ce19e5c 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml @@ -82,4 +82,22 @@ </if> </where> </select> + <select id="getShopStatistics" resultType="com.ruoyi.other.vo.ShopStatistics"> + SELECT + SUM(ts.shop_all_point) totalPoint, + SUM(ts.share_point) commissionPoint, + SUM(ts.server_point) servicePoint, + SUM(ts.lower_level_giveaway_money) bindCommissionPoint, + SUM(ts.giveaway_all_money) totalCommissionMoney, + SUM(ts.giveaway_money) commissionMoney, + SUM(ts.lower_level_giveaway_money) bindCommissionMoney, + SUM(ts.server_giveaway_money) serviceCommissionMoney, + SUM(ts.order_number) totalOrder, + SUM(ts.server_order_number) serviceOrder, + SUM(ts.custom_order_number) goodsOrder, + SUM(ts.can_withdraw_money) canWithdrawMoney, + SUM(ts.withdraw_money) alreadyWithdrawMoney + FROM + t_shop ts + </select> </mapper> \ No newline at end of file -- Gitblit v1.7.1