|
@@ -359,34 +359,13 @@ class FyySqlServerService extends Service
|
|
|
//销售出库单保存接口给以及审核
|
|
|
public function U8Rdrecord32Save($data,$bredvouch = 0){
|
|
|
if(! empty($this->error)) return [false,$this->error];
|
|
|
- date_default_timezone_set("PRC");
|
|
|
-
|
|
|
- //通过销售订单号 获取发货单的数据
|
|
|
- $out_order_no = array_unique(array_column($data,'out_order_no'));
|
|
|
- $return = $this->getDataFromDispatchList($out_order_no);
|
|
|
- if(empty($return)) return [false,'没有找到发货单!'];
|
|
|
-
|
|
|
- //组织发货单的数据
|
|
|
- $map = [];
|
|
|
- foreach ($return as $value){
|
|
|
- $map[$value['cSOCode']][] = $value;
|
|
|
- }
|
|
|
|
|
|
- $detail = [];
|
|
|
+ $new = [];
|
|
|
foreach ($data as $value){
|
|
|
- if(! isset($map[$value['out_order_no']])) return [false,'包装单的销售订单号:' . $value['out_order_no'] .'没有找到发货单!'];
|
|
|
- $is_flag = 0;
|
|
|
- foreach ($map[$value['out_order_no']] as $m){
|
|
|
- if($value['product_no'] == $m['cinvcode'] && $value['technology_name'] == $m['cfree1'] && $value['wood_name'] == $m['cfree2']) {
|
|
|
- $is_flag = 1;
|
|
|
- $m['iquantity'] = $value['num'];
|
|
|
- $detail[$m['cSOCode']][] = $m;
|
|
|
- }
|
|
|
- }
|
|
|
- if(! $is_flag) return [false,'包装单的产品:' . $value['product_no'] . $value['technology_name'] . $value['wood_name'] . '在发货单中不存在!'];
|
|
|
+ $new[$value['id']][] = $value;
|
|
|
}
|
|
|
|
|
|
- foreach ($detail as $value){
|
|
|
+ foreach ($new as $value){
|
|
|
$main_tmp = $value[0];
|
|
|
foreach ($value as $val){
|
|
|
$bodys_tmp[] = [
|
|
@@ -395,13 +374,13 @@ class FyySqlServerService extends Service
|
|
|
"dlrowno"=>"",
|
|
|
"cbdlcode"=>"",
|
|
|
"cinvcode"=>$val['cinvcode'],
|
|
|
- "cposition"=>$val['cposition'],
|
|
|
- "cbatch"=>$val['cbatch'],
|
|
|
+ "cposition"=>$val['cposition'] ?? "",
|
|
|
+ "cbatch"=>$val['cbatch'] ?? "",
|
|
|
"iquantity"=>$val['iquantity'],
|
|
|
- "inum"=>$val['iquantity'],
|
|
|
- "iinvexchrate"=>$value['iinvexchrate'],
|
|
|
- "iunitcost"=>"",
|
|
|
- "iprice"=>"",
|
|
|
+ "inum"=>$val['inum'],
|
|
|
+ "iinvexchrate"=> $val['iinvexchrate'] ?? 0,
|
|
|
+ "iunitcost"=>$val['iunitcost'],
|
|
|
+ "iprice"=>$val['imoney'],
|
|
|
"cbmemo"=>"",
|
|
|
];
|
|
|
}
|
|
@@ -423,9 +402,9 @@ class FyySqlServerService extends Service
|
|
|
"dnmaketime"=> date("Y-m-d"),
|
|
|
"IsExamine"=>true,
|
|
|
"bredvouch"=> $bredvouch,
|
|
|
- "cwhcode"=>"02",
|
|
|
- "cdepcode"=>"06",
|
|
|
- "crdcode"=>"102",
|
|
|
+ "cwhcode"=>$main_tmp['cwhcode'],
|
|
|
+ "cdepcode"=>$main_tmp['cdepcode'],
|
|
|
+ "crdcode"=>'',
|
|
|
"cmemo"=> '',
|
|
|
"cdefine10" => $main_tmp['customer_name'], //客户名称
|
|
|
"bodys"=>$bodys_tmp
|
|
@@ -544,7 +523,7 @@ class FyySqlServerService extends Service
|
|
|
->leftJoin('DispatchLists as b','b.DLID','a.DLID')
|
|
|
->where('a.cSOcode',$order_number)
|
|
|
->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
|
|
|
- ->select('a.cDefine10 as customer_name','a.cSOCode','a.cDepCode','b.iDLsID as idlsid','b.cWhCode as cwhcode','b.cInvCode as cinvcode','b.cInvName as product_title','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity')
|
|
|
+ ->select('a.DLID as id','a.cDefine10 as customer_name','a.cSOCode','a.cDepCode as cdepcode','b.iDLsID as idlsid','b.cWhCode as cwhcode','b.cInvCode as cinvcode','b.cInvName as product_title','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity','b.iUnitPrice as iunitcost','b.iMoney as imoney')
|
|
|
->get()->toArray();
|
|
|
if(! empty($message)){
|
|
|
foreach ($message as $key => $value){
|