|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
namespace App\Imports;
|
|
namespace App\Imports;
|
|
|
|
|
|
|
|
-use App\Http\Controllers\api\jianshang\RejectedController;
|
|
|
|
|
|
|
+use App\Http\Controllers\api\thirdPart\jianshang\RejectedController;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Logistic;
|
|
use App\Logistic;
|
|
|
use App\Owner;
|
|
use App\Owner;
|
|
@@ -13,7 +13,9 @@ use Illuminate\Support\Collection;
|
|
|
use Illuminate\Support\Facades\Session;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
|
|
|
+use Maatwebsite\Excel\Imports\HeadingRowFormatter;
|
|
|
|
|
|
|
|
|
|
+HeadingRowFormatter::default('none');
|
|
|
class RejectedImport implements ToCollection, WithHeadingRow
|
|
class RejectedImport implements ToCollection, WithHeadingRow
|
|
|
{
|
|
{
|
|
|
// protected $isOverride=false;
|
|
// protected $isOverride=false;
|
|
@@ -39,7 +41,6 @@ class RejectedImport implements ToCollection, WithHeadingRow
|
|
|
$remark = trim($row['备注']??$row['remark']??'');
|
|
$remark = trim($row['备注']??$row['remark']??'');
|
|
|
$id_owner=Session::get('jianshangIdOwner');
|
|
$id_owner=Session::get('jianshangIdOwner');
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$lastReturnNumber = Session::get('jianshangLastImportedBill');
|
|
$lastReturnNumber = Session::get('jianshangLastImportedBill');
|
|
|
if(!$logistic_number_return)$logistic_number_return=$lastReturnNumber;
|
|
if(!$logistic_number_return)$logistic_number_return=$lastReturnNumber;
|
|
|
$lastMobile = Session::get('jianshangLastImportedMobile');
|
|
$lastMobile = Session::get('jianshangLastImportedMobile');
|
|
@@ -49,12 +50,12 @@ class RejectedImport implements ToCollection, WithHeadingRow
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!$id_owner){
|
|
if(!$id_owner){
|
|
|
- $id_owner=Owner::where('name','like','%笕尚%')->first()['id'];
|
|
|
|
|
|
|
+ $id_owner=Owner::query()->where('name','like','%笕尚%')->first()['id'];
|
|
|
Session::put('jianshangIdOwner',$id_owner);
|
|
Session::put('jianshangIdOwner',$id_owner);
|
|
|
}
|
|
}
|
|
|
- $id_logistic_return=Logistic::where('name','like',"%{$logistic_name}%")->first()['id'];
|
|
|
|
|
|
|
+ $id_logistic_return=Logistic::query()->where('name','like',"%{$logistic_name}%")->first()['id'];
|
|
|
if(!$id_logistic_return){
|
|
if(!$id_logistic_return){
|
|
|
- $id_logistic_return=Logistic::where('name','like',"%其它%")->first()['id'];
|
|
|
|
|
|
|
+ $id_logistic_return=Logistic::query()->where('name','like',"%其它%")->first()['id'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$id_quality_label=3;
|
|
$id_quality_label=3;
|
|
@@ -66,9 +67,9 @@ class RejectedImport implements ToCollection, WithHeadingRow
|
|
|
if(!$amount)$amount=1;
|
|
if(!$amount)$amount=1;
|
|
|
|
|
|
|
|
|
|
|
|
|
- $bill=RejectedBill::where('logistic_number_return',trim($logistic_number_return))->first();
|
|
|
|
|
|
|
+ $bill=RejectedBill::query()->where('logistic_number_return',trim($logistic_number_return))->first();
|
|
|
if($bill){
|
|
if($bill){
|
|
|
- $item=RejectedBillItem::where('id_rejected_bill',$bill['id'])
|
|
|
|
|
|
|
+ $item=RejectedBillItem::query()->where('id_rejected_bill',$bill['id'])
|
|
|
->where('barcode_goods',trim($barcode))->where('id_quality_label',$id_quality_label)->first();
|
|
->where('barcode_goods',trim($barcode))->where('id_quality_label',$id_quality_label)->first();
|
|
|
if($item){
|
|
if($item){
|
|
|
$item['amount']+=$amount;
|
|
$item['amount']+=$amount;
|
|
@@ -95,7 +96,7 @@ class RejectedImport implements ToCollection, WithHeadingRow
|
|
|
$bill->save();
|
|
$bill->save();
|
|
|
$bill->joinOrderIssue();
|
|
$bill->joinOrderIssue();
|
|
|
$bill->syncOrderIssue();
|
|
$bill->syncOrderIssue();
|
|
|
- $item=RejectedBillItem::where('id_rejected_bill',$bill['id'])
|
|
|
|
|
|
|
+ $item=RejectedBillItem::query()->where('id_rejected_bill',$bill['id'])
|
|
|
->where('barcode_goods',trim($barcode))->where('id_quality_label',$id_quality_label)->first();
|
|
->where('barcode_goods',trim($barcode))->where('id_quality_label',$id_quality_label)->first();
|
|
|
if($item){
|
|
if($item){
|
|
|
$item['amount']+=$amount;
|
|
$item['amount']+=$amount;
|
|
@@ -126,11 +127,11 @@ class RejectedImport implements ToCollection, WithHeadingRow
|
|
|
$havingFail=0;
|
|
$havingFail=0;
|
|
|
if(!config('api.API_FAKING'))
|
|
if(!config('api.API_FAKING'))
|
|
|
$bill->items()->get()->each(function(RejectedBillItem $item)use(&$havingFail){
|
|
$bill->items()->get()->each(function(RejectedBillItem $item)use(&$havingFail){
|
|
|
- $rejectedBill=RejectedBill::find($item['id_rejected_bill']);
|
|
|
|
|
|
|
+ $rejectedBill=RejectedBill::query()->find($item['id_rejected_bill']);
|
|
|
if($rejectedBill['is_loaded']!=0){
|
|
if($rejectedBill['is_loaded']!=0){
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- $owner = Owner::find($rejectedBill['id_owner']);
|
|
|
|
|
|
|
+ $owner = Owner::query()->find($rejectedBill['id_owner']);
|
|
|
if(strstr($owner->name??'','笕尚')){
|
|
if(strstr($owner->name??'','笕尚')){
|
|
|
$rejected=new Rejected();
|
|
$rejected=new Rejected();
|
|
|
app('LogService')->log(__METHOD__,'找不到表','132行');
|
|
app('LogService')->log(__METHOD__,'找不到表','132行');
|