Commit c384707b authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-wx, litemall-wx-api]: 订单API调整及文档

parent 833035ca
......@@ -158,7 +158,7 @@ list是对象数组,total是总的数量。
"password': "user123'
}
2. 成功以后,会接收后端想要的一个token,
2. 成功以后,前端会接收后端响应的一个token,
{
"errno": 0,
......@@ -1399,12 +1399,58 @@ API应该存在版本控制,以保证兼容性。
接口链接
GET /wx/order/list
请求参数
showType: 订单类型,0则全部,1则待付款,2则待发货,3则待收货,4则代评价
page: 请求页码
limit: 每一页数量
sort: 排序字段
order: 升序降序
响应结果
{
"errno": 0,
"data": {
"total": 1,
"pages": 1,
"limit": 10,
"page": 1,
"list": [
{
"orderStatusText": "未付款",
"isGroupin": false,
"orderSn": "20190509607545",
"actualPrice": 3989.00,
"goodsList": [
{
"number": 1,
"picUrl": "http://yanxuan.nosdn.127.net/c5be2604c0e4186a4e7079feeb742cee.png",
"id": 3,
"goodsName": "云端沙发组合",
"specifications": [
"标准"
]
}
],
"id": 3,
"handleOption": {
"cancel": true,
"delete": false,
"pay": true,
"comment": false,
"confirm": false,
"refund": false,
"rebuy": false
}
}
]
},
"errmsg": "成功"
}
错误码
......@@ -1417,15 +1463,68 @@ API应该存在版本控制,以保证兼容性。
接口链接
GET /wx/order/detail
请求参数
orderId: 订单ID
响应结果
{
"errno": 0,
"data": {
"orderInfo": {
"consignee": "d",
"address": "北京市市辖区东城区 ddd",
"addTime": "2019-05-09 15:30:29",
"orderSn": "20190509607545",
"actualPrice": 3989.00,
"mobile": "13811111111",
"orderStatusText": "未付款",
"goodsPrice": 3999.00,
"couponPrice": 10.00,
"id": 3,
"freightPrice": 0.00,
"handleOption": {
"cancel": true,
"delete": false,
"pay": true,
"comment": false,
"confirm": false,
"refund": false,
"rebuy": false
}
},
"orderGoods": [
{
"id": 3,
"orderId": 3,
"goodsId": 1109008,
"goodsName": "云端沙发组合",
"goodsSn": "1109008",
"productId": 140,
"number": 1,
"price": 3999.00,
"specifications": [
"标准"
],
"picUrl": "http://yanxuan.nosdn.127.net/c5be2604c0e4186a4e7079feeb742cee.png",
"comment": 0,
"addTime": "2019-05-09 15:30:29",
"updateTime": "2019-05-09 15:30:29",
"deleted": false
}
]
},
"errmsg": "成功"
}
错误码
#### 2.6.3 创建订单
#### 2.6.3 创建订单
应用场景
......@@ -1433,13 +1532,29 @@ API应该存在版本控制,以保证兼容性。
接口链接
POST /wx/order/submit
请求参数
{
"cartId": 0,
"addressId": 3,
"couponId": -1,
"message": "",
"grouponRulesId": 0,
"grouponLinkId": 0
}
响应结果
{
"errno": 0,
"data": {
"orderId": 4
},
"errmsg": "成功"
}
错误码
......@@ -1452,18 +1567,24 @@ API应该存在版本控制,以保证兼容性。
接口链接
POST /wx/order/cancel
请求参数
orderId: 订单ID
响应结果
{
"errno": 0,
"errmsg": "成功"
}
错误码
#### 2.6.4 订单的微信预支付交易单
#### 2.6.5 微信预支付交易单
应用场景
......@@ -1471,21 +1592,200 @@ API应该存在版本控制,以保证兼容性。
接口链接
POST /wx/order/prepay
说明
具体微信支付交互流程和预支付使用方式,见官方文档: https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_3&index=1
请求参数
orderId: 订单ID
响应结果
{
errno: 0,
errmsg: "成功"
errmsg: "成功",
data: {
appId: 'xxx',
timeStamp: 'xxx',
nonceStr: 'xxx',
packageValue: 'xxx',
signType: 'xxx',
paySign: 'xxx'
}
}
错误码
#### 2.6.6 确认收货
应用场景
订单确认收货
接口链接
POST /wx/order/confirm
请求参数
orderId: 订单ID
响应结果
{
"errno": 0,
"errmsg": "成功"
}
错误码
#### 2.6.7 订单删除
应用场景
删除订单记录
接口链接
POST /wx/order/delete
请求参数
orderId: 订单ID
响应结果
{
"errno": 0,
"errmsg": "成功"
}
错误码
#### 2.6.8 订单退款
应用场景
订单已经支付但是商家未发货,用户可以点击退款按钮申请退款取消订单。
说明
退款请求发送以后,不会自动退款,仅仅是后端设置退款请求记录。
管理员在管理后台看到退款请求以后会手动退款或者拒绝退款。
接口链接
POST /wx/order/refund
请求参数
orderId: 订单ID
响应结果
{
"errno": 0,
"errmsg": "成功"
}
错误码
#### 2.6.9 待评价商品
应用场景
用户确认收货以后,可以待评价的订单商品。
接口链接
GET /wx/order/goods
请求参数
orderId: 订单ID
goodsId: 商品ID
响应结果
{
"errno": 0,
"data": {
"id": 4,
"orderId": 4,
"goodsId": 1109008,
"goodsName": "云端沙发组合",
"goodsSn": "1109008",
"productId": 140,
"number": 1,
"price": 3999.00,
"specifications": [
"标准"
],
"picUrl": "http://yanxuan.nosdn.127.net/c5be2604c0e4186a4e7079feeb742cee.png",
"comment": 0,
"addTime": "2019-05-09 17:06:54",
"updateTime": "2019-05-09 17:06:54",
"deleted": false
},
"errmsg": "成功"
}
错误码
#### 2.6.10 订单评价
应用场景
订单评价
接口链接
POST /wx/order/comment
请求参数
orderGoodsId: 订单商品ID
content: 评价内容
star: 评分,1分至5分
hasPicture: 是否有评价图片
picUrls: 评价图片列表
例如
{
"orderGoodsId": 4,
"content": "不错",
"star": 5,
"hasPicture": true,
"picUrls": []
}
响应结果
{
"errno": 0,
"errmsg": "成功"
}
错误码
### 2.7 会员服务
### 2.8 收货地址服务
......@@ -1502,7 +1802,6 @@ API应该存在版本控制,以保证兼容性。
请求参数
userId: 用户ID
page: 请求页码
limit: 每一页数量
sort: 排序字段
......@@ -1554,7 +1853,6 @@ API应该存在版本控制,以保证兼容性。
请求参数
userId: 用户ID
id: 收货地址ID
响应结果
......@@ -2761,6 +3059,8 @@ API应该存在版本控制,以保证兼容性。
### 2.19 对象存储服务
### 2.20 其他服务
## 3 管理后台API服务
......
......@@ -69,7 +69,7 @@ public class LitemallOrderService {
return orderSn;
}
public List<LitemallOrder> queryByOrderStatus(Integer userId, List<Short> orderStatus, Integer page, Integer limit) {
public List<LitemallOrder> queryByOrderStatus(Integer userId, List<Short> orderStatus, Integer page, Integer limit, String sort, String order) {
LitemallOrderExample example = new LitemallOrderExample();
example.setOrderByClause(LitemallOrder.Column.addTime.desc());
LitemallOrderExample.Criteria criteria = example.or();
......@@ -78,6 +78,10 @@ public class LitemallOrderService {
criteria.andOrderStatusIn(orderStatus);
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
PageHelper.startPage(page, limit);
return litemallOrderMapper.selectByExample(example);
}
......
......@@ -8,7 +8,6 @@ import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.pagehelper.PageInfo;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
......@@ -120,33 +119,31 @@ public class WxOrderService {
* @param limit 分页大小
* @return 订单列表
*/
public Object list(Integer userId, Integer showType, Integer page, Integer limit) {
public Object list(Integer userId, Integer showType, Integer page, Integer limit, String sort, String order) {
if (userId == null) {
return ResponseUtil.unlogin();
}
List<Short> orderStatus = OrderUtil.orderStatus(showType);
List<LitemallOrder> orderList = orderService.queryByOrderStatus(userId, orderStatus, page, limit);
long count = PageInfo.of(orderList).getTotal();
int totalPages = (int) Math.ceil((double) count / limit);
List<LitemallOrder> orderList = orderService.queryByOrderStatus(userId, orderStatus, page, limit, sort, order);
List<Map<String, Object>> orderVoList = new ArrayList<>(orderList.size());
for (LitemallOrder order : orderList) {
for (LitemallOrder o : orderList) {
Map<String, Object> orderVo = new HashMap<>();
orderVo.put("id", order.getId());
orderVo.put("orderSn", order.getOrderSn());
orderVo.put("actualPrice", order.getActualPrice());
orderVo.put("orderStatusText", OrderUtil.orderStatusText(order));
orderVo.put("handleOption", OrderUtil.build(order));
orderVo.put("id", o.getId());
orderVo.put("orderSn", o.getOrderSn());
orderVo.put("actualPrice", o.getActualPrice());
orderVo.put("orderStatusText", OrderUtil.orderStatusText(o));
orderVo.put("handleOption", OrderUtil.build(o));
LitemallGroupon groupon = grouponService.queryByOrderId(order.getId());
LitemallGroupon groupon = grouponService.queryByOrderId(o.getId());
if (groupon != null) {
orderVo.put("isGroupin", true);
} else {
orderVo.put("isGroupin", false);
}
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(o.getId());
List<Map<String, Object>> orderGoodsVoList = new ArrayList<>(orderGoodsList.size());
for (LitemallOrderGoods orderGoods : orderGoodsList) {
Map<String, Object> orderGoodsVo = new HashMap<>();
......@@ -162,12 +159,7 @@ public class WxOrderService {
orderVoList.add(orderVo);
}
Map<String, Object> result = new HashMap<>();
result.put("count", count);
result.put("data", orderVoList);
result.put("totalPages", totalPages);
return ResponseUtil.ok(result);
return ResponseUtil.okList(orderVoList, orderList);
}
/**
......
......@@ -2,6 +2,8 @@ package org.linlinjava.litemall.wx.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.WxOrderService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,8 +36,10 @@ public class WxOrderController {
public Object list(@LoginUser Integer userId,
@RequestParam(defaultValue = "0") Integer showType,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
return wxOrderService.list(userId, showType, page, limit);
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
return wxOrderService.list(userId, showType, page, limit, sort, order);
}
/**
......
......@@ -60,6 +60,11 @@ Page({
},
goOrder() {
if (this.data.hasLogin) {
try {
wx.setStorageSync('tab', 0);
} catch (e) {
}
wx.navigateTo({
url: "/pages/ucenter/order/order"
});
......
......@@ -6,7 +6,7 @@ Page({
orderList: [],
showType: 0,
page: 1,
size: 10,
limit: 10,
totalPages: 1
},
onLoad: function(options) {
......@@ -26,13 +26,13 @@ Page({
util.request(api.OrderList, {
showType: that.data.showType,
page: that.data.page,
size: that.data.size
limit: that.data.limit
}).then(function(res) {
if (res.errno === 0) {
console.log(res.data);
that.setData({
orderList: that.data.orderList.concat(res.data.data),
totalPages: res.data.totalPages
orderList: that.data.orderList.concat(res.data.list),
totalPages: res.data.pages
});
}
});
......@@ -58,7 +58,7 @@ Page({
orderList: [],
showType: showType,
page: 1,
size: 10,
limit: 10,
totalPages: 1
});
this.getOrderList();
......
......@@ -6,7 +6,7 @@ Page({
orderList: [],
showType: 0,
page: 1,
size: 10,
limit: 10,
totalPages: 1
},
onLoad: function(options) {
......@@ -26,12 +26,12 @@ Page({
util.request(api.OrderList, {
showType: that.data.showType,
page: that.data.page,
size: that.data.size
limit: that.data.limit
}).then(function(res) {
if (res.errno === 0) {
that.setData({
orderList: that.data.orderList.concat(res.data.data),
totalPages: res.data.totalPages
orderList: that.data.orderList.concat(res.data.list),
totalPages: res.data.pages
});
wx.hideLoading();
}
......@@ -58,7 +58,7 @@ Page({
orderList: [],
showType: showType,
page: 1,
size: 10,
limit: 10,
totalPages: 1
});
this.getOrderList();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment