Authored by mali

Merge branch 'test6.8.4' of http://git.yoho.cn/ufo/ufo-platform into test6.8.4

package com.yoho.order.dal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.BuyerOrderMeta;
... ... @@ -12,4 +14,6 @@ public interface BuyerOrderMetaMapper {
BuyerOrderMeta selectByOrderCodeAndKey(@Param("orderCode") String orderCode, @Param("metaKey") String metaKey);
int updateMetaValue(@Param("orderCode") String orderCode, @Param("metaKey") String metaKey, @Param("metaValue") String metaValue);
List<BuyerOrderMeta> selectByBatchOrderCodeAndKey(@Param("list") List<String> orderCodeList, @Param("metaKey") String metaKey);
}
... ...
... ... @@ -23,4 +23,12 @@
where order_code=#{orderCode} and meta_key=#{metaKey}
</update>
<select id="selectByBatchOrderCodeAndKey" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from buyer_order_meta where meta_key=#{metaKey} and order_code in
<foreach collection="list" item="orderCode" open="(" separator="," close=")">
#{orderCode}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
... ... @@ -138,4 +139,11 @@ public class BuyerOrderController {
List<OrderOperateRecordResp> result = buyerOrderService.queryOperateRecordList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("获取信息成功").data(result).build();
}
@RequestMapping(value = "/queryByOrderCodeOrWaybillCode")
public ApiResponse queryByOrderCodeOrWaybillCode(@RequestBody String queryStr) {
LOGGER.info("queryByOrderCodeOrWaybillCode in. queryStr is {}", queryStr);
PageResponseBO<BuyerOrderResp> result = buyerOrderService.queryByOrderCodeOrWaybillCode(queryStr);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
... ... @@ -42,4 +42,6 @@ public interface IBuyerOrderService {
int updateReceiveInfo(BuyerOrderReq req);
List<OrderOperateRecordResp> queryOperateRecordList(BuyerOrderReq req);
PageResponseBO<BuyerOrderResp> queryByOrderCodeOrWaybillCode(String queryStr);
}
... ...
... ... @@ -177,9 +177,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
public PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq req) {
if(!checkAndBuildParam(req)) {
return null;
}
buildParam(req);
int total = buyerOrderMapper.selectTotalByCondition(req);
if(total == 0) {
... ... @@ -239,7 +237,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
List<ExpressCompany> companyList = expressCompanyMapper.selectByIdList(expressCompanyIdList);
companyMap = companyList.stream().collect(Collectors.toMap(ExpressCompany::getId, ExpressCompany::getCompanyName));
}
List<BuyerOrderResp> respList = convertToResp(orderList, buyerGoodsMap, sellerOrderMap, sellerGoodsMap,expressRecordMap, platformExpressRecordMap, companyMap,skupProductCodeMap);
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
... ... @@ -251,6 +248,59 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return result;
}
public PageResponseBO<BuyerOrderResp> queryByOrderCodeOrWaybillCode(String queryStr) {
if(StringUtils.isEmpty(queryStr)) {
return null;
}
List<BuyerOrder> orderList = Lists.newArrayList();
//先按订单号来查
BuyerOrder order = buyerOrderMapper.selectByOrderCode(queryStr);
if(null == order){//再按卖家运单号来查
BuyerOrderReq req = new BuyerOrderReq();
req.setSellerWaybillCode(queryStr);
List<BuyerOrder> list = buyerOrderMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(list)){
return null;
}
orderList.addAll(list);
}else{
orderList.add(order);
}
//查询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;
}
Map<String, BuyerOrderGoods> buyerGoodsMap = buyerGoodsList.stream().collect(Collectors.toMap(BuyerOrderGoods::getOrderCode, b->b));
//查询seller_order_goods
List<Integer> skupList = buyerGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
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));
List<BuyerOrderResp> respList = convertToRespForQuery(orderList, buyerGoodsMap, sellerGoodsMap,expressRecordMap, buyerOrderMetaMap);
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
result.setList(respList);
result.setSize(respList.size());
result.setTotal(respList.size());
return result;
}
public JSONObject updateOrderStatus(BuyerOrderReq req) {
if(null == req.getId() || null == req.getStatus()) {
return null;
... ... @@ -789,6 +839,36 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return respList;
}
private List<BuyerOrderResp> convertToRespForQuery(List<BuyerOrder> orderList, Map<String, BuyerOrderGoods> buyerGoodsMap,
Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap,
Map<String, BuyerOrderMeta> buyerOrderMetaMap){
List<BuyerOrderResp> respList = Lists.newArrayList();
for(BuyerOrder item : orderList) {
if(null == buyerGoodsMap.get(item.getOrderCode())) {
continue;
}
Integer skup = buyerGoodsMap.get(item.getOrderCode()).getSkup();
BuyerOrderResp resp = new BuyerOrderResp();
resp.setOrderCode(item.getOrderCode());
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());
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));
respList.add(resp);
}
return respList;
}
private List<Byte> getStatusListByNavStatus(Integer navStatus) {
switch(navStatus) {
case 1: return Lists.newArrayList(Constant.BUYER_ORDER_STATUS_BUYER_NOT_PAY.getByteVal());
... ... @@ -809,7 +889,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
}
private boolean checkAndBuildParam(BuyerOrderReq req) {
private void buildParam(BuyerOrderReq req) {
if(StringUtils.isNotEmpty(req.getStatusStr())) {
req.setStatusList(convertStatus(req.getStatusStr()));
}
... ... @@ -818,18 +898,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
req.setStatusList(getStatusListByNavStatus(req.getNavStatus()));
}
// if(StringUtils.isNotEmpty(req.getSellerWaybillCode())) {
// List<ExpressRecord> expressRecordList = expressoRecordMapper.selectByWaybillCode(req.getSellerWaybillCode());
// if(CollectionUtils.isEmpty(expressRecordList)) {
// return false;
// }else {
// List<String> buyerOrderCodeList = expressRecordList.stream().map(ExpressRecord::getOrderCode).collect(Collectors.toList());
// List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectByOrderCode(buyerOrderCodeList);
// List<Integer> skupList = buyerOrderGoodsList.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
// req.setSkupList(skupList);
// }
// }
if(StringUtils.isNotEmpty(req.getMobile())) {
Integer uid = getUidByMobile(req.getMobile());
if(null != uid) {
... ... @@ -837,8 +905,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
}
return true;
}
private List<Byte> convertStatus(String statusStr){
... ...