Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
wangw 2025-09-26 16:54:13 +08:00
commit 9313f0f5d5
4 changed files with 69 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import com.czg.account.entity.ShopUserFlow;
import com.czg.account.service.MemberPointsLogService; import com.czg.account.service.MemberPointsLogService;
import com.czg.account.service.ShopUserFlowService; import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.UShopUserService; import com.czg.account.service.UShopUserService;
import com.czg.account.vo.PointsShopListVO;
import com.czg.annotation.Debounce; import com.czg.annotation.Debounce;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
@ -19,6 +20,8 @@ import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* 店铺会员相关 * 店铺会员相关
* *
@ -98,6 +101,14 @@ public class UShopUserController {
.eq(ShopUserFlow::getUserId, StpKit.USER.getLoginIdAsLong()).eq(ShopUserFlow::getId, id))); .eq(ShopUserFlow::getUserId, StpKit.USER.getLoginIdAsLong()).eq(ShopUserFlow::getId, id)));
} }
/**
* 获取用户所有门店下积分列表
*/
@GetMapping("/pointsShopList")
public CzgResult<List<PointsShopListVO>> getList() {
return CzgResult.success(memberPointsLogService.getList(StpKit.USER.getLoginIdAsLong()));
}
/** /**
* 获取积分明细 * 获取积分明细
* @return 分页数据 * @return 分页数据

View File

@ -2,9 +2,12 @@ package com.czg.account.service;
import com.czg.account.dto.points.MemberPointsLogDTO; import com.czg.account.dto.points.MemberPointsLogDTO;
import com.czg.account.entity.MemberPointsLog; import com.czg.account.entity.MemberPointsLog;
import com.czg.account.vo.PointsShopListVO;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import java.util.List;
/** /**
* 会员积分变动记录 * 会员积分变动记录
* *
@ -15,4 +18,5 @@ public interface MemberPointsLogService extends IService<MemberPointsLog> {
Page<MemberPointsLogDTO> getMemberPointsLogPage(MemberPointsLogDTO param); Page<MemberPointsLogDTO> getMemberPointsLogPage(MemberPointsLogDTO param);
} List<PointsShopListVO> getList(long userId);
}

View File

@ -0,0 +1,13 @@
package com.czg.account.vo;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class PointsShopListVO {
private String shopName;
private String logo;
private Long shopId;
private Integer accountPoints;
}

View File

@ -4,16 +4,27 @@ import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.points.MemberPointsLogDTO; import com.czg.account.dto.points.MemberPointsLogDTO;
import com.czg.account.entity.MemberPointsLog; import com.czg.account.entity.MemberPointsLog;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.service.MemberPointsLogService; import com.czg.account.service.MemberPointsLogService;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService;
import com.czg.account.vo.PointsShopListVO;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.account.mapper.MemberPointsLogMapper; import com.czg.service.account.mapper.MemberPointsLogMapper;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static com.czg.account.entity.table.MemberPointsLogTableDef.MEMBER_POINTS_LOG; import static com.czg.account.entity.table.MemberPointsLogTableDef.MEMBER_POINTS_LOG;
import static com.czg.account.entity.table.MemberPointsTableDef.MEMBER_POINTS; import static com.czg.account.entity.table.MemberPointsTableDef.MEMBER_POINTS;
import static com.czg.account.entity.table.ShopUserTableDef.SHOP_USER; import static com.czg.account.entity.table.ShopUserTableDef.SHOP_USER;
@ -26,6 +37,10 @@ import static com.czg.account.entity.table.ShopUserTableDef.SHOP_USER;
*/ */
@Service @Service
public class MemberPointsLogServiceImpl extends ServiceImpl<MemberPointsLogMapper, MemberPointsLog> implements MemberPointsLogService { public class MemberPointsLogServiceImpl extends ServiceImpl<MemberPointsLogMapper, MemberPointsLog> implements MemberPointsLogService {
@Resource
private ShopUserService shopUserService;
@Resource
private ShopInfoService shopInfoService;
private QueryWrapper buildQueryWrapper(MemberPointsLogDTO param) { private QueryWrapper buildQueryWrapper(MemberPointsLogDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper(); QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
@ -73,4 +88,28 @@ public class MemberPointsLogServiceImpl extends ServiceImpl<MemberPointsLogMappe
QueryWrapper queryWrapper = buildFullQueryWrapper(param); QueryWrapper queryWrapper = buildFullQueryWrapper(param);
return super.pageAs(PageUtil.buildPage(), queryWrapper, MemberPointsLogDTO.class); return super.pageAs(PageUtil.buildPage(), queryWrapper, MemberPointsLogDTO.class);
} }
}
@Override
public List<PointsShopListVO> getList(long userId) {
ArrayList<PointsShopListVO> pointsShopListVOS = new ArrayList<>();
List<ShopUser> shopUserList = shopUserService.list(new QueryWrapper().eq(ShopUser::getUserId, userId).gt(ShopUser::getAccountPoints, 0));
if (shopUserList.isEmpty()) {
return pointsShopListVOS;
}
Set<Long> shopIdList = shopUserList.stream().map(ShopUser::getSourceShopId).collect(Collectors.toSet());
Map<Long, ShopInfo> shopInfoMap = shopInfoService.listByIds(shopIdList).stream().collect(Collectors.toMap(ShopInfo::getId, item -> item));
for (ShopUser shopUser : shopUserList) {
ShopInfo shopInfo = shopInfoMap.get(shopUser.getSourceShopId());
if (shopInfo == null) {
continue;
}
pointsShopListVOS.add(new PointsShopListVO()
.setShopName(shopInfo.getShopName())
.setLogo(shopInfo.getLogo())
.setAccountPoints(shopUser.getAccountPoints())
.setShopId(shopInfo.getId()));
}
return pointsShopListVOS;
}
}