会员 条件开通
This commit is contained in:
@@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.CzgPayUtils;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.CzgBaseRespParams;
|
||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||
@@ -38,10 +37,6 @@ import java.io.IOException;
|
||||
@RequestMapping("/notify")
|
||||
public class NotifyController {
|
||||
private static final String SUCCESS = "SUCCESS";
|
||||
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MemberConfigDTO;
|
||||
import com.czg.market.dto.MemberLevelDTO;
|
||||
@@ -411,16 +412,19 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
boolean canOpen = switch (item.getCode()) {
|
||||
case "BIND_PHONE" -> StrUtil.isNotBlank(shopUser.getPhone());
|
||||
case "ORDER" ->
|
||||
orderInfoService.count(new QueryWrapper().eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
orderInfoService.count(query().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.notIn(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode(), OrderStatusEnums.CANCELLED.getCode())) >= Integer.parseInt(item.getValue());
|
||||
case "COST_AMOUNT" ->
|
||||
orderInfoService.list(new QueryWrapper().eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.notIn(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode(), OrderStatusEnums.CANCELLED.getCode()))
|
||||
.stream().map(OrderInfo::getPayAmount).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
case "RECHARGE_AMOUNT" ->
|
||||
paymentService.list(new QueryWrapper().eq(OrderPayment::getShopId, shopUser.getSourceShopId())
|
||||
.eq(OrderPayment::getSourceId, shopUser.getId()).isNotNull(OrderPayment::getTradeNumber))
|
||||
.stream().map(OrderPayment::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
orderInfoService.getOneAs(query().select("sum(pay_amount)").eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.notIn(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode(), OrderStatusEnums.CANCELLED.getCode()), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
case "RECHARGE_AMOUNT" -> paymentService.getOneAs(query().select("sum(amount)")
|
||||
.eq(OrderPayment::getShopId, shopId)
|
||||
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
|
||||
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
|
||||
.eq(OrderPayment::getSourceId, shopUser.getId())
|
||||
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
default -> throw new CzgException("会员开通条件类型错误");
|
||||
};
|
||||
if (!canOpen) {
|
||||
@@ -431,10 +435,12 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
ShopUser upShopUser = new ShopUser();
|
||||
upShopUser.setId(shopUser.getId());
|
||||
upShopUser.setMemberLevelId(levelConfig.getId());
|
||||
upShopUser.setStartTime(DateUtil.date().toLocalDateTime());
|
||||
|
||||
upShopUser.setStartTime(LocalDateTime.now());
|
||||
upShopUser.setEndTime(shopUser.getStartTime().plusDays(20000));
|
||||
upShopUser.setIsVip(1);
|
||||
if (shopUser.getJoinTime() != null) {
|
||||
upShopUser.setJoinTime(LocalDateTime.now());
|
||||
}
|
||||
upShopUser.setOpenType("CONDITION");
|
||||
return shopUserService.updateById(upShopUser);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user