Bläddra i källkod

完善同步收款记录的定时任务逻辑

cgp 2 dagar sedan
förälder
incheckning
2008bbc5b1

+ 5 - 0
fs-service/src/main/java/com/fs/qw/domain/FsCompanyExternalPayReceipt.java

@@ -114,6 +114,11 @@ public class FsCompanyExternalPayReceipt extends BaseEntity {
      */
     private String corpId;
 
+    /**
+     * 公司销售ID
+     * */
+    private Long companyUserId;
+
     /**
      * 企业名称
      */

+ 5 - 0
fs-service/src/main/java/com/fs/qw/domain/FsCompanyExternalPayRefund.java

@@ -107,6 +107,11 @@ public class FsCompanyExternalPayRefund extends BaseEntity {
      */
     private String corpId;
 
+    /**
+     * 公司销售ID
+     * */
+    private Long companyUserId;
+
     /**
      * 企业名称
      */

+ 16 - 4
fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyExternalPayReceiptServiceImpl.java

@@ -3,9 +3,11 @@ package com.fs.qw.service.impl;
 import com.fs.qw.domain.FsCompanyExternalPayReceipt;
 import com.fs.qw.domain.FsCompanyExternalPayRefund;
 import com.fs.qw.domain.QwCompany;
+import com.fs.qw.domain.QwUser;
 import com.fs.qw.dto.ReceiptDto;
 import com.fs.qw.mapper.FsCompanyExternalPayReceiptMapper;
 import com.fs.qw.mapper.FsCompanyExternalPayRefundMapper;
+import com.fs.qw.mapper.QwUserMapper;
 import com.fs.qw.service.IFsCompanyExternalPayReceiptService;
 import com.fs.qw.utils.MoneyUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -14,10 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
+
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -35,6 +34,9 @@ public class FsCompanyExternalPayReceiptServiceImpl implements IFsCompanyExterna
     @Autowired
     private FsCompanyExternalPayRefundMapper refundMapper;
 
+    @Autowired
+    private QwUserMapper qwUserMapper;
+
     // 同步收、退款记录(定时任务同步或手动同步)
     @Override
     //移除 @Transactional,每个企业独立处理,一个失败不回滚其他企业
@@ -65,6 +67,11 @@ public class FsCompanyExternalPayReceiptServiceImpl implements IFsCompanyExterna
                         entity.setTotalRefundFee(MoneyUtils.centToYuan(dto.getTotalRefundFee()));
                         entity.setSaleTime(secondsToDate(dto.getPayTime()));//转成时间戳格式保存
 
+                        //根据corpId和微信返回的user_id查询scrm系统中的companyUserId
+                        QwUser qwUser = qwUserMapper.selectQwUserByCorpIdAndUserId(corpId, dto.getPayeeUserid());
+                        if (qwUser!=null&&qwUser.getCompanyUserId()!=null){
+                            entity.setCompanyUserId(qwUser.getCompanyUserId());
+                        }
                         FsCompanyExternalPayReceipt exist = receiptMapper.selectByTransactionId(dto.getTransactionId());
                         if (exist == null) {
                             receiptMapper.insertFsCompanyExternalPayReceipt(entity);
@@ -80,6 +87,11 @@ public class FsCompanyExternalPayReceiptServiceImpl implements IFsCompanyExterna
                         refund.setCorpName(corpName);
                         refund.setRefundFee(MoneyUtils.centToYuan(dto.getRefundFee()));
                         refund.setSaleTime(secondsToDate(dto.getPayTime()));//转成时间戳格式保存
+                        //根据corpId和微信返回的user_id查询scrm系统中的companyUserId
+                        QwUser qwUser = qwUserMapper.selectQwUserByCorpIdAndUserId(corpId, dto.getPayeeUserid());
+                        if (qwUser!=null&&qwUser.getCompanyUserId()!=null){
+                            refund.setCompanyUserId(qwUser.getCompanyUserId());
+                        }
                         FsCompanyExternalPayRefund existRefund = refundMapper.selectByTransactionId(dto.getTransactionId());
                         if (existRefund == null) {
                             refundMapper.insertRefund(refund);

+ 11 - 1
fs-service/src/main/resources/mapper/qw/FsCompanyExternalPayReceiptMapper.xml

@@ -24,6 +24,7 @@
         <result property="createTime"        column="create_time"        />
         <result property="updateTime"        column="update_time"        />
         <result property="corpId"            column="corp_id"            />
+        <result property="companyUserId"     column="company_user_id"    />
         <result property="corpName"          column="corp_name"          />
     </resultMap>
 
@@ -32,7 +33,7 @@
                external_userid, total_fee, payee_userid, payment_type,
                mch_id, remark, total_refund_fee, commodity_list,
                contact_info, miniprogram_info, create_time, update_time,
-               corp_id, corp_name
+               corp_id,company_user_id, corp_name
         from fs_company_external_pay_receipt
     </sql>
 
@@ -70,6 +71,12 @@
             <if test="mchId != null and mchId != ''">
                 and mch_id = #{mchId}
             </if>
+            <if test="corpId != null and corpId != ''">
+                and corp_id = #{corpId}
+            </if>
+            <if test="companyUserId != null and companyUserId != ''">
+                and company_user_id = #{companyUserId}
+            </if>
             <if test="remark != null and remark != ''">
                 and remark like concat('%', #{remark}, '%')
             </if>
@@ -118,6 +125,7 @@
             <if test="contactInfo != null">contact_info,</if>
             <if test="miniprogramInfo != null">miniprogram_info,</if>
             <if test="corpId != null">corp_id,</if>
+            <if test="companyUserId != null">,company_user_id,</if>
             <if test="corpName != null">corp_name,</if>
             create_time, update_time
         </trim>
@@ -138,6 +146,7 @@
             <if test="contactInfo != null">#{contactInfo},</if>
             <if test="miniprogramInfo != null">#{miniprogramInfo},</if>
             <if test="corpId != null">#{corpId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
             <if test="corpName != null">#{corpName},</if>
             sysdate(), sysdate()
         </trim>
@@ -183,6 +192,7 @@
             <if test="contactInfo != null">contact_info = #{contactInfo},</if>
             <if test="miniprogramInfo != null">miniprogram_info = #{miniprogramInfo},</if>
             <if test="corpId != null">corp_id = #{corpId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             <if test="corpName != null">corp_name = #{corpName},</if>
             update_time = sysdate()
         </set>

+ 5 - 1
fs-service/src/main/resources/mapper/qw/FsCompanyExternalPayRefundMapper.xml

@@ -21,13 +21,14 @@
         <result property="createTime"       column="create_time"       />
         <result property="updateTime"       column="update_time"       />
         <result property="corpId"           column="corp_id"           />
+        <result property="companyUserId"    column="company_user_id"   />
         <result property="corpName"         column="corp_name"         />
     </resultMap>
 
     <sql id="Base_Column_List">
         select id, transaction_id, out_trade_no, out_refund_no, refund_userid, refund_comment,
                refund_reqtime, refund_status, refund_fee, external_userid, payee_userid,
-               payment_type, mch_id, pay_time, sale_time, create_time, update_time, corp_id, corp_name
+               payment_type, mch_id, pay_time, sale_time, create_time, update_time, corp_id,company_user_id, corp_name
         from fs_company_external_pay_refund
     </sql>
 
@@ -50,6 +51,7 @@
             <if test="payTime != null">pay_time,</if>
             <if test="saleTime != null">sale_time,</if>
             <if test="corpId != null">corp_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
             <if test="corpName != null">corp_name,</if>
             create_time, update_time
         </trim>
@@ -69,6 +71,7 @@
             <if test="payTime != null">#{payTime},</if>
             <if test="saleTime != null">#{saleTime},</if>
             <if test="corpId != null">#{corpId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
             <if test="corpName != null">#{corpName},</if>
             sysdate(), sysdate()
         </trim>
@@ -91,6 +94,7 @@
             <if test="payTime != null">pay_time = #{payTime},</if>
             <if test="saleTime != null">sale_time = #{saleTime},</if>
             <if test="corpId != null">corp_id = #{corpId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             <if test="corpName != null">corp_name = #{corpName},</if>
             update_time = sysdate()
         </set>