ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java
@@ -80,6 +80,11 @@ @ApiModelProperty(value = "添加时间") @TableField("create_time") private LocalDateTime createTime; @ApiModelProperty(value = "用户姓名") @TableField(exist = false) private String userName; @ApiModelProperty(value = "用户电话") @TableField(exist = false) private String userPhone; } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -41,6 +42,9 @@ @ApiModelProperty(value = "用户") @TableField("name") private String name; @ApiModelProperty("会员名称") @TableField(exist = false) private String vipName; @ApiModelProperty(value = "手机号") @TableField("phone") @@ -68,6 +72,7 @@ @ApiModelProperty(value = "添加时间") @TableField("create_time") @JsonFormat(pattern = "yyyy-MM-dd") private LocalDateTime createTime; @ApiModelProperty(value = "删除(0=否,1=是)") @@ -102,6 +107,9 @@ @ApiModelProperty(value = "绑定门店名称") @TableField(exist = false) private String shopName; @ApiModelProperty(value = "绑定门店列表") @TableField(exist = false) private List<String> shopNames; @ApiModelProperty(value = "绑定门店封面") @TableField(exist = false) private String shopCover; @@ -247,6 +255,15 @@ @TableField(exist = false) private Set<Integer> shopIds; @ApiModelProperty(value = "降级预警") @TableField("is_danger") private Integer isDanger; @ApiModelProperty(value = "最后下单时间") @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime lastOrderTime; ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserCancellationLog.java
@@ -49,5 +49,10 @@ @TableField("vip_id") private Integer vipId; @TableField(exist = false) private String userName; @TableField(exist = false) private String userPhone; } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserChangeLog.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -39,6 +40,7 @@ @ApiModelProperty(value = "添加时间") @TableField("create_time") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; @ApiModelProperty(value = "用户id") @@ -53,9 +55,15 @@ @TableField("after_vip_id") private Integer afterVipId; @ApiModelProperty(value = "变更类型") @ApiModelProperty(value = "变更类型 0降级1升级") @TableField("change_type") private Integer changeType; @ApiModelProperty("用户姓名") @TableField(exist = false) private String userName; @ApiModelProperty("用户电话") @TableField(exist = false) private String userPhone; } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java
@@ -52,6 +52,11 @@ public R<Price> getGoodsPrice(Long appUserId, Integer goodsId, Integer shopId) { return R.fail("获取商品价格失败"); } @Override public R<Order> getLastOrder(Long appUserId) { return R.fail("获取订单失败"); } }; } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java
@@ -31,6 +31,10 @@ @PostMapping("/order/getOrderListByIds") public R<List<Order>> getOrderListByIds(@RequestBody List<Long> orderIds); @PostMapping("/order/byUserId") public R<List<Order>> byUserId(@RequestParam("appUserId")Long appUserId); /** * 根据用户id和商品id查找订单列表 */ @@ -57,4 +61,6 @@ @GetMapping("/shopping-cart/getGoodsPrice") public R<Price> getGoodsPrice(@RequestParam("appUserId") Long appUserId, @RequestParam("goodsId") Integer goodsId, @RequestParam("shopId") Integer shopId); @PostMapping("/order/getLastOrder") public R<Order> getLastOrder(@RequestParam("appUserId") Long appUserId); } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
@@ -18,7 +18,12 @@ public R<Shop> getShopById(Integer id) { return R.fail("根据id获取门店信息失败:" + cause.getMessage()); } @Override public R<List<Shop>> getShopByUserId(Long id) { return R.fail("根据用户id集合获取门店数据失败"); } @Override public R<Shop> getShopByPhone(String phone) { return R.fail("根据店铺管理员电话获取门店数据失败:" + cause.getMessage()); ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
@@ -29,7 +29,9 @@ */ @PostMapping("/shop/getShopById") R<Shop> getShopById(@RequestParam("id") Integer id); @PostMapping("/shop/getShopByUserId") R<List<Shop>> getShopByUserId(@RequestParam("id") Long id); /** * 根据店铺管理员电话获取门店数据 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
@@ -1,16 +1,22 @@ package com.ruoyi.account.controller; import java.time.LocalDateTime; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.dto.AgentQuery; import com.ruoyi.account.service.AgentApplicationService; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserChangeLogService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.other.api.domain.VipSetting; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.ApiParam; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -27,6 +33,8 @@ public class AgentApplicationController extends BaseController { @Resource private AgentApplicationService agentApplicationService; @Resource private AppUserService appUserService; @PostMapping("/apply") @ApiOperation(value = "会员申请", tags = {"会员中心-小程序"}) @@ -35,5 +43,46 @@ return R.ok(); } @PostMapping("/page") @ApiOperation(value = "会员申请列表", tags = {"后台"}) public R<IPage<AgentApplication>> page(@RequestBody AgentQuery agentQuery) { return R.ok(agentApplicationService.pageList(agentQuery)); } @GetMapping("/detail") @ApiOperation(value = "会员申请详情", tags = {"会员中心-小程序"}) public R<AgentApplication> detail(@RequestParam Long id) { return R.ok(agentApplicationService.getById(id)); } @Resource private UserChangeLogService userChangeLogService; @GetMapping("/auth") @ApiOperation(value = "会员申请审核", tags = {"会员中心-小程序"}) public R<AgentApplication> auth(@RequestParam Long id, @ApiParam("2'已处理-同意',3'已处理-拒绝")Integer status,@ApiParam("处理意见") String remark) { AgentApplication byId = agentApplicationService.getById(id); byId.setStatus(status); byId.setRemark(remark); agentApplicationService.updateById(byId); AppUser byId1 = appUserService.getById(byId.getAppUserId()); //插入等级变化数据 UserChangeLog userChangeLog = new UserChangeLog(); userChangeLog.setCreateTime(LocalDateTime.now()); userChangeLog.setAppUserId(byId.getAppUserId()); userChangeLog.setBeforeVipId(byId1.getVipId()); userChangeLog.setAfterVipId(byId.getApplicationVipId()); if (userChangeLog.getBeforeVipId()>userChangeLog.getAfterVipId()) { userChangeLog.setChangeType(0); }else { userChangeLog.setChangeType(1); } userChangeLogService.save(userChangeLog); //变更会员等级 byId1.setVipId(byId.getApplicationVipId()); return R.ok(byId); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -2,19 +2,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.account.api.model.AppUser; 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.service.AppUserService; import com.ruoyi.account.service.UserCancellationLogService; import com.ruoyi.account.service.UserCouponService; import com.ruoyi.account.service.UserSignRecordService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.*; import com.ruoyi.account.dto.DangerInfoDto; import com.ruoyi.account.service.*; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; import com.ruoyi.order.model.Order; 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.feignClient.StoreClient; import com.ruoyi.other.api.feignClient.VipSettingClient; import io.swagger.annotations.*; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -57,6 +59,12 @@ @Resource private UserSignRecordService userSignRecordService; @Resource private VipSettingClient vipSettingClient; @Resource private UserPointService userPointService; @Resource private VipSettingService vipSettingService; @ResponseBody @@ -354,6 +362,116 @@ return R.ok(appuserPage); } @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(); } @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); } @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("/getAppUserByPhone") public R<AppUser> getAppUserByPhone(String phone){ @@ -363,5 +481,6 @@ } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCancellationLogController.java
@@ -1,8 +1,20 @@ package com.ruoyi.account.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.dto.AgentQuery; import com.ruoyi.account.dto.UserCancelQuery; import com.ruoyi.account.service.UserCancellationLogService; import com.ruoyi.common.core.domain.R; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; /** * <p> @@ -15,6 +27,14 @@ @RestController @RequestMapping("/user-cancellation-log") public class UserCancellationLogController { @Resource private UserCancellationLogService cancellationLogService; @PostMapping("/page") @ApiOperation(value = "注销记录列表", tags = {"后台"}) public R<IPage<UserCancellationLog>> page(@RequestBody UserCancelQuery agentQuery) { return R.ok(cancellationLogService.pageList(agentQuery)); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserChangeLogController.java
@@ -1,7 +1,10 @@ package com.ruoyi.account.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.dto.UserChangeQuery; import com.ruoyi.account.service.UserChangeLogService; import com.ruoyi.common.core.domain.R; import org.springframework.web.bind.annotation.PostMapping; @@ -37,9 +40,16 @@ userChangeLogService.save(userChangeLog); return R.ok(); } @PostMapping("/page") public R<IPage<UserChangeLog>> page(@RequestBody UserChangeQuery userChangeLog){ return R.ok(userChangeLogService.pageList(userChangeLog)); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/AgentQuery.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.account.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class AgentQuery { @ApiModelProperty("用户名称") private String name; @ApiModelProperty("电话") private String phone; @ApiModelProperty("会员等级") private Integer vipId; @ApiModelProperty("1'待处理',2'已处理-同意',3'已处理-拒绝'") private Integer status; private Integer pageNum; private Integer pageSize; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/DangerInfoDto.java
New file @@ -0,0 +1,42 @@ package com.ruoyi.account.dto; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class DangerInfoDto { @ApiModelProperty(value = "消费积分保级周期(天)") @TableField("keep_buy_day") private Integer keepBuyDay; @ApiModelProperty(value = "消费积分保级的积分阈值(分))") @TableField("keep_buy_point") private Integer keepBuyPoint; @ApiModelProperty(value = "当前消费积分") private Integer userKeepBuyPoint; @ApiModelProperty(value = "返佣积分保的周期(天)") @TableField("keep_share_day") private Integer keepShareDay; @ApiModelProperty(value = "返佣积分保级的积分阈值(分)") @TableField("keep_share_point") private Integer keepSharePoint; @ApiModelProperty(value = "当前返佣积分") @TableField("keep_share_point") private Integer userKeepSharePoint; @ApiModelProperty(value = "门店业绩积分保级的周期(天)") @TableField("keep_shop_day") private Integer keepShopDay; @ApiModelProperty(value = "门店业绩积分保级的积分阈值(分)") @TableField("keep_shop_point") private Integer keepShopPoint; @ApiModelProperty(value = "当前门店业绩积分") private Integer userKeepShopPoint; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/UserCancelQuery.java
New file @@ -0,0 +1,24 @@ package com.ruoyi.account.dto; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDate; @Data public class UserCancelQuery { @ApiModelProperty("用户名称") private String name; @ApiModelProperty("电话") private String phone; private Integer vipId; private LocalDate localDate1; private LocalDate localDate2; private Integer pageNum; private Integer pageSize; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/UserChangeQuery.java
New file @@ -0,0 +1,26 @@ package com.ruoyi.account.dto; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDate; @Data public class UserChangeQuery { @ApiModelProperty("用户名称") private String name; @ApiModelProperty("电话") private String phone; @ApiModelProperty(value = "变更类型 0降级1升级") @TableField("change_type") private Integer changeType; private LocalDate localDate1; private LocalDate localDate2; private Integer pageNum; private Integer pageSize; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AgentApplicationMapper.java
@@ -1,7 +1,12 @@ package com.ruoyi.account.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.dto.AgentQuery; import com.ruoyi.other.api.domain.Shop; import org.apache.ibatis.annotations.Param; /** * <p> @@ -13,4 +18,5 @@ */ public interface AgentApplicationMapper extends BaseMapper<AgentApplication> { IPage<AgentApplication> pageList(@Param("page") Page<Shop> page, @Param("agentQuery") AgentQuery agentQuery); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserCancellationLogMapper.java
@@ -1,7 +1,12 @@ package com.ruoyi.account.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.dto.UserCancelQuery; import com.ruoyi.other.api.domain.Shop; import org.apache.ibatis.annotations.Param; /** * <p> @@ -13,4 +18,5 @@ */ public interface UserCancellationLogMapper extends BaseMapper<UserCancellationLog> { IPage<UserCancellationLog> pageList(@Param("page")Page<Shop> page, @Param("agentQuery")UserCancelQuery agentQuery); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/UserChangeLogMapper.java
@@ -1,7 +1,11 @@ package com.ruoyi.account.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.dto.UserChangeQuery; import org.apache.ibatis.annotations.Param; /** * <p> @@ -12,5 +16,5 @@ * @since 2024-11-21 */ public interface UserChangeLogMapper extends BaseMapper<UserChangeLog> { IPage<UserChangeLog> pageList(@Param("page")Page<UserChangeLog> page, @Param("userChangeLog")UserChangeQuery userChangeLog); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AgentApplicationService.java
@@ -1,7 +1,9 @@ package com.ruoyi.account.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.dto.AgentQuery; /** * <p> @@ -15,4 +17,5 @@ void apply(AgentApplication agentApplication); IPage<AgentApplication> pageList(AgentQuery agentQuery); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserCancellationLogService.java
@@ -1,7 +1,9 @@ package com.ruoyi.account.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.dto.UserCancelQuery; /** * <p> @@ -13,4 +15,5 @@ */ public interface UserCancellationLogService extends IService<UserCancellationLog> { IPage<UserCancellationLog> pageList(UserCancelQuery agentQuery); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserChangeLogService.java
@@ -1,7 +1,10 @@ package com.ruoyi.account.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.dto.UserChangeQuery; /** * <p> @@ -13,4 +16,5 @@ */ public interface UserChangeLogService extends IService<UserChangeLog> { IPage<UserChangeLog> pageList(UserChangeQuery userChangeLog); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/VipSettingService.java
@@ -7,4 +7,6 @@ VipSetting getVipSettingById(Integer id); VipSetting getVipSettingByUserId(Long appUserId); void downUsers(); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AgentApplicationServiceImpl.java
@@ -1,9 +1,12 @@ 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.AgentApplication; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.dto.AgentQuery; import com.ruoyi.account.mapper.AgentApplicationMapper; import com.ruoyi.account.service.AgentApplicationService; import com.ruoyi.account.service.AppUserService; @@ -68,4 +71,13 @@ agentApplication.setBindShopNum(shopList.size()); agentApplicationMapper.insert(agentApplication); } @Override public IPage<AgentApplication> pageList(AgentQuery agentQuery) { Page<Shop> page = new Page<>(); page.setCurrent(agentQuery.getPageNum()); page.setSize(agentQuery.getPageSize()); IPage<AgentApplication> shopIPage = agentApplicationMapper.pageList(page, agentQuery); return shopIPage; } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserCancellationLogServiceImpl.java
@@ -1,9 +1,14 @@ package com.ruoyi.account.service.impl; 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.AgentApplication; import com.ruoyi.account.dto.UserCancelQuery; import com.ruoyi.account.mapper.UserCancellationLogMapper; import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.service.UserCancellationLogService; import com.ruoyi.other.api.domain.Shop; import org.springframework.stereotype.Service; /** @@ -17,4 +22,12 @@ @Service public class UserCancellationLogServiceImpl extends ServiceImpl<UserCancellationLogMapper, UserCancellationLog> implements UserCancellationLogService { @Override public IPage<UserCancellationLog> pageList(UserCancelQuery agentQuery) { Page<Shop> page = new Page<>(); page.setCurrent(agentQuery.getPageNum()); page.setSize(agentQuery.getPageSize()); IPage<UserCancellationLog> shopIPage = this.baseMapper.pageList(page, agentQuery); return shopIPage; } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserChangeLogServiceImpl.java
@@ -1,9 +1,14 @@ package com.ruoyi.account.service.impl; 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.AgentApplication; import com.ruoyi.account.dto.UserChangeQuery; import com.ruoyi.account.mapper.UserChangeLogMapper; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.service.UserChangeLogService; import com.ruoyi.other.api.domain.Shop; import org.springframework.stereotype.Service; /** @@ -17,4 +22,12 @@ @Service public class UserChangeLogServiceImpl extends ServiceImpl<UserChangeLogMapper, UserChangeLog> implements UserChangeLogService { @Override public IPage<UserChangeLog> pageList(UserChangeQuery userChangeLog) { Page<UserChangeLog> page = new Page<>(); page.setCurrent(userChangeLog.getPageNum()); page.setSize(userChangeLog.getPageSize()); IPage<UserChangeLog> shopIPage = this.baseMapper.pageList(page, userChangeLog); return shopIPage; } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipSettingServiceImpl.java
@@ -2,14 +2,22 @@ import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserPoint; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserPointService; import com.ruoyi.account.service.VipSettingService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.api.feignClient.RemoteVipSettingClient; import com.ruoyi.other.api.feignClient.VipSettingClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @Service public class VipSettingServiceImpl implements VipSettingService { @@ -18,6 +26,14 @@ private RemoteVipSettingClient remoteVipSettingClient; @Resource private AppUserClient appUserClient; @Resource private AppUserService appUserService; @Resource private VipSettingClient vipSettingClient; @Resource private UserPointService userPointService; @Autowired private PointSettingServiceImpl pointSettingServiceImpl; @Override @@ -37,4 +53,79 @@ } return getVipSettingById(appUser.getVipId()); } @Override public void downUsers() { //查出可能需要降级的人员 List<Integer> vipIds = new ArrayList<>(); vipIds.add(5); vipIds.add(6); vipIds.add(7); List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list(); VipSetting vipSetting5 = vipSettingClient.getVipSetting(5).getData(); VipSetting vipSetting6 = vipSettingClient.getVipSetting(6).getData(); VipSetting vipSetting7 = vipSettingClient.getVipSetting(7).getData(); LocalDate now = LocalDate.now(); //循环判断是否要展示 if (list.size()>0){ for (AppUser appUser : list){ boolean danger = false; if (appUser.getVipId()==5){ extracted(vipSetting5, now,danger); } if (appUser.getVipId()==6){ extracted(vipSetting6, now,danger); } if (appUser.getVipId()==7){ extracted(vipSetting7, now,danger); } if (danger){ appUser.setIsDanger(1); }else { appUser.setIsDanger(0); } } appUserService.updateBatchById(list); } } private void extracted(VipSetting vipSetting5, LocalDate now,boolean danger) { if (vipSetting5.getKeepBuyPoint()!=null){ //如果消费不为空,查找对应天数的消费积分 List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,1).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list(); //如果消费积分小于保级积分,设置用户降级标志并将降级信息 Integer point = 0; for (UserPoint userPoint : list1) { point = point+userPoint.getVariablePoint(); } if (point<= vipSetting5.getKeepBuyPoint()){ danger = true; } } if (vipSetting5.getKeepSharePoint()!=null){ //如果消费不为空,查找对应天数的消费积分 List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,2).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list(); //如果消费积分小于保级积分,设置用户降级标志并将降级信息 Integer point = 0; for (UserPoint userPoint : list1) { point = point+userPoint.getVariablePoint(); } if (point<= vipSetting5.getKeepBuyPoint()){ danger = true; } } if (vipSetting5.getKeepShopPoint()!=null){ //如果消费不为空,查找对应天数的消费积分 List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,5).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list(); //如果消费积分小于保级积分,设置用户降级标志并将降级信息 Integer point = 0; for (UserPoint userPoint : list1) { point = point+userPoint.getVariablePoint(); } if (point<= vipSetting5.getKeepBuyPoint()){ danger = true; } } } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java
@@ -2,6 +2,7 @@ import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.VipSettingService; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -16,6 +17,8 @@ @Resource private AppUserService appUserService; @Resource private VipSettingService vipSettingService; @@ -29,5 +32,20 @@ appUserService.unbindThePromoter(); } /** * 每天的凌晨执行的任务 */ @Scheduled(cron = "0 0 0 * * *") public void taskDay(){ try { vipSettingService.downUsers(); }catch (Exception e){ e.printStackTrace(); } } } ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AgentApplicationMapper.xml
@@ -23,5 +23,24 @@ <sql id="Base_Column_List"> id, app_user_id, application_vip_id, application_time, status, shop_point, share_point, direct_vip_num, direct_agent_num, bind_shop_num, remark, del_flag, create_time </sql> <select id="pageList" resultType="com.ruoyi.account.api.model.AgentApplication"> select t1.*,t2.name as userName,t2.phone as userPhone from t_agent_application t1 left join t_app_user t2 on t1.app_user_id = t2.id <where> <if test="agentQuery.name !=null and agentQuery.name !=''"> and t2.name like concat('%',#{agentQuery.name},'%') </if> <if test="agentQuery.phone !=null and agentQuery.phone !=''"> and t2.phone like concat('%',#{agentQuery.phone},'%') </if> <if test="agentQuery.vipId !=null"> and t1.applicationVipId = #{agentQuery.vipId} </if> <if test="agentQuery.status !=null"> and t1.status = #{agentQuery.status} </if> </where> </select> </mapper> ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
@@ -63,6 +63,9 @@ <if test="null != appUser.phone and '' != appUser.phone"> and ta.phone like CONCAT('%',#{appUser.phone},'%') </if> <if test="null != appUser.status"> and ta.status = #{appUser.status} </if> <if test="null != appUser.vipId"> and ta.vip_id = #{appUser.vipId} </if> @@ -73,6 +76,7 @@ </foreach> </if> </where> order by ta.is_danger desc </select> </mapper> ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml
@@ -15,5 +15,24 @@ <sql id="Base_Column_List"> id, del_flag, create_time, app_user_id, vip_id </sql> <select id="pageList" resultType="com.ruoyi.account.api.model.UserCancellationLog"> select t1.*,t2.name as userName,t2.phone as userPhone from t_user_cancellation_log t1 left join t_app_user t2 on t1.app_user_id = t2.id <where> <if test="agentQuery.name != null and agentQuery.name != ''"> and t2.name like concat('%',#{agentQuery.name},'%') </if> <if test="agentQuery.phone != null and agentQuery.phone != ''"> and t2.phone like concat('%',#{agentQuery.phone},'%') </if> <if test="agentQuery.vipId != null"> and t1.vip_id = #{agentQuery.vipId} </if> <if test="agentQuery.localDate1 != null"> and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2} </if> </where> </select> </mapper> ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserChangeLogMapper.xml
@@ -17,5 +17,24 @@ <sql id="Base_Column_List"> id, del_flag, create_time, app_user_id, before_vip_id, after_vip_id, change_type </sql> <select id="pageList" resultType="com.ruoyi.account.api.model.UserChangeLog"> SELECT t1.*,t2.`name` as userName,t2.phone as userPhone from t_user_change_log t1 LEFT JOIN t_app_user t2 on t1.app_user_id = t2.id <where> <if test="userChangeLog.name !=null and userChangeLog.name !=''"> and t2.name like concat('%',#{userChangeLog.name},'%') </if> <if test="userChangeLog.phone !=null and userChangeLog.phone !=''"> and t2.phone like concat('%',#{userChangeLog.phone},'%') </if> <if test="userChangeLog.changeType !=null"> and t1.change_type = #{userChangeLog.phone.changeType} </if> <if test="userChangeLog.localDate1 !=null"> and DATE(t1.create_time) between #{userChangeLog.localDate1} and #{userChangeLog.localDate2} </if> </where> </select> </mapper> ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -206,6 +206,11 @@ return R.ok(); } @PostMapping("/getLastOrder") public R<Order> getLastOrder(@RequestParam("appUserId") Long appUserId){ Order one = orderService.lambdaQuery().eq(Order::getAppUserId, appUserId).orderByDesc(Order::getCreateTime).last("limit 1").one(); return R.ok(one); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -203,6 +203,13 @@ Shop shop = shopService.getById(id); return R.ok(shop); } @ResponseBody @PostMapping("/getShopByUserId") public R<List<Shop>> getShopByUserId(@RequestParam("id") Integer id){ List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).list(); return R.ok(list); } /** ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
@@ -37,22 +37,22 @@ @Override public void downUsers() { //查出可能需要降级的人员 R<List<AppUser>> topUsers = appUserClient.getTopUsers(); //循环判断是否要展示 if (topUsers.getData()!=null && topUsers.getData().size()>0){ for (AppUser appUser : topUsers.getData()){ if (appUser.getVipId()==5){ VipSetting vipSetting = this.baseMapper.selectById(5); if (vipSetting.getKeepBuyPoint()!=null){ //如果消费不为空,查找对应天数的消费积分 //如果消费积分小于保级积分,设置用户降级标志并将降级信息 } } } } // //查出可能需要降级的人员 // R<List<AppUser>> topUsers = appUserClient.getTopUsers(); // //循环判断是否要展示 // if (topUsers.getData()!=null && topUsers.getData().size()>0){ // for (AppUser appUser : topUsers.getData()){ // if (appUser.getVipId()==5){ // VipSetting vipSetting = this.baseMapper.selectById(5); // if (vipSetting.getKeepBuyPoint()!=null){ // //如果消费不为空,查找对应天数的消费积分 // // //如果消费积分小于保级积分,设置用户降级标志并将降级信息 // } // // } // } // } //然后设置降级提示