初始上传
This commit is contained in:
281
addon/stock/storeapi/controller/Allocate.php
Executable file
281
addon/stock/storeapi/controller/Allocate.php
Executable file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\stock\storeapi\controller;
|
||||
|
||||
use addon\stock\model\stock\Allot;
|
||||
use addon\stock\model\stock\Document;
|
||||
use app\storeapi\controller\BaseStoreApi;
|
||||
|
||||
/**
|
||||
* 库存调拨
|
||||
*/
|
||||
class Allocate extends BaseStoreApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 调拨单
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$allot_model = new Allot();
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$allot_no = $this->params['allot_no'] ?? '';
|
||||
$store_id = $this->store_id;
|
||||
|
||||
$condition = [
|
||||
[ '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 = $this->params['allot_id'] ?? 0;
|
||||
$condition = [
|
||||
[ '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);
|
||||
$detail[ 'data' ][ 'uid' ] = $this->user_info[ 'uid' ];
|
||||
$document_model = new Document();
|
||||
|
||||
$detail[ 'data' ][ 'is_audit' ] = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
)[ 'code' ];
|
||||
return $this->response($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建调拨单
|
||||
*/
|
||||
public function addAllocate()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' =>'store',
|
||||
'is_admin'=>$this->user_info['is_admin'],
|
||||
'menu_array'=>$this->menu_array
|
||||
]
|
||||
);
|
||||
if($audit_result['code'] < 0)
|
||||
return $this->response($audit_result);
|
||||
|
||||
$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' ] ?? '',
|
||||
'allot_no' => $this->params[ 'allot_no' ] ?? '',
|
||||
'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,
|
||||
'is_auto_audit' => false,
|
||||
'operater' => $this->uid,
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
|
||||
$result = $allot_model->addAllot($data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑盘点记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function editAllocate()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' =>$this->app_module,
|
||||
'is_admin'=>$this->user_info['is_admin'],
|
||||
'menu_array'=>$this->menu_array
|
||||
]
|
||||
);
|
||||
if($audit_result['code'] < 0)
|
||||
return $this->response($audit_result);
|
||||
|
||||
$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' ] ?? '',
|
||||
'allot_no' => $this->params[ 'allot_no' ] ?? '',
|
||||
'allot_id' => $this->params[ 'allot_id' ] ?? '',
|
||||
'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,
|
||||
'user_info' => $this->user_info,
|
||||
'is_auto_audit' => false,
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
|
||||
$result = $allot_model->editAllot($data);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑调拨单数据
|
||||
* @return false|string
|
||||
*/
|
||||
public function editData()
|
||||
{
|
||||
$allot_id = $this->params['allot_id'] ?? 0;
|
||||
|
||||
$allot_model = new Allot();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'allot_id', '=', $allot_id ],
|
||||
[ 'output_store_id|input_store_id', '=', $this->store_id ],
|
||||
];
|
||||
$allot_info = $allot_model->getAllotEditData($condition);
|
||||
return $this->response($allot_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过审核
|
||||
* @return false|string
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$allot_id = $this->params['allot_id'] ?? 0;
|
||||
$allot_model = new Allot();
|
||||
$res = $allot_model->audit([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'allot_id' => $allot_id,
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核拒绝
|
||||
* @return false|string
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$allot_id = $this->params['allot_id'] ?? 0;
|
||||
$allot_model = new Allot();
|
||||
$refuse_reason = $this->params['refuse_reason'] ?? '';
|
||||
|
||||
$res = $allot_model->refuse([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'allot_id' => $allot_id,
|
||||
'refuse_reason' => $refuse_reason
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单据
|
||||
* @return false|string
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
$allot_id = $this->params['allot_id'] ?? 0;
|
||||
$allot_model = new Allot();
|
||||
$res = $allot_model->delete([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'allot_id' => $allot_id,
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取调拨单号
|
||||
* @return false|string
|
||||
*/
|
||||
public function getAllotNo()
|
||||
{
|
||||
$allot_model = new Allot();
|
||||
$allot_no = $allot_model->getAllotNo();
|
||||
return $this->response($this->success($allot_no));
|
||||
}
|
||||
|
||||
}
|
||||
259
addon/stock/storeapi/controller/Check.php
Executable file
259
addon/stock/storeapi/controller/Check.php
Executable file
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\stock\storeapi\controller;
|
||||
|
||||
use addon\stock\model\stock\Document;
|
||||
use addon\stock\model\stock\Inventory;
|
||||
use app\storeapi\controller\BaseStoreApi;
|
||||
|
||||
/**
|
||||
* 库存盘点
|
||||
*/
|
||||
class Check extends BaseStoreApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 库存盘点
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$inventory_no = $this->params['inventory_no'] ?? '';
|
||||
$store_id = $this->store_id;
|
||||
$condition = [
|
||||
[ '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_id = $this->params['inventory_id'] ?? 0;
|
||||
$inventory_model = new Inventory();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'inventory_id', '=', $inventory_id ],
|
||||
[ 'store_id', '=', $this->store_id ],
|
||||
];
|
||||
$inventory_detail = $inventory_model->getInventoryInfo($condition);
|
||||
if (empty($inventory_detail)) {
|
||||
return $this->response($this->error('盘点单不存在'));
|
||||
}
|
||||
|
||||
$document_model = new Document();
|
||||
$inventory_detail[ 'data' ][ 'is_audit' ] = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
)[ 'code' ];
|
||||
$inventory_detail[ 'data' ][ 'uid' ] = $this->user_info[ 'uid' ];
|
||||
|
||||
return $this->response($inventory_detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增盘点记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$inventory_model = new Inventory();
|
||||
$store_id = $this->store_id;
|
||||
$stock_list = $this->params['stock_json'] ?? '';//商品库存映照json {{'sku_id':1, 'stock' : 10, 'cost_price':10,'source':'来源'}}
|
||||
$remark = $this->params['remark'] ?? '';
|
||||
$inventory_no = $this->params['inventory_no'] ?? '';
|
||||
$time = isset($this->params[ 'time' ]) ? date_to_time($this->params[ 'time' ]) : date('Y-m-d H:i:s');
|
||||
$stock_list = json_decode($stock_list, true);
|
||||
$params = [
|
||||
'site_id' => $this->site_id,
|
||||
'store_id' => $store_id,
|
||||
'sku_list' => $stock_list,
|
||||
'user_info' => $this->user_info,
|
||||
'is_auto_audit' => false,
|
||||
'remark' => $remark,
|
||||
'inventory_no' => $inventory_no,
|
||||
'action_time' => $time,
|
||||
];
|
||||
|
||||
|
||||
$result = $inventory_model->addInventory($params);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑盘点记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$inventory_id = $this->params['inventory_id'] ?? 0;
|
||||
$stock_list = $this->params['stock_json'] ?? '';//商品库存映照json {{'sku_id':1, 'stock' : 10, 'cost_price':10,'source':'来源'}}
|
||||
$remark = $this->params['remark'] ?? '';
|
||||
$inventory_no = $this->params['inventory_no'] ?? '';
|
||||
$time = isset($this->params[ 'time' ]) ? date_to_time($this->params[ 'time' ]) : date('Y-m-d H:i:s');
|
||||
$store_id = $this->store_id;
|
||||
$stock_list = json_decode($stock_list, true);
|
||||
|
||||
$inventory_model = new Inventory();
|
||||
$params = [
|
||||
'site_id' => $this->site_id,
|
||||
'store_id' => $store_id,
|
||||
'sku_list' => $stock_list,
|
||||
'user_info' => $this->user_info,
|
||||
'is_auto_audit' => false,
|
||||
'inventory_id' => $inventory_id,
|
||||
'remark' => $remark,
|
||||
'inventory_no' => $inventory_no,
|
||||
'action_time' => $time,
|
||||
];
|
||||
$result = $inventory_model->editInventory($params);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑盘点单数据
|
||||
* @return false|string
|
||||
*/
|
||||
public function editData()
|
||||
{
|
||||
$inventory_id = $this->params['inventory_id'] ?? 0;
|
||||
|
||||
|
||||
$inventory_model = new Inventory();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'inventory_id', '=', $inventory_id ],
|
||||
[ 'store_id', '=', $this->store_id ]
|
||||
];
|
||||
$inventory_info = $inventory_model->getInventoryEditData($condition);
|
||||
return $this->response($inventory_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 盘点单据通过审核
|
||||
* @return false|string
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$inventory_id = $this->params['inventory_id'] ?? 0;
|
||||
|
||||
$inventory_model = new Inventory();
|
||||
$res = $inventory_model->audit([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'inventory_id' => $inventory_id
|
||||
]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 盘点单据审核拒绝
|
||||
* @return false|string
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$inventory_id = $this->params['inventory_id'] ?? 0;
|
||||
$refuse_reason = $this->params['refuse_reason'] ?? '';
|
||||
|
||||
$inventory_model = new Inventory();
|
||||
$res = $inventory_model->refuse([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'inventory_id' => $inventory_id,
|
||||
'refuse_reason' => $refuse_reason
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除盘点单据【待审核状态】
|
||||
* @return false|string
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$inventory_id = $this->params['inventory_id'] ?? 0;
|
||||
|
||||
$inventory_model = new Inventory();
|
||||
$res = $inventory_model->delete([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'inventory_id' => $inventory_id
|
||||
]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取盘点单号
|
||||
* @return false|string
|
||||
*/
|
||||
public function getInventoryNo()
|
||||
{
|
||||
$inventory_model = new Inventory();
|
||||
$inventory_no = $inventory_model->inventoryNo();
|
||||
return $this->response($this->success($inventory_no));
|
||||
}
|
||||
|
||||
}
|
||||
238
addon/stock/storeapi/controller/Manage.php
Executable file
238
addon/stock/storeapi/controller/Manage.php
Executable file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\stock\storeapi\controller;
|
||||
|
||||
use addon\stock\model\stock\Document;
|
||||
use addon\stock\model\stock\Stock as StockModel;
|
||||
use app\dict\goods\GoodsDict;
|
||||
use app\model\goods\Goods;
|
||||
use app\model\goods\GoodsCategory;
|
||||
use app\storeapi\controller\BaseStoreApi;
|
||||
|
||||
/**
|
||||
* 库存管理
|
||||
*/
|
||||
class Manage extends BaseStoreApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 库存管理
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$search = $this->params['search'] ?? '';
|
||||
$category_id = $this->params['category_id'] ?? '';
|
||||
$min_stock = $this->params['min_stock'] ?? 0;
|
||||
$max_stock = $this->params['max_stock'] ?? 0;
|
||||
|
||||
$store_id = $this->store_id;
|
||||
|
||||
$condition = [];
|
||||
$condition[] = [ 'gs.site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'g.is_delete', '=', 0 ];
|
||||
|
||||
$condition[] = [ 'g.goods_class', 'in', [ GoodsDict::real, GoodsDict::weigh ] ];
|
||||
if (!empty($search)) {
|
||||
$condition[] = [ 'gs.sku_name|sku_no', 'like', '%' . $search . '%' ];
|
||||
}
|
||||
|
||||
if (!empty($category_id)) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $category_id . ',%' ];
|
||||
}
|
||||
if ($min_stock > 0 && $max_stock > 0) {
|
||||
$condition[] = [ 'sgs.real_stock', 'between', [ $min_stock, $max_stock ] ];
|
||||
} else if ($min_stock > 0 && $max_stock == 0) {
|
||||
$condition[] = [ 'sgs.real_stock', '>', $min_stock ];
|
||||
} else if ($min_stock == 0 && $max_stock > 0) {
|
||||
$condition[] = [ 'sgs.real_stock', '<', $max_stock ];
|
||||
}
|
||||
|
||||
$field = 'gs.stock,gs.*,g.unit';
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = gs.goods_id', 'left' ],
|
||||
];
|
||||
|
||||
if ($store_id > 0) {
|
||||
$join[] = [
|
||||
'store_goods_sku sgs',
|
||||
'sgs.sku_id = gs.sku_id and (sgs.store_id is null or sgs.store_id = ' . $store_id . ')',
|
||||
'left'
|
||||
];
|
||||
$field .= ',sgs.stock, sgs.real_stock';
|
||||
}
|
||||
|
||||
$goods_model = new \app\model\goods\Goods();
|
||||
$list = $goods_model->getGoodsSkuPageList($condition, $page, $page_size, 'g.create_time desc', $field, 'gs', $join);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存流水
|
||||
*/
|
||||
public function records()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$sku_id = $this->params['sku_id'] ?? 0;
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$start_time = $this->params['start_time'] ?? 0;
|
||||
$end_time = $this->params['end_time'] ?? 0;
|
||||
$type = $this->params['type'] ?? '';
|
||||
|
||||
$condition = [
|
||||
[ 'dg.site_id', '=', $this->site_id ],
|
||||
[ 'd.store_id', '=', $this->store_id ],
|
||||
];
|
||||
if ($sku_id > 0) {
|
||||
$condition[] = [ 'dg.goods_sku_id', '=', $sku_id ];
|
||||
}
|
||||
if (!empty($type)) {
|
||||
$condition[] = [ 'dt.key', '=', $type ];
|
||||
}
|
||||
//注册时间
|
||||
if ($start_time != '' && $end_time != '') {
|
||||
$condition[] = [ 'dg.create_time', 'between', [ strtotime($start_time), strtotime($end_time) ] ];
|
||||
} else if ($start_time != '' && $end_time == '') {
|
||||
$condition[] = [ 'dg.create_time', '>=', strtotime($start_time) ];
|
||||
} else if ($start_time == '' && $end_time != '') {
|
||||
$condition[] = [ 'dg.create_time', '<=', strtotime($end_time) ];
|
||||
}
|
||||
|
||||
if ($sku_id > 0) {
|
||||
$condition[] = [ 'dg.goods_sku_id', '=', $sku_id ];
|
||||
}
|
||||
if ($goods_id > 0) {
|
||||
$condition[] = [ 'dg.goods_id', '=', $goods_id ];
|
||||
}
|
||||
|
||||
$result = $document_model->getDocumentGoodsPageList($condition, $page, $page_size, 'dg.create_time desc');
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品规格列表(仅作临时用)
|
||||
*/
|
||||
public function getSkuList()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$search = $this->params['search'] ?? '';
|
||||
|
||||
$temp_store_id = $this->params[ 'temp_store_id' ] ?? 0;
|
||||
|
||||
$store_id = $temp_store_id > 0 ? $temp_store_id : $this->store_id;
|
||||
$stock_model = new StockModel();
|
||||
$condition = [
|
||||
[ 'gs.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_class', 'in', [ GoodsDict::real, GoodsDict::weigh ] ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
if (!empty($search)) {
|
||||
$condition[] = [ 'gs.sku_name|gs.spec_name|g.goods_name|gs.sku_no', 'like', '%' . $search . '%' ];
|
||||
}
|
||||
if (!empty($goods_id)) {
|
||||
$condition[] = [ 'g.goods_id', '=', $goods_id ];
|
||||
}
|
||||
if ($store_id > 0) {
|
||||
//查询商品支持门店(支持当前门店或全部)
|
||||
$condition[] = [ 'g.sale_store', 'like', [ '%,' . $store_id . ',%', '%all%'], 'or' ];
|
||||
}
|
||||
$field = 'gs.sku_id, gs.goods_id, gs.sku_name, gs.sku_no, gs.price, gs.discount_price,gs.goods_class, gs.goods_name, gs.spec_name, sgs.stock,sgs.real_stock,sgs.price,sgs.cost_price';
|
||||
$sku_list = $stock_model->getStoreGoodsSkuList($condition, $field, 'gs.create_time desc', $store_id, $page, $page_size);
|
||||
return $this->response($sku_list);
|
||||
}
|
||||
|
||||
public function getDocumentType()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$type_list = $document_model->getDocumentTypeList();
|
||||
return $this->response($type_list);
|
||||
}
|
||||
|
||||
public function getGoodsCategory()
|
||||
{
|
||||
$goods_model = new Goods();
|
||||
$category_id_arr = $goods_model->getGoodsCategoryIds([
|
||||
[ 'is_delete', '=', 0 ],
|
||||
[ 'goods_state', '=', 1 ],
|
||||
[ 'goods_stock', '>', 0 ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
])[ 'data' ];
|
||||
|
||||
$goods_category_model = new GoodsCategory();
|
||||
$field = 'category_id,category_name as title,pid';
|
||||
$list = $goods_category_model->getCategoryList([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'category_id', 'in', $category_id_arr ]
|
||||
], $field)[ 'data' ];
|
||||
$tree['data'] = list_to_tree($list, 'category_id', 'pid', 'children', 0);
|
||||
return $this->response($tree);
|
||||
}
|
||||
|
||||
public function getStoreGoods()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$search = $this->params['search_text'] ?? '';
|
||||
$category_id = $this->params['category_id'] ?? '';
|
||||
$temp_store_id = $this->params[ 'temp_store_id' ] ?? 0;
|
||||
$goods_class = $this->params['goods_class'] ?? '';
|
||||
$brand_id = $this->params['brand_id'] ?? '';
|
||||
$supplier_id = $this->params['supplier_id'] ?? '';
|
||||
|
||||
$store_id = $temp_store_id > 0 ? $temp_store_id : $this->store_id;
|
||||
$stock_model = new StockModel();
|
||||
|
||||
$condition = [
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
// [ 'g.goods_stock', '>', 0 ],
|
||||
[ 'g.goods_class', 'in', [ GoodsDict::real, GoodsDict::weigh ] ],
|
||||
[ 'gs.site_id', '=', $this->site_id ],
|
||||
[ 'g.is_virtual', '=', 0]
|
||||
];
|
||||
|
||||
if (!empty($search)) {
|
||||
$condition[] = [ 'gs.sku_name|gs.spec_name|g.goods_name|gs.sku_no', 'like', '%' . $search . '%' ];
|
||||
}
|
||||
if (!empty($goods_id)) {
|
||||
$condition[] = [ 'g.goods_id', '=', $goods_id ];
|
||||
}
|
||||
if ($store_id > 0) {
|
||||
//查询商品支持门店(支持当前门店或全部)
|
||||
$condition[] = [ 'g.sale_store', 'like', [ '%,' . $store_id . ',%', '%all%'], 'or' ];
|
||||
}
|
||||
|
||||
if (!empty($category_id)) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $category_id . ',%' ];
|
||||
}
|
||||
if(!empty($goods_class)){
|
||||
$condition[] = ['g.goods_class', '=', $goods_class];
|
||||
}
|
||||
if(!empty($brand_id)){
|
||||
$condition[] = ['g.brand_id', '=', $brand_id];
|
||||
}
|
||||
if(!empty($supplier_id)){
|
||||
$condition[] = ['g.supplier_id', '=', $supplier_id];
|
||||
}
|
||||
|
||||
$field = 'gs.sku_id, gs.goods_id, gs.sku_name, gs.sku_no, gs.price, gs.discount_price,gs.goods_class, gs.goods_name, gs.spec_name, gs.sku_image,gs.unit, sgs.stock,sgs.real_stock,sgs.store_id, sgs.price,sgs.cost_price';
|
||||
$sku_list = $stock_model->getStoreGoodsSkuPage($condition, $field, 'gs.goods_id desc, gs.create_time desc, gs.sku_id desc', $store_id, $page, $page_size);
|
||||
return $this->response($sku_list);
|
||||
}
|
||||
}
|
||||
240
addon/stock/storeapi/controller/Storage.php
Executable file
240
addon/stock/storeapi/controller/Storage.php
Executable file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\stock\storeapi\controller;
|
||||
|
||||
use addon\stock\dict\StockDict;
|
||||
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 = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$status = $this->params['status'] ?? '';
|
||||
$store_id = $this->store_id;
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', StockDict::input ]
|
||||
];
|
||||
if ($store_id > 0) {
|
||||
$condition[] = [ 'store_id', 'in', $store_id ];
|
||||
}
|
||||
if (!empty($status)) {
|
||||
$condition[] = [ 'document_no', 'like', '%' . $status . '%' ];
|
||||
}
|
||||
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
|
||||
$field = 'document_id, document_no, key, goods_money, promotion_money, invoice_money, document_money, remark, status, create_time, store_id, store_name, operater, operater_name, verifier, verifier_name, inventory_id,refuse_reason,audit_time';
|
||||
$result = $document_model->getDocumentPageList($condition, $page, $page_size, 'create_time desc', $field);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑入库单
|
||||
*/
|
||||
public function stockin()
|
||||
{
|
||||
$stock_json = $this->params['stock_json'] ?? '';
|
||||
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
|
||||
$remark = $this->params['remark'] ?? '';
|
||||
$document_no = $this->params['document_no'] ?? '';
|
||||
$time = isset($this->params[ 'time' ]) ? date_to_time($this->params[ 'time' ]) : date('Y-m-d H:i:s');
|
||||
$store_id = $this->store_id;
|
||||
$stock_array = json_decode($stock_json, true);
|
||||
|
||||
$document_model = new Document();
|
||||
|
||||
$document_params = [
|
||||
'site_id' => $this->site_id,
|
||||
'store_id' => $store_id,
|
||||
'user_info' => $this->user_info,
|
||||
'remark' => $remark,
|
||||
'document_no' => $document_no,
|
||||
'goods_sku_list' => $stock_array,
|
||||
'time' => $time
|
||||
];
|
||||
|
||||
if (!empty($document_id)) {
|
||||
$document_params[ 'document_id' ] = $document_id;
|
||||
$result = $document_model->editDocument($document_params);
|
||||
} else {
|
||||
$document_params[ 'is_auto_audit' ] = false;
|
||||
$result = $document_model->addPurchase($document_params);
|
||||
}
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑入库单据数据
|
||||
*/
|
||||
public function editData()
|
||||
{
|
||||
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
|
||||
|
||||
$document_model = new Document();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'document_id', '=', $document_id ],
|
||||
[ 'type', '=', StockDict::input ],
|
||||
[ 'store_id', '=', $this->store_id ],
|
||||
];
|
||||
$document_info = $document_model->getDocumentEditData($condition);
|
||||
return $this->response($document_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库单详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
|
||||
$document_model = new Document();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'document_id', '=', $document_id ],
|
||||
[ 'type', '=', StockDict::input ],
|
||||
[ 'store_id', '=', $this->store_id ],
|
||||
];
|
||||
$document_detail = $document_model->getDocumentDetail($condition);
|
||||
|
||||
$document_model = new Document();
|
||||
$document_detail[ 'data' ][ 'is_audit' ] = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
)[ 'code' ];
|
||||
$document_detail[ 'data' ][ 'uid' ] = $this->user_info[ 'uid' ];
|
||||
return $this->response($document_detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 出入库单据通过审核
|
||||
* @return false|string
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$document_id = $this->params['document_id'] ?? 0;
|
||||
|
||||
$res = $document_model->audit([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'document_id' => $document_id,
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 出入库单据审核拒绝
|
||||
* @return false|string
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$document_id = $this->params['document_id'] ?? 0;
|
||||
$refuse_reason = $this->params['refuse_reason'] ?? '';
|
||||
|
||||
$res = $document_model->refuse([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'document_id' => $document_id,
|
||||
'refuse_reason' => $refuse_reason
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单据
|
||||
* @return false|string
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$document_id = $this->params['document_id'] ?? 0;
|
||||
|
||||
$document_model = new Document();
|
||||
$audit_result = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
);
|
||||
if ($audit_result[ 'code' ] < 0) {
|
||||
return $this->response($audit_result);
|
||||
}
|
||||
|
||||
$res = $document_model->delete([
|
||||
'site_id' => $this->site_id,
|
||||
'user_info' => $this->user_info,
|
||||
'document_id' => $document_id,
|
||||
]);
|
||||
return $this->response($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取入库单号
|
||||
* @return false|string
|
||||
*/
|
||||
public function getDocumentNo()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$document_type_info = $document_model->getDocumentTypeInfo([ 'key' => 'PURCHASE' ]);
|
||||
$prefix = $document_type_info[ 'prefix' ];
|
||||
$document_no = $document_model->createDocumentNo($prefix);
|
||||
return $this->response($this->success($document_no));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
addon/stock/storeapi/controller/Store.php
Executable file
35
addon/stock/storeapi/controller/Store.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\stock\storeapi\controller;
|
||||
|
||||
use addon\stock\model\Store as StoreModel;
|
||||
use app\storeapi\controller\BaseStoreApi;
|
||||
|
||||
|
||||
/**
|
||||
* 库存调拨
|
||||
*/
|
||||
class Store extends BaseStoreApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取门店
|
||||
* @return false|string
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$store_list = ( new StoreModel )->getStoreList($this->site_id);
|
||||
return $this->response($store_list);
|
||||
}
|
||||
|
||||
}
|
||||
159
addon/stock/storeapi/controller/Wastage.php
Executable file
159
addon/stock/storeapi/controller/Wastage.php
Executable file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\stock\storeapi\controller;
|
||||
|
||||
use addon\stock\dict\StockDict;
|
||||
use addon\stock\model\stock\Document;
|
||||
use app\storeapi\controller\BaseStoreApi;
|
||||
|
||||
/**
|
||||
* 出库管理
|
||||
*/
|
||||
class Wastage extends BaseStoreApi
|
||||
{
|
||||
/**
|
||||
* 出库管理(应该豁免盘点)
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$search_text = $this->params['search_text'] ?? '';
|
||||
$status = $this->params['status'] ?? '';
|
||||
|
||||
$store_id = $this->store_id;
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', StockDict::output ]
|
||||
];
|
||||
if ($store_id > 0) {
|
||||
$condition[] = [ 'store_id', '=', $store_id ];
|
||||
}
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'document_no', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
$field = 'document_id, document_no, key, goods_money, promotion_money, invoice_money, document_money, remark, status, create_time, store_id, store_name, operater, operater_name, verifier, verifier_name, inventory_id,refuse_reason,audit_time';
|
||||
$result = $document_model->getDocumentPageList($condition, $page, $page_size, 'create_time desc', $field);
|
||||
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑出库单
|
||||
*/
|
||||
public function stockout()
|
||||
{
|
||||
$stock_json = $this->params['stock_json'] ?? '';
|
||||
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
|
||||
$remark = $this->params['remark'] ?? '';
|
||||
$document_no = $this->params['document_no'] ?? '';
|
||||
$time = isset($this->params[ 'time' ]) ? date_to_time($this->params[ 'time' ]) : date('Y-m-d H:i:s');
|
||||
$store_id = $this->store_id;
|
||||
$stock_array = json_decode($stock_json, true);
|
||||
|
||||
$document_model = new Document();
|
||||
|
||||
if (!empty($document_id)) {
|
||||
$result = $document_model->editDocument([
|
||||
'document_id' => $document_id,
|
||||
'site_id' => $this->site_id,
|
||||
'store_id' => $store_id,
|
||||
'user_info' => $this->user_info,
|
||||
'goods_sku_list' => $stock_array,
|
||||
'remark' => $remark,
|
||||
'time' => $time,
|
||||
]);
|
||||
} else {
|
||||
$result = $document_model->addOtherOutput([
|
||||
'site_id' => $this->site_id,
|
||||
'store_id' => $store_id,
|
||||
'user_info' => $this->user_info,
|
||||
'goods_sku_list' => $stock_array,
|
||||
'is_out_stock' => 1,
|
||||
'is_auto_audit' => false,
|
||||
'remark' => $remark,
|
||||
'time' => $time,
|
||||
'document_no' => $document_no,
|
||||
|
||||
]);
|
||||
}
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑出库单据数据
|
||||
*/
|
||||
public function editData()
|
||||
{
|
||||
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
|
||||
|
||||
$document_model = new Document();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'document_id', '=', $document_id ],
|
||||
[ 'type', '=', StockDict::output ],
|
||||
[ 'store_id', '=', $this->store_id ],
|
||||
];
|
||||
$document_info = $document_model->getDocumentEditData($condition);
|
||||
return $this->response($document_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 出库单详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$document_id = isset($this->params[ 'document_id' ]) ? (int) $this->params[ 'document_id' ] : 0;
|
||||
|
||||
$document_model = new Document();
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'document_id', '=', $document_id ],
|
||||
[ 'type', '=', StockDict::output ],
|
||||
[ 'store_id', '=', $this->store_id ],
|
||||
];
|
||||
$document_detail = $document_model->getDocumentDetail($condition);
|
||||
|
||||
$document_model = new Document();
|
||||
$document_detail[ 'data' ][ 'is_audit' ] = $document_model->checkAudit(
|
||||
[
|
||||
'app_module' => $this->app_module,
|
||||
'is_admin' => $this->user_info[ 'is_admin' ],
|
||||
'menu_array' => $this->menu_array
|
||||
]
|
||||
)[ 'code' ];
|
||||
$document_detail[ 'data' ][ 'uid' ] = $this->user_info[ 'uid' ];
|
||||
return $this->response($document_detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取出库单号
|
||||
* @return false|string
|
||||
*/
|
||||
public function getDocumentNo()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$document_type_info = $document_model->getDocumentTypeInfo([ 'key' => 'OTHERCK' ]);
|
||||
$prefix = $document_type_info[ 'prefix' ];
|
||||
$document_no = $document_model->createDocumentNo($prefix);
|
||||
return $this->response($this->success($document_no));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user