fix[litemall-wx, litemall-wx-api]: 调整订单操作。
1. 添加订单则商品货品数量减少 2. 取消订单和退款取消则商品货品数量增加 3. 小程序下单时点击确定模拟支付成功,点击取消模拟支付失败。
This commit is contained in:
@@ -28,7 +28,7 @@ public class OrderUtil {
|
||||
public static final Short STATUS_PAY = 201;
|
||||
public static final Short STATUS_SHIP= 301;
|
||||
public static final Short STATUS_CONFIRM = 401;
|
||||
public static final Short STATUS_CANCEL= 201;
|
||||
public static final Short STATUS_CANCEL= 102;
|
||||
public static final Short STATUS_REFUND = 202;
|
||||
public static final Short STATUS_AUTO_CONFIRM= 402;
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@ package org.linlinjava.litemall.wx.web;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.linlinjava.litemall.db.domain.LitemallAddress;
|
||||
import org.linlinjava.litemall.db.domain.LitemallCart;
|
||||
import org.linlinjava.litemall.db.domain.LitemallOrder;
|
||||
import org.linlinjava.litemall.db.domain.LitemallOrderGoods;
|
||||
import org.linlinjava.litemall.db.domain.*;
|
||||
import org.linlinjava.litemall.db.service.*;
|
||||
import org.linlinjava.litemall.db.util.JacksonUtil;
|
||||
import org.linlinjava.litemall.db.util.OrderHandleOption;
|
||||
@@ -29,7 +26,7 @@ import java.util.Map;
|
||||
*
|
||||
* 订单状态:
|
||||
* 101 订单生成,未支付;102,订单生产,但是未支付就取消;
|
||||
* 201 支付完成,商家未发货;202,订单生产,已付款未发货,却取消
|
||||
* 201 支付完成,商家未发货;202,订单生产,已付款未发货,但是退款取消;
|
||||
* 301 商家发货,用户未确认;
|
||||
* 401 用户确认收货,订单结束; 402 用户没有确认收货,但是快递反馈已收获后,超过一定时间,系统自动确认收货,订单结束。
|
||||
*
|
||||
@@ -39,7 +36,8 @@ import java.util.Map;
|
||||
* 当401用户确认收货以后,此时用户可以进行的操作是删除订单,评价商品,或者再次购买
|
||||
* 当402系统自动确认收货以后,此时用户可以删除订单,评价商品,或者再次购买
|
||||
*
|
||||
* 目前不支持订单退货
|
||||
* 目前不支持订单退货和售后服务
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wx/order")
|
||||
@@ -56,6 +54,8 @@ public class WxOrderController {
|
||||
private LitemallCartService cartService;
|
||||
@Autowired
|
||||
private LitemallRegionService regionService;
|
||||
@Autowired
|
||||
private LitemallProductService productService;
|
||||
|
||||
public WxOrderController() {
|
||||
}
|
||||
@@ -73,12 +73,27 @@ public class WxOrderController {
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* showType:
|
||||
* 0, 全部订单
|
||||
* 1,待付款
|
||||
* 2,待发货
|
||||
* 3,待收货
|
||||
* 4,待评价
|
||||
* @param userId 用户ID
|
||||
* @param showType 订单信息
|
||||
* 0, 全部订单
|
||||
* 1,待付款
|
||||
* 2,待发货
|
||||
* 3,待收货
|
||||
* 4,待评价
|
||||
* @param page 分页页数
|
||||
* @param size 分页大小
|
||||
* @return 订单操作结果
|
||||
* 成功则
|
||||
* {
|
||||
* errno: 0,
|
||||
* errmsg: '成功',
|
||||
* data:
|
||||
* {
|
||||
* data: xxx ,
|
||||
* count: xxx
|
||||
* }
|
||||
* }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("list")
|
||||
public Object list(@LoginUser Integer userId, Integer showType,
|
||||
@@ -127,8 +142,23 @@ public class WxOrderController {
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param orderId 订单信息
|
||||
* @return 订单操作结果
|
||||
* 成功则
|
||||
* {
|
||||
* errno: 0,
|
||||
* errmsg: '成功',
|
||||
* data:
|
||||
* {
|
||||
* orderInfo: xxx ,
|
||||
* orderGoods: xxx
|
||||
* }
|
||||
* }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("detail")
|
||||
@GetMapping("detail")
|
||||
public Object detail(@LoginUser Integer userId, Integer orderId) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
@@ -179,14 +209,24 @@ public class WxOrderController {
|
||||
|
||||
/**
|
||||
* 提交订单
|
||||
* 1. 根据购物车ID、地址ID、优惠券ID,创建订单表项
|
||||
* 2. 购物车清空
|
||||
* 3. TODO 优惠券设置已用
|
||||
* 4. 商品货品数量减少
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ cartId:xxx, addressId: xxx, couponId: xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功', data: { orderInfo: xxx } }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("submit")
|
||||
public Object submit(@LoginUser Integer userId, @RequestBody String body) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if(body == null){
|
||||
return ResponseUtil.fail402();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
Integer cartId = JacksonUtil.parseInteger(body, "cartId");
|
||||
Integer addressId = JacksonUtil.parseInteger(body, "addressId");
|
||||
@@ -202,7 +242,7 @@ public class WxOrderController {
|
||||
// 使用优惠券减免的金额
|
||||
BigDecimal couponPrice = new BigDecimal(0.00);
|
||||
|
||||
// 商品价格
|
||||
// 货品价格
|
||||
List<LitemallCart> checkedGoodsList = null;
|
||||
if (cartId.equals(0)) {
|
||||
checkedGoodsList = cartService.queryByUidAndChecked(userId);
|
||||
@@ -216,8 +256,8 @@ public class WxOrderController {
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
BigDecimal checkedGoodsPrice = new BigDecimal(0.00);
|
||||
for (LitemallCart cart : checkedGoodsList) {
|
||||
checkedGoodsPrice = checkedGoodsPrice.add(cart.getRetailPrice().multiply(new BigDecimal(cart.getNumber())));
|
||||
for (LitemallCart checkGoods : checkedGoodsList) {
|
||||
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getRetailPrice().multiply(new BigDecimal(checkGoods.getNumber())));
|
||||
}
|
||||
|
||||
// 根据订单商品总价计算运费,满88则免运费,否则8元;
|
||||
@@ -239,7 +279,7 @@ public class WxOrderController {
|
||||
order.setUserId(userId);
|
||||
order.setOrderSn(orderService.generateOrderSn(userId));
|
||||
order.setAddTime(LocalDateTime.now());
|
||||
order.setOrderStatus(OrderUtil.STATUS_PAY);
|
||||
order.setOrderStatus(OrderUtil.STATUS_CREATE);
|
||||
order.setConsignee(checkedAddress.getName());
|
||||
order.setMobile(checkedAddress.getMobile());
|
||||
String detailedAddress = detailedAddress(checkedAddress);
|
||||
@@ -271,51 +311,207 @@ public class WxOrderController {
|
||||
// 删除购物车里面的商品信息
|
||||
cartService.clearGoods(userId);
|
||||
|
||||
// 商品货品数量减少
|
||||
for (LitemallCart checkGoods : checkedGoodsList) {
|
||||
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getRetailPrice().multiply(new BigDecimal(checkGoods.getNumber())));
|
||||
Integer productId= checkGoods.getProductId();
|
||||
LitemallProduct product = productService.findById(productId);
|
||||
if(product == null){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
Integer remainNumber = product.getGoodsNumber() - checkGoods.getNumber();
|
||||
if(remainNumber < 0){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
product.setGoodsNumber(remainNumber);
|
||||
productService.updateById(product);
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("orderInfo", order);
|
||||
return ResponseUtil.ok(data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
* 1. 检测当前订单是否能够取消
|
||||
* 2. 设置订单取消状态
|
||||
* 3. 商品货品数量增加
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("cancel")
|
||||
public Object cancel(@LoginUser Integer userId, Integer orderId) {
|
||||
@PostMapping("cancel")
|
||||
public Object cancel(@LoginUser Integer userId, @RequestBody String body) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
|
||||
if(orderId == null){
|
||||
return ResponseUtil.fail402();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
if(order == null){
|
||||
return ResponseUtil.fail403();
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
// 检测是否能够取消
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
if(!handleOption.isCancel()){
|
||||
return ResponseUtil.fail(403, "订单不能取消");
|
||||
}
|
||||
|
||||
order.setOrderStatus((short)102);
|
||||
// 设置订单已取消状态
|
||||
order.setOrderStatus(OrderUtil.STATUS_CANCEL);
|
||||
orderService.update(order);
|
||||
|
||||
// 商品货品数量增加
|
||||
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
|
||||
for(LitemallOrderGoods orderGoods : orderGoodsList){
|
||||
Integer productId = orderGoods.getProductId();
|
||||
LitemallProduct product = productService.findById(productId);
|
||||
if(product == null){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
Integer number = product.getGoodsNumber() + orderGoods.getNumber();
|
||||
product.setGoodsNumber(number);
|
||||
productService.updateById(product);
|
||||
}
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("refund")
|
||||
public Object refund(@LoginUser Integer userId, Integer orderId) {
|
||||
/**
|
||||
* 付款
|
||||
* 1. 检测当前订单是否能够付款
|
||||
* 2. 设置订单付款状态
|
||||
* 3. TODO 微信后台申请支付,同时设置付款状态
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("pay")
|
||||
public Object pay(@LoginUser Integer userId, @RequestBody String body) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
|
||||
if(orderId == null){
|
||||
return ResponseUtil.fail402();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
if(order == null){
|
||||
return ResponseUtil.fail403();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
// 检测是否能够付款
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
if(!handleOption.isPay()){
|
||||
return ResponseUtil.fail(403, "订单不能付款");
|
||||
}
|
||||
|
||||
// 微信后台申请微信支付订单号
|
||||
String payId = "";
|
||||
// 微信支付订单号生产未支付
|
||||
Short payStatus = 1;
|
||||
|
||||
order.setOrderStatus(OrderUtil.STATUS_PAY);
|
||||
order.setPayId(payId);
|
||||
order.setPayStatus(payStatus);
|
||||
orderService.update(order);
|
||||
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 付款成功回调接口
|
||||
* 1. 检测当前订单是否是付款状态
|
||||
* 2. 设置订单付款成功状态相关信息
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx, payId: xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*
|
||||
* 注意,这里pay_notify是示例地址,开发者应该设立一个隐蔽的回调地址
|
||||
* TODO 这里需要根据微信支付文档设计
|
||||
*/
|
||||
@PostMapping("pay_notify")
|
||||
public Object pay_notify(@LoginUser Integer userId, @RequestBody String body) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
|
||||
Integer payId = JacksonUtil.parseInteger(body, "payId");
|
||||
if(orderId == null || payId == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
if(order == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
// 检测是否是付款状态
|
||||
if(!order.getOrderStatus().equals(OrderUtil.STATUS_PAY)){
|
||||
logger.error("系统内部错误");
|
||||
}
|
||||
if(!order.getPayId().equals(payId)){
|
||||
logger.error("系统内部错误");
|
||||
}
|
||||
|
||||
Short payStatus = (short)2;
|
||||
order.setPayStatus(payStatus);
|
||||
order.setPayTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退款取消订单
|
||||
* 1. 检测当前订单是否能够退款取消
|
||||
* 2. 设置订单退款取消状态
|
||||
* 3. TODO 退款
|
||||
* 4. 商品货品数量增加
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("refund")
|
||||
public Object refund(@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.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
@@ -323,27 +519,179 @@ public class WxOrderController {
|
||||
return ResponseUtil.fail(403, "订单不能取消");
|
||||
}
|
||||
|
||||
// 设置订单取消状态
|
||||
order.setOrderStatus(OrderUtil.STATUS_REFUND);
|
||||
orderService.update(order);
|
||||
|
||||
// 退款操作
|
||||
|
||||
// 设置订单取消状态
|
||||
order.setOrderStatus((short)202);
|
||||
// 商品货品数量增加
|
||||
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
|
||||
for(LitemallOrderGoods orderGoods : orderGoodsList){
|
||||
Integer productId = orderGoods.getProductId();
|
||||
LitemallProduct product = productService.findById(productId);
|
||||
if(product == null){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
Integer number = product.getGoodsNumber() + orderGoods.getNumber();
|
||||
product.setGoodsNumber(number);
|
||||
productService.updateById(product);
|
||||
}
|
||||
|
||||
orderService.update(order);
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
public Object delete(@LoginUser Integer userId, Integer orderId) {
|
||||
/**
|
||||
* 发货
|
||||
* 1. 检测当前订单是否能够发货
|
||||
* 2. 设置订单发货状态
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx, shipSn: xxx, shipChannel: xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("ship")
|
||||
public Object ship(@LoginUser Integer userId, @RequestBody String body) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if(orderId == null){
|
||||
return ResponseUtil.fail402();
|
||||
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
|
||||
String shipSn = JacksonUtil.parseString(body, "shipSn");
|
||||
String shipChannel = JacksonUtil.parseString(body, "shipChannel");
|
||||
if(orderId == null || shipSn == null || shipChannel == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
if(order == null){
|
||||
return ResponseUtil.fail403();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
// 如果订单不是已付款状态,则不能发货
|
||||
if(!order.getOrderStatus().equals(OrderUtil.STATUS_PAY)){
|
||||
return ResponseUtil.fail(403, "订单不能确认收货");
|
||||
}
|
||||
|
||||
order.setOrderStatus(OrderUtil.STATUS_SHIP);
|
||||
order.setShipSn(shipSn);
|
||||
order.setShipChannel(shipChannel);
|
||||
order.setShipStartTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认收货
|
||||
* 1. 检测当前订单是否能够确认订单
|
||||
* 2. 设置订单确认状态
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("confirm")
|
||||
public Object confirm(@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.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
if(!handleOption.isConfirm()){
|
||||
return ResponseUtil.fail(403, "订单不能确认收货");
|
||||
}
|
||||
|
||||
order.setOrderStatus(OrderUtil.STATUS_CONFIRM);
|
||||
order.setConfirmTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自动确认收货
|
||||
* 1. 检测当前订单是否能够自动确认订单
|
||||
* 2. 设置订单自动确认状态
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("autoconfirm")
|
||||
public Object autoconfirm(@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.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
if(!handleOption.isConfirm()){
|
||||
return ResponseUtil.fail(403, "订单不能确认收货");
|
||||
}
|
||||
|
||||
order.setOrderStatus(OrderUtil.STATUS_AUTO_CONFIRM);
|
||||
order.setConfirmTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
* 1. 检测当前订单是否删除
|
||||
* 2. 设置订单删除状态
|
||||
* @param userId 用户ID
|
||||
* @param body 订单信息,{ orderId:xxx }
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功' }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public Object delete(@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.badArgument();
|
||||
}
|
||||
if(!order.getUserId().equals(userId)){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
}
|
||||
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
@@ -352,50 +700,29 @@ public class WxOrderController {
|
||||
}
|
||||
|
||||
// 订单order_status没有字段用于标识删除
|
||||
// 而是存在专门的is_delete字段表示是否删除
|
||||
// 而是存在专门的delete字段表示是否删除
|
||||
orderService.deleteById(orderId);
|
||||
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户确认收货
|
||||
* 可以评价的订单商品信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param orderId 订单ID
|
||||
* @param goodsId 商品ID
|
||||
* @return 订单操作结果
|
||||
* 成功则 { errno: 0, errmsg: '成功', data: xxx }
|
||||
* 失败则 { errno: XXX, errmsg: XXX }
|
||||
*/
|
||||
@RequestMapping("confirm")
|
||||
public Object confirm(@LoginUser Integer userId, Integer orderId) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
}
|
||||
if(orderId == null){
|
||||
return ResponseUtil.fail402();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(orderId);
|
||||
if(order == null){
|
||||
return ResponseUtil.fail403();
|
||||
}
|
||||
|
||||
OrderHandleOption handleOption = OrderUtil.build(order);
|
||||
if(!handleOption.isConfirm()){
|
||||
return ResponseUtil.fail(403, "订单不能确认收货");
|
||||
}
|
||||
|
||||
order.setOrderStatus((short)401);
|
||||
order.setConfirmTime(LocalDateTime.now());
|
||||
orderService.update(order);
|
||||
return ResponseUtil.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户评价的商品信息
|
||||
*/
|
||||
@RequestMapping("comment")
|
||||
@GetMapping("comment")
|
||||
public Object comment(@LoginUser Integer userId, Integer orderId, Integer goodsId) {
|
||||
if(userId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if(orderId == null || goodsId == null){
|
||||
return ResponseUtil.fail402();
|
||||
if(orderId == null){
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
|
||||
|
||||
@@ -12,7 +12,7 @@ Page({
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
this.setData({
|
||||
orderId: options.orderId,
|
||||
status: options.status
|
||||
status: options.status === '1' ? true : false
|
||||
})
|
||||
},
|
||||
onReady: function () {
|
||||
|
||||
@@ -109,27 +109,43 @@ Page({
|
||||
// 目前不能支持微信支付,这里仅仅是模拟支付成功,同理,后台也仅仅是返回一个成功的消息而已
|
||||
wx.showModal({
|
||||
title: '目前不能微信支付',
|
||||
content: '点击确定模拟支付成功',
|
||||
showCancel: false,
|
||||
success: function(res) {
|
||||
wx.redirectTo({
|
||||
url: '/pages/payResult/payResult?status=true&orderId=' + orderId
|
||||
});
|
||||
content: '点击确定模拟支付成功,点击取消模拟未支付成功',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
util.request(api.OrderPay, { orderId: orderId }, 'POST').then(res => {
|
||||
if (res.errno === 0) {
|
||||
wx.redirectTo({
|
||||
url: '/pages/payResult/payResult?status=1&orderId=' + orderId
|
||||
});
|
||||
}
|
||||
else{
|
||||
wx.redirectTo({
|
||||
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (res.cancel) {
|
||||
wx.redirectTo({
|
||||
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// pay.payOrder(orderId).then(res => {
|
||||
// wx.redirectTo({
|
||||
// url: '/pages/payResult/payResult?status=true&orderId=' + orderId
|
||||
// url: '/pages/payResult/payResult?status=1&orderId=' + orderId
|
||||
// });
|
||||
// }).catch(res => {
|
||||
// wx.redirectTo({
|
||||
// url: '/pages/payResult/payResult?status=false&orderId=' + orderId
|
||||
// url: '/pages/payResult/payResult?status=0&orderId=' + orderId
|
||||
// });
|
||||
// });
|
||||
// } else {
|
||||
// wx.redirectTo({
|
||||
// url: '/pages/payResult/payResult?status=false&orderId=' + orderId
|
||||
// url: '/pages/payResult/payResult?status=0&orderId=' + orderId
|
||||
// });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ Page({
|
||||
let that = this;
|
||||
util.request(api.PayPrepayId, {
|
||||
orderId: that.data.orderId
|
||||
}).then(function (res) {
|
||||
}, 'POST').then(function (res) {
|
||||
if (res.errno === 0) {
|
||||
const payParam = res.data;
|
||||
wx.requestPayment({
|
||||
@@ -67,7 +67,7 @@ Page({
|
||||
if (res.confirm) {
|
||||
util.request(api.OrderCancel, {
|
||||
orderId: orderInfo.id
|
||||
}).then(function (res) {
|
||||
}, 'POST').then(function (res) {
|
||||
if (res.errno === 0) {
|
||||
wx.showToast({
|
||||
title: '取消订单成功'
|
||||
@@ -94,7 +94,7 @@ Page({
|
||||
if (res.confirm) {
|
||||
util.request(api.OrderRefund, {
|
||||
orderId: orderInfo.id
|
||||
}).then(function (res) {
|
||||
}, 'POST').then(function (res) {
|
||||
if (res.errno === 0) {
|
||||
wx.showToast({
|
||||
title: '取消订单成功'
|
||||
@@ -109,7 +109,7 @@ Page({
|
||||
}
|
||||
});
|
||||
},
|
||||
// “取消订单并退款”点击效果
|
||||
// “删除”点击效果
|
||||
deleteOrder: function () {
|
||||
let that = this;
|
||||
let orderInfo = that.data.orderInfo;
|
||||
@@ -121,7 +121,7 @@ Page({
|
||||
if (res.confirm) {
|
||||
util.request(api.OrderDelete, {
|
||||
orderId: orderInfo.id
|
||||
}).then(function (res) {
|
||||
}, 'POST').then(function (res) {
|
||||
if (res.errno === 0) {
|
||||
wx.showToast({
|
||||
title: '删除订单成功'
|
||||
@@ -148,7 +148,7 @@ Page({
|
||||
if (res.confirm) {
|
||||
util.request(api.OrderConfirm, {
|
||||
orderId: orderInfo.id
|
||||
}).then(function (res) {
|
||||
}, 'POST').then(function (res) {
|
||||
if (res.errno === 0) {
|
||||
wx.showToast({
|
||||
title: '确认收货成功!'
|
||||
|
||||
Reference in New Issue
Block a user