Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai
2025-03-12 10:42:54 +08:00
6 changed files with 37 additions and 20 deletions

View File

@@ -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<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
@@ -27,12 +31,12 @@ public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, Sho
return one == null ? new ShopMerchant() : one;
}
@CacheEvict(key = "#shopMerchantEditDTO.id")
@Override
public Boolean edit(ShopMerchantEditDTO shopMerchantEditDTO) {
ShopMerchant shopMerchant = queryChain().eq(ShopMerchant::getShopId, StpKit.USER.getLoginIdAsLong()).one();
ShopMerchant shopMerchant = queryChain().eq(ShopMerchant::getShopId, shopMerchantEditDTO.getShopId()).one();
if (shopMerchant == null) {
shopMerchant = new ShopMerchant();
shopMerchant.setShopId(StpKit.USER.getLoginIdAsLong());
BeanUtil.copyProperties(shopMerchantEditDTO, shopMerchant);
return save(shopMerchant);
}
@@ -40,10 +44,11 @@ public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, Sho
return updateById(shopMerchant);
}
@Cacheable(key = "#id")
@Override
public ShopMerchant getById(Serializable id) {
ShopMerchant shopMerchant = getMapper().selectOneById(id);
AssertUtil.isNull(shopMerchant, "暂未开通支付");
return getMapper().selectOneById(id);
return shopMerchant;
}
}

View File

@@ -13,6 +13,7 @@ import com.czg.config.RedisCst;
import com.czg.entity.req.*;
import com.czg.entity.resp.*;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
import com.czg.exception.PaySuccessException;
import com.czg.order.dto.BigDecimalDTO;
import com.czg.order.dto.CheckOrderPay;
@@ -638,14 +639,14 @@ public class PayServiceImpl implements PayService {
@Override
@Transactional
public CzgResult<CzgBaseResp> 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<CzgRefundResp> 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<Map<String, Object>> 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<CzgH5PayResp> h5PayRespCzgResult = czgPayService.h5Pay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
@@ -673,7 +674,7 @@ public class PayServiceImpl implements PayService {
}
private CzgResult<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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<CzgScanPayResp> scanPayRespCzgResult = czgPayService.scanPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
@@ -703,7 +704,7 @@ public class PayServiceImpl implements PayService {
private CzgResult<Map<String, Object>> 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<CzgRefundResp> 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<Map<String, Object>> execPayResult(CzgResult<? extends CzgBaseResp> res) {
CzgResult<Map<String, Object>> result = CzgResult.success();
if (res.getCode() != 200 || res.getData() == null) {