Browse Source

修复查询订单支付报错

qmj 1 month ago
parent
commit
d690874ae7

File diff suppressed because it is too large
+ 113 - 0
.claude/homunculus/observations.jsonl


+ 7 - 7
ruoyi-admin/src/main/java/com/ruoyi/app/pay/OmgPayController.java

@@ -784,8 +784,8 @@ public class OmgPayController extends BaseController {
             return new int[]{ps == 2 ? 2 : 0, 0};
             return new int[]{ps == 2 ? 2 : 0, 0};
         }
         }
 
 
-        PosStoreOmg cred = storeOmgService.getCredentialByMerchantId(payment.getMerchantId());
-        if (cred == null || cred.getStoreId() == null || !cred.getStoreId().equals(payment.getStoreId())) {
+        PosStoreOmg cred = storeOmgService.getCredentialByMerchantIdAndStoreId(payment.getMerchantId(), payment.getStoreId());
+        if (cred == null) {
             log.warn("[OMG-{}] 门店凭证不可用: ddId={}", source, ddId);
             log.warn("[OMG-{}] 门店凭证不可用: ddId={}", source, ddId);
             return new int[]{0, 0};
             return new int[]{0, 0};
         }
         }
@@ -992,11 +992,11 @@ public class OmgPayController extends BaseController {
 
 
     private String auditJson(Map<String, String> form) {
     private String auditJson(Map<String, String> form) {
         Map<String, String> audit = new LinkedHashMap<>(form);
         Map<String, String> audit = new LinkedHashMap<>(form);
-        audit.remove("CheckMacValue");
-        audit.remove("AuthCode");
-        audit.remove("auth_code");
-        audit.remove("card4no");
-        audit.remove("card6no");
+//        audit.remove("CheckMacValue");
+//        audit.remove("AuthCode");
+//        audit.remove("auth_code");
+//        audit.remove("card4no");
+//        audit.remove("card6no");
         return JSON.toJSONString(audit);
         return JSON.toJSONString(audit);
     }
     }
 
 

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PosStoreOmgMapper.java

@@ -23,6 +23,9 @@ public interface PosStoreOmgMapper extends BaseMapper<PosStoreOmg> {
     /** 按 OMG 商店代号反查凭证(回调按 MerchantID 定位门店用)。 */
     /** 按 OMG 商店代号反查凭证(回调按 MerchantID 定位门店用)。 */
     PosStoreOmg selectByMerchantId(@Param("merchantId") String merchantId);
     PosStoreOmg selectByMerchantId(@Param("merchantId") String merchantId);
 
 
+    /** 按 merchant_id + store_id 精确反查凭证(退款/查询补单:同 merchant 多门店定位本店)。 */
+    PosStoreOmg selectByMerchantIdAndStoreId(@Param("merchantId") String merchantId, @Param("storeId") Long storeId);
+
     /** 门店 OMG 凭证管理列表(pos_store LEFT JOIN pos_store_omg + info_user,配合 PageHelper 分页)。 */
     /** 门店 OMG 凭证管理列表(pos_store LEFT JOIN pos_store_omg + info_user,配合 PageHelper 分页)。 */
     List<PosStoreOmgVo> selectOmgStoreList(PosStoreOmgVo query);
     List<PosStoreOmgVo> selectOmgStoreList(PosStoreOmgVo query);
 
 

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPosStoreOmgService.java

@@ -25,6 +25,9 @@ public interface IPosStoreOmgService {
     /** 回调/退款按 MerchantID 读取已配置凭证;停用只阻止新支付,不得阻断在途交易。 */
     /** 回调/退款按 MerchantID 读取已配置凭证;停用只阻止新支付,不得阻断在途交易。 */
     PosStoreOmg getCredentialByMerchantId(String merchantId);
     PosStoreOmg getCredentialByMerchantId(String merchantId);
 
 
+    /** 退款/查询补单按 merchant_id + store_id 精确读凭证(同 merchant 多门店时定位本店)。 */
+    PosStoreOmg getCredentialByMerchantIdAndStoreId(String merchantId, Long storeId);
+
     /** 凭证管理列表(配合 PageHelper 分页)。 */
     /** 凭证管理列表(配合 PageHelper 分页)。 */
     List<PosStoreOmgVo> selectOmgStoreList(PosStoreOmgVo query);
     List<PosStoreOmgVo> selectOmgStoreList(PosStoreOmgVo query);
 
 

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PosStoreOmgServiceImpl.java

@@ -61,6 +61,18 @@ public class PosStoreOmgServiceImpl implements IPosStoreOmgService {
         return row;
         return row;
     }
     }
 
 
+    @Override
+    public PosStoreOmg getCredentialByMerchantIdAndStoreId(String merchantId, Long storeId) {
+        if (StrUtil.isBlank(merchantId) || storeId == null) {
+            return null;
+        }
+        PosStoreOmg row = posStoreOmgMapper.selectByMerchantIdAndStoreId(merchantId, storeId);
+        if (row == null || StrUtil.isBlank(row.getHashKey()) || StrUtil.isBlank(row.getHashIv())) {
+            return null;
+        }
+        return row;
+    }
+
     @Override
     @Override
     public List<PosStoreOmgVo> selectOmgStoreList(PosStoreOmgVo query) {
     public List<PosStoreOmgVo> selectOmgStoreList(PosStoreOmgVo query) {
         return posStoreOmgMapper.selectOmgStoreList(query);
         return posStoreOmgMapper.selectOmgStoreList(query);

+ 18 - 0
ruoyi-system/src/main/resources/mapper/chanting/PosStoreOmgMapper.xml

@@ -28,6 +28,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                create_by AS createBy, update_by AS updateBy
                create_by AS createBy, update_by AS updateBy
         FROM pos_store_omg
         FROM pos_store_omg
         WHERE merchant_id = #{merchantId}
         WHERE merchant_id = #{merchantId}
+        ORDER BY id DESC
+        LIMIT 1
+    </select>
+
+    <!-- 按 merchant_id + store_id 精确反查凭证(退款/查询补单:同 merchant_id 多门店时定位本店) -->
+    <select id="selectByMerchantIdAndStoreId" parameterType="map"
+            resultType="com.ruoyi.system.domain.PosStoreOmg">
+        SELECT id, store_id AS storeId, omg_status AS omgStatus, is_enabled AS isEnabled,
+               merchant_id AS merchantId, hash_key AS hashKey, hash_iv AS hashIv,
+               enabled_payments AS enabledPayments, apply_time AS applyTime,
+               approved_time AS approvedTime, last_verify_result AS lastVerifyResult,
+               remark, create_time AS createTime, update_time AS updateTime,
+               create_by AS createBy, update_by AS updateBy
+        FROM pos_store_omg
+        WHERE merchant_id = #{merchantId}
+          AND store_id = #{storeId}
+        ORDER BY id DESC
+        LIMIT 1
     </select>
     </select>
 
 
     <!-- 门店 OMG 凭证管理列表:列名别名对齐 VO 属性,resultType 自动映射 -->
     <!-- 门店 OMG 凭证管理列表:列名别名对齐 VO 属性,resultType 自动映射 -->

Some files were not shown because too many files changed in this diff