会员列表返回优惠券数量
This commit is contained in:
parent
42c2a90ec6
commit
b2042e4721
|
|
@ -1,10 +1,7 @@
|
||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
import com.czg.account.dto.shopuser.*;
|
||||||
import com.czg.account.dto.shopuser.ShopUserEditDTO;
|
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
|
||||||
import com.czg.account.dto.shopuser.ShopUserSummaryDTO;
|
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
import com.czg.account.entity.ShopUserFlow;
|
import com.czg.account.entity.ShopUserFlow;
|
||||||
import com.czg.account.service.ShopUserFlowService;
|
import com.czg.account.service.ShopUserFlowService;
|
||||||
|
|
@ -86,7 +83,7 @@ public class ShopUserController {
|
||||||
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
|
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
|
||||||
@SaAdminCheckPermission(value = "shopUser:list", name = "店铺用户列表")
|
@SaAdminCheckPermission(value = "shopUser:list", name = "店铺用户列表")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public CzgResult<Page<ShopUser>> list(String key, Integer isVip) {
|
public CzgResult<Page<ShopUserDTO>> list(String key, Integer isVip) {
|
||||||
return CzgResult.success(shopUserService.getPage(key, isVip));
|
return CzgResult.success(shopUserService.getPage(key, isVip));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +100,7 @@ public class ShopUserController {
|
||||||
if (id == null && userId == null) {
|
if (id == null && userId == null) {
|
||||||
return CzgResult.failure("id和userId不能重复为空");
|
return CzgResult.failure("id和userId不能重复为空");
|
||||||
}
|
}
|
||||||
return CzgResult.success(shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getId, id).eq(ShopUser::getUserId, userId)));
|
return CzgResult.success(shopUserService.getDetail(id, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.czg.account.dto.shopuser;
|
||||||
|
|
||||||
|
import com.czg.account.entity.ShopUser;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class ShopUserDTO extends ShopUser {
|
||||||
|
private Long couponNum;
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ import com.mybatisflex.core.service.IService;
|
||||||
*/
|
*/
|
||||||
public interface ShopUserService extends IService<ShopUser> {
|
public interface ShopUserService extends IService<ShopUser> {
|
||||||
|
|
||||||
Page<ShopUser> getPage(String key, Integer isVip);
|
Page<ShopUserDTO> getPage(String key, Integer isVip);
|
||||||
|
|
||||||
Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO);
|
Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO);
|
||||||
|
|
||||||
|
|
@ -39,4 +39,6 @@ public interface ShopUserService extends IService<ShopUser> {
|
||||||
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
|
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
|
||||||
|
|
||||||
ShopUserDetailDTO getInfo(Long shopId, long userId);
|
ShopUserDetailDTO getInfo(Long shopId, long userId);
|
||||||
|
|
||||||
|
ShopUser getDetail(Integer id, Integer userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.czg.service.account.mapper;
|
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.ShopUserSummaryDTO;
|
||||||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||||
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
||||||
|
|
@ -10,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户储值会员 映射层。
|
* 商户储值会员 映射层。
|
||||||
|
|
@ -19,9 +21,7 @@ import java.time.LocalDateTime;
|
||||||
*/
|
*/
|
||||||
public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
||||||
|
|
||||||
Page<ShopUser> selectPageByKeyAndIsVip();
|
List<ShopUserDTO> selectPageByKeyAndIsVip(@Param("shopId") Long shopId, @Param("isVip") Integer isVip, @Param("key") String key);
|
||||||
|
|
||||||
long selectPageByKeyAndIsVip_COUNT();
|
|
||||||
|
|
||||||
int incrAccount(@Param("shopId") long shopId, @Param("id") Long id, @Param("time") LocalDateTime time, @Param("money") BigDecimal money);
|
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);
|
int decrAccount(@Param("shopId") long shopId, @Param("id") Long id, @Param("time") LocalDateTime time, @Param("money") BigDecimal money);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ import com.czg.system.service.SysParamsService;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import com.czg.utils.JoinQueryWrapper;
|
import com.czg.utils.JoinQueryWrapper;
|
||||||
import com.czg.utils.PageUtil;
|
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.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;
|
||||||
|
|
@ -78,23 +80,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ShopUser> getPage(String key, Integer isVip) {
|
public Page<ShopUserDTO> getPage(String key, Integer isVip) {
|
||||||
JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId());
|
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||||
if (StrUtil.isNotBlank(key)) {
|
return PageUtil.convert(new PageInfo<>(mapper.selectPageByKeyAndIsVip(StpKit.USER.getShopId(), isVip, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -340,4 +328,13 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||||
shopUserDetailDTO.setPayPwd(userInfo.getPayPwd());
|
shopUserDetailDTO.setPayPwd(userInfo.getPayPwd());
|
||||||
return shopUserDetailDTO;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,23 @@
|
||||||
on c.shop_id = b.shop_id and c.shop_user_id = b.id and c.`status` = 1
|
on c.shop_id = b.shop_id and c.shop_user_id = b.id and c.`status` = 1
|
||||||
where a.id = #{userId}
|
where a.id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.entity.ShopUser">
|
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.dto.shopuser.ShopUserDTO">
|
||||||
select tb_shop_user.*
|
SELECT
|
||||||
from tb_shop_user
|
a.*, count(c.id) couponNum
|
||||||
left join tb_user_info on tb_user_info.id = tb_shop_user.user_id ${qwSql}
|
FROM
|
||||||
limit ${pageOffset}, ${pageSize}
|
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>
|
||||||
<select id="selectPageByKeyAndIsVip_COUNT" resultType="java.lang.Long">
|
<select id="selectPageByKeyAndIsVip_COUNT" resultType="java.lang.Long">
|
||||||
select count(1)
|
select count(1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue