init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace Retail\Controller;
|
||||
|
||||
use Common\Business\SerialNumberGoods;
|
||||
use Common\Business\StockRecord;
|
||||
use Think\Controller;
|
||||
|
||||
//[1.7.90]
|
||||
class StockOutRecordController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$merchant_id = session("merchant_userinfo")['id'];
|
||||
$arr = array(
|
||||
'exportOperation' => '/index.php/Retail/StockOutRecord/export',
|
||||
);
|
||||
$authArr = checkFunction($arr);
|
||||
$class_name = A('Api/Inventory')->GoodsClass($merchant_id);
|
||||
$this->assign('authArr', $authArr);
|
||||
$this->assign('goodsClass1', json_encode($class_name));
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
//出库记录串号列表
|
||||
public function stockSerialList()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['user_type'] = 3;
|
||||
$data['serial_type'] = 3;
|
||||
$SerialClass = new SerialNumberGoods();
|
||||
$result = $SerialClass->recordSerialList($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//出库记录
|
||||
public function recordList()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['merchant_id'] = $this->merchant_id;
|
||||
$StockClass = new StockRecord();
|
||||
$result = $StockClass->recordList($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//导出
|
||||
public function export()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
$user = session("merchant_userinfo");
|
||||
$content = I('get.');
|
||||
$goods_query = $content['goods_query'];
|
||||
$type = $content['type'];
|
||||
$person1 = $content['person1'];
|
||||
$person2 = $content['person2'];
|
||||
$person3 = $content['person3'];
|
||||
$add_time = $content['add_time'];
|
||||
if (!empty($goods_query)) {
|
||||
$where['goods_name|goods_number|sku_goods_number|goods_code|sku_code'] = array('like', "%" . $goods_query . "%");
|
||||
}
|
||||
if ($type != '') {
|
||||
$where['type'] = $type;
|
||||
}
|
||||
if (!empty($add_time)) {
|
||||
$add_time = explode(',', $add_time);
|
||||
$start_time = strtotime($add_time[0]);
|
||||
$end_time = strtotime($add_time[1]);
|
||||
$where['add_time'] = array("between", array($start_time, $end_time));
|
||||
}
|
||||
$flag = 0;
|
||||
if (!empty($person3)) {
|
||||
$where['goods_class_id'] = $person3;
|
||||
} else if (!empty($person2)) {
|
||||
$class = M('retail_goods_class as c2')
|
||||
->join('ls_retail_goods_class as c3 on c2.id=c3.pid')
|
||||
->where(array('c2.id' => $person2, 'c3.status' => 0))
|
||||
->field('c3.id')->select();
|
||||
$flag = 1;
|
||||
} else if (!empty($person1)) {
|
||||
$class = M('retail_goods_class as c1')
|
||||
->join('ls_retail_goods_class as c2 on c1.id=c2.pid')
|
||||
->join('ls_retail_goods_class as c3 on c2.id=c3.pid AND c3.status=0', 'LEFT')
|
||||
->where(array('c1.id' => $person1, 'c2.status' => 0))
|
||||
->field('c2.id,c3.id as c3_id')->select();
|
||||
$flag = 1;
|
||||
}
|
||||
if (!empty($class)) {
|
||||
$arr = array();
|
||||
foreach ($class as &$val) {
|
||||
if (!in_array($val['id'], $arr)) {
|
||||
$arr[] = $val['id'];
|
||||
}
|
||||
if (!empty($val['c3_id'])) {
|
||||
if (!in_array($val['c3_id'], $arr)) {
|
||||
$arr[] = $val['c3_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$str = implode(',', $arr);
|
||||
$where['goods_class_id'] = array('in', $str . ',' . ($person2 ? $person2 : $person1));
|
||||
} else if ($flag == 1) {
|
||||
$where['goods_class_id'] = $person2 ? $person2 : $person1;
|
||||
}
|
||||
$where['merchant_id'] = $user['id'];
|
||||
$list = D('StockOutGoods')->getSelect($where);
|
||||
if ($list) {
|
||||
foreach ($list as $key => &$val) {
|
||||
$val['index'] = $key + 1;
|
||||
switch ($val['type']) {
|
||||
case 0:
|
||||
$val['type_name'] = '其他出库';
|
||||
break;
|
||||
case 1:
|
||||
$val['type_name'] = '调拨出库';
|
||||
break;
|
||||
case 2:
|
||||
$val['type_name'] = '盘亏出库';
|
||||
break;
|
||||
case 3:
|
||||
$val['type_name'] = '门店申请调拨出库';
|
||||
break;
|
||||
case 4:
|
||||
$val['type_name'] = '退货出库';
|
||||
break;
|
||||
}
|
||||
if ($val['attribute_state'] == 2) {
|
||||
$val['goods_number'] = $val['sku_goods_number'];
|
||||
}
|
||||
$val['stock_price'] = strval(round($val['stock_price'], 2));
|
||||
$val['sku_num'] = strval(round($val['sku_num'], 3));
|
||||
$val['stock_num'] = strval(round($val['stock_num'], 3));
|
||||
$val['subtotal'] = strval(round($val['subtotal'], 2));
|
||||
$val['add_time'] = date('Y-m-d H:i:s', $val['add_time']);
|
||||
}
|
||||
}
|
||||
$fileds_name = "出库记录";
|
||||
$arr = array(
|
||||
array('index', '序号'),
|
||||
array('type_name', '出库类型'),
|
||||
array('goods_name', '商品名称'),
|
||||
array('sku_name', '规格名称'),
|
||||
array('goods_number', '货号'),
|
||||
array('goods_code', '条码'),
|
||||
array('sku_num', '规格基数'),
|
||||
array('company', '单位'),
|
||||
array('stock_num', '出库数量'),
|
||||
array('stock_price', '出库价'),
|
||||
array('subtotal', '合计'),
|
||||
array('remarks', '备注'),
|
||||
array('add_time', '出库时间'),
|
||||
);
|
||||
$str = $fileds_name . ',导出日期:' . date('Y-m-d H:i:s', time());
|
||||
getExcel($fileds_name, $arr, $list, $str);
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户