Authored by caoyan

订单管理

... ... @@ -14,6 +14,8 @@ public interface BuyerOrderMapper {
int selectCountByStatus(List<Byte> statusList);
int selectCountByStatusAndDepotNo(@Param("list")List<Byte> statusList, @Param("depotNo")Integer depotNo);
int selectTotalByCondition(@Param("buyerOrderReq") BuyerOrderReq req);
List<BuyerOrder> selectByCondition(@Param("buyerOrderReq") BuyerOrderReq req);
... ...
... ... @@ -11,7 +11,8 @@ import com.yoho.order.model.ExpressRecord;
*/
public interface ExpressRecordMapper {
List<ExpressRecord> selectByOrderCodeList(@Param("orderCodeList") List<String> orderCodeList);
List<ExpressRecord> selectByOrderCodeListAndType(@Param("orderCodeList") List<String> orderCodeList,
@Param("expressTypeList") List<Integer> expressTypeList);
ExpressRecord selectByWaybillCode(@Param("waybillCode") String waybillCode);
... ...
... ... @@ -44,6 +44,27 @@
</if>
</select>
<select id="selectCountByStatusAndDepotNo" resultType="java.lang.Integer">
select count(1)
from buyer_order a
<if test="depotNo != null">
LEFT JOIN buyer_order_goods b
ON( b.order_code=a.order_code)
LEFT JOIN seller_order_goods c
ON( c.id=b.skup)
</if>
where 1=1
<if test="list != null and list.size()>0">
and a.status in
<foreach collection="list" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
<if test="depotNo != null">
and c.depot_no=#{depotNo}
</if>
</select>
<sql id="Query_Order_Sql" >
<if test="buyerOrderReq.statusList != null and buyerOrderReq.statusList.size() >0">
and a.status in
... ...
... ... @@ -16,12 +16,18 @@
id, uid, order_code, waybill_code, logistics_type, depot_num, create_time, express_type
</sql>
<select id="selectByOrderCodeList" resultMap="BaseResultMap">
<select id="selectByOrderCodeListAndType" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from express_record where order_code in
<foreach collection="orderCodeList" item="orderCode" open="(" close=")" separator=",">
#{orderCode}
</foreach>
<if test="expressTypeList != null and expressTypeList.size()>0">
and express_type in
<foreach collection="expressTypeList" item="expressType" open="(" close=")" separator=",">
#{expressType}
</foreach>
</if>
</select>
<select id="selectByWaybillCode" resultMap="BaseResultMap">
... ...
... ... @@ -31,9 +31,9 @@ public class BuyerOrderController {
private IBuyerOrderService buyerOrderService;
@RequestMapping(value = "/getCountByJudgeStatus")
public ApiResponse getCountByJudgeStatus() {
public ApiResponse getCountByJudgeStatus(BuyerOrderReq req) {
LOGGER.info("getCountByJudgeStatus in");
Map<String, Integer> map = buyerOrderService.getCountByJudgeStatus();
Map<String, Integer> map = buyerOrderService.getCountByJudgeStatus(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(map).build();
}
... ...
... ... @@ -17,7 +17,7 @@ import com.yohobuy.ufo.model.order.resp.OrderOperateRecordResp;
* @date 2018/9/13
*/
public interface IBuyerOrderService {
Map<String, Integer> getCountByJudgeStatus();
Map<String, Integer> getCountByJudgeStatus(BuyerOrderReq req);
PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq req);
... ...
... ... @@ -123,7 +123,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
private static final Integer OPERATE_TYPE_UPDATE_RECEIVE_INFO = 2;//修改收货人信息
public Map<String, Integer> getCountByJudgeStatus(){
public Map<String, Integer> getCountByJudgeStatus(BuyerOrderReq req){
List<Byte> toBeJudgedList = Lists.newArrayList();
List<Byte> alreadyJudgedList = Lists.newArrayList();
toBeJudgedList.add(Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal());
... ... @@ -131,8 +131,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
alreadyJudgedList.add(Constant.BUYER_ORDER_STATUS_TO_BE_RECEIVED.getByteVal());
alreadyJudgedList.add(Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal());
int toBeJudgedNum = buyerOrderMapper.selectCountByStatus(toBeJudgedList);
int alreadyJudgedNum = buyerOrderMapper.selectCountByStatus(alreadyJudgedList);
int toBeJudgedNum = buyerOrderMapper.selectCountByStatusAndDepotNo(toBeJudgedList, req.getDepotNo());
int alreadyJudgedNum = buyerOrderMapper.selectCountByStatusAndDepotNo(alreadyJudgedList, req.getDepotNo());
Map<String, Integer> resultMap = Maps.newHashMap();
resultMap.put("toBeJudgedNum", toBeJudgedNum);
... ... @@ -194,14 +194,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
//查询seller_order
List<SellerOrder> sellerOrderList = sellerOrderMapper.selectBySkups(skupList);
List<String> sellerOrderCodeList = sellerOrderList.stream().map(SellerOrder::getOrderCode).collect(Collectors.toList());
Map<Integer, SellerOrder> sellerOrderMap = sellerOrderList.stream().collect(Collectors.toMap(SellerOrder::getSkup, s->s));
//查询卖家快递单号
List<ExpressRecord> expressRecordList =expressRecordMapper.selectByOrderCodeList(sellerOrderCodeList);
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 = convertToResp(orderList, buyerGoodsMap, sellerOrderMap, sellerGoodsMap,expressRecordMap);
//查询平台快递单号
List<ExpressRecord> platformExpressList = expressRecordMapper.selectByOrderCodeListAndType(buyerOrderCodeList, Lists.newArrayList(EXPRESS_TYPE_JUDGE_TO_BUYER, EXPRESS_TYPE_JUDGE_TO_SELLER));
Map<String, ExpressRecord> platformExpressRecordMap = platformExpressList.stream().collect(Collectors.toMap(ExpressRecord::getOrderCode, e->e));
List<BuyerOrderResp> respList = convertToResp(orderList, buyerGoodsMap, sellerOrderMap, sellerGoodsMap,expressRecordMap, platformExpressRecordMap);
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
result.setList(respList);
... ... @@ -254,7 +257,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
BuyerOrderResp result = new BuyerOrderResp();
result.setReceiveName(metaValue.getString("addresseeName"));
result.setReceiveMobile(metaValue.getString("mobile"));
result.setReceiveAddress(rebuildReceiveAddress(metaValue.getJSONObject("area")));
result.setReceiveAddress(getAddressInfo(metaValue.getString("areaCode")));
return result;
}
... ... @@ -306,18 +309,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setReceiveAreaCode(metaValue.getString("areaCode"));
resp.setReceiveAddressDetail(metaValue.getString("address"));
resp.setZipCode("null".equals(metaValue.getString("zipCode")) ? "--" : metaValue.getString("zipCode"));
String receiveAddressCode = metaValue.getString("areaCode");
//查询四级地址,比如code=110102001:北京市北京市西城区西长安街街道办事处,110000-北京市, 110100-北京市, 110102-西城区 110102001-西长安街街道办事处
Integer firstCode = Integer.valueOf(receiveAddressCode.substring(0, 2) + "0000");
Integer secondeCode = Integer.valueOf(receiveAddressCode.substring(0, 4) + "00");
Integer thirdCode = Integer.valueOf(receiveAddressCode.substring(0, 6));
Integer fourthCode = Integer.valueOf(receiveAddressCode);
List<Area> areaList = areaMapper.selectByCodeList(Lists.newArrayList(firstCode, secondeCode, thirdCode, fourthCode));
Map<Integer, String> areaMap = areaList.stream().collect(Collectors.toMap(Area::getCode, Area::getCaption));
String receiveAddress = areaMap.get(firstCode) + areaMap.get(secondeCode) + areaMap.get(thirdCode) + areaMap.get(fourthCode);
resp.setReceiveAddress(receiveAddress);
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
//查询buyer_order_goods
List<BuyerOrderGoods> goodsList = buyerOrderGoodsMapper.selectByOrderCode(Lists.newArrayList(buyerOrder.getOrderCode()));
... ... @@ -355,13 +348,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setDepotNo(sellerGoods.getDepotNo());
// List<SellerOrder> sellerOrderList = sellerOrderMapper.selectBySkups(Lists.newArrayList(skup));
// if(CollectionUtils.isEmpty(sellerOrderList)) {
// return resp;
// }
//
// SellerOrder sellerOrder = sellerOrderList.get(0);
//商品信息
resp.setProductImage(sellerGoods.getImageUrl());
resp.setProductName(sellerGoods.getProductName());
... ... @@ -519,6 +505,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return result;
}
private String getAddressInfo(String areaCode) {
//查询四级地址,比如code=110102001:北京市北京市西城区西长安街街道办事处,110000-北京市, 110100-北京市, 110102-西城区 110102001-西长安街街道办事处
Integer firstCode = Integer.valueOf(areaCode.substring(0, 2) + "0000");
Integer secondeCode = Integer.valueOf(areaCode.substring(0, 4) + "00");
Integer thirdCode = Integer.valueOf(areaCode.substring(0, 6));
Integer fourthCode = Integer.valueOf(areaCode);
List<Area> areaList = areaMapper.selectByCodeList(Lists.newArrayList(firstCode, secondeCode, thirdCode, fourthCode));
Map<Integer, String> areaMap = areaList.stream().collect(Collectors.toMap(Area::getCode, Area::getCaption));
return areaMap.get(firstCode) + areaMap.get(secondeCode) + areaMap.get(thirdCode) + areaMap.get(fourthCode);
}
private String getMobileByUid(Integer uid) {
Map<String,Integer> request = Collections.singletonMap("uid", uid);
JSONObject jsonObject = serviceCaller.getcall("uic.getProfileAction", request, JSONObject.class);
... ... @@ -593,23 +590,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
}
private String rebuildReceiveAddress(JSONObject address) {
String fourthName = address.getString("caption");
JSONObject thirdObj = address.getJSONObject("parent");
String thirdName = thirdObj.getString("caption");
JSONObject secondObj = thirdObj.getJSONObject("parent");
String secondName = secondObj.getString("caption");
JSONObject firstObj = secondObj.getJSONObject("parent");
String firstName = firstObj.getString("caption");
StringBuilder sb = new StringBuilder();
sb.append(firstName).append(secondName).append(thirdName).append(fourthName);
return sb.toString();
}
private List<BuyerOrderResp> convertToResp(List<BuyerOrder> orderList, Map<String, BuyerOrderGoods> buyerGoodsMap,
Map<Integer, SellerOrder> sellerOrderMap, Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap){
Map<Integer, SellerOrder> sellerOrderMap, Map<Integer, SellerOrderGoods> sellerGoodsMap, Map<String, ExpressRecord> expressInfoMap,
Map<String, ExpressRecord> platformExpressRecordMap){
List<BuyerOrderResp> respList = Lists.newArrayList();
for(BuyerOrder item : orderList) {
if(null == buyerGoodsMap.get(item.getOrderCode())) {
... ... @@ -624,7 +607,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setProductNum(1);//目前固定为1
resp.setSkuStr(sellerGoodsMap.get(skup).getStorageId().toString());
resp.setDepotNo(sellerGoodsMap.get(skup).getDepotNo());
resp.setSellerWaybillCode(null == expressInfoMap.get(sellerOrder.getOrderCode()) ? "" : expressInfoMap.get(sellerOrder.getOrderCode()).getWaybillCode());
resp.setSellerWaybillCode(null == expressInfoMap.get(item.getOrderCode()) ? "" : expressInfoMap.get(item.getOrderCode()).getWaybillCode());
resp.setSellerOrderCode(sellerOrder.getOrderCode());
resp.setSkup(skup);
resp.setCreateTimeStr(null == item.getCreateTime() ? "" : DateUtil.long2DateStr(item.getCreateTime().longValue()*1000, "yyyy-MM-dd HH:mm:ss"));
... ... @@ -634,6 +617,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
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()));
resp.setPlatformWaybillCode(null == platformExpressRecordMap.get(item.getOrderCode()) ? "" : platformExpressRecordMap.get(item.getOrderCode()).getWaybillCode());
respList.add(resp);
}
... ... @@ -675,9 +659,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
if(null == expressRecord) {
return false;
}else {
String sellerOrderCode = expressRecord.getOrderCode();
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(sellerOrderCode);
req.setSkup(sellerOrder.getSkup());
String buyerOrderCode = expressRecord.getOrderCode();
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectByOrderCode(Lists.newArrayList(buyerOrderCode));
req.setSkup(buyerOrderGoodsList.get(0).getSkup());
}
}
... ...
... ... @@ -66,7 +66,7 @@
<label>卖家快递单号:</label>
<input id="sellerWaybillCode_1" type="text" class="easyui-textbox" style="width:150px"/>
<label>订单状态</label>
<label>鉴定结果</label>
<select id="status_1" class="easyui-combobox" style="width:100px;" >
<option value="">全部</option>
<option value="4">鉴定通过</option>
... ... @@ -105,6 +105,7 @@ $(function() {
$("#depotNo").combobox({
onChange : function(newValue, oldValue){
getCountByJudgeStatus();
var depotNo = $("#depotNo").combobox("getValue");
$("#orderListTable").datagrid("load", {
statusStr : "2,3",
... ... @@ -225,7 +226,14 @@ function getToBeJudgedList(){
title: "收货仓库",
field: "depotNo",
width: 20,
align: "center"
align: "center",
formatter: function (value, rowData, rowIndex) {
if (value == 0) {
return "北京";
}else if(value == 1){
return "南京";
}
}
}, {
title: "商品件数",
field: "productNum",
... ... @@ -340,7 +348,7 @@ function getAlreadyJudgedList(){
},
columns: [[{
title: "卖家快递单号",
title: "平台快递单号",
field: "sellerWaybillCode",
width: 30,
align: "center"
... ... @@ -355,7 +363,7 @@ function getAlreadyJudgedList(){
width: 20,
align: "center"
}, {
title: "SKU",
title: "SKU-P",
field: "skuStr",
width: 20,
align: "center"
... ... @@ -511,11 +519,13 @@ function sendBackGoods(id){
}
function getCountByJudgeStatus(){
var form = new FormData();
form.append("depotNo", $("#depotNo").combobox("getValue"));
//发送请求
$.ajax({
type: "POST",
url: contextPath + '/buyerOrder/getCountByJudgeStatus',
//data: form,
data: form,
async: false,
cache: false,
contentType: false,
... ...