|
@@ -16,6 +16,7 @@ import com.example.xiaoshiweixinback.entity.weixinPay.VipRightsDTO;
|
|
import com.example.xiaoshiweixinback.entity.weixinPay.VipRightsVO;
|
|
import com.example.xiaoshiweixinback.entity.weixinPay.VipRightsVO;
|
|
import com.example.xiaoshiweixinback.mapper.VipMapper;
|
|
import com.example.xiaoshiweixinback.mapper.VipMapper;
|
|
import jakarta.json.JsonObject;
|
|
import jakarta.json.JsonObject;
|
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
import org.eclipse.parsson.JsonUtil;
|
|
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;
|
|
@@ -47,6 +48,8 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
private SysFunctionService sysFunctionService;
|
|
private SysFunctionService sysFunctionService;
|
|
@Autowired
|
|
@Autowired
|
|
private CacheUtil cacheUtil;
|
|
private CacheUtil cacheUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private InviteMessageService inviteMessageService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询会员
|
|
* 查询会员
|
|
@@ -56,7 +59,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, Vip::getFinalPrice);
|
|
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);
|
|
@@ -70,28 +73,30 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
return vip;
|
|
return vip;
|
|
}
|
|
}
|
|
|
|
|
|
- public void activateVIP(Order order) {
|
|
|
|
|
|
+ public void activateVIP(Order order, String uuid) {
|
|
String tradeNo = order.getTradeNo();
|
|
String tradeNo = order.getTradeNo();
|
|
- 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.getAsso(personUuId, vip);
|
|
AssoPersonVip assoPersonVip = assoPersonVipService.getAsso(personUuId, vip);
|
|
- //查询vip相关权益
|
|
|
|
- List<AssoVipFunction> assoVipFunctions = assoVipFunctionService.getVipFunctionByVipUuid(uuid);
|
|
|
|
- //将权益赋值给人员
|
|
|
|
- List<AssoPersonFunction> assoPersonFunctions = new ArrayList<>();
|
|
|
|
- assoVipFunctions.forEach(item -> {
|
|
|
|
- AssoPersonFunction assoPersonFunction = new AssoPersonFunction();
|
|
|
|
- assoPersonFunction.setFunctionUuid(item.getFunctionUuid());
|
|
|
|
- assoPersonFunction.setExpiryTime(assoPersonVip.getExpiryTime());
|
|
|
|
- assoPersonFunction.setCreateTime(assoPersonVip.getCreateTime());
|
|
|
|
- assoPersonFunction.setFunctionParameter(item.getFunctionParameter());
|
|
|
|
- assoPersonFunction.setVipType(vip.getVipType());
|
|
|
|
- assoPersonFunction.setVipUuid(vip.getVipUuid());
|
|
|
|
- assoPersonFunction.setPersonUuid(personUuId);
|
|
|
|
- assoPersonFunctions.add(assoPersonFunction);
|
|
|
|
- });
|
|
|
|
- assoPersonFunctionService.saveBatch(assoPersonFunctions);
|
|
|
|
|
|
+ // //查询vip相关权益
|
|
|
|
+ // List<AssoVipFunction> assoVipFunctions = assoVipFunctionService.getVipFunctionByVipUuid(uuid);
|
|
|
|
+// //将权益赋值给人员
|
|
|
|
+// List<AssoPersonFunction> assoPersonFunctions = new ArrayList<>();
|
|
|
|
+// assoVipFunctions.forEach(item -> {
|
|
|
|
+// AssoPersonFunction assoPersonFunction = new AssoPersonFunction();
|
|
|
|
+// assoPersonFunction.setFunctionUuid(item.getFunctionUuid());
|
|
|
|
+// assoPersonFunction.setExpiryTime(assoPersonVip.getExpiryTime());
|
|
|
|
+// assoPersonFunction.setCreateTime(assoPersonVip.getCreateTime());
|
|
|
|
+// assoPersonFunction.setFunctionParameter(item.getFunctionParameter());
|
|
|
|
+// assoPersonFunction.setVipType(vip.getVipType());
|
|
|
|
+// assoPersonFunction.setVipUuid(vip.getVipUuid());
|
|
|
|
+// assoPersonFunction.setPersonUuid(personUuId);
|
|
|
|
+// assoPersonFunctions.add(assoPersonFunction);
|
|
|
|
+// });
|
|
|
|
+// assoPersonFunctionService.saveBatch(assoPersonFunctions);
|
|
|
|
+
|
|
|
|
+ //添加优惠券
|
|
|
|
+ inviteMessageService.getInviteGiveVoucher(personUuId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -110,6 +115,7 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
FunctionConfig functionConfig = JSON.parseObject(parameter, FunctionConfig.class);
|
|
FunctionConfig functionConfig = JSON.parseObject(parameter, FunctionConfig.class);
|
|
String description = this.replaceDescription(sysFunction.getDescription(), functionConfig);
|
|
String description = this.replaceDescription(sysFunction.getDescription(), functionConfig);
|
|
item.setDescription(description);
|
|
item.setDescription(description);
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
FunctionRightVO functionRightVO = new FunctionRightVO();
|
|
FunctionRightVO functionRightVO = new FunctionRightVO();
|
|
@@ -140,10 +146,10 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
}
|
|
}
|
|
|
|
|
|
public List<PersonFunctionVO> getPersonRights() {
|
|
public List<PersonFunctionVO> getPersonRights() {
|
|
-
|
|
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
-
|
|
|
|
- List<PersonFunctionVO> personFunctionVOS = assoPersonFunctionService.getBaseMapper().getByPerson(personnelVO.getUuid(), null);
|
|
|
|
|
|
+ String personUuid = personnelVO.getUuid();
|
|
|
|
+ List<PersonFunctionVO> personFunctionVOS = this.getVipFunctions(personUuid);
|
|
|
|
+ // 查询登录人的vip
|
|
personFunctionVOS.forEach(item ->
|
|
personFunctionVOS.forEach(item ->
|
|
{
|
|
{
|
|
String parameter = item.getFunctionParameter();
|
|
String parameter = item.getFunctionParameter();
|
|
@@ -204,6 +210,7 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
return vip;
|
|
return vip;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
public AssoPersonFunction getAssoPersonFunction(String functionUuid) {
|
|
public AssoPersonFunction getAssoPersonFunction(String functionUuid) {
|
|
AssoPersonFunction assoPersonFunction = null;
|
|
AssoPersonFunction assoPersonFunction = null;
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
@@ -218,12 +225,59 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public Vip getDefaultVip( ) {
|
|
|
|
|
|
+ public Vip getDefaultVip() {
|
|
LambdaQueryWrapper<Vip> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Vip> queryWrapper = new LambdaQueryWrapper<>();
|
|
queryWrapper.eq(Vip::getVipType, 0);
|
|
queryWrapper.eq(Vip::getVipType, 0);
|
|
- Vip vip = this.getOne(queryWrapper,false);
|
|
|
|
|
|
+ Vip vip = this.getOne(queryWrapper, false);
|
|
return vip;
|
|
return vip;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public AssoVipFunction getVipFunctionMessage(String functionUuid) {
|
|
|
|
+
|
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+ //查询当前用户的会员
|
|
|
|
+ LambdaQueryWrapper<AssoPersonVip> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.gt(AssoPersonVip::getExpiryTime, new Date())
|
|
|
|
+ .eq(AssoPersonVip::getPersonUuid, personnelVO.getUuid());
|
|
|
|
+ AssoPersonVip assoPersonVip = assoPersonVipService.getOne(queryWrapper, false);
|
|
|
|
+ Integer vipType = null;
|
|
|
|
+ if (assoPersonVip == null) {
|
|
|
|
+ vipType = 0;
|
|
|
|
+ } else {
|
|
|
|
+ vipType = assoPersonVip.getVipType();
|
|
|
|
+ }
|
|
|
|
+ //根据vipType和functionUuid查询
|
|
|
|
+ LambdaQueryWrapper<AssoVipFunction> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper1.eq(AssoVipFunction::getVipType, vipType)
|
|
|
|
+ .eq(AssoVipFunction::getFunctionUuid, functionUuid);
|
|
|
|
+ AssoVipFunction assoVipFunction = assoVipFunctionService.getOne(queryWrapper1);
|
|
|
|
+ return assoVipFunction;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public List<PersonFunctionVO> getVipFunctions(String personUuid) {
|
|
|
|
+ Integer vipType = this.getVipTypes(personUuid);
|
|
|
|
+ List<PersonFunctionVO> personFunctionVOS = assoVipFunctionService.getBaseMapper().getVipFunction(vipType);
|
|
|
|
+ return personFunctionVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Integer getVipTypes(String personUuid) {
|
|
|
|
+ LambdaQueryWrapper<AssoPersonVip> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.gt(AssoPersonVip::getExpiryTime, new Date())
|
|
|
|
+ .eq(AssoPersonVip::getPersonUuid, personUuid);
|
|
|
|
+ AssoPersonVip assoPersonVip = assoPersonVipService.getOne(queryWrapper, false);
|
|
|
|
+ Integer vipType = null;
|
|
|
|
+ if (assoPersonVip == null) {
|
|
|
|
+ vipType = 0;
|
|
|
|
+ } else {
|
|
|
|
+ vipType = assoPersonVip.getVipType();
|
|
|
|
+ }
|
|
|
|
+ return vipType;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|