mitao
2024-08-12 aeb379749ad10eabd54086e93231228a48c69843
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/PaylogServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.order.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeRefundRequest;
@@ -63,6 +64,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
@@ -73,6 +75,7 @@
 * @author mitao
 * @since 2024-05-22
 */
@Slf4j
@Service
public class PaylogServiceImpl extends ServiceImpl<PaylogMapper, Paylog> implements IPaylogService {
@@ -101,6 +104,7 @@
            HttpServletRequest request) {
        Member member = memberClient.getMembeOne(uid, SecurityConstants.INNER).getData();
        openId = member.getMiniOpenid();
        String zfbOpenid = member.getZfbOpenid();
        Double price = 0.0;
        String subject;
        String body;
@@ -169,7 +173,7 @@
                    subject = " 订单支付";
                    if (type == 1) {
                        // 支付宝预下单
                        return this.alipay(orderNO, subject, body, price, request);
                        return this.alipay(zfbOpenid, orderNO, subject, body, price, request);
                    } if (type == 2){
                        // 微信预下单
                        return this.wxpay(2 ,orderNO, body, openId, price, request);
@@ -185,7 +189,7 @@
                    Map<String, Object> map = new HashMap<String, Object>();
                    if (type == 1) {
                        // 支付宝预下单
                        return this.alipay(orderNO, subject, body, price, request);
                        return this.alipay(zfbOpenid, orderNO, subject, body, price, request);
                    } if (type == 2) {
                        // 微信预下单
                        return this.wxpay(2, orderNO, body,openId, price, request);
@@ -528,20 +532,24 @@
     * @param request
     * @return
     */
    public R<Map<String, Object>> alipay(String orderNo, String subject, String body, Double price,
    public R<Map<String, Object>> alipay(String zfbOpenid, String orderNo, String subject,
            String body, Double price,
                                         HttpServletRequest request) {
        try {
            // 接口封装支付宝请求参数
            // Map<String, Object> mData = new HashMap<String, Object>();
            // 构建请求支付签名参数
            Map<String, Object> pay = PayDemoActivity.appPay(subject, body, price, orderNo);
            // Map<String, Object> pay = PayDemoActivity.appPay(subject, body, price, orderNo);
            Map<String, Object> pay = PayDemoActivity.jsApiPay(subject, body, price, orderNo,
                    zfbOpenid);
            /*
             * Set<Entry<String, String>> entrySet = pay.entrySet();
             * Iterator<Entry<String, String>> iterator = entrySet.iterator();
             * while (iterator.hasNext()) { Entry<String, String> next =
             * iterator.next(); mData.put(next.getKey(), next.getValue()); }
             */
            log.info("支付宝预支付信息:{}", JSON.toJSONString(pay));
            return R.ok(pay);
        } catch (Exception e) {
            e.printStackTrace();