Authored by tanling

订单列表 and 详情

... ... @@ -14,7 +14,9 @@ public interface BuyerOrderGoodsMapper {
BuyerOrderGoods selectByPrimaryKey(Integer id);
List<BuyerOrderGoods> selectByOrderCode(@Param("list") List<Long> orderCodeList);
List<BuyerOrderGoods> selectByOrderCodeList(@Param("uid") int uid, @Param("list") List<Long> orderCodeList);
BuyerOrderGoods selectByOrderCode(@Param("uid") int uid, @Param("orderCode") long orderCode);
int updateByPrimaryKeySelective(BuyerOrderGoods record);
... ...
... ... @@ -7,12 +7,22 @@ public class BuyerOrderGoods {
private Long orderCode;
private Integer uid;
private Integer skup;
private BigDecimal goodsPrice;
private BigDecimal goodsAmount;
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Integer getId() {
return id;
}
... ...
... ... @@ -3,13 +3,14 @@
<mapper namespace="com.yohoufo.dal.order.BuyerOrderGoodsMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.BuyerOrderGoods">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="skup" jdbcType="INTEGER" property="skup" />
<result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
<result column="goods_amount" jdbcType="DECIMAL" property="goodsAmount" />
</resultMap>
<sql id="Base_Column_List">
id, order_code, skup, goods_price, goods_amount
id, order_code, skup, goods_price, goods_amount, uid
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
... ... @@ -19,11 +20,12 @@
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByOrderCode" resultMap="BaseResultMap">
<select id="selectByOrderCodeList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from buyer_order_goods
where 1=1
and uid = #{uid,jdbcType=INTEGER}
<if test="list != null">
and order_code in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
... ... @@ -32,6 +34,17 @@
</if>
</select>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from buyer_order_goods
where 1=1
and uid = #{uid,jdbcType=INTEGER}
and order_code = #{orderCode,jdbcType=BIGINT}
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from buyer_order_goods
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -74,6 +74,7 @@
from buyer_order
where order_code = #{orderCode,jdbcType=BIGINT}
and uid = #{uid,jdbcType=INTEGER}
and order_status = 1
limit 1
</select>
... ...
package com.yohoufo.order.common;
import com.google.common.collect.Lists;
import com.yohoufo.order.constants.OrderDetailDesc;
import java.util.Arrays;
import java.util.List;
... ... @@ -8,102 +11,157 @@ public enum OrderStatus {
WAITING_PAY(0,
"未付款",
"待付款",
Arrays.asList(ButtonShow.CANCEL_ORDER, ButtonShow.NOW_BUY)),
Arrays.asList(ButtonShow.CANCEL_ORDER, ButtonShow.NOW_BUY),
Arrays.asList(ButtonShow.CANCEL_ORDER, ButtonShow.NOW_BUY),
OrderDetailDesc.NO_PAY),
HAS_PAYED(1,
"已付款",
"商品调拨中",
Arrays.asList(ButtonShow.SHOW_DETAIL)),
Arrays.asList(ButtonShow.SHOW_DETAIL),
Lists.newArrayList(),
OrderDetailDesc.BUY_HAS_PAID),
SELLER_SEND_OUT(2,
"商品调拨中(卖家发货,可查物流)",
"商品调拨中",
Arrays.asList(ButtonShow.SHOW_DETAIL)),
Arrays.asList(ButtonShow.SHOW_DETAIL),
Lists.newArrayList(),
OrderDetailDesc.SELL_HAS_SENDED),
PLATFORM_CHECKING(3,
"有货平台鉴定中",
"有货平台鉴定中",
Arrays.asList(ButtonShow.SHOW_DETAIL)),
Arrays.asList(ButtonShow.SHOW_DETAIL),
Lists.newArrayList(),
OrderDetailDesc.PLATFORM_SEND),
WAITING_RECEIVE(4,
"待收货",
"待收货",
Arrays.asList(ButtonShow.SHOW_EXPRESS, ButtonShow.CONFIRM_DELIVERY)),
Arrays.asList(ButtonShow.SHOW_EXPRESS, ButtonShow.CONFIRM_DELIVERY),
Arrays.asList(ButtonShow.SHOW_EXPRESS, ButtonShow.CONFIRM_DELIVERY),
OrderDetailDesc.CHECK_OK_SEND),
DONE(5,
"已完成",
"交易成功",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
SELLER_CANCEL_BEFORE_PAY(10,
"买家付款前卖家取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
OrderDetailDesc.DONE),
// TODO 这种状态不存在
// SELLER_CANCEL_BEFORE_PAY(10,
// "买家付款前卖家取消",
// "交易失败",
// Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
// Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
// ),
SELLER_CANCEL_AFTER_PAY(11,
"买家付款后卖家取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
OrderDetailDesc.SELL_CANCEL_SEND),
SEND_OUT_TIMEOUT(12,
"超时未发货取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
OrderDetailDesc.SELL_TIMETOUT_CANCEL),
CHECKING_FAKE(13,
"鉴定不通过取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
OrderDetailDesc.CHECK_FAKE),
BUYER_CANCEL_BEFORE_PAY(14,
"支付前取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
OrderDetailDesc.BUY_CANCEL),
BUYER_CANCEL_TIMEOUT(15,
"超时未支付取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER)),
CUSTOMER_SERVICE(17,
"客服取消",
"交易失败",
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER))
Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
OrderDetailDesc.BUY_TIMEOUT_CANCEL),
// CUSTOMER_SERVICE(17,
// "客服取消",
// "交易失败",
// Arrays.asList(ButtonShow.SHOW_DETAIL, ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER),
// Arrays.asList(ButtonShow.BUY_AGAIN, ButtonShow.DEL_ORDER))
;
int code;
String desc;
String listStatusStr;
/**
* 列表or详情显示状态
*/
String statusStr;
List<ButtonShow> buttonList;
/**
* 订单列表中的按钮
*/
List<ButtonShow> listButtons;
/**
* 详情的按钮
*/
List<ButtonShow> detailButtons;
/**
* 详情页状态说明
*/
String detailDesc;
/**
*
* @param code db中code
* @param desc db中code的含义
* @param listStatusStr 订单列表中状态显示
* @param buttonList 订单列表显示的按钮
* @param statusStr 订单列表中状态显示
* @param listButtons 订单列表显示的按钮
*/
OrderStatus(int code, String desc, String listStatusStr, List<ButtonShow> buttonList) {
OrderStatus(int code, String desc, String statusStr, List<ButtonShow> listButtons,
List<ButtonShow> detailButtons, String detailDesc) {
this.code = code;
this.desc = desc;
this.listStatusStr = listStatusStr;
this.buttonList = buttonList;
this.statusStr = statusStr;
this.listButtons = listButtons;
this.detailButtons = detailButtons;
this.detailDesc = detailDesc;
}
public int getCode() {
return code;
}
public List<ButtonShow> getButtonList() {
return buttonList;
public List<ButtonShow> getListButtons() {
return listButtons;
}
public List<ButtonShow> getDetailButtons() {
return detailButtons;
}
public String getDetailDesc() {
return detailDesc;
}
public String getListStatusStr() {
return listStatusStr;
public String getStatusStr() {
return statusStr;
}
public static OrderStatus getOrderStatus(int code){
... ...
... ... @@ -2,8 +2,8 @@ package com.yohoufo.order.common;
public enum Payment {
ALIPAY(1, "trade.precreate"),
WECHAT(2, "wx.unifiedOrder");
ALIPAY(1, "trade.precreate", "支付宝"),
WECHAT(2, "wx.unifiedOrder", "微信");
int code;
... ... @@ -12,9 +12,12 @@ public enum Payment {
*/
String value;
Payment(int code, String value) {
String desc;
Payment(int code, String value, String desc) {
this.code = code;
this.value = value;
this.desc = desc;
}
public int getCode() {
... ... @@ -25,6 +28,10 @@ public enum Payment {
return value;
}
public String getDesc() {
return desc;
}
/**
* 检查是否存在该支付方式
* @param code
... ...
package com.yohoufo.order.common;
public enum TabType {
BUY("buy"),
SELL("sell");
String value;
TabType(String value) {
this.value = value;
}
public static TabType getTabType(String value){
for(TabType v : values()){
if(v.value.equals(value)){
return v;
}
}
return null;
}
}
... ...
... ... @@ -43,5 +43,7 @@ public interface OrderConstant {
String SPLIT_STR = "_";
String EXPRESS_SENDTIME_TO_QUERY = "express_sendtime";
}
... ...
package com.yohoufo.order.constants;
public interface OrderDetailDesc {
/**
* 买家拍下商品未支付
*/
String NO_PAY = "请在15分钟内完成付款,超时付款将自动取消订单";
/**
* 买家拍下商品未支付后主动取消购买
*/
String BUY_CANCEL = "您已取消商品购买";
/**
* 买家拍下商品未支付系统超时
*/
String BUY_TIMEOUT_CANCEL = "您未在15分钟内付款,系统取消订单";
/**
* 买家拍下并付款
*/
String BUY_HAS_PAID = "商品调拨中预计3-5个工作日,请耐心等待";
/**
* 买家下单成功,卖家取消发货
*/
String SELL_CANCEL_SEND = "卖家取消商品出售,你已获得卖家补偿款,请留意收款银行卡到账通知";
/**
* 买家下单成功,卖家发货超时
*/
String SELL_TIMETOUT_CANCEL = "您发货超时,系统取消订单,您支付的保证金作已为补偿赔付给买家";
/**
* 卖家已发货
*/
String SELL_HAS_SENDED = "商品调拨中预计3-5个工作日,请耐心等待";
/**
* 平台已收货
*/
String PLATFORM_SEND = "有货鉴定中心已收货,您购买的商品正在鉴定中,鉴定通过以后会尽快为您发货";
/**
* 商品鉴定不通过,到付退还商品至卖家
*/
String CHECK_FAKE = "您购买的商品鉴定未通过,你已获得卖家补偿款,请留意收款银行卡到账通知";
/**
* 商品鉴定通过,给买家发货 非直接显示
*/
String CHECK_OK_SEND = OrderConstant.EXPRESS_SENDTIME_TO_QUERY;
/**
* 用户确认收货/物流返回妥投状态/物流未返回妥投且用户未主动确认收货,发货后7天自动确认收货
* 非直接显示
*/
String DONE = OrderConstant.EXPRESS_SENDTIME_TO_QUERY;
}
... ...
... ... @@ -2,7 +2,8 @@ package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.response.OrderInfoListRsp;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -41,8 +42,30 @@ public class BuyerOrderController {
.page(page)
.limit(limit)
.build();
OrderInfoListRsp orderInfoListRsp = buyerOrderService.getOrderList(orderListRequest);
OrderListInfoRsp orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderInfoListRsp).message("订单列表").build();
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("订单列表").build();
}
/**
* 订单详情
* @param orderCode
* @param uid
* @return
*/
@RequestMapping(params = "method=app.buyer.detail")
@ResponseBody
public ApiResponse getOrderDetail(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid,
@RequestParam("tabType") String tabType) {
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.orderCode(orderCode)
.tabType(tabType)
.build();
return null;
}
}
... ...
package com.yohoufo.order.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OrderRequest {
int uid;
long orderCode;
String tabType;
}
... ...
package com.yohoufo.order.response;
import lombok.Data;
@Data
public class GoodsInfo {
int skup;
/**
* 商品题目
*/
String productName;
/**
* 商品图片
*/
String imageUrl;
String colorName;
String sizeName;
/**
* 商品价格
*/
String goodPrice;
}
... ...
package com.yohoufo.order.response;
import com.yohoufo.order.common.ButtonShow;
import lombok.Data;
import lombok.experimental.Builder;
import java.util.List;
@Data
public class OrderDetailInfo {
int uid;
long orderCode;
/**
* 商品信息
*/
GoodsInfo goodsInfo;
/**
* 状态详细
*/
StatusDetail statusDetail;
/**
* 价格详细
*/
PriceInfo priceInfo;
/**
* TODO 用户收货情报
*/
/**
* 按钮显示
*/
List<ButtonShow> buttons;
int payment;
String paymentStr;
/**
* 提交订单时间
*/
String submitOrderTimeStr;
@Builder
@Data
public static class StatusDetail{
int status;
/**
* 列表中状态显示
*/
String statuStr;
/**
* 详情页的线上
*/
String detailDesc;
/**
* 剩余价格
*/
int leftTime;
/**
* 是否显示 物流箭头信息
*/
boolean expressShow;
/**
* 物流信息
*/
String express;
/**
* 发货时间点
*/
String sendOutTimeStr;
}
@Data
@Builder
public static class PriceInfo{
/**
* 商品金额
*/
String goodPrice;
/**
* 运费
*/
String feePrice;
/**
* 实付金额
*/
String realPayPrice;
}
}
... ...
... ... @@ -6,7 +6,9 @@ import lombok.Data;
import java.util.List;
@Data
public class OrderInfo {
public class OrderListInfo {
int uid;
long orderCode;
... ... @@ -17,22 +19,11 @@ public class OrderInfo {
*/
String realPrice;
/**
* 商品题目
*/
String productName;
/**
* 商品图片
*/
String imageUrl;
String colorName;
String sizeName;
GoodsInfo goodsInfo;
/**
*
* 剩余时间
*/
int leftTime;
... ...
... ... @@ -11,9 +11,9 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderInfoListRsp {
public class OrderListInfoRsp {
List<OrderInfo> data;
List<OrderListInfo> data;
// 页码
private int currPage;
... ...
package com.yohoufo.order.service;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.response.OrderInfoListRsp;
import com.yohoufo.order.response.OrderListInfoRsp;
public interface IBuyerOrderService {
... ... @@ -11,5 +11,5 @@ public interface IBuyerOrderService {
* @param request
* @return
*/
public OrderInfoListRsp getOrderList(OrderListRequest request);
public OrderListInfoRsp getOrderList(OrderListRequest request);
}
... ...
package com.yohoufo.order.service.impl;
import com.google.common.collect.Lists;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.BuyerOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.OrderListType;
import com.yohoufo.order.common.OrderStatus;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.response.OrderInfo;
import com.yohoufo.order.response.OrderInfoListRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.common.OrderCodeType;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.common.*;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.constants.OrderConstant;
import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.request.ShoppingRequest;
import com.yohoufo.order.response.OrderSubmitResponse;
import com.yohoufo.order.response.ShoppingPaymentResponse;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.GoodsInfo;
import com.yohoufo.order.response.OrderDetailInfo;
import com.yohoufo.order.response.OrderListInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.IOrdeCreationService;
import com.yohoufo.order.service.support.ShoppingSupport;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -37,9 +30,6 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
@Service
public class BuyerOrderServiceImpl implements IBuyerOrderService {
... ... @@ -55,13 +45,145 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
BuyerOrderMetaMapper buyerOrderMetaMapper;
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest){
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
logger.warn("getOrderDetail uid or orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
TabType tabType = TabType.getTabType(orderRequest.getTabType());
if (tabType == null){
logger.warn("getOrderDetail tabType invalidate, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode());
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
if (TabType.BUY != tabType){
return new OrderDetailInfo();
}
// 查询订单状态
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderRequest.getOrderCode(), orderRequest.getUid());
if (buyerOrder == null){
logger.warn("getOrderDetail orderCode exist, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode() );
throw new ServiceException(ServiceError.ORDER_NULL);
}
// 检查 订单状态
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
if (orderStatus == null){
logger.warn("getOrderDetail status invalidate, uid is {}, orderCode is {}, status is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
// 收货地址 and 用户信息 TODO
BuyerOrderMeta buyerOrderMeta = buyerOrderMetaMapper.selectByMetaKey(orderRequest.getUid(),
orderRequest.getOrderCode(), MetaKey.BUYER_DELIVERY_ADDRESS);
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), orderRequest.getOrderCode());
if (buyerOrderGoods == null){
logger.warn("getOrderDetail skup not exist, uid is {}, orderCode is {}", orderRequest.getUid(), orderRequest.getOrderCode());
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(buyerOrderGoods.getSkup());
if (sellerOrderGoods == null){
logger.warn("getOrderDetail order goods not exist, uid is {}, orderCode is {}, skup is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrderGoods.getSkup());
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
OrderDetailInfo orderDetailInfo = buildOrderDetail(buyerOrder, orderStatus, buyerOrderGoods, sellerOrderGoods);
return orderDetailInfo;
}
private OrderDetailInfo buildOrderDetail(BuyerOrder buyerOrder, OrderStatus orderStatus, BuyerOrderGoods buyerOrderGoods, SellerOrderGoods sellerOrderGoods) {
OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
orderDetailInfo.setUid(buyerOrder.getUid());
orderDetailInfo.setOrderCode(buyerOrder.getOrderCode());
orderDetailInfo.setButtons(orderStatus.getDetailButtons());
OrderDetailInfo.StatusDetail statusDetail = getStatusDetail(buyerOrder, orderStatus);
orderDetailInfo.setStatusDetail(statusDetail);
GoodsInfo goodsInfo = getGoodsInfo(sellerOrderGoods);
orderDetailInfo.setGoodsInfo(goodsInfo);
OrderDetailInfo.PriceInfo priceInfo = OrderDetailInfo.PriceInfo.builder()
.goodPrice(buyerOrderGoods.getGoodsPrice() == null ? "0" : buyerOrderGoods.getGoodsPrice().toPlainString() )
.feePrice(buyerOrder.getShipFee() == null ? "0" : buyerOrder.getShipFee().toPlainString())
.realPayPrice(buyerOrder.getAmount() == null ? "0" : buyerOrder.getAmount().toPlainString())
.build();
// 支付状态
if (buyerOrder.getPayment() != null){
Payment payment = Payment.getPayment(buyerOrder.getPayment());
if (payment != null){
orderDetailInfo.setPaymentStr(payment.getDesc());
orderDetailInfo.setPayment(buyerOrder.getPayment());
}
}
return orderDetailInfo;
}
/**
* 商品信息
* @param sellerOrderGoods
* @return
*/
private GoodsInfo getGoodsInfo(SellerOrderGoods sellerOrderGoods) {
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setProductName(sellerOrderGoods.getProductName());
goodsInfo.setColorName(sellerOrderGoods.getColorName());
goodsInfo.setSizeName(sellerOrderGoods.getSizeName());
goodsInfo.setImageUrl(sellerOrderGoods.getImageUrl());
goodsInfo.setGoodPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
return goodsInfo;
}
/**
* 获取详情页 状态位明细
* @param buyerOrder
* @param orderStatus
* @return
*/
private OrderDetailInfo.StatusDetail getStatusDetail(BuyerOrder buyerOrder,OrderStatus orderStatus) {
OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail.builder()
.status(orderStatus.getCode())
.statuStr(orderStatus.getStatusStr())
.build();
// TODO 需要查询 时间点 and 物流定位
if (OrderConstant.EXPRESS_SENDTIME_TO_QUERY.equals(orderStatus.getDetailDesc())){
}
// 待付款时,剩余时间
if (orderStatus.getCode() == OrderStatus.WAITING_PAY.getCode()){
statusDetail.setLeftTime(DateUtil.getCurrentTimeSecond() - buyerOrder.getCreateTime());
}
return statusDetail;
}
/**
* 订单列表
* @param request
* @return
*/
public OrderInfoListRsp getOrderList(OrderListRequest request){
public OrderListInfoRsp getOrderList(OrderListRequest request){
// check and init请求参数
List<Integer> statusQuery = initOrderListRequest(request);
... ... @@ -75,26 +197,27 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
List<Long> orderCodeList = buyerOrderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
// buyer_order_goods ===> skup+商品成交价
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectByOrderCode(orderCodeList);
Map<Long, BuyerOrderGoods> buyerOrderGoodsMap = buyerOrderGoodsList.stream().collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, Function.identity()));
// buyer_order_goods ===> skup+商品成交价 1:1
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectByOrderCodeList(request.getUid(), orderCodeList);
Map<Long, BuyerOrderGoods> buyerOrderGoodsMap = buyerOrderGoodsList.stream()
.collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, Function.identity(), (key1, key2) -> key2));
List<Integer> skups = buyerOrderGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
// seller_order_goods ===> 商品信息
List<SellerOrderGoods> sellerOrderGoodsList = sellerOrderGoodsMapper.selectBySkups(skups);
Map<Integer, SellerOrderGoods> sellerOrderGoodsMap = sellerOrderGoodsList.stream().collect(Collectors.toMap(SellerOrderGoods::getId, Function.identity()));
List<OrderInfo> data = Lists.newArrayList();
List<OrderListInfo> data = Lists.newArrayList();
buyerOrderList.stream().forEach(buyerOrder -> {
OrderInfo orderInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder);
if (orderInfo == null) return;
OrderListInfo orderListInfo = convertOrderInfo(buyerOrderGoodsMap, sellerOrderGoodsMap, buyerOrder);
if (orderListInfo == null) return;
data.add(orderInfo);
data.add(orderListInfo);
});
OrderInfoListRsp orderInfoListRsp = OrderInfoListRsp.builder()
OrderListInfoRsp orderListInfoRsp = OrderListInfoRsp.builder()
.data(data)
.currPage(request.getPage())
.limit(limit)
... ... @@ -102,7 +225,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
.currTotal(data.size())
.pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1)).build();
return orderInfoListRsp;
return orderListInfoRsp;
}
... ... @@ -113,46 +236,64 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
* @param buyerOrder
* @return
*/
private OrderInfo convertOrderInfo(Map<Long, BuyerOrderGoods> buyerOrderGoodsMap,
Map<Integer, SellerOrderGoods> sellerOrderGoodsMap,
BuyerOrder buyerOrder) {
private OrderListInfo convertOrderInfo(Map<Long, BuyerOrderGoods> buyerOrderGoodsMap,
Map<Integer, SellerOrderGoods> sellerOrderGoodsMap,
BuyerOrder buyerOrder) {
/**
* 1.查询 buyer_order
* 2.查询 buyer_order_goods ==> skup
* 3.查询 seller_order_goods
*/
OrderInfo orderInfo = new OrderInfo();
orderInfo.setOrderCode(buyerOrder.getOrderCode());
orderInfo.setRealPrice(buyerOrder.getAmount() == null ? "" : buyerOrder.getAmount().toPlainString());
OrderListInfo orderListInfo = new OrderListInfo();
orderListInfo.setUid(buyerOrder.getUid());
orderListInfo.setOrderCode(buyerOrder.getOrderCode());
orderListInfo.setRealPrice(buyerOrder.getAmount() == null ? "" : buyerOrder.getAmount().toPlainString());
// 订单中状态显示
orderInfo.setStatus(buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus());
OrderStatus orderStatus = OrderStatus.getOrderStatus(orderInfo.getStatus());
orderInfo.setStatuStr(orderStatus == null ? "" : orderStatus.getListStatusStr());
orderListInfo.setStatus(buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus());
OrderStatus orderStatus = OrderStatus.getOrderStatus(orderListInfo.getStatus());
if (orderStatus == null){
logger.warn("getOrderList orderStatus not exist, uid is {}, orderCode is {}, status is {}",
buyerOrder.getUid(), orderListInfo.getOrderCode(), buyerOrder.getStatus());
return null;
}
orderListInfo.setStatuStr(orderStatus.getStatusStr());
// 按钮显示
orderInfo.setButtons(orderStatus == null ? Lists.newArrayList() : orderStatus.getButtonList());
orderListInfo.setButtons(orderStatus.getListButtons());
// 当订单状态是待付款, 显示leftTime
if (orderInfo.getStatus() == OrderStatus.WAITING_PAY.getCode()){
orderInfo.setLeftTime(DateUtil.getCurrentTimeSecond() - buyerOrder.getCreateTime());
if (orderListInfo.getStatus() == OrderStatus.WAITING_PAY.getCode()){
orderListInfo.setLeftTime(DateUtil.getCurrentTimeSecond() - buyerOrder.getCreateTime());
}
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMap.get(buyerOrder.getOrderCode());
if (buyerOrderGoods == null){
logger.warn("getOrderList buyer goods not exist, uid is {}, orderCode is {}",
buyerOrder.getUid(), orderListInfo.getOrderCode());
return null;
}
orderInfo.setSkup(buyerOrderGoods.getSkup());
orderListInfo.setSkup(buyerOrderGoods.getSkup());
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMap.get(buyerOrderGoods.getSkup());
if (sellerOrderGoods == null){
logger.warn("getOrderList seller goods not exist, uid is {}, orderCode is {}",
buyerOrder.getUid(), orderListInfo.getOrderCode());
return null;
}
orderInfo.setProductName(sellerOrderGoods.getProductName());
orderInfo.setImageUrl(sellerOrderGoods.getImageUrl());
orderInfo.setColorName(sellerOrderGoods.getColorName());
orderInfo.setSizeName(sellerOrderGoods.getSizeName());
return orderInfo;
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setColorName(sellerOrderGoods.getColorName());
goodsInfo.setProductName(sellerOrderGoods.getProductName());
goodsInfo.setImageUrl(sellerOrderGoods.getImageUrl());
goodsInfo.setSizeName(sellerOrderGoods.getSizeName());
goodsInfo.setGoodPrice(buyerOrderGoods.getGoodsPrice() == null ? "" :buyerOrderGoods.getGoodsPrice().toPlainString());
orderListInfo.setGoodsInfo(goodsInfo);
return orderListInfo;
}
/**
... ...