| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
- * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
- * =========================================================
- */
- namespace addon\stock\storeapi\controller;
- use addon\stock\model\stock\Allot;
- use app\storeapi\controller\BaseStoreApi;
- /**
- * 库存调拨
- */
- class Allocate extends BaseStoreApi
- {
- /**
- * 调拨单
- * @return mixed
- */
- public function lists()
- {
- $allot_model = new Allot();
- $page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
- $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
- $allot_no = isset($this->params[ 'allot_no' ]) ? $this->params[ 'allot_no' ] : '';
- $store_id = $this->store_id;
- $condition = array (
- [ 'site_id', '=', $this->site_id ],
- );
- $condition[] = [ 'output_store_id|input_store_id', '=', $store_id ];
- if ($allot_no) {
- $condition[] = [ 'allot_no', '=', $allot_no ];
- }
- $result = $allot_model->getStockAllotPageList($condition, $page, $page_size, 'create_time desc');
- return $this->response($result);
- }
- /**
- * 详情
- */
- public function detail()
- {
- $allot_id = isset($this->params[ 'allot_id' ]) ? $this->params[ 'allot_id' ] : 0;
- $condition = array (
- [ 'site_id', '=', $this->site_id ],
- [ 'allot_id', '=', $allot_id ],
- [ 'output_store_id|input_store_id', '=', $this->store_id ]
- );
- $allot_model = new Allot();
- $detail = $allot_model->getAllotInfo($condition);
- return $this->response($detail);
- }
- /**
- * 创建调拨单
- */
- public function addAllocate()
- {
- $type = $this->params[ 'allot_type' ] ?? '';//in out
- $store_id = $this->params[ 'temp_store_id' ] ?? 0;
- if ($type == 'in') {
- $output_store_id = $store_id;
- $input_store_id = $this->store_id;
- } else {
- $output_store_id = $this->store_id;
- $input_store_id = $store_id;
- }
- $allot_model = new Allot();
- $data = [
- 'output_store_id' => $output_store_id,
- 'input_store_id' => $input_store_id,
- 'remark' => $this->params[ 'remark' ] ?? '',
- 'goods_sku_list' => !empty($this->params[ 'goods_sku_list' ]) ? json_decode($this->params[ 'goods_sku_list' ], true) : [],
- 'allot_time' => !empty($this->params[ 'allot_time' ]) ? date_to_time($this->params[ 'allot_time' ]) : 0,
- 'operater' => $this->uid,
- 'site_id' => $this->site_id
- ];
- $result = $allot_model->addAllot($data);
- return $this->response($result);
- }
- }
|