1. 程式人生 > >27、生鮮電商平臺-物流配送的設計與架構

27、生鮮電商平臺-物流配送的設計與架構

fmt equal list all 成了 平臺 日期 dsi 而已

說明:由於Java開源生鮮電商平臺是屬於自建物流系統,也就是買家下的單,需要公司派物流團隊進行派送。

業務需求中買家的下單時間控制在:12:00-03:00之間。這段時間可以進行下單。

1.業務分析:

物流團隊需要知道以下東西。

1. 配送師傅需要知道去那個菜市場去哪個賣家那裏拿到那個買家的貨,由於買家買的菜是全品類,但是賣家賣的菜是單品,所以需要進行袋子組裝。

2. 配送師傅需要確認按照買家分組,知道那些菜是否組裝了,那些菜沒有進行組裝。

3. 對於已經送完的買家需要物流APP操作已經送完,方便整個系統的運營與管理。

2. 業務架構:

1. 根據業務的分析,我們得出以下幾個數據庫表的設計

2. 物流人員的管理表,其中由於物流的經理是可以看到所有的區域以及所有的物流的情況。

3. 需要根據GPS定位知道目前配送師傅的具體地址。

4. 配送師傅知道今天要去那幾家取貨,而且取多少,需要一目了然。

最新表結構如下:

3. 配送人員基礎信息表:

技術分享圖片
CREATE TABLE `delivery` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘自動增加ID‘,
  `delivery_phone` varchar(16) DEFAULT NULL COMMENT ‘手機號碼,作為賬號登陸‘,
  `delivery_password` varchar(64) DEFAULT NULL COMMENT ‘密碼‘,
  `delivery_name` varchar(16) DEFAULT NULL COMMENT ‘配送人員姓名‘,
  `delivery_sex` int(11) DEFAULT NULL COMMENT ‘性別,1為男,2為女‘,
  `delivery_idcard` varchar(18) DEFAULT NULL COMMENT ‘身份證號碼‘,
  `delivery_age` int(11) DEFAULT NULL COMMENT ‘配送人員年齡‘,
  `delivery_type` int(11) DEFAULT NULL COMMENT ‘配送人員類型:1為自營,2為加盟‘,
  `area_id` bigint(20) DEFAULT NULL COMMENT ‘所屬區域‘,
  `sequence` int(11) DEFAULT NULL COMMENT ‘排序使用.從小到大排序‘,
  `status` int(11) DEFAULT NULL COMMENT ‘1為可用,-1為不可用‘,
  `remark` varchar(256) DEFAULT NULL COMMENT ‘備註信息‘,
  `create_time` datetime DEFAULT NULL COMMENT ‘創建時間‘,
  `last_update_time` datetime DEFAULT NULL COMMENT ‘最後更新時間‘,
  `permission_type` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT=‘配送人員基本信息‘;
技術分享圖片

補充說明:增加了一個permission_type來確定當前用戶賬號的權限。相關的表結構的註釋寫的比較清楚。

4. 配送師傅配送區域信息表

技術分享圖片
CREATE TABLE `delivery_area` (
  `da_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘主鍵‘,
  `da_area_id` bigint(20) DEFAULT NULL COMMENT ‘區域ID‘,
  `da_address` varchar(255) DEFAULT NULL COMMENT ‘地址‘,
  `da_status` tinyint(4) DEFAULT NULL COMMENT ‘狀態 1在用 -1停用‘,
  `da_user_id` bigint(20) DEFAULT NULL COMMENT ‘創建人‘,
  `da_create_time` datetime DEFAULT NULL COMMENT ‘創建時間‘,
  PRIMARY KEY (`da_id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COMMENT=‘配送區域‘;
技術分享圖片

說明:不可能全城所有的物流都是一個師傅配送吧,每個師傅需要看到屬於自己配送的買家,僅此而已,我們按照區域維度進行劃分。

5. 我們需要知道配送師傅目前的GPS地理位置,那麽需要建立一個數據進行存儲

技術分享圖片
CREATE TABLE `delivery_coordinate` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘自增ID‘,
  `delivery_id` bigint(20) DEFAULT NULL COMMENT ‘配送人員ID‘,
  `lng` varchar(60) DEFAULT NULL COMMENT ‘經度‘,
  `lat` varchar(60) DEFAULT NULL COMMENT ‘維度‘,
  `address` varchar(255) DEFAULT NULL COMMENT ‘地址‘,
  `create_time` datetime DEFAULT NULL COMMENT ‘創建時間‘,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=152063 DEFAULT CHARSET=utf8 COMMENT=‘配送司機坐標‘;
技術分享圖片

備註說明:平均每隔30秒,進行系統的主動上報,最終會形成一個配送師傅的坐標。

6. 配送人員管理區域信息表

技術分享圖片
CREATE TABLE `delivery_da` (
  `dda_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘主鍵‘,
  `dda_delivery_id` bigint(20) DEFAULT NULL COMMENT ‘配送人員ID‘,
  `dda_da_id` bigint(20) DEFAULT NULL COMMENT ‘配送區域ID‘,
  `dda_user_id` bigint(20) DEFAULT NULL COMMENT ‘創建人‘,
  `dda_create_time` datetime DEFAULT NULL COMMENT ‘創建時間‘,
  PRIMARY KEY (`dda_id`)
) ENGINE=InnoDB AUTO_INCREMENT=465 DEFAULT CHARSET=utf8 COMMENT=‘配送人員管理區域‘;
技術分享圖片

說明:一個區域可能買家比較多,所以需要進行多維度進行劃分,更加細致的進行配送人員的管理。

7.對於有些特殊的情況,比如車在路上壞了,那麽需要進行人工分配物流

技術分享圖片
CREATE TABLE `delivery_task` (
  `task_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘主鍵ID‘,
  `delivery_id` bigint(20) DEFAULT NULL COMMENT ‘配送人員ID‘,
  `order_id` bigint(20) DEFAULT NULL COMMENT ‘訂單ID‘,
  `order_item_id` bigint(20) DEFAULT NULL COMMENT ‘訂單明細ID‘,
  `sys_user_id` bigint(20) DEFAULT NULL COMMENT ‘分配人員ID‘,
  `create_time` datetime DEFAULT NULL COMMENT ‘創建時間‘,
  PRIMARY KEY (`task_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
技術分享圖片

最終形成了完整的業務邏輯閉環

相關的業務核心代碼如下:

技術分享圖片
/**
 * 配送端訂單
 */
@RestController
@RequestMapping("/delivery")
public class OrderV1Controller extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(OrderV1Controller.class);

    @Autowired
    private OrderV1Service orderV1Service;
    @Autowired
    private DeliveryCoordinateService deliveryCoordinateService;
    @Autowired
    private DeliveryService deliveryService;
    @Autowired
    private AreaService areaService;
    
    /**
     * 統計配送人員訂單數
     */
    @RequestMapping(value = "/order/index", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult index(HttpServletRequest request, HttpServletResponse response,Model model,Long deliveryId) {
        try {
            //全部
            DeliveryVo all = deliveryService.getDeliveryVo(0,deliveryId,null);
            //已送
            DeliveryVo send = deliveryService.getDeliveryVo(1,deliveryId,2);
            //未送
            DeliveryVo noSend = deliveryService.getDeliveryVo(1,deliveryId,1);
            int sendCount = send.getOrderNum();
            BigDecimal totalAmt = all.getTotalAmt() == null ? BigDecimal.ZERO :all.getTotalAmt();
            int allCount = all.getOrderNum();
            int noSendCount = noSend.getOrderNum();
            model.addAttribute("noSendCount",noSendCount);
            model.addAttribute("sendCount",sendCount);
            model.addAttribute("allCount",allCount);
            model.addAttribute("totalAmt",totalAmt);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", model);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][index] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 取貨訂單列表(按賣家查詢) 
     */
    @RequestMapping(value = "/order/pickUplistBySeller", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult pickUplistBySeller(HttpServletRequest request, HttpServletResponse response,Long sellerId,Long deliveryId,Short deliveryType,Short deliveryStatus,Short payStatus) {
        try {
            //查詢訂單明細
            List<PickUpItemVo> orderItemList = orderV1Service.getPickUpItemList(null,sellerId,deliveryId,deliveryType,deliveryStatus,payStatus);
            //返回取貨列表
            List<PickUpListVo> pickUpList = new ArrayList<PickUpListVo>(); 
            //返回結果
            List<BuyerVo> buyerList = new ArrayList<BuyerVo>();
            //分組判斷
            Map<Long,BuyerVo> buyerMap = new HashMap<Long,BuyerVo>();
            //分組判斷
            Map<Long,List<BuyerVo>> pickUpMap = new TreeMap<Long,List<BuyerVo>>(new Comparator<Long>(){
                public int compare(Long obj1, Long obj2) {
                    // 降序排序
                    return obj2.compareTo(obj1);
                }
            });
            //賣家訂單總金額
            Map<Long,BigDecimal> buyer_amt = new HashMap<Long,BigDecimal>();
            //備貨完成統計
            Map<Long,Integer> a = new HashMap<Long,Integer>();
            //缺貨統計
            Map<Long,Integer> b = new HashMap<Long,Integer>();
            //訂單明細數量
            Map<Long,Integer> c = new HashMap<Long,Integer>();
            if (null != orderItemList){
                for(PickUpItemVo oiv : orderItemList){
                    Long orderId = oiv.getOrderId();
                    //配送狀態
                    int stockStatus = 0;
                    //訂單明細配送狀態
                    int status = oiv.getSellerStatus();
                    //備貨完成統計
                    int aa = a.get(orderId) == null ? 0 :a.get(orderId);
                    //缺貨統計
                    int bb = b.get(orderId) == null ? 0 :b.get(orderId);
                    //訂單明細數量
                    int cc = c.get(orderId) == null ? 0 :c.get(orderId);
                    BigDecimal buyer_totalAmt = buyer_amt.get(orderId) == null ? BigDecimal.ZERO :buyer_amt.get(orderId);
                    if(buyerMap.containsKey(orderId)){
                        if(status == 1){
                            aa += status;
                        }
                        if(status == 2){
                            bb += status;
                        }
                        cc++;
                        a.put(orderId, aa);
                        b.put(orderId, bb);
                        c.put(orderId, cc);
                        //備貨完成
                        if(aa == cc){
                            stockStatus = 1;
                        }
                        //部分備貨
                        if(aa>0 && aa!=cc){
                            stockStatus = 2;
                        }
                        //缺貨
                        if(aa == 0 && bb>0){
                            stockStatus = 3;
                        }
                        buyer_totalAmt = oiv.getGoodsAmount().add(buyer_totalAmt);
                        buyer_amt.put(orderId, buyer_totalAmt);
                        //跟買賣家總金額
                        buyerMap.get(orderId).setTotalAmt(buyer_totalAmt);
                        buyerMap.get(orderId).setStockStatus(stockStatus);
                    }else{
                        c.put(orderId, 1);
                        if(status == 1){
                            a.put(orderId, 1);
                            stockStatus = 1;
                        }
                        if(status == 2){
                            b.put(orderId, 2);
                            stockStatus = 3;
                        }
                        //創建買家信息
                        BuyerVo bv = new BuyerVo();
                        bv.setOrderId(oiv.getOrderId());
                        bv.setOrderNumber(oiv.getOrderNumber());
                        bv.setBuyerId(oiv.getBuyerId());
                        bv.setBuyerName(oiv.getBuyerName());
                        bv.setBuyerMobile(oiv.getBuyerMobile());
                        bv.setBuyerAddress(oiv.getBuyerAddress());
                        bv.setDeliveryStatus(oiv.getDeliveryStatus());
                        bv.setDeliveryTime(oiv.getBestTime());
                        bv.setTotalAmt(oiv.getGoodsAmount());
                        bv.setSellerStatus(oiv.getSellerStatus());
                        bv.setPayStatus(oiv.getPayStatus());
                        bv.setDeliveryAreaId(oiv.getDeliveryAreaId());
                        bv.setDaAddress(oiv.getDaAddress());
                        bv.setStockStatus(stockStatus);
                        bv.setTheAmt(oiv.getTheAmt());
                        bv.setThePerson(oiv.getThePerson());
                        bv.setSaleId(oiv.getSaleId());
                        bv.setSaleName(oiv.getSaleName());
                        bv.setSalePhone(oiv.getSalePhone());
                        
                        buyer_totalAmt = bv.getTotalAmt();
                        buyer_amt.put(orderId, buyer_totalAmt);
                        buyerMap.put(orderId, bv);
                        buyerList.add(bv);
                    }
                }
                List<BuyerVo> bvList = null;
                for(BuyerVo bv:buyerList){
                    Long areaId = 0L;
                    if(bv.getDeliveryAreaId()!=null){
                        areaId = bv.getDeliveryAreaId();
                    }
                    if(pickUpMap.containsKey(areaId)){
                        pickUpMap.get(areaId).add(bv);
                    }else{
                        PickUpListVo pv = new PickUpListVo();
                        pv.setDeliveryAreaId(areaId);
                        pv.setDaAddress(bv.getDaAddress());
                        
                        bvList = new ArrayList<BuyerVo>();
                        bvList.add(bv);
                        pickUpMap.put(areaId, bvList);
                        pv.setBuyerList(bvList);
                        pickUpList.add(pv);
                    }
                }
            }
            
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", pickUpList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][pickUplistBySeller] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 送達列表  deliveryStatus=1未送達 2已送達
     */
    @RequestMapping(value = "/order/sellerListByBuyer", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult sellerListByBuyer(HttpServletRequest request, HttpServletResponse response,Long deliveryId,Long orderId,Short deliveryStatus) {
        try {
            //查詢訂單明細
            List<PickUpItemVo> orderItemList = orderV1Service.getPickUpItemList(orderId,null,deliveryId,(short)1,deliveryStatus,(short)0);
            //返回結果
            List<SellerVo> sellerListList = new ArrayList<SellerVo>();
            //按買家分組
            Map<Long,SellerVo> sellerMap = new TreeMap<Long,SellerVo>(new Comparator<Long>(){
                public int compare(Long obj1, Long obj2) {
                    // 降序排序
                    return obj2.compareTo(obj1);
                }
            });
            //備貨完成統計
            Map<Long,Integer> a = new HashMap<Long,Integer>();
            //缺貨統計
            Map<Long,Integer> b = new HashMap<Long,Integer>();
            //訂單明細數量
            Map<Long,Integer> c = new HashMap<Long,Integer>();
            //賣家訂單總金額
            Map<Long,BigDecimal> seller_amt = new HashMap<Long,BigDecimal>();
            if (null != orderItemList){
                for(PickUpItemVo oiv : orderItemList){
                    Long sellerId = oiv.getSellerId();
                    //配送狀態
                    int stockStatus = 0;
                    //訂單明細配送狀態
                    int status = oiv.getSellerStatus();
                    //備貨完成統計
                    int aa = a.get(sellerId) == null ? 0 :a.get(sellerId);
                    //缺貨統計
                    int bb = b.get(sellerId) == null ? 0 :b.get(sellerId);
                    //訂單明細數量
                    int cc = c.get(sellerId) == null ? 0 :c.get(sellerId);
                    BigDecimal seller_totalAmt = seller_amt.get(sellerId) == null ? BigDecimal.ZERO :seller_amt.get(sellerId);
                    if(sellerMap.containsKey(sellerId)){
                        if(status == 1){
                            aa += status;
                        }
                        if(status == 2){
                            bb += status;
                        }
                        cc++;
                        a.put(sellerId, aa);
                        b.put(sellerId, bb);
                        c.put(sellerId, cc);
                        //備貨完成
                        if(aa == cc){
                            stockStatus = 1;
                        }
                        //部分備貨
                        if(aa>0 && aa!=cc){
                            stockStatus = 2;
                        }
                        //缺貨
                        if(aa == 0 && bb>0){
                            stockStatus = 3;
                        }
                        seller_totalAmt = oiv.getGoodsAmount().add(seller_totalAmt);
                        seller_amt.put(sellerId, seller_totalAmt);
                        //將買家信息加入到買家列表中
                        sellerMap.get(sellerId).setTotalAmt(seller_totalAmt);
                        sellerMap.get(sellerId).setStockStatus(stockStatus);
                    }else{
                        c.put(sellerId, 1);
                        if(status == 1){
                            a.put(orderId, 1);
                            stockStatus = 1;
                        }
                        if(status == 2){
                            b.put(orderId, 2);
                            stockStatus = 3;
                        }
                        
                        //創建賣家信息
                        SellerVo seller = new SellerVo();
                        seller.setOrderId(oiv.getOrderId());
                        seller.setOrderNumber(oiv.getOrderNumber());
                        seller.setSellerId(oiv.getSellerId());
                        seller.setSellerName(oiv.getSellerName());
                        seller.setSellerAccount(oiv.getSellerAccount());
                        seller.setSellerLogo(oiv.getSellerLogo());
                        seller.setSellerRemark(oiv.getSellerRemark());
                        seller.setTrueName(oiv.getTrueName());
                        seller.setSellerAddress(oiv.getSellerAddress());
                        seller.setDeliveryStatus(oiv.getDeliveryStatus());
                        seller.setTotalAmt(oiv.getGoodsAmount());
                        seller.setSellerStatus(oiv.getSellerStatus());
                        seller.setPayStatus(oiv.getPayStatus());
                        seller.setStockStatus(stockStatus);
                        
                        seller_totalAmt = seller.getTotalAmt();
                        seller_amt.put(sellerId, seller_totalAmt);
                        //放入賣家信息到Map
                        sellerMap.put(sellerId, seller);
                        
                        sellerListList.add(seller);
                    }
                }
            }
            
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", sellerListList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][sellerListByBuyer] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 訂單商品列表
     * type=1 按賣家(傳sellerId) 2按買家(傳buyerId) 3按明細(傳orderId和sellerId)
     */
    @RequestMapping(value = "/order/v1/goodslist", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult goodsList(HttpServletRequest request, HttpServletResponse response,Short type,Short deliveryType,Long orderId,Long sellerId,Long buyerId,Long deliveryId) {
        try {
            List<OrderGoodsVo> goodsList = orderV1Service.getOrderGoodsList(type,deliveryType,orderId,sellerId, buyerId,deliveryId);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", goodsList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][goodsList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }


    /**
     * 更新取貨狀態 
     */
    @RequestMapping(value = "/order/v1/updatePickUpStatus", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult updatePickUpStatus(HttpServletRequest request, HttpServletResponse response,Long orderId,Long sellerId) {
        try {
            int result = orderV1Service.updatePickUpStatus(orderId, sellerId);
            if(result > 0){
                return new JsonResult(JsonResultCode.SUCCESS, "更新信息成功", "");
            }else{
                return new JsonResult(JsonResultCode.FAILURE, "更新信息失敗", "");
            }
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][updatePickUpStatus] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 根據訂單明細更新取貨狀態
     */
    @RequestMapping(value = "/order/v1/updatePickUpStatusByItemId", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult updatePickUpStatusByItemId(HttpServletRequest request, HttpServletResponse response,Long itemId) {
        try {
            int result = orderV1Service.updatePickUpStatusByItemId(itemId);
            if(result > 0){
                return new JsonResult(JsonResultCode.SUCCESS, "更新信息成功", "");
            }else{
                return new JsonResult(JsonResultCode.FAILURE, "更新信息失敗", "");
            }
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][updatePickUpStatusByItemId] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }

    /**
     * 更新送達狀態
     */
    @RequestMapping(value = "/order/v1/updateDeliveryStatus", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult updateDeliveryStatus(HttpServletRequest request, HttpServletResponse response,Long orderId,Long sellerId,Long deliveryId,String size,String onlyId) {
        try 
        {
            logger.info("[配送人員][手機型號:"+size+"][手機唯一標識:"+onlyId+"][時間:"+DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss")+"]");
            Date now = new Date();
            //當前日期
            String currentDate = DateUtil.dateToString(now, DateUtil.FMT_DATE);
            String beginTime = currentDate+" 07:00:00";
            int a = DateUtil.compareDate(now, DateUtil.stringToDate(beginTime, DateUtil.FMT_DATETIME));
            if(a<0)
            {
                logger.info("[手機型號:"+size+"][手機唯一標識:"+onlyId+"][時間:"+DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss")+"]");
                return new JsonResult(JsonResultCode.FAILURE, "7點鐘之後才能點擊已送達!", "");
            }else{
                int result = orderV1Service.updateDeliveryStatus(orderId, sellerId,deliveryId);
                if(result > 0){
                    return new JsonResult(JsonResultCode.SUCCESS, "更新信息成功", "");
                }else{
                    return new JsonResult(JsonResultCode.FAILURE, "更新信息失敗", "");
                }
            }
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][updateDeliveryStatus] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 線下收款確認
     */
    @RequestMapping(value = "/order/v1/updatePayStatus", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult updatePayStatus(HttpServletRequest request, HttpServletResponse response,Long deliveryId,Long brId,String skReamk,BigDecimal ssAmt) {
        try {
            int result = orderV1Service.updatePayStatus(deliveryId,brId, skReamk,ssAmt);
            if(result > 0){
                return new JsonResult(JsonResultCode.SUCCESS, "更新信息成功", "");
            }else{
                return new JsonResult(JsonResultCode.FAILURE, "更新信息失敗", "");
            }
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][updatePayStatus] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 取貨商家列表
     */
    @RequestMapping(value = "/order/getPickUpSellerList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getPickUpSellerList(HttpServletRequest request, HttpServletResponse response,Long deliveryId) {
        try {
            List<SellerInfoVo> list = orderV1Service.getPickUpSellerList(deliveryId, (short)1);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", list);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getPickUpSellerList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 按買家顯示商品 取貨界面全部商品
     */
    @RequestMapping(value = "/order/v1/getBuyerGoodsList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getBuyerGoodsList(HttpServletRequest request, HttpServletResponse response,Long sellerId,Long deliveryId,Integer type,Long categoryId,Long areaId) {
        try {
            List<BuyerGoodsVo> goodsList = orderV1Service.getBuyerGoodsList(sellerId, deliveryId,type,categoryId,areaId);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", goodsList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getBuyerGoodsList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 獲取賣家區域
     */
    @RequestMapping(value = "/order/v1/getSellerRegions", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getSellerRegions(HttpServletRequest request, HttpServletResponse response,String regionIds) {
        try {
            if(StringUtils.isBlank(regionIds)){
                return new JsonResult(JsonResultCode.FAILURE, "區域id為空", "");
            }
            List<Area> areaList = areaService.getAreas(regionIds);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢區域信息成功", areaList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getSellerRegions] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 備貨清單
     */
    @RequestMapping(value = "/order/v1/getStockList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getStockList(HttpServletRequest request, HttpServletResponse response,Long sellerId,Long deliveryId,String categoryCode) {
        try {
            List<StockVo> stockList = orderV1Service.getStockList(sellerId, deliveryId,categoryCode);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", stockList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getStockList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 備貨詳情
     */
    @RequestMapping(value = "/order/v1/getStockInfoList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getStockInfoList(HttpServletRequest request, HttpServletResponse response,Long sellerId,Long formatId,
            Long deliveryId,Long goodsId,Long methodId,String formatIds) {
        try {
            List<StockInfoVo> stockInfoList = orderV1Service.getStockInfoList(sellerId, formatId, deliveryId,goodsId, methodId,formatIds);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", stockInfoList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getStockInfoList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 買家地址詳情
     */
    @RequestMapping(value = "/order/getBuyerAddress", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getBuyerAddress(HttpServletRequest request, HttpServletResponse response,Long buyerId) {
        try {
            BuyerAddressVo bav = orderV1Service.getBuyerAddress(buyerId);
            if(null == bav){
                bav = new BuyerAddressVo();
            }
            if(null != bav.getBuyerImages() && !"".equals(bav.getBuyerImages())){
                String[] list = bav.getBuyerImages().split(",");
                bav.setPicList(Arrays.asList(list));
            }
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", bav);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getBuyerAddress] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 新增配送人員坐標
     */
    @RequestMapping(value = "/order/v1/insertDeliveryCoordinate", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult insertDeliveryCoordinate(HttpServletRequest request, HttpServletResponse response,@RequestBody DeliveryCoordinate deliveryCoordinate) {
        try {
            int result = deliveryCoordinateService.insertDeliveryCoordinate(deliveryCoordinate);
            if(result > 0){
                return new JsonResult(JsonResultCode.SUCCESS, "添加信息成功", "");
            }else{
                return new JsonResult(JsonResultCode.FAILURE, "添加信息失敗", "");
            }
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][insertDeliveryCoordinate] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 更新送達狀態為未送達
     */
    @RequestMapping(value = "/order/v1/updateDeliveryStatusToIng", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult updateDeliveryStatusToIng(HttpServletRequest request, HttpServletResponse response,Long orderId,Long deliveryId,String size,String onlyId) {
        try 
        {
            logger.info("[配送人員:"+deliveryId+"][手機型號:"+size+"][手機唯一標識:"+onlyId+"][時間:"+DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss")+"]");
            int result = orderV1Service.updateDeliveryStatusToIng(orderId);
            if(result > 0){
                return new JsonResult(JsonResultCode.SUCCESS, "更新信息成功", "");
            }else{
                return new JsonResult(JsonResultCode.FAILURE, "更新信息失敗", "");
            }
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][updateDeliveryStatusToIng] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 按分類取貨
     */
    @RequestMapping(value = "/order/v1/getStockListByCategory", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getStockListByCategory(HttpServletRequest request, HttpServletResponse response,Long deliveryId,Integer type) {
        try {
            List<CategoryVo> cvList = orderV1Service.getStockListByCategory(deliveryId,type);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", cvList);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getStockList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 線下收款列表
     */
    @RequestMapping(value = "/order/getReceiptList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getReceiptList(HttpServletRequest request, HttpServletResponse response,Short type,Long deliveryId) {
        try {
            List<ReceiptListVo> list = orderV1Service.getReceiptList(type, deliveryId);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", list);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getReceiptList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 線下收款訂單
     */
    @RequestMapping(value = "/order/getReceiptOrderList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getReceiptOrderList(HttpServletRequest request, HttpServletResponse response,String orderDate,Long buyerId) {
        try {
            List<OrderVo> list = orderV1Service.getReceiptOrderList(orderDate, buyerId);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", list);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getReceiptOrderList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
    /**
     * 線下收款訂單商品
     */
    @RequestMapping(value = "/order/getOrderGoodsList", method = { RequestMethod.GET, RequestMethod.POST })
    public JsonResult getOrderGoodsList(HttpServletRequest request, HttpServletResponse response,Long orderId) {
        try {
            List<OrderGoodsVo> list = orderV1Service.getLineOrderGoodsList(orderId);
            return new JsonResult(JsonResultCode.SUCCESS, "查詢信息成功", list);
        } catch (Exception ex) {
            logger.error("[OrderV1Controller][getOrderGoodsList] exception :", ex);
            return new JsonResult(JsonResultCode.FAILURE, "系統錯誤,請稍後重試", "");
        }
    }
    
}
技術分享圖片

轉載自--https://www.cnblogs.com/jurendage/p/9124947.html

27、生鮮電商平臺-物流配送的設計與架構