|
@@ -106,35 +106,45 @@ class FinancialManager extends Base{
|
|
|
public function OrderImport($data){
|
|
|
|
|
|
$data['total_num'] = $data['balance_num'] =$data['inv_num'];
|
|
|
- self::startTrans();
|
|
|
- try{
|
|
|
- if($data['inv_num']==0) throw new \Exception('发票商品数量不能为0');
|
|
|
- if($data['type']==1){
|
|
|
- $product= $this->inProduct($data);
|
|
|
- $data['error_remark'] = $data['balance_num']!='0'?'入库数量不正确':'';
|
|
|
- }
|
|
|
- if($data['type']==2){
|
|
|
- $product= $this->outProduct($data);
|
|
|
- $data['error_remark'] = $data['balance_num']!='0'?'出库数量不正确':'';
|
|
|
- }
|
|
|
- if($data['balance_num']!=$data['total_num'] && $data['balance_num']!='0') throw new \Exception($data['error_remark']);
|
|
|
- $data['status']=$data['balance_num']==$data['total_num']?1:2;
|
|
|
- self::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- self::rollback();
|
|
|
- if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
- $temp=[];
|
|
|
- $temp['product_id']=$item['id'];
|
|
|
- $temp['type']=$data['type'];
|
|
|
- $temp['num']=$item['num'];
|
|
|
- $temp['apply_id'] = $data['apply_id'];
|
|
|
- $temp['apply_name'] = $data['apply_name'];
|
|
|
- $temp['status'] = 0;
|
|
|
- return $temp;
|
|
|
- },$data['idArr']);
|
|
|
- $data['status'] =4;
|
|
|
- $data['error_remark'] = $e->getMessage();
|
|
|
- }
|
|
|
+ if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
+ $temp=[];
|
|
|
+ $temp['product_id']=$item['id'];
|
|
|
+ $temp['type']=$data['type'];
|
|
|
+ $temp['num']=$item['num'];
|
|
|
+ $temp['apply_id'] = $data['apply_id'];
|
|
|
+ $temp['apply_name'] = $data['apply_name'];
|
|
|
+ $temp['status'] = 0;
|
|
|
+ return $temp;
|
|
|
+ },$data['idArr']);
|
|
|
+// self::startTrans();
|
|
|
+// try{
|
|
|
+// if($data['inv_num']==0) throw new \Exception('发票商品数量不能为0');
|
|
|
+// if($data['type']==1){
|
|
|
+// $product= $this->inProduct($data);
|
|
|
+// $data['error_remark'] = $data['balance_num']!='0'?'入库数量不正确':'';
|
|
|
+// }
|
|
|
+// if($data['type']==2){
|
|
|
+// $product= $this->outProduct($data);
|
|
|
+// $data['error_remark'] = $data['balance_num']!='0'?'出库数量不正确':'';
|
|
|
+// }
|
|
|
+// if($data['balance_num']!=$data['total_num'] && $data['balance_num']!='0') throw new \Exception($data['error_remark']);
|
|
|
+// $data['status']=$data['balance_num']==$data['total_num']?1:2;
|
|
|
+// self::commit();
|
|
|
+// }catch (\Exception $e){
|
|
|
+// self::rollback();
|
|
|
+// if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
+// $temp=[];
|
|
|
+// $temp['product_id']=$item['id'];
|
|
|
+// $temp['type']=$data['type'];
|
|
|
+// $temp['num']=$item['num'];
|
|
|
+// $temp['apply_id'] = $data['apply_id'];
|
|
|
+// $temp['apply_name'] = $data['apply_name'];
|
|
|
+// $temp['status'] = 0;
|
|
|
+// return $temp;
|
|
|
+// },$data['idArr']);
|
|
|
+// $data['status'] =4;
|
|
|
+// $data['error_remark'] = $e->getMessage();
|
|
|
+// }
|
|
|
$info=$this->create($data);
|
|
|
if($info->isEmpty()) throw new \Exception('添加失败');
|
|
|
if (isset($product)) ManagerProduct::AddProduct($info->id,$product);
|
|
@@ -305,34 +315,44 @@ class FinancialManager extends Base{
|
|
|
public function OfflineImport($data){
|
|
|
$data['total_num'] = $data['balance_num'] =$data['relaArr'][0]['num'];
|
|
|
if($data['orderCode']=="")$data['orderCode']=makeNo("PQR");
|
|
|
- self::startTrans();
|
|
|
- try{
|
|
|
- if($data['type']==1){
|
|
|
- $product=$this->inProduct($data);
|
|
|
- $data['error_remark'] = $data['balance_num']!='0'?'入库数量不正确':'';
|
|
|
- }
|
|
|
- if($data['type']==2){
|
|
|
- $product=$this->outProduct($data);
|
|
|
- $data['error_remark'] = $data['balance_num']!='0'?'出库数量不正确':'';
|
|
|
- }
|
|
|
- if($data['balance_num']!=$data['total_num'] && $data['balance_num']!='0') throw new \Exception($data['error_remark']);
|
|
|
- $data['status']=$data['balance_num']==$data['total_num']?1:2;
|
|
|
- self::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- self::rollback();
|
|
|
- if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
- $temp=[];
|
|
|
- $temp['product_id']=$item['id'];
|
|
|
- $temp['type']=$data['type'];
|
|
|
- $temp['num']=$item['num'];
|
|
|
- $temp['apply_id'] = $data['apply_id'];
|
|
|
- $temp['apply_name'] = $data['apply_name'];
|
|
|
- $temp['status'] = 0;
|
|
|
- return $temp;
|
|
|
- },$data['idArr']);
|
|
|
- $data['status'] =4;
|
|
|
- $data['error_remark'] = $e->getMessage();
|
|
|
- }
|
|
|
+ if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
+ $temp=[];
|
|
|
+ $temp['product_id']=$item['id'];
|
|
|
+ $temp['type']=$data['type'];
|
|
|
+ $temp['num']=$item['num'];
|
|
|
+ $temp['apply_id'] = $data['apply_id'];
|
|
|
+ $temp['apply_name'] = $data['apply_name'];
|
|
|
+ $temp['status'] = 0;
|
|
|
+ return $temp;
|
|
|
+ },$data['idArr']);
|
|
|
+// self::startTrans();
|
|
|
+// try{
|
|
|
+// if($data['type']==1){
|
|
|
+// $product=$this->inProduct($data);
|
|
|
+// $data['error_remark'] = $data['balance_num']!='0'?'入库数量不正确':'';
|
|
|
+// }
|
|
|
+// if($data['type']==2){
|
|
|
+// $product=$this->outProduct($data);
|
|
|
+// $data['error_remark'] = $data['balance_num']!='0'?'出库数量不正确':'';
|
|
|
+// }
|
|
|
+// if($data['balance_num']!=$data['total_num'] && $data['balance_num']!='0') throw new \Exception($data['error_remark']);
|
|
|
+// $data['status']=$data['balance_num']==$data['total_num']?1:2;
|
|
|
+// self::commit();
|
|
|
+// }catch (\Exception $e){
|
|
|
+// self::rollback();
|
|
|
+// if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
+// $temp=[];
|
|
|
+// $temp['product_id']=$item['id'];
|
|
|
+// $temp['type']=$data['type'];
|
|
|
+// $temp['num']=$item['num'];
|
|
|
+// $temp['apply_id'] = $data['apply_id'];
|
|
|
+// $temp['apply_name'] = $data['apply_name'];
|
|
|
+// $temp['status'] = 0;
|
|
|
+// return $temp;
|
|
|
+// },$data['idArr']);
|
|
|
+// $data['status'] =4;
|
|
|
+// $data['error_remark'] = $e->getMessage();
|
|
|
+// }
|
|
|
$info=$this->create($data);
|
|
|
if($info->isEmpty()) throw new \Exception('添加失败');
|
|
|
if(isset($product) && !empty($product))ManagerProduct::AddProduct($info->id,$product);
|
|
@@ -341,34 +361,44 @@ class FinancialManager extends Base{
|
|
|
public function CImport($data){
|
|
|
|
|
|
$data['total_num'] = $data['balance_num'] =$data['num'];
|
|
|
- self::startTrans();
|
|
|
- try{
|
|
|
- if($data['type']==1){
|
|
|
- $product=$this->inProduct($data);
|
|
|
- $data['error_remark'] = $data['balance_num']!='0'?'入库数量不正确':'';
|
|
|
- }
|
|
|
- if($data['type']==2){
|
|
|
- $product=$this->outProduct($data);
|
|
|
- $data['error_remark'] = $data['balance_num']!='0'?'出库数量不正确':'';
|
|
|
- }
|
|
|
- if($data['balance_num']!=$data['total_num'] && $data['balance_num']!='0') throw new \Exception($data['error_remark']);
|
|
|
- $data['status']=$data['balance_num']==$data['total_num']?1:2;
|
|
|
- self::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- self::rollback();
|
|
|
- if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
- $temp=[];
|
|
|
- $temp['product_id']=$item['id'];
|
|
|
- $temp['type']=$data['type'];
|
|
|
- $temp['num']=$item['num'];
|
|
|
- $temp['apply_id'] = $data['apply_id'];
|
|
|
- $temp['apply_name'] = $data['apply_name'];
|
|
|
- $temp['status'] = 0;
|
|
|
- return $temp;
|
|
|
- },$data['idArr']);
|
|
|
- $data['status'] =4;
|
|
|
- $data['error_remark'] = $e->getMessage();
|
|
|
- }
|
|
|
+ if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
+ $temp=[];
|
|
|
+ $temp['product_id']=$item['id'];
|
|
|
+ $temp['type']=$data['type'];
|
|
|
+ $temp['num']=$item['num'];
|
|
|
+ $temp['apply_id'] = $data['apply_id'];
|
|
|
+ $temp['apply_name'] = $data['apply_name'];
|
|
|
+ $temp['status'] = 0;
|
|
|
+ return $temp;
|
|
|
+ },$data['idArr']);
|
|
|
+// self::startTrans();
|
|
|
+// try{
|
|
|
+// if($data['type']==1){
|
|
|
+// $product=$this->inProduct($data);
|
|
|
+// $data['error_remark'] = $data['balance_num']!='0'?'入库数量不正确':'';
|
|
|
+// }
|
|
|
+// if($data['type']==2){
|
|
|
+// $product=$this->outProduct($data);
|
|
|
+// $data['error_remark'] = $data['balance_num']!='0'?'出库数量不正确':'';
|
|
|
+// }
|
|
|
+// if($data['balance_num']!=$data['total_num'] && $data['balance_num']!='0') throw new \Exception($data['error_remark']);
|
|
|
+// $data['status']=$data['balance_num']==$data['total_num']?1:2;
|
|
|
+// self::commit();
|
|
|
+// }catch (\Exception $e){
|
|
|
+// self::rollback();
|
|
|
+// if(!empty($data['idArr'])) $product=array_map(function ($item) use($data){
|
|
|
+// $temp=[];
|
|
|
+// $temp['product_id']=$item['id'];
|
|
|
+// $temp['type']=$data['type'];
|
|
|
+// $temp['num']=$item['num'];
|
|
|
+// $temp['apply_id'] = $data['apply_id'];
|
|
|
+// $temp['apply_name'] = $data['apply_name'];
|
|
|
+// $temp['status'] = 0;
|
|
|
+// return $temp;
|
|
|
+// },$data['idArr']);
|
|
|
+// $data['status'] =4;
|
|
|
+// $data['error_remark'] = $e->getMessage();
|
|
|
+// }
|
|
|
$info=$this->create($data);
|
|
|
if($info->isEmpty()) throw new \Exception('添加失败');
|
|
|
if(isset($product) && !empty($product))ManagerProduct::AddProduct($info->id,$product);
|