Browse Source

退款功能

Administrator 2 years ago
parent
commit
7540be01be

+ 11 - 3
mhotel/src/com/happy/action/AppBookingAction.java

@@ -282,13 +282,21 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
         }
 
         Booking booking = bookService.getById(Func.parseInt(this.bookingId));
-        if (booking == null || Func.checkNull(booking.getRefundWay()))
+        if (booking == null )
          {
             jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
             jsonObject.put(B.message, "未获取到订单信息");
             ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
          }
+        if (Func.checkNull(booking.getRefundWay()) && Func.parseStr(PayEnum.SEVEN.getNum()).equals(booking.getOrderStatus()))
+        {
+            jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
+            jsonObject.put(B.message, "已取消订单");
+            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
 
         // 进行判断如果订单是退款中,并且标识字段微信退款,则进入退款流程
         if (Func.parseStr(PayEnum.TEN.getNum()).equals(booking.getOrderStatus()) && OrderEnum.微信退款.toString().equals(booking.getRefundWay())) {
@@ -517,7 +525,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
                 {
                     hotelName = book.getHouseName();
                 }
-                Message2.send(adminManager.getOpenid(),book.getOrderNum(),book.getHouseName(),live_end,book.getUserName(),hotelName);
+                Message2.send(adminManager.getOpenid(),book.getOrderNum(),book.getHouseName(),live_end,book.getUserName(),hotelName,Func.parseStr(book.getId()));
 
 
             }
@@ -751,7 +759,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
                     hotelName = booking.getHouseName();
                 }
                 System.out.println(adminManager.getOpenid()+"==="+order_num +"==="+booking.getHouseName()+"==="+live_end+"==="+booking.getUserName()+"==="+hotelName);
-                Message2.send(adminManager.getOpenid(),order_num,booking.getHouseName(),live_end,booking.getUserName(),hotelName);
+                Message2.send(adminManager.getOpenid(),order_num,booking.getHouseName(),live_end,booking.getUserName(),hotelName, Func.parseStr(booking.getId()));
 
                 int m = bookService.updateBooking(booking);
                 if (m>0){

+ 85 - 80
mhotel/src/com/happy/common/http/Message2.java

@@ -1,80 +1,85 @@
-package com.happy.common.http;
-
-import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-import com.happy.Model.Message.Mp_template_msg;
-import java.util.HashMap;
-
-/**
- * 公众号,推送信息,推给商家信息
- */
-public class Message2 {
-
-    /** 小程序推送消息到公众号
-     * openid:用户小程序openid, order_num订单号,
-     *  h_type房型, live_end入住和离店日期:2023-08-02~2023-08-06
-     *  user_name:用户名, hotel_name:酒店名
-     * **/
-    public static String send(String openid,String order_num,
-                              String h_type,String live_end,
-                              String user_name,String hotel_name)
-            throws Exception {
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("grant_type", "client_credential");
-        jsonObject.put("appid", "wx2fc3f45732fae5d3"); // 小程序
-        jsonObject.put("secret","7eee4a49a4470a77f9222995e8511547");
-        String msg3 = HttpsClient.sendJson2("https://api.weixin.qq.com/cgi-bin/stable_token",jsonObject);
-        Gson gson = new Gson();
-        HashMap<String, String> userMap = gson.fromJson(msg3.toString(), new TypeToken<HashMap<String, String>>() {}.getType());
-        JSONObject message = new JSONObject();
-        String token = userMap.get("access_token");
-        message.put("touser", openid);
-
-        Mp_template_msg mp_template_msg = new Mp_template_msg();
-        mp_template_msg.setAppid("wxa46ef222053a1047");  // 公众号
-        mp_template_msg.setTemplate_id("2qQLkDrxBpMcao35jONQSo8GIY6wwzFna-LLU7Q7qRM");
-        mp_template_msg.setUrl("index");
-        JSONObject jsonObject1 = new JSONObject();
-        jsonObject1.put("appid","wx2fc3f45732fae5d3");
-        jsonObject1.put("pagepath","pages/index/index");
-        mp_template_msg.setMiniprogram(jsonObject1);
-        // 订单号
-        JSONObject character_string1_ = new JSONObject();
-        character_string1_.put("value", order_num);
-        character_string1_.put("color", "#173177");
-        // 房型名称
-        JSONObject thing6 = new JSONObject();
-        thing6.put("value", h_type);
-        thing6.put("color", "#0000FF");
-        // 入离时间
-        JSONObject time11 = new JSONObject();
-        time11.put("value", live_end);
-        time11.put("color", "#173177");
-        // 客户名称
-        JSONObject thing10 = new JSONObject();
-        thing10.put("value", user_name);
-        thing10.put("color", "#173177");
-        // 酒店名称
-        JSONObject thing9_ = new JSONObject();
-        thing9_.put("value", hotel_name);
-        thing9_.put("color", "#173177");
-        // 封装data
-        JSONObject data = new JSONObject();
-        // 订单号
-        data.put("character_string1",character_string1_);
-        // 房型名称
-        data.put("thing6",thing6);
-        // 入离时间
-        data.put("time11",time11);
-        // 客户名称
-        data.put("thing10",thing10);
-        // 酒店名称
-        data.put("thing9",thing9_);
-        mp_template_msg.setData(data);
-        message.put("mp_template_msg",mp_template_msg);
-        return HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token="+token, message);
-    }
-
-
-}
+package com.happy.common.http;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.happy.Model.Message.Mp_template_msg;
+import java.util.HashMap;
+
+/**
+ * 公众号,推送信息,推给商家信息
+ */
+public class Message2 {
+
+    /** 小程序推送消息到公众号
+     * openid:用户小程序openid, order_num订单号,
+     *  h_type房型, live_end入住和离店日期:2023-08-02~2023-08-06
+     *  user_name:用户名, hotel_name:酒店名
+     * **/
+    public static String send(String openid,String order_num,
+                              String h_type,String live_end,
+                              String user_name,String hotel_name,String id)
+            throws Exception {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("grant_type", "client_credential");
+        jsonObject.put("appid", "wx2fc3f45732fae5d3"); // 小程序
+        jsonObject.put("secret","7eee4a49a4470a77f9222995e8511547");
+        String msg3 = HttpsClient.sendJson2("https://api.weixin.qq.com/cgi-bin/stable_token",jsonObject);
+        Gson gson = new Gson();
+        HashMap<String, String> userMap = gson.fromJson(msg3.toString(), new TypeToken<HashMap<String, String>>() {}.getType());
+        JSONObject message = new JSONObject();
+        String token = userMap.get("access_token");
+        message.put("touser", openid);
+
+        Mp_template_msg mp_template_msg = new Mp_template_msg();
+        mp_template_msg.setAppid("wxa46ef222053a1047");  // 公众号
+        mp_template_msg.setTemplate_id("2qQLkDrxBpMcao35jONQSo8GIY6wwzFna-LLU7Q7qRM");
+        mp_template_msg.setUrl("index");
+        JSONObject jsonObject1 = new JSONObject();
+        jsonObject1.put("appid","wx2fc3f45732fae5d3");
+        jsonObject1.put("pagepath","/pages/push/push?id="+id);
+        mp_template_msg.setMiniprogram(jsonObject1);
+        // 订单号
+        JSONObject character_string1_ = new JSONObject();
+        character_string1_.put("value", order_num);
+        character_string1_.put("color", "#173177");
+        // 房型名称
+        JSONObject thing6 = new JSONObject();
+        thing6.put("value", h_type);
+        thing6.put("color", "#0000FF");
+        // 入离时间
+        JSONObject time11 = new JSONObject();
+        time11.put("value", live_end);
+        time11.put("color", "#173177");
+        // 客户名称
+        JSONObject thing10 = new JSONObject();
+        thing10.put("value", user_name);
+        thing10.put("color", "#173177");
+        // 酒店名称
+        JSONObject thing9_ = new JSONObject();
+        thing9_.put("value", hotel_name);
+        thing9_.put("color", "#173177");
+        // 封装data
+        JSONObject data = new JSONObject();
+        // 订单号
+        data.put("character_string1",character_string1_);
+        // 房型名称
+        data.put("thing6",thing6);
+        // 入离时间
+        data.put("time11",time11);
+        // 客户名称
+        data.put("thing10",thing10);
+        // 酒店名称
+        data.put("thing9",thing9_);
+        mp_template_msg.setData(data);
+        message.put("mp_template_msg",mp_template_msg);
+        return HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token="+token, message);
+    }
+
+    public static void main(String[] args) throws Exception {
+        String msg = send("oz3gK5m2JQORvn9ruKoT33TSA7Wk","2308082018488183",
+                "小三房","2023-08-08~2023-08-08",
+                "xieli测试数据","aaaa","1111");
+        System.out.println(msg);
+    }
+}

+ 1 - 1
mhotel/src/com/happy/service/impl/BookImplService.java

@@ -112,7 +112,7 @@ public class BookImplService implements BookService {
             book.setOrderStatus(Func.parseStr(PayEnum.TEN.getNum()));
             book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
             // 注明需要退款: (标识走退款操作)
-            book.setPayWay(OrderEnum.微信退款.toString());
+            book.setRefundWay(OrderEnum.微信退款.toString());
             bookDao.updateBooking(book);
 
             String sendMsg = "订单:"+ book.getOrderNum() +"已取消";