Authored by tanling

给erp的订单列表

... ... @@ -31,9 +31,9 @@ public interface BuyerOrderMapper {
int updateByOrderCode(BuyerOrder record);
int selectCntByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status);
int selectCntByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status);
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status,
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status,
@Param("offset")Integer offset, @Param("limit")Integer limit);
int selectCntBySellerUidStatus(@Param("sellerUid") int suid, @Param("status") List<Integer> status);
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderInfo;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
... ... @@ -21,6 +22,17 @@ public interface SellerOrderGoodsMapper {
List<SellerOrderGoods> selectBySkupsNStatus(@Param("list") List<Integer> skup, @Param("statusList") Collection<Integer> statusList);
List<SellerOrderInfo> selectByStatusAndOrderCode(@Param("uid") int uid,
@Param("orderCode") Long orderCode,
@Param("statusList") Collection<Integer> statusList,
@Param("offset")Integer offset,
@Param("limit")Integer limit);
int selectCntByStatusAndOrderCode(@Param("uid") int uid,
@Param("orderCode") Long orderCode,
@Param("statusList") Collection<Integer> statusList);
int updateByPrimaryKeySelective(SellerOrderGoods record);
int updateByPrimaryKey(SellerOrderGoods record);
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
@ToString
@Data
public class SellerOrderInfo {
private Integer uid;
private Integer productId;
private String productName;
private Integer sizeId;
private String sizeName;
private Integer colorId;
private String colorName;
private BigDecimal goodsPrice;
private Integer status;
private String imageUrl;
private int skup;
private long orderCode;
private int attribute;
private int createTime;
}
\ No newline at end of file
... ...
... ... @@ -53,6 +53,9 @@
<select id="selectListByUidStatus" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from buyer_order
where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
<if test="orderCode != null">
and order_code = #{orderCode,jdbcType=BIGINT}
</if>
<if test="status != null">
and status in
<foreach item="item" index="index" collection="status" open="(" separator="," close=")">
... ...
... ... @@ -21,6 +21,8 @@
<result column="skup_list" jdbcType="VARCHAR" property="skupList" />
<result column="attributes" jdbcType="INTEGER" property="attributes" />
</resultMap>
<sql id="Base_Column_List">
id, uid, product_id, product_name, storage_id, depot_no, size_id, size_name,
color_id, color_name, goods_price, status, image_url, is_del, batch_no, attributes
... ... @@ -51,6 +53,43 @@
</if>
</select>
<select id="selectCntByStatusAndOrderCode" resultType="java.lang.Integer">
select
count(1)
from ufo_order.seller_order a, ufo_order.seller_order_goods b
where a.skup=b.id
<include refid="join_where_status_orderCode"></include>
</select>
<select id="selectByStatusAndOrderCode" resultType="com.yohoufo.dal.order.model.SellerOrderInfo">
select
a.order_code orderCode, b.status status, b.image_url imageUrl,
b.product_name productName, b.product_id productId, a.skup skup,
b.color_id colorId, b.color_name colorName, b.size_id sizeId, b.size_name sizeName,
b.goods_price goodsPrice, b.attributes attributes,
a.uid ,a.create_time createTime
from ufo_order.seller_order a, ufo_order.seller_order_goods b
where a.skup=b.id
<include refid="join_where_status_orderCode"></include>
order by a.create_time desc
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<sql id="join_where_status_orderCode">
<if test="orderCode !=null">
and a.order_code = #{orderCode,jdbcType=BIGINT}
</if>
and a.uid = #{uid,jdbcType=INTEGER} and a.is_del = 1
<if test="statusList != null">
and b.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
</sql>
<select id="selectByBatchNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
... ... @@ -343,6 +382,7 @@
WHERE <include refid="sql_where_4_select_UidStatusGBBNList"/> ) t
</select>
<select id="selectByUidStatusGBBNList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods
where <include refid="sql_where_4_select_UidStatusGBBNList"/>
... ...
package com.yohoufo.order.controller;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.req.BuyerOrderCancelReq;
import com.yohobuy.ufo.model.order.req.ManualDealRequest;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Objects;
@RestController
@RequestMapping("/erp")
public class ErpGWOrderController {
... ... @@ -26,6 +34,10 @@ public class ErpGWOrderController {
@Autowired
IPaymentService paymentService;
@Autowired
SellerOrderService sellerOrderService;
@RequestMapping(params = "method=ufo.buyer.orderNums")
@IgnoreSession
public BuyerOrderNums getBuyerOrderNums(@RequestParam("uid") int uid){
... ... @@ -34,6 +46,44 @@ public class ErpGWOrderController {
return buyerOrderNums;
}
@IgnoreSignature
@IgnoreSession
@RequestMapping(value="/getOrderListForErpGW")
public ApiResponse getOrderListForErpGW(@RequestParam("tabType") String tabType,
@RequestParam("uid") int uid,
@RequestParam(value = "orderCode", required = false) Long orderCode,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
TabType actor = TabType.getTabType(tabType);
if (Objects.isNull(actor)){
return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();
}
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
.orderCode(orderCode)
.type(OrderListType.ALL.getType()) // 默认全部状态
.page(page)
.limit(limit)
.tabType(tabType)
.actor(actor)
.build();
LOG.info("in ufo.order.list, req {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
switch (actor){
case BUY:
orderListInfoRsp = buyerOrderService.getOrderListForErpGW(orderListRequest);
break;
case SELL:
orderListInfoRsp = sellerOrderService.getOrderListForErpGW(orderListRequest);
break;
default:
orderListInfoRsp = null;
}
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("订单列表").build();
}
@IgnoreSignature
@IgnoreSession
@RequestMapping(value="/manualDealMon")
... ...
... ... @@ -25,4 +25,6 @@ public class OrderListRequest {
String tabType;
TabType actor;
Long orderCode;
}
... ...
... ... @@ -4,7 +4,9 @@ import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCancelComputeResult;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderSummaryResp;
... ... @@ -18,6 +20,8 @@ public interface IBuyerOrderService extends IOrderListService, IOrderDetailServi
*/
BuyerOrderNums getBuyerOrderNums(int uid);
/**
* 取消订单
* @param orderRequest
... ...
... ... @@ -15,4 +15,9 @@ public interface IOrderListService {
* @return
*/
PageResp<OrderListInfo> getOrderList(OrderListRequest request);
PageResp getOrderListForErpGW(OrderListRequest request);
}
... ...
... ... @@ -38,14 +38,15 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
abstract List<Integer> initOrderListRequest(OrderListRequest request);
abstract int getTotal(int uid, List<Integer> statusQuery);
abstract int getTotal(int uid, Long orderCode, List<Integer> statusQuery);
abstract List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit);
abstract List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit);
abstract List<BuyerOrderGoods> getOrderGoodsList(int uid, List<Long> orderCodeList);
abstract List<SellerOrderGoods> getBaseOrderGoodsList(List<Integer> skups);
/**
* 获取鉴定视频
* @param buyerOrderList
... ... @@ -65,7 +66,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
// check and init请求参数
List<Integer> statusQuery = initOrderListRequest(request);
TabType actor = request.getActor();
int total = getTotal(request.getUid(), statusQuery);
int total = getTotal(request.getUid(), request.getOrderCode(), statusQuery);
int limit = request.getLimit();
PageResp.PageRespBuilder respBuilder = PageResp.builder()
.page(request.getPage())
... ... @@ -78,7 +79,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
int offset = (request.getPage() - 1) * limit;
List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), statusQuery, offset, limit);
List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), request.getOrderCode(), statusQuery, offset, limit);
List<Long> orderCodeList = buyerOrderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
//TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络I
... ...
... ... @@ -8,6 +8,7 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -56,6 +57,11 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
@Autowired
private QiniuLiveRecordService qiniuLiveRecordService;
public PageResp getOrderListForErpGW(OrderListRequest request) {
return getOrderList(request);
}
/**
* 根据type获取 指定的状态
* @param request
... ... @@ -80,13 +86,13 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
}
@Override
int getTotal(int uid, List<Integer> statusQuery){
return buyerOrderMapper.selectCntByUidStatus(uid, statusQuery);
int getTotal(int uid, Long orderCode, List<Integer> statusQuery){
return buyerOrderMapper.selectCntByUidStatus(uid, orderCode, statusQuery);
}
@Override
List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListByUidStatus(uid, statusQuery, offset, limit);
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListByUidStatus(uid, orderCode, statusQuery, offset, limit);
return buyerOrderList;
}
... ... @@ -160,4 +166,5 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
Logger getLogger() {
return logger;
}
}
... ...
... ... @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohobuy.ufo.model.order.resp.*;
... ... @@ -593,6 +592,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public PageResp getOrderListForErpGW(OrderListRequest request) {
return buyerOrderListService.getOrderListForErpGW(request);
}
@Override
public PageResp getOrderList(OrderListRequest request) {
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
... ...
package com.yohoufo.order.service.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
... ... @@ -16,10 +17,7 @@ import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.AbsSellerOrderViewService;
... ... @@ -41,6 +39,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
... ... @@ -86,10 +85,19 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
SkupStatus.SELLER_CANCEL_SELL.getCode()
);
private static List<Integer> skupStatusListErpGW = Arrays.asList(
SkupStatus.SELL_OUT.getCode()
);
public static List<Integer> getSkupStatusListV683(){
return skupStatusListV683;
}
public static List<Integer> getSkupStatusListErpGW(){
return skupStatusListErpGW;
}
public List<OrderListInfo> buildOrderList(List<SellerOrderGoods> sogList, SellerType sellerType){
sogList.stream().forEach(item -> {
... ... @@ -109,6 +117,45 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
return data;
}
public PageResp<OrderListInfo> getOrderListForErpGW(OrderListRequest request){
// 只给erp显示售出的订单
List<Integer> statusList = getSkupStatusListErpGW();
int total = sellerOrderGoodsMapper.selectCntByStatusAndOrderCode(request.getUid(), request.getOrderCode(), statusList);
int limit = request.getLimit();
PageResp.PageRespBuilder respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit)
.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
int offset = (request.getPage() - 1) * limit;
List<SellerOrderInfo> sellerOrderInfoList = sellerOrderGoodsMapper.selectByStatusAndOrderCode(request.getUid(), request.getOrderCode(),
statusList, offset, limit);
if (CollectionUtils.isEmpty(sellerOrderInfoList)){
log.warn("seller get order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
// 查询skup的买家订单号
List<BuyerOrderGoods> buyerOrderGoods = buyerOrderGoodsMapper.selectBySkups(sellerOrderInfoList.stream().map(SellerOrderInfo::getSkup).collect(Collectors.toList()));
Map<Integer, Long> buyerOrderMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(buyerOrderGoods)){
buyerOrderMap = buyerOrderGoods.stream().collect(Collectors.toMap(BuyerOrderGoods::getSkup, BuyerOrderGoods::getOrderCode, (key1, key2) -> key2));
}
// 将查询结果转换成想要结果
List<OrderListInfo> data = Lists.newArrayList();
Map<Integer, Long> finalBuyerOrderMap = buyerOrderMap;
sellerOrderInfoList.stream().forEach(x -> data.add(this.convertOrderInfo(x, finalBuyerOrderMap)));
PageResp orderListInfoRsp = respBuilder.data(data).build();
return orderListInfoRsp;
}
@Override
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
... ... @@ -236,9 +283,6 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
SellerOrder sellerOrder, SellerType st, Map<String,String> overPriceTipsMap) {
... ... @@ -306,6 +350,41 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
OrderListInfo convertOrderInfo(SellerOrderInfo sellerOrderInfo, Map<Integer, Long> buyerOrderMap) {
OrderListInfo orderListInfo = new OrderListInfo();
orderListInfo.setUid(sellerOrderInfo.getUid());
orderListInfo.setOrderCode(sellerOrderInfo.getOrderCode());
orderListInfo.setRealPrice(sellerOrderInfo.getGoodsPrice().toPlainString());
// 订单中状态显示
SkupStatus skupStatus = SkupStatus.getSkupStatus(sellerOrderInfo.getStatus().intValue());
if (skupStatus != null){
orderListInfo.setStatus(skupStatus.getCode());
orderListInfo.setStatuStr(skupStatus.getDesc());
}
orderListInfo.setSkup(sellerOrderInfo.getSkup());
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setColorName(sellerOrderInfo.getColorName());
goodsInfo.setProductName(sellerOrderInfo.getProductName());
goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderInfo.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
goodsInfo.setSizeName(sellerOrderInfo.getSizeName());
goodsInfo.setProductId(sellerOrderInfo.getProductId());
goodsInfo.setGoodPrice(sellerOrderInfo.getGoodsPrice().toPlainString());
orderListInfo.setGoodsInfo(goodsInfo);
orderListInfo.setCreateTime(DateUtil.formatDate(sellerOrderInfo.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
// 查询skup的买家订单号
orderListInfo.setBuyerOrderCode(buyerOrderMap.get(sellerOrderInfo.getSkup()));
return orderListInfo;
}
@Override
protected List<Integer> initOrderListRequest(OrderListRequest request) {
if (request.getUid() < 0){
... ... @@ -325,12 +404,12 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
@Override
int getTotal(int uid, List<Integer> statusQuery) {
int getTotal(int uid, Long orderCode, List<Integer> statusQuery) {
return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery);
}
@Override
List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListBySellerUidStatus(uid, statusQuery, offset, limit);
return buyerOrderList;
}
... ...
... ... @@ -529,6 +529,10 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
public PageResp<OrderListInfo> getOrderListForErpGW(OrderListRequest request){
return sellerOrderListService.getOrderListForErpGW(request);
}
@Override
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
... ...
... ... @@ -18,7 +18,7 @@
<properties>
<qiniu.version>7.0.5</qiniu.version>
<project-name>yohoufo-fore</project-name>
<model.version>6.0-SNAPSHOT</model.version>
<model.version>7.0-SNAPSHOT</model.version>
</properties>
<dependencyManagement>
... ...