admin
2020-04-13 dd5b15229cb15459fa7c31ccea77dac28cbfafbd
fanli/src/main/java/com/yeshi/fanli/util/wx/BanLiShopWXPayUtil.java
@@ -9,6 +9,7 @@
import org.yeshi.utils.exception.WXOrderException;
import org.yeshi.utils.exception.WXPlaceOrderParamsException;
import org.yeshi.utils.wx.WXPayUtil;
import org.yeshi.utils.wx.WXUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.shop.BanLiShopOrderUtil;
@@ -32,7 +33,7 @@
    * @param money
    * @return
    */
   public static String getWXH5PayUrl(String orderNo, String ip, String goodsName, BigDecimal money) {
   public static String getWXH5PayUrl(String orderNo, String ip, String goodsName, BigDecimal money, String platform) {
      String wxOrderNo = BanLiShopOrderUtil.getWXPayOrderNo(orderNo);
      WXPlaceOrderParams params = new WXPlaceOrderParams();
      params.setBody(goodsName);
@@ -46,8 +47,14 @@
      params.setTradeType("MWEB");
      try {
         Map<String, String> map = WXPayUtil.produceOrder(params);
         return map.get("mweb_url") + "&redirect_url=" + URLEncoder
               .encode("http://test.banliapp.com/flqFront/AppInside/shop/wx_pay_success.html", "UTF-8");
         if ("ios".equalsIgnoreCase(platform))
            return map.get("mweb_url") + "&redirect_url="
                  + URLEncoder.encode("shop.banliapp.com://shop.banliapp.com/wx_pay_finish.html", "UTF-8");
         else
            return map.get("mweb_url") + "&redirect_url="
                  + URLEncoder.encode("http://shop.banliapp.com/wx_pay_finish.html", "UTF-8");
      } catch (WXPlaceOrderParamsException e) {
         e.printStackTrace();
      } catch (Exception e) {
@@ -66,7 +73,8 @@
   public static boolean refund(String orderNo, BigDecimal money) throws WXOrderException {
      boolean success = WXPayUtil.refund(BanLiShopOrderUtil.getWXPayOrderNo(orderNo), money, money, null,
            new WXAPPInfo(Constant.getWXAccount(null, null).getGzAppId(),
                  Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY), MCH_ID, BanLiShopWXPayUtil.class.getClassLoader().getResourceAsStream(MCH_CERT_PATH));
                  Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY),
            MCH_ID, BanLiShopWXPayUtil.class.getClassLoader().getResourceAsStream(MCH_CERT_PATH));
      return success;
   }
@@ -76,4 +84,29 @@
                  Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY));
   }
   /**
    * 是否支付成功
    *
    * @param orderNo
    * @return
    * @throws WXOrderException
    */
   public static boolean isPaySuccess(String orderNo) throws WXOrderException {
      return WXPayUtil.isPaySuccess(BanLiShopOrderUtil.getWXPayOrderNo(orderNo),
            new WXAPPInfo(Constant.getWXAccount(null, null).getGzAppId(),
                  Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY));
   }
   /**
    * 签名是否正确
    *
    * @param params
    * @param sign
    * @return
    */
   public static boolean signIsRight(Map<String, String> params, String sign) {
      String newSign = WXUtil.getSignMD5(params, MCH_KEY);
      return newSign.equalsIgnoreCase(sign);
   }
}