vip购买相关
This commit is contained in:
@@ -54,11 +54,11 @@ public class UserVipController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VipBuyConfigDao vipBuyConfigDao;
|
private VipBuyConfigDao vipBuyConfigDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private UserVipDao userVipDao;
|
||||||
|
@Autowired
|
||||||
private TransactionDetailsService transactionDetailsService;
|
private TransactionDetailsService transactionDetailsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JfTransactionDetailsDao jfTransactionDetailsDao;
|
private JfTransactionDetailsDao jfTransactionDetailsDao;
|
||||||
@Autowired
|
|
||||||
private UserVipDao userVipDao;
|
|
||||||
|
|
||||||
@RequestMapping("/getMyVipHistory")
|
@RequestMapping("/getMyVipHistory")
|
||||||
public R getMyVipHistory(String userId) {
|
public R getMyVipHistory(String userId) {
|
||||||
@@ -70,6 +70,7 @@ public class UserVipController {
|
|||||||
return R.ok().put("result", userVips);
|
return R.ok().put("result", userVips);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/placeVipOrder")
|
||||||
@Transactional
|
@Transactional
|
||||||
public R placeVipOrder(@RequestBody BuyOrder buyOrder) throws Exception {
|
public R placeVipOrder(@RequestBody BuyOrder buyOrder) throws Exception {
|
||||||
int uid = ShiroUtils.getUId();
|
int uid = ShiroUtils.getUId();
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.Period;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -61,6 +63,12 @@ public class AliPayServiceImpl implements AliPayService {
|
|||||||
private UserCourseBuyDao userCourseBuyDao;
|
private UserCourseBuyDao userCourseBuyDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JfTransactionDetailsDao jfTransactionDetailsDao;
|
private JfTransactionDetailsDao jfTransactionDetailsDao;
|
||||||
|
@Autowired
|
||||||
|
private MyUserDao myUserDao;
|
||||||
|
@Autowired
|
||||||
|
private VipBuyConfigDao vipBuyConfigDao;
|
||||||
|
@Autowired
|
||||||
|
private UserVipDao userVipDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String pay(AlipayDTO payDto) {
|
public String pay(AlipayDTO payDto) {
|
||||||
@@ -147,16 +155,29 @@ public class AliPayServiceImpl implements AliPayService {
|
|||||||
String customerid = oldPayZfbOrderEntity.getCustomerid();
|
String customerid = oldPayZfbOrderEntity.getCustomerid();
|
||||||
|
|
||||||
if ("vip".equals(subject)) {
|
if ("vip".equals(subject)) {
|
||||||
//获取会员开通 日期
|
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", oldPayZfbOrderEntity.getRelevanceoid()));
|
||||||
|
//更新 订单 记录
|
||||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(Integer.valueOf(body));
|
|
||||||
String month = bookBuyConfigEntity.getMonth();
|
|
||||||
userService.openMember(Integer.valueOf(customerid),Integer.valueOf(month));
|
|
||||||
|
|
||||||
// 插入 开通记录
|
|
||||||
|
|
||||||
buyOrderService.updateOrderStatus(Integer.valueOf(customerid),oldPayZfbOrderEntity.getRelevanceoid(),"2");
|
buyOrderService.updateOrderStatus(Integer.valueOf(customerid),oldPayZfbOrderEntity.getRelevanceoid(),"2");
|
||||||
|
|
||||||
|
//处理抵扣积分
|
||||||
|
if(orderEntity.getJfDeduction().compareTo(BigDecimal.ZERO)>0){
|
||||||
|
userCoinJf(orderEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
//开通vip
|
||||||
|
openVipForUser(orderEntity);
|
||||||
|
|
||||||
|
//获取会员开通 日期
|
||||||
|
|
||||||
|
// BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(Integer.valueOf(body));
|
||||||
|
// String month = bookBuyConfigEntity.getMonth();
|
||||||
|
// userService.openMember(Integer.valueOf(customerid),Integer.valueOf(month));
|
||||||
|
//
|
||||||
|
// // 插入 开通记录
|
||||||
|
//
|
||||||
|
// buyOrderService.updateOrderStatus(Integer.valueOf(customerid),oldPayZfbOrderEntity.getRelevanceoid(),"2");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -300,6 +321,93 @@ public class AliPayServiceImpl implements AliPayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openVipForUser(BuyOrder buyOrder) throws Exception {
|
||||||
|
VipBuyConfigEntity vipBuyConfigEntity = vipBuyConfigDao.selectById(buyOrder.getVipBuyConfigId());
|
||||||
|
MyUserEntity userEntity = myUserDao.selectById(buyOrder.getUserId());
|
||||||
|
if(vipBuyConfigEntity.getType()==1){//超v
|
||||||
|
if(userEntity.getVip().equals("0")){//初次办理
|
||||||
|
UserVip userVip = new UserVip();
|
||||||
|
userVip.setUserId(userEntity.getId());
|
||||||
|
userVip.setType(1);
|
||||||
|
userVip.setStartTime(new Date());
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||||
|
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||||
|
userVip.setEndTime(threeYearsDate);
|
||||||
|
userVipDao.insert(userVip);
|
||||||
|
userEntity.setVip("1");
|
||||||
|
myUserDao.updateById(userEntity);
|
||||||
|
}
|
||||||
|
if(userEntity.getVip().equals("1")){//vip延期
|
||||||
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
|
if(userVips.size()!=1){
|
||||||
|
throwExceptionMethod();
|
||||||
|
}
|
||||||
|
UserVip userVip = userVips.get(0);
|
||||||
|
Date endTime = userVip.getEndTime();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(endTime);
|
||||||
|
calendar.add(Calendar.YEAR,vipBuyConfigEntity.getYear());
|
||||||
|
userVip.setEndTime(calendar.getTime());
|
||||||
|
userVipDao.updateById(userVip);
|
||||||
|
}
|
||||||
|
if (userEntity.getVip().equals("2")||userEntity.getVip().equals("3")){//医学vip或国学vip升级
|
||||||
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
|
if(userVips.size()!=1){
|
||||||
|
throwExceptionMethod();
|
||||||
|
}
|
||||||
|
UserVip userVip1 = userVips.get(0);
|
||||||
|
userVip1.setEndTime(new Date());
|
||||||
|
userVip1.setState(1);
|
||||||
|
userVipDao.updateById(userVip1);
|
||||||
|
UserVip userVip = new UserVip();
|
||||||
|
userVip.setUserId(userEntity.getId());
|
||||||
|
userVip.setType(1);
|
||||||
|
userVip.setStartTime(new Date());
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||||
|
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||||
|
userVip.setEndTime(threeYearsDate);
|
||||||
|
userVipDao.insert(userVip);
|
||||||
|
userEntity.setVip("1");
|
||||||
|
myUserDao.updateById(userEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(vipBuyConfigEntity.getType()==2||vipBuyConfigEntity.getType()==3){//医学vip或国学vip
|
||||||
|
if(userEntity.getVip().equals("2")||userEntity.getVip().equals("3")){//续费
|
||||||
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
|
if(userVips.size()!=1){
|
||||||
|
throwExceptionMethod();
|
||||||
|
}
|
||||||
|
UserVip userVip = userVips.get(0);
|
||||||
|
Date endTime = userVip.getEndTime();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(endTime);
|
||||||
|
calendar.add(Calendar.YEAR,vipBuyConfigEntity.getYear());
|
||||||
|
userVip.setEndTime(calendar.getTime());
|
||||||
|
userVipDao.updateById(userVip);
|
||||||
|
}else{//新办理
|
||||||
|
UserVip userVip = new UserVip();
|
||||||
|
userVip.setUserId(userEntity.getId());
|
||||||
|
userVip.setType(vipBuyConfigEntity.getType());
|
||||||
|
userVip.setStartTime(new Date());
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||||
|
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||||
|
userVip.setEndTime(threeYearsDate);
|
||||||
|
userVipDao.insert(userVip);
|
||||||
|
userEntity.setVip(vipBuyConfigEntity.getType().toString());
|
||||||
|
myUserDao.updateById(userEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void throwExceptionMethod() throws Exception {
|
||||||
|
throw new Exception("开通vip异常");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public String refund(Map<String,Object> params) {
|
public String refund(Map<String,Object> params) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class WeChatPayController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/payNotify")
|
@PostMapping("/payNotify")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void payNotify(HttpServletRequest request, HttpServletResponse response){
|
public void payNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
wxpayService.payNotify(request);
|
wxpayService.payNotify(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public interface WxpayService extends IService<PayWechatOrderEntity> {
|
|||||||
|
|
||||||
void prepay(WechatPaymentInfo wechatDto);
|
void prepay(WechatPaymentInfo wechatDto);
|
||||||
|
|
||||||
void payNotify(HttpServletRequest request);
|
void payNotify(HttpServletRequest request) throws Exception;
|
||||||
|
|
||||||
String refund(Map<String,Object> map);
|
String refund(Map<String,Object> map);
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.peanut.modules.common.dao.BuyOrderProductDao;
|
import com.peanut.modules.common.dao.*;
|
||||||
import com.peanut.modules.common.dao.JfTransactionDetailsDao;
|
|
||||||
import com.peanut.modules.common.dao.PayWechatOrderDao;
|
|
||||||
import com.peanut.modules.book.service.*;
|
import com.peanut.modules.book.service.*;
|
||||||
import com.peanut.modules.common.dao.UserCourseBuyDao;
|
|
||||||
import com.peanut.modules.common.entity.*;
|
import com.peanut.modules.common.entity.*;
|
||||||
import com.peanut.modules.pay.refund.entity.PayRefundOrder;
|
import com.peanut.modules.pay.refund.entity.PayRefundOrder;
|
||||||
import com.peanut.modules.pay.refund.service.PayRefundOrderService;
|
import com.peanut.modules.pay.refund.service.PayRefundOrderService;
|
||||||
@@ -28,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.Period;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -72,6 +71,12 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
|||||||
private UserCourseBuyDao userCourseBuyDao;
|
private UserCourseBuyDao userCourseBuyDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JfTransactionDetailsDao jfTransactionDetailsDao;
|
private JfTransactionDetailsDao jfTransactionDetailsDao;
|
||||||
|
@Autowired
|
||||||
|
private MyUserDao myUserDao;
|
||||||
|
@Autowired
|
||||||
|
private VipBuyConfigDao vipBuyConfigDao;
|
||||||
|
@Autowired
|
||||||
|
private UserVipDao userVipDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepay(WechatPaymentInfo paymentInfo){
|
public void prepay(WechatPaymentInfo paymentInfo){
|
||||||
@@ -114,7 +119,8 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void payNotify(HttpServletRequest request){
|
@Transactional
|
||||||
|
public void payNotify(HttpServletRequest request) throws Exception {
|
||||||
log.info("微信支付回调");
|
log.info("微信支付回调");
|
||||||
// 处理通知参数
|
// 处理通知参数
|
||||||
Map<String, Object> bodyMap = getNotifyBody(request);
|
Map<String, Object> bodyMap = getNotifyBody(request);
|
||||||
@@ -130,6 +136,23 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
|||||||
payWechatOrderService.updateById(payWechatOrderEntity);
|
payWechatOrderService.updateById(payWechatOrderEntity);
|
||||||
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
|
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
|
||||||
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||||
|
|
||||||
|
if("vip".equals(order.getOrderType())){
|
||||||
|
|
||||||
|
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||||
|
//更新 订单 记录
|
||||||
|
|
||||||
|
buyOrderService.updateOrderStatus(orderEntity.getUserId(),orderNo,"2");
|
||||||
|
|
||||||
|
//处理抵扣积分
|
||||||
|
if(orderEntity.getJfDeduction().compareTo(BigDecimal.ZERO)>0){
|
||||||
|
userCoinJf(orderEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
//开通vip
|
||||||
|
openVipForUser(orderEntity);
|
||||||
|
}
|
||||||
|
|
||||||
// 1.根据订单id获取订单信息
|
// 1.根据订单id获取订单信息
|
||||||
if ("order".equals(order.getOrderType())) {
|
if ("order".equals(order.getOrderType())) {
|
||||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||||
@@ -259,6 +282,93 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openVipForUser(BuyOrder buyOrder) throws Exception {
|
||||||
|
VipBuyConfigEntity vipBuyConfigEntity = vipBuyConfigDao.selectById(buyOrder.getVipBuyConfigId());
|
||||||
|
MyUserEntity userEntity = myUserDao.selectById(buyOrder.getUserId());
|
||||||
|
if(vipBuyConfigEntity.getType()==1){//超v
|
||||||
|
if(userEntity.getVip().equals("0")){//初次办理
|
||||||
|
UserVip userVip = new UserVip();
|
||||||
|
userVip.setUserId(userEntity.getId());
|
||||||
|
userVip.setType(1);
|
||||||
|
userVip.setStartTime(new Date());
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||||
|
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||||
|
userVip.setEndTime(threeYearsDate);
|
||||||
|
userVipDao.insert(userVip);
|
||||||
|
userEntity.setVip("1");
|
||||||
|
myUserDao.updateById(userEntity);
|
||||||
|
}
|
||||||
|
if(userEntity.getVip().equals("1")){//vip延期
|
||||||
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
|
if(userVips.size()!=1){
|
||||||
|
throwExceptionMethod();
|
||||||
|
}
|
||||||
|
UserVip userVip = userVips.get(0);
|
||||||
|
Date endTime = userVip.getEndTime();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(endTime);
|
||||||
|
calendar.add(Calendar.YEAR,vipBuyConfigEntity.getYear());
|
||||||
|
userVip.setEndTime(calendar.getTime());
|
||||||
|
userVipDao.updateById(userVip);
|
||||||
|
}
|
||||||
|
if (userEntity.getVip().equals("2")||userEntity.getVip().equals("3")){//医学vip或国学vip升级
|
||||||
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
|
if(userVips.size()!=1){
|
||||||
|
throwExceptionMethod();
|
||||||
|
}
|
||||||
|
UserVip userVip1 = userVips.get(0);
|
||||||
|
userVip1.setEndTime(new Date());
|
||||||
|
userVip1.setState(1);
|
||||||
|
userVipDao.updateById(userVip1);
|
||||||
|
UserVip userVip = new UserVip();
|
||||||
|
userVip.setUserId(userEntity.getId());
|
||||||
|
userVip.setType(1);
|
||||||
|
userVip.setStartTime(new Date());
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||||
|
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||||
|
userVip.setEndTime(threeYearsDate);
|
||||||
|
userVipDao.insert(userVip);
|
||||||
|
userEntity.setVip("1");
|
||||||
|
myUserDao.updateById(userEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(vipBuyConfigEntity.getType()==2||vipBuyConfigEntity.getType()==3){//医学vip或国学vip
|
||||||
|
if(userEntity.getVip().equals("2")||userEntity.getVip().equals("3")){//续费
|
||||||
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, userEntity.getId()).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
|
if(userVips.size()!=1){
|
||||||
|
throwExceptionMethod();
|
||||||
|
}
|
||||||
|
UserVip userVip = userVips.get(0);
|
||||||
|
Date endTime = userVip.getEndTime();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(endTime);
|
||||||
|
calendar.add(Calendar.YEAR,vipBuyConfigEntity.getYear());
|
||||||
|
userVip.setEndTime(calendar.getTime());
|
||||||
|
userVipDao.updateById(userVip);
|
||||||
|
}else{//新办理
|
||||||
|
UserVip userVip = new UserVip();
|
||||||
|
userVip.setUserId(userEntity.getId());
|
||||||
|
userVip.setType(vipBuyConfigEntity.getType());
|
||||||
|
userVip.setStartTime(new Date());
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate threeYearsLater = today.plus(Period.ofYears(vipBuyConfigEntity.getYear()));
|
||||||
|
Date threeYearsDate = Date.from(threeYearsLater.atStartOfDay(java.time.ZoneId.systemDefault()).toInstant());
|
||||||
|
userVip.setEndTime(threeYearsDate);
|
||||||
|
userVipDao.insert(userVip);
|
||||||
|
userEntity.setVip(vipBuyConfigEntity.getType().toString());
|
||||||
|
myUserDao.updateById(userEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void throwExceptionMethod() throws Exception {
|
||||||
|
throw new Exception("开通vip异常");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String refund(Map<String,Object> map){
|
public String refund(Map<String,Object> map){
|
||||||
LambdaQueryWrapper<PayWechatOrderEntity> wrapper = new LambdaQueryWrapper();
|
LambdaQueryWrapper<PayWechatOrderEntity> wrapper = new LambdaQueryWrapper();
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ public class VipServiceImpl extends ServiceImpl<VipBuyConfigDao, VipBuyConfigEnt
|
|||||||
List<VipBuyConfigEntity> vipBuyConfigEntities = this.getBaseMapper().selectList(wrapper);
|
List<VipBuyConfigEntity> vipBuyConfigEntities = this.getBaseMapper().selectList(wrapper);
|
||||||
for (VipBuyConfigEntity v:vipBuyConfigEntities){
|
for (VipBuyConfigEntity v:vipBuyConfigEntities){
|
||||||
if(v.getType()==1){
|
if(v.getType()==1){
|
||||||
if(!Objects.equals(userEntity.getVip(), "1") &&chaoCount==0){
|
if(userEntity.getVip().equals("0")){
|
||||||
v.setLastFee(v.getFee());
|
v.setLastFee(chaoCount==0?v.getFee():v.getRebateFee());
|
||||||
} else {
|
} else {
|
||||||
if(userEntity.getVip().equals("2")){//医学转超v计算价格
|
if(userEntity.getVip().equals("2")){//医学转超v计算价格
|
||||||
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).lt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 2).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
if(userVips.size()!=1){
|
if(userVips.size()!=1){
|
||||||
return R.error("用户vip信息异常,请联系管理员");
|
return R.error("用户vip信息异常,请联系管理员");
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ public class VipServiceImpl extends ServiceImpl<VipBuyConfigDao, VipBuyConfigEnt
|
|||||||
BigDecimal chaFee = BigDecimal.valueOf(i);
|
BigDecimal chaFee = BigDecimal.valueOf(i);
|
||||||
v.setLastFee(chaoCount>0?v.getRebateFee().subtract(chaFee):v.getFee().subtract(chaFee));
|
v.setLastFee(chaoCount>0?v.getRebateFee().subtract(chaFee):v.getFee().subtract(chaFee));
|
||||||
} else if (userEntity.getVip().equals("3")) {//国学vip转超v计算价格
|
} else if (userEntity.getVip().equals("3")) {//国学vip转超v计算价格
|
||||||
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 3).lt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
List<UserVip> userVips = userVipDao.selectList(new LambdaQueryWrapper<UserVip>().eq(UserVip::getUserId, uid).eq(UserVip::getType, 3).gt(UserVip::getEndTime, new Date()).eq(UserVip::getState, 0));
|
||||||
if(userVips.size()!=1){
|
if(userVips.size()!=1){
|
||||||
return R.error("用户vip信息异常,请联系管理员");
|
return R.error("用户vip信息异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user