feat(integral-external): order/user list, integral log, wa selfBonus
- Fix ExternalIntegral order list (no double restPage); default 普通订单; UI columns for useIntegral and buyer uid/nickname/phone; enrich StoreOrderDetailResponse and admin query select. - External user list: UserResponse.selfBonus and fillWaSelfBonus from wa_users.id=uid. - Integral log: AdminIntegralSearchRequest nickName/phone; findAdminList filters and ordering; integralExternal API sends page/limit as query params. - Integral detail page: linkType Chinese mapping including selfbonus; update docs/newpage.md. - Dashboard grid menu entries for integral-external routes. Made-with: Cursor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.zbkj.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.zbkj.common.page.CommonPage;
|
||||
import com.zbkj.common.request.*;
|
||||
import com.zbkj.common.response.StoreOrderDetailResponse;
|
||||
@@ -69,7 +70,7 @@ public class ExternalIntegralController {
|
||||
@Validated StoreOrderSearchRequest request,
|
||||
@Validated PageParamRequest pageParamRequest) {
|
||||
CommonPage<StoreOrderDetailResponse> restPage =
|
||||
CommonPage.restPage(storeOrderService.getAdminList(request, pageParamRequest));
|
||||
storeOrderService.getAdminList(request, pageParamRequest);
|
||||
return CommonResult.success(restPage);
|
||||
}
|
||||
|
||||
@@ -87,6 +88,9 @@ public class ExternalIntegralController {
|
||||
@Validated PageParamRequest pageParamRequest) {
|
||||
CommonPage<UserResponse> restPage =
|
||||
CommonPage.restPage(userService.getList(request, pageParamRequest));
|
||||
if (CollUtil.isNotEmpty(restPage.getList())) {
|
||||
userService.fillWaSelfBonus(restPage.getList());
|
||||
}
|
||||
return CommonResult.success(restPage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,10 @@ public class AdminIntegralSearchRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "用户名称(昵称,模糊匹配)")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "用户手机号(模糊匹配)")
|
||||
private String phone;
|
||||
}
|
||||
|
||||
@@ -123,4 +123,16 @@ public class StoreOrderDetailResponse implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "物流状态/出库状态:0-未出库,1-已出库")
|
||||
private Integer deliveryStatus;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "用户手机号")
|
||||
private String userPhone;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "使用积分")
|
||||
private Integer useIntegral;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ public class UserResponse {
|
||||
@ApiModelProperty(value = "用户剩余积分(支持小数点后3位)")
|
||||
private BigDecimal integral;
|
||||
|
||||
@ApiModelProperty(value = "个人奖金(寄卖 wa_users.self_bonus,与 uid 对应 wa_users.id)")
|
||||
private BigDecimal selfBonus;
|
||||
|
||||
@ApiModelProperty(value = "用户剩余经验")
|
||||
private Integer experience;
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ public interface UserService extends IService<User> {
|
||||
*/
|
||||
PageInfo<UserResponse> getList(UserSearchRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 按 eb_user.uid = wa_users.id 批量填充寄卖个人奖金(wa_users.self_bonus)
|
||||
*/
|
||||
void fillWaSelfBonus(List<UserResponse> users);
|
||||
|
||||
/**
|
||||
* 操作积分、余额
|
||||
*/
|
||||
@@ -260,6 +265,13 @@ public interface UserService extends IService<User> {
|
||||
*/
|
||||
List<Integer> findIdListLikeName(String nikeName);
|
||||
|
||||
/**
|
||||
* 根据手机号模糊匹配用户,返回 uid 集合
|
||||
* @param phone 手机号关键字
|
||||
* @return uid 列表
|
||||
*/
|
||||
List<Integer> findIdListLikePhone(String phone);
|
||||
|
||||
/**
|
||||
* 清除对应的用户等级
|
||||
* @param levelId 等级id
|
||||
|
||||
@@ -168,10 +168,11 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderDao, StoreOrder
|
||||
public CommonPage<StoreOrderDetailResponse> getAdminList(StoreOrderSearchRequest request, PageParamRequest pageParamRequest) {
|
||||
Page<Object> startPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
QueryWrapper<StoreOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id", "order_id", "uid", "real_name", "pay_price", "pay_type", "create_time", "status", "refund_status"
|
||||
queryWrapper.select("id", "order_id", "uid", "real_name", "user_phone", "pay_price", "pay_type", "create_time", "status", "refund_status"
|
||||
, "refund_reason_wap_img", "refund_reason_wap_explain", "refund_reason_wap", "refund_reason", "refund_reason_time"
|
||||
, "is_del", "combination_id", "pink_id", "seckill_id", "bargain_id", "verify_code", "remark", "paid", "is_system_del"
|
||||
, "shipping_type", "type", "is_alter_price", "pro_total_price", "is_alter_price", "coupon_price", "delivery_status");
|
||||
, "shipping_type", "type", "is_alter_price", "pro_total_price", "is_alter_price", "coupon_price", "delivery_status"
|
||||
, "use_integral");
|
||||
if (StrUtil.isNotBlank(request.getOrderNo())) {
|
||||
queryWrapper.eq("order_id", request.getOrderNo());
|
||||
}
|
||||
@@ -302,17 +303,19 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderDao, StoreOrder
|
||||
|
||||
//获取订单详情map
|
||||
HashMap<Integer, List<StoreOrderInfoOldVo>> orderInfoList = StoreOrderInfoService.getMapInId(orderIdList);
|
||||
//
|
||||
// //根据用户获取信息
|
||||
// List<Integer> userIdList = orderList.stream().map(StoreOrder::getUid).distinct().collect(Collectors.toList());
|
||||
// //订单用户信息
|
||||
// HashMap<Integer, User> userList = userService.getMapListInUid(userIdList);
|
||||
|
||||
List<Integer> userIdList = orderList.stream().map(StoreOrder::getUid).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
HashMap<Integer, User> userMap = CollUtil.isEmpty(userIdList) ? new HashMap<>() : userService.getMapListInUid(userIdList);
|
||||
|
||||
for (StoreOrder storeOrder : orderList) {
|
||||
StoreOrderDetailResponse storeOrderItemResponse = new StoreOrderDetailResponse();
|
||||
BeanUtils.copyProperties(storeOrder, storeOrderItemResponse);
|
||||
|
||||
storeOrderItemResponse.setProductList(orderInfoList.get(storeOrder.getId()));
|
||||
User buyer = userMap.get(storeOrder.getUid());
|
||||
if (ObjectUtil.isNotNull(buyer)) {
|
||||
storeOrderItemResponse.setNickname(buyer.getNickname());
|
||||
}
|
||||
|
||||
//订单状态
|
||||
storeOrderItemResponse.setStatusStr(getStatus(storeOrder));
|
||||
|
||||
@@ -33,7 +33,10 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -114,7 +117,7 @@ public class UserIntegralRecordServiceImpl extends ServiceImpl<UserIntegralRecor
|
||||
|
||||
// 批量事务处理同一用户的积分解冻
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
Integer currentIntegral = user.getIntegral();
|
||||
BigDecimal currentIntegral = user.getIntegral();
|
||||
for (UserIntegralRecord record : userRecords) {
|
||||
record.setStatus(IntegralRecordConstants.INTEGRAL_RECORD_STATUS_COMPLETE);
|
||||
// 计算积分余额
|
||||
@@ -126,7 +129,7 @@ public class UserIntegralRecordServiceImpl extends ServiceImpl<UserIntegralRecor
|
||||
|
||||
// 更新用户积分
|
||||
userService.operationIntegral(uid, record.getIntegral(), currentIntegral, "add");
|
||||
currentIntegral = balance; // 更新当前积分供下一条记录计算
|
||||
currentIntegral = BigDecimal.valueOf(balance); // 更新当前积分供下一条记录计算
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
@@ -151,19 +154,48 @@ public class UserIntegralRecordServiceImpl extends ServiceImpl<UserIntegralRecor
|
||||
Page<UserIntegralRecordResponse> page = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<UserIntegralRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.select(UserIntegralRecord::getId, UserIntegralRecord::getTitle, UserIntegralRecord::getBalance, UserIntegralRecord::getIntegral,
|
||||
UserIntegralRecord::getMark, UserIntegralRecord::getUid, UserIntegralRecord::getUpdateTime);
|
||||
UserIntegralRecord::getMark, UserIntegralRecord::getUid, UserIntegralRecord::getUpdateTime,
|
||||
UserIntegralRecord::getType, UserIntegralRecord::getLinkType, UserIntegralRecord::getStatus, UserIntegralRecord::getCreateTime);
|
||||
lqw.eq(UserIntegralRecord::getStatus, IntegralRecordConstants.INTEGRAL_RECORD_STATUS_COMPLETE);
|
||||
if (ObjectUtil.isNotNull(request.getUid())) {
|
||||
lqw.eq(UserIntegralRecord::getUid, request.getUid());
|
||||
}
|
||||
if (StrUtil.isNotBlank(request.getKeywords())) {
|
||||
List<Integer> idList = userService.findIdListLikeName(request.getKeywords());
|
||||
if (CollUtil.isNotEmpty(idList)) {
|
||||
lqw.in(UserIntegralRecord::getUid, idList);
|
||||
} else {
|
||||
|
||||
String nameKey = StrUtil.isNotBlank(request.getNickName()) ? request.getNickName() : request.getKeywords();
|
||||
List<Integer> nameUidList = null;
|
||||
if (StrUtil.isNotBlank(nameKey)) {
|
||||
nameUidList = userService.findIdListLikeName(nameKey);
|
||||
if (CollUtil.isEmpty(nameUidList)) {
|
||||
return CommonPage.copyPageInfo(page, CollUtil.newArrayList());
|
||||
}
|
||||
}
|
||||
List<Integer> phoneUidList = null;
|
||||
if (StrUtil.isNotBlank(request.getPhone())) {
|
||||
phoneUidList = userService.findIdListLikePhone(request.getPhone());
|
||||
if (CollUtil.isEmpty(phoneUidList)) {
|
||||
return CommonPage.copyPageInfo(page, CollUtil.newArrayList());
|
||||
}
|
||||
}
|
||||
List<Integer> mergedUids = null;
|
||||
if (nameUidList != null) {
|
||||
mergedUids = new ArrayList<>(nameUidList);
|
||||
}
|
||||
if (phoneUidList != null) {
|
||||
if (mergedUids == null) {
|
||||
mergedUids = new ArrayList<>(phoneUidList);
|
||||
} else {
|
||||
mergedUids.retainAll(new HashSet<>(phoneUidList));
|
||||
if (mergedUids.isEmpty()) {
|
||||
return CommonPage.copyPageInfo(page, CollUtil.newArrayList());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(request.getUid())) {
|
||||
if (mergedUids != null && !mergedUids.contains(request.getUid())) {
|
||||
return CommonPage.copyPageInfo(page, CollUtil.newArrayList());
|
||||
}
|
||||
lqw.eq(UserIntegralRecord::getUid, request.getUid());
|
||||
} else if (mergedUids != null) {
|
||||
lqw.in(UserIntegralRecord::getUid, mergedUids);
|
||||
}
|
||||
|
||||
//时间范围
|
||||
if (StrUtil.isNotBlank(request.getDateLimit())) {
|
||||
DateLimitUtilVo dateLimit = CrmebDateUtil.getDateLimit(request.getDateLimit());
|
||||
@@ -176,6 +208,7 @@ public class UserIntegralRecordServiceImpl extends ServiceImpl<UserIntegralRecor
|
||||
lqw.between(UserIntegralRecord::getUpdateTime, dateLimit.getStartTime(), dateLimit.getEndTime());
|
||||
}
|
||||
lqw.orderByDesc(UserIntegralRecord::getUpdateTime);
|
||||
lqw.orderByDesc(UserIntegralRecord::getId);
|
||||
List<UserIntegralRecord> list = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return CommonPage.copyPageInfo(page, CollUtil.newArrayList());
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.common.constants.*;
|
||||
import com.zbkj.common.exception.CrmebException;
|
||||
import com.zbkj.common.model.consignment.WaUsers;
|
||||
import com.zbkj.common.model.coupon.StoreCoupon;
|
||||
import com.zbkj.common.model.coupon.StoreCouponUser;
|
||||
import com.zbkj.common.model.order.StoreOrder;
|
||||
@@ -28,6 +29,7 @@ import com.zbkj.common.token.FrontTokenComponent;
|
||||
import com.zbkj.common.utils.*;
|
||||
import com.zbkj.common.vo.DateLimitUtilVo;
|
||||
import com.zbkj.service.dao.UserDao;
|
||||
import com.zbkj.service.dao.consignment.WaUsersDao;
|
||||
import com.zbkj.service.service.*;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -58,6 +60,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserS
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
|
||||
@Resource
|
||||
private WaUsersDao waUsersDao;
|
||||
|
||||
@Autowired
|
||||
private UserBillService userBillService;
|
||||
|
||||
@@ -223,6 +228,33 @@ public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserS
|
||||
return CommonPage.copyPageInfo(pageUser, userResponses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWaSelfBonus(List<UserResponse> users) {
|
||||
if (CollUtil.isEmpty(users)) {
|
||||
return;
|
||||
}
|
||||
List<Integer> uids = users.stream()
|
||||
.map(UserResponse::getUid)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(uids)) {
|
||||
return;
|
||||
}
|
||||
List<WaUsers> waUsers = waUsersDao.selectBatchIds(uids);
|
||||
if (CollUtil.isEmpty(waUsers)) {
|
||||
return;
|
||||
}
|
||||
Map<Integer, BigDecimal> idToBonus = waUsers.stream()
|
||||
.filter(w -> w.getId() != null)
|
||||
.collect(Collectors.toMap(WaUsers::getId, WaUsers::getSelfBonus, (a, b) -> a));
|
||||
for (UserResponse ur : users) {
|
||||
if (ur.getUid() != null && idToBonus.containsKey(ur.getUid())) {
|
||||
ur.setSelfBonus(idToBonus.get(ur.getUid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作积分、余额
|
||||
*/
|
||||
@@ -1586,6 +1618,18 @@ public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserS
|
||||
return userList.stream().map(User::getUid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> findIdListLikePhone(String phone) {
|
||||
LambdaQueryWrapper<User> lqw = Wrappers.lambdaQuery();
|
||||
lqw.select(User::getUid);
|
||||
lqw.like(User::getPhone, phone);
|
||||
List<User> userList = userDao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return userList.stream().map(User::getUid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除对应的用户等级
|
||||
* @param levelId 等级id
|
||||
|
||||
Reference in New Issue
Block a user