Commit bc479b92 by 杨树贤

初始化

parent 845b8b88
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Http\Services; namespace App\Http\Services;
//后台用户相关信息服务 //后台用户相关信息服务
use Log;
use Carbon\Carbon; use Carbon\Carbon;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use App\Model\LogModel; use App\Model\LogModel;
...@@ -23,6 +22,7 @@ use App\Model\SupplierAddressModel; ...@@ -23,6 +22,7 @@ use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
use App\Model\SupplierReceiptModel; use App\Model\SupplierReceiptModel;
use Illuminate\Support\Facades\Log;
use App\Model\SupplierContractModel; use App\Model\SupplierContractModel;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
...@@ -877,7 +877,7 @@ class DataService ...@@ -877,7 +877,7 @@ class DataService
//同步供应商到erp //同步供应商到erp
public static function syncSupplierToErp() public static function syncSupplierToErp()
{ {
$supplierIds = SupplierChannelModel::where('is_type', 0)->where('group_code', '!=', '')->where('create_time','>',1723132800) $supplierIds = SupplierChannelModel::where('is_type', 0)->where('group_code', '!=', '')->where('create_time', '>', 1723132800)
->pluck('supplier_id')->toArray(); ->pluck('supplier_id')->toArray();
foreach ($supplierIds as $supplierId) { foreach ($supplierIds as $supplierId) {
(new SyncSupplierService())->syncSupplierToErp($supplierId); (new SyncSupplierService())->syncSupplierToErp($supplierId);
...@@ -886,18 +886,18 @@ class DataService ...@@ -886,18 +886,18 @@ class DataService
public static function repaireSkuUploadRuler() public static function repaireSkuUploadRuler()
{ {
NationModel::where('nation_id', 194)->update([ NationModel::where('nation_id', 194)->update([
'international_code' => 'HK', 'international_code' => 'HK',
]); ]);
NationModel::where('nation_id', 195)->update([ NationModel::where('nation_id', 195)->update([
'international_code' => 'TW', 'international_code' => 'TW',
]); ]);
} }
public static function updateGroupCode() public static function updateGroupCode()
{ {
SupplierChannelModel::where('supplier_code','L0005670')->update(['group_code' => 'G003815']); SupplierChannelModel::where('supplier_code', 'L0005670')->update(['group_code' => 'G003815']);
} }
...@@ -912,7 +912,7 @@ class DataService ...@@ -912,7 +912,7 @@ class DataService
$supplierId = $supplier->supplier_id; $supplierId = $supplier->supplier_id;
$supplierCode = $supplier->supplier_code; $supplierCode = $supplier->supplier_code;
//重新初始化供应商的有效时间 //重新初始化供应商的有效时间
(new SupplierService())->initialCpTimeDays($supplierId, $supplierCode); (new SupplierService())->initialCpTimeDays($supplierId, $supplierCode);
\dump('重新初始化供应商有效时间:' . $supplierId . ' ' . $supplierCode); \dump('重新初始化供应商有效时间:' . $supplierId . ' ' . $supplierCode);
} }
} }
...@@ -923,4 +923,24 @@ class DataService ...@@ -923,4 +923,24 @@ class DataService
DB::connection('liexin')->table('user_oauth')->update(['sales_id' => '']); DB::connection('liexin')->table('user_oauth')->update(['sales_id' => '']);
Log::info('已将所有用户oauth的sales_id重置为0'); Log::info('已将所有用户oauth的sales_id重置为0');
} }
//供应商
public static function initSupplierCacche()
{
ini_set('memory_limit', '512M');
$supplierList = SupplierChannelModel::select([
'supplier_id',
'supplier_code',
'supplier_name'
])->get()->toArray();
$redis = new RedisModel();
foreach ($supplierList as $supplier) {
$supplierId = $supplier['supplier_id'];
$supplierCode = $supplier['supplier_code'];
$supplierName = $supplier['supplier_name'];
Log::info('初始化供应商缓存:' . $supplierId . ' ' . $supplierCode . ' ' . $supplierName);
// 这里可以添加具体的缓存初始化逻辑
$redis->hset('lie_supplier_info', $supplier['supplier_id'], json_encode($supplier));
}
}
} }
...@@ -435,6 +435,8 @@ class SupplierService ...@@ -435,6 +435,8 @@ class SupplierService
if ($isAudit && array_get($oldSupplier, 'status') == SupplierChannelModel::STATUS_PASSED && !$needAudit && !empty($channel['supplier_id'])) { if ($isAudit && array_get($oldSupplier, 'status') == SupplierChannelModel::STATUS_PASSED && !$needAudit && !empty($channel['supplier_id'])) {
//什么都不需要操作 //什么都不需要操作
} }
$redis->hset('liexin_supplier_info', $supplierId, json_encode($newSupplier));
return $supplierId; return $supplierId;
} }
...@@ -512,12 +514,12 @@ class SupplierService ...@@ -512,12 +514,12 @@ class SupplierService
$cpTimeDay = 7; $cpTimeDay = 7;
$futuresCpTimeDay = 30; $futuresCpTimeDay = 30;
} }
SupplierChannelModel::where('supplier_id', $supplierId)->update([ SupplierChannelModel::where('supplier_id', $supplierId)->update([
'cp_time_day' => $cpTimeDay, 'cp_time_day' => $cpTimeDay,
'futures_cp_time_day' => $futuresCpTimeDay, 'futures_cp_time_day' => $futuresCpTimeDay,
]); ]);
$redis = new RedisModel(); $redis = new RedisModel();
$ruler = $redis->hget('supplier_sku_upload_ruler_v2', $supplierId); $ruler = $redis->hget('supplier_sku_upload_ruler_v2', $supplierId);
if ($ruler) { if ($ruler) {
......
...@@ -96,7 +96,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -96,7 +96,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
DataService::initUserOauthSalesId(); DataService::initSupplierCacche();
// DataService::initSupplierReceiptNationId(); // DataService::initSupplierReceiptNationId();
// SupplierAccountService::initYunxinAccountName(); // SupplierAccountService::initYunxinAccountName();
// DataService::syncSupplierToErp(); // DataService::syncSupplierToErp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment