用户信息相关
This commit is contained in:
parent
344b25b31c
commit
301660182f
|
|
@ -38,6 +38,6 @@ public class UserAuthorizationController {
|
|||
@PostMapping("/test")
|
||||
public CzgResult<String> login() {
|
||||
StpKit.USER.login(1L, null, false, false);
|
||||
return CzgResult.success(StpKit.USER.getTokenValue() +"哈哈哈");
|
||||
return CzgResult.success(StpKit.USER.getTokenValue());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.czg.controller.user;
|
|||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoEditDTO;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
|
|
@ -26,8 +27,8 @@ public class UserController {
|
|||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<UserInfo> get() {
|
||||
return CzgResult.success(userInfoService.getById(StpKit.USER.getLoginIdAsLong()));
|
||||
public CzgResult<UserInfoDTO> get() {
|
||||
return CzgResult.success(userInfoService.getInfo(StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.czg.account.dto.user.userinfo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoAssetsSummaryDTO {
|
||||
/**
|
||||
* 总余额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
/**
|
||||
* 总积分
|
||||
*/
|
||||
private Integer points;
|
||||
/**
|
||||
* 可使用优惠券数量
|
||||
*/
|
||||
private Integer couponNum;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.account.dto.user.userinfo;
|
||||
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UserInfoDTO extends UserInfo {
|
||||
/**
|
||||
* 用户资产概述
|
||||
*/
|
||||
private UserInfoAssetsSummaryDTO assetsSummary;
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
|
|
@ -11,4 +12,5 @@ import com.mybatisflex.core.service.IService;
|
|||
*/
|
||||
public interface UserInfoService extends IService<UserInfo> {
|
||||
|
||||
UserInfoDTO getInfo(long userInfoId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.czg.service.account.mapper;
|
|||
|
||||
import com.czg.account.dto.shopuser.ShopUserSummaryDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
|
@ -27,4 +28,7 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
|||
ShopUserSummaryDTO selectUserSummary(@Param("shopId") Long shopId, @Param("isVip") Integer isVip);
|
||||
|
||||
Page<ShopUserVipCardDTO> selectVipCard(@Param("page") Page<Object> objectPage, @Param("userInfoId") long userInfoId);
|
||||
|
||||
UserInfoAssetsSummaryDTO selectAssetsSummary(@Param("userId") Long userInfoId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.service.account.mapper.ShopUserMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.service.account.mapper.UserInfoMapper;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
@ -14,5 +21,19 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService{
|
||||
@Resource
|
||||
private ShopUserMapper shopUserMapper;
|
||||
|
||||
@Override
|
||||
public UserInfoDTO getInfo(long userInfoId) {
|
||||
UserInfo userInfo = queryChain().eq(UserInfo::getId, userInfoId).one();
|
||||
if (userInfo == null) {
|
||||
throw new ApiNotPrintException("用户信息不存在");
|
||||
}
|
||||
|
||||
UserInfoAssetsSummaryDTO assetsSummaryDTO = shopUserMapper.selectAssetsSummary(userInfoId);
|
||||
UserInfoDTO userInfoDTO = BeanUtil.copyProperties(userInfo, UserInfoDTO.class);
|
||||
userInfoDTO.setAssetsSummary(assetsSummaryDTO);
|
||||
return userInfoDTO;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,15 +31,26 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="selectUserSummary" resultType="com.czg.account.dto.shopuser.ShopUserSummaryDTO">
|
||||
select count(a.id) userTotal, sum(IFNULL(a.amount, 0)) balanceTotal,sum(IFNULL(b.amount,0)) chargeTotal from tb_shop_user as a
|
||||
left join tb_shop_user_flow as b on a.id=b.user_id and b.type='+' and b.biz_code in ('cashIn', 'wechatIn', 'alipayIn')
|
||||
select count(a.id) userTotal, sum(IFNULL(a.amount, 0)) balanceTotal,sum(IFNULL(b.amount,0)) chargeTotal from
|
||||
tb_shop_user as a
|
||||
left join tb_shop_user_flow as b on a.id=b.user_id and b.type='+' and b.biz_code in ('cashIn', 'wechatIn',
|
||||
'alipayIn')
|
||||
where a.shop_id = #{shopId}
|
||||
<if test="isVip !=null">
|
||||
and a.is_vip=#{isVip}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectVipCard" resultType="com.czg.account.dto.shopuser.ShopUserVipCardDTO">
|
||||
select b.logo, b.shop_name shopName, a.amount, a.shop_id shopId from tb_shop_user as a left join tb_shop_info as b on a.shop_id=b.id
|
||||
where a.user_id=#{userInfoId}
|
||||
select b.logo, b.shop_name shopName, a.amount, a.shop_id shopId
|
||||
from tb_shop_user as a
|
||||
left join tb_shop_info as b on a.shop_id = b.id
|
||||
where a.user_id = #{userInfoId}
|
||||
</select>
|
||||
<select id="selectAssetsSummary" resultType="com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO">
|
||||
select sum(IFNULL(b.amount, 0)) amount, sum(IFNULL(b.account_points, 0)) points, sum(IFNULL(c.over_num, 0)) couponNum
|
||||
from tb_user_info as a
|
||||
left join tb_shop_user as b on a.id = b.user_id
|
||||
left join tb_shop_activate_in_record as c on c.shop_id = b.shop_id
|
||||
where a.id=#{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue