From d99a56e37cf9109b46ee68d34a06594ef5615ed3 Mon Sep 17 00:00:00 2001
From: 张天森 <1292933220@qq.com>
Date: 星期四, 10 十一月 2022 16:06:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/huacheng_test' into huacheng_test

---
 springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 110 insertions(+), 5 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java
index b819486..edb9839 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxCallbackApi.java
@@ -2,16 +2,27 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.panzhihua.applets.umf.MyAESUtil;
+import com.panzhihua.applets.umf.UmfPayUtil;
+import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.service.user.UserService;
+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 com.panzhihua.common.service.community.ComBatteryCommodityOrderFeign;
 import org.json.XML;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -20,6 +31,8 @@
 import com.panzhihua.common.utlis.StringUtils;
 
 import lombok.extern.slf4j.Slf4j;
+
+import static com.umf.api.service.UmfServiceImpl.printResult;
 
 /**
  * @auther lyq
@@ -36,12 +49,18 @@
     @Resource
     private CommunityService communityService;
     @Resource
+    private UmfPayUtil umfPayUtil;
+    @Value("${umf.file}")
+    private String file;
+    @Resource
+    private UserService userService;
+    @Resource
     private ComBatteryCommodityOrderFeign commodityOrderFeign;
 
 
     @PostMapping("wxNotify")
     public void payCallback(HttpServletRequest request, HttpServletResponse response) {
-        log.info("微信支付回调start");
+        log.error("微信支付回调start");
         String inputLine = "";
         String notityXml = "";
         try {
@@ -50,7 +69,7 @@
             }
             // 关闭流
             request.getReader().close();
-            log.info("微信回调内容信息:" + notityXml);
+            log.error("微信回调内容信息:" + notityXml);
             // 解析成Json
             org.json.JSONObject xmlJson = XML.toJSONObject(notityXml);
             if (StringUtils.isNotEmpty(xmlJson.toString())) {
@@ -106,6 +125,87 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
+    }
+    @GetMapping("wxNotifyAll")
+    public void payCallbackAll(HttpServletRequest request, HttpServletResponse response) {
+        //获取联动发送请求的参数
+        String requestParam =  request.getQueryString();
+        System.out.println("请求参数 :" + requestParam);
+        //调用异步通知解析方法
+        UmfService service = new UmfServiceImpl("53461",file);
+        Map respMap = null;
+        try {
+            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,"appid","10000");;
+        }
+        //调用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洗车退款接口")
+    @PostMapping("/uuRepay")
+    public R uuRepay(@RequestBody String aesString){
+        try {
+            Map<String, String> aesMap= (Map<String, String>) JSON.parse(aesString);
+            String desString=MyAESUtil.Decrypt(aesMap.get("aesString"),"Ryo7M3n8loC5Abcd");
+            Map<String,String> desMap= (Map) JSON.parse(desString);
+            Map map=umfPayUtil.repay(desMap.get("orderId"),desMap.get("merdate"), DateUtils.getDateFormatString(new Date(),"yyMMddHHmmss")+"0001",desMap.get("refundAmount"),desMap.get("orgAmount"));
+            return R.ok(map);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail("加密验证失败");
+        }
+
+    }
+    @ApiOperation("uu洗车推送")
+    @PostMapping("/uuPush")
+    public R uuPush(@RequestBody String aesString){
+        try {
+            Map<String, String> aesMap= (Map<String, String>) JSON.parse(aesString);
+            String desString=MyAESUtil.Decrypt(aesMap.get("aesString"),"Ryo7M3n8loC5Abcd");
+            Map<String,String> desMap= (Map) JSON.parse(desString);
+            return userService.uuPush(desMap.get("washer_mobile"),desMap.get("phone"),desMap.get("washer_name"),Integer.parseInt(desMap.get("order_status")));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail("推送失败");
+        }
+
+    }
+    @ApiOperation("ws洗车推送")
+    @PostMapping("/wsPush")
+    public R wsPush(@RequestBody String aesString){
+        try {
+            Map<String, String> aesMap= (Map<String, String>) JSON.parse(aesString);
+            String desString=MyAESUtil.Decrypt(aesMap.get("aesString"),"Ryo7M3n8loC5Abcd");
+            Map<String,String> desMap= (Map) JSON.parse(desString);
+            return userService.wsPush(desMap.get("washer_mobile"),desMap.get("phone"),desMap.get("washer_name"),Integer.parseInt(desMap.get("order_status")));
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail("推送失败");
+        }
+
     }
 
     /**
@@ -243,4 +343,9 @@
         buffer.append("</xml>");
         return buffer.toString();
     }
+
+    @GetMapping("/settle")
+    public R settle(String settleDate){
+        return R.ok(umfPayUtil.settle(settleDate));
+    }
 }

--
Gitblit v1.7.1