package com.hollywood.applet.service.impl;
|
import java.time.LocalDateTime;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.hollywood.applet.dto.PerformanceJoinDto;
|
import com.hollywood.applet.mapper.TUserMapper;
|
import com.hollywood.applet.mapper.TVipConfigMapper;
|
import com.hollywood.applet.mapper.TVipPurchaseRecordMapper;
|
import com.hollywood.applet.service.TVipConfigService;
|
import com.hollywood.common.basic.ApiResult;
|
import com.hollywood.common.model.*;
|
import com.hollywood.common.utils.PayMoneyUtil;
|
import com.hollywood.common.utils.UUIDUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
|
/**
|
* <p>
|
* 会员设置 服务实现类
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2024-02-29
|
*/
|
@Service
|
public class TVipConfigServiceImpl extends ServiceImpl<TVipConfigMapper, TVipConfig> implements TVipConfigService {
|
|
@Resource
|
private TUserMapper userMapper;
|
@Resource
|
private TVipPurchaseRecordMapper vipPurchaseRecordMapper;
|
@Autowired
|
private PayMoneyUtil payMoneyUtil;
|
@Override
|
public ApiResult pay(Long userId, BigDecimal money, Integer month,Integer payType,Integer type) throws Exception {
|
//进行支付操作
|
if(payType == 1){//微信支付
|
return weChatPaymentAPerformance(money,userId,month,type);
|
}
|
if (payType==2){
|
return aliPayPerformance(money,userId,month,type);
|
|
}
|
return ApiResult.failed("请选择支付方式");
|
}
|
|
public ApiResult weChatPaymentAPerformance(BigDecimal money, Long userId,Integer month,Integer type) throws Exception{
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);
|
TVipPurchaseRecord tVipPurchaseRecord = new TVipPurchaseRecord();
|
tVipPurchaseRecord.setUserId(userId);
|
if (type==1||type==2) {
|
tVipPurchaseRecord.setVipType(1);
|
} else if (type==3||type==4) {
|
tVipPurchaseRecord.setVipType(2);
|
}
|
switch (type){
|
case 1: tVipPurchaseRecord.setChargeType(1);
|
case 2: tVipPurchaseRecord.setChargeType(2);
|
case 3: tVipPurchaseRecord.setChargeType(1);
|
case 4: tVipPurchaseRecord.setChargeType(2);
|
|
}
|
tVipPurchaseRecord.setPurchaseCount(month);
|
tVipPurchaseRecord.setPayMoney(money.doubleValue());
|
tVipPurchaseRecord.setPayTime(LocalDateTime.now());
|
tVipPurchaseRecord.setCode(code);
|
vipPurchaseRecordMapper.insert(tVipPurchaseRecord);
|
ApiResult weixinpay = payMoneyUtil.weixinpay("参加演员活动", "", code,money.toString(), "/base/vip/wxcallback", "APP");
|
return weixinpay;
|
}
|
|
private ApiResult aliPayPerformance(BigDecimal money, Long userId,Integer month,Integer type) {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);
|
TVipPurchaseRecord tVipPurchaseRecord = new TVipPurchaseRecord();
|
tVipPurchaseRecord.setUserId(userId);
|
if (type==1||type==2) {
|
tVipPurchaseRecord.setVipType(1);
|
} else if (type==3||type==4) {
|
tVipPurchaseRecord.setVipType(2);
|
}
|
switch (type){
|
case 1: tVipPurchaseRecord.setChargeType(1);
|
case 2: tVipPurchaseRecord.setChargeType(2);
|
case 3: tVipPurchaseRecord.setChargeType(1);
|
case 4: tVipPurchaseRecord.setChargeType(2);
|
|
}
|
tVipPurchaseRecord.setPurchaseCount(month);
|
tVipPurchaseRecord.setPayMoney(money.doubleValue());
|
tVipPurchaseRecord.setPayTime(LocalDateTime.now());
|
tVipPurchaseRecord.setCode(code);
|
tVipPurchaseRecord.setIsPay(1);
|
vipPurchaseRecordMapper.insert(tVipPurchaseRecord);
|
ApiResult alipay = payMoneyUtil.alipay("vip费用", "vip费用", code,money.toString(), "/base/vip/aliPaymentCourseCallback");
|
return alipay;
|
}
|
}
|