|
|
@@ -10,6 +10,7 @@ use App\OrderBarcode;
|
|
|
use App\RejectedBill;
|
|
|
use App\RejectedBillItem;
|
|
|
use App\SkuNew;
|
|
|
+use App\Store;
|
|
|
use App\WMSReflectReceive;
|
|
|
use App\WMSReflectReceiveSku;
|
|
|
use Illuminate\Http\Request;
|
|
|
@@ -27,7 +28,7 @@ class ReceiveController extends Controller
|
|
|
{
|
|
|
$errors=$this->validatorForNew($request->all())->errors();
|
|
|
if(count($errors)>0){
|
|
|
- $this->log(__METHOD__, 'error' . __FUNCTION__, json_encode($request->all()));
|
|
|
+ $this->log(__METHOD__, 'error_body' . __FUNCTION__, json_encode($request->getContent()));
|
|
|
(new Controller())->log(__METHOD__,'error_'.__FUNCTION__,'fields wrong, see Errors report please.'.'|'.json_encode($request).'|'.json_encode($errors));
|
|
|
return response()->json(['response'=>['flag'=>'W','message'=>'fields wrong, see Errors report please.',
|
|
|
'errors'=>$errors]])
|
|
|
@@ -62,7 +63,7 @@ class ReceiveController extends Controller
|
|
|
'request.*.WAREHOUSEID' => ['required', 'string', 'max:191'],
|
|
|
'request.*.CUSTOMERID' => ['required', 'string', 'max:191'],
|
|
|
'request.*.ASNTYPE' => ['nullable', 'string', 'max:191'],
|
|
|
- 'request.*.ASNREFERENCE1' => ['required', 'string', 'max:191'],
|
|
|
+ 'request.*.ASNREFERENCE1' => ['nullable', 'string', 'max:191'],
|
|
|
'request.*.ASNREFERENCE2' => ['nullable', 'string', 'max:191'],
|
|
|
'request.*.ASNREFERENCE3' => ['required', 'string', 'max:191'],
|
|
|
'request.*.ASNSTATUS' => ['nullable', 'string', 'max:191'],
|
|
|
@@ -257,4 +258,151 @@ class ReceiveController extends Controller
|
|
|
|
|
|
return $success;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 入库回传给WMS
|
|
|
+ * @param RejectedBill $rejectedBill
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ static public function accomplishStoreToWMS(Store $store)
|
|
|
+ {
|
|
|
+// $bill=$rejectedBill;
|
|
|
+// $wmsReceiveds=WMSReflectReceive::where('ASNREFERENCE3',$rejectedBill['logistic_number_return'])
|
|
|
+// ->where('is_uploaded',0)->get();
|
|
|
+// if($wmsReceiveds->isEmpty()){
|
|
|
+// (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,'没有WMS入库单');
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// $items=$bill->items()->get();
|
|
|
+// $amountsItem=(function()use($items){
|
|
|
+// $result=[];
|
|
|
+// $items->each(function($item)use(&$result){
|
|
|
+// $result[$item['id']]= $item['amount'];
|
|
|
+// });
|
|
|
+// return $result;
|
|
|
+// })();
|
|
|
+// $success=true;
|
|
|
+// $wmsReceiveds->each(function ($wmsReceived)use(&$bill,&$amountsItem,$items,&$success){
|
|
|
+// if(!$bill && $bill['is_loaded']!=0)return;
|
|
|
+//
|
|
|
+// $wmsSkus=$wmsReceived->skus()->get();
|
|
|
+// $orderNumberCode=$wmsReceived['ASNREFERENCE1']??$bill['order_number'];
|
|
|
+// $amountsSku=(function()use($wmsSkus){
|
|
|
+// $result=[];
|
|
|
+// $wmsSkus->each(function($sku)use(&$result){
|
|
|
+// $result[$sku['id']]= $sku['EXPECTEDQTY_EACH'];
|
|
|
+// });
|
|
|
+// return $result;
|
|
|
+// })();
|
|
|
+// $skuStrList=[];
|
|
|
+// $customerCode=$bill->owner()->first()['code'];
|
|
|
+// $wmsSkus->each(function(WMSReflectReceiveSku $sku)use(&$items,&$skuList,&$amountsItem,&$amountsSku,&$skuStrList,$wmsReceived,$customerCode){
|
|
|
+// $items->each(function(RejectedBillItem $item)use(&$sku,&$amountsItem,&$amountsSku,&$skuStrList,$wmsReceived,$customerCode){
|
|
|
+// if($item['barcode_goods']!=$sku['ALTERNATE_SKU1'])return;
|
|
|
+// if($amountsItem[$item['id']]==0||$amountsSku[$sku['id']]==0)return;
|
|
|
+// $uploadingAmount=(function()use(&$item,&$sku,&$amountsItem,&$amountsSku){
|
|
|
+// if($amountsItem[$item['id']]>$amountsSku[$sku['id']]){
|
|
|
+// $amountsItem[$item['id']]-=$amountsSku[$sku['id']];
|
|
|
+// $amount= $amountsSku[$sku['id']];
|
|
|
+// $amountsSku[$sku['id']]=0;
|
|
|
+// return $amount;
|
|
|
+// }
|
|
|
+// if($amountsItem[$item['id']]<$amountsSku[$sku['id']]){
|
|
|
+// $amount=$amountsItem[$item['id']];
|
|
|
+// $amountsSku[$sku['id']]-=$amount;
|
|
|
+// $amountsItem[$item['id']]=0;
|
|
|
+// return $amount;
|
|
|
+// }
|
|
|
+// $amount=$amountsItem[$item['id']];
|
|
|
+// $amountsItem[$item['id']]=0;
|
|
|
+// $amountsSku[$sku['id']]=0;
|
|
|
+// return $amount;
|
|
|
+// })();
|
|
|
+// if($item['is_loaded']=='已入库'){return;}
|
|
|
+// $STATUS=$item['id_quality_label']==1?'ZP':'CC';
|
|
|
+// $STATUS_code=$item['id_quality_label']==1?'01':'02';
|
|
|
+// $skuStr="
|
|
|
+// {
|
|
|
+// \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
|
|
|
+// \"ASNLINENO\": \"{$sku['ASNLINENO']}\",
|
|
|
+// \"SKUCODE\": \"{$sku['SKU']}\",
|
|
|
+// \"QUANTITY\": \"{$uploadingAmount}\",
|
|
|
+// \"LOTATT04\": \"{$sku['LOTATT04']}\",
|
|
|
+// \"LOTATT05\": \"{$sku['LOTATT05']}\",
|
|
|
+// \"STATUS\": \"{$STATUS}\",
|
|
|
+// \"PRODUCTION DATE\": \"{$item['made_at']}\",
|
|
|
+// \"EXPIRATION DATE\": \"{$item['validity_at']}\",
|
|
|
+// \"USERDEFINE1\": \"{$customerCode}{$STATUS_code}\",
|
|
|
+// \"USERDEFINE2\": \"\",
|
|
|
+// \"USERDEFINE3\": \"\",
|
|
|
+// \"UNIQUE_CODE_LIST\": [".
|
|
|
+//// {
|
|
|
+//// \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
|
|
|
+//// \"SKUCODE\": \"{$sku['SKU']}\",
|
|
|
+//// \"STATUS\": \"{$STATUS}\",
|
|
|
+//// \"PRODUCTION DATE\": \"{$item['made_at']}\",
|
|
|
+//// \"EXPIRATION DATE\": \"{$item['validity_at']}\",
|
|
|
+//// \"LOTATT05\": \"{$sku['LOTATT05']}\",
|
|
|
+//// \"UNIQUE_CODE\": \"\"
|
|
|
+//// }
|
|
|
+// "]
|
|
|
+// }
|
|
|
+// ";
|
|
|
+// $skuStrList[]=$skuStr;
|
|
|
+// });
|
|
|
+// });
|
|
|
+// if(count($skuStrList)==0)return;
|
|
|
+// $skuStrList = implode(',',$skuStrList);
|
|
|
+// $json="
|
|
|
+// {
|
|
|
+// \"request\": [
|
|
|
+// {
|
|
|
+// \"ORDERNUMBERCODE\": \"{$wmsReceived['ASNNO']}\",
|
|
|
+// \"CUSTOMERID\": \"{$customerCode}\",
|
|
|
+// \"ASNTYPE\": \"{$wmsReceived['ASNTYPE']}\",
|
|
|
+// \"ASNREFERENCE1\": \"{$orderNumberCode}\",
|
|
|
+// \"ADDWHO\": \"WCS\",
|
|
|
+// \"USERDEFINE1\": \"\",
|
|
|
+// \"USERDEFINE2\": \"\",
|
|
|
+// \"USERDEFINE3\": \"\",
|
|
|
+// \"SKU_LIST\": [{$skuStrList}]
|
|
|
+// }
|
|
|
+// ]
|
|
|
+// }
|
|
|
+// ";
|
|
|
+//
|
|
|
+// $sendingJson = json_decode($json,true);
|
|
|
+// $url=url(config('api.flux.receive.new'));
|
|
|
+// $response = Zttp::post($url, $sendingJson);
|
|
|
+// $noIssues=true;
|
|
|
+// $json = $response->json();
|
|
|
+// (new Controller())->log(__METHOD__,__FUNCTION__,$response->body().'|'.json_encode($sendingJson));
|
|
|
+// if(!$json||!isset($json['Response'])||!$json['Response']['return']['returnFlag']=='1'){
|
|
|
+// $noIssues=false;
|
|
|
+// }
|
|
|
+// if($json&&isset($json['Response'])){
|
|
|
+// if($json['Response']['return']['returnFlag']=='2'){
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// if(isset($json['Response']['return']['returnDesc'])&&strpos($json['Response']['return']['returnDesc'],'唯一约束')!==false){
|
|
|
+// (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,$response->body().'|'.json_encode($sendingJson));
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// if(isset($json['Response']['return']['errordescr'])&&strpos($json['Response']['return']['errordescr'],'已完成')!==false){
|
|
|
+// (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,$response->body().'|'.json_encode($sendingJson));
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if($noIssues&&$json['Response']['return']['returnFlag']=='1'){
|
|
|
+// $wmsReceived['is_uploaded']=1;
|
|
|
+// $wmsReceived->save();
|
|
|
+// return true;
|
|
|
+// }else{
|
|
|
+// $success=false;
|
|
|
+// (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,$response->body().'|'.json_encode($sendingJson));
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+//
|
|
|
+// return $success;
|
|
|
+ }
|
|
|
}
|