101captain
2022-06-23 4ac787c26c39cc811051f6d3adb89604fd3b5414
bug修改
2个文件已修改
103 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java
@@ -211,7 +211,7 @@
    @ApiOperation("uu洗车下单接口")
    @GetMapping("/uuPay")
    public R uuPay(@RequestParam("orderid") String orderid,@RequestParam("openid")String openid,@RequestParam("amount")String amount){
        Map map=umfPayUtil.pay(openid, DateUtils.getCurrentDateString(),openid,amount);
        Map map=umfPayUtil.pay(orderid, DateUtils.getCurrentDateString(),openid,amount);
        return R.ok(map);
    }
}
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
@@ -12,8 +13,12 @@
import com.panzhihua.applets.umf.UmfPayUtil;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.HttpClientUtil;
import com.umf.api.service.UmfService;
import com.umf.api.service.UmfServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.json.XML;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;
@@ -23,6 +28,8 @@
import com.panzhihua.common.utlis.StringUtils;
import lombok.extern.slf4j.Slf4j;
import static com.umf.api.service.UmfServiceImpl.printResult;
/**
 * @auther lyq
@@ -38,6 +45,8 @@
    private CommunityService communityService;
    @Resource
    private UmfPayUtil umfPayUtil;
    @Value("${umf.file}")
    private String file;
    @PostMapping("wxNotify")
    public void payCallback(HttpServletRequest request, HttpServletResponse response) {
@@ -107,72 +116,42 @@
            e.printStackTrace();
        }
    }
    @PostMapping("wxNotifyAll")
    @GetMapping("wxNotifyAll")
    public void payCallbackAll(HttpServletRequest request, HttpServletResponse response) {
        log.info("微信支付回调start");
        String inputLine = "";
        String notityXml = "";
        //获取联动发送请求的参数
        String requestParam =  request.getQueryString();
        System.out.println("请求参数 :" + requestParam);
        //调用异步通知解析方法
        UmfService service = new UmfServiceImpl("53461",file);
        Map respMap = null;
        try {
            while ((inputLine = request.getReader().readLine()) != null) {
                notityXml += inputLine;
            }
            // 关闭流
            request.getReader().close();
            log.info("微信回调内容信息:" + notityXml);
            // 解析成Json
            org.json.JSONObject xmlJson = XML.toJSONObject(notityXml);
            if (StringUtils.isNotEmpty(xmlJson.toString())) {
                JSONObject resultData = JSON.parseObject(xmlJson.get("xml").toString());
                // 成功支付订单
                if (resultData.getString("result_code").equals("SUCCESS")
                        && resultData.getString("return_code").equals("SUCCESS")) {
                    WxPayNotifyOrderDTO notifyOrderDTO = new WxPayNotifyOrderDTO();
                    // 订单号
                    String orderTradeNo = resultData.getString("out_trade_no");
                    notifyOrderDTO.setOrderTradeNo(orderTradeNo);
                    // 微信支付订单号
                    String wxTradeNo = resultData.getString("transaction_id");
                    notifyOrderDTO.setWxTradeNo(wxTradeNo);
                    // 订单金额
                    String totalFee = resultData.getString("total_fee");
                    notifyOrderDTO.setTotalFee(totalFee);
                    // 支付完成时间
                    String payTime = resultData.getString("time_end");
                    notifyOrderDTO.setPayTime(payTime);
                    // 现金支付金额
                    String cashFee = resultData.getString("cash_fee");
                    notifyOrderDTO.setCashFee(cashFee);
                    // 封装 返回值
                    StringBuffer buffer = new StringBuffer();
                    buffer.append("<xml>");
                    buffer.append("<return_code>SUCCESS</return_code>");
                    buffer.append("<return_msg>OK</return_msg>");
                    buffer.append("</xml>");
                    // 给微信服务器返回 成功标示 否则会一直询问 咱们服务器 是否回调成功
                    PrintWriter writer = response.getWriter();
                    // 返回
                    writer.print(buffer.toString());
                } else {// 未成功支付订单
                    // 封装 返回值
                    StringBuffer buffer = new StringBuffer();
                    buffer.append("<xml>");
                    buffer.append("<return_code>FAIL</return_code>");
                    buffer.append("<return_msg>FAIL</return_msg>");
                    buffer.append("</xml>");
                    // 给微信服务器返回 成功标示 否则会一直询问 咱们服务器 是否回调成功
                    PrintWriter writer = response.getWriter();
                    // 返回
                    writer.print(buffer.toString());
                }
            }
            respMap = service.notifyDataParserMap(requestParam);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if(respMap.get("error_code").equals("0000")){
            //调用uu洗车支付成功回调
            Map map=new HashMap();
            map.put("orderId",respMap.get("order_id"));
            HttpClientUtil.sendPostByJson("https://api.uucsh.cn/notify/wx/pzh-pay",JSONObject.toJSONString(map),1,"","");;
        }
        //调用SDK生成返回联动平台字符串,加到CONTENT中
        String resMetaData = service.responseUMFMap(respMap);
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = null;
        try {
            out = response.getWriter();
        } catch (IOException e) {
            e.printStackTrace();
        }
        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
        out.println("<HTML>");
        out.println("<HEAD><META NAME=\"MobilePayPlatform\" CONTENT=\"" + resMetaData + "\" /></HEAD>");
        out.println("<BODY>");
        out.println("</BODY>");
        out.println("</HTML>");
        out.flush();
        out.close();
    }
    @ApiOperation("uu洗车退款接口")
    @GetMapping("/uuRepay")