|
|
@@ -127,18 +127,23 @@ class Deliver extends Backend
|
|
|
if ($this->request->isAjax() === false){
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
- $lager_list = input('search');
|
|
|
+ $filter = input('filter');
|
|
|
+ $filter = json_decode($filter,true);
|
|
|
$order = input('order');
|
|
|
$offset = input('offset');
|
|
|
$limit = input('limit');
|
|
|
- $lagerList = explode(',',$lager_list);
|
|
|
+ $where = [
|
|
|
+ 'delete_time' => '',
|
|
|
+ ];
|
|
|
+ if (isset($filter['large_id'])){
|
|
|
+ $where['large_id'] =$filter['large_id'];
|
|
|
+ }
|
|
|
$smallList = $small->name($userinfo['company'].'_'.'qcode_small')
|
|
|
- ->whereIn('large_id',$lagerList)
|
|
|
-// ->order('l_flow',$order)
|
|
|
+ ->where($where)
|
|
|
->skip($offset)
|
|
|
->limit($limit)
|
|
|
->select();
|
|
|
- $total = $small->name($userinfo['company'].'_'.'qcode_small')->whereIn('large_id',$lagerList)->count();
|
|
|
+ $total = $small->name($userinfo['company'].'_'.'qcode_small')->where($where)->count();
|
|
|
$list = [];
|
|
|
foreach ($smallList as $k=>$v){
|
|
|
$list[$k] = [
|
|
|
@@ -189,53 +194,49 @@ class Deliver extends Backend
|
|
|
$bach_id = array_unique($bach_id);
|
|
|
$data = [];
|
|
|
foreach ($bach_id as $k=>$v){
|
|
|
- $m = 1;$n =0;
|
|
|
- $large_str = '';
|
|
|
- foreach ($lagerId as $key=>$value){
|
|
|
- $lagerList = $lager->name($userinfo['company'].'_'.'qcode_large')->where('_id',$value)->find();
|
|
|
- if($v === $lagerList['bach_id']){
|
|
|
- $m++;
|
|
|
- $large_str = $large_str.substr(json_encode($lagerList['_id']),9,-2).',';
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- $large_str = substr($large_str,0,strlen($large_str)-1);
|
|
|
- foreach (explode(',',$large_str) as $kk=>$vv){
|
|
|
- $n = $n + $small->name($userinfo['company'].'_'.'qcode_small')->where('large_id',$vv)->count();
|
|
|
- }
|
|
|
- $bachDetail = $bach->name($userinfo['company'].'_'.'qcode_bach')->where('_id',$v)->find();
|
|
|
- if ($bachDetail['box_num'] === 1){
|
|
|
- $mater_type = 2;
|
|
|
- }else{
|
|
|
- $mater_type = 1;
|
|
|
- }
|
|
|
- $exportData = $this->exportdata($v,$large_str,$userinfo['company'],$m,$n);
|
|
|
- $file_dir = $this->exportExcel($exportData);
|
|
|
- $data[$k] = [
|
|
|
- 'username' => $bachDetail['supplier_name'],
|
|
|
- 'matter_name' => $bachDetail['matter_name'],
|
|
|
- 'matter_no' => $bachDetail['matter_no'],
|
|
|
- 'large_str' => $large_str,
|
|
|
- 'large_num' => $lager_num,
|
|
|
- 'small_num' => $n,
|
|
|
- 'status' => 0,
|
|
|
- 'num' => $bachDetail['s_weight'],
|
|
|
- 'bach_num' => $bachDetail['bach_num'],
|
|
|
- 'mater_type' => $mater_type,
|
|
|
- 'note' => '',
|
|
|
- 'user_id' => $userinfo['id'],
|
|
|
- 'create_time' => time(),
|
|
|
- 'file_dir' => $file_dir,
|
|
|
- 'company_id' => $userinfo['company'],
|
|
|
- ];
|
|
|
- $res = $export->save($data[$k]);
|
|
|
- if ($res === false){
|
|
|
- $this->error('发货失败');
|
|
|
- }
|
|
|
- $lager = new QcodeLarge();
|
|
|
- $lager->name($userinfo['company'].'_'.'qcode_large')->where('bach_id',$v)->whereIn('_id',$lagerId)->update(['l_status'=>1]);
|
|
|
+ $data[$k] = $bach->name($userinfo['company'].'_'.'qcode_bach')->where('_id',$v)->field('matter_no')->find()['matter_no'];
|
|
|
}
|
|
|
- $this->success('成功');
|
|
|
+ $data = array_unique($data);
|
|
|
+ if (count($data)>1){
|
|
|
+ $this->error('请选择同一产品');
|
|
|
+ }
|
|
|
+ $n =0;
|
|
|
+ foreach (explode(',',$lager_id) as $kk=>$vv){
|
|
|
+ $n = $n + $small->name($userinfo['company'].'_'.'qcode_small')->where('large_id',$vv)->count();
|
|
|
+ }
|
|
|
+ $bachDetail = $bach->name($userinfo['company'].'_'.'qcode_bach')->where('_id',$bach_id[0])->find();
|
|
|
+ if ($bachDetail['box_num'] === 1){
|
|
|
+ $mater_type = 2;
|
|
|
+ }else{
|
|
|
+ $mater_type = 1;
|
|
|
+ }
|
|
|
+ $exportData = $this->exportdata($bach_id,$lager_id,$userinfo['company'],$lager_num,$n);
|
|
|
+ $file_dir = $this->exportExcel($exportData);
|
|
|
+ $row = [
|
|
|
+ 'username' => $bachDetail['supplier_name'],
|
|
|
+ 'matter_name' => $bachDetail['matter_name'],
|
|
|
+ 'matter_no' => $bachDetail['matter_no'],
|
|
|
+ 'large_str' => $lager_id,
|
|
|
+ 'large_num' => $lager_num,
|
|
|
+ 'small_num' => $n,
|
|
|
+ 'status' => 0,
|
|
|
+ 'num' => $bachDetail['s_weight'],
|
|
|
+ 'bach_num' => $bachDetail['bach_num'],
|
|
|
+ 'mater_type' => $mater_type,
|
|
|
+ 'note' => '',
|
|
|
+ 'user_id' => $userinfo['id'],
|
|
|
+ 'create_time' => time(),
|
|
|
+ 'file_dir' => $file_dir,
|
|
|
+ 'company_id' => $userinfo['company'],
|
|
|
+ ];
|
|
|
+ $res = $export->save($row);
|
|
|
+ if ($res === false){
|
|
|
+ $this->error('发货失败');
|
|
|
+ }
|
|
|
+ $lager = new QcodeLarge();
|
|
|
+ $lager->name($userinfo['company'].'_'.'qcode_large')->whereIn('_id',$lagerId)->update(['l_status'=>1]);
|
|
|
+
|
|
|
+ $this->success('成功','',$file_dir);
|
|
|
}
|
|
|
/**
|
|
|
* 表格数据处理
|
|
|
@@ -254,7 +255,7 @@ class Deliver extends Backend
|
|
|
$bach = new QcodeBach();
|
|
|
$large = new QcodeLarge();
|
|
|
$small = new QcodeSmall();
|
|
|
- $bachList = $bach->name($company . '_' . 'qcode_bach')->where('_id', $bach_id)->find();
|
|
|
+ $bachList = $bach->name($company . '_' . 'qcode_bach')->where('_id', $bach_id[0])->find();
|
|
|
$data = [
|
|
|
'supplier_name' => $bachList['supplier_name'],
|
|
|
'supplier_no' => $bachList['supplier_code'],
|
|
|
@@ -365,7 +366,7 @@ class Deliver extends Backend
|
|
|
}
|
|
|
$writer = IOFactory::createWriter($objexcel, 'Xlsx');
|
|
|
$writer->save(ROOT_PATH.'public/uploads/export/'.$filename);
|
|
|
- return 'public/uploads/export/'.$filename;
|
|
|
+ return 'uploads/export/'.$filename;
|
|
|
}
|
|
|
|
|
|
/**
|