小程序首页数据接口
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.market.entity.MkPointsConfig;
|
||||
import com.czg.market.entity.MkPointsUser;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.MkDistributionConfigVO;
|
||||
import com.czg.market.vo.UserCouponVO;
|
||||
import com.czg.market.vo.UserHomeDataVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2025/12/11 11:33
|
||||
*/
|
||||
@Service
|
||||
public class UserHomeServiceImpl implements UserHomeService {
|
||||
|
||||
@Resource
|
||||
private MkPointsConfigService mkPointsConfigService;
|
||||
|
||||
@Resource
|
||||
private MkDistributionConfigService mkDistributionConfigService;
|
||||
|
||||
@Resource
|
||||
private MkPointsUserService mkPointsUserService;
|
||||
|
||||
@Resource
|
||||
private ShopCouponService couponService;
|
||||
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Override
|
||||
public UserHomeDataVo getUserHomeData(Long userId, Long shopId) {
|
||||
UserHomeDataVo userHomeDataVo = new UserHomeDataVo()
|
||||
.setShopId(shopId)
|
||||
.setUserId(userId)
|
||||
.setGroup(0)
|
||||
.setTakeout(0);
|
||||
|
||||
// 用户信息
|
||||
UserInfoDTO info = userInfoService.getInfo(userId);
|
||||
if (info != null) {
|
||||
userHomeDataVo
|
||||
.setUserNickname(info.getNickName())
|
||||
.setUserAvatar(info.getHeadImg());
|
||||
}
|
||||
|
||||
// 积分商城
|
||||
MkPointsConfig pointsConfig = mkPointsConfigService.getById(shopId);
|
||||
if (pointsConfig != null) {
|
||||
userHomeDataVo.setPointsMall(pointsConfig.getEnablePointsMall());
|
||||
}
|
||||
|
||||
// 分销
|
||||
MkDistributionConfigVO distributionConfig = mkDistributionConfigService.detail(shopId);
|
||||
if (distributionConfig != null) {
|
||||
userHomeDataVo.setDistribution(distributionConfig.getIsEnable());
|
||||
}
|
||||
|
||||
// 积分
|
||||
MkPointsUser pointsUser = mkPointsUserService.getPointsUser(shopId, null, userId);
|
||||
if (pointsUser != null) {
|
||||
userHomeDataVo.setPointNum(pointsUser.getPointBalance());
|
||||
}
|
||||
|
||||
// 优惠券
|
||||
Page<UserCouponVO> coupon = couponService.find(userId, "", shopId, 0);
|
||||
userHomeDataVo.setCouponNum(coupon.getTotalRow());
|
||||
|
||||
return userHomeDataVo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user