Browse Source

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-oauth

zhoux 1 year ago
parent
commit
d8e16ad5a9

+ 7 - 0
src/main/java/com/dk/oauth/service/impl/AuthAccessTokenServiceImpl.java

@@ -256,6 +256,9 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
 //                        company.setFunPackage(JSON.parseArray(JSON.toJSONString(licenseMap.get("fun_package")),Activity.class));
                         company.setFunPackage((List<Map<String, Object>>) licenseMap.get("fun_package"));
                     }
+                    if (licenseMap.get("re_new") != null) {
+                        company.setReNew((Map<String, Object>) licenseMap.get("re_new"));
+                    }
                     company.setGradeCode(licenseMap.get("grade_code").toString());
                 } else {
                     // 获取最近一次的交易记录
@@ -613,6 +616,9 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
 //                        company.setFunPackage(JSON.parseArray(JSON.toJSONString(licenseMap.get("fun_package")),Activity.class));
                         company.setFunPackage((List<Map<String, Object>>) licenseMap.get("fun_package"));
                     }
+                    if (licenseMap.get("re_new") != null) {
+                        company.setReNew((Map<String, Object>) licenseMap.get("re_new"));
+                    }
                     company.setGradeCode(licenseMap.get("grade_code").toString());
                 } else {
                     // 获取最近一次的交易记录
@@ -809,6 +815,7 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
         UserLogin userLogin = userMapper.selectById(userId);
         Map<String, Object> map = new HashMap<>();
         map.put("publicOpenId",userLogin.getPublicOpenId());
+        map.put("userWxId",userLogin.getUserWxid());
         map.put("userImage",userLogin.getUserImage());
         return ResponseResultUtil.success(map);
     }

+ 0 - 6
src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java

@@ -493,12 +493,6 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         licenseMap.put("re_new", companyVO.getReNew());
         company.setLicenseSocial(AESUtil.aesEncrypt(JSON.toJSONString(licenseMap)));
 //        续费和升级
-        if (Constant.TradeType.RENEW.getName().equals(companyVO.getTradeType())) {
-
-        } else {
-
-        }
-
         companyMapper.updateById(company);
         // 生成交易记录
         Trade trade = new Trade();

+ 33 - 1
src/main/java/com/dk/oauth/service/wxapi/basic/WechatPayService.java

@@ -1,8 +1,10 @@
 package com.dk.oauth.service.wxapi.basic;
 
+import com.alibaba.fastjson.JSON;
 import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.constant.Constant;
 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.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
@@ -36,6 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -61,6 +66,8 @@ public class WechatPayService {
     private UserMapper userMapper;
     @Autowired
     private CompanyMapper companyMapper;
+    @Autowired
+    private XxlJobUtils xxlJobUtils;
 
     /**
      * 商户 下单选取旗舰版或专业版的订单
@@ -131,7 +138,7 @@ public class WechatPayService {
         log.info("微信用户----------" + byWxid);
         // 获取交易记录
         TradeResponse tradeResponse = tradeMapper.selectTradeByNo(new Trade().setTradeNo(info.getOutTradeNo()));
-        if(tradeResponse == null){
+        if (tradeResponse == null) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(),
                     ErrorCodeEnum.NO_FIND_TRADE.getMessage());
         }
@@ -142,6 +149,31 @@ public class WechatPayService {
         trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
         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中
         log.info("交易记录----------" + trade);
 //        企业