jh-admin/addon/stock/storeapi/controller/Storage.php

84 lines
2.8 KiB
PHP

<?php
/**
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.gobuysaas.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\stock\storeapi\controller;
use addon\stock\model\stock\Document;
use app\storeapi\controller\BaseStoreApi;
/**
* 入库管理
*/
class Storage extends BaseStoreApi
{
/**
* 入库管理(应该豁免盘点)
* @return mixed
*/
public function lists()
{
$document_model = new Document();
$page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
$page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
$search_text = isset($this->params[ 'search_text' ]) ? $this->params[ 'search_text' ] : '';
$store_id = $this->store_id;
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'type', '=', 'input' ]
);
if ($store_id > 0) {
$condition[] = [ 'store_id', 'in', $store_id ];
}
if (!empty($search_text)) {
$condition[] = [ 'document_no', 'like', '%' . $search_text . '%' ];
}
$result = $document_model->getDocumentPageList($condition, $page, $page_size, 'create_time desc');
return $this->response($result);
}
/**
* 创建入库单
*/
public function stockin()
{
$stock_json = isset($this->params[ 'stock_json' ]) ? $this->params[ 'stock_json' ] : '';
$stock_array = json_decode($stock_json, true);
$store_id = $this->store_id;
$document_model = new Document();
$result = $document_model->addPurchase([
'site_id' => $this->site_id,
'store_id' => $store_id,
'user_info' => $this->user_info,
'goods_sku_list' => $stock_array,
]);
return $this->response($result);
}
/**
* 入库单详情
*/
public function detail()
{
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
$document_model = new Document();
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'document_id', '=', $document_id ],
[ 'type', '=', 'input' ],
[ 'store_id', '=', $this->store_id ],
);
$document_detail = $document_model->getDocumentInfo($condition);
return $this->response($document_detail);
}
}