1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

小程序端确认收货

This commit is contained in:
程序员小墨 2023-04-17 23:15:43 +08:00
parent 3e822ba3a0
commit 918917868f
6 changed files with 90 additions and 3 deletions

View File

@ -21,6 +21,7 @@
后台订单管理页 后台订单管理页
每个人创建账号的时候填充一些测试数据进去
门禁端左侧提示文字修改 门禁端左侧提示文字修改

View File

@ -47,8 +47,8 @@ public class OrderVO implements Serializable {
String price = order.getOrderPrice().setScale(2, RoundingMode.FLOOR).toPlainString(); String price = order.getOrderPrice().setScale(2, RoundingMode.FLOOR).toPlainString();
orderVO.setOrderPrice(price); orderVO.setOrderPrice(price);
if (order.getOrderDate() != null) { if (order.getPayDate() != null) {
orderVO.setPayDate(order.getOrderDate().toString().replace("T", " ")); orderVO.setPayDate(order.getPayDate().toString().replace("T", " "));
} }
if (order.getCancelDate() != null) { if (order.getCancelDate() != null) {
orderVO.setCancelDate(order.getCancelDate().toString().replace("T", " ")); orderVO.setCancelDate(order.getCancelDate().toString().replace("T", " "));

View File

@ -223,4 +223,42 @@ public class OrderController {
return Res.success(success ? "取消成功" : "取消失败"); return Res.success(success ? "取消成功" : "取消失败");
} }
@PostMapping("/miniprogram/confirmOrder")
@ResponseBody
public Res confirmOrder(@RequestBody JSONObject params) {
Long orderId = params.getLong("orderId");
if (orderId == null) {
return Res.error("参数错误");
}
// 查询订单详情
Order order = orderService.getOrderById(orderId);
if (order == null) {
return Res.error("订单不存在");
}
//判断是否可以取消
OrderStatus orderStatus = OrderStatus.get(order.getOrderStatus());
switch (orderStatus) {
case PENDING:
return Res.error("订单尚未支付,不可确认收货");
case PROCESSING:
return Res.error("订单尚未发货,不可确认收货");
case SHIPPED:
// 可以确认收货
break;
case DELIVERED:
return Res.error("您已确认收货,无需再次确认");
case CANCELLED:
return Res.error("订单已取消,不可确认收货");
default:
return Res.error("当前订单状态无法确认收货");
}
// 更新支付信息
Boolean success = orderService.updateOrderStatus(orderId, OrderStatus.DELIVERED);
return Res.success(success ? "确认收货成功" : "确认收货失败");
}
} }

View File

@ -188,6 +188,39 @@ Page({
}) })
}, },
// 订单状态:已发货,点击确认收货
confirmReceipt() {
// 点击确认收货按钮
wx.showModal({
title: '是否确认收货?',
content: '未收到货时请不要点击确认',
complete: (res) => {
if (res.confirm) {
(async () => {
this.clearPageData()
let confirmResult = await orderService.confirmOrder(this.data.orderId)
console.log("confirmResult", confirmResult)
this.onLoad(this.data._options)
this.refreshMyOrderPage()
wx.showModal({
title: '操作结果',
content: confirmResult || "操作失败,请重试",
showCancel: false,
complete: (res) => {
// wx.navigateBack({
// delta: getCurrentPages().length - 1
// })
// wx.navigateTo({
// url: "/pages/shop/orderDetail?orderId=" + this.data.orderId,
// })
}
})
})();
}
}
})
},
loadPageData() { loadPageData() {
(async () => { (async () => {
console.log("orderId", this.data.orderId) console.log("orderId", this.data.orderId)

View File

@ -45,6 +45,8 @@
<view wx:if="{{order.cancelDate}}">订单取消时间:{{order.cancelDate}}</view> <view wx:if="{{order.cancelDate}}">订单取消时间:{{order.cancelDate}}</view>
<view wx:if="{{order.shipDate}}">订单发货时间:{{order.shipDate}}</view> <view wx:if="{{order.shipDate}}">订单发货时间:{{order.shipDate}}</view>
<view wx:if="{{order.deliverDate}}">确认收货时间:{{order.deliverDate}}</view> <view wx:if="{{order.deliverDate}}">确认收货时间:{{order.deliverDate}}</view>
<view wx:if="{{order.expressId}}">发货快递单号:{{order.expressId}}</view>
<view wx:if="{{order.comment}}">发货备注信息:{{order.comment}}</view>
</view> </view>
<view class="good-list-title">订单详情</view> <view class="good-list-title">订单详情</view>
@ -86,10 +88,12 @@
<!-- Cancelled --> <!-- Cancelled -->
<view wx:if="{{ orderStatusCode == 'Cancelled' }}" class="txt txt-disabled">❕无法操作已取消订单</view> <view wx:if="{{ orderStatusCode == 'Cancelled' }}" class="txt txt-disabled">❕无法操作已取消订单</view>
<!-- Processing --> <!-- Processing -->
<view wx:if="{{ orderStatusCode == 'Processing' }}" class="txt txt-disabled">当前订单尚未发货,可以取消</view>
<view wx:if="{{ orderStatusCode == 'Processing' }}" class="btn btn-hollow" bindtap="cancelPayment">取消订单</view> <view wx:if="{{ orderStatusCode == 'Processing' }}" class="btn btn-hollow" bindtap="cancelPayment">取消订单</view>
<!-- Shipped --> <!-- Shipped -->
<view wx:if="{{ orderStatusCode == 'Shipped' }}" class="txt txt-disabled">当前订单不可取消,请耐心等待</view> <view wx:if="{{ orderStatusCode == 'Shipped' }}" class="txt txt-disabled">当前订单不可取消,请耐心等待</view>
<view wx:if="{{ orderStatusCode == 'Shipped' }}" class="btn btn-solid" bindtap="confirmReceipt">确认收货</view>
<!-- Delivered --> <!-- Delivered -->
<view wx:if="{{ orderStatusCode == 'Delivered' }}" class="txt txt-done">✅订单已送达</view> <view wx:if="{{ orderStatusCode == 'Delivered' }}" class="txt txt-done">✅订单已送达</view>
</view> </view>
</view> </view>

View File

@ -61,3 +61,14 @@ export function cancelOrder(orderId) {
} }
}) })
} }
/** 确认收货 */
export function confirmOrder(orderId) {
return send_request({
url: '/shop/order/miniprogram/confirmOrder',
method: "POST",
data: {
"orderId": orderId,
}
})
}