Browse Source

Merge branch 'yang' of ssh://47.103.131.176:10022/var/git/bswas into SyncOrder_Tack

ajun 5 năm trước cách đây
mục cha
commit
c89610223c
1 tập tin đã thay đổi với 0 bổ sung97 xóa
  1. 0 97
      app/Services/CommoditySync.php

+ 0 - 97
app/Services/CommoditySync.php

@@ -1,97 +0,0 @@
-<?php
-
-
-namespace App\Services;
-
-
-use App\Commodity;
-use App\KeyValues;
-use App\OracleBasSKU;
-use App\Owner;
-use Carbon\Carbon;
-use Illuminate\Support\Facades\Cache;
-
-class CommoditySync
-{
-    public function sync()
-    {
-        $this->syncCreated2();
-        $this->syncUpdated();
-    }
-
-    private function syncCreated()
-    {
-        $keyValues = KeyValues::query()->where('key', 'commodity_last_created_sync_at');
-        if (!$keyValues || !$keyValues->value) {
-            $commodity = Commodity::query()->orderByDesc('created_at')->first();
-            $last_created_sync_at = $commodity->created_at;
-        }
-        $last_created_sync_at = $keyValues->value;
-
-        $oracleBasSKUs = OracleBasSKU::query()->where('addtime', '>', '   ');
-        $owners = Owner::query()->whereIn('code', data_get($oracleBasSKUs, '*.customerid'))->get();
-        $ownerMap = [];
-        $owners->each(function ($item) use (&$ownerMap) {
-            $ownerMap[$item->code] = $item->id;
-        });
-
-        $commoditys = [];
-        $oracleBasSKUs->each(function ($item) use (&$commoditys, $ownerMap) {
-            $owner_id = $ownerMap[$item->customerid];
-            $dateTime = Carbon::now()->format('Y-m-d H:i:s');
-            $commoditys[] = [
-                'name' => $item->descr_c,
-                'sku' => $item->sku,
-                'owner_id' => $owner_id,
-                'length' => $item->skulength,
-                'width' => $item->skuwidth,
-                'height' => $item->skuhigh,
-                'volumn' => $item->cube,
-                'type' => '无',
-                'created_at' => $dateTime,
-                'updated_at' => $dateTime,
-            ];
-        });
-
-
-    }
-
-    private function syncCreated2()
-    {
-        $keyValues = KeyValues::query()->where('key', 'commodity_last_created_sync_at');
-
-        if (!$keyValues || !$keyValues->value) {
-            //未同步过
-            $last_created_sync_at = new Carbon();
-        } else {
-            $last_created_sync_at = Carbon::parse($keyValues->value)->subSecond()->format('Y-m-d H:i:s');
-            $oracleBasSKUs = OracleBasSKU::query()->where('addtime', '>', $last_created_sync_at)->orderByDesc('addtime');
-            if (Cache::get('commodity_newest_has_set')) {
-                $oracleBasSKUsNew = collect();
-                $oracleBasSKUs->each(function ($item) use (&$oracleBasSKUsNew, &$oracleBasSKUsOld) {
-                    $key = 'commodity_newest_' . $item->customerid . '_' . $item->sku;
-                    if (!Cache::get($key)) {
-                        $oracleBasSKUsNew->push($item);
-                    }
-                });
-                //插入数据到commodity
-                $data = [];
-                $oracleBasSKUsNew->each(function ($item) use (&$data) {
-                    $data[] = [
-
-                    ];
-                });
-
-            } else {
-                //去数据库中对比查询的结果是否有重复的
-            }
-        }
-
-
-    }
-
-    private function syncUpdated()
-    {
-
-    }
-}