会员列表返回优惠券数量

This commit is contained in:
张松
2025-03-17 13:43:30 +08:00
parent 42c2a90ec6
commit b2042e4721
6 changed files with 54 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
package com.czg.service.account.mapper;
import com.czg.account.dto.shopuser.ShopUserDTO;
import com.czg.account.dto.shopuser.ShopUserSummaryDTO;
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
@@ -10,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 商户储值会员 映射层。
@@ -19,9 +21,7 @@ import java.time.LocalDateTime;
*/
public interface ShopUserMapper extends BaseMapper<ShopUser> {
Page<ShopUser> selectPageByKeyAndIsVip();
long selectPageByKeyAndIsVip_COUNT();
List<ShopUserDTO> selectPageByKeyAndIsVip(@Param("shopId") Long shopId, @Param("isVip") Integer isVip, @Param("key") String key);
int incrAccount(@Param("shopId") long shopId, @Param("id") Long id, @Param("time") LocalDateTime time, @Param("money") BigDecimal money);
int decrAccount(@Param("shopId") long shopId, @Param("id") Long id, @Param("time") LocalDateTime time, @Param("money") BigDecimal money);

View File

@@ -24,6 +24,8 @@ import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.JoinQueryWrapper;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
@@ -78,23 +80,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
}
@Override
public Page<ShopUser> getPage(String key, Integer isVip) {
JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(key)) {
queryWrapper.and(q -> {
q.like(ShopUser::getNickName, key).or(r -> {
r.like(ShopUser::getPhone, key);
});
});
// queryWrapper.and(column(UserInfo::getNickName).like(key).or(column(UserInfo::getPhone).like(key)));
}
if (isVip != null) {
queryWrapper.eq(ShopUser::getIsVip, isVip);
}
queryWrapper.orderBy(ShopUser::getId, false);
return mapper.xmlPaginate("selectPageByKeyAndIsVip", PageUtil.buildPage(), queryWrapper);
public Page<ShopUserDTO> getPage(String key, Integer isVip) {
PageHelper.startPage(PageUtil.buildPageHelp());
return PageUtil.convert(new PageInfo<>(mapper.selectPageByKeyAndIsVip(StpKit.USER.getShopId(), isVip, key)));
}
@Override
@@ -340,4 +328,13 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
shopUserDetailDTO.setPayPwd(userInfo.getPayPwd());
return shopUserDetailDTO;
}
@Override
public ShopUser getDetail(Integer id, Integer userId) {
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getId, id).eq(ShopUser::getUserId, userId));
long count = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0));
ShopUserDTO shopUserDTO = BeanUtil.copyProperties(shopUser, ShopUserDTO.class);
shopUserDTO.setCouponNum(count);
return shopUserDTO;
}
}

View File

@@ -48,11 +48,23 @@
on c.shop_id = b.shop_id and c.shop_user_id = b.id and c.`status` = 1
where a.id = #{userId}
</select>
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.entity.ShopUser">
select tb_shop_user.*
from tb_shop_user
left join tb_user_info on tb_user_info.id = tb_shop_user.user_id ${qwSql}
limit ${pageOffset}, ${pageSize}
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.dto.shopuser.ShopUserDTO">
SELECT
a.*, count(c.id) couponNum
FROM
tb_shop_user a
LEFT JOIN tb_user_info b ON b.id = a.user_id
left join tb_shop_activate_coupon_record c on c.shop_user_id=a.id and c.`status`=0
where a.shop_id=#{shopId}
<if test="isVip != null">
and a.is_vip=#{isVip}
</if>
<if test="key != null and key != ''">
and (a.nick_name like concat('%', #{key}, '%') or a.phone like concat('%', #{key}, '%'))
</if>
GROUP BY a.id
order by a.create_time desc
</select>
<select id="selectPageByKeyAndIsVip_COUNT" resultType="java.lang.Long">
select count(1)