init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
|
||||
namespace Terminalapi\Controller;
|
||||
|
||||
use Common\Business\LossReport;
|
||||
use Common\Business\SerialNumberGoods;
|
||||
use Think\Controller;
|
||||
|
||||
//[1.7.90]
|
||||
//商户报损管理
|
||||
class LossReportController extends Controller
|
||||
{
|
||||
//报损列表
|
||||
public function LossReportList()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['operator_type'] = 3;
|
||||
$data['user_type'] = 3;
|
||||
$data['merchant_id'] = $data['merchantid'];
|
||||
$LossClass = new LossReport();
|
||||
$result = $LossClass->orderList($data);
|
||||
$result['data'] = $result['data']['list'];
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//报损时仓库商品列表已作废
|
||||
public function LossGoodsList()
|
||||
{
|
||||
$content = I("post.");
|
||||
$merchant_id = $content['merchantid'];
|
||||
$page = $content['page'];
|
||||
$limit = $content['limit'];
|
||||
$notInIds = $content['notInIds'];
|
||||
$status = $content['status'];
|
||||
$stock_status = $content['stock_status'];
|
||||
$searchText = $content['searchText'];
|
||||
$person1 = $content['person1'];
|
||||
$person2 = $content['person2'];
|
||||
$person3 = $content['person3'];
|
||||
if (!empty($searchText)) {
|
||||
$where['goods_name|sku_name|goods_code|sku_code|goods_number|sku_goods_number'] = array('like', '%' . $searchText . '%');
|
||||
}
|
||||
if (!empty($stock_status)) {
|
||||
switch ($stock_status) {
|
||||
case 1:
|
||||
//预警
|
||||
$where['_string'] = 'goods_num <= less_num';
|
||||
break;
|
||||
case 2:
|
||||
//超量
|
||||
$where['_string'] = 'goods_num >= more_num';
|
||||
break;
|
||||
case 3:
|
||||
//售罄
|
||||
$where['_string'] = 'goods_num <= 0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
if (!empty($notInIds)) {
|
||||
$where['id'] = array('not in', $notInIds);
|
||||
}
|
||||
$where['merchant_id'] = $merchant_id;
|
||||
$where['status'] = array('in', '0,1');
|
||||
if ($status != '') {
|
||||
$where['status'] = $status;
|
||||
}
|
||||
//商品列表
|
||||
$info = D('SaleMGoods')->getSelect($where, $page, $limit, $field = '', $order = "id desc");
|
||||
if ($info) {
|
||||
foreach ($info as &$value) {
|
||||
$value['loss_num'] = "";
|
||||
$value['goods_num'] = round($value['goods_num'], 3);
|
||||
$value['cost_price'] = round($value['cost_price'], 2);
|
||||
}
|
||||
}
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '查询成功';
|
||||
$res['data'] = $info;
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
|
||||
|
||||
//提交报损信息
|
||||
public function LossOperation()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['merchant_id'] = $data['merchantid'];
|
||||
$result = A('Api/Inventory')->MerReportSub($data);
|
||||
if ($result['status'] == 1) {
|
||||
$log_data = array(
|
||||
'source' => 1,
|
||||
'type' => 3,
|
||||
'desc' => '报损管理-新增',
|
||||
'request_data' => json_encode($_POST),
|
||||
'operator_id' => $_POST['operator_id'],
|
||||
'mer_id' => $_POST['merchantid']
|
||||
);
|
||||
action_log_v2($log_data);
|
||||
}
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//报损详情
|
||||
public function LossInfo()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['user_type'] = 3;
|
||||
$LossClass = new LossReport();
|
||||
$result = $LossClass->orderGoodsList($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//报损详情的串号列表
|
||||
public function lossInfoSerial()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['user_type'] = 3;
|
||||
$data['serial_type'] = 1;
|
||||
$SerialClass = new SerialNumberGoods();
|
||||
$result = $SerialClass->recordSerialList($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
/*
|
||||
* ***************************************门店模块***********************************
|
||||
*/
|
||||
//门店报损列表
|
||||
public function StoreLossReportList()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['operator_type'] = 3;
|
||||
$data['user_type'] = 4;
|
||||
$data['merchant_id'] = $data['merchantid'];
|
||||
$data['store_id'] = $data['storeid'];
|
||||
$LossClass = new LossReport();
|
||||
$result = $LossClass->orderList($data);
|
||||
$result['data'] = $result['data']['list'];
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
//门店商品列表已作废
|
||||
public function StoreLossGoodsList()
|
||||
{
|
||||
$content = I("post.");
|
||||
$merchant_id = $content['merchantid'];
|
||||
$store_id = $content['storeid'];
|
||||
$page = $content['page'];
|
||||
$limit = $content['limit'];
|
||||
$notInIds = $content['notInIds'];
|
||||
$status = $content['status'];
|
||||
$stock_status = $content['stock_status'];
|
||||
$searchText = $content['searchText'];
|
||||
$person1 = $content['person1'];
|
||||
$person2 = $content['person2'];
|
||||
$person3 = $content['person3'];
|
||||
if (!empty($searchText)) {
|
||||
$where['goods_name|sku_name|goods_code|sku_code|goods_number|sku_goods_number'] = array('like', '%' . $searchText . '%');
|
||||
}
|
||||
if (!empty($stock_status)) {
|
||||
switch ($stock_status) {
|
||||
case 1:
|
||||
$where['_string'] = 'goods_num <= less_num';
|
||||
break;
|
||||
case 2:
|
||||
$where['_string'] = 'goods_num >= more_num';
|
||||
break;
|
||||
case 3:
|
||||
$where['_string'] = 'goods_num <= 0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
if (!empty($notInIds)) {
|
||||
$where['id'] = array('not in', $notInIds);
|
||||
}
|
||||
$where['merchant_id'] = $merchant_id;
|
||||
$where['store_id'] = $store_id;
|
||||
$where['status'] = array('in', '0,1');
|
||||
if ($status != '') {
|
||||
$where['status'] = $status;
|
||||
}
|
||||
//商品列表
|
||||
$info = D('SSaleMGoods')->getSelect($where, $page, $limit, $field = '', $order = "id desc");
|
||||
if ($info) {
|
||||
foreach ($info as $key => &$value) {
|
||||
$value['loss_num'] = "";
|
||||
$value['goods_num'] = round($value['goods_num'], 3);
|
||||
$value['cost_price'] = round($value['cost_price'], 2);
|
||||
}
|
||||
}
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '查询成功';
|
||||
$res['data'] = $info;
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店报损提交
|
||||
*/
|
||||
public function StoreLossOperation()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['merchant_id'] = $data['merchantid'];
|
||||
$data['store_id'] = $data['storeid'];
|
||||
$result = A('Api/Inventory')->StoreReportSub($data);
|
||||
if ($result['status'] == 1) {
|
||||
$log_data = array(
|
||||
'source' => 1,
|
||||
'type' => 4,
|
||||
'desc' => '报损管理-新增',
|
||||
'request_data' => json_encode($_POST),
|
||||
'operator_id' => $_POST['operator_id'],
|
||||
'mer_id' => $_POST['storeid']
|
||||
);
|
||||
action_log_v2($log_data);
|
||||
}
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//门店报损详情
|
||||
public function StoreLossInfo()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['user_type'] = 4;
|
||||
$LossClass = new LossReport();
|
||||
$result = $LossClass->orderGoodsList($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
|
||||
//门店报损详情的串号列表
|
||||
public function storeLossInfoSerial()
|
||||
{
|
||||
$data = I('post.');
|
||||
$data['user_type'] = 4;
|
||||
$data['serial_type'] = 1;
|
||||
$SerialClass = new SerialNumberGoods();
|
||||
$result = $SerialClass->recordSerialList($data);
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户