Commit a07285e3 by mushishixian

导出脚本

parent e31af927
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Http\Services\DataService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
...@@ -29,6 +30,7 @@ class SetSupplierFollowUp extends Command ...@@ -29,6 +30,7 @@ class SetSupplierFollowUp extends Command
*/ */
public function handle() public function handle()
{ {
$this->comment(PHP_EOL."111111111111".PHP_EOL); $service = new DataService();
$service->importSupplierLevel();
} }
} }
...@@ -27,11 +27,13 @@ class DataService ...@@ -27,11 +27,13 @@ class DataService
{ {
$tagList = [ $tagList = [
1 => '临时供应商', // 1 => '临时供应商',
2 => '优质供应商', // 2 => '优质供应商',
3 => '客户指定供应商', // 3 => '客户指定供应商',
4 => '开票不及时', // 4 => '开票不及时',
5 => '跳票', // 5 => '跳票',
'见票见货后付款供应商',
]; ];
$client = new Client([ $client = new Client([
...@@ -53,8 +55,8 @@ class DataService ...@@ -53,8 +55,8 @@ class DataService
$response = $client->post('/create', [ $response = $client->post('/create', [
RequestOptions::JSON => $params, RequestOptions::JSON => $params,
]); ]);
var_dump($response->getBody()->getContents());
} }
// dd($response->getBody()->getContents());
} }
//20210722 //20210722
...@@ -289,6 +291,48 @@ class DataService ...@@ -289,6 +291,48 @@ class DataService
$result = $channel->basic_publish($msg, '', 'supplier_zhuanmai_update'); $result = $channel->basic_publish($msg, '', 'supplier_zhuanmai_update');
} }
} }
//导入等级修改供应商并且找出没有等级的供应商(针对正式的)
public function importSupplierLevel()
{
$filePath = public_path('data') . DIRECTORY_SEPARATOR . 'supplier_level.xls';
try {
// $excelData = Excel::load($filePath)->getSheet(0)->toArray();
// dd($excelData);
Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) {
$supplierChannelModel = new SupplierChannelModel();
$reader->sheet('供应商清单', function ($sheet) use ($reader, $supplierChannelModel) {
$number = 0;
foreach ($reader->all()->toArray() as $key => $item) {
$supplierName = trim($item[1]);
$level = trim($item[3]);
//先去判断是否存在
$exist = $supplierChannelModel->where('supplier_name', $supplierName)
->exists();
if (!$exist) {
$number++;
//然后修改excel
$sheet->cell('E' . ($key + 2), function ($cell) {
$cell->setValue('供应商不存在');
});
} else {
$supplierChannelModel->where('supplier_name', $supplierName)->update([
'level' => $level,
]);
$sheet->cell('E' . ($key + 2), function ($cell) {
$cell->setValue('修改成功');
});
}
}
var_dump("一共有${number}个不存在的供应商");
});
})->store('xls');
} catch (\Exception $exception) {
var_dump($exception);
}
}
} }
...@@ -46,7 +46,7 @@ Route::match(['get', 'post'], '/test', function () { ...@@ -46,7 +46,7 @@ Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService(); $service = new \App\Http\Services\DataService();
// $service->pushSupplierSKu(); // $service->pushSupplierSKu();
// $service->makeSupplierSystemTag(); // $service->makeSupplierSystemTag();
// $service->initSystemTag(); $service->importSupplierLevel();
// $service->transferFileData(); // $service->transferFileData();
// $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid(); // $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid();
// $service->replaceStandardBrandId(); // $service->replaceStandardBrandId();
......
No preview for this file type
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
} }
}, },
{ {
field: 'supplier_name', title: '供应商名称', align: 'center', width: 230, templet: function (data) { field: 'supplier_name', title: '供应商名称', align: 'center', width: 180, templet: function (data) {
if (data.status === -3) { if (data.status === -3) {
return "<span title='" + data.block_reason + "'>" + data.supplier_name + "</span>" return "<span title='" + data.block_reason + "'>" + data.supplier_name + "</span>"
} else { } else {
...@@ -75,6 +75,9 @@ ...@@ -75,6 +75,9 @@
} }
}, },
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 115}, {field: 'supplier_group', title: '供应商性质', align: 'center', width: 115},
{field: 'level', title: '等级', align: 'center', width: 60,templet:function (d) {
return d.level ? d.level : '-';
}},
{field: 'region_name', title: '区域', align: 'center', width: 60}, {field: 'region_name', title: '区域', align: 'center', width: 60},
{ {
field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) { field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) {
......
No preview for this file type
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