Jelajahi Sumber

续费的更新数据

姜永辉 1 tahun lalu
induk
melakukan
07f29c09db

+ 9 - 0
src/main/java/com/dk/oauth/controller/wxapi/basic/WechatPayController.java

@@ -122,4 +122,13 @@ public class WechatPayController {
     }
 
 
+    @ApiOperation(
+            value = "续费的公司提醒回调",
+            notes = "续费的公司提醒回调"
+    )
+    @PostMapping("renew_reminder")
+    public ResponseResultVO<?> renewReminder() {
+        return wechatPayService.renewReminder();
+    }
+
 }

+ 16 - 6
src/main/java/com/dk/oauth/feign/service/StaffFeign.java

@@ -23,23 +23,33 @@ public interface StaffFeign {
      * @author : 姜永辉
      * @date : 2023-11-02 16:27
      */
-    @PostMapping({ "/feign_get_experience"})
+    @PostMapping({"/feign_get_experience"})
     ResponseResultVO<StaffResponse> getFeignExperience(@RequestBody Map<String, Object> collectQuery);
 
     /**
      * @desc : 注册商户时候插入  角色 基础资料(仓库 渠道 收入 支出 入库 出库 账户 来源 盈亏原因) 计量单位 种类  打印票据  等等。
-     *         返回角色的数据
+     * 返回角色的数据
+     * -因为没有登录
      * @author : 姜永辉
      * @date : 2023-11-02 16:27
      */
-    @PostMapping({"//" + Constant.MDM_PREFIX + Constant.SERVER + "-$CLUSTER_ID"    + Constant.MST_STAFF + "/insert_feign_company_data"})
-    ResponseResultVO  insertFeignCompanyData(@RequestBody Map<String, List<Map<String, Object>>> map);
+    @PostMapping({"//" + Constant.MDM_PREFIX + Constant.SERVER + "-$CLUSTER_ID"  + Constant.MST_STAFF + "/insert_feign_company_data"})
+    ResponseResultVO insertFeignCompanyData(@RequestBody Map<String, List<Map<String, Object>>> map);
 
     /**
-     * @desc : 注册商户时候插入员工
+     * @desc : 注册商户时候插入员工-因为没有登录
      * @author : 姜永辉
      * @date : 2023-11-02 16:27
      */
-    @PostMapping({"//" + Constant.MDM_PREFIX + Constant.SERVER + "-$CLUSTER_ID"   + Constant.MST_STAFF + "/insert_feign_staff"})
+    @PostMapping({"//" + Constant.MDM_PREFIX + Constant.SERVER + "-$CLUSTER_ID" + Constant.MST_STAFF + "/insert_feign_staff"})
     ResponseResultVO<StaffResponse> insertFeignStaff(@RequestBody StaffVO staffVO);
+
+
+    /**
+     * @desc : 更新员工的登录标识-已经登录的接口
+     * @author : 姜永辉
+     * @date : 2023-11-02 16:27
+     */
+    @PostMapping({"/update_feign_staff_flg_can_login"})
+    ResponseResultVO updateFeignStaffFlgCanLogin(@RequestBody List<String> list);
 }

+ 7 - 0
src/main/java/com/dk/oauth/mapper/CompanyMapper.java

@@ -73,6 +73,13 @@ public interface CompanyMapper extends BaseMapper<Company> {
     int updateCompanyLicense(Company Company);
 
     /**
+     * @desc : 更新企业的license文件
+     * @author : 周兴
+     * @date : 2024-05-20 15:21
+     */
+    int updateCompanyNewLicense(Company Company);
+
+    /**
      * @desc : 更新企业所有者信息
      * @author : 刘尧
      * @date : 2024-06-21 10:51

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

@@ -517,6 +517,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         trade.setActivityIds(companyVO.getActivityIds());
         trade.setActivityItemIds(companyVO.getActivityItemIds());
         tradeMapper.insert(trade);
+
         return ResponseResultUtil.success(trade);
     }
 

+ 66 - 0
src/main/java/com/dk/oauth/service/wxapi/basic/WechatPayService.java

@@ -1,10 +1,12 @@
 package com.dk.oauth.service.wxapi.basic;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 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.model.response.mst.StaffResponse;
 import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
@@ -14,6 +16,7 @@ import com.dk.oauth.entity.Company;
 import com.dk.oauth.entity.Trade;
 import com.dk.oauth.entity.TradeResponse;
 import com.dk.oauth.entity.UserLogin;
+import com.dk.oauth.feign.service.StaffFeign;
 import com.dk.oauth.mapper.CompanyMapper;
 import com.dk.oauth.mapper.TradeMapper;
 import com.dk.oauth.mapper.UserMapper;
@@ -29,12 +32,15 @@ import com.github.binarywang.wxpay.config.WxPayConfig;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDate;
@@ -68,6 +74,8 @@ public class WechatPayService {
     private CompanyMapper companyMapper;
     @Autowired
     private XxlJobUtils xxlJobUtils;
+    @Resource
+    StaffFeign staffFeign;
 
     /**
      * 商户 下单选取旗舰版或专业版的订单
@@ -236,4 +244,62 @@ public class WechatPayService {
         }
 
     }
+
+
+    /**
+     * @desc : 续费的公司提醒回调
+     * @author : 姜永辉
+     * @date : 2024-06-29 14:22
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    @XxlJob("renew-reminder")
+    public ResponseResultVO renewReminder() {
+        log.info("@XxlJob(\"renewReminder\")id: {}", XxlJobHelper.getJobParam());
+        try {
+//            Integer cpid = 382;
+            Company company = companyMapper.selectById( XxlJobHelper.getJobParam());
+            // 解析license信息
+            String licenseStr = AESUtil.desEncrypt(company.getLicense());
+            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) {
+                    // 续费 返回的
+                    Map<String, Object> renewM = (Map<String, Object>) licenseMap.get("re_new");
+                    // 生成临时license授权
+                    Map<String, Object> licenseMapNew = new HashMap<>();
+                    licenseMapNew.put("grade_code", licenseMap.get("grade_code"));
+                    licenseMapNew.put("end_date", LocalDate.parse(licenseMap.get("end_date") + ""));
+                    // 续费 返回的
+                    licenseMapNew.put("user_end_date", LocalDate.parse(renewM.get("user_end_date") + ""));
+                    licenseMapNew.put("web_max_num", Integer.parseInt(licenseMap.get("web_max_num") + ""));
+                    // // 续费 返回的
+                    licenseMapNew.put("wx_max_num", Integer.parseInt(renewM.get("wx_max_num") + ""));
+                    licenseMapNew.put("vip", licenseMap.get("vip"));
+                    // 续费 返回的
+                    licenseMapNew.put("fun_package", renewM.get("fun_package"));
+                    // re_new 的值变为null
+//                    licenseMapNew.put("re_new", licenseMap.get("re_new"));
+                    // 续费和升级
+                    Company companynew = new Company();
+                    companynew.setCpId(company.getCpId());
+                    companynew.setLicense(AESUtil.aesEncrypt(JSON.toJSONString(licenseMapNew)));
+                    companyMapper.updateCompanyNewLicense(companynew);
+                    // 续费 返回的 取消授权的员工id 将员工的登录标识修改
+                    if (renewM.get("del_staff_ids") != null) {
+                        List<String> staffids = (List<String>) renewM.get("del_staff_ids");
+                        // 更新员工的登录标识
+                        ResponseResultVO responseResultVO = staffFeign.updateFeignStaffFlgCanLogin(staffids);
+                    }
+
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("续费的公司提醒回调----异常:{}", e.getMessage());
+        }
+        return null;
+    }
 }

+ 19 - 0
src/main/resources/dev/bootstrap.yml

@@ -144,6 +144,25 @@ dongke:
     ds:
       table-name:
 
+xxl:
+  job:
+    admin:
+      addresses: http://s.dev01.dkiboss.com:16100
+    accessToken:
+    executor:
+      appname: xxl-job-mini-company-renew
+      address:
+      ip:
+      port: 16121
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30
+  info:
+    renew:
+      job-desc: 公司续费
+      executo-handler: renew-reminder
+  job-group: 2
+  server-url: ${xxl.job.admin.addresses}
+
 #  单点登录是否开启
 single-sign-on: false
 uploadPath: ''

+ 4 - 0
src/main/resources/mapper/CompanyMapper.xml

@@ -226,6 +226,10 @@
     <update id="updateCompanyLicense">
         update dkic_a.t_a_company set license = license_social,license_social = null where cp_id = #{cpId}
     </update>
+    <!--更新企业的临时license到license中-->
+    <update id="updateCompanyNewLicense">
+        update dkic_a.t_a_company set license = #{license},license_social = null where cp_id = #{cpId}
+    </update>
     <!--更新企业所有者信息-->
     <update id="updateOwner">
         UPDATE dkic_a.t_a_company set owner = #{owner}::uuid, cp_manager = #{cpManager}, cp_phone = #{cpPhone} WHERE cp_id = #{cpId}

+ 19 - 0
src/main/resources/prod/bootstrap.yml

@@ -144,6 +144,25 @@ dongke:
     ds:
       table-name:
 
+xxl:
+  job:
+    admin:
+      addresses: http://s.dev01.dkiboss.com:16100
+    accessToken:
+    executor:
+      appname: xxl-job-mini-company-renew
+      address:
+      ip:
+      port: 16121
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30
+  info:
+    renew:
+      job-desc: 公司续费
+      executo-handler: renew-reminder
+  job-group: 2
+  server-url: ${xxl.job.admin.addresses}
+
 #  单点登录是否开启
 single-sign-on: false
 uploadPath: ''

+ 19 - 0
src/main/resources/test/bootstrap.yml

@@ -144,6 +144,25 @@ dongke:
     ds:
       table-name:
 
+xxl:
+  job:
+    admin:
+      addresses: http://s.dev01.dkiboss.com:16100
+    accessToken:
+    executor:
+      appname: xxl-job-mini-company-renew
+      address:
+      ip:
+      port: 16121
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30
+  info:
+    renew:
+      job-desc: 公司续费
+      executo-handler: renew-reminder
+  job-group: 2
+  server-url: ${xxl.job.admin.addresses}
+
 #  单点登录是否开启
 single-sign-on: false
 uploadPath: ''