Merge remote-tracking branch 'origin/master'

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

View File

@ -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<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
shopMerchantEditDTO.setShopId(StpKit.USER.getLoginIdAsLong());
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
}
}

View File

@ -19,7 +19,7 @@ public class StatisticTask {
@Resource
private ShopOrderStatisticService shopOrderStatisticService;
// @Scheduled(cron = "0 0 18 * * ?")
@Scheduled(cron = "0 0 9 * * ?")
public void run() {
shopOrderStatisticService.statistic();
shopProdStatisticService.statistic();

View File

@ -8,6 +8,7 @@ import lombok.Data;
*/
@Data
public class ShopMerchantEditDTO {
private Long shopId;
@NotEmpty(message = "支付系统商户id不为空")
private String storeId;
@NotEmpty(message = "支付系统商户名称不为空")

View File

@ -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 {

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) {