Browse Source

Merge remote-tracking branch 'origin/master'

raojiaolong@163.com 2 năm trước cách đây
mục cha
commit
2601e97181

+ 1 - 1
mhotel/src/com/happy/Until/TimeExchange.java

@@ -410,7 +410,7 @@ public class TimeExchange {
      * @throws ParseException
      * @throws ParseException
      */
      */
     public static boolean CompareDate(String dateOne, String dateTwo) throws ParseException {
     public static boolean CompareDate(String dateOne, String dateTwo) throws ParseException {
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date sd1=df.parse(dateOne);
         Date sd1=df.parse(dateOne);
         Date sd2=df.parse(dateTwo);
         Date sd2=df.parse(dateTwo);
         return sd1.before(sd2);
         return sd1.before(sd2);

+ 44 - 5
mhotel/src/com/happy/action/AppBookingAction.java

@@ -169,6 +169,45 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
         return null;
         return null;
     }
     }
 
 
+    /**
+     * 进行更新数据将订单状态修改为已超时。
+     * @return
+     */
+    public String updateOrderStatus()
+    {
+        JSONObject jsonObject = new JSONObject();
+        if (Func.checkNull(bookingId))
+        {
+            jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
+            jsonObject.put(B.message, "未传入bookingId---updateOrderStatus");
+            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        try {
+            Booking booking = bookService.getById(Func.parseInt(bookingId));
+            Date createTime = DateUtil.parseDate(booking.getCreateTime(),DateUtil.Time_Formatter_Second);
+            // 对订单时间进行累加
+            String lockTime = TimeExchange.TimeRangeM(DateUtil.getFormatPaternDate(createTime), Func.parseInt(booking.getLockTime()));
+            // 当前时间 大于 锁定时间 为true  且支付状态
+            boolean flag = TimeExchange.CompareDate(lockTime, TimeExchange.getDate());
+            if (flag)
+            {
+                // 如果超时,则将订单状态修改为已超时
+                booking.setOrderStatus(Func.parseStr(PayEnum.SIX.getNum()));
+                booking.setUpdateTime(TimeExchange.getDate());
+                bookService.updateBooking(booking);
+                System.out.println("已将订单"+booking.getOrderNum()+"标识为支付超时");
+
+                jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
+                jsonObject.put(B.message, "已将订单"+booking.getOrderNum()+"标识为支付超时");
+                ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            }
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+        return null;
+    }
 
 
 
 
     /**
     /**
@@ -704,7 +743,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
 
 
         Users users = userService.queryByOpenid(open_id); // 用户信息
         Users users = userService.queryByOpenid(open_id); // 用户信息
         Booking booking = bookService.getById(Func.parseInt(bookingId)); // 订单信息
         Booking booking = bookService.getById(Func.parseInt(bookingId)); // 订单信息
-        if (users == null || booking == null) {
+        if (users == null || booking == null || booking.getOrderStatus().equals(Func.parseStr(PayEnum.SIX.getNum()))) {
             resultjson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
             resultjson.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
             resultjson.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
             resultjson.put(B.message, ResultStatusCode.BAD_REQUEST.getMsg());
             ResponseUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
             ResponseUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
@@ -827,10 +866,10 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
                 {
                 {
                     // 自动接单,订单状态修改为待入住
                     // 自动接单,订单状态修改为待入住
                     booking.setOrderStatus(Func.parseStr(PayEnum.THREE.getNum()));
                     booking.setOrderStatus(Func.parseStr(PayEnum.THREE.getNum()));
-//                    String userId = booking.getCreateUserid();
-//                    Users users = userService.queryByUserId(userId);
-//                    String mess = "您已成功订房,订单号:"+order_num;
-//                    Message.send(users.getOpenid(),order_num, users.getUser_name(),mess, booking.getPayTime());
+                    String userId = booking.getCreateUserid();
+                    Users users = userService.queryByUserId(userId);
+                    String mess = "您已成功订房,订单号:"+order_num;
+                    Message.send(users.getOpenid(),order_num, users.getUser_name(),mess, booking.getPayTime());
                 }
                 }
 
 
                 // 手动接单,发消息给商家
                 // 手动接单,发消息给商家

+ 79 - 0
mhotel/src/com/happy/common/util/HttpSendFile.java

@@ -0,0 +1,79 @@
+package com.happy.common.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+/**
+ * 调用跨网文件发送接口
+ * @author tingh
+ *
+ */
+public class HttpSendFile {
+
+    private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8");
+
+    /**
+     * 调用文件发送接口
+     * @param file
+     * @param
+     * @param remote_url
+     * @return
+     */
+
+    public static Map<String, Object> call_sendFile(File file,String FileName,String remote_url){
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        Map<String, Object> responseMap = new HashMap<>();
+        String result = "";
+        try{
+            HttpPost httpPost = new HttpPost(remote_url);
+
+            //创建接口需要的参数
+            MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
+            entityBuilder.addPart("myFile", new FileBody(file));
+            entityBuilder.addPart("myFileFileName", new StringBody(FileName));
+            HttpEntity entity = entityBuilder.build();
+            httpPost.setEntity(entity);
+
+            //调用跨网文件发送接口
+            HttpResponse response = httpclient.execute(httpPost);
+            //获取响应信息
+            HttpEntity responseEntity = response.getEntity();
+            if(responseEntity != null){
+                result = EntityUtils.toString(responseEntity, CHARSET_UTF8);
+                System.out.println(result);
+            }
+            responseMap.put("code", response.getStatusLine().getStatusCode());
+            responseMap.put("result", result);
+        } catch (IOException e){
+            e.printStackTrace();
+        } catch (Exception e){
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+        return responseMap;
+    }
+
+    public static void main(String[] args) {
+        File file = new File("F://1.jpg");
+        call_sendFile(file,"1111.jpg","http://localhost:8088/fileload/loadhimage.action");
+    }
+}

+ 1 - 1
mhotel/src/com/happy/dao/impl/BookImplDao.java

@@ -182,7 +182,7 @@ public class BookImplDao implements BookDao {
     @Override
     @Override
     public List<Booking> queryPage(String sqlx, int page, int rows) {
     public List<Booking> queryPage(String sqlx, int page, int rows) {
         int start = (page - 1) * rows;// 每页的起始下标
         int start = (page - 1) * rows;// 每页的起始下标
-        String sql = "SELECT a.*,b.name hotel_township_name FROM booking a left join hotel_dict b on a.hotel_township = b.id WHERE is_delete=1 "+sqlx+" ORDER BY id DESC,pay_time DESC limit :start,:rows ";
+        String sql = "SELECT a.*,b.name hotel_township_name FROM booking a left join hotel_dict b on a.hotel_township = b.id WHERE is_delete=1 "+sqlx+" ORDER BY create_time DESC limit :start,:rows ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("start", start);
         sps.addValue("start", start);
         sps.addValue("rows", rows);
         sps.addValue("rows", rows);

+ 1 - 1
mhotel/src/struts.xml

@@ -33,7 +33,7 @@
 		</action>
 		</action>
 		<action name="book*" method = "{1}" class="com.happy.action.bookAction">
 		<action name="book*" method = "{1}" class="com.happy.action.bookAction">
 		</action>
 		</action>
-<!--		<action name="app*" method = "{1}" class="com.happy.action.appAction"></action>-->
+		<action name="app*" method = "{1}" class="com.happy.action.appAction"></action>
 		<action name="upload*" method = "{1}" class="com.happy.action.uploadAction">
 		<action name="upload*" method = "{1}" class="com.happy.action.uploadAction">
 		</action>
 		</action>
 		<action name="idc*" method = "{1}" class="com.happy.action.IDCAction">
 		<action name="idc*" method = "{1}" class="com.happy.action.IDCAction">

+ 11 - 11
mhotel/src/test2.java

@@ -1,4 +1,5 @@
 import com.happy.Model.weixin.Users;
 import com.happy.Model.weixin.Users;
+import com.happy.Until.DateUtil;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
 
 
 /**
 /**
@@ -10,17 +11,16 @@ import net.sf.json.JSONObject;
 public class test2 {
 public class test2 {
     public static void main(String[] args) throws InterruptedException {
     public static void main(String[] args) throws InterruptedException {
 
 
-//        JSONObject obj = new JSONObject();
-//        Users users = new Users();
-//        users.setUser_phone("321");
-//        users.setUser_name("321");
-//        users.setContactId(3);
-//        obj.put("map", users);
+        String start= "2023-02-03";
+        String end= "2023-04-05";
+//        System.out.println(DateUtil.convertTimeArea(start,end));
 
 
-//        System.out.printf(Func.parseStr(new Date()));
-//        for (int i = 0; i < 10; i++) {
-//            Thread.sleep(1000);
-//            System.out.println(i);
-//        }
+//
+//        String live_end = start.substring(0,10)  +"~"+  end.substring(0,10);
+//        System.out.println(live_end);
+
+        Double a = new Double(2);
+        Double b = new Double(3.5);
+        System.out.println(a*b);
     }
     }
 }
 }