diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopMerchantController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopMerchantController.java index b97293894..0ea4bd3c8 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopMerchantController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopMerchantController.java @@ -6,6 +6,7 @@ import com.czg.account.service.ShopMerchantService; import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckRole; import com.czg.resp.CzgResult; +import com.czg.sa.StpKit; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -41,6 +42,7 @@ public class ShopMerchantController { @SaAdminCheckPermission(value = "shopMerchant:edit", name = "商户支付信息修改") @PutMapping public CzgResult edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) { + shopMerchantEditDTO.setShopId(StpKit.USER.getLoginIdAsLong()); return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO)); } } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/dto/merchant/ShopMerchantEditDTO.java b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/merchant/ShopMerchantEditDTO.java index bb3ecda40..8590a4ca5 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/dto/merchant/ShopMerchantEditDTO.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/merchant/ShopMerchantEditDTO.java @@ -8,6 +8,7 @@ import lombok.Data; */ @Data public class ShopMerchantEditDTO { + private Long shopId; @NotEmpty(message = "支付系统商户id不为空") private String storeId; @NotEmpty(message = "支付系统商户名称不为空") diff --git a/cash-sdk/czg-pay/src/main/java/com/czg/CzgPayUtils.java b/cash-sdk/czg-pay/src/main/java/com/czg/CzgPayUtils.java index 0d7bc5194..5ec233aaf 100644 --- a/cash-sdk/czg-pay/src/main/java/com/czg/CzgPayUtils.java +++ b/cash-sdk/czg-pay/src/main/java/com/czg/CzgPayUtils.java @@ -141,11 +141,11 @@ public class CzgPayUtils { log.error("超掌柜回调响应失败,{}", respParams); return null; } - if (StrUtil.isNotBlank(respParams.getSign())) { - if (validateSign(respParams.getSign(), respParams.getBizData())) { - log.error("超掌柜回调 验签失败"); - } - } +// if (StrUtil.isNotBlank(respParams.getSign())) { +// if (validateSign(respParams.getSign(), respParams.getBizData())) { +// log.error("超掌柜回调 验签失败"); +// } +// } return JSONObject.parse(respParams.getBizData()); } @@ -178,11 +178,11 @@ public class CzgPayUtils { result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode())); result.setMsg(respParams.getMsg()); if ("000000".equals(respParams.getCode()) && StrUtil.isNotBlank(respParams.getSign())) { - if (validateSign(respParams.getSign(), JSONObject.toJSONString(respParams))) { +// if (validateSign(respParams.getSign(), JSONObject.toJSONString(respParams))) { // result.setCode(CzgRespCode.FAILURE.getCode()); // result.setMsg("验签失败"); - log.info("验签失败"); - } +// log.info("验签失败"); +// } result.setData(JSONObject.parseObject(respParams.getBizData(), clazz)); } } else { diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopMerchantServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopMerchantServiceImpl.java index 0e7c2bd8c..df1a7b176 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopMerchantServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopMerchantServiceImpl.java @@ -9,6 +9,9 @@ import com.czg.service.account.mapper.ShopMerchantMapper; import com.czg.utils.AssertUtil; import com.mybatisflex.spring.service.impl.ServiceImpl; import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import java.io.Serializable; @@ -18,6 +21,7 @@ import java.io.Serializable; * @author Administrator * @since 2025-02-11 */ +@CacheConfig(cacheNames = "shop:merchant") @DubboService public class ShopMerchantServiceImpl extends ServiceImpl implements ShopMerchantService { @@ -27,12 +31,12 @@ public class ShopMerchantServiceImpl extends ServiceImpl queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); return czgPayService.queryPayOrder(shopMerchant.getAppId(), shopMerchant.getAppSecret(), payOrderId, mchOrderNo); } @Override @Transactional public CzgResult queryRefund(@NonNull Long shopId, String mchRefundNo, String refundOrderId) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); return czgPayService.queryRefundOrder(shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId); } @@ -665,7 +666,7 @@ public class PayServiceImpl implements PayService { private CzgResult> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(), sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode())); CzgResult h5PayRespCzgResult = czgPayService.h5Pay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData); @@ -673,7 +674,7 @@ public class PayServiceImpl implements PayService { } private CzgResult> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid()); AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序"); bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(), @@ -684,7 +685,7 @@ public class PayServiceImpl implements PayService { } private CzgResult> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid()); AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序"); bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(), @@ -694,7 +695,7 @@ public class PayServiceImpl implements PayService { } private CzgResult> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(), sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode())); CzgResult scanPayRespCzgResult = czgPayService.scanPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData); @@ -703,7 +704,7 @@ public class PayServiceImpl implements PayService { private CzgResult> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) { AssertUtil.isBlank(bizData.getAuthCode(), "扫码失败,请重试"); - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(), sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode())); String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2); @@ -727,11 +728,19 @@ public class PayServiceImpl implements PayService { } private CzgResult refund(@NonNull Long shopId, CzgRefundReq bizData) { - ShopMerchant shopMerchant = shopMerchantService.getById(shopId); + ShopMerchant shopMerchant = getMerchant(shopId); bizData.setNotifyUrl(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_REFUND_NOTIFY_URL.getCode())); return czgPayService.refundOrder(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData); } + private ShopMerchant getMerchant(Long shopId) { + try { + return shopMerchantService.getById(shopId); + } catch (Exception e) { + throw new CzgException(e.getMessage()); + } + } + private CzgResult> execPayResult(CzgResult res) { CzgResult> result = CzgResult.success(); if (res.getCode() != 200 || res.getData() == null) {