From 4ea15c3e2a3f0434df79a1b49fe4e90f7337b025 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 06 二月 2025 18:16:40 +0800
Subject: [PATCH] 修改物流信息导入模板
---
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 168 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 149 insertions(+), 19 deletions(-)
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 2c7b14a..e354037 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
@@ -1,6 +1,7 @@
package com.ruoyi.account.controller;
+import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -11,11 +12,16 @@
import com.ruoyi.account.mapper.AppUserMapper;
import com.ruoyi.account.service.*;
import com.ruoyi.account.util.ObsUploadUtil;
+import com.ruoyi.account.util.weChat.EnvVersion;
+import com.ruoyi.account.util.weChat.WeChatUtil;
import com.ruoyi.account.vo.*;
+import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
@@ -29,7 +35,9 @@
import com.ruoyi.other.api.feignClient.VipSettingClient;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
+import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -57,8 +65,7 @@
@RestController
@RequestMapping("/app-user")
public class AppUserController extends BaseController {
-
-
+
@Resource
private TokenService tokenService;
@Resource
@@ -92,6 +99,16 @@
private UserCancellationLogService userCancellationLogService;
@Resource
private BalanceChangeRecordService balanceChangeRecordService;
+ @Resource
+ private UserChangeLogService userChangeLogService;
+ @Resource
+ private RedisService redisService;
+
+ @Resource
+ private WeChatUtil weChatUtil;
+
+ @Value("${file.upload.location}")
+ private String filePath;
@ResponseBody
@@ -114,6 +131,17 @@
public AppUser getAppUserById(@RequestParam("id") Long id) {
return appUserService.getById(id);
}
+
+ @PostMapping("/getBaseUserById")
+ public R<Map<String, Object>> getBaseUserById(@RequestParam("id") Long id) {
+ AppUser appUser = appUserService.getById(id);
+ Map<String, Object> map = new HashMap<>();
+ map.put("id", appUser.getId());
+ map.put("name", appUser.getName());
+ map.put("phone", appUser.getPhone());
+ return R.ok(map);
+ }
+
@ResponseBody
@PostMapping("/editAppUserById")
@@ -200,6 +228,13 @@
public R<AppUser> info() {
Long userId = tokenService.getLoginUserApplet().getUserid();
AppUser user = appUserService.getById(userId);
+ if(StringUtils.isEmpty(user.getQrCode())){
+ //获取微信推广二维码
+ String fileName = UUID.randomUUID() + ".jpg";
+ String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/login/login", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName);
+ user.setQrCode(getwxacodeunlimit);
+ appUserService.updateById(user);
+ }
return R.ok(user);
}
@@ -258,49 +293,87 @@
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.list();
+
+ Long vip1Count1 =0L;
+ Long vip1Count2 =0L;
+ Long vip1Count3 =0L;
+ Long vip1Count4 =0L;
+ Long vip1Count5 =0L;
+ Long vip1Count6 =0L;
+ Long vip1Count7 =0L;
for (AppUser appUser : list) {
+ if (appUser.getVipId() == 1){
+ vip1Count1++;
+ }
+ if (appUser.getVipId() == 2){
+ vip1Count2++;
+ }
+ if (appUser.getVipId() == 3){
+ vip1Count3++;
+ }
+ if (appUser.getVipId() == 4){
+ vip1Count4++;
+ }
+ if (appUser.getVipId() == 5){
+ vip1Count5++;
+ }
+ if (appUser.getVipId() == 6){
+ vip1Count6++;
+ }
+ if (appUser.getVipId() == 7){
+ vip1Count7++;
+ }
+
Long count1 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 1)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count1 += count1;
+
Long count2 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 2)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count2 += count2;
Long count3 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 3)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count3 += count3;
Long count4 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 4)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count4 += count4;
Long count5 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 5)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count5 += count5;
Long count6 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 6)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count6 += count6;
Long count7 = appUserService.lambdaQuery()
.eq(AppUser::getVipId, 7)
.eq(AppUser::getInviteUserId, appUser.getId())
.eq(AppUser::getDelFlag, 0)
.ne(AppUser::getStatus, 3)
.count();
+ vip1Count7 += count7;
appUser.setCount1(count1);
appUser.setCount2(count2);
appUser.setCount3(count3);
@@ -310,7 +383,13 @@
appUser.setCount7(count7);
}
user.setBottomUsers(list);
-
+ user.setCount1(vip1Count1);
+ user.setCount2(vip1Count2);
+ user.setCount3(vip1Count3);
+ user.setCount4(vip1Count4);
+ user.setCount5(vip1Count5);
+ user.setCount6(vip1Count6);
+ user.setCount7(vip1Count7);
return R.ok(user);
}
@@ -569,19 +648,19 @@
//检查是否达标,不达标继续标红
VipSetting vipSetting = vipSettingClient.getVipSetting(appUser.getVipId()).getData();
//消费积分
- List<UserPoint> list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 1).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepBuyDay() + " DAY) >= create_time"));
+ List<UserPoint> list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 1).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepBuyDay() + " DAY) <= create_time"));
int sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum();
if(sum < vipSetting.getKeepBuyPoint()){
appUser.setIsDanger(1);
}
//返佣积分
- list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 2).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShareDay() + " DAY) >= create_time"));
+ list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 2).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShareDay() + " DAY) <= create_time"));
sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum();
if(sum < vipSetting.getKeepSharePoint()){
appUser.setIsDanger(1);
}
//门店业绩
- list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 8).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShopDay() + " DAY) >= create_time"));
+ list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 8).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShopDay() + " DAY) <= create_time"));
sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum();
if(sum < vipSetting.getKeepShopPoint()){
appUser.setIsDanger(1);
@@ -596,7 +675,21 @@
AppUser byId = appUserService.getById(id);
byId.setStatus(status);
appUserService.updateById(byId);
+ loginout(id);
return R.ok();
+ }
+
+ private void loginout(Long userId) {
+ Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
+ if (!CollectionUtils.isEmpty(keys)) {
+ for (String key : keys) {
+ LoginUser user = redisService.getCacheObject(key);
+ if (user.getUserid().equals(userId)) {
+ redisService.deleteObject(key);
+ break;
+ }
+ }
+ }
}
@GetMapping("/select")
@@ -652,8 +745,7 @@
@GetMapping("/detail")
@ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
- public R<AppUser> detail(Long id) {
-
+ public R<AppUser> detail(Long id, Integer shopId) {
Long userid = tokenService.getLoginUser().getUserid();
SysUser sysUser = sysUserClient.getSysUser(userid).getData();
AppUser byId = appUserService.getById(id);
@@ -686,7 +778,13 @@
List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list();
byId.setBottomUsers(list);
//消费总金额
- R<List<Order>> orderR = remoteOrderGoodsClient.byShopIdAndUserId(id,byId.getShopId());
+ if(null == shopId || 1 == sysUser.getRoleType()){
+ shopId = -1;
+ }
+ if(null == shopId && 2 == sysUser.getRoleType()){
+ shopId = sysUser.getObjectId();
+ }
+ R<List<Order>> orderR = remoteOrderGoodsClient.byUserId(id, shopId);
List<Order> orderList = orderR.getData();
if (!CollectionUtils.isEmpty(orderList)){
BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -697,8 +795,21 @@
return R.ok(byId);
}
- @Resource
- private UserChangeLogService userChangeLogService;
+ /**
+ * 获取指定用户的下级用户
+ */
+ @GetMapping("/bottom/list")
+ @ApiOperation(value = "用户列表-下级用户", tags = {"管理后台"})
+ public R<Page<AppUser>> bottom(Integer pageNum, Integer pageSize, Long userId){
+ Page<AppUser> page = appUserService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<AppUser>()
+ .eq(AppUser::getInviteUserId, userId));
+ return R.ok(page);
+ }
+
+
+
+
+
@GetMapping("/change/vip")
@ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"})
@@ -719,7 +830,6 @@
byId.setVipId(vipId);
appUserService.updateById(byId);
return R.ok();
-
}
@GetMapping("/bottom")
@@ -733,13 +843,35 @@
@GetMapping("/orders")
@ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"})
- public R<List<Order>> orders(Long id) {
+ public R<JSONObject> orders(Long id,Integer pageNum, Integer pageSize) {
Long userid = tokenService.getLoginUser().getUserid();
SysUser sysUser = sysUserClient.getSysUser(userid).getData();
- Integer shopId = sysUser.getObjectId();
+ Integer shopId = -1;
+ if(sysUser.getRoleType() == 2){
+ shopId = sysUser.getObjectId();
+ }
R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id,shopId);
- return R.ok(listR.getData());
-
+ List<Order> data = listR.getData();
+ Integer total = data.size();
+ // 手动分页
+ if (data != null && data.size() > 0) {
+ if (pageNum == null || pageNum == 0) {
+ pageNum = 1;
+ }
+ if (pageSize == null || pageSize == 0) {
+ pageSize = 10;
+ }
+ data = data.stream()
+ .skip((pageNum - 1) * pageSize)
+ .limit(pageSize)
+ .collect(Collectors.toList());
+ }
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("records", data);
+ jsonObject.put("total", total);
+ jsonObject.put("size", pageSize);
+ jsonObject.put("current", pageNum);
+ return R.ok(jsonObject);
}
@@ -831,8 +963,6 @@
if (cd.getStartTime().isAfter(cd.getEndTime())) {
return R.fail("开始时间不能大于结束时间");
}
-
-
Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new TreeMap<>();
getDatesBetween(cd.getStartTime(), cd.getEndTime()).forEach(date -> {
for (int i = 1; i < 8; i++){
@@ -1001,7 +1131,7 @@
* 检查会员降级
* @param appUserId
*/
- @PostMapping("/app-user/vipDemotion")
+ @PostMapping("/vipDemotion")
public void vipDemotion(@RequestParam("appUserId") Long appUserId){
appUserService.vipDemotion(appUserId);
}
--
Gitblit v1.7.1