|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
+use App\Model\BoxDetail;
|
|
|
use App\Model\Orders;
|
|
|
use App\Model\SaleOrdersProduct;
|
|
|
use Illuminate\Support\Facades\Config;
|
|
@@ -177,7 +178,7 @@ class FyySqlServerService extends Service
|
|
|
$model->whereBetween('a.dverifydate',[$start1, $end1]);
|
|
|
}
|
|
|
|
|
|
- $result = $model->get()->toArray();dump($result);die;
|
|
|
+ $result = $model->get()->toArray();
|
|
|
if(empty($result)) return [false,'暂无数据,更新结束!',''];
|
|
|
list($status,$msg) = $this->orderRule($result);
|
|
|
if(empty($msg)) return [false,'暂无数据,更新结束!',''];
|
|
@@ -357,76 +358,109 @@ class FyySqlServerService extends Service
|
|
|
if(! empty($this->error)) return [false,$this->error];
|
|
|
date_default_timezone_set("PRC");
|
|
|
|
|
|
- $return = $this->getDataFromDispatchList($data);
|
|
|
- if(empty($return)) return [false,'根据销售订单号:'. $data['order_number'] . '未找到发货单数据!'];
|
|
|
+ //获取包装单内数据
|
|
|
+ $box = $this->getBoxData($data);
|
|
|
+ if(empty($box)) return [false,'包装单不能为空!'];
|
|
|
|
|
|
- $main = $return[0];
|
|
|
- if($bredvouch){
|
|
|
- $cmemo = '备注一';
|
|
|
- }else{
|
|
|
- $cmemo = '销售单号:'.$main['out_order'];
|
|
|
- }
|
|
|
+ //获取发货单的数据
|
|
|
+ $return = $this->getDataFromDispatchList(array_column($box,'cSOCode'));
|
|
|
+ if(empty($return)) return [false,'没有找到发货单!'];
|
|
|
|
|
|
- //数据
|
|
|
- $bodys = [];
|
|
|
+ //组织发货单的数据
|
|
|
+ $map = [];
|
|
|
foreach ($return as $value){
|
|
|
- $bodys[] = [
|
|
|
- "idlsid"=>$value['idlsid'],
|
|
|
- "cdlcode"=>"",
|
|
|
- "dlrowno"=>"",
|
|
|
- "cbdlcode"=>"",
|
|
|
- "cinvcode"=>$value['cinvcode'],
|
|
|
- "cposition"=>$value['cposition'],
|
|
|
- "cbatch"=>$value['cbatch'],
|
|
|
- "iquantity"=>$value['iquantity'],
|
|
|
- "inum"=>$value['inum'],
|
|
|
- "iinvexchrate"=>$value['iinvexchrate'],
|
|
|
- "iunitcost"=>"",
|
|
|
- "iprice"=>"",
|
|
|
- "cbmemo"=>"",
|
|
|
+ $map[$value['cSOCode']][] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ $detail = [];
|
|
|
+ foreach ($box as $value){
|
|
|
+ if(! isset($map[$value['cSOCode']])) {
|
|
|
+ return [false,'包装单内销售订单号:' . $value['cSOCode'] .'没有找到发货单!'];
|
|
|
+ }
|
|
|
+ $is_flag = 0;
|
|
|
+ foreach ($map[$value['cSOCode']] as $m){
|
|
|
+ if($value['cinvcode'] == $m['cinvcode'] && $value['cfree1'] == $m['cfree1'] && $value['cfree2'] == $m['cfree2']) {
|
|
|
+ $is_flag = 1;
|
|
|
+ $m['iquantity'] = $value['iquantity'];
|
|
|
+ $detail[$m['cSOCode']][] = $m;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(! $is_flag) return [false,'包装单内销售订单号:' . $value['cSOCode'] .'产品:' . $value['cinvcode'] . $value['cfree1'] . $value['cfree2'] . '在发货单中不存在!'];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($detail as $value){
|
|
|
+ $main_tmp = $value[0];
|
|
|
+ foreach ($value as $val){
|
|
|
+ $bodys_tmp[] = [
|
|
|
+ "idlsid"=>$val['idlsid'],
|
|
|
+ "cdlcode"=>"",
|
|
|
+ "dlrowno"=>"",
|
|
|
+ "cbdlcode"=>"",
|
|
|
+ "cinvcode"=>$val['cinvcode'],
|
|
|
+ "cposition"=>$val['cposition'],
|
|
|
+ "cbatch"=>$val['cbatch'],
|
|
|
+ "iquantity"=>$val['iquantity'],
|
|
|
+ "inum"=>$val['iquantity'],
|
|
|
+ "iinvexchrate"=>$value['iinvexchrate'],
|
|
|
+ "iunitcost"=>"",
|
|
|
+ "iprice"=>"",
|
|
|
+ "cbmemo"=>"",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $post_tmp = [
|
|
|
+ "password"=>"cloud@123456",
|
|
|
+ "entity"=>"U8Rdrecord32Save",
|
|
|
+ "login"=>[
|
|
|
+ "sAccID"=> "(default)@001",
|
|
|
+ "sDate"=> date("Y-m-d"),
|
|
|
+ "sServer"=> '127.0.0.1',
|
|
|
+ "sUserID"=> "董晓磊",
|
|
|
+ "sSerial"=> "",
|
|
|
+ "sPassword"=> ""
|
|
|
+ ],
|
|
|
+ "data"=>[
|
|
|
+ "ccode"=>'',
|
|
|
+ "ddate"=>date("Y-m-d"),
|
|
|
+ "cmaker"=>"董晓磊",
|
|
|
+ "dnmaketime"=> date("Y-m-d"),
|
|
|
+ "IsExamine"=>true,
|
|
|
+ "bredvouch"=> $bredvouch,
|
|
|
+ "cwhcode"=>"02",
|
|
|
+ "cdepcode"=>"06",
|
|
|
+ "crdcode"=>"102",
|
|
|
+ "cmemo"=> '',
|
|
|
+ "cdefine10" => $main_tmp['customer_name'], //客户名称
|
|
|
+ "bodys"=>$bodys_tmp
|
|
|
+ ]
|
|
|
];
|
|
|
+
|
|
|
+ $return = $this->post_helper($this->url,json_encode($post_tmp), ['Content-Type:application/json']);
|
|
|
+ if(! $return['flag']) return [false,$return['msg']];
|
|
|
}
|
|
|
- $post = [
|
|
|
- "password"=>"cloud@123456",
|
|
|
- "entity"=>"U8Rdrecord32Save",
|
|
|
- "login"=>[
|
|
|
- "sAccID"=> "(default)@001",
|
|
|
- "sDate"=> date("Y-m-d"),
|
|
|
- "sServer"=> '127.0.0.1',
|
|
|
- "sUserID"=> "董晓磊",
|
|
|
- "sSerial"=> "",
|
|
|
- "sPassword"=> ""
|
|
|
- ],
|
|
|
- "data"=>[
|
|
|
- "ccode"=>'',
|
|
|
- "ddate"=>date("Y-m-d"),
|
|
|
- "cmaker"=>"董晓磊",
|
|
|
- "dnmaketime"=> date("Y-m-d"),
|
|
|
- "IsExamine"=>true,
|
|
|
- "bredvouch"=> $bredvouch,
|
|
|
- "cwhcode"=>"02",
|
|
|
- "cdepcode"=>"06",
|
|
|
- "crdcode"=>"102",
|
|
|
- "cmemo"=> $cmemo,
|
|
|
- "cdefine10" => $main['customer_name'], //客户名称
|
|
|
- "bodys"=>$bodys
|
|
|
- ]
|
|
|
- ];
|
|
|
|
|
|
- $return = $this->post_helper($this->url,json_encode($post), ['Content-Type:application/json']);
|
|
|
- return [$return['flag'], $return['msg']];
|
|
|
+ return [true,''];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getBoxData($data){
|
|
|
+ $boxData = BoxDetail::from('box_detail as a')
|
|
|
+ ->leftJoin('sale_orders_product as b','b.id','a.top_id')
|
|
|
+ ->where('a.del_time',0)
|
|
|
+ ->where('a.order_no',$data['order_number']) //包装单号
|
|
|
+ ->select('a.num as iquantity','b.product_no as cinvcode','b.technology_name as cfree1','b.wood_name as cfree2','b.out_order_no as cSOCode');
|
|
|
+
|
|
|
+ return $boxData;
|
|
|
}
|
|
|
|
|
|
- public function getDataFromDispatchList($data){
|
|
|
+ public function getDataFromDispatchList($order_number){
|
|
|
$message = $this->db->table('DispatchList as a')
|
|
|
->leftJoin('DispatchLists as b','b.DLID','a.DLID')
|
|
|
- ->where('a.cSOcode',$data['order_number'])
|
|
|
- ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
|
|
|
- ->select('a.cDefine10 as customer_name','a.cSOCode as out_order','b.iDLsID as idlsid','b.cInvCode as cinvcode','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')
|
|
|
+ ->whereIn('a.cSOcode',$order_number)
|
|
|
+// ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
|
|
|
+ ->select('a.cDefine10 as customer_name','a.cSOCode','b.iDLsID as idlsid','b.cInvCode as cinvcode','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')
|
|
|
->get()->toArray();
|
|
|
if(! empty($message)){
|
|
|
foreach ($message as $key => $value){
|
|
|
- $message[$key]->iquantity = $value->iquantity - $value->out_quantity;
|
|
|
+// $message[$key]->iquantity = $value->iquantity - $value->out_quantity;
|
|
|
$message[$key] = (array)$value;
|
|
|
}
|
|
|
}
|