|
@@ -30,9 +30,11 @@ import java.io.BufferedReader;
|
|
|
import java.io.PrintWriter;
|
|
import java.io.PrintWriter;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -160,30 +162,29 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 定时任务
|
|
* 定时任务
|
|
|
|
|
+ *
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public String scheduledTasks()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public String scheduledTasks() {
|
|
|
// 获取所有的订单待支付状态
|
|
// 获取所有的订单待支付状态
|
|
|
StringBuffer strSqlBook = new StringBuffer();
|
|
StringBuffer strSqlBook = new StringBuffer();
|
|
|
strSqlBook.append(" and order_status = '").append(PayEnum.待支付.getNum()).append("' ");
|
|
strSqlBook.append(" and order_status = '").append(PayEnum.待支付.getNum()).append("' ");
|
|
|
List<Booking> bookingList = bookService.queryList(strSqlBook.toString());
|
|
List<Booking> bookingList = bookService.queryList(strSqlBook.toString());
|
|
|
- if (bookingList == null || bookingList.size() <= 0){
|
|
|
|
|
|
|
+ if (bookingList == null || bookingList.size() <= 0) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- for (Booking booking: bookingList) {
|
|
|
|
|
- if (booking == null || Func.checkNull(booking.getCreateTime()) || Func.checkNull(booking.getLockTime()))
|
|
|
|
|
|
|
+ for (Booking booking : bookingList) {
|
|
|
|
|
+ if (booking == null || Func.checkNull(booking.getCreateTime()) || Func.checkNull(booking.getLockTime()))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
- Date createTime = DateUtil.parseDate(booking.getCreateTime(),DateUtil.Time_Formatter_Second);
|
|
|
|
|
|
|
+ Date createTime = DateUtil.parseDate(booking.getCreateTime(), DateUtil.Time_Formatter_Second);
|
|
|
// 对订单时间进行累加
|
|
// 对订单时间进行累加
|
|
|
- String lockTime = TimeExchange.TimeRangeM(DateUtil.getFormatPaternDate(createTime),Func.parseInt(booking.getLockTime()));
|
|
|
|
|
|
|
+ String lockTime = TimeExchange.TimeRangeM(DateUtil.getFormatPaternDate(createTime), Func.parseInt(booking.getLockTime()));
|
|
|
// 当前时间 大于 锁定时间 为true 且支付状态
|
|
// 当前时间 大于 锁定时间 为true 且支付状态
|
|
|
boolean flag = TimeExchange.CompareDate(lockTime, TimeExchange.getDate());
|
|
boolean flag = TimeExchange.CompareDate(lockTime, TimeExchange.getDate());
|
|
|
- if (flag)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (flag) {
|
|
|
// 如果超时,则将订单状态修改为已超时
|
|
// 如果超时,则将订单状态修改为已超时
|
|
|
booking.setOrderStatus(Func.parseStr(PayEnum.支付超时.getNum()));
|
|
booking.setOrderStatus(Func.parseStr(PayEnum.支付超时.getNum()));
|
|
|
booking.setUpdateTime(TimeExchange.getDate());
|
|
booking.setUpdateTime(TimeExchange.getDate());
|
|
@@ -195,7 +196,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
// 将状态修改为已超时订单时,写入数据操作
|
|
// 将状态修改为已超时订单时,写入数据操作
|
|
|
bookinglogService.addBooklog(OrderEnum.将订单设置为已超时.toString(), booking);
|
|
bookinglogService.addBooklog(OrderEnum.将订单设置为已超时.toString(), booking);
|
|
|
|
|
|
|
|
- System.out.println("已将订单"+booking.getOrderNum()+"标识为支付超时");
|
|
|
|
|
|
|
+ System.out.println("已将订单" + booking.getOrderNum() + "标识为支付超时");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -208,13 +209,12 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 进行更新数据将订单状态修改为已超时。
|
|
* 进行更新数据将订单状态修改为已超时。
|
|
|
|
|
+ *
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public String updateOrderStatus()
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public String updateOrderStatus() {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- if (Func.checkNull(bookingId))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (Func.checkNull(bookingId)) {
|
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
jsonObject.put(B.message, "未传入bookingId---updateOrderStatus");
|
|
jsonObject.put(B.message, "未传入bookingId---updateOrderStatus");
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
@@ -223,20 +223,19 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
Booking booking = bookService.getById(Func.parseInt(bookingId));
|
|
Booking booking = bookService.getById(Func.parseInt(bookingId));
|
|
|
- Date createTime = DateUtil.parseDate(booking.getCreateTime(),DateUtil.Time_Formatter_Second);
|
|
|
|
|
|
|
+ Date createTime = DateUtil.parseDate(booking.getCreateTime(), DateUtil.Time_Formatter_Second);
|
|
|
// 对订单时间进行累加
|
|
// 对订单时间进行累加
|
|
|
String lockTime = TimeExchange.TimeRangeM(DateUtil.getFormatPaternDate(createTime), Func.parseInt(booking.getLockTime()));
|
|
String lockTime = TimeExchange.TimeRangeM(DateUtil.getFormatPaternDate(createTime), Func.parseInt(booking.getLockTime()));
|
|
|
// 当前时间 大于 锁定时间 为true 且支付状态
|
|
// 当前时间 大于 锁定时间 为true 且支付状态
|
|
|
boolean flag = TimeExchange.CompareDate(lockTime, TimeExchange.getDate());
|
|
boolean flag = TimeExchange.CompareDate(lockTime, TimeExchange.getDate());
|
|
|
- if (flag)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (flag) {
|
|
|
// 如果超时,则将订单状态修改为已超时
|
|
// 如果超时,则将订单状态修改为已超时
|
|
|
booking.setOrderStatus(Func.parseStr(PayEnum.支付超时.getNum()));
|
|
booking.setOrderStatus(Func.parseStr(PayEnum.支付超时.getNum()));
|
|
|
booking.setUpdateTime(TimeExchange.getDate());
|
|
booking.setUpdateTime(TimeExchange.getDate());
|
|
|
bookService.updateBooking(booking);
|
|
bookService.updateBooking(booking);
|
|
|
|
|
|
|
|
// 将状态修改为已超时订单时,写入数据操作
|
|
// 将状态修改为已超时订单时,写入数据操作
|
|
|
- bookinglogService.addBooklog(OrderEnum.将订单设置为已超时.toString(),booking);
|
|
|
|
|
|
|
+ bookinglogService.addBooklog(OrderEnum.将订单设置为已超时.toString(), booking);
|
|
|
|
|
|
|
|
List<HotelCouponStatus> list = hotelCoupomStatusService.getBookingId(booking.getId() + "");
|
|
List<HotelCouponStatus> list = hotelCoupomStatusService.getBookingId(booking.getId() + "");
|
|
|
if (list != null && list.size() > 0) {
|
|
if (list != null && list.size() > 0) {
|
|
@@ -246,7 +245,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
System.out.println("已将订单" + booking.getOrderNum() + "标识为支付超时");
|
|
System.out.println("已将订单" + booking.getOrderNum() + "标识为支付超时");
|
|
|
|
|
|
|
|
jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
|
|
|
- jsonObject.put(B.message, "已将订单"+booking.getOrderNum()+"标识为支付超时");
|
|
|
|
|
|
|
+ jsonObject.put(B.message, "已将订单" + booking.getOrderNum() + "标识为支付超时");
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
}
|
|
}
|
|
|
} catch (ParseException e) {
|
|
} catch (ParseException e) {
|
|
@@ -282,7 +281,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
String endDate = DateUtil.parseDateToStr((Func.parseDate(endTime)), DateUtil.Time_Formatter_Day);
|
|
String endDate = DateUtil.parseDateToStr((Func.parseDate(endTime)), DateUtil.Time_Formatter_Day);
|
|
|
|
|
|
|
|
// 创建订单之前,先验证是否有房间
|
|
// 创建订单之前,先验证是否有房间
|
|
|
- String backMessage = appBookService.varificationHouse(houseId, startDate, endDate,houseOrderNumber);
|
|
|
|
|
|
|
+ String backMessage = appBookService.varificationHouse(houseId, startDate, endDate, houseOrderNumber);
|
|
|
if (!Func.checkNull(backMessage)) {
|
|
if (!Func.checkNull(backMessage)) {
|
|
|
jsonObject.put(B.code, ResultStatusCode.CANNTBOOKING.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.CANNTBOOKING.getStatus());
|
|
|
jsonObject.put(B.message, backMessage);
|
|
jsonObject.put(B.message, backMessage);
|
|
@@ -310,7 +309,8 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
/**
|
|
/**
|
|
|
* bookingId 订单id
|
|
* bookingId 订单id
|
|
|
* 商家在已支付,待入住时点退单 ,进入退款流程后退单
|
|
* 商家在已支付,待入住时点退单 ,进入退款流程后退单
|
|
|
- * 在已入住,时点退单,进入退款流程后退款
|
|
|
|
|
|
|
+ * 在已入住,时点退单,进入退款流程后退款
|
|
|
|
|
+ *
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public String chargeback() throws Exception {
|
|
public String chargeback() throws Exception {
|
|
@@ -325,8 +325,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
//1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款,10退款中
|
|
//1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款,10退款中
|
|
|
int status = Func.parseInt(book.getOrderStatus());
|
|
int status = Func.parseInt(book.getOrderStatus());
|
|
|
- if (status == PayEnum.待支付.getNum())
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (status == PayEnum.待支付.getNum()) {
|
|
|
book.setOrderStatus(Func.parseStr(PayEnum.已取消.getNum())); // 如果在1待支付情况,用户点击取消订单按钮,后台直接修改取消订单操作
|
|
book.setOrderStatus(Func.parseStr(PayEnum.已取消.getNum())); // 如果在1待支付情况,用户点击取消订单按钮,后台直接修改取消订单操作
|
|
|
book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
|
|
book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
|
|
|
bookService.updateBooking(book);
|
|
bookService.updateBooking(book);
|
|
@@ -343,8 +342,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
|
|
jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
- }else if (status == PayEnum.已支付.getNum() || status == PayEnum.待入住.getNum())
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (status == PayEnum.已支付.getNum() || status == PayEnum.待入住.getNum()) {
|
|
|
book.setOrderStatus(Func.parseStr(PayEnum.退款中.getNum())); // 如果在2已支付,3待入住 情况,商家点击取消订单按钮,后台先修改状态为退款中,然后走退款流程
|
|
book.setOrderStatus(Func.parseStr(PayEnum.退款中.getNum())); // 如果在2已支付,3待入住 情况,商家点击取消订单按钮,后台先修改状态为退款中,然后走退款流程
|
|
|
book.setRemake(Func.parseStr(PayEnum.已退单.getPayStatus()));
|
|
book.setRemake(Func.parseStr(PayEnum.已退单.getPayStatus()));
|
|
|
List<HotelCouponStatus> list = hotelCoupomStatusService.getBookingId(book.getId() + "");
|
|
List<HotelCouponStatus> list = hotelCoupomStatusService.getBookingId(book.getId() + "");
|
|
@@ -365,7 +363,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
book.setRefundWay(OrderEnum.微信退款.toString());
|
|
book.setRefundWay(OrderEnum.微信退款.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- jsonObject = refundMethod(book,users.getOpenid());
|
|
|
|
|
|
|
+ jsonObject = refundMethod(book, users.getOpenid());
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -390,7 +388,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
// 取消订单,修改订单的支付状态
|
|
// 取消订单,修改订单的支付状态
|
|
|
Booking book = bookService.getById(Func.parseInt(bookingId));
|
|
Booking book = bookService.getById(Func.parseInt(bookingId));
|
|
|
- if (book == null ) {
|
|
|
|
|
|
|
+ if (book == null) {
|
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
jsonObject.put(B.message, "未获取到订单信息,请重新查询");
|
|
jsonObject.put(B.message, "未获取到订单信息,请重新查询");
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
@@ -450,7 +448,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
// 退款操作
|
|
// 退款操作
|
|
|
book.setRemake(Func.parseStr(PayEnum.已取消.getPayStatus()));
|
|
book.setRemake(Func.parseStr(PayEnum.已取消.getPayStatus()));
|
|
|
book.setRefundWay(OrderEnum.微信退款.toString());
|
|
book.setRefundWay(OrderEnum.微信退款.toString());
|
|
|
- jsonObject = refundMethod(book,users.getOpenid());
|
|
|
|
|
|
|
+ jsonObject = refundMethod(book, users.getOpenid());
|
|
|
jsonObject.put(B.data, book);
|
|
jsonObject.put(B.data, book);
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
@@ -458,13 +456,14 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 退款方法
|
|
* 退款方法
|
|
|
|
|
+ *
|
|
|
* @param book
|
|
* @param book
|
|
|
* @param open_id
|
|
* @param open_id
|
|
|
* @return
|
|
* @return
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
- public JSONObject refundMethod(Booking book,String open_id) throws Exception {
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
+ public JSONObject refundMethod(Booking book, String open_id) throws Exception {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
if (book == null || Func.checkNull(open_id)) {
|
|
if (book == null || Func.checkNull(open_id)) {
|
|
|
jsonObject.put("code", 400);
|
|
jsonObject.put("code", 400);
|
|
|
jsonObject.put("message", "未传入book和open_id数据---refundMethod");
|
|
jsonObject.put("message", "未传入book和open_id数据---refundMethod");
|
|
@@ -496,7 +495,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
params.put("notify_url", w.getNotify_url());
|
|
params.put("notify_url", w.getNotify_url());
|
|
|
params.put("out_refund_no", w.getOut_refund_no()); // 退款单号
|
|
params.put("out_refund_no", w.getOut_refund_no()); // 退款单号
|
|
|
params.put("out_trade_no", w.getOut_trade_no());
|
|
params.put("out_trade_no", w.getOut_trade_no());
|
|
|
- params.put("refund_fee",w.getRefund_fee()+""); // 退款金额
|
|
|
|
|
|
|
+ params.put("refund_fee", w.getRefund_fee() + ""); // 退款金额
|
|
|
params.put("total_fee", w.getTotal_fee() + "");
|
|
params.put("total_fee", w.getTotal_fee() + "");
|
|
|
|
|
|
|
|
w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
|
|
w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
|
|
@@ -508,10 +507,10 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
"<nonce_str>" + w.getNonce_str() + "</nonce_str>" +
|
|
"<nonce_str>" + w.getNonce_str() + "</nonce_str>" +
|
|
|
"<notify_url>" + w.getNotify_url() + "</notify_url>" +
|
|
"<notify_url>" + w.getNotify_url() + "</notify_url>" +
|
|
|
"<out_refund_no>" + w.getOut_refund_no() + "</out_refund_no>" +
|
|
"<out_refund_no>" + w.getOut_refund_no() + "</out_refund_no>" +
|
|
|
- "<out_trade_no>" + w.getOut_trade_no() + "</out_trade_no>" +
|
|
|
|
|
- "<refund_fee>" + w.getRefund_fee()+"" + "</refund_fee>" +
|
|
|
|
|
|
|
+ "<out_trade_no>" + w.getOut_trade_no() + "</out_trade_no>" +
|
|
|
|
|
+ "<refund_fee>" + w.getRefund_fee() + "" + "</refund_fee>" +
|
|
|
"<total_fee>" + w.getTotal_fee() + "" + "</total_fee>" +
|
|
"<total_fee>" + w.getTotal_fee() + "" + "</total_fee>" +
|
|
|
- "<sign>" + w.getSign() + "</sign>" +
|
|
|
|
|
|
|
+ "<sign>" + w.getSign() + "</sign>" +
|
|
|
"</xml>";
|
|
"</xml>";
|
|
|
//String msg = HttpsClient.sendPost2("https://api.mch.weixin.qq.com/secapi/pay/refund", retXml);
|
|
//String msg = HttpsClient.sendPost2("https://api.mch.weixin.qq.com/secapi/pay/refund", retXml);
|
|
|
String msg = HttpUtils.post2("https://api.mch.weixin.qq.com/secapi/pay/refund", xml);
|
|
String msg = HttpUtils.post2("https://api.mch.weixin.qq.com/secapi/pay/refund", xml);
|
|
@@ -523,10 +522,10 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
}
|
|
}
|
|
|
// 设置订单状态为退款中
|
|
// 设置订单状态为退款中
|
|
|
book.setOrderStatus(Func.parseStr(PayEnum.退款中.getNum()));
|
|
book.setOrderStatus(Func.parseStr(PayEnum.退款中.getNum()));
|
|
|
- book.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
|
|
|
|
|
|
|
+ book.setUpdateTime(DateUtil.parseDateToStr(new Date(), DateUtil.Time_Formatter_Second));
|
|
|
bookService.updateBooking(book); // 退款中
|
|
bookService.updateBooking(book); // 退款中
|
|
|
// 用户在待支付状态下取消了订单时,写入数据操作
|
|
// 用户在待支付状态下取消了订单时,写入数据操作
|
|
|
- bookinglogService.addBooklog("用户在取消了订单,正进入退款流程",book);
|
|
|
|
|
|
|
+ bookinglogService.addBooklog("用户在取消了订单,正进入退款流程", book);
|
|
|
jsonObject.put("code", 200);
|
|
jsonObject.put("code", 200);
|
|
|
jsonObject.put("message", "申请已提交,请稍候查询");
|
|
jsonObject.put("message", "申请已提交,请稍候查询");
|
|
|
return jsonObject;
|
|
return jsonObject;
|
|
@@ -625,7 +624,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
StringBuffer strSqlBook = new StringBuffer();
|
|
StringBuffer strSqlBook = new StringBuffer();
|
|
|
strSqlBook.append(" and order_status = '").append(PayEnum.退款中.getNum()).append("' ");
|
|
strSqlBook.append(" and order_status = '").append(PayEnum.退款中.getNum()).append("' ");
|
|
|
List<Booking> booking = bookService.queryList(strSqlBook.toString());
|
|
List<Booking> booking = bookService.queryList(strSqlBook.toString());
|
|
|
- if (booking==null){
|
|
|
|
|
|
|
+ if (booking == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
@@ -653,21 +652,21 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
params.put("sign", w.getSign());
|
|
params.put("sign", w.getSign());
|
|
|
String retXml = JaxbUtil.getRequestXml(params);
|
|
String retXml = JaxbUtil.getRequestXml(params);
|
|
|
String msg = HttpUtils.post("https://api.mch.weixin.qq.com/pay/refundquery", retXml);
|
|
String msg = HttpUtils.post("https://api.mch.weixin.qq.com/pay/refundquery", retXml);
|
|
|
- if (msg.indexOf("<refund_status_0><![CDATA[SUCCESS]]></refund_status_0>")>0) {
|
|
|
|
|
|
|
+ if (msg.indexOf("<refund_status_0><![CDATA[SUCCESS]]></refund_status_0>") > 0) {
|
|
|
//退款的数据删除一下房态删除
|
|
//退款的数据删除一下房态删除
|
|
|
String sql = " and booking_id = " + book.getId();
|
|
String sql = " and booking_id = " + book.getId();
|
|
|
List<HouseNumberStatus> houseNumberStatuse = houseNumberStatusService.getList(sql);
|
|
List<HouseNumberStatus> houseNumberStatuse = houseNumberStatusService.getList(sql);
|
|
|
houseNumberStatusService.updateHouseNumberStatus(String.valueOf(book.getId()));
|
|
houseNumberStatusService.updateHouseNumberStatus(String.valueOf(book.getId()));
|
|
|
|
|
|
|
|
// 退款成功,将数据写入本地数据库
|
|
// 退款成功,将数据写入本地数据库
|
|
|
- book.setRefundTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
|
|
|
|
|
|
|
+ book.setRefundTime(DateUtil.parseDateToStr(new Date(), DateUtil.Time_Formatter_Second));
|
|
|
book.setRefundAmount(book.getHouseTotalPrice());
|
|
book.setRefundAmount(book.getHouseTotalPrice());
|
|
|
- book.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
|
|
|
|
|
|
|
+ book.setUpdateTime(DateUtil.parseDateToStr(new Date(), DateUtil.Time_Formatter_Second));
|
|
|
book.setOrderStatus(Func.parseStr(PayEnum.getKeyByValue(book.getRemake()))); // 将走微信前的标识,写入回调函数
|
|
book.setOrderStatus(Func.parseStr(PayEnum.getKeyByValue(book.getRemake()))); // 将走微信前的标识,写入回调函数
|
|
|
bookService.updateBooking(book);
|
|
bookService.updateBooking(book);
|
|
|
|
|
|
|
|
// 退款成功后,写入数据操作
|
|
// 退款成功后,写入数据操作
|
|
|
- bookinglogService.addBooklog("用户在取消了订单,已退款成功,退款金额是" + book.getRefundAmount() ,book);
|
|
|
|
|
|
|
+ bookinglogService.addBooklog("用户在取消了订单,已退款成功,退款金额是" + book.getRefundAmount(), book);
|
|
|
|
|
|
|
|
// 发送成功消息给商家和用户
|
|
// 发送成功消息给商家和用户
|
|
|
AdminManager adminManager = adminManagerService.getById(Func.parseInt(book.getHotelManagerId()));
|
|
AdminManager adminManager = adminManagerService.getById(Func.parseInt(book.getHotelManagerId()));
|
|
@@ -675,14 +674,14 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
String sendMsg = book.getRemake();
|
|
String sendMsg = book.getRemake();
|
|
|
// 推给用户(需求确定,用户点取消退款以后[标识订单状态已取消]只发商家,不发用户。 商家点拒单以后[标识订单状态已退单]只发用户不发商家)
|
|
// 推给用户(需求确定,用户点取消退款以后[标识订单状态已取消]只发商家,不发用户。 商家点拒单以后[标识订单状态已退单]只发用户不发商家)
|
|
|
int status = Func.parseInt(book.getOrderStatus());
|
|
int status = Func.parseInt(book.getOrderStatus());
|
|
|
- if (status == PayEnum.已退单.getNum()){
|
|
|
|
|
- Message.send(users.getOpenid(),book.getHotelName(),book.getOrderStatus(), book.getOrderStartTime(),book.getOrderEndTime(), book.getHouseName());
|
|
|
|
|
|
|
+ if (status == PayEnum.已退单.getNum()) {
|
|
|
|
|
+ Message.send(users.getOpenid(), book.getHotelName(), book.getOrderStatus(), book.getOrderStartTime(), book.getOrderEndTime(), book.getHouseName());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 推给商家
|
|
// 推给商家
|
|
|
- String live_end = book.getOrderStartTime().substring(0,10) +"~"+ book.getOrderEndTime().substring(0,10);
|
|
|
|
|
|
|
+ String live_end = book.getOrderStartTime().substring(0, 10) + "~" + book.getOrderEndTime().substring(0, 10);
|
|
|
String hotelName = Func.checkNull(book.getHotelName()) ? book.getHotelName() : book.getHouseName();
|
|
String hotelName = Func.checkNull(book.getHotelName()) ? book.getHotelName() : book.getHouseName();
|
|
|
- if (status == PayEnum.已取消.getNum()) {
|
|
|
|
|
|
|
+ if (status == PayEnum.已取消.getNum()) {
|
|
|
Message2.send(adminManager.getOpenid(), book.getHotelType(), book.getHouseName(), live_end, book.getUserName(), hotelName, Func.parseStr(book.getId()));
|
|
Message2.send(adminManager.getOpenid(), book.getHotelType(), book.getHouseName(), live_end, book.getUserName(), hotelName, Func.parseStr(book.getId()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -743,7 +742,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String backMessage = appBookService.varificationHouse(houseId, startTime, endTime,houseOrderNumber);
|
|
|
|
|
|
|
+ String backMessage = appBookService.varificationHouse(houseId, startTime, endTime, houseOrderNumber);
|
|
|
|
|
|
|
|
if (!Func.checkNull(backMessage)) {
|
|
if (!Func.checkNull(backMessage)) {
|
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
@@ -786,7 +785,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// 支付费用
|
|
// 支付费用
|
|
|
- double totalPrice = booking.getHouseTotalPrice() ;
|
|
|
|
|
|
|
+ double totalPrice = booking.getHouseTotalPrice();
|
|
|
int totalfee = Func.parseInt(totalPrice * 100);
|
|
int totalfee = Func.parseInt(totalPrice * 100);
|
|
|
|
|
|
|
|
WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
@@ -852,8 +851,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
bookService.updateBooking(booking);
|
|
bookService.updateBooking(booking);
|
|
|
|
|
|
|
|
//用户开启支付,写入数据操作
|
|
//用户开启支付,写入数据操作
|
|
|
- bookinglogService.addBooklog("用户点击订单,进行支付" ,booking);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ bookinglogService.addBooklog("用户点击订单,进行支付", booking);
|
|
|
|
|
|
|
|
|
|
|
|
|
resultjson.put(B.code, ResultStatusCode.OK.getStatus());
|
|
resultjson.put(B.code, ResultStatusCode.OK.getStatus());
|
|
@@ -870,13 +868,12 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 支付成功后回调,推送消息给商家
|
|
|
|
|
- *
|
|
|
|
|
|
|
+ * 支付成功后回调,推送消息给商家
|
|
|
*/
|
|
*/
|
|
|
- public String payResulet(){
|
|
|
|
|
|
|
+ public String payResulet() {
|
|
|
System.out.println("进入支付回调====");
|
|
System.out.println("进入支付回调====");
|
|
|
JSONObject resultjson = new JSONObject();
|
|
JSONObject resultjson = new JSONObject();
|
|
|
- try{
|
|
|
|
|
|
|
+ try {
|
|
|
BufferedReader reader = null;// BufferedReader 字符输入流
|
|
BufferedReader reader = null;// BufferedReader 字符输入流
|
|
|
reader = request.getReader();
|
|
reader = request.getReader();
|
|
|
String line = "";
|
|
String line = "";
|
|
@@ -890,10 +887,10 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
JaxbUtil requestBinder = new JaxbUtil(PayResult.class, PayResult.class);
|
|
JaxbUtil requestBinder = new JaxbUtil(PayResult.class, PayResult.class);
|
|
|
PayResult result = requestBinder.fromXml(xmlString);// Xml到Java,用fromXML()方法
|
|
PayResult result = requestBinder.fromXml(xmlString);// Xml到Java,用fromXML()方法
|
|
|
String order_num = result.getOut_trade_no();
|
|
String order_num = result.getOut_trade_no();
|
|
|
- System.out.println("支付成功回调,订单号:"+order_num);
|
|
|
|
|
|
|
+ System.out.println("支付成功回调,订单号:" + order_num);
|
|
|
Booking book = bookService.queryByOrder(order_num);
|
|
Booking book = bookService.queryByOrder(order_num);
|
|
|
// 支付成功
|
|
// 支付成功
|
|
|
- if (result.getResult_code().equals("SUCCESS") && book!=null && ("1").equals(book.getOrderStatus())) {
|
|
|
|
|
|
|
+ if (result.getResult_code().equals("SUCCESS") && book != null && ("1").equals(book.getOrderStatus())) {
|
|
|
|
|
|
|
|
// 保存支付信息
|
|
// 保存支付信息
|
|
|
book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
|
|
book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
|
|
@@ -901,33 +898,93 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
book.setPayTime(DateUtil.getFormatPaternDate(new Date()));
|
|
book.setPayTime(DateUtil.getFormatPaternDate(new Date()));
|
|
|
book.setPayWay(OrderEnum.微信支付.toString());
|
|
book.setPayWay(OrderEnum.微信支付.toString());
|
|
|
// 进行业务判断,如果是商家设定了自动接单,则支付状态直接变为待入住 接单设置(1自动接单 2手动接单)
|
|
// 进行业务判断,如果是商家设定了自动接单,则支付状态直接变为待入住 接单设置(1自动接单 2手动接单)
|
|
|
- //目前该自动接单逻辑无法与定时的自动接单操作衔接特此屏蔽 后续可以直接删除
|
|
|
|
|
-// if ("1".equals(book.getHotelIsOrder()))
|
|
|
|
|
-// {
|
|
|
|
|
-// // 自动接单,订单状态修改为待入住
|
|
|
|
|
-// book.setOrderStatus(Func.parseStr(PayEnum.待入住.getNum()));
|
|
|
|
|
-// String userId = book.getCreateUserid();
|
|
|
|
|
-// Users users = userService.queryByUserId(userId);
|
|
|
|
|
-// String mess = "您已成功订房,订单号:"+order_num;
|
|
|
|
|
-// Message.send(users.getOpenid(),book.getHotelName(),book.getOrderStatus(), book.getOrderStartTime(),book.getOrderEndTime(), book.getHouseName());
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ //目前付完钱之后如果是设置的自动接单就进行自动接单
|
|
|
|
|
+ if ("1".equals(book.getHotelIsOrder())) {
|
|
|
|
|
+ AtomicInteger n = new AtomicInteger();
|
|
|
|
|
+ String userId = book.getCreateUserid();
|
|
|
|
|
+ Users users = userService.queryByUserId(userId);
|
|
|
|
|
+ String mess = "您已成功订房,订单号:" + order_num;
|
|
|
|
|
+ Message.send(users.getOpenid(), book.getHotelName(), book.getOrderStatus(), book.getOrderStartTime(), book.getOrderEndTime(), book.getHouseName());
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("手动接单定时程序5");
|
|
|
|
|
+ List<HouseNumberStatus> list = new ArrayList<>();
|
|
|
|
|
+ //不可入住的房间
|
|
|
|
|
+ List<HouseNumber> houseNumbers = houseNumberService.queryHouseStatus(book);
|
|
|
|
|
+ //所有房间
|
|
|
|
|
+ List<HouseNumber> houseNumberList = houseNumberService.queryByHouseId(book.getHouseId());
|
|
|
|
|
+ AtomicInteger i = new AtomicInteger();
|
|
|
|
|
+ List<String> Ids = new ArrayList<>();
|
|
|
|
|
+ if (houseNumbers != null) {
|
|
|
|
|
+ houseNumberList.forEach(houseNumber -> {
|
|
|
|
|
+ //添加的房间不在不可添加的房间当中并且数量小于订房总数
|
|
|
|
|
+ if (!houseNumbers.contains(houseNumber) && i.get() < book.getHouseOrderNumber()) {
|
|
|
|
|
+ Ids.add(houseNumber.getId());
|
|
|
|
|
+ i.getAndIncrement();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //所有房间都可以预定
|
|
|
|
|
+ houseNumberList.forEach(houseNumber -> {
|
|
|
|
|
+ //添加的房间不在不可添加的房间当中并且数量小于订房总数
|
|
|
|
|
+ if (i.get() < book.getHouseOrderNumber()) {
|
|
|
|
|
+ Ids.add(houseNumber.getId());
|
|
|
|
|
+ i.getAndIncrement();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ LocalDateTime str = LocalDateTime.parse(book.getOrderStartTime(), inputFormatter);
|
|
|
|
|
+ LocalDateTime end = LocalDateTime.parse(book.getOrderEndTime(), inputFormatter);
|
|
|
|
|
+ String a = str.format(formatter);
|
|
|
|
|
+ String B = end.format(formatter);
|
|
|
|
|
+ LocalDate strDate = LocalDate.parse(a, formatter);
|
|
|
|
|
+ LocalDate endDate = LocalDate.parse(B, formatter);
|
|
|
|
|
+ Date now = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String number : Ids) {
|
|
|
|
|
+ for (LocalDate date = strDate; !date.isAfter(endDate.minusDays(1)); date = date.plusDays(1)) {
|
|
|
|
|
+ HouseNumberStatus houseNumberStatus = new HouseNumberStatus();
|
|
|
|
|
+ houseNumberStatus.setNumberId(number);
|
|
|
|
|
+ houseNumberStatus.setId(String.valueOf(UUID.randomUUID()));
|
|
|
|
|
+ houseNumberStatus.setCreateDate(now);
|
|
|
|
|
+ houseNumberStatus.setModifyDate(now);
|
|
|
|
|
+ houseNumberStatus.setRemark("");
|
|
|
|
|
+ houseNumberStatus.setBookingId(String.valueOf(book.getId()));
|
|
|
|
|
+ houseNumberStatus.setSetDate(date.format(formatter));
|
|
|
|
|
+ houseNumberStatus.setStatus(5);//状态(0删除 1.正常 2.关房 3.脏房 4.净房 5.预定 6.入住)
|
|
|
|
|
+ list.add(houseNumberStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ int m = houseNumberStatusService.saveBatch(list);
|
|
|
|
|
+ if (m > 0) {
|
|
|
|
|
+ n.getAndIncrement();
|
|
|
|
|
+ // 自动接单,订单状态修改为待入住
|
|
|
|
|
+ book.setOrderStatus(Func.parseStr(PayEnum.待入住.getNum()));
|
|
|
|
|
+ book.setUpdateTime(UUIDUtil.getNewDate());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 手动接单,发消息给商家
|
|
// 手动接单,发消息给商家
|
|
|
AdminManager adminManager = adminManagerService.getById(Func.parseInt(book.getHotelManagerId()));
|
|
AdminManager adminManager = adminManagerService.getById(Func.parseInt(book.getHotelManagerId()));
|
|
|
- String live_end = book.getOrderStartTime().substring(0,10) +"~"+ book.getOrderEndTime().substring(0,10);
|
|
|
|
|
|
|
+ String live_end = book.getOrderStartTime().substring(0, 10) + "~" + book.getOrderEndTime().substring(0, 10);
|
|
|
String hotelName = book.getHotelName();
|
|
String hotelName = book.getHotelName();
|
|
|
- if (Func.checkNull(book.getHotelName()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (Func.checkNull(book.getHotelName())) {
|
|
|
hotelName = book.getHouseName();
|
|
hotelName = book.getHouseName();
|
|
|
}
|
|
}
|
|
|
- Message2.send(adminManager.getOpenid(),order_num,book.getHouseName(),live_end,book.getUserName(),hotelName, Func.parseStr(book.getId()));
|
|
|
|
|
- double totalPrice = book.getHouseTotalPrice() ;
|
|
|
|
|
|
|
+ Message2.send(adminManager.getOpenid(), order_num, book.getHouseName(), live_end, book.getUserName(), hotelName, Func.parseStr(book.getId()));
|
|
|
|
|
+ double totalPrice = book.getHouseTotalPrice();
|
|
|
book.setPayAccount(totalPrice);
|
|
book.setPayAccount(totalPrice);
|
|
|
int m = bookService.updateBooking(book);
|
|
int m = bookService.updateBooking(book);
|
|
|
//用户支付,写入数据操作
|
|
//用户支付,写入数据操作
|
|
|
- bookinglogService.addBooklog("用户支付成功" ,book);
|
|
|
|
|
|
|
+ bookinglogService.addBooklog("用户支付成功", book);
|
|
|
|
|
|
|
|
- if (m>0){
|
|
|
|
|
|
|
+ if (m > 0) {
|
|
|
String returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
|
|
String returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
|
|
|
HttpServletResponse response = ServletActionContext.getResponse();
|
|
HttpServletResponse response = ServletActionContext.getResponse();
|
|
|
response.setContentType("text/html;charset=utf-8");
|
|
response.setContentType("text/html;charset=utf-8");
|
|
@@ -938,7 +995,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- } catch (Exception e){
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
resultjson.put("message", "支付失败");
|
|
resultjson.put("message", "支付失败");
|
|
|
resultjson.put("code", 205);
|
|
resultjson.put("code", 205);
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
@@ -951,8 +1008,6 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
public String getOpen_id() {
|
|
public String getOpen_id() {
|
|
|
return open_id;
|
|
return open_id;
|
|
|
}
|
|
}
|
|
@@ -960,4 +1015,4 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
public void setOpen_id(String open_id) {
|
|
public void setOpen_id(String open_id) {
|
|
|
this.open_id = open_id;
|
|
this.open_id = open_id;
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+}
|