|
|
@@ -0,0 +1,68 @@
|
|
|
+package com.cyksj.service.vip.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
+import com.cyksj.mapper.sys.SysConfigMapper;
|
|
|
+import com.cyksj.mapper.vip.VipGoodsSkuMapper;
|
|
|
+import com.cyksj.model.entity.SysConfig;
|
|
|
+import com.cyksj.model.entity.VipGoodsSku;
|
|
|
+import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
+import com.cyksj.model.response.VipUserPageResp;
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
+import com.cyksj.service.vip.VipFrontService;
|
|
|
+import com.ejlchina.searcher.BeanSearcher;
|
|
|
+import com.ejlchina.searcher.param.Operator;
|
|
|
+import com.ejlchina.searcher.util.MapUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 项目名: yhlxj2
|
|
|
+ * 文件名: VipFrontServiceImpl
|
|
|
+ * 创建者: JavaZou
|
|
|
+ * 创建时间:2025/5/15 16:00
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class VipFrontServiceImpl implements VipFrontService {
|
|
|
+ private final SysConfigMapper sysConfigMapper;
|
|
|
+
|
|
|
+ private final VipGoodsSkuMapper vipGoodsSkuMapper;
|
|
|
+
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
+
|
|
|
+ private final BeanSearcher beanSearcher;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void fillVipInfo(long userId, VipUserPageResp vipUserPageResp) {
|
|
|
+ SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
+ .eq(SysConfig::getSysKey, Constant.VIP_FEE_KEY)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (sysConfig != null && StrUtil.isNotBlank(sysConfig.getSysValue())) {
|
|
|
+ vipUserPageResp.setVipFee(BigDecimal.valueOf(Integer.parseInt(sysConfig.getSysValue())));
|
|
|
+ }
|
|
|
+ //可抵扣价格
|
|
|
+ BigDecimal deductMoney = BigDecimal.ZERO;
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ List<Long> vipSkuIds = vipGoodsSkuMapper.selectList(null).stream().map(VipGoodsSku::getSkuId).collect(Collectors.toList());
|
|
|
+ //可有抵扣车票
|
|
|
+ Number count = beanSearcher.searchCount(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ .field(GroupsRelationView::getUserId, userIdList).op(Operator.InList)
|
|
|
+ .field(GroupsRelationView::getSkuId, vipSkuIds).op(Operator.InList)
|
|
|
+ .field(GroupsRelationView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
|
|
|
+ .build());
|
|
|
+ //可抵扣车票
|
|
|
+ if (count.intValue() > 0) {
|
|
|
+ for (Long vipSkuId : vipSkuIds) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vipUserPageResp.setDeductMoney(deductMoney);
|
|
|
+ }
|
|
|
+}
|