From d20a4aade6f9ed5111b496ac9abdff9f05f81535 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 15 一月 2025 22:32:02 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng --- ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java | 50 +-- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java | 1 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java | 153 ++++++++---- ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java | 2 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java | 4 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java | 13 + ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 52 +++ ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java | 5 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 11 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 40 +- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java | 4 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml | 1 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java | 6 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java | 15 + ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java | 4 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java | 9 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java | 19 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java | 1 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java | 3 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java | 4 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java | 1 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 86 ++++++ ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java | 2 ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml | 8 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianMapper.xml | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java | 45 ++- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 21 + ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java | 6 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java | 3 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/controller/WalletController.java | 30 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java | 2 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java | 5 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 65 +++-- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 3 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java | 2 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 3 40 files changed, 488 insertions(+), 203 deletions(-) diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java index 60c15e0..e7a43e0 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java @@ -111,6 +111,11 @@ } @Override + public void vipDemotion(Long appUserId) { + R.fail("检查会员等级降级失败:" + cause.getMessage()); + } + + @Override public void demotionDetection() { R.fail("用户降级检测失败:" + cause.getMessage()); } diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java index 6d3c044..3e367f9 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java @@ -101,6 +101,15 @@ /** + * 检查会员降级 + * @param appUserId + */ + @PostMapping("/app-user/vipDemotion") + void vipDemotion(@RequestParam("appUserId") Long appUserId); + + + + /** * 用户降级检测 */ @PostMapping("/app-user/demotionDetection") 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 b63b819..5a681b5 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 @@ -91,4 +91,8 @@ @TableField(exist = false) private String shopName; + @ApiModelProperty(value = "增或减标识: 1-增 2-减") + @TableField(exist = false) + private Integer flag; + } 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 e37d35e..220e3da 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 @@ -38,7 +38,7 @@ private Long id; @ApiModelProperty(value = "变动类型(1-消费,2-返佣,3-拉新,4-每日分享,5-每日签到,6-使用时长, 7-注册积分, 8-门店业绩," + - "9-门店返佣,14-下级门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人)") + "9-门店返佣,14-下级门店返佣,10-技师业绩,11-兑换商品,12-他人赠送,13-赠与他人,15-兑换券)") @TableField("type") private Integer type; diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java index 9a944f8..f2659f8 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java @@ -54,7 +54,7 @@ } @Override - public R<List<Order>> byUserId(Long appUserId) { + public R<List<Order>> byUserId(Long appUserId,Integer shopId) { return R.fail(); } @@ -62,6 +62,10 @@ public R<List<Order>> byShopId(Integer shopId) { return R.fail(); } + @Override + public R<List<Order>> byShopIdAndUserId(Long userId,Integer shopId) { + return R.fail("通过门店和用户id查询订单失败"); + } }; } diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java index 19394a0..b61064e 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java @@ -32,9 +32,11 @@ R<List<Order>> getOrderListByIds(@RequestBody List<Long> orderIds); @PostMapping("/order/byUserId") - R<List<Order>> byUserId(@RequestParam("appUserId") Long appUserId); + R<List<Order>> byUserId(@RequestParam("appUserId") Long appUserId,@RequestParam("shopId") Integer shopId); @PostMapping("/order/byShopId") R<List<Order>> byShopId(@RequestParam("shopId") Integer shopId); + @PostMapping("/order/byShopIdAndUserId") + R<List<Order>> byShopIdAndUserId(@RequestParam("appUserId") Long appUserId,@RequestParam("shopId") Integer shopId); /** diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java index f5a1336..0ef8657 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java @@ -100,5 +100,6 @@ private String expressResult; @ApiModelProperty("最新快递信息") + @TableField(exist = false) private String express; } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java index 63bc9aa..d27b161 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java @@ -163,6 +163,10 @@ */ @TableField(exist = false) private String isAsc; + @TableField(exist = false) + private Integer pageNum; + @TableField(exist = false) + private Integer pageSize; public String getIdStr() { diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java index e65c65d..59fdb69 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java @@ -5,6 +5,7 @@ import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.factory.StoreFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -14,7 +15,7 @@ */ @FeignClient(contextId = "StoreClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = StoreFallbackFactory.class) public interface StoreClient { - @PostMapping(value = "/shop/getDetailById") + @GetMapping(value = "/shop/getDetailById") R<Shop> getStoreById(@RequestParam("id") Integer id); diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java index ed689ec..b41500b 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java @@ -91,7 +91,7 @@ if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员"); // throw new ServiceException("对不起,您的账号:" + username + " 已停用"); - throw new ServiceException("您所属门店已被冻结,请联系平台"); + throw new ServiceException("您的账号已被禁用,请联系平台"); } passwordService.validate(user, password, request); recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_SUCCESS_STATUS, "登录成功"); diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java index 31365c3..2f3df05 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java @@ -43,6 +43,10 @@ this.pageNum = pageNum; } + public void setPageCurr(Integer pageCurr){ + this.pageNum = pageCurr; + } + public Integer getPageSize() { return pageSize; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java index 49a0356..76e191a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java @@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile; import java.util.Arrays; +import java.util.Objects; /** * 个人信息 业务处理 @@ -107,6 +108,10 @@ System.err.println(newPassword); // String username = SecurityUtils.getUsername(); SysUser user = userService.selectUserByUserName(username); + if (Objects.isNull(user)) + { + return error("未查询到该账号"); + } String password = user.getPassword(); if (!SecurityUtils.matchesPassword(oldPassword, password)) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index ff2051b..502eb1f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -329,7 +329,8 @@ if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) { return error("当前用户不能删除"); } - return toAjax(userService.deleteUserByIds(userIds)); + userService.deleteUserByIds(userIds); + return AjaxResult.success(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 776f124..5e980b4 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -199,7 +199,7 @@ * @param userIds 需要删除的用户ID * @return 结果 */ - int deleteUserByIds(Long[] userIds); + void deleteUserByIds(Long[] userIds); /** * 导入用户数据 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index e71b4f8..c1a051d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -446,7 +446,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteUserByIds(Long[] userIds) { + public void deleteUserByIds(Long[] userIds) { Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = this.getById(userid); for (Long userId : userIds) { @@ -476,7 +476,6 @@ userMapper.deleteUserById(user.getUserId()); } } - return 0; } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml index ac04b1d..8aa82dc 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml @@ -271,16 +271,16 @@ update sys_user set password = #{password} where user_name = #{userName} </update> - <delete id="deleteUserById" parameterType="Long"> + <update id="deleteUserById" parameterType="Long"> update sys_user set del_flag = '2' where user_id = #{userId} - </delete> + </update> - <delete id="deleteUserByIds" parameterType="Long"> + <update id="deleteUserByIds" parameterType="Long"> update sys_user set del_flag = '2' where user_id in <foreach collection="array" item="userId" open="(" separator="," close=")"> #{userId} </foreach> - </delete> + </update> <delete id="deleteSysUser"> delete from sys_user where user_id in <foreach collection="userIds" separator="," open="(" item="id" close=")" > diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java index 553522d..8483e72 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java @@ -1,7 +1,10 @@ package com.ruoyi.account.controller; import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.AppUser; @@ -11,6 +14,7 @@ import com.ruoyi.account.service.AgentApplicationService; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserChangeLogService; +import com.ruoyi.account.service.VipCenterService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.controller.BaseController; @@ -41,6 +45,8 @@ private AppUserService appUserService; @Resource private BaseSettingClient baseSettingClient; + @Resource + private VipCenterService vipCenterService; @PostMapping("/apply") @ApiOperation(value = "会员申请", tags = {"会员中心-小程序"}) @@ -98,39 +104,50 @@ userChangeLogService.save(userChangeLog); //变更会员等级 byId1.setVipId(byId.getApplicationVipId()); - appUserService.updateById(byId1); // 当用户为合伙人时,计算合伙人积分和培育积分 Integer vipId = byId1.getVipId(); if (vipId == 7){ + R<BaseSetting> baseSetting = baseSettingClient.getBaseSetting(1); + BaseSetting data = baseSetting.getData(); + int basePoint = Integer.parseInt(data.getContent()); // 当前用户计算合伙人积分 R<VipSetting> vipSetting = vipSettingClient.getVipSetting(vipId); - setPoint(vipSetting, byId1, byId1.getShopPoint(), byId1.getSharePoint()); + Integer point = getPoint(vipSetting, byId1, basePoint); + byId1.setPartPoint(point); // 上级计算培育积分 + R<BaseSetting> baseSetting2 = baseSettingClient.getBaseSetting(1); + BaseSetting data2 = baseSetting2.getData(); + int basePoint2 = Integer.parseInt(data2.getContent()); Long inviteUserId = byId1.getInviteUserId(); AppUser byId2 = appUserService.getById(inviteUserId); if (byId2 != null){ - setPoint(vipSetting, byId2, byId1.getShopPoint(), byId1.getSharePoint()); + Integer point1 = getPoint(vipSetting, byId2, basePoint2); + byId2.setPartGrowPoint(point1); } } + + appUserService.updateById(byId1); return R.ok(byId); } - private void setPoint(R<VipSetting> vipSetting, AppUser appUser, Integer shopPoint, Integer sharePoint) { + private Integer getPoint(R<VipSetting> vipSetting, AppUser appUser, Integer basePoint) { VipSetting vipSettingData = vipSetting.getData(); Integer vipLevelUpShopRole = vipSettingData.getVipLevelUpShopRole(); + int i = 1; if (vipLevelUpShopRole == 1){ - Integer vipLevelUpShop = vipSettingData.getVipLevelUpShop(); - Integer vipLevelUpShare = vipSettingData.getVipLevelUpShare(); - if (shopPoint >=vipLevelUpShop && sharePoint >= vipLevelUpShare) { - R<BaseSetting> baseSetting = baseSettingClient.getBaseSetting(1); - BaseSetting data = baseSetting.getData(); - if (data != null){ - appUser.setPartPoint(Integer.parseInt(data.getContent())); - appUserService.updateById(appUser); - } - } + i += 1; } + Integer vipLevelUpNumRole = vipSettingData.getVipLevelUpNumRole(); + if (vipLevelUpNumRole == 1){ + i += 1; + } + + + if (vipCenterService.checkReadyToBePartner(appUser.getId())){ + return basePoint * i; + } + return 0; } 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 834ecc6..6e18e35 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 @@ -374,7 +374,7 @@ .eq(AppUser::getDelFlag, 0)); ArrayList<Long> userIds = new ArrayList<>(); userIds.add(userId); - getUserAncestorList(userIds, appUserList); + getUserAncestorList(user,userIds,new ArrayList<>(),appUserList); // Long count1 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); // Long count2 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); // Long count3 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); @@ -382,13 +382,13 @@ // Long count5 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); // Long count6 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); // Long count7 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).or().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); +// 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()) .eq(UserSignRecord::getAppUserId,userId).list(); @@ -399,25 +399,18 @@ } return R.ok(user); } - private Long count1 = 0L; - private Long count2 = 0L; - private Long count3 = 0L; - private Long count4 = 0L; - private Long count5 = 0L; - private Long count6 = 0L; - private Long count7 = 0L; - public void getUserAncestorList(List<Long> userIds, List<AppUser> list) { - List<AppUser> children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); + public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> children,List<AppUser> list) { + children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); if(!CollectionUtils.isEmpty(children)){ - count1 = count1 + children.stream().filter(e->e.getVipId() == 1).count(); - count2 = count2 + children.stream().filter(e->e.getVipId() == 2).count(); - count3 = count3 + children.stream().filter(e->e.getVipId() == 3).count(); - count4 = count4 + children.stream().filter(e->e.getVipId() == 4).count(); - count5 = count5 + children.stream().filter(e->e.getVipId() == 5).count(); - count6 = count6 + children.stream().filter(e->e.getVipId() == 6).count(); - count7 = count7 + children.stream().filter(e->e.getVipId() == 7).count(); + user.setCount1((user.getCount1() == null ? 0L : user.getCount1()) + children.stream().filter(e->e.getVipId() == 1).count()); + user.setCount2((user.getCount2() == null ? 0L : user.getCount2()) + children.stream().filter(e->e.getVipId() == 2).count()); + user.setCount3((user.getCount3() == null ? 0L : user.getCount3()) + children.stream().filter(e->e.getVipId() == 3).count()); + user.setCount4((user.getCount4() == null ? 0L : user.getCount4()) + children.stream().filter(e->e.getVipId() == 4).count()); + user.setCount5((user.getCount5() == null ? 0L : user.getCount5()) + children.stream().filter(e->e.getVipId() == 5).count()); + user.setCount6((user.getCount6() == null ? 0L : user.getCount6()) + children.stream().filter(e->e.getVipId() == 6).count()); + user.setCount7((user.getCount7() == null ? 0L : user.getCount7()) + children.stream().filter(e->e.getVipId() == 7).count()); List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); - getUserAncestorList(userIdList, children); + getUserAncestorList(user,userIdList, children,list); } } @@ -557,8 +550,8 @@ 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(); + List<UserPoint> list2 = userPointService.lambdaQuery().eq(UserPoint::getType, 9).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); + List<UserPoint> list3 = userPointService.lambdaQuery().eq(UserPoint::getType, 8).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); Integer userKeepBuyPoint = 0; for (UserPoint userPoint : list1) { userKeepBuyPoint = userPoint.getVariablePoint() + userKeepBuyPoint; @@ -683,7 +676,7 @@ List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); byId.setBottomUsers(list); //消费总金额 - R<List<Order>> orderR = remoteOrderGoodsClient.byShopId(sysUser.getObjectId()); + R<List<Order>> orderR = remoteOrderGoodsClient.byShopIdAndUserId(id,sysUser.getObjectId()); List<Order> orderList = orderR.getData(); if (!CollectionUtils.isEmpty(orderList)){ BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); @@ -731,7 +724,10 @@ @GetMapping("/orders") @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"}) public R<List<Order>> orders(Long id) { - R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id); + Long userid = tokenService.getLoginUser().getUserid(); + SysUser sysUser = sysUserClient.getSysUser(userid).getData(); + Integer shopId = sysUser.getObjectId(); + R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id,shopId); return R.ok(listR.getData()); } @@ -1002,6 +998,17 @@ /** + * 检查会员降级 + * @param appUserId + */ + @PostMapping("/app-user/vipDemotion") + public void vipDemotion(@RequestParam("appUserId") Long appUserId){ + appUserService.vipDemotion(appUserId); + } + + + + /** * 用户降级检测 */ @PostMapping("/demotionDetection") diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java index 1d24df4..fe902b7 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java @@ -244,7 +244,7 @@ appUserService.updateById(byId); UserPoint userPoint = new UserPoint(); - userPoint.setType(11); + userPoint.setType(15); userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(point); userPoint.setBalance(byId.getLavePoint()); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java index 75701a6..1e6bccb 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.BalanceChangeRecord; import com.ruoyi.account.api.model.BalancePayment; @@ -77,9 +79,11 @@ */ @ApiOperation(value = "变更明细", notes = "变更明细") @GetMapping("change") - public R<List<BalanceChangeRecord>> change(@ApiParam(value = "变更类型") + public R<IPage<BalanceChangeRecord>> change(@ApiParam(value = "变更类型") @RequestParam(required = false) Integer changeType, - @ApiParam(value = "创建时间") + Integer pageCurr, + Integer pageSize, + @ApiParam(value = "创建时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate createTime) { @@ -99,10 +103,12 @@ endTime = lastDayOfMonth.atTime(LocalTime.MAX); } - List<BalanceChangeRecord> list = balanceChangeRecordService.list(new LambdaQueryWrapper<BalanceChangeRecord>() + Page<BalanceChangeRecord> page = balanceChangeRecordService.page(Page.of(pageCurr, pageSize), new LambdaQueryWrapper<BalanceChangeRecord>() .eq(changeType != null, BalanceChangeRecord::getChangeType, changeType) .between(startTime != null, BalanceChangeRecord::getCreateTime, startTime, endTime) .eq(BalanceChangeRecord::getAppUserId, userId).orderByDesc(BalanceChangeRecord::getCreateTime)); + + List<BalanceChangeRecord> list = page.getRecords(); List<Long> orderIds = list.stream().map(BalanceChangeRecord::getOrderId).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(orderIds)){ @@ -115,12 +121,22 @@ orderList.stream().filter(o -> o.getId().equals(bc.getOrderId())).findFirst().ifPresent(o -> { Long appUserId = o.getAppUserId(); AppUser appUser = appUserService.getById(appUserId); - bc.setUserName(appUser.getName()); - bc.setAmount(o.getPaymentAmount()); + if(null != appUser){ + bc.setUserName(appUser.getName()); + bc.setAmount(o.getPaymentAmount()); + } }); + + BigDecimal beforeAmount = bc.getBeforeAmount(); + BigDecimal afterAmount = bc.getAfterAmount(); + if (beforeAmount.compareTo(afterAmount) > 0){ + bc.setFlag(2); + }else { + bc.setFlag(1); + } }); } - return R.ok(list); + return R.ok(page); } /** @@ -214,7 +230,5 @@ out.flush(); out.close(); } - - } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java index 7dc3c41..f0671a0 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java @@ -94,6 +94,12 @@ */ void vipUpgrade(Long appUserId); + /** + * 处理用户会员降级 + * @param appUserId + */ + void vipDemotion(Long appUserId); + /** * 降级检测 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 6f84c3e..7567718 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 @@ -179,7 +179,8 @@ } //查询用户是否注册,没有注册则跳转到注册页面 - AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, mobileLogin.getPhone()).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); + AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, mobileLogin.getPhone()) + .ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); if(null == appUser){ LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(2); @@ -200,8 +201,7 @@ loginUser.setUsername(appUser.getName()); Map<String, Object> tokenApplet = tokenService.createTokenApplet(loginUser); loginVo.setToken(tokenApplet.get("access_token").toString()); - loginVo.setFailureTime(Long.valueOf(tokenApplet.get("expires_in").toString())); - + loginVo.setFailureTime(Long.valueOf(tokenApplet.get("expires_in").toString())); appUser.setLastLoginTime(LocalDateTime.now()); this.updateById(appUser); return R.ok(loginVo); @@ -608,7 +608,85 @@ } } - + /** + * 处理会员降级 + * @param appUserId + */ + @Override + public void vipDemotion(Long appUserId) { + AppUser appUser = this.getById(appUserId); + Integer vipId = appUser.getVipId(); + //黄金会员 + VipSetting vipSetting2 = vipSettingClient.getVipSetting(2).getData(); + //消费积分满足升级 + if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting2.getVipLevelUpShop() && appUser.getVipId() > 2){ + appUser.setVipId(2); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(0); + userChangeLogService.save(userChangeLog); + return; + } + //返佣积分满足升级 + if(1 == vipSetting2.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting2.getVipLevelUpShare() && appUser.getVipId() > 2){ + appUser.setVipId(2); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(0); + userChangeLogService.save(userChangeLog); + return; + } + //下级人数满足升级 + Integer vipLevelUpNumRole = vipSetting2.getVipLevelUpNumRole(); + Integer vipDirectNum = vipSetting2.getVipDirectNum(); + Integer vipTeamNum = vipSetting2.getVipTeamNum(); + if(1 == vipLevelUpNumRole && appUser.getVipId() > 2){ + //查询直推用户达到X人或者团队人数达到X人后,可升级 + //直推用户数 + long count = this.count(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1).eq(AppUser::getInviteUserId, appUserId)); + //团队用户数 + List<AppUser> subordinate = getSubordinate(appUserId); + if(vipDirectNum <= count || vipTeamNum <= subordinate.size()){ + appUser.setVipId(2); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(0); + userChangeLogService.save(userChangeLog); + return; + } + } + if(appUser.getVipId() > 2){ + appUser.setVipId(1); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(0); + userChangeLogService.save(userChangeLog); + } + } /** * 递归查询顶级推广人 diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java index 402bd5d..a942c97 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java @@ -289,7 +289,7 @@ // 获取用户直推代理用户数量 List<AppUser> userAgentList = appUserService.list(new LambdaQueryWrapper<AppUser>() .in(AppUser::getId, userShopList) - .eq(AppUser::getVipId, 5)); + .gt(AppUser::getVipId, 4)); // 代理下的准代理数量 List<Long> userQuasiAgent = userAgentList.stream().map(AppUser::getId).collect(Collectors.toList()); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java index 94ee314..5dc7b75 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java @@ -59,20 +59,24 @@ LoginUser loginUserApplet = tokenService.getLoginUserApplet(); AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); + Integer vipId = appUser.getVipId(); + VipSetting vipSetting = vipSettingService.getVipSettingById(vipId); + BigDecimal withdrawableAmount = appUser.getWithdrawableAmount(); + + BigDecimal vipWithdrawalMinAmount = vipSetting.getVipWithdrawalMinAmount(); + if (vipWithdrawalMinAmount.compareTo(withdrawableAmount) > 0) { + throw new ServiceException("提现失败,提现门槛为:"+vipWithdrawalMinAmount+"元!"); + } + if (appUser.getWithdrawableAmount().compareTo(withdrawalAmount) < 0) { throw new ServiceException("提现失败,可提现金额不足!"); } - Integer vipId = appUser.getVipId(); - VipSetting vipSetting = vipSettingService.getVipSettingById(vipId); + if (vipSetting.getVipWithdrawalRole() == 0) { throw new ServiceException("提现失败,当前会员等级不允许提现!"); } - BigDecimal vipWithdrawalMinAmount = vipSetting.getVipWithdrawalMinAmount(); - if (withdrawalAmount.compareTo(vipWithdrawalMinAmount) < 0) { - throw new ServiceException("提现失败,提现金额不能小于" + vipWithdrawalMinAmount + "元!"); - } - + // 提现手续费 BigDecimal vipWithdrawalFee = vipSetting.getVipWithdrawalFee() .divide(VIP_WITHDRAWAL_FEE_DENOMINATOR, 2, RoundingMode.HALF_UP); @@ -98,7 +102,6 @@ withdrawalRequests.setAuditStatus(1); save(withdrawalRequests); //修改用户的可提现金额 - BigDecimal withdrawableAmount = appUser.getWithdrawableAmount(); BigDecimal withdrawnAmount = appUser.getWithdrawnAmount(); BigDecimal balance = appUser.getBalance(); appUser.setWithdrawableAmount(withdrawableAmount.subtract(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN)); diff --git a/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java b/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java index acaa797..ec40325 100644 --- a/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java +++ b/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java @@ -22,38 +22,32 @@ @Test public void contextLoads() { List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() - .ne(AppUser::getStatus, 3)); + .ne(AppUser::getStatus, 3) + .eq(AppUser::getDelFlag, 0)); + AppUser user = appUserService.getById(1879047378761244673L); ArrayList<Long> userIds = new ArrayList<>(); - userIds.add(1879046499735789569L); - getUserAncestorList(userIds, appUserList); - System.err.println(count1); - System.err.println(count2); - System.err.println(count3); - System.err.println(count4); - System.err.println(count5); - System.err.println(count6); - System.err.println(count7); + userIds.add(1879047378761244673L); + getUserAncestorList(user,userIds, new ArrayList<>(),appUserList); + System.err.println(user.getCount1()); + System.err.println(user.getCount2()); + System.err.println(user.getCount3()); + System.err.println(user.getCount4()); + System.err.println(user.getCount5()); + System.err.println(user.getCount6()); + System.err.println(user.getCount7()); } - - private Long count1 = 0L; - private Long count2 = 0L; - private Long count3 = 0L; - private Long count4 = 0L; - private Long count5 = 0L; - private Long count6 = 0L; - private Long count7 = 0L; - public void getUserAncestorList(List<Long> userIds, List<AppUser> list) { - List<AppUser> children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); + public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> children,List<AppUser> list) { + children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); if(!CollectionUtils.isEmpty(children)){ - count1 = count1 + children.stream().filter(e->e.getVipId() == 1).count(); - count2 = count2 + children.stream().filter(e->e.getVipId() == 2).count(); - count3 = count3 + children.stream().filter(e->e.getVipId() == 3).count(); - count4 = count4 + children.stream().filter(e->e.getVipId() == 4).count(); - count5 = count5 + children.stream().filter(e->e.getVipId() == 5).count(); - count6 = count6 + children.stream().filter(e->e.getVipId() == 6).count(); - count7 = count7 + children.stream().filter(e->e.getVipId() == 7).count(); + user.setCount1((user.getCount1() == null ? 0L : user.getCount1()) + children.stream().filter(e->e.getVipId() == 1).count()); + user.setCount2((user.getCount2() == null ? 0L : user.getCount2()) + children.stream().filter(e->e.getVipId() == 2).count()); + user.setCount3((user.getCount3() == null ? 0L : user.getCount3()) + children.stream().filter(e->e.getVipId() == 3).count()); + user.setCount4((user.getCount4() == null ? 0L : user.getCount4()) + children.stream().filter(e->e.getVipId() == 4).count()); + user.setCount5((user.getCount5() == null ? 0L : user.getCount5()) + children.stream().filter(e->e.getVipId() == 5).count()); + user.setCount6((user.getCount6() == null ? 0L : user.getCount6()) + children.stream().filter(e->e.getVipId() == 6).count()); + user.setCount7((user.getCount7() == null ? 0L : user.getCount7()) + children.stream().filter(e->e.getVipId() == 7).count()); List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); - getUserAncestorList(userIdList, children); + getUserAncestorList(user,userIdList, children,list); } } 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 b52570f..349856a 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 @@ -234,12 +234,17 @@ @PostMapping("/byUserId") - public R<List<Order>> byUserId(@RequestParam("appUserId") Long appUserId){ - return R.ok(orderService.lambdaQuery().eq(Order::getAppUserId, appUserId).list()); + public R<List<Order>> byUserId(@RequestParam("appUserId") Long appUserId,@RequestParam("shopId") Integer shopId){ + return R.ok(orderService.lambdaQuery().eq(Order::getAppUserId, appUserId).eq(Order::getShopId, shopId).list()); } @PostMapping("/byShopId") public R<List<Order>> byShopId(@RequestParam("shopId") Integer shopId){ return R.ok(orderService.lambdaQuery().isNotNull(Order::getEndTime).eq(Order::getShopId, shopId).list()); + } + @PostMapping("/byShopIdAndUserId") + public R<List<Order>> byShopIdAndUserId(@RequestParam("appUserId") Long appUserId,@RequestParam("shopId") Integer shopId){ + List<Order> list = orderService.lambdaQuery().isNotNull(Order::getEndTime).eq(Order::getShopId, shopId).eq(Order::getAppUserId, appUserId).in(Order::getOrderStatus, 4, 7, 8).list(); + return R.ok(list); } @@ -419,7 +424,7 @@ */ @PostMapping("/getGoodsSaleNum") public R<Integer> getGoodsSaleNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("type") Integer type){ - Integer goodsSaleNum = orderService.getGoodsSaleNum(goodsId, type); + Integer goodsSaleNum = orderService.getGoodsSaleNum(goodsId, type, null); return R.ok(goodsSaleNum); } 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 7078489..fafbf08 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 @@ -92,7 +92,7 @@ if(StringUtils.isNotEmpty(one.getExpressResult())){ MapTrackKD100Vo mapTrackKD100Vo = JSON.parseObject(one.getExpressResult(), MapTrackKD100Vo.class); List<QueryKD100ListVo> data = mapTrackKD100Vo.getData(); - one.setExpress(data.size() > 0 ? data.get(0).getContext() : ""); + one.setExpress(null != data && data.size() > 0 ? data.get(0).getContext() : ""); } return R.ok(one); } 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 47f8d47..903558a 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 @@ -43,7 +43,9 @@ * @param goodsId * @return */ - Integer getGoodsSaleNum(@Param("goodsId") Integer goodsId, @Param("type") Integer type); + Integer getGoodsSaleNum(@Param("goodsId") Integer goodsId, + @Param("type") Integer type, + @Param("userId") Long userId); /** 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 823df14..5777cc5 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 @@ -98,7 +98,7 @@ * @param goodsId * @return */ - Integer getGoodsSaleNum(Integer goodsId, Integer type); + Integer getGoodsSaleNum(Integer goodsId, Integer type, Long userId); /** 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 38932d5..d621963 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 @@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.account.api.feignClient.AppUserClient; -import com.ruoyi.account.api.feignClient.BalanceChangeRecordClient; -import com.ruoyi.account.api.feignClient.UserCouponClient; -import com.ruoyi.account.api.feignClient.UserPointClient; +import com.ruoyi.account.api.feignClient.*; import com.ruoyi.account.api.model.*; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; @@ -89,9 +86,6 @@ private UserPointClient userPointClient; @Resource - private PointSettingClient pointSettingClient; - - @Resource private OrderBalancePaymentService orderBalancePaymentService; @Resource @@ -115,6 +109,9 @@ @Resource private UserCouponClient userCouponClient; + + @Resource + private UserChangeLogClient userChangeLogClient; @@ -205,7 +202,7 @@ if(StringUtils.isNotEmpty(order.getExpressResult())){ MapTrackKD100Vo mapTrackKD100Vo = JSON.parseObject(order.getExpressResult(), MapTrackKD100Vo.class); List<QueryKD100ListVo> data = mapTrackKD100Vo.getData(); - orderDetailVO.setExpress(data.size() > 0 ? data.get(0).getContext() : ""); + orderDetailVO.setExpress(null != data && data.size() > 0 ? data.get(0).getContext() : ""); } if(order.getOrderType() == 1){ @@ -286,6 +283,7 @@ if(StringUtils.isNotEmpty(technicianId) && !"null".equals(technicianId)){ order.setTechnicianId(Integer.valueOf(technicianId)); } + // TODO orderMapper.updateById(order); } @@ -518,11 +516,6 @@ } appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint); - boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId()); - if(vipDemotion){ - appUser.setVipId(appUser.getVipId() - 1); - } - //构建积分流水明细 UserPoint userPoint = new UserPoint(); userPoint.setType(1); @@ -534,6 +527,12 @@ userPoint.setObjectId(order.getId()); userPointClient.saveUserPoint(userPoint); appUserClient.editAppUserById(appUser); + + //降级检测 + boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId()); + if(vipDemotion){ + appUserClient.vipDemotion(appUser.getId()); + } //回退优惠券状态 if(null != order.getUserCouponId()){ UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); @@ -650,11 +649,6 @@ } appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint); - boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId()); - if(vipDemotion){ - appUser.setVipId(appUser.getVipId() - 1); - } - //构建积分流水明细 UserPoint userPoint = new UserPoint(); userPoint.setType(1); @@ -666,6 +660,12 @@ userPoint.setObjectId(order.getId()); userPointClient.saveUserPoint(userPoint); appUserClient.editAppUserById(appUser); + + //降级检测 + boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId()); + if(vipDemotion){ + appUserClient.vipDemotion(appUser.getId()); + } //回退优惠券状态 if(null != order.getUserCouponId()){ @@ -853,8 +853,8 @@ * @return */ @Override - public Integer getGoodsSaleNum(Integer goodsId, Integer type) { - return this.baseMapper.getGoodsSaleNum(goodsId, type); + public Integer getGoodsSaleNum(Integer goodsId, Integer type, Long userId) { + return this.baseMapper.getGoodsSaleNum(goodsId, type, userId); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java index bfda500..5d23be9 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java @@ -11,6 +11,7 @@ import com.ruoyi.account.api.vo.PaymentUserCoupon; import com.ruoyi.account.api.vo.PaymentUserCouponVo; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.mapper.ShoppingCartMapper; @@ -190,7 +191,7 @@ info.setVip(appUser.getVipId()); GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格 - if((null == goodsSeckill || (null != goodsSeckill.getCashPayment() && null != goodsSeckill.getPointPayment())) || type == 1){ + if((null == goodsSeckill || (null == goodsSeckill.getCashPayment() && null == goodsSeckill.getPointPayment())) || type == 1){ //没有秒杀价,则判断门店特价 GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice(); goodsBargainPrice.setGoodsId(goodsId); @@ -329,6 +330,15 @@ @Override public Long addGoods(ShoppingCart shoppingCart) { Long userid = tokenService.getLoginUserApplet().getUserid(); + long goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), null, userid); + long count = count(new LambdaQueryWrapper<ShoppingCart>() + .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()) + .eq(ShoppingCart::getAppUserId, userid)); + goodsSaleNum += count; + Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); + if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + shoppingCart.getNumber()) > goods.getPurchaseLimit()){ + throw new ServiceException("超出购买数量限制"); + } ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid) .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()).eq(ShoppingCart::getType, shoppingCart.getType()).eq(ShoppingCart::getStatus, 1)); if(null != one){ @@ -351,15 +361,16 @@ */ @Override public R setGoodsNumber(SetGoodsNumber setGoodsNumber) { + + ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); if(0 >= setGoodsNumber.getNumber()){ return R.fail("修改数量不能小于等于0"); } - ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); if(null != shoppingCart){ - Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); - if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && goods.getPurchaseLimit() < setGoodsNumber.getNumber()){ + Goods goods1 = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); + if(null != goods1.getPurchaseLimit() && -1 != goods1.getPurchaseLimit() && goods1.getPurchaseLimit() < setGoodsNumber.getNumber()){ return R.fail("修改数量不能大于限购数量"); } @@ -723,7 +734,7 @@ num += num1; ShoppingCart shoppingCart = this.getById(id); //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) - Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type); + Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type, userid); Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); if(1 == type){ if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + num1) > goods.getPurchaseLimit()){ 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 02ed969..34fa450 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 @@ -118,6 +118,9 @@ <if test="null != type"> and a.type = #{type} </if> + <if test="userId != null"> + and b.app_user_id = #{userId} + </if> </select> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java index 5e750ee..c845839 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java @@ -63,7 +63,6 @@ @ApiOperation(value = "秒杀活动列表",tags = {"小程序-商城-首页","后台管理-活动管理-秒杀活动"}) public R<TableDataInfo> list(Goods goods) { - startPage(); return R.ok(getDataTable(seckillActivityInfoService.listSeckillActivity(goods))); } 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 bb4826d..91516e9 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 @@ -418,20 +418,52 @@ shop.setStatus(status); shopService.updateById(shop); //处理员工等数据 - UserShop userSh = new UserShop(); - userSh.setShopId(id); - List<UserShop> data = userShopClient.getUserShop(userSh).getData(); - for (UserShop datum : data) { - UserShop userShop = new UserShop(); - userShop.setUserId(datum.getUserId()); - List<UserShop> data1 = userShopClient.getUserShop(userShop).getData(); - long count = data1.stream().filter(s -> !s.getShopId().equals(id)).count(); - if(0 == count){ + if(status == 1){ + UserShop userSh = new UserShop(); + userSh.setShopId(id); + List<UserShop> data = userShopClient.getUserShop(userSh).getData(); + for (UserShop datum : data) { SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); - sysUser.setStatus(status == 1 ? "0" : "1"); + sysUser.setStatus("0"); sysUserClient.updateUser(sysUser); } + }else{ + //查询门店所有关联数据 + UserShop userSh = new UserShop(); + userSh.setShopId(id); + List<UserShop> data = userShopClient.getUserShop(userSh).getData(); + for (UserShop datum : data) { + //查询用户关联的其他店铺 + UserShop userShop = new UserShop(); + userShop.setUserId(datum.getUserId()); + List<UserShop> data1 = userShopClient.getUserShop(userShop).getData(); + List<UserShop> collect = data1.stream().filter(s -> !s.getShopId().equals(id)).collect(Collectors.toList()); + if(collect.size() == 0){ + //如果没有其他店铺,则将用户禁用 + SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); + sysUser.setStatus("1"); + sysUserClient.updateUser(sysUser); + }else{ + List<Integer> shopIds = collect.stream().map(UserShop::getShopId).collect(Collectors.toList()); + List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1) + .in(Shop::getId, shopIds)); + //如果用户关联的其他门店都禁用了,将用户禁用 + if(list.size() == 0){ + SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); + sysUser.setStatus("1"); + sysUserClient.updateUser(sysUser); + }else{ + //修改默认门店 + SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); + if(sysUser.getObjectId().equals(id)){ + sysUser.setObjectId(list.get(0).getId()); + sysUserClient.updateUser(sysUser); + } + } + } + } } + return R.ok(); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java index 7e7a80e..23e3f28 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java @@ -5,7 +5,6 @@ @Getter public enum TechnicianStatus { UNSUBSCRIBE(0, "待服务"), - SERVE(1, "已服务"), CANCEL(2, "已取消"), EXPIRED(3, "已到期"); private final Integer code; diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java index f994879..bd6853a 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java @@ -2,11 +2,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.utils.ServletUtils; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.utils.sql.SqlUtil; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableSupport; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.order.feignClient.OrderClient; @@ -31,6 +36,8 @@ import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; + +import static com.ruoyi.common.core.utils.PageUtils.startPage; /** * <p> @@ -66,6 +73,12 @@ LoginUser loginUserApplet = tokenService.getLoginUserApplet(); AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); goods.setVipId(appUser.getVipId()); + + + PageDomain pageDomain = TableSupport.buildPageRequest(); + Boolean reasonable = pageDomain.getReasonable(); + PageHelper.startPage(goods.getPageCurr(), goods.getPageSize(), goods.getOrderByColumn()).setReasonable(reasonable); + List<SeckillActivityVO> seckillActivityVOS = seckillActivityInfoMapper.listSeckillActivity(goods); for (SeckillActivityVO seckillActivityVO : seckillActivityVOS) { Integer data = orderClient.getGoodsSaleNum(seckillActivityVO.getGoodsId(), 2).getData(); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java index ff5a481..85e2d86 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java @@ -53,56 +53,111 @@ Integer sPoint = 0; Integer shopCommissionPoint = 0; Integer subShopCommissionPoint = 0; - Shop shop = shopService.getById(sysUser.getObjectId()); - sPoint += shop.getServerPoint(); - shopCommissionPoint += shop.getSharePoint(); - subShopCommissionPoint += shop.getLowerLevelSharePoint(); - ShopPointStatistics shopPointStatistics = new ShopPointStatistics(); - shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint); - shopPointStatistics.setShopPoint(sPoint); - shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); - shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint); - - IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); - shopPointStatistics.setShopPointIPage(shopPointIPage); - - LocalDateTime startTime = shopPoint.getStartTime(); - LocalDateTime endTime = shopPoint.getEndTime(); - if(null != startTime){ - List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>() - .eq(ShopPoint::getShopId, sysUser.getObjectId()) - .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'")); - List<String> date = new ArrayList<>(); - List<Map<String, Integer>> data = new ArrayList<>(); - String format = "MM.dd"; - while (true){ - if(startTime.isAfter(endTime)){ - break; - } - date.add(startTime.format(DateTimeFormatter.ofPattern(format))); - Map<String, Integer> map = new HashMap<>(); - //返佣积分 - LocalDateTime finalStartTime = startTime; - List<ShopPoint> collect = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) - .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 2).collect(Collectors.toList()); - map.put("fyjf", collect.stream().mapToInt(ShopPoint::getVariablePoint).sum()); - - //服务积分 - List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) - .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 4).collect(Collectors.toList()); - map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum()); - //绑定下级门店返佣积分 - List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) - .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 3).collect(Collectors.toList()); - map.put("xjmdfyjf", collect2.stream().mapToInt(ShopPoint::getVariablePoint).sum()); - data.add(map); - startTime = startTime.plusDays(1); + if (sysUser.getRoleType()==1){ + List<Shop> shopIds = shopService.lambdaQuery().eq(Shop::getDelFlag, 0).list(); + for (Shop shop : shopIds) { + sPoint += shop.getServerPoint(); + shopCommissionPoint += shop.getSharePoint(); + subShopCommissionPoint += shop.getLowerLevelSharePoint(); } - Map<String, Object> brokenLine = new HashMap<>(); - brokenLine.put("date", date); - brokenLine.put("data", data); - shopPointStatistics.setBrokenLine(brokenLine); + ShopPointStatistics shopPointStatistics = new ShopPointStatistics(); + shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint); + shopPointStatistics.setShopPoint(sPoint); + shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); + shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint); + IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); + shopPointStatistics.setShopPointIPage(shopPointIPage); + + LocalDateTime startTime = shopPoint.getStartTime(); + LocalDateTime endTime = shopPoint.getEndTime(); + if(null != startTime){ + List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>() + .eq(ShopPoint::getShopId, sysUser.getObjectId()) + .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'")); + List<String> date = new ArrayList<>(); + List<Map<String, Integer>> data = new ArrayList<>(); + String format = "MM.dd"; + while (true){ + if(startTime.isAfter(endTime)){ + break; + } + date.add(startTime.format(DateTimeFormatter.ofPattern(format))); + Map<String, Integer> map = new HashMap<>(); + //返佣积分 + LocalDateTime finalStartTime = startTime; + List<ShopPoint> collect = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 2).collect(Collectors.toList()); + map.put("fyjf", collect.stream().mapToInt(ShopPoint::getVariablePoint).sum()); + + //服务积分 + List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 4).collect(Collectors.toList()); + map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum()); + //绑定下级门店返佣积分 + List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 3).collect(Collectors.toList()); + map.put("xjmdfyjf", collect2.stream().mapToInt(ShopPoint::getVariablePoint).sum()); + data.add(map); + startTime = startTime.plusDays(1); + } + Map<String, Object> brokenLine = new HashMap<>(); + brokenLine.put("date", date); + brokenLine.put("data", data); + shopPointStatistics.setBrokenLine(brokenLine); + } + return shopPointStatistics; + }else{ + Shop shop = shopService.getById(sysUser.getObjectId()); + sPoint += shop.getServerPoint(); + shopCommissionPoint += shop.getSharePoint(); + subShopCommissionPoint += shop.getLowerLevelSharePoint(); + ShopPointStatistics shopPointStatistics = new ShopPointStatistics(); + shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint); + shopPointStatistics.setShopPoint(sPoint); + shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); + shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint); + + IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); + shopPointStatistics.setShopPointIPage(shopPointIPage); + + LocalDateTime startTime = shopPoint.getStartTime(); + LocalDateTime endTime = shopPoint.getEndTime(); + if(null != startTime){ + List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>() + .eq(ShopPoint::getShopId, sysUser.getObjectId()) + .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'")); + List<String> date = new ArrayList<>(); + List<Map<String, Integer>> data = new ArrayList<>(); + String format = "MM.dd"; + while (true){ + if(startTime.isAfter(endTime)){ + break; + } + date.add(startTime.format(DateTimeFormatter.ofPattern(format))); + Map<String, Integer> map = new HashMap<>(); + //返佣积分 + LocalDateTime finalStartTime = startTime; + List<ShopPoint> collect = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 2).collect(Collectors.toList()); + map.put("fyjf", collect.stream().mapToInt(ShopPoint::getVariablePoint).sum()); + + //服务积分 + List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 4).collect(Collectors.toList()); + map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum()); + //绑定下级门店返佣积分 + List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 3).collect(Collectors.toList()); + map.put("xjmdfyjf", collect2.stream().mapToInt(ShopPoint::getVariablePoint).sum()); + data.add(map); + startTime = startTime.plusDays(1); + } + Map<String, Object> brokenLine = new HashMap<>(); + brokenLine.put("date", date); + brokenLine.put("data", data); + shopPointStatistics.setBrokenLine(brokenLine); + } + return shopPointStatistics; } - return shopPointStatistics; } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java index 951f527..93a1013 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java @@ -88,8 +88,10 @@ String id = technicianSubscribeVO.getId(); TechnicianSubscribe technicianSubscribe = this.getById(id); AppUser appUser = appUserClient.getAppUserById(technicianSubscribe.getAppUserId()); - technicianSubscribeVO.setUserName(appUser.getName()); - technicianSubscribeVO.setPhone(appUser.getPhone()); + if(null != appUser){ + technicianSubscribeVO.setUserName(appUser.getName()); + technicianSubscribeVO.setPhone(appUser.getPhone()); + } Integer serviceMode = technicianSubscribeVO.getServiceMode(); if(1 == serviceMode){ UserAddress userAddress = JSON.parseObject(technicianSubscribeVO.getUserAddress(), UserAddress.class); @@ -113,7 +115,14 @@ } @Override public IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status) { - return technicianSubscribeMapper.getTechnicianSubscribeByUser(page, userId, status); + IPage<TechnicianSubscribeVO> technicianSubscribeByUser = technicianSubscribeMapper.getTechnicianSubscribeByUser(page, userId, status); + technicianSubscribeByUser.getRecords().forEach(technicianSubscribeVO -> { + UserAddress userAddress = JSON.parseObject(technicianSubscribeVO.getUserAddress(), UserAddress.class); + if (userAddress != null){ + technicianSubscribeVO.setUserAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); + } + }); + return technicianSubscribeByUser; } @Override diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml index b5c0016..1158d17 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml @@ -33,7 +33,6 @@ <if test="vipId == null"> AND tgs.vip in (0, -1) </if> - order by tsai.create_time desc </select> <select id="selectDetail" resultType="com.ruoyi.other.vo.SeckillActivityDetailVO"> SELECT diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianMapper.xml index f74199c..a59d351 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianMapper.xml @@ -11,7 +11,7 @@ AVG( IFNULL(ttsc.score,0) ) AS score FROM t_technician tt - LEFT JOIN t_technician_subscribe tts ON tt.id = tts.technician_id and tts.`status` != 0 + LEFT JOIN t_technician_subscribe tts ON tt.id = tts.technician_id LEFT JOIN t_technician_score ttsc ON ttsc.technician_id = tt.id WHERE tt.`status` = 2 -- Gitblit v1.7.1