141 行
4.8 KiB
PHP
可执行文件
141 行
4.8 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Retail\Controller;
|
|
|
|
use Common\Business\DownFile;
|
|
use Common\Business\Export;
|
|
use Common\Business\SerialNumberGoods;
|
|
use Common\Business\Supplier;
|
|
use Common\Business\WarehousingRecord;
|
|
use Think\Controller;
|
|
|
|
//[1.7.90]
|
|
class SWarehouseRecordController extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
$global_store_jurisdiction = session('global_store_jurisdiction');
|
|
$merchant_id = session("ls_userinfo")['merchantid'];
|
|
$arr = array(
|
|
'exportOperation' => '/index.php/Retail/SWarehouseRecord/export',
|
|
);
|
|
$authArr = checkFunction($arr);
|
|
$class_name = A('Api/Inventory')->GoodsClass($merchant_id);//分类
|
|
//供货商
|
|
$SupplierClass = new Supplier();
|
|
$supplier_list = $SupplierClass->getList([
|
|
'user_type' => 4,
|
|
'merchant_id' => $this->merchant_id,
|
|
'store_id' => $this->store_id,
|
|
'fields' => 'id,supplier_name'
|
|
]);
|
|
$this->assign('authArr', $authArr);
|
|
$this->assign('goodsClass1', json_encode($class_name));
|
|
$this->assign('supplier_list', json_encode($supplier_list));
|
|
$this->assign('data_export', $global_store_jurisdiction['data_export']);
|
|
$this->assign("identity", self::$identity);
|
|
$this->assign('supplier_type', session('ls_userinfo')['supplier_type']);
|
|
$this->display();
|
|
}
|
|
|
|
|
|
//入库记录串号列表
|
|
public function warehouseSerialList()
|
|
{
|
|
$data = I('post.');
|
|
$data['user_type'] = 4;
|
|
$data['serial_type'] = 2;
|
|
$SerialClass = new SerialNumberGoods();
|
|
$result = $SerialClass->recordSerialList($data);
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
|
|
//入库记录
|
|
public function recordList()
|
|
{
|
|
$data = I("post.");
|
|
$data['merchant_id'] = $this->merchant_id;
|
|
$data['store_id'] = $this->store_id;
|
|
$data['showPrice'] = self::$showPrice;
|
|
$data['identity'] = self::$identity;
|
|
$data['operator_type'] = 1;
|
|
$RecordClass = new WarehousingRecord();
|
|
$result = $RecordClass->storeWarehousingGoodsRecord($data);
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
|
|
//导出
|
|
public function export()
|
|
{
|
|
ini_set('memory_limit', '-1');
|
|
$content = I("post.");
|
|
$content['merchant_id'] = $this->merchant_id;
|
|
$content['store_id'] = $this->store_id;
|
|
$content['showPrice'] = self::$showPrice;
|
|
$content['identity'] = self::$identity;
|
|
$content['operator_type'] = 1;
|
|
$RecordClass = new WarehousingRecord();
|
|
$info = $RecordClass->storeWarehousingGoodsRecord($content);
|
|
$directory_name = $content['directory_name']; //文件路径
|
|
if (empty($directory_name)) {
|
|
$directory_name = "./Uploads/WarehouseRecordExport/{$this->merchant_id}/{$this->store_id}/";
|
|
}
|
|
$fileds_name = "入库记录";
|
|
$arr = array(
|
|
array('index', '序号'),
|
|
array('type_name', '入库类型'),
|
|
array('supplier_name', '供货商'),
|
|
array('goods_name', '商品名称'),
|
|
array('sku_name', '规格名称'),
|
|
array('goods_number', '货号'),
|
|
array('goods_code', '条码'),
|
|
array('sku_num', '规格基数'),
|
|
array('company', '单位'),
|
|
array('build_date', '生产日期'),
|
|
array('quality_guarantee_period', '保质期'),
|
|
array('warehouse_num', '入库数量'),
|
|
array('warehouse_price', '入库价'),
|
|
array('subtotal', '合计'),
|
|
array('remarks', '备注'),
|
|
array('add_time', '入库时间'),
|
|
);
|
|
$str = $fileds_name . ',导出日期:' . date('Y-m-d H:i:s', time());
|
|
$param = [
|
|
'expTitle' => $fileds_name,
|
|
'expCellName' => $arr,
|
|
'expTableData' => $info['data']['list'],
|
|
'common' => $str,
|
|
'directory_name' => $directory_name,
|
|
'page' => $content['page'],
|
|
];
|
|
$ExportClass = new Export();
|
|
$result = $ExportClass->generateXLS($param);
|
|
$res = [
|
|
'status' => 1,
|
|
'message' => '请继续生成文件',
|
|
'data' => [
|
|
'type' => 1,
|
|
'directory_name' => $result['directory_name'],
|
|
]
|
|
];
|
|
if (count($info['data']['list']) < $content['limit']) {
|
|
$res['data']['type'] = 2;
|
|
$res['message'] = '数据生成完毕';
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
|
|
//下载文件
|
|
public function exportFile()
|
|
{
|
|
$DownFileClass = new DownFile();
|
|
$DownFileClass->downFile([
|
|
'file_path' => I('get.file_path'),
|
|
'file_name' => '入库记录导出',
|
|
'file_type' => '.xls'
|
|
]);
|
|
}
|
|
} |