105 行
4.0 KiB
PHP
可执行文件
105 行
4.0 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
//use Think\Controller;
|
||
//[1.9.15]
|
||
use Common\Model\RetailStoreModel;
|
||
use Common\Model\SWarehousingGoodsModel;
|
||
|
||
class PastController extends BaseController
|
||
{
|
||
public function index()
|
||
{
|
||
$arr = array(
|
||
'addWarning' => '/index.php/Retail/Past/addWarning',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
// 过期商品
|
||
public function getWarningGoods()
|
||
{
|
||
if (IS_POST) {
|
||
$data = I("post.");
|
||
$time = time();
|
||
$storeModel = new RetailStoreModel();
|
||
$store_warning = $storeModel->getFindField(['id' => $this->store_id], "warning");
|
||
$warning_time = $time + $store_warning * 86400;
|
||
$fields = "goods_name,sku_name,goods_number,sku_goods_number,goods_code,sku_code,company,warehouse_num,surplus_num,build_date,quality_guarantee_period,warehouse_price,attribute_state";
|
||
$where = [
|
||
'store_id' => $this->store_id,
|
||
'surplus_num' => ['gt', 0],
|
||
'build_date' => [['neq', ''], ['elt', $time], 'and'],
|
||
'quality_guarantee_period' => ['neq', ''],
|
||
'_string' => "build_date + (quality_guarantee_period * 86400) <= $warning_time"
|
||
];
|
||
if (!empty($data['keyword'])) {
|
||
$where['goods_name|goods_number'] = ['like', '%' . $data['keyword'] . '%'];
|
||
}
|
||
$saleModel = new SWarehousingGoodsModel();
|
||
$list = $saleModel->getSelect($where, $data['page'], $data['limit'], $fields);
|
||
$count = $saleModel->getCount($where);
|
||
foreach ($list as $key => &$val) {
|
||
$val['index'] = $key + 1;
|
||
$val['warehouse_price'] = round($val['warehouse_price'], 2);
|
||
$val['surplus_num'] = round($val['surplus_num'], 3);
|
||
if ($val['attribute_state'] == 2) {
|
||
$val['goods_number'] = $val['sku_goods_number'];
|
||
$val['goods_code'] = $val['sku_code'];
|
||
}
|
||
if (!empty($val['build_date'])) {
|
||
$val['build_date'] = date('Y-m-d', $val['build_date']);
|
||
}
|
||
}
|
||
$this->ajaxReturn(callBack(statusCode()['success'], $list ? '获取成功' : '暂无数据', [
|
||
'list' => $list ? $list : [],
|
||
'count' => int($count),
|
||
]));
|
||
}
|
||
}
|
||
|
||
// 加载模板
|
||
public function addWarning()
|
||
{
|
||
$storeid = session('storeid');
|
||
$warning = M('retail_store')->where(array('id' => $storeid))->getField('warning');
|
||
$warning = $warning ? $warning : 1;
|
||
$this->assign('warning', $warning);
|
||
$this->assign('storeid', $storeid);
|
||
$this->display();
|
||
}
|
||
|
||
// 修改预警时间
|
||
public function create_warning()
|
||
{
|
||
if (IS_POST) {
|
||
$warning = I('post.warning');
|
||
$storeid = I('post.storeid');
|
||
if (!empty($warning) && !empty($storeid)) {
|
||
$set_warning = M('retail_store')->where(array('id' => $storeid))->setField('warning', $warning);
|
||
if (!empty($set_warning)) {
|
||
//操作日志记录
|
||
$source = 0;//请求来源: 0pc系统 1小助手
|
||
$type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端
|
||
$request_data = json_encode($_POST);//请求参数 json数据
|
||
$desc = '临期预警-预警设置';//操作行为描述
|
||
action_log($source, $type, $request_data, $desc);
|
||
|
||
$res['status'] = 1;
|
||
$res['msg'] = '修改成功!';
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '修改失败!';
|
||
}
|
||
} else {
|
||
$res['status'] = 0;
|
||
$res['msg'] = '缺少参数!';
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
}
|
||
|
||
?>
|