|
@@ -1,8 +1,10 @@
|
|
|
package com.dk.oauth.service.wxapi.basic;
|
|
package com.dk.oauth.service.wxapi.basic;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.dk.common.exception.BaseBusinessException;
|
|
import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
|
import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
|
|
+import com.dk.common.infrastructure.xxl.XxlJobUtils;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
import com.dk.common.response.ResponseResultVO;
|
|
@@ -36,6 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.ZoneOffset;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -61,6 +66,8 @@ public class WechatPayService {
|
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CompanyMapper companyMapper;
|
|
private CompanyMapper companyMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private XxlJobUtils xxlJobUtils;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商户 下单选取旗舰版或专业版的订单
|
|
* 商户 下单选取旗舰版或专业版的订单
|
|
@@ -131,7 +138,7 @@ public class WechatPayService {
|
|
|
log.info("微信用户----------" + byWxid);
|
|
log.info("微信用户----------" + byWxid);
|
|
|
// 获取交易记录
|
|
// 获取交易记录
|
|
|
TradeResponse tradeResponse = tradeMapper.selectTradeByNo(new Trade().setTradeNo(info.getOutTradeNo()));
|
|
TradeResponse tradeResponse = tradeMapper.selectTradeByNo(new Trade().setTradeNo(info.getOutTradeNo()));
|
|
|
- if(tradeResponse == null){
|
|
|
|
|
|
|
+ if (tradeResponse == null) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(),
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(),
|
|
|
ErrorCodeEnum.NO_FIND_TRADE.getMessage());
|
|
ErrorCodeEnum.NO_FIND_TRADE.getMessage());
|
|
|
}
|
|
}
|
|
@@ -142,6 +149,31 @@ public class WechatPayService {
|
|
|
trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
|
|
trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
|
|
|
tradeMapper.updateById(trade);
|
|
tradeMapper.updateById(trade);
|
|
|
|
|
|
|
|
|
|
+ // 交易类型-续费- 将该公司的 生成一个job的任务
|
|
|
|
|
+ if (Constant.TradeType.RENEW.getName().equals(trade.getTradeType())) {
|
|
|
|
|
+ log.error("交易类型-续费插入任务数据-getTradeType:" + trade.getTradeType());
|
|
|
|
|
+ try {
|
|
|
|
|
+ Company company = companyMapper.selectById(tradeResponse.getCpId());
|
|
|
|
|
+ // 解析license信息
|
|
|
|
|
+ String licenseStr = AESUtil.desEncrypt(company.getLicenseSocial());
|
|
|
|
|
+ log.error("交易类型-续费插入任务数据-licenseStr:" + licenseStr);
|
|
|
|
|
+ if (licenseStr != null) {
|
|
|
|
|
+ Map<String, Object> licenseMap = JSON.parseObject(licenseStr, Map.class);
|
|
|
|
|
+ log.error("交易类型-续费插入任务数据-re_new:" + licenseMap.get("re_new"));
|
|
|
|
|
+ if (licenseMap.get("re_new") != null) {
|
|
|
|
|
+ String d = licenseMap.get("user_end_date") + "";
|
|
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.parse(d, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ int id = xxlJobUtils.create(Math.toIntExact(
|
|
|
|
|
+ (localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli() - System.currentTimeMillis()) / 1000
|
|
|
|
|
+ ), tradeResponse.getCpId() + "", Constant.XxlJobInfo.RENEW.getValue());
|
|
|
|
|
+ log.error("交易类型-续费插入任务数据-:" + id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("交易类型-续费插入任务数据-异常:" + e.getStackTrace());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 更新企业,把临时license更新到license中
|
|
// 更新企业,把临时license更新到license中
|
|
|
log.info("交易记录----------" + trade);
|
|
log.info("交易记录----------" + trade);
|
|
|
// 企业
|
|
// 企业
|