fix[litemall-wx, litemall-wx-api]: 小商城模拟支付错误。
This commit is contained in:
@@ -108,8 +108,11 @@ public class OrderUtil {
|
||||
handleOption.setComment(true);
|
||||
handleOption.setRebuy(true);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("status不支持");
|
||||
}
|
||||
|
||||
throw new IllegalStateException("status不支持");
|
||||
return handleOption;
|
||||
}
|
||||
|
||||
public static List<Short> orderStatus(Integer showType){
|
||||
|
||||
@@ -356,6 +356,50 @@ public class WxOrderController {
|
||||
return ResponseUtil.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 付款订单
|
||||
*
|
||||
* 1. 检测当前订单是否能够付款
|
||||
* 2. 微信支付平台返回支付订单ID
|
||||
* 3. 设置订单付款状态
|
||||
* TODO 与微信后台交互产生付款订单ID,以及不同的付款状态
|
||||
* 目前这里直接设置订单已付款状态模拟支付成功
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '模拟付款支付成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("pay")
|
||||
public Object payPrepay(@LoginUser Integer userId, @RequestBody String body) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
|
||||
if (orderId == null) {
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
if (order == null) {
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
if (!order.getUserId().equals(userId)) {
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
// 检测是否能够取消
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
if (!handleOption.isPay()) {
|
||||
return ResponseUtil.fail(403, "订单不能支付");
|
||||
}
|
||||
|
||||
order.setPayStatus(OrderUtil.STATUS_PAY);
|
||||
orderService.updateById(order);
|
||||
return ResponseUtil.ok("模拟付款支付成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
* 1. 检测当前订单是否能够取消
|
||||
|
||||
@@ -71,10 +71,11 @@ module.exports = {
|
||||
RegionList: WxApiRoot + 'region/list', //获取区域列表
|
||||
|
||||
OrderSubmit: WxApiRoot + 'order/submit', // 提交订单
|
||||
OrderPay: WxApiRoot + 'order/pay', // 支付订单
|
||||
OrderList: WxApiRoot + 'order/list', //订单列表
|
||||
OrderDetail: WxApiRoot + 'order/detail', //订单详情
|
||||
OrderCancel: WxApiRoot + 'order/cancel', //取消订单
|
||||
OrderRefund: WxApiRoot + 'order/refund', //取消订单并退款
|
||||
OrderRefund: WxApiRoot + 'order/refund', //退款取消订单
|
||||
OrderDelete: WxApiRoot + 'order/delete', //删除订单
|
||||
OrderConfirm: WxApiRoot + 'order/confirm', //确认收货
|
||||
OrderComment: WxApiRoot + 'order/comment', // 代评价商品信息
|
||||
|
||||
@@ -31,12 +31,37 @@ Page({
|
||||
|
||||
},
|
||||
payOrder() {
|
||||
pay.payOrder(this.data.orderId).then(res => {
|
||||
this.setData({
|
||||
status: true
|
||||
});
|
||||
}).catch(res => {
|
||||
util.showErrorToast('支付失败');
|
||||
let that = this;
|
||||
// 目前不能支持微信支付,这里仅仅是模拟支付成功,同理,后台也仅仅是返回一个成功的消息而已
|
||||
wx.showModal({
|
||||
title: '目前不能微信支付',
|
||||
content: '点击确定模拟支付成功,点击取消模拟未支付成功',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
util.request(api.OrderPay, { orderId: that.data.orderId }, 'POST').then(res => {
|
||||
if (res.errno === 0) {
|
||||
that.setData({
|
||||
status: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
util.showErrorToast('支付失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (res.cancel) {
|
||||
util.showErrorToast('支付失败');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// pay.payOrder(this.data.orderId).then(res => {
|
||||
// this.setData({
|
||||
// status: true
|
||||
// });
|
||||
// }).catch(res => {
|
||||
// util.showErrorToast('支付失败');
|
||||
// });
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user