Allocate.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\stock\storeapi\controller;
  13. use addon\stock\model\stock\Allot;
  14. use app\storeapi\controller\BaseStoreApi;
  15. /**
  16. * 库存调拨
  17. */
  18. class Allocate extends BaseStoreApi
  19. {
  20. /**
  21. * 调拨单
  22. * @return mixed
  23. */
  24. public function lists()
  25. {
  26. $allot_model = new Allot();
  27. $page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
  28. $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
  29. $allot_no = isset($this->params[ 'allot_no' ]) ? $this->params[ 'allot_no' ] : '';
  30. $store_id = $this->store_id;
  31. $condition = array (
  32. [ 'site_id', '=', $this->site_id ],
  33. );
  34. $condition[] = [ 'output_store_id|input_store_id', '=', $store_id ];
  35. if ($allot_no) {
  36. $condition[] = [ 'allot_no', '=', $allot_no ];
  37. }
  38. $result = $allot_model->getStockAllotPageList($condition, $page, $page_size, 'create_time desc');
  39. return $this->response($result);
  40. }
  41. /**
  42. * 详情
  43. */
  44. public function detail()
  45. {
  46. $allot_id = isset($this->params[ 'allot_id' ]) ? $this->params[ 'allot_id' ] : 0;
  47. $condition = array (
  48. [ 'site_id', '=', $this->site_id ],
  49. [ 'allot_id', '=', $allot_id ],
  50. [ 'output_store_id|input_store_id', '=', $this->store_id ]
  51. );
  52. $allot_model = new Allot();
  53. $detail = $allot_model->getAllotInfo($condition);
  54. return $this->response($detail);
  55. }
  56. /**
  57. * 创建调拨单
  58. */
  59. public function addAllocate()
  60. {
  61. $type = $this->params[ 'allot_type' ] ?? '';//in out
  62. $store_id = $this->params[ 'temp_store_id' ] ?? 0;
  63. if ($type == 'in') {
  64. $output_store_id = $store_id;
  65. $input_store_id = $this->store_id;
  66. } else {
  67. $output_store_id = $this->store_id;
  68. $input_store_id = $store_id;
  69. }
  70. $allot_model = new Allot();
  71. $data = [
  72. 'output_store_id' => $output_store_id,
  73. 'input_store_id' => $input_store_id,
  74. 'remark' => $this->params[ 'remark' ] ?? '',
  75. 'goods_sku_list' => !empty($this->params[ 'goods_sku_list' ]) ? json_decode($this->params[ 'goods_sku_list' ], true) : [],
  76. 'allot_time' => !empty($this->params[ 'allot_time' ]) ? date_to_time($this->params[ 'allot_time' ]) : 0,
  77. 'operater' => $this->uid,
  78. 'site_id' => $this->site_id
  79. ];
  80. $result = $allot_model->addAllot($data);
  81. return $this->response($result);
  82. }
  83. }