admin
2021-02-19 58577bae968f2a10232bc8b3c04910b93ea3c69a
src/main/java/com/yeshi/buwan/controller/WXController.java
@@ -1,6 +1,9 @@
package com.yeshi.buwan.controller;
import com.yeshi.buwan.service.inter.vip.VIPService;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.user.VipUtil;
import com.yeshi.buwan.util.vip.VIPOrderUtil;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
@@ -8,8 +11,8 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.entity.wx.WXAPPInfo;
import org.yeshi.utils.wx.WXPayV3Util;
import javax.annotation.Resource;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.GCMParameterSpec;
@@ -17,6 +20,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@@ -27,6 +32,9 @@
@RequestMapping("wx")
public class WXController {
    Logger logger = LoggerFactory.getLogger(WXController.class);
    @Resource
    private VIPService vipService;
    private static String decryptToString(String apiV3Key, String associatedData, String nonce, String ciphertext)
            throws GeneralSecurityException, IOException {
@@ -53,7 +61,7 @@
     * @throws Exception
     */
    private void process(HttpServletRequest request) throws Exception {
        WXAPPInfo wxappInfo = new WXAPPInfo();
        WXAPPInfo wxappInfo = VipUtil.getWXAPP();
        //验证证书序列号
        String mchSerialNo = request.getHeader("Wechatpay-Serial");
        if (!mchSerialNo.equalsIgnoreCase(wxappInfo.getMchSerialNo())) {
@@ -96,15 +104,11 @@
                String tradeState = decript.optString("trade_state");
                //支付成功
                if (tradeState.equalsIgnoreCase("SUCCESS")) {
                    boolean isPaySuccess = WXPayV3Util.isPaySuccess(outTradeNo, wxappInfo);
                    if (isPaySuccess) {
                        //TODO 支付成功
                    }
                    String id = VIPOrderUtil.getIdFromOutOrderNo(outTradeNo);
                    vipService.checkOrderPayState(id);
                }
                break;
        }
    }