|
@@ -150,7 +150,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
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)
|
|
|
{
|
|
{
|
|
@@ -259,6 +259,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * bookingId 订单id
|
|
|
* 商家在已支付,待入住时点退单 ,进入退款流程后退单
|
|
* 商家在已支付,待入住时点退单 ,进入退款流程后退单
|
|
|
* 在已入住,时点退单,进入退款流程后退款
|
|
* 在已入住,时点退单,进入退款流程后退款
|
|
|
* @return
|
|
* @return
|
|
@@ -300,69 +301,8 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
book.setRefundWay(OrderEnum.微信退款.toString());
|
|
book.setRefundWay(OrderEnum.微信退款.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 进行判断如果订单是退款中,并且标识字段微信退款,则进入退款流程
|
|
|
|
|
- if (Func.parseStr(PayEnum.TEN.getNum()).equals(book.getOrderStatus()) && OrderEnum.微信退款.toString().equals(book.getRefundWay())) {
|
|
|
|
|
-
|
|
|
|
|
- String ip = WeiXinUtil.ip;
|
|
|
|
|
- double money = book.getPayAccount();
|
|
|
|
|
- int a = (int) (money * 100);
|
|
|
|
|
- WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
|
|
|
- w.setAppid(WeiXinUtil.appid_c);
|
|
|
|
|
- w.setAttach("chuanghai");
|
|
|
|
|
- w.setBody("chuanghai");
|
|
|
|
|
- w.setMch_id(WeiXinUtil.account);
|
|
|
|
|
- w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
|
|
|
|
|
- w.setNotify_url(WeiXinUtil.ip_h + "/abkquery_refund.action");// 支付结果回调地址
|
|
|
|
|
- w.setOpenid(open_id);
|
|
|
|
|
- w.setOut_trade_no(book.getOrderNum());
|
|
|
|
|
- String refund_order = WxUtil.mchOrderNo();
|
|
|
|
|
- w.setOut_refund_no(refund_order); // 退款单号
|
|
|
|
|
- w.setSpbill_create_ip(ip);
|
|
|
|
|
- w.setTotal_fee(a);
|
|
|
|
|
- w.setRefund_fee(a); // 退款金额
|
|
|
|
|
- w.setTrade_type("JSAPI");
|
|
|
|
|
- SortedMap<String, String> params = new TreeMap<>();
|
|
|
|
|
- params.put("appid", w.getAppid());
|
|
|
|
|
- params.put("mch_id", w.getMch_id());
|
|
|
|
|
- params.put("nonce_str", w.getNonce_str());
|
|
|
|
|
- params.put("notify_url", w.getNotify_url());
|
|
|
|
|
- params.put("out_refund_no", w.getOut_refund_no()); // 退款单号
|
|
|
|
|
- params.put("out_trade_no", w.getOut_trade_no());
|
|
|
|
|
- params.put("refund_fee",w.getRefund_fee()+""); // 退款金额
|
|
|
|
|
- params.put("total_fee", w.getTotal_fee() + "");
|
|
|
|
|
-
|
|
|
|
|
- w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
|
|
|
|
|
- params.put("sign", w.getSign());
|
|
|
|
|
- //String retXml = JaxbUtil.getRequestXml(params);
|
|
|
|
|
- String xml = "<xml>" +
|
|
|
|
|
- "<appid>" + w.getAppid() + "</appid>" +
|
|
|
|
|
- "<mch_id>" + w.getMch_id() + "</mch_id>" +
|
|
|
|
|
- "<nonce_str>" + w.getNonce_str() + "</nonce_str>" +
|
|
|
|
|
- "<notify_url>" + w.getNotify_url() + "</notify_url>" +
|
|
|
|
|
- "<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>" +
|
|
|
|
|
- "<total_fee>" + w.getTotal_fee() + "" + "</total_fee>" +
|
|
|
|
|
- "<sign>" + w.getSign() + "</sign>" +
|
|
|
|
|
- "</xml>";
|
|
|
|
|
- String msg = HttpUtils.post2("https://api.mch.weixin.qq.com/secapi/pay/refund", xml);
|
|
|
|
|
- if (msg.indexOf("FAIL") > -1) {
|
|
|
|
|
- jsonObject.put("code", 507);
|
|
|
|
|
- jsonObject.put("message", "退款失败");
|
|
|
|
|
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 设置订单状态为退款中
|
|
|
|
|
- book.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
|
|
|
|
|
- bookService.updateBooking(book); // 退款中
|
|
|
|
|
-
|
|
|
|
|
- jsonObject.put("code", 200);
|
|
|
|
|
- jsonObject.put("message", "退款申请已提交,请稍候查询");
|
|
|
|
|
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ jsonObject = refundMethod(book,users.getOpenid());
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -376,56 +316,95 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public String cancelBooking() throws Exception {
|
|
public String cancelBooking() throws Exception {
|
|
|
- if (Func.checkNull(bookingId))
|
|
|
|
|
- return null;
|
|
|
|
|
-
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ if (Func.checkNull(this.bookingId)) {
|
|
|
|
|
+ jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
|
|
+ jsonObject.put(B.message, "未传入bookingId");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 取消订单,修改订单的支付状态
|
|
// 取消订单,修改订单的支付状态
|
|
|
- String mess = bookService.cancelBooking(bookingId);
|
|
|
|
|
- if (!Func.checkNull(mess)) {
|
|
|
|
|
|
|
+ Booking book = bookService.getById(Func.parseInt(bookingId));
|
|
|
|
|
+ if (book == null )
|
|
|
|
|
+ {
|
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
- jsonObject.put(B.message, mess);
|
|
|
|
|
|
|
+ jsonObject.put(B.message, "未获取到订单信息,请重新查询");
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Booking booking = bookService.getById(Func.parseInt(this.bookingId));
|
|
|
|
|
- if (booking == null )
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ //是否能取消订单(1是 2否)
|
|
|
|
|
+ if (Func.parseInt(book.getHotelIsCanorder()) == 2)
|
|
|
|
|
+ {
|
|
|
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());
|
|
|
return null;
|
|
return null;
|
|
|
- }
|
|
|
|
|
- if (Func.checkNull(booking.getRefundWay()) && Func.parseStr(PayEnum.SEVEN.getNum()).equals(booking.getOrderStatus()))
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AdminManager adminManager = adminManagerService.getById(Func.parseInt(book.getHotelManagerId()));
|
|
|
|
|
+
|
|
|
|
|
+ //1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款,10退款中
|
|
|
|
|
+ int status = Func.parseInt(book.getOrderStatus());
|
|
|
|
|
+ if (status == 1)
|
|
|
{
|
|
{
|
|
|
|
|
+ book.setOrderStatus(Func.parseStr(PayEnum.SEVEN.getNum())); // 如果在1待支付情况,用户点击取消订单按钮,后台直接修改取消订单操作
|
|
|
|
|
+ book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
|
|
|
|
|
+ book.setRemake(Func.parseStr(PayEnum.FIVE.getNum()));
|
|
|
|
|
+ bookService.updateBooking(book);
|
|
|
jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
|
|
jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
|
|
|
jsonObject.put(B.message, "已取消订单");
|
|
jsonObject.put(B.message, "已取消订单");
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
return null;
|
|
return null;
|
|
|
|
|
+
|
|
|
|
|
+ }else if (status == 2 || status == 3)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 如果在2已支付,3待入住 情况,用户点击取消订单按钮,后台先修改状态为退款中,然后走退款流程
|
|
|
|
|
+ book.setOrderStatus(Func.parseStr(PayEnum.TEN.getNum()));
|
|
|
|
|
+ book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
|
|
|
|
|
+ book.setRemake(Func.parseStr(PayEnum.FIVE.getNum()));
|
|
|
|
|
+ if (book.getPayAccount() > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 注明如果支付金额大于0,则需要退款: (标识走退款操作)
|
|
|
|
|
+ book.setRefundWay(OrderEnum.微信退款.toString());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Users users = userService.queryByUserId(book.getCreateUserid()); // 用户信息
|
|
|
|
|
+ if (users == null) {
|
|
|
|
|
+ jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
|
|
+ jsonObject.put(B.message, "未查询到当前用户数据users,请先授权");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 进行判断如果订单是退款中,并且标识字段微信退款,则进入退款流程
|
|
|
|
|
- if (Func.parseStr(PayEnum.TEN.getNum()).equals(booking.getOrderStatus()) && OrderEnum.微信退款.toString().equals(booking.getRefundWay())) {
|
|
|
|
|
- if (Func.checkNull(this.open_id) || Func.checkNull(this.bookingId)) {
|
|
|
|
|
- jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
|
|
- jsonObject.put(B.message, "未传入open_id和bookingId");
|
|
|
|
|
- ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ jsonObject = refundMethod(book,users.getOpenid());
|
|
|
|
|
+ jsonObject.put(B.data, book);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Users users = userService.queryByOpenid(open_id); // 用户信息
|
|
|
|
|
- if (users == null || booking == null) {
|
|
|
|
|
- jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
|
|
- jsonObject.put(B.message, "未查询到当前用户数据users,请先授权");
|
|
|
|
|
- ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 退款方法
|
|
|
|
|
+ * @param book
|
|
|
|
|
+ * @param open_id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public JSONObject refundMethod(Booking book,String open_id) throws Exception {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ if (book == null || Func.checkNull(open_id))
|
|
|
|
|
+ {
|
|
|
|
|
+ jsonObject.put("code", 400);
|
|
|
|
|
+ jsonObject.put("message", "未传入book和open_id数据---refundMethod");
|
|
|
|
|
+ return jsonObject;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ // 进行判断如果订单是退款中,并且标识字段微信退款,则进入退款流程
|
|
|
|
|
+ if (Func.parseStr(PayEnum.TEN.getNum()).equals(book.getOrderStatus()) && OrderEnum.微信退款.toString().equals(book.getRefundWay())) {
|
|
|
String ip = WeiXinUtil.ip;
|
|
String ip = WeiXinUtil.ip;
|
|
|
- double money = booking.getPayAccount();
|
|
|
|
|
|
|
+ double money = book.getPayAccount();
|
|
|
int a = (int) (money * 100);
|
|
int a = (int) (money * 100);
|
|
|
WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
WechatUnifiedOrder w = new WechatUnifiedOrder();
|
|
|
w.setAppid(WeiXinUtil.appid_c);
|
|
w.setAppid(WeiXinUtil.appid_c);
|
|
@@ -435,7 +414,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
|
|
w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
|
|
|
w.setNotify_url(WeiXinUtil.ip_h + "/abkquery_refund.action");// 支付结果回调地址
|
|
w.setNotify_url(WeiXinUtil.ip_h + "/abkquery_refund.action");// 支付结果回调地址
|
|
|
w.setOpenid(open_id);
|
|
w.setOpenid(open_id);
|
|
|
- w.setOut_trade_no(booking.getOrderNum());
|
|
|
|
|
|
|
+ w.setOut_trade_no(book.getOrderNum());
|
|
|
String refund_order = WxUtil.mchOrderNo();
|
|
String refund_order = WxUtil.mchOrderNo();
|
|
|
w.setOut_refund_no(refund_order); // 退款单号
|
|
w.setOut_refund_no(refund_order); // 退款单号
|
|
|
w.setSpbill_create_ip(ip);
|
|
w.setSpbill_create_ip(ip);
|
|
@@ -476,23 +455,21 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置订单状态为退款中
|
|
// 设置订单状态为退款中
|
|
|
- booking.setOrderStatus(Func.parseStr(PayEnum.TEN.getNum()));
|
|
|
|
|
- booking.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
|
|
|
|
|
- bookService.updateBooking(booking); // 退款中
|
|
|
|
|
|
|
+ book.setOrderStatus(Func.parseStr(PayEnum.TEN.getNum()));
|
|
|
|
|
+ book.setUpdateTime(DateUtil.parseDateToStr(new Date(),DateUtil.Time_Formatter_Second));
|
|
|
|
|
+ bookService.updateBooking(book); // 退款中
|
|
|
|
|
|
|
|
jsonObject.put("code", 200);
|
|
jsonObject.put("code", 200);
|
|
|
- jsonObject.put("message", "退款申请已提交,请稍候查询");
|
|
|
|
|
- ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ jsonObject.put("message", "申请已提交,请稍候查询");
|
|
|
|
|
+ return jsonObject;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
|
|
|
|
|
- jsonObject.put(B.message, "取消订单成功");
|
|
|
|
|
- jsonObject.put(B.data, booking);
|
|
|
|
|
- ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ jsonObject.put("code", 400);
|
|
|
|
|
+ jsonObject.put("message", "提交申请失败");
|
|
|
|
|
+ return jsonObject;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// /**
|
|
// /**
|
|
|
// * open_id
|
|
// * open_id
|
|
|
// * bookingId
|
|
// * bookingId
|