Authored by caoyan

质检

... ... @@ -183,7 +183,7 @@
</if>
where 1=1
<include refid="Query_Order_Sql" />
order by a.create_time desc
order by a.update_time desc
<if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
limit #{buyerOrderReq.start},#{buyerOrderReq.size}
</if>
... ...
... ... @@ -25,6 +25,7 @@ import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.ExpressInfoResp;
import com.yohobuy.ufo.model.order.resp.OrderDetailResp;
import com.yohobuy.ufo.model.order.resp.OrderOperateRecordResp;
import com.yohobuy.ufo.model.order.resp.QcOrderDetailResp;
@RestController
@RequestMapping(value = "/buyerOrder")
... ... @@ -416,5 +417,12 @@ public class BuyerOrderController {
PageResponseBO<BuyerOrderResp> result = buyerOrderService.queryOrderListByStatusForQc(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
@RequestMapping(value = "/getQcOrderDetail")
public ApiResponse getQcOrderDetail(BuyerOrderReq req) {
LOGGER.info("getQcOrderDetail in. param is {}", req);
QcOrderDetailResp result = buyerOrderService.getQcOrderDetail(req.getOrderCode());
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
... ... @@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.ExpressInfoResp;
import com.yohobuy.ufo.model.order.resp.OrderDetailResp;
import com.yohobuy.ufo.model.order.resp.OrderOperateRecordResp;
import com.yohobuy.ufo.model.order.resp.QcOrderDetailResp;
/**
* @author caoyan
... ... @@ -93,4 +94,6 @@ public interface IBuyerOrderService {
Map<String, Integer> getCountForQc(BuyerOrderReq req);
PageResponseBO<BuyerOrderResp> queryOrderListByStatusForQc(BuyerOrderReq req);
QcOrderDetailResp getQcOrderDetail(String orderCode);
}
... ...
... ... @@ -76,11 +76,13 @@ import com.yohobuy.ufo.model.order.common.EnumExpressType;
import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus;
import com.yohobuy.ufo.model.order.common.EnumQualityCheckType;
import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.ExpressInfoResp;
import com.yohobuy.ufo.model.order.resp.OrderDetailResp;
import com.yohobuy.ufo.model.order.resp.OrderOperateRecordResp;
import com.yohobuy.ufo.model.order.resp.QcOrderDetailResp;
/**
* @author caoyan
... ... @@ -255,8 +257,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
Map<String, Integer> resultMap = Maps.newHashMap();
int receivedNum = buyerOrderMapper.selectCountByStatusAndDepotNo(receivedList, req.getDepotNo(),null);
int processingNum = buyerOrderMapper.selectCountByStatusAndDepotNo(processingList, req.getDepotNo(),null);
int alreadyDeliverNum = buyerOrderMapper.selectCountByStatusAndDepotNo(alreadyDeliverList, req.getDepotNo(),null);
int processingNum = buyerOrderMapper.selectCountByStatusAndDepotNo(processingList, req.getDepotNo(), "haveNotExpress");
int alreadyDeliverNum = buyerOrderMapper.selectCountByStatusAndDepotNo(alreadyDeliverList, req.getDepotNo(), "haveExpress");
int problemNum = buyerOrderMapper.selectCountByStatusAndDepotNo(problemList, req.getDepotNo(),null);
resultMap.put("receivedNum", receivedNum);
... ... @@ -268,23 +270,30 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
private Map<String, Integer> queryOrderNumByStatus(String queryStr, Integer depotNo){
List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, depotNo);
int receivedNum = 0;
int processingNum = 0;
int alreadyDeliverNum = 0;
int problemNum = 0;
//遍历按状态统计数量
Map<String, Integer> resultMap = Maps.newHashMap();
for(BuyerOrder item : orderList) {
if(receivedList.contains(item.getStatus())) {
receivedNum += 1;
}else if(processingList.contains(item.getStatus())) {
processingNum += 1;
}else if(alreadyDeliverList.contains(item.getStatus())) {
alreadyDeliverNum += 1;
}else if(problemList.contains(item.getStatus())) {
problemNum += 1;
}
List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, depotNo, null);
if(CollectionUtils.isNotEmpty(orderList)) {
List<String> orderCodeList = orderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
List<ExpressRecord> expressList = expressRecordMapper.selectByOrderCodeListAndType(orderCodeList, Lists.newArrayList(2,3,4));
List<String> expressOrderCodeList = expressList.stream().map(ExpressRecord::getOrderCode).collect(Collectors.toList());
for(BuyerOrder item : orderList) {
if(receivedList.contains(item.getStatus())) {
receivedNum += 1;
}else if(processingList.contains(item.getStatus()) && !expressOrderCodeList.contains(item.getOrderCode())) {
processingNum += 1;
}else if(alreadyDeliverList.contains(item.getStatus()) && expressOrderCodeList.contains(item.getOrderCode())) {
alreadyDeliverNum += 1;
}else if(problemList.contains(item.getStatus())) {
problemNum += 1;
}
}
}
resultMap.put("receivedNum", receivedNum);
... ... @@ -295,17 +304,19 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return resultMap;
}
private List<BuyerOrder> queryOrderByQueryStr(String queryStr, Integer depotNo) {
private List<BuyerOrder> queryOrderByQueryStr(String queryStr, Integer depotNo, Byte status) {
//先按订单号来查
BuyerOrderReq req = new BuyerOrderReq();
req.setOrderCode(queryStr);
req.setDepotNo(depotNo);
req.setStatus(status);
req.setSize(100);
List<BuyerOrder> orderList = buyerOrderMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(orderList)){//再按卖家运单号来查
req = new BuyerOrderReq();
req.setSellerWaybillCode(queryStr);
req.setDepotNo(depotNo);
req.setStatus(status);
req.setSize(100);
List<BuyerOrder> list = buyerOrderMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(list)){
... ... @@ -501,7 +512,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return null;
}
List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, null);
//查询卖家已发货的订单
List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, null, Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal());
List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
if(CollectionUtils.isEmpty(respList)) {
... ... @@ -519,24 +531,30 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Override
public PageResponseBO<BuyerOrderResp> queryOrderListByStatusForQc(BuyerOrderReq req) {
if(StringUtils.isNotEmpty(req.getQueryStr())) {
return queryOrderListByStatusAndQueryStr(req.getStatus(), req.getQueryStr(), req.getDepotNo());
}
Byte status = req.getStatus();
List<Byte> checkStatusList = Lists.newArrayList();
String platformExpressInfoFlag = "";
if(status.equals(QC_STATUS_RECEIVED)) {
checkStatusList = receivedList;
}else if(status.equals(QC_STATUS_PROCESSING)) {
checkStatusList = processingList;
platformExpressInfoFlag = "haveNotExpress";
}else if(status.equals(QC_STATUS_ALREADY_DELIVER)) {
checkStatusList = alreadyDeliverList;
platformExpressInfoFlag = "haveExpress";
}else if(status.equals(QC_STATUS_PROBLEM)) {
checkStatusList = problemList;
}
if(StringUtils.isNotEmpty(req.getQueryStr())) {
return queryOrderListByStatusAndQueryStr(req.getQueryStr(), req.getDepotNo(), checkStatusList, platformExpressInfoFlag);
}
req.setStatus(null);
req.setStatusList(checkStatusList);
req.setPlatformExpressInfoFlag(platformExpressInfoFlag);
int total = buyerOrderMapper.selectTotalByCondition(req);
if(total == 0) {
return null;
... ... @@ -562,53 +580,56 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return result;
}
private PageResponseBO<BuyerOrderResp> queryOrderListByStatusAndQueryStr(Byte status, String queryStr, Integer depotNo){
List<BuyerOrder> preOrderList = queryOrderByQueryStr(queryStr, depotNo);
if(CollectionUtils.isEmpty(preOrderList)) {
return null;
}else {
List<Byte> checkStatusList = Lists.newArrayList();
if(status.equals(QC_STATUS_RECEIVED)) {
checkStatusList = receivedList;
}else if(status.equals(QC_STATUS_PROCESSING)) {
checkStatusList = processingList;
}else if(status.equals(QC_STATUS_ALREADY_DELIVER)) {
checkStatusList = alreadyDeliverList;
}else if(status.equals(QC_STATUS_PROBLEM)) {
checkStatusList = problemList;
}
List<BuyerOrder> orderList = Lists.newArrayList();
for(BuyerOrder order : preOrderList) {
if(checkStatusList.contains(order.getStatus())) {
orderList.add(order);
}
}
if(CollectionUtils.isEmpty(orderList)) {
return null;
}
List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
if(CollectionUtils.isEmpty(respList)) {
return null;
}
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
result.setPage(1);
result.setList(respList);
result.setSize(respList.size());
result.setTotal(respList.size());
private PageResponseBO<BuyerOrderResp> queryOrderListByStatusAndQueryStr(String queryStr, Integer depotNo,
List<Byte> checkStatusList, String platformExpressInfoFlag){
//先按订单号来查
BuyerOrderReq req = new BuyerOrderReq();
req.setOrderCode(queryStr);
req.setDepotNo(depotNo);
req.setStatusList(checkStatusList);
req.setPlatformExpressInfoFlag(platformExpressInfoFlag);
req.setSize(100);
List<BuyerOrder> orderList = buyerOrderMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(orderList)){//再按卖家运单号来查
orderList = Lists.newArrayList();
req = new BuyerOrderReq();
req.setSellerWaybillCode(queryStr);
req.setDepotNo(depotNo);
req.setStatusList(checkStatusList);
req.setPlatformExpressInfoFlag(platformExpressInfoFlag);
req.setSize(100);
List<BuyerOrder> list = buyerOrderMapper.selectByCondition(req);
if(CollectionUtils.isNotEmpty(list)){
orderList.addAll(list);
}
}
if(CollectionUtils.isEmpty(orderList)) {
return null;
}
return result;
List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
if(CollectionUtils.isEmpty(respList)) {
return null;
}
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
result.setPage(1);
result.setList(respList);
result.setSize(respList.size());
result.setTotal(respList.size());
return result;
}
private List<BuyerOrderResp> buildBuyerOrderRespForQc(List<BuyerOrder> orderList){
//查询buyer_order_goods
List<String> buyerOrderCodeList = orderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
List<BuyerOrderGoods> buyerGoodsList = buyerOrderGoodsMapper.selectByOrderCode(buyerOrderCodeList);
if(CollectionUtils.isEmpty(buyerGoodsList)) {
return null;
return Lists.newArrayList();
}
Map<String, BuyerOrderGoods> buyerGoodsMap = buyerGoodsList.stream().collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, b->b));
... ... @@ -617,24 +638,16 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
List<SellerOrderGoods> sellerGoodsList = sellerOrderGoodsMapper.selectByIds(skupList);
Map<Integer, SellerOrderGoods> sellerGoodsMap = sellerGoodsList.stream().collect(Collectors.toMap(SellerOrderGoods::getId, s->s));
//查询buyer_order_meta
List<BuyerOrderMeta> buyerOrderMetaList = buyerOrderMetaMapper.selectByBatchOrderCodeAndKey(buyerOrderCodeList, BUYER_ORDER_META_KEY_DELIVERY_ADDRESS);
Map<String, BuyerOrderMeta> buyerOrderMetaMap = buyerOrderMetaList.stream().collect(Collectors.toMap(BuyerOrderMeta::getOrderCode, b->b));
//查询卖家快递单号
List<ExpressRecord> expressRecordList =expressRecordMapper.selectByOrderCodeListAndType(buyerOrderCodeList, Lists.newArrayList(EXPRESS_TYPE_SELLER_TO_JUDGE));
Map<String, ExpressRecord> expressRecordMap = expressRecordList.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, e->e));
//查询identify_records
List<IdentifyRecords> identifyRecordList = identifyRecordsMapper.selectByBatchOrderCode(buyerOrderCodeList);
Map<String, List<IdentifyRecords>> identifyMap = identifyRecordList.stream().collect(Collectors.groupingBy(IdentifyRecords::getOrderCode));
//查询product获取货号
List<Integer> productIdList = sellerGoodsList.stream().map(SellerOrderGoods::getProductId).collect(Collectors.toList());
List<Product> productList = productMapper.selectProductListByIds(productIdList);
Map<Integer, String> productIdCodeMap = productList.stream().collect(Collectors.toMap(Product::getId, Product::getProductCode));
return convertToRespForQc(orderList, buyerGoodsMap, sellerGoodsMap,expressRecordMap, buyerOrderMetaMap, identifyMap, productIdCodeMap);
return convertToRespForQc(orderList, buyerGoodsMap, sellerGoodsMap,expressRecordMap, productIdCodeMap);
}
... ... @@ -1440,6 +1453,109 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return resp;
}
@Override
public QcOrderDetailResp getQcOrderDetail(String orderCode) {
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if(null == buyerOrder) {
return null;
}
QcOrderDetailResp resp = new QcOrderDetailResp();
resp.setOrderCode(buyerOrder.getOrderCode());
resp.setStatus(buyerOrder.getStatus());
resp.setStatusStr(Constant.convertOrderStatusStr(buyerOrder.getStatus()));
resp.setCreateTimeStr(DateUtil.long2DateStr(buyerOrder.getCreateTime().longValue()*1000, "yyyy-MM-dd HH:mm:ss"));
//卖家物流单号
ExpressRecord sellerExpressRecord = expressRecordMapper.selectByOrderCodeAndType(buyerOrder.getOrderCode(),
buyerOrder.getSellerUid(), EXPRESS_TYPE_SELLER_TO_JUDGE);
if(null != sellerExpressRecord) {
resp.setSellerWaybillCode(sellerExpressRecord.getWaybillCode());
}
//查询buyer_order_goods
List<BuyerOrderGoods> goodsList = buyerOrderGoodsMapper.selectByOrderCode(Lists.newArrayList(buyerOrder.getOrderCode()));
if(CollectionUtils.isEmpty(goodsList)) {
return resp;
}
BuyerOrderGoods goods = goodsList.get(0);
Integer skup = goods.getSkup();
//查询seller_order_goods
List<SellerOrderGoods> sellerGoodsList = sellerOrderGoodsMapper.selectByIds(Lists.newArrayList(skup));
if(CollectionUtils.isEmpty(sellerGoodsList)) {
return resp;
}
SellerOrderGoods sellerGoods = sellerGoodsList.get(0);
//商品信息
resp.setProductImage(ImagesHelper.getImageAbsoluteUrl(sellerGoods.getImageUrl(), ImagesConstant.BUCKET_GOODS_IMG));
resp.setProductName(sellerGoods.getProductName());
resp.setSizeName(sellerGoods.getSizeName());
resp.setGoodsPrice(String.format("%.2f", sellerGoods.getGoodsPrice().doubleValue()));
Product product = productMapper.selectByPrimaryKey(sellerGoods.getProductId());
resp.setProductCode(null == product ? "" : product.getProductCode());
resp.setVedioUrl(getVedioUrl(buyerOrder.getOrderCode()));
rebuildQcOrderDetailResp(buyerOrder, skup, resp);
return resp;
}
private void rebuildQcOrderDetailResp(BuyerOrder buyerOrder, Integer skup, QcOrderDetailResp resp) {
if(buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal()) {
//收货信息
BuyerOrderMeta buyerMeta = buyerOrderMetaMapper.selectByOrderCodeAndKey(buyerOrder.getOrderCode(), BUYER_ORDER_META_KEY_DELIVERY_ADDRESS);
JSONObject metaValue = JSONObject.parseObject(buyerMeta.getMetaValue());
resp.setReceiveName(metaValue.getString("consignee"));
resp.setReceiveMobile(metaValue.getString("mobile"));
resp.setReceiveAddressDetail(metaValue.getString("address"));
String receiveAddressCode = metaValue.getString("areaCode");
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
}
if(buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal()) {
//卖家信息
resp.setSellerName(getUserNameByUid(buyerOrder.getSellerUid()));
SellerOrderMeta sellerMeta = sellerOrderMetaMapper.selectBySkupAndKey(skup, SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS);
if(sellerMeta!=null){
JSONObject sellerMetaValue = JSONObject.parseObject(sellerMeta.getMetaValue());
resp.setSellerRebackAddressDetail(sellerMetaValue.getString("address"));
resp.setSellerRebackAddress(getAddressInfo(sellerMetaValue.getString("areaCode")));
resp.setSellerRebackMobile(sellerMetaValue.getString("mobile"));
}
}
if(buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_TO_BE_RECEIVED.getByteVal()
|| buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal()) {
//物流信息-平台
List<ExpressRecord> platformExpressList =
expressRecordMapper.selectByOrderCodeListAndType(Lists.newArrayList(buyerOrder.getOrderCode()), Lists.newArrayList(EXPRESS_TYPE_JUDGE_TO_BUYER, EXPRESS_TYPE_JUDGE_TO_SELLER,EXPRESS_TYPE_RETURN_BACK_TO_SELLER));
if(CollectionUtils.isNotEmpty(platformExpressList)) {
ExpressRecord judgeExpressRecord =platformExpressList.get(0);
resp.setPlatformWaybillCode(judgeExpressRecord.getWaybillCode());
}
}
}
private String getVedioUrl(String orderCode) {
List<QiniuLiveRecord> liveRecordList = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(Long.valueOf(orderCode)));
if(CollectionUtils.isNotEmpty(liveRecordList)) {
String filename = liveRecordList.get(0).getVedioFileUrl();
if (StringUtils.isBlank(filename)) {
return "";
}
if (filename.startsWith("http")) {
return filename;
}else {
return QNliveConstants.LIVE_VIDEO_DOMAIN + QNliveConstants.MP4_FILEKEY_PRE + filename;
}
}
return "";
}
public Map<String,Object> queryExpressListAndAddressInfo(String orderCode, String expressType){
LOGGER.info("queryExpressListAndAddressInfo orderCode is {}, expressTypeStr is {}", orderCode, expressType);
... ... @@ -1961,7 +2077,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
private List<BuyerOrderResp> convertToRespForQc(List<BuyerOrder> orderList, Map<String, BuyerOrderGoods> buyerGoodsMap,
Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap,
Map<String, BuyerOrderMeta> buyerOrderMetaMap, Map<String, List<IdentifyRecords>> identifyMap,
Map<Integer, String> productIdCodeMap){
List<BuyerOrderResp> respList = Lists.newArrayList();
for(BuyerOrder item : orderList) {
... ... @@ -1974,19 +2089,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setSellerWaybillCode(null == expressInfoMap.get(item.getOrderCode()) ? "" : expressInfoMap.get(item.getOrderCode()).getWaybillCode());
resp.setProductName(sellerGoodsMap.get(skup).getProductName());
resp.setProductImage(ImagesHelper.getImageAbsoluteUrl(sellerGoodsMap.get(skup).getImageUrl(), ImagesConstant.BUCKET_GOODS_IMG));
resp.setColorName(sellerGoodsMap.get(skup).getColorName());
Integer productId = sellerGoodsMap.get(skup).getProductId();
resp.setProductCode(productIdCodeMap.get(productId));
resp.setSizeName(sellerGoodsMap.get(skup).getSizeName());
resp.setGoodsPrice(String.format("%.2f", buyerGoodsMap.get(item.getOrderCode()).getGoodsPrice().doubleValue()));
resp.setAmount(null == item.getAmount() ? null : String.format("%.2f", item.getAmount().doubleValue()));
JSONObject metaValue = JSONObject.parseObject(buyerOrderMetaMap.get(item.getOrderCode()).getMetaValue());
resp.setReceiveName(metaValue.getString("consignee"));
resp.setReceiveMobile(metaValue.getString("mobile"));
String receiveAddressCode = metaValue.getString("areaCode");
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
resp.setNfcStatus(CollectionUtils.isEmpty(identifyMap.get(item.getOrderCode())) ? 0 : 1);//0:未写入,1:已写入
Integer productId = sellerGoodsMap.get(skup).getProductId();
resp.setProductCode(productIdCodeMap.get(productId));
resp.setStatusStr(Constant.convertOrderStatusStr(item.getStatus()));
respList.add(resp);
}
... ...