|
@@ -3,10 +3,13 @@ package com.example.xiaoshiweixinback.service;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
|
-import com.example.xiaoshiweixinback.domain.Vip;
|
|
|
+import com.example.xiaoshiweixinback.domain.*;
|
|
|
import com.example.xiaoshiweixinback.mapper.VipMapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -16,9 +19,19 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private OrderService orderService;
|
|
|
+ @Autowired
|
|
|
+ private AssoVipFunctionService assoVipFunctionService;
|
|
|
+ @Autowired
|
|
|
+ private AssoPersonVipService assoPersonVipService;
|
|
|
+ @Autowired
|
|
|
+ private AssoPersonFunctionService assoPersonFunctionService;
|
|
|
|
|
|
/**
|
|
|
* 查询会员
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public Records getAllVip() {
|
|
@@ -30,11 +43,34 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
- public void getVip(){
|
|
|
-
|
|
|
+ public Vip getVipByUuId(String uuid) {
|
|
|
+ LambdaQueryWrapper<Vip> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(Vip::getVipUuId, uuid);
|
|
|
+ Vip vip = this.getOne(queryWrapper);
|
|
|
+ return vip;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ public void activateVIP(String tradeNo) {
|
|
|
+ Order order = orderService.getOrderByTradeNo(tradeNo);
|
|
|
+ String uuid = order.getGoodUuid();
|
|
|
+ String personUuId = order.getPersonUuid();
|
|
|
+ Vip vip = this.getVipByUuId(uuid);
|
|
|
+ AssoPersonVip assoPersonVip = assoPersonVipService.addAssoPersonVip(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());
|
|
|
+ assoPersonFunctions.add(assoPersonFunction);
|
|
|
+ });
|
|
|
+ assoPersonFunctionService.saveBatch(assoPersonFunctions);
|
|
|
}
|
|
|
}
|
|
|
|