89 lines
3.0 KiB
PHP
89 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.gobuysaas.com
|
|
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
|
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
|
* =========================================================
|
|
*/
|
|
|
|
namespace addon\stock\storeapi\controller;
|
|
|
|
use addon\stock\model\stock\Inventory;
|
|
use app\storeapi\controller\BaseStoreApi;
|
|
|
|
/**
|
|
* 库存盘点
|
|
*/
|
|
class Check extends BaseStoreApi
|
|
{
|
|
|
|
/**
|
|
* 库存盘点
|
|
* @return mixed
|
|
*/
|
|
public function lists()
|
|
{
|
|
$page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1;
|
|
$page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS;
|
|
$inventory_no = isset($this->params[ 'inventory_no' ]) ? $this->params[ 'inventory_no' ] : '';
|
|
$store_id = $this->store_id;
|
|
$condition = array (
|
|
[ 'site_id', '=', $this->site_id ],
|
|
);
|
|
if ($store_id > 0) {
|
|
$condition[] = [ 'store_id', '=', $store_id ];
|
|
}
|
|
if (!empty($inventory_no)) {
|
|
$condition[] = [ 'inventory_no', 'like', '%' . $inventory_no . '%' ];
|
|
}
|
|
$inventory_model = new Inventory();
|
|
$list = $inventory_model->getInventoryPageList($condition, $page, $page_size, 'create_time desc');
|
|
return $this->response($list);
|
|
|
|
}
|
|
|
|
/**
|
|
* 库存盘点详情
|
|
*/
|
|
public function detail()
|
|
{
|
|
$inventory_no = isset($this->params[ 'inventory_no' ]) ? $this->params[ 'inventory_no' ] : 0;
|
|
$inventory_model = new Inventory();
|
|
$condition = array (
|
|
[ 'site_id', '=', $this->site_id ],
|
|
[ 'inventory_no', '=', $inventory_no ],
|
|
[ 'store_id', '=', $this->store_id ],
|
|
);
|
|
$inventory_detail = $inventory_model->getInventoryInfo($condition);
|
|
if (empty($inventory_detail)) {
|
|
return $this->response($this->error("盘点单不存在"));
|
|
}
|
|
|
|
return $this->response($inventory_detail);
|
|
}
|
|
|
|
/**
|
|
*新增盘点记录
|
|
* @return mixed
|
|
*/
|
|
public function add()
|
|
{
|
|
$inventory_model = new Inventory();
|
|
$store_id = $this->store_id;
|
|
$stock_list = isset($this->params[ 'stock_json' ]) ? $this->params[ 'stock_json' ] : '';//商品库存映照json {{'sku_id':1, 'stock' : 10, 'cost_price':10,'source':'来源'}}
|
|
$stock_list = json_decode($stock_list, true);
|
|
$params = array (
|
|
'site_id' => $this->site_id,
|
|
'store_id' => $store_id,
|
|
'sku_list' => $stock_list,
|
|
'user_info' => $this->user_info,
|
|
);
|
|
$result = $inventory_model->addInventory($params);
|
|
return $this->response($result);
|
|
}
|
|
|
|
} |