|
@@ -1,17 +1,30 @@
|
|
package com.example.xiaoshiweixinback.service;
|
|
package com.example.xiaoshiweixinback.service;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
|
|
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
|
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
import com.example.xiaoshiweixinback.domain.*;
|
|
import com.example.xiaoshiweixinback.domain.*;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.sysFuctionRights.FunctionConfig;
|
|
import com.example.xiaoshiweixinback.entity.vip.ActiveVipDTO;
|
|
import com.example.xiaoshiweixinback.entity.vip.ActiveVipDTO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.vip.PersonFunctionVO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.weixinPay.FunctionRightVO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.weixinPay.VipRightsDTO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.weixinPay.VipRightsVO;
|
|
import com.example.xiaoshiweixinback.mapper.VipMapper;
|
|
import com.example.xiaoshiweixinback.mapper.VipMapper;
|
|
|
|
+import jakarta.json.JsonObject;
|
|
|
|
+import org.eclipse.parsson.JsonUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author admin
|
|
* @author admin
|
|
@@ -29,6 +42,10 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
private AssoPersonVipService assoPersonVipService;
|
|
private AssoPersonVipService assoPersonVipService;
|
|
@Autowired
|
|
@Autowired
|
|
private AssoPersonFunctionService assoPersonFunctionService;
|
|
private AssoPersonFunctionService assoPersonFunctionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysFunctionService sysFunctionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CacheUtil cacheUtil;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询会员
|
|
* 查询会员
|
|
@@ -38,7 +55,7 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
public Records getAllVip() {
|
|
public Records getAllVip() {
|
|
Records records = new Records();
|
|
Records records = new Records();
|
|
LambdaQueryWrapper<Vip> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Vip> queryWrapper = new LambdaQueryWrapper<>();
|
|
- queryWrapper.select(Vip::getPrice,Vip::getVipUuid,Vip::getName,Vip::getConfigParameter);
|
|
|
|
|
|
+ queryWrapper.select(Vip::getPrice, Vip::getVipUuid, Vip::getName, Vip::getConfigParameter);
|
|
queryWrapper.ne(Vip::getVipType, 0);
|
|
queryWrapper.ne(Vip::getVipType, 0);
|
|
List<Vip> vipList = this.list(queryWrapper);
|
|
List<Vip> vipList = this.list(queryWrapper);
|
|
records.setData(vipList);
|
|
records.setData(vipList);
|
|
@@ -50,17 +67,14 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
queryWrapper.eq(Vip::getVipUuid, uuid);
|
|
queryWrapper.eq(Vip::getVipUuid, uuid);
|
|
Vip vip = this.getOne(queryWrapper);
|
|
Vip vip = this.getOne(queryWrapper);
|
|
return vip;
|
|
return vip;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- public void activateVIP(ActiveVipDTO activeVipDTO) {
|
|
|
|
- String tradeNo = activeVipDTO.getTradeNo();
|
|
|
|
- Order order = orderService.getOrderByTradeNo(tradeNo);
|
|
|
|
|
|
+ public void activateVIP(Order order) {
|
|
|
|
+ String tradeNo = order.getTradeNo();
|
|
String uuid = order.getGoodUuid();
|
|
String uuid = order.getGoodUuid();
|
|
String personUuId = order.getPersonUuid();
|
|
String personUuId = order.getPersonUuid();
|
|
Vip vip = this.getVipByUuId(uuid);
|
|
Vip vip = this.getVipByUuId(uuid);
|
|
- AssoPersonVip assoPersonVip = assoPersonVipService.addAssoPersonVip(personUuId, vip);
|
|
|
|
|
|
+ AssoPersonVip assoPersonVip = assoPersonVipService.getAsso(personUuId, vip);
|
|
//查询vip相关权益
|
|
//查询vip相关权益
|
|
List<AssoVipFunction> assoVipFunctions = assoVipFunctionService.getVipFunctionByVipUuid(uuid);
|
|
List<AssoVipFunction> assoVipFunctions = assoVipFunctionService.getVipFunctionByVipUuid(uuid);
|
|
//将权益赋值给人员
|
|
//将权益赋值给人员
|
|
@@ -71,10 +85,134 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
assoPersonFunction.setExpiryTime(assoPersonVip.getExpiryTime());
|
|
assoPersonFunction.setExpiryTime(assoPersonVip.getExpiryTime());
|
|
assoPersonFunction.setCreateTime(assoPersonVip.getCreateTime());
|
|
assoPersonFunction.setCreateTime(assoPersonVip.getCreateTime());
|
|
assoPersonFunction.setFunctionParameter(item.getFunctionParameter());
|
|
assoPersonFunction.setFunctionParameter(item.getFunctionParameter());
|
|
|
|
+ assoPersonFunction.setPersonUuid(personUuId);
|
|
assoPersonFunctions.add(assoPersonFunction);
|
|
assoPersonFunctions.add(assoPersonFunction);
|
|
});
|
|
});
|
|
assoPersonFunctionService.saveBatch(assoPersonFunctions);
|
|
assoPersonFunctionService.saveBatch(assoPersonFunctions);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public List<FunctionRightVO> getVipRights() {
|
|
|
|
+
|
|
|
|
+ List<FunctionRightVO> functionRightVOS = new ArrayList<>();
|
|
|
|
+ //查询所有功能
|
|
|
|
+ List<SysFunction> sysFunctions = sysFunctionService.getAllFunction();
|
|
|
|
+ //查询功能和vip的关联
|
|
|
|
+ List<VipRightsVO> vipRightsVOS = assoVipFunctionService.getBaseMapper().getAll();
|
|
|
|
+ //装载
|
|
|
|
+ for (SysFunction sysFunction : sysFunctions) {
|
|
|
|
+ List<VipRightsVO> temAssoes = vipRightsVOS.stream().filter(item -> item.getFunctionUuid().equals(sysFunction.getUuid())).collect(Collectors.toList());
|
|
|
|
+ temAssoes.forEach(item -> {
|
|
|
|
+ String parameter = item.getFunctionParameter();
|
|
|
|
+ FunctionConfig functionConfig = JSON.parseObject(parameter, FunctionConfig.class);
|
|
|
|
+ String description = this.replaceDescription(sysFunction.getDescription(), functionConfig);
|
|
|
|
+ item.setDescription(description);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ FunctionRightVO functionRightVO = new FunctionRightVO();
|
|
|
|
+ functionRightVO.setFunctionName(sysFunction.getName());
|
|
|
|
+ functionRightVO.setVipRightsVOList(temAssoes);
|
|
|
|
+ functionRightVOS.add(functionRightVO);
|
|
|
|
+ }
|
|
|
|
+ return functionRightVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String replaceDescription(String description, FunctionConfig functionConfig) {
|
|
|
|
+ if (functionConfig.getSize() != null && functionConfig.getSize() != -1) {
|
|
|
|
+
|
|
|
|
+ description = description.replace("size", functionConfig.getSize().toString());
|
|
|
|
+ } else {
|
|
|
|
+ description = description.replace("size", "无限");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (functionConfig.getCanGetNum() != null && functionConfig.getCanGetNum() != -1) {
|
|
|
|
+
|
|
|
|
+ description = description.replace("canGetNum", functionConfig.getCanGetNum().toString());
|
|
|
|
+ } else {
|
|
|
|
+ description = description.replace("canGetNum", "无限");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return description;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<PersonFunctionVO> getPersonRights() {
|
|
|
|
+
|
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+
|
|
|
|
+ List<PersonFunctionVO> personFunctionVOS = assoPersonFunctionService.getBaseMapper().getByPerson(personnelVO.getUuid(), null);
|
|
|
|
+ personFunctionVOS.forEach(item ->
|
|
|
|
+ {
|
|
|
|
+ String parameter = item.getFunctionParameter();
|
|
|
|
+ FunctionConfig functionConfig = JSON.parseObject(parameter, FunctionConfig.class);
|
|
|
|
+ String description = this.replaceDescription(item.getDescription(), functionConfig);
|
|
|
|
+ item.setDescription(description);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return personFunctionVOS;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Vip getPersonVip() {
|
|
|
|
+ Vip vip = null;
|
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ LambdaQueryWrapper<AssoPersonVip> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(AssoPersonVip::getPersonUuid, personnelVO.getUuid())
|
|
|
|
+ .gt(AssoPersonVip::getExpiryTime, date)
|
|
|
|
+ .orderByDesc(AssoPersonVip::getExpiryTime);
|
|
|
|
+ List<AssoPersonVip> assoPersonVips = assoPersonVipService.list(queryWrapper);
|
|
|
|
+ List<String> personVipUUids = assoPersonVips.stream().map(AssoPersonVip::getVipUuid).collect(Collectors.toList());
|
|
|
|
+ ;
|
|
|
|
+ if (personVipUUids.size() != 0) {
|
|
|
|
+ LambdaQueryWrapper<Vip> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper1.in(Vip::getVipUuid, personVipUUids);
|
|
|
|
+ queryWrapper1.orderByDesc(Vip::getVipType);
|
|
|
|
+ vip = this.getOne(queryWrapper1, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return vip;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public Vip getLastHighVip() {
|
|
|
|
+ Vip vip = null;
|
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ LambdaQueryWrapper<AssoPersonVip> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(AssoPersonVip::getPersonUuid, personnelVO.getUuid())
|
|
|
|
+ .gt(AssoPersonVip::getExpiryTime, date)
|
|
|
|
+ .orderByDesc(AssoPersonVip::getExpiryTime);
|
|
|
|
+ List<AssoPersonVip> assoPersonVips = assoPersonVipService.list(queryWrapper);
|
|
|
|
+ List<String> personVipUUids = assoPersonVips.stream().map(AssoPersonVip::getVipUuid).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (personVipUUids.size() != 0) {
|
|
|
|
+ LambdaQueryWrapper<Vip> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper1.in(Vip::getVipUuid, personVipUUids);
|
|
|
|
+ queryWrapper1.orderByDesc(Vip::getVipType);
|
|
|
|
+ vip = this.getOne(queryWrapper1, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return vip;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public AssoPersonFunction getAssoPersonFunction(String functionUuid) {
|
|
|
|
+ AssoPersonFunction assoPersonFunction = null;
|
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+
|
|
|
|
+ List<PersonFunctionVO> personFunctionVOS = assoPersonFunctionService.getBaseMapper().getByPerson(personnelVO.getUuid(), functionUuid);
|
|
|
|
+ if (personFunctionVOS != null && personFunctionVOS.size() > 0) {
|
|
|
|
+ Integer id = personFunctionVOS.get(0).getId();
|
|
|
|
+ assoPersonFunction = assoPersonFunctionService.getById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return assoPersonFunction;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|