|
|
@@ -32,16 +32,23 @@ Class OwnerService
|
|
|
->where('DESCR_C', 'not like', '%退仓%')
|
|
|
->where('CUSTOMER_TYPE', 'OW')
|
|
|
->get();
|
|
|
- $ownerCount = Owner::count();
|
|
|
+ $ownerCount = Owner::query()->count();
|
|
|
if (count($basCustomers) == $ownerCount) return null;
|
|
|
foreach ($basCustomers as $basCustomer) {
|
|
|
- $owner = Owner::where('code', $basCustomer['customerid'])->first();
|
|
|
- if (!isset($owner))
|
|
|
+ $owner = Owner::query()->where('code', $basCustomer['customerid'])->first();
|
|
|
+ if (!isset($owner)){
|
|
|
Owner::query()->create([
|
|
|
'code' => $basCustomer['customerid'],
|
|
|
'name' => $basCustomer['descr_c'],
|
|
|
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
|
]);
|
|
|
+ }
|
|
|
+ if ($owner['name']!=$basCustomer['descr_c']){
|
|
|
+ $owner->update([
|
|
|
+ 'code' => $basCustomer['customerid'],
|
|
|
+ 'name' => $basCustomer['descr_c'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|
|
|
$owners = Owner::query()->select('id', 'name')->get();
|
|
|
return $owners;
|