Commit 65ee9685 by mushishixian

标准品牌

parent 175ec29f
......@@ -37,6 +37,14 @@ class CommonApiController extends Controller
return $this->response(0, 'ok', $brandList);
}
//获取标准品牌
public function getStandardBrandList($request)
{
$model = new BrandModel();
$brandList = $model->getStandardBrandList();
return $this->response(0, 'ok', $brandList);
}
private function SearchBrand($request)
{
$brandName = $request->input('brand_name');
......
......@@ -14,6 +14,7 @@ use App\Model\SupplierContactModel;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Maatwebsite\Excel\Facades\Excel;
//这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多
......@@ -129,6 +130,35 @@ class DataService
}
}
//替换老的品牌选择成为新的标准品牌id
public function replaceStandardBrandId()
{
$supplierModel = new SupplierChannelModel();
$suppliers = $supplierModel->where('main_brands', '!=', '')->get()->toArray();
$redis = new RedisModel();
foreach ($suppliers as $supplier) {
$mainBrands = explode(',', $supplier['main_brands']);
$standardBrandIds = [];
foreach ($mainBrands as $brandId) {
//找标准品牌ID,没有直接跳过
$standardBrandId = $redis->hget('standard_brand_mapping', $brandId);
if (empty($standardBrandId)) {
continue;
}
$standardBrandIds[] = $standardBrandId;
}
if (!empty($standardBrandIds)) {
$standardBrandIdsStr = implode(',', $standardBrandIds);
} else {
$standardBrandIdsStr = '';
}
// $supplierModel->where('supplier_id', $supplier['supplier_id'])->update([
// 'main_brands' => $standardBrandIdsStr
// ]);
print_r($standardBrandIds);
}
}
}
......@@ -36,6 +36,7 @@ class SupplierTransformer
$supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']);
$supplier['purchase_username'] = array_get($users, $supplier['purchase_uid']);
$supplier['status_name'] = array_get(config('fixed.SupplierStatus'), $supplier['status']);
$supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region'],'暂无');
$supplier['contact_num'] = $this->getContactNum($supplier['supplier_id']);
$supplier['has_sku'] = $supplier['sku_num'] ? '是' : '否';
$supplier['is_own'] = $supplier['create_uid'] == request()->user->userId ? "创建" : "指派";
......
......@@ -20,7 +20,8 @@ class SupplierValidator
'supplier_name' => 'required',
'legal_representative' => 'required',
'stockup_type' => 'required',
'supplier_address' => 'required',
'main_brands' => 'required',
// 'supplier_address' => 'required',
'region' => 'required',
'cn_delivery_time' => 'regex:/^\d+\-\d$/',
'us_delivery_time' => 'regex:/^\d+\-\d$/',
......@@ -118,6 +119,7 @@ class SupplierValidator
'return_address.max' => '退货地址不能超过100个字符',
'return_consignee.max' => '退货收货人不能超过50个字符',
'return_phone.max' => '退货收货人电话不能超过50个字符',
'main_brands.require' => '主营品牌不能为空',
];
}
......
......@@ -42,5 +42,6 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
});
Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
$service->initSystemTag();
// $service->initSystemTag();
$service->replaceStandardBrandId();
});
......@@ -63,4 +63,19 @@ class BrandModel extends Model
}
return $brandList;
}
public function getStandardBrandList()
{
$redis = new RedisModel();
$standardBrands = json_decode($redis->get('standard_brands_for_supplier'),true);
if (empty($standardBrands)) {
$standardBrandModel = new StandardBrandModel();
$standardBrands = $standardBrandModel->selectRaw('brand_name,standard_brand_id as brand_id')
->where('status', 1)->get()->toArray();
$redis->set('standard_brands_for_supplier', json_encode($standardBrands));
$redis->expire('standard_brands_for_supplier', 600);
}
return $standardBrands;
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class StandardBrandModel extends Model
{
protected $connection='spu';
protected $table='brand_standard';
public $timestamps = false;
}
......@@ -75,6 +75,7 @@
}
},
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 115},
{field: 'region_name', title: '区域', align: 'center', width: 60},
{
field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) {
return "<span title='" + data.stockup_type + "'>" + data.stockup_type + "</span>"
......@@ -103,7 +104,6 @@
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110},
{field: 'create_name', title: '创建人', align: 'center', width: 70},
{field: 'update_time', title: '最近修改时间', align: 'center', width: 145},
{field: 'create_time', title: '创建时间', align: 'center', width: 145},
];
@if(checkPerm('ViewFakeSupplier'))
......@@ -113,7 +113,9 @@
}
})
@endif
cols.push(
{field: 'create_time', title: '创建时间', align: 'center', width: 145},
);
table.render({
elem: '#list'
, url: '/api/supplier/GetSupplierList'
......
......@@ -66,7 +66,7 @@
//渲染主营品牌的多选
function getBrandOption(element, brandType) {
let brandUrl = '/api/common/getBrandList?type=' + brandType;
let brandUrl = '/api/common/getStandardBrandList';
let brandRes = ajax(brandUrl);
let brandList = brandRes.data;
return {
......
......@@ -101,6 +101,7 @@
</div>
<div class="layui-form-item">
<label class="layui-form-label">
<span class="require">*</span>
主营品牌</label>
<div class="layui-input-block" style="margin-top: 15px">
<div id="brand_selector" class="layui-input-inline" style="width: 100%;">
......
......@@ -23,7 +23,7 @@
</button>
<input type="hidden" class="upload_obj" value="">
</div>
<div class="layui-col-md12" style="padding-left: 35px;margin-top: 20px">
<div class="layui-col-md12" style="padding-left: 45px;margin-top: 5px">
<blockquote class="layui-elem-quote layui-quote-nm" style="padding-bottom: 5px">
<div id="file_list" class="layui-row">
@foreach(config('fixed.FileNameMapping') as $name=>$cnName)
......
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