[关闭]
@Wahson 2018-06-18T22:53:28.000000Z 字数 3402 阅读 1002

修正单重构设计文档

工作


1. 门店收货逻辑调整

门店收货逻辑调整: 门店多次收货,原2个接口合并为一个接口,

  1. CreateStoreInStockOrderNotTourActionResetStoreInStockOrderNotTourAction
  2. => StoreReceiptAction // 门店收货
  3. 前置检查:
  4. 1. 配送单号校验
  5. 2. (配送单状态 == 配送中) || (配送单状态 == 配送完成 && 入库单创建时间为当天)
  6. 3. 配送单仓库实发 = 门店实收 + 拒收 + 缺货
  7. 代码逻辑:
  8. 1. 根据配送单id, 查询门店入库单
  9. 2. 如果没有门店入库单(第一次收货),则新建入库单和入库子单,保存sku入库数
  10. 3. 如果存在入库单(非第一次收货),更新入库单子单数量、金额,更新入库主单数量、金额,fire库存事件,更新门店实时库存
  11. 4. 更新配送单实收数、拒收数、缺货数、拒收原因

2. 定时器 -- 日结后将前一天收货配送单的拒收数量和缺货数量推送到wms ,并且生成对应的缺货修正单和拒收修正单

  1. 接口定义:void wmsDeliveryRejectionOrAbsenceSync()
  2. 定时配置: @ScheduledTaskCron(cron = "0 0 2 * * ?")
  3. 逻辑:
  4. 1. 查询 deliveryOrders =
  5. select d.* from delivery_order d
  6. join stock_order so on d.id = so.delivery_order_id
  7. where d.from_type = 仓库 and d.to_type = 门店
  8. and so.created_at >= date_sub(current_date, interval 1 day) and so.created_at < current_date
  9. // 找出有拒收数量或缺货数量的配送单
  10. val list = deliveryOrders.map { delivery =>
  11. val deliveryOrderItems = queryDeliveryOrderItems(delivery.id)
  12. val doisWithRejection = deliveryOrderItems.filter(_.rejectionNum > 0)
  13. val doisWithAbsence = deliveryOrderItems.filter(_.absenceNum > 0)
  14. (delivery, doisWithRejection, doisWithAbsence)
  15. }
  16. // 生成缺货/拒收修正单
  17. // 构造拒收推送实体
  18. val rejections = list.map { item =>
  19. constructPostWmsRequest(item._1, item._2)
  20. }
  21. // 构造缺货推送实体
  22. val absences = list.map { item =>
  23. constructPostWmsRequest(item._1, item._3)
  24. }
  25. // 推送wms
  26. // PostWmsRequest 增加字段relatedDeliveryOrderId 关联的配送单id
  27. new PostDeliveryOrderToWmsAction(rejections ++ absences).execute

3. 定时器 -- 自动确认拒收数或缺货数

  1. 接口定义:void autoConfirm()
  2. 定时配置:@ScheduledTaskCron(cron = "0 30 0 * * ?")
  3. 处理逻辑:
  4. // 1. 找待确认且离创建时间超过31天的修正单
  5. val correctOrders = select * from correct_order where status = 待确认 and delivery_from_type = 仓库 and delivery_to_type = 门店 and created_at < date_sub(current_date, interval 31 day)
  6. correctOrders.foreach { correctOrder =>
  7. //3. 更新子单 仓库确认拒收数&拒收金额 或 确认缺货数&确认缺货金额
  8. update correct_order_item set
  9. confirm_reject_num = case when absence_num <> confirm_absence_num then reject_num else 0 end,
  10. confirm_reject_amount = case when absence_num <> confirm_absence_num then reject_amount else 0 end,
  11. confirm_absence_num = case when reject_num <> confirm_reject_num then absence_num else 0 end,
  12. confirm_absence_amount = case when reject_num <> confirm_reject_num then absence_amount else 0 end
  13. where correct_order_id = ${correctOrder.id};
  14. // 逻辑说明: 如门店拒收数量和仓库确认拒收数量不相等,31天内依然没有收到wms回抛缺货数,则默认仓库接受门店缺货数,更新confirm_absence_num = absence_num
  15. }
  16. // 3. 更新主单状态
  17. update correct_order set status = 待裁决 where id in (${ids}));

不变量规则:
1. 当且仅当门店拒收数量和仓库确认拒收数量门店缺货数量和仓库确认缺货数量不相等,是存在修正单,且修正单状态为待确认。


4. 接收wms回抛接口

  1. 接口定义:
  2. 处理逻辑:
  3. val deliveryOrder = queryDeliveryOrderById(request.relatedDeliveryOrderId)
  4. val deliveryOrderItems = queryDeliveryOrderItems(deliveryOrder.id)
  5. val correctOrderOpt = queryCorrectOrderByDeliveryOrderId(deliveryOrder.id)
  6. request.修正类型 match {
  7. case 拒收 =>
  8. // 比对找出有拒收差异的sku
  9. if(correctOrderOpt.isDefined) {
  10. if(有差异的skus.size > 0) {
  11. 更新子单确认拒收数量和金额()
  12. 更新主单相应数量和金额()
  13. }
  14. 更新主单状态 = 待裁决
  15. } else {
  16. if(有差异的skus.size > 0) {
  17. 修正单状态 = if(deliveryOrderItems.exist(sku.absenceNum > 0)) 待确认 else 待裁决
  18. 新建修正单(修正单状态)
  19. }
  20. }
  21. case 缺货 =>
  22. // 比对找出有缺货差异的sku
  23. if(correctOrderOpt.isDefined) {
  24. if(有差异的skus.size > 0) {
  25. 更新子单确认缺货数量和金额()
  26. 更新主单相应数量和金额()
  27. }
  28. 更新主单状态 = 待裁决
  29. } else {
  30. if(有差异的skus.size > 0) {
  31. 修正单状态 = if(deliveryOrderItems.exist(sku.rejectionNum > 0)) 待确认 else 待裁决
  32. 新建修正单(修正单状态)
  33. }
  34. }
  35. }

7. 总部物流裁决接口

  1. 接口定义: void makeLogisticsAdjudgement(request)
  2. 处理逻辑:
  3. 1. 更新修正子单裁决拒收数/金额和裁决缺货数/金额字段
  4. 2. 更新修正主单相应数量/金额, 状态 = 已裁决
  5. 3. 裁决拒收数和裁决缺货数推送wms, 接口待wms给出

8. 门店拒收收货

  1. 接口定义:StoreRejectionReceiveAction
  2. 接口逻辑:
  3. 门店收货拒收,总部裁决后,对于仓库打回的拒收货物的收货操作
  4. 根据修正单总部裁决拒收数,更新收货数量,门店入库(入库数量=门店拒收数-总部裁决拒收数)

9. eywa修正单页面 --朱方方

参照原型

10. navi收货页面逻辑调整 --吴月

  1. 配送单日结前可以多次收货,日结后不能收货
  2. 修正单裁决后,配送单可以收货,收货时只能修改拒收数量
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注