ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
@@ -23,7 +23,7 @@ public AppUserClient create(Throwable cause) { return new AppUserClient() { @Override @Override public AppUser getAppUserById(Long id) { log.error("根据id获取用户失败:{}", cause.getMessage()); throw new RuntimeException("根据id获取用户失败"); @@ -52,6 +52,12 @@ log.error("获取用户祖籍列表失败:{}", cause.getMessage()); throw new RuntimeException("获取用户祖籍列表失败"); } @Override public R<AppUser> getSuperiorLeader(Long id) { return R.fail("获取直帮上级用户失败"); } @Override public R<Long> getVipCount(Long userId, Integer vipId) { log.error("获取直推会员数失败:{}", cause.getMessage()); ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
@@ -46,6 +46,9 @@ @GetMapping("/appletLogin/getUserAncestorList") R<List<AppUser>> getUserAncestorList(@RequestParam("id") Long id); @GetMapping("/appletLogin/getSuperiorLeader") R<AppUser> getSuperiorLeader(@RequestParam("id") Long id); @PostMapping("/app-user/getVipCount") ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserAddress.java
@@ -30,6 +30,9 @@ @TableId("id") private Long id; @TableField(exist = false) private String uid; @ApiModelProperty(value = "用户id") @TableField("app_user_id") ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/OrderGood.java
@@ -77,7 +77,11 @@ @ApiModelProperty(value = "获取返佣积分上级类型(1=直推上级,2=直帮上级)") @TableField("superior_type") private Integer superiorType; @ApiModelProperty(value = "获取分佣金额上级类型(1=直推上级,2=直帮上级)") @TableField("superior_price_type") private Integer superiorPriceType; @ApiModelProperty(value = "核销门店可获得服务费") @TableField("servuce_shop_charges") private BigDecimal servuceShopCharges; ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsVip.java
@@ -72,6 +72,10 @@ @TableField("superior_type") private Integer superiorType; @ApiModelProperty(value = "获取分佣金额上级类型(1=直推上级,2=直帮上级)") @TableField("superior_price_type") private Integer superiorPriceType; @ApiModelProperty(value = "核销门店可获得服务费") @TableField("servuce_shop_charges") private BigDecimal servuceShopCharges; ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java
@@ -39,15 +39,15 @@ @TableField("vip_info") private String vipInfo; @ApiModelProperty(value = "1级会员用 注册 天后 未成为黄金会员自动解绑推广人") @ApiModelProperty(value = "1级会员专用 自动解绑推广人天数: 达到设置天数未成为黄金会员自动解绑推广人") @TableField("vip_cancel_day") private Integer vipCancelDay; @ApiModelProperty(value = "1级会员用 注册 天后 未在商城下单,可更换推广人") @ApiModelProperty(value = "1级会员专用 可更换绑定人天数:用户在达到设置的天数未下单商品,可以更换绑定人") @TableField("vip_change_day") private Integer vipChangeDay; @ApiModelProperty(value = "钱包提现权限1开0关") @ApiModelProperty(value = "钱包提现权限:1开0关") @TableField("vip_withdrawal_role") private Integer vipWithdrawalRole; @@ -63,69 +63,73 @@ @TableField("vip_gift_role") private Integer vipGiftRole; @ApiModelProperty(value = "消费达到积分 后升级") @ApiModelProperty(value = "达成会员等级所需消费积分数量") @TableField("vip_level_up_shop") private BigDecimal vipLevelUpShop; private Integer vipLevelUpShop; @ApiModelProperty(value = "普通会员:达到消费积分后升级开关 1开0关") @ApiModelProperty(value = "通过消费积分达成会员等级的开关 1开0关") @TableField("vip_level_up_shop_role") private Integer vipLevelUpShopRole; @ApiModelProperty(value = "返佣达到积分 后升级") @ApiModelProperty(value = "达成会员等级所需的返佣积分数量") @TableField("vip_level_up_share") private BigDecimal vipLevelUpShare; private Integer vipLevelUpShare; @ApiModelProperty(value = "普通会员:返佣积分后升级开关 1开0关") @ApiModelProperty(value = "通过返佣积分达成会员等级的开关 1开0关") @TableField("vip_level_up_share_role") private Integer vipLevelUpShareRole; @ApiModelProperty(value = "创业者:消费并且返佣升级 1开0关") @TableField("vip_agent_level_up_role") private Integer vipAgentLevelUpRole; @ApiModelProperty(value = "普通会员:直推用户数 达到后升级") @ApiModelProperty(value = "达成会员等级所需的直推人数(包括钻石和代理)") @TableField("vip_direct_num") private Integer vipDirectNum; @ApiModelProperty(value = "普通会员:团队人数达到后升级") @ApiModelProperty(value = "达成会员等级所需的团队数量") @TableField("vip_team_num") private Integer vipTeamNum; @ApiModelProperty(value = "普通会员:推广人数升级开关 1开0关") @ApiModelProperty(value = "通过直推用户或团队数量的方式达成会员等级的开关 1开0关") @TableField("vip_level_up_num_role") private Integer vipLevelUpNumRole; @ApiModelProperty(value = "创业者:直推钻石会员") @ApiModelProperty(value = "达成会员等级所需准代理数(达成总代和合伙人用到)") @TableField("vip_direct_vip_num") private Integer vipDirectVipNum; @ApiModelProperty(value = "创业者:直推钻石会员开关 1开0关") @TableField("vip_direct_vip_role") private Integer vipDirectVipRole; @ApiModelProperty(value = "达成会员等级所需总代数量(达成合伙人用到)") @TableField("vip_team_vip_num") private Integer vipTeamVipNum; @ApiModelProperty(value = "保级:消费x天") @ApiModelProperty(value = "达成会员等级所需开店数量") @TableField("vip_open_shop_num") private Integer vipOpenShopNum; @ApiModelProperty(value = "消费积分保级周期(天)") @TableField("keep_buy_day") private Integer keepBuyDay; @ApiModelProperty(value = "保级:消费x分") @ApiModelProperty(value = "消费积分保级的积分阈值(分))") @TableField("keep_buy_point") private BigDecimal keepBuyPoint; private Integer keepBuyPoint; @ApiModelProperty(value = "保级:返佣x天") @ApiModelProperty(value = "返佣积分保的周期(天)") @TableField("keep_share_day") private Integer keepShareDay; @ApiModelProperty(value = "保级:返佣x分") @ApiModelProperty(value = "返佣积分保级的积分阈值(分)") @TableField("keep_share_point") private BigDecimal keepSharePoint; private Integer keepSharePoint; @ApiModelProperty(value = "保级:门店x天") @ApiModelProperty(value = "门店业绩积分保级的周期(天)") @TableField("keep_shop_day") private Integer keepShopDay; @ApiModelProperty(value = "保级:门店x分") @ApiModelProperty(value = "门店业绩积分保级的积分阈值(分)") @TableField("keep_shop_point") private BigDecimal keepShopPoint; private Integer keepShopPoint; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/VipGoodClientFallbackFactory.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.VipGood; import com.ruoyi.other.api.feignClient.VipGoodClient; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.web.bind.annotation.GetMapping; import java.util.List; public class VipGoodClientFallbackFactory implements FallbackFactory<VipGoodClient> { @Override public VipGoodClient create(Throwable cause) { return new VipGoodClient() { @GetMapping("/vip-good/getVipGoodsByVipId") @Override public R<List<VipGood>> getVipGoodsByVipId(Integer vipId) { return R.fail("根据会员id获取会员购买商品失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsBargainPriceClient.java
@@ -13,7 +13,7 @@ * @author zhibing.pu * @Date 2024/11/28 10:53 */ @FeignClient(contextId = "GoodsBargainPriceClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = GoodsBargainPriceClientFallbackFactory.class) @FeignClient(contextId = "GoodsBargainPriceClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = GoodsBargainPriceClientFallbackFactory.class) public interface GoodsBargainPriceClient { ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java
@@ -12,7 +12,7 @@ * @author zhibing.pu * @Date 2024/11/29 10:55 */ @FeignClient(contextId = "OrderActivityInfoClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderActivityInfoClientFallbackFactory.class) @FeignClient(contextId = "OrderActivityInfoClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = OrderActivityInfoClientFallbackFactory.class) public interface OrderActivityInfoClient { ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderClient.java
@@ -13,7 +13,7 @@ * 后台订单服务 * @author ruoyi */ @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderFallbackFactory.class) @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = OrderFallbackFactory.class) public interface OrderClient { @PostMapping(value = "/management/give/vip") public R<List<Long>> getOrderIdsByTechId(@RequestParam("id") Integer id); ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SeckillActivityInfoClient.java
@@ -13,7 +13,7 @@ * @author zhibing.pu * @Date 2024/11/28 10:38 */ @FeignClient(contextId = "SeckillActivityInfoClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = SeckillActivityInfoClientFallbackFactory.class) @FeignClient(contextId = "SeckillActivityInfoClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = SeckillActivityInfoClientFallbackFactory.class) public interface SeckillActivityInfoClient { ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
@@ -12,7 +12,7 @@ * @author zhibing.pu * @Date 2024/11/29 10:28 */ @FeignClient(contextId = "ShopClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = ShopClientFallbackFactory.class) @FeignClient(contextId = "ShopClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = ShopClientFallbackFactory.class) public interface ShopClient { ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SystemConfigClient.java
@@ -12,7 +12,7 @@ * @author zhibing.pu * @Date 2024/11/29 15:58 */ @FeignClient(contextId = "SystemConfigClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = SystemConfigClientFallbackFactory.class) @FeignClient(contextId = "SystemConfigClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = SystemConfigClientFallbackFactory.class) public interface SystemConfigClient { ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TechnicianClient.java
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestParam; @FeignClient(contextId = "TechnicianClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = TechnicianClientFallbackFactory.class) @FeignClient(contextId = "TechnicianClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = TechnicianClientFallbackFactory.class) public interface TechnicianClient { @PostMapping("/technician/shop/detail") ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/VipGoodClient.java
New file @@ -0,0 +1,18 @@ package com.ruoyi.other.api.feignClient; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.VipGood; import com.ruoyi.other.api.factory.VipGoodClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @FeignClient(contextId = "VipGoodClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = VipGoodClientFallbackFactory.class) public interface VipGoodClient { @GetMapping("/vip-good/getVipGoodsByVipId") public R<List<VipGood>> getVipGoodsByVipId(@RequestParam("subscribeId") Integer vipId); } ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -12,4 +12,6 @@ com.ruoyi.other.api.factory.SystemConfigClientFallbackFactory com.ruoyi.other.api.factory.StoreFallbackFactory com.ruoyi.other.api.factory.CouponClientFallbackFactory com.ruoyi.other.api.factory.TechnicianClientFallbackFactory com.ruoyi.other.api.factory.TechnicianClientFallbackFactory com.ruoyi.other.api.factory.PointSettingClientFallbackFactory com.ruoyi.other.api.factory.VipGoodClientFallbackFactory ruoyi-modules/ruoyi-job/pom.xml
@@ -16,6 +16,12 @@ </description> <dependencies> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-modules-order</artifactId> <version>3.6.2</version> </dependency> <!-- SpringCloud Alibaba Nacos --> <dependency> ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/AfterSalesTask.java
@@ -1,5 +1,6 @@ package com.ruoyi.job.task; import com.ruoyi.order.service.CommissionService; import lombok.extern.log4j.Log4j2; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; @@ -12,6 +13,8 @@ public class AfterSalesTask { @Resource private RedisTemplate<String, String> redisTemplate; @Resource private CommissionService commissionService; /** * 计算佣金(设置每分钟执行一次) @@ -22,6 +25,7 @@ // 从延迟队列中获取需要处理的订单 Set<String> orderIds = redisTemplate.opsForZSet().rangeByScore("delay_queue:commission", 0, now); if (orderIds != null && !orderIds.isEmpty()) { commissionService.calculationCommission(orderIds); // 处理完后移除已处理的订单 redisTemplate.opsForZSet().removeRangeByScore("delay_queue:commission", 0, now); } ruoyi-service/ruoyi-account/pom.xml
@@ -37,10 +37,10 @@ <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-seata</artifactId> </dependency> <!--<dependency>--> <!--<groupId>com.alibaba.cloud</groupId>--> <!--<artifactId>spring-cloud-starter-alibaba-seata</artifactId>--> <!--</dependency>--> <!-- SpringBoot Actuator --> <dependency> ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -221,12 +221,16 @@ @ResponseBody @GetMapping("/change") @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) public R<AppUser> change(@ApiParam("换绑用户id") Long userId){ public R<AppUser> change(@ApiParam("换绑用户手机号") String phone){ Long userId1 = tokenService.getLoginUserApplet().getUserid(); //获取绑定门店 AppUser user = appUserService.getById(userId1); user.setInviteUserId(userId); appUserService.updateById(user); AppUser byId = appUserService.getById(userId1); //获取绑定门店 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(); } @@ -290,6 +294,17 @@ return R.ok(list); } /** * 获取用户的直帮上级用户 */ @ResponseBody @PostMapping("/getSuperiorLeader") @ApiOperation(value = "获取用户的直帮上级用户") public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) { AppUser superiorLeader = appUserService.getSuperiorLeader(id); return R.ok(superiorLeader); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java
@@ -64,29 +64,59 @@ @ApiOperation(value = "添加", tags = {"小程序-个人中心首页-我的地址"}) public R add(@RequestBody UserAddress userAddress){ Long userId = tokenService.getLoginUserApplet().getUserid(); if (userAddress.getIsDefault()==1){ List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); for (UserAddress userAddress1 : list) { userAddress1.setIsDefault(0); } userAddressService.updateBatchById(list); } userAddress.setAppUserId(userId); userAddressService.save(userAddress); return R.ok(); } @ResponseBody @GetMapping("/list") @ApiOperation(value = "列表", tags = {"小程序-个人中心首页-我的地址"}) public R list(){ Long userId = tokenService.getLoginUserApplet().getUserid(); List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).orderByDesc(UserAddress::getIsDefault).list(); for (UserAddress userAddress : list) { userAddress.setUid(userAddress.getId().toString()); } return R.ok(list); } @ResponseBody @PostMapping("/edit") @ApiOperation(value = "编辑", tags = {"小程序-个人中心首页-我的地址"}) public R edit(@RequestBody UserAddress userAddress){ Long userId = tokenService.getLoginUserApplet().getUserid(); if (userAddress.getIsDefault()==1){ List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); for (UserAddress userAddress1 : list) { userAddress1.setIsDefault(0); } userAddressService.updateBatchById(list); } userAddressService.updateById(userAddress); return R.ok(); } @ResponseBody @PostMapping("/delete") @GetMapping("/delete") @ApiOperation(value = "删除", tags = {"小程序-个人中心首页-我的地址"}) public R edit(@RequestParam Integer id){ public R edit(@RequestParam String id){ userAddressService.removeById(id); return R.ok(); } @ResponseBody @PostMapping("/set") @GetMapping("/set") @ApiOperation(value = "设为默认", tags = {"小程序-个人中心首页-我的地址"}) public R set(@RequestParam Integer id){ public R set(@RequestParam String id){ Long userId = tokenService.getLoginUserApplet().getUserid(); List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); for (UserAddress userAddress : list) { ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
@@ -52,7 +52,7 @@ @PostMapping("/mine/list") @GetMapping("/mine/list") @ApiOperation(value = "已领取列表", tags = {"小程序-个人中心-优惠劵"}) public R<Page<UserCoupon>> minelist(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status) { Long userid = tokenService.getLoginUserApplet().getUserid(); @@ -60,7 +60,7 @@ .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime) .isNotNull(status!=null&&status==2,UserCoupon::getUseTime) .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()) .eq(UserCoupon::getAppUserId, userid).page(Page.of(pageNum, pageSize)); .eq(UserCoupon::getAppUserId, userid).page(Page.of(pageNum-1, pageSize)); for (UserCoupon record : page.getRecords()) { CouponInfo data = couponClient.detail(record.getCouponId()).getData(); CouponInfoVo vo = new CouponInfoVo(); @@ -79,7 +79,7 @@ } @PostMapping("/get") @GetMapping("/get") @ApiOperation(value = "领取或者兑换优惠券", tags = {"小程序-个人中心-优惠劵"}) public R<Page<UserCoupon>> get(@RequestParam Integer couponId) { ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserSignRecordController.java
@@ -1,8 +1,22 @@ package com.ruoyi.account.controller; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserSignRecord; import com.ruoyi.account.service.UserSignRecordService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; 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.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; /** * <p> @@ -15,6 +29,22 @@ @RestController @RequestMapping("/user-sign-record") public class UserSignRecordController { @Resource private UserSignRecordService userSignRecordService; @Resource private TokenService tokenService; @ResponseBody @GetMapping("/sign") @ApiOperation(value = "签到", tags = {"小程序-签到"}) public R<AppUser> change(){ Long userId1 = tokenService.getLoginUserApplet().getUserid(); UserSignRecord userSignRecord = new UserSignRecord(); userSignRecord.setAppUserId(userId1); userSignRecord.setCreateTime(LocalDateTime.now()); userSignRecord.setRedAmount(new BigDecimal(0)); userSignRecord.setSignDay(LocalDate.now()); return R.ok(); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java
File was deleted ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java
New file @@ -0,0 +1,190 @@ package com.ruoyi.account.controller; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.VipSettingService; import com.ruoyi.account.vo.vip.Level; import com.ruoyi.account.vo.vip.VipLevel; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.api.feignClient.BaseSettingClient; import com.ruoyi.other.api.feignClient.GoodsVipClient; import com.ruoyi.other.api.feignClient.RemoteVipSettingClient; import com.ruoyi.other.api.feignClient.VipGoodClient; import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @RestController @RequestMapping("/vipCenter") @Api(tags = "小程序-会员中心") @Log4j2 public class VipCenterController { @Resource private RemoteVipSettingClient remoteVipSettingClient; @Resource private BaseSettingClient baseSettingClient; @Resource private GoodsVipClient goodsVipClient; @Resource private VipSettingService vipSettingService; @Resource private TokenService tokenService; @Resource private VipGoodClient vipGoodClient; @Resource private AppUserService appUserService; @GetMapping("getVipLevelList") @ApiOperation(value = "会员等级列表", tags = {"会员中心-小程序"}) public R<VipLevel> vipLevelList() { try { R<List<VipSetting>> r = remoteVipSettingClient.list(); if (!checkSuccess(r)) { return R.fail("会员等级获取失败"); } List<VipSetting> vipSettingList = r.getData(); if (vipSettingList == null || vipSettingList.isEmpty()) { return R.fail("会员等级获取失败"); } R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(3); if (!checkSuccess(baseSettingR)) { log.error("【会员设置说明】获取失败:{}", baseSettingR.getMsg()); return R.fail("会员等级获取失败"); } BaseSetting baseSetting = baseSettingR.getData(); if (baseSetting == null) { log.error("【会员设置说明】未设置"); return R.fail("会员等级获取失败"); } Long userid = tokenService.getLoginUserApplet().getUserid(); VipSetting loginUserVipSetting = vipSettingService.getVipSettingByUserId(userid); VipLevel vipLevel = new VipLevel(); List<Level> levelList = new ArrayList<>(); // 批量获取 goodsVip 和 vipGoods List<Integer> vipIds = vipSettingList.stream().map(VipSetting::getId).collect(Collectors.toList()); Map<Integer, R<GoodsVip>> goodsVipMap = getGoodsVips(vipIds); Map<Integer, R<List<VipGood>>> vipGoodsMap = getVipGoods(vipIds); vipSettingList.forEach(vipSetting -> { Level level = new Level(); level.setId(vipSetting.getId()); level.setName(vipSetting.getVipName()); level.setVipInfo(vipSetting.getVipInfo()); level.setVipDesc(baseSetting.getContent()); level.setVipLevelUpShop(vipSetting.getVipLevelUpShop()); level.setVipLevelUpShare(vipSetting.getVipLevelUpShare()); level.setKeepBuyDay(vipSetting.getKeepBuyDay()); level.setKeepBuyPoint(vipSetting.getKeepBuyPoint()); level.setKeepShareDay(vipSetting.getKeepShareDay()); level.setKeepSharePoint(vipSetting.getKeepSharePoint()); level.setKeepShopDay(vipSetting.getKeepShopDay()); level.setKeepShopPoint(vipSetting.getKeepShopPoint()); R<GoodsVip> goodsVipR = goodsVipMap.get(vipSetting.getId()); if (R.isSuccess(goodsVipR)) { R<List<VipGood>> vipGoodR = vipGoodsMap.get(vipSetting.getId()); if (R.isSuccess(vipGoodR)) { List<VipGood> vipGoodList = vipGoodR.getData(); if (vipGoodList != null && !vipGoodList.isEmpty()) { List<String> goodsNames = new ArrayList<>(); vipGoodList.forEach(vipGood -> { String goodJson = vipGood.getGoodJson(); if (isValidJson(goodJson)) { Goods goods = JSONObject.parseObject(goodJson, Goods.class); goodsNames.add(goods.getName()); } else { log.warn("JSON无效: " + goodJson); } }); level.setGoodsNames(goodsNames); } } } levelList.add(level); }); vipLevel.setLevelList(levelList); vipLevel.setCurrentLevel(loginUserVipSetting.getId()); return R.ok(vipLevel); } catch (Exception e) { log.error("会员等级获取失败", e); return R.fail("会员等级获取失败"); } } public R<Void> test() { LoginUser loginUserApplet = tokenService.getLoginUserApplet(); AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); if (appUser.getShopPoint() < 500){ return R.fail("消费积分不足500"); } if (appUser.getSharePoint() < 500){ return R.fail("返佣积分不足500"); } // 当前用户的直推用户 // List<AppUser> bottomUsers = appUserService.list(new LambdaQueryWrapper<AppUser>() // .eq(AppUser::getInviteUserId, loginUserApplet.getUserid()) // .eq(AppUser::getVipId)); return null; } private boolean checkSuccess(R<?> r) { if (!R.isSuccess(r)) { log.error("请求失败: " + r.getMsg()); } return R.isSuccess(r); } private Map<Integer, R<GoodsVip>> getGoodsVips(List<Integer> vipIds) { Map<Integer, R<GoodsVip>> result = new HashMap<>(); for (Integer vipId : vipIds) { R<GoodsVip> goodsVipR = goodsVipClient.getGoodsVip(vipId); result.put(vipId, goodsVipR); } return result; } private Map<Integer, R<List<VipGood>>> getVipGoods(List<Integer> vipIds) { Map<Integer, R<List<VipGood>>> result = new HashMap<>(); for (Integer vipId : vipIds) { // R<List<VipGood>> vipGoodR = vipGoodClient.getVipGoodsByVipId(vipId); // result.put(vipId, vipGoodR); } return result; } private boolean isValidJson(String json) { try { JSONObject.parseObject(json); return true; } catch (Exception e) { return false; } } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
@@ -62,4 +62,9 @@ * 获取用户的祖籍列表 */ List<AppUser> getUserAncestorList(Long id,List<AppUser> list); /** * 获取指定用户的直帮上级用户(消费用户绑定的上级,最近一个用户会员类型为【创业者】的用户) */ AppUser getSuperiorLeader(Long id); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -380,4 +380,19 @@ return list; } @Override public AppUser getSuperiorLeader(Long id) { AppUser appUser = getById(id); Long inviteUserId = appUser.getInviteUserId(); AppUser inviteUser = getById(inviteUserId); if (inviteUser == null){ return null; } if (inviteUser.getVipId() > 3) { return inviteUser; }else { getSuperiorLeader(inviteUserId); } return null; } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java
@@ -54,7 +54,7 @@ walletVO.setAuditAmount(waitAuditList.stream() .map(WithdrawalRequests::getWithdrawalAmount) .reduce(BigDecimal.ZERO, BigDecimal::add)); walletVO.setBalance(appUser.getBalance()); return walletVO; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java
@@ -26,33 +26,38 @@ private String vipDesc; @ApiModelProperty(value = "消费达到积分 后升级") private BigDecimal vipLevelUpShop; private Integer vipLevelUpShop; @ApiModelProperty(value = "返佣达到积分 后升级") private BigDecimal vipLevelUpShare; private Integer vipLevelUpShare; @ApiModelProperty(value = "升级会员的直推用户人数要求") private Integer vipDirectNum; @ApiModelProperty(value = "升级会员的团队数要求") @ApiModelProperty(value = "升级会员的团队数要求/准代人数") private Integer vipTeamNum; @ApiModelProperty(value = "保级:消费x天") private Integer keepBuyDay; @ApiModelProperty(value = "保级:消费x分") private BigDecimal keepBuyPoint; private Integer keepBuyPoint; @ApiModelProperty(value = "保级:返佣x天") private Integer keepShareDay; @ApiModelProperty(value = "保级:返佣x分") private BigDecimal keepSharePoint; private Integer keepSharePoint; @ApiModelProperty(value = "保级:门店x天") private Integer keepShopDay; @ApiModelProperty(value = "保级:门店x分") private BigDecimal keepShopPoint; private Integer keepShopPoint; @ApiModelProperty(value = "指定购买商品") private List<String> goodsNames; ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java
@@ -2,11 +2,12 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Set; public interface CommissionService { // 计算佣金 void calculationCommission(List<Long> orderIds); void calculationCommission(Set<String> orderIds); void addToCommissionDelayQueue(Long orderId, LocalDateTime afterSalesDeadline); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
@@ -20,6 +20,7 @@ import java.time.ZoneId; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @Service @@ -49,7 +50,7 @@ } @Override public void calculationCommission(List<Long> orderIds) { public void calculationCommission(Set<String> orderIds) { List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() .in(OrderGood::getOrderId, orderIds)); @@ -77,32 +78,51 @@ throw new RuntimeException("获取用户信息失败"); } Long inviteUserId = appUser.getInviteUserId(); // 直推上级用户 AppUser inviteUser = appUserClient.getAppUserById(inviteUserId); // 获取直帮上级用户 R<AppUser> superiorLeaderR = appUserClient.getSuperiorLeader(appUserId); if (!R.isSuccess(superiorLeaderR)) { throw new RuntimeException("获取直帮上级信息失败"); } AppUser superiorLeader = superiorLeaderR.getData(); for (OrderGood og : v) {// 累计分销金额 // 上级分销金额 if (inviteUser != null){ // 直推上级分佣金额 Integer superiorType = og.getSuperiorType(); if (superiorType == 1 && inviteUser != null){ // 分佣金额 BigDecimal superiorSubcommission = og.getSuperiorSubcommission(); BigDecimal totalDistributionAmount = inviteUser.getTotalDistributionAmount(); totalDistributionAmount = totalDistributionAmount.add(superiorSubcommission); // Integer superiorType = og.getSuperiorType(); inviteUser.setTotalDistributionAmount(totalDistributionAmount); // 分佣积分 Integer sharePoint = inviteUser.getSharePoint(); if (superiorType == 1) { Integer superiorRebatePoints = og.getSuperiorRebatePoints(); sharePoint = sharePoint + superiorRebatePoints; inviteUser.setSharePoint(sharePoint); appUserClient.editAppUserById(inviteUser); }else // 直帮上级分佣金额 if (superiorType == 2 && superiorLeader != null){ // 分佣金额 BigDecimal superiorSubcommission = og.getSuperiorSubcommission(); BigDecimal totalDistributionAmount = superiorLeader.getTotalDistributionAmount(); totalDistributionAmount = totalDistributionAmount.add(superiorSubcommission); superiorLeader.setTotalDistributionAmount(totalDistributionAmount); // 分佣积分 Integer sharePoint = superiorLeader.getSharePoint(); Integer superiorRebatePoints = og.getSuperiorRebatePoints(); sharePoint = sharePoint + superiorRebatePoints; } else if (superiorType == 2) { superiorLeader.setSharePoint(sharePoint); } else { continue; appUserClient.editAppUserById(superiorLeader); } inviteUser.setTotalDistributionAmount(totalDistributionAmount); inviteUser.setSharePoint(sharePoint); } // 门店分销金额 og.getBoundShopCharges(); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -421,35 +421,37 @@ paymentUserCoupon.setType(confirmOrder.getType()); if(confirmOrder.getPaymentType() == 1){ List<PaymentUserCouponVo> data = userCouponClient.getPaymentUserCoupon(paymentUserCoupon).getData(); for (PaymentUserCouponVo couponInfo : data) { List<Integer> forGoodIds = couponInfo.getForGoodIds(); //全部商品适用 if(null == forGoodIds){ //满减券 if(1 == couponInfo.getCouponType() && orderMoney.compareTo(couponInfo.getConditionAmount()) >= 0){ couponInfo.setAvailable(true); } //代金券和折扣券 if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ couponInfo.setAvailable(true); } }else{ //部分商品适用 BigDecimal goodsMoney = BigDecimal.ZERO; for (MyShoppingCartVo myShoppingCartVo : goodsList) { Integer goodsId = myShoppingCartVo.getGoodsId(); BigDecimal cash = myShoppingCartVo.getCash(); if(forGoodIds.contains(goodsId)){ goodsMoney = goodsMoney.add(cash); if(null != data){ for (PaymentUserCouponVo couponInfo : data) { List<Integer> forGoodIds = couponInfo.getForGoodIds(); //全部商品适用 if(null == forGoodIds){ //满减券 if(1 == couponInfo.getCouponType() && orderMoney.compareTo(couponInfo.getConditionAmount()) >= 0){ couponInfo.setAvailable(true); } } //满减 if(1 == couponInfo.getCouponType() && couponInfo.getConditionAmount().compareTo(goodsMoney) <= 0){ couponInfo.setAvailable(true); } //代金券 if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ couponInfo.setAvailable(true); //代金券和折扣券 if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ couponInfo.setAvailable(true); } }else{ //部分商品适用 BigDecimal goodsMoney = BigDecimal.ZERO; for (MyShoppingCartVo myShoppingCartVo : goodsList) { Integer goodsId = myShoppingCartVo.getGoodsId(); BigDecimal cash = myShoppingCartVo.getCash(); if(forGoodIds.contains(goodsId)){ goodsMoney = goodsMoney.add(cash); } } //满减 if(1 == couponInfo.getCouponType() && couponInfo.getConditionAmount().compareTo(goodsMoney) <= 0){ couponInfo.setAvailable(true); } //代金券 if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ couponInfo.setAvailable(true); } } } } @@ -493,7 +495,7 @@ for (ShoppingCart shoppingCart : list) { Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); MyShoppingCartVo vo = new MyShoppingCartVo(); vo.setId(shoppingCart.getId()); vo.setId(shoppingCart.getId().toString()); vo.setGoodsId(goods.getId()); vo.setHomePicture(goods.getHomePagePicture()); vo.setName(goods.getName()); @@ -510,6 +512,7 @@ //获取支付价格 Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId); if(null == price){ price = new Price(); //使用商品的基础价格 price.setCash(1 == goods.getCashPayment() ? goods.getSellingPrice() : null); price.setPoint(1 == goods.getPointPayment() ? goods.getIntegral() : null); @@ -829,7 +832,7 @@ } } //判断运费支付是否足够 if(2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){ if(null != shoppingCartPayment.getFreightPaymentType() && 2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){ BigDecimal balance = appUser.getBalance(); if(balance.compareTo(expressFee) < 0){ return R.fail("账户余额不足"); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java
@@ -14,7 +14,7 @@ @ApiModel("购物车") public class MyShoppingCartVo { @ApiModelProperty("数据id") private Long id; private String id; @ApiModelProperty("商品id") private Integer goodsId; @ApiModelProperty("封面图") ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderVO.java
@@ -10,7 +10,7 @@ @Data public class OrderVO { @ApiModelProperty(value = "订单id") private Integer id; private Long id; @ApiModelProperty(value = "订单编号") private String orderNumber; ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/SetGoodsNumber.java
@@ -12,7 +12,7 @@ @ApiModel public class SetGoodsNumber { @ApiModelProperty(value = "购物车数据id", required = true) private Integer id; private Long id; @ApiModelProperty(value = "修改数量", required = true) private Integer number; } ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -32,7 +32,8 @@ o.good_pics, o.num, o.point, o.payment_amount o.payment_amount, o.create_time ORDER BY o.create_time DESC </select> ruoyi-service/ruoyi-other/pom.xml
@@ -44,10 +44,10 @@ <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-seata</artifactId> </dependency> <!--<dependency>--> <!--<groupId>com.alibaba.cloud</groupId>--> <!--<artifactId>spring-cloud-starter-alibaba-seata</artifactId>--> <!--</dependency>--> <!-- SpringBoot Actuator --> <dependency> ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
@@ -46,7 +46,7 @@ } @PostMapping("/gift/list") @GetMapping("/gift/list") @ApiOperation(value = "待领取列表", tags = {"小程序-个人中心-优惠劵"}) public R<List<CouponInfo>> giftlist(){ Long userid = tokenService.getLoginUserApplet().getUserid(); ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -47,9 +47,9 @@ */ @GetMapping("/getGoodsListByShopId") @ApiOperation(value = "商品列表", tags = {"小程序-首页-门店详情-商品购买列表"}) public R<List<Goods>> getGoodsListByShopId(@ApiParam("门店id") @RequestParam Integer shopId) { public R<TableDataInfo> getGoodsListByShopId(@ApiParam("门店id") @RequestParam Integer shopId) { startPage(); return R.ok(goodsService.getGoodsListByShopId(shopId)); return R.ok(getDataTable(goodsService.getGoodsListByShopId(shopId))); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -71,17 +71,6 @@ return R.ok(shopService.nearbyShopList(longitude, latitude)); } /** * 门店详情 */ @GetMapping("/technicianList") @ApiOperation(value = "技师列表", tags = {"技师列表-小程序"}) public AjaxResult technicianList(@ApiParam("门店id") @RequestParam String shopId){ return success(technicianService.list(new LambdaQueryWrapper<Technician>() .eq(Technician::getShopId,shopId) .eq(Technician::getStatus,2) .eq(Technician::getSubscribeStatus,1))); } @GetMapping("/shopDetail") @ApiOperation(value = "门店详情", tags = {"小程序-首页-门店详情"}) ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
@@ -2,11 +2,14 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.feignClient.OrderClient; import com.ruoyi.other.service.GoodsEvaluateService; import com.ruoyi.other.service.TechnicianService; import com.ruoyi.other.service.TechnicianSubscribeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import javax.annotation.Resource; @@ -30,7 +33,8 @@ */ @RestController @RequestMapping("/technician") public class TechnicianController { @Api(tags = "技师") public class TechnicianController extends BaseController { @Resource private TechnicianService technicianService; @Resource @@ -103,8 +107,9 @@ */ @GetMapping("/technicianListByShopId") @ApiOperation(value = "技师列表", tags = {"技师列表-小程序"}) public R<List<TechnicianVO>> technicianListByShopId(@ApiParam("门店id") @RequestParam Long shopId) { return R.ok(technicianService.getTechnicianListByShopId(shopId)); public R<TableDataInfo<TechnicianVO>> technicianListByShopId(@ApiParam("门店id") @RequestParam Long shopId) { startPage(); return R.ok(getDataTable(technicianService.getTechnicianListByShopId(shopId))); } /** ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipGoodController.java
@@ -1,8 +1,18 @@ package com.ruoyi.other.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.other.api.domain.VipGood; import com.ruoyi.other.service.VipGoodService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; /** * <p> @@ -14,7 +24,14 @@ */ @RestController @RequestMapping("/vip-good") public class VipGoodController { public class VipGoodController extends BaseController { @Resource private VipGoodService vipGoodService; @GetMapping("getVipGoodsByVipId") public R<List<VipGood>> getVipGoodsByVipId(@RequestParam("vipId") Integer vipId){ return R.ok(vipGoodService.list(new LambdaQueryWrapper<VipGood>() .eq(VipGood::getVipId, vipId))); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java
@@ -36,8 +36,9 @@ @Resource private VipGoodService vipGoodService; @GetMapping("/list") public R<List<VipSetting>> list() { @GetMapping("/info") @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页", "小程序-会员中心"}) public R<List<VipSetting>> info() { List<VipSetting> list = vipSettingService.list(); return R.ok(list); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.other.api.domain.Goods; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -14,5 +15,5 @@ * @since 2024-11-20 */ public interface GoodsMapper extends BaseMapper<Goods> { List<Goods> selectListByShopId(Integer shopId, Integer vip); List<Goods> selectListByShopId(@Param("shopId") Integer shopId,@Param("vip") Integer vip); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -101,6 +101,8 @@ Goods goods = this.getById(goodsId); GoodsVO goodsVO = new GoodsVO(); BeanUtils.copyBeanProp(goodsVO, goods); goodsVO.setGoodsId(goods.getId()); goodsVO.setGoodsName(goods.getName()); goodsVO.setSellingPrice(sellingPrice); goodsVO.setIntegral(integral); return goodsVO; ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java
@@ -50,4 +50,5 @@ @ApiModelProperty(value = "已售数量") private Integer saleNum; } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianDetailVO.java
@@ -1,11 +1,13 @@ package com.ruoyi.other.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value="技师详情对象", description="技师详情对象") public class TechnicianDetailVO { /** ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianVO.java
@@ -1,12 +1,14 @@ package com.ruoyi.other.vo; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value="技师对象", description="技师对象") public class TechnicianVO { @ApiModelProperty(value = "主键") private Long id;