Storage.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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\Document;
  14. use app\storeapi\controller\BaseStoreApi;
  15. /**
  16. * 入库管理
  17. */
  18. class Storage extends BaseStoreApi
  19. {
  20. /**
  21. * 入库管理(应该豁免盘点)
  22. * @return mixed
  23. */
  24. public function lists()
  25. {
  26. $document_model = new Document();
  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. $search_text = isset($this->params[ 'search_text' ]) ? $this->params[ 'search_text' ] : '';
  30. $store_id = $this->store_id;
  31. $condition = array (
  32. [ 'site_id', '=', $this->site_id ],
  33. [ 'type', '=', 'input' ]
  34. );
  35. if ($store_id > 0) {
  36. $condition[] = [ 'store_id', 'in', $store_id ];
  37. }
  38. if (!empty($search_text)) {
  39. $condition[] = [ 'document_no', 'like', '%' . $search_text . '%' ];
  40. }
  41. $result = $document_model->getDocumentPageList($condition, $page, $page_size, 'create_time desc');
  42. return $this->response($result);
  43. }
  44. /**
  45. * 创建入库单
  46. */
  47. public function stockin()
  48. {
  49. $stock_json = isset($this->params[ 'stock_json' ]) ? $this->params[ 'stock_json' ] : '';
  50. $stock_array = json_decode($stock_json, true);
  51. $store_id = $this->store_id;
  52. $document_model = new Document();
  53. $result = $document_model->addPurchase([
  54. 'site_id' => $this->site_id,
  55. 'store_id' => $store_id,
  56. 'user_info' => $this->user_info,
  57. 'goods_sku_list' => $stock_array,
  58. ]);
  59. return $this->response($result);
  60. }
  61. /**
  62. * 入库单详情
  63. */
  64. public function detail()
  65. {
  66. $document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
  67. $document_model = new Document();
  68. $condition = array (
  69. [ 'site_id', '=', $this->site_id ],
  70. [ 'document_id', '=', $document_id ],
  71. [ 'type', '=', 'input' ],
  72. [ 'store_id', '=', $this->store_id ],
  73. );
  74. $document_detail = $document_model->getDocumentInfo($condition);
  75. return $this->response($document_detail);
  76. }
  77. }