新客立减相关
This commit is contained in:
@@ -27,4 +27,5 @@ public class ShopUserDTO extends ShopUser {
|
||||
private String memberLevelName;
|
||||
private String nextMemberLevelName;
|
||||
private Long nextExperience;
|
||||
private boolean isNew;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.czg.market.service;
|
||||
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.market.vo.MkConsumeDiscountVO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||
@@ -37,4 +38,6 @@ public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsu
|
||||
* @param amount 减免金额
|
||||
*/
|
||||
void useDiscount(Long shopUserId, Long orderId, BigDecimal amount);
|
||||
|
||||
boolean isNewUser(ShopUser shopUser, Long shopId);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.czg.market.entity.MemberLevelConfig;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.entity.SmsPushEventUser;
|
||||
import com.czg.market.service.MemberLevelConfigService;
|
||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.TbMemberConfigService;
|
||||
import com.czg.market.vo.MemberConfigVO;
|
||||
@@ -67,6 +68,8 @@ public class AShopUserServiceImpl implements AShopUserService {
|
||||
private MemberLevelConfigService memberLevelConfigService;
|
||||
@DubboReference
|
||||
private TbMemberConfigService memberConfigService;
|
||||
@DubboReference
|
||||
private MkShopConsumeDiscountRecordService consumeDiscountService;
|
||||
|
||||
private ShopUser getUserInfo(Long shopUserId) {
|
||||
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one();
|
||||
@@ -93,7 +96,11 @@ public class AShopUserServiceImpl implements AShopUserService {
|
||||
public Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount) {
|
||||
Long mainIdByShopId = shopInfoService.getMainIdByShopId(StpKit.USER.getShopId());
|
||||
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
return PageUtil.convert(new PageInfo<>(shopUserMapper.selectPageByKeyAndIsVip(mainIdByShopId, isVip, key, amount)));
|
||||
PageInfo<ShopUserDTO> shopUserDTOPageInfo = new PageInfo<>(shopUserMapper.selectPageByKeyAndIsVip(mainIdByShopId, isVip, key, amount));
|
||||
shopUserDTOPageInfo.getList().forEach(item -> {
|
||||
item.setNew(consumeDiscountService.isNewUser(item, StpKit.USER.getShopId()));
|
||||
});
|
||||
return PageUtil.convert(shopUserDTOPageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.auth.v1alpha1.Ca;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -35,7 +36,7 @@ import java.util.Random;
|
||||
* @since 2025-09-17
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DubboService
|
||||
public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopConsumeDiscountRecordMapper, MkShopConsumeDiscountRecord> implements MkShopConsumeDiscountRecordService {
|
||||
@Resource
|
||||
private MkConsumeDiscountService consumeDiscountService;
|
||||
@@ -101,9 +102,25 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
AssertUtil.isTrue(!flag, "修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewUser(ShopUser shopUser, Long shopId) {
|
||||
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
||||
.eq(MkShopConsumeDiscountRecord::getIsUse, 1)
|
||||
.eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId()));
|
||||
boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
|
||||
return !exists && discountRecord == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getSourceShopId, shopId));
|
||||
boolean newUser = isNewUser(shopUser, shopId);
|
||||
if (!newUser) {
|
||||
// throw new ApiNotPrintException("新客立减仅新用户可用");
|
||||
log.info("新客立减仅限新用户使用");
|
||||
return null;
|
||||
}
|
||||
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
||||
.eq(MkShopConsumeDiscountRecord::getOrderId, orderId)
|
||||
.eq(MkShopConsumeDiscountRecord::getIsUse, 0)
|
||||
@@ -115,13 +132,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
}
|
||||
return discountRecord;
|
||||
}
|
||||
boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
|
||||
if (exists) {
|
||||
// throw new ApiNotPrintException("新客立减仅新用户可用");
|
||||
log.info("新客立减仅限新用户使用");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
MkConsumeDiscountVO consumeDiscountVO = canUse(shopId, userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user