运营端充值
This commit is contained in:
@@ -6,6 +6,7 @@ import com.czg.resp.CzgResult;
|
|||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.order.service.DistributionPayService;
|
import com.czg.service.order.service.DistributionPayService;
|
||||||
import com.czg.system.service.SysParamsService;
|
import com.czg.system.service.SysParamsService;
|
||||||
|
import com.czg.utils.AssertUtil;
|
||||||
import com.czg.utils.ServletUtil;
|
import com.czg.utils.ServletUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@@ -52,14 +53,14 @@ public class DistributionPayController {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运营端小程序支付
|
* 运营端小程序余额充值
|
||||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||||
* openId 必填
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("/mchRecharge")
|
@PostMapping("/mchRecharge")
|
||||||
@Debounce(value = "#payParam.userId")
|
@Debounce(value = "#payParam.userId")
|
||||||
public CzgResult<Map<String, String>> mchRecharge(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
public CzgResult<Map<String, String>> mchRecharge(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||||
payParam.setShopId(shopId);
|
payParam.setShopId(shopId);
|
||||||
|
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
|
||||||
return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
|
return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -7,14 +7,18 @@ import cn.hutool.core.util.RandomUtil;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.CzgPayUtils;
|
import com.czg.CzgPayUtils;
|
||||||
import com.czg.entity.CzgBaseRespParams;
|
import com.czg.entity.CzgBaseRespParams;
|
||||||
|
import com.czg.market.service.MkDistributionConfigService;
|
||||||
import com.czg.mq.PrintMqListener;
|
import com.czg.mq.PrintMqListener;
|
||||||
|
import com.czg.order.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderInfoService;
|
import com.czg.order.service.OrderInfoService;
|
||||||
|
import com.czg.order.service.OrderPaymentService;
|
||||||
import com.czg.order.service.ShopTableOrderStatisticService;
|
import com.czg.order.service.ShopTableOrderStatisticService;
|
||||||
import com.czg.service.Impl.WxServiceImpl;
|
import com.czg.service.Impl.WxServiceImpl;
|
||||||
import com.czg.system.service.WxService;
|
import com.czg.system.service.WxService;
|
||||||
import com.czg.task.StatisticTask;
|
import com.czg.task.StatisticTask;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import com.ijpay.core.kit.AesUtil;
|
import com.ijpay.core.kit.AesUtil;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -46,11 +50,15 @@ public class NotifyController {
|
|||||||
private ShopTableOrderStatisticService shopTableOrderStatisticService;
|
private ShopTableOrderStatisticService shopTableOrderStatisticService;
|
||||||
@Resource
|
@Resource
|
||||||
private WxService wxService;
|
private WxService wxService;
|
||||||
|
@Resource
|
||||||
|
private MkDistributionConfigService distributionConfigService;
|
||||||
|
@Resource
|
||||||
|
private OrderPaymentService paymentService;
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("testOpen")
|
@GetMapping("testOpen")
|
||||||
public Map<String, String> test1(String code) throws Exception {
|
public Map<String, String> test1(String code) throws Exception {
|
||||||
return wxService.v3Pay("oeQYq5LzW-kSxJL9TR4s_UmOmNLE", new BigDecimal("0.01"), "测试", "testZs" + RandomUtil.randomNumbers(20), "test");
|
return wxService.v3Pay("oeQYq5LzW-kSxJL9TR4s_UmOmNLE", new BigDecimal("0.01"), "测试", "testZs" + RandomUtil.randomNumbers(20), "distributionRecharge");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,7 +74,6 @@ public class NotifyController {
|
|||||||
|
|
||||||
@RequestMapping("/native/wx/pay/distributionRecharge")
|
@RequestMapping("/native/wx/pay/distributionRecharge")
|
||||||
public String nativeNotify(HttpServletRequest request) throws IOException {
|
public String nativeNotify(HttpServletRequest request) throws IOException {
|
||||||
|
|
||||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
String nonce = request.getHeader("Wechatpay-Nonce");
|
||||||
String serialNo = request.getHeader("Wechatpay-Serial");
|
String serialNo = request.getHeader("Wechatpay-Serial");
|
||||||
@@ -79,14 +86,19 @@ public class NotifyController {
|
|||||||
String nonceStr = resource.getString("nonce");
|
String nonceStr = resource.getString("nonce");
|
||||||
|
|
||||||
String plainText = wxService.decryptToString(associatedData, nonceStr, ciphertext);
|
String plainText = wxService.decryptToString(associatedData, nonceStr, ciphertext);
|
||||||
log.info("支付通知明文 {}", plainText);
|
log.info("充值支付通知明文 {}", plainText);
|
||||||
|
|
||||||
JSONObject plainTextJson = JSONObject.parseObject(plainText);
|
JSONObject plainTextJson = JSONObject.parseObject(plainText);
|
||||||
String outTradeNo = plainTextJson.getString("out_trade_no");
|
String outTradeNo = plainTextJson.getString("out_trade_no");
|
||||||
String tradeState = plainTextJson.getString("trade_state");
|
String tradeState = plainTextJson.getString("trade_state");
|
||||||
String transactionId = plainTextJson.getString("transaction_id");
|
String transactionId = plainTextJson.getString("transaction_id");
|
||||||
if ("SUCCESS" == tradeState) {
|
if ("SUCCESS".equals(tradeState)) {
|
||||||
|
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, outTradeNo));
|
||||||
|
payment.setTradeNumber(transactionId);
|
||||||
|
payment.setPayTime(DateUtil.date().toLocalDateTime());
|
||||||
|
payment.setRespJson(plainTextJson.toJSONString());
|
||||||
|
paymentService.updateById(payment);
|
||||||
|
distributionConfigService.rechargeCallBack(payment.getSourceId(), payment.getShopId(), payment.getAmount(), payment.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return "SUCCESS";
|
return "SUCCESS";
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ public record SysLoginDTO(
|
|||||||
@NotEmpty(message = "uid不为空")
|
@NotEmpty(message = "uid不为空")
|
||||||
String uuid, // 验证码uid
|
String uuid, // 验证码uid
|
||||||
@NotNull
|
@NotNull
|
||||||
Integer loginType // 登录类型 0:商户登录 1:员工登录
|
Integer loginType
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,4 +31,6 @@ public interface MkDistributionConfigService extends IService<MkDistributionConf
|
|||||||
* @param shopId 店铺id
|
* @param shopId 店铺id
|
||||||
*/
|
*/
|
||||||
void open(Long userId, BigDecimal amount, Long shopId, Long sourceId);
|
void open(Long userId, BigDecimal amount, Long shopId, Long sourceId);
|
||||||
|
|
||||||
|
void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,5 @@ public class MkDistributionPayDTO implements Serializable {
|
|||||||
private String buyerRemark;
|
private String buyerRemark;
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
private String remark;
|
private String remark;
|
||||||
|
private String code;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,4 +134,15 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl<MkDistributionC
|
|||||||
distributionUserService.addDistributionUser(new MkDistributionUser().setParentId(null).setShopId(shopId)
|
distributionUserService.addDistributionUser(new MkDistributionUser().setParentId(null).setShopId(shopId)
|
||||||
.setShopUserId(shopUserInfo.getId()).setOpeningMethod("付费开通"));
|
.setShopUserId(shopUserInfo.getId()).setOpeningMethod("付费开通"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId) {
|
||||||
|
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||||
|
BigDecimal finalAmount = shopInfoService.updateAmount(shopId, amount);
|
||||||
|
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||||
|
.setType(TableValueConstant.DistributionAmountFlow.Type.SELF_RECHARGE.getCode())
|
||||||
|
.setMainShopId(mainShopId).setShopId(shopId).setAmount(finalAmount).setChangeAmount(amount).setSourceId(paymentId)
|
||||||
|
.setRemark("自助充值").setOpAccount(StpKit.USER.getAccount()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.czg.service.order.service.impl;
|
package com.czg.service.order.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.account.entity.ShopInfo;
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
import com.czg.account.entity.UserInfo;
|
import com.czg.account.entity.UserInfo;
|
||||||
@@ -82,6 +83,11 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||||||
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
|
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
|
||||||
.setOpenId("aliPay".equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
|
.setOpenId("aliPay".equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(payParam.getCode())) {
|
||||||
|
String openId = wxService.getOpenId(payParam.getCode());
|
||||||
|
initInfo.setOpenId(openId);
|
||||||
|
}
|
||||||
return initInfo;
|
return initInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user