Commit 12a34922 by 杨树贤

搜索供应商的需求

parent b216f1a4
...@@ -147,7 +147,7 @@ class SupplierApiController extends Controller ...@@ -147,7 +147,7 @@ class SupplierApiController extends Controller
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$query = $model->orderBy('update_time', 'desc'); $query = $model->orderBy('update_time', 'desc');
$filter = new SupplierFilter(); $filter = new SupplierFilter();
$query = $filter->listFilter($request, $query); $query = $filter->listFilter($request->all(), $query);
$limit = $request->get('limit', 10); $limit = $request->get('limit', 10);
$list = $query->paginate($limit)->toArray(); $list = $query->paginate($limit)->toArray();
$transformer = new SupplierTransformer(); $transformer = new SupplierTransformer();
...@@ -497,4 +497,15 @@ class SupplierApiController extends Controller ...@@ -497,4 +497,15 @@ class SupplierApiController extends Controller
$supplierService->batchApplyInReviewSupplier($supplierIds); $supplierService->batchApplyInReviewSupplier($supplierIds);
$this->response(0, '申请审核成功'); $this->response(0, '申请审核成功');
} }
//搜索供应商
public function searchSupplier($request)
{
$map = $request->only(['supplier_name']);
if (empty($map['supplier_name'])) {
$this->response(-1, '搜索的供应商名称不能为空');
}
$suppliers = SupplierService::searchSupplier($map);
$this->response(0, 'ok', $suppliers['data'],$suppliers['total']);
}
} }
...@@ -12,14 +12,15 @@ use Illuminate\Support\Facades\DB; ...@@ -12,14 +12,15 @@ use Illuminate\Support\Facades\DB;
class SupplierFilter class SupplierFilter
{ {
//查询条件 //查询条件
public function listFilter($request, $query) public function listFilter($map, $query)
{ {
$map = $request->all();
$map = array_map(function ($item) { $map = array_map(function ($item) {
return trim($item); return trim($item);
}, $map); }, $map);
//显示默认的数据(有权限逻辑) if (!empty($map['source_type'])) {
$query = $this->defaultFilter($query, $map['source_type']); //显示默认的数据(有权限逻辑)
$query = $this->defaultFilter($query, $map['source_type']);
}
//判断筛选参数 //判断筛选参数
if (!empty($map['supplier_id'])) { if (!empty($map['supplier_id'])) {
$query->where('supplier_channel.supplier_id', $map['supplier_id']); $query->where('supplier_channel.supplier_id', $map['supplier_id']);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Services; namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel; use App\Model\RedisModel;
...@@ -83,7 +84,7 @@ class SupplierService ...@@ -83,7 +84,7 @@ class SupplierService
$channel['us_delivery_time_period'], $channel['attachment']); $channel['us_delivery_time_period'], $channel['attachment']);
//获取付款类型有关的数据 //获取付款类型有关的数据
$payTypeData = array_only($channel,['pay_type','pay_type_value','pay_type_extra']); $payTypeData = array_only($channel, ['pay_type', 'pay_type_value', 'pay_type_extra']);
unset($channel['pay_type'], $channel['pay_type_value'], $channel['pay_type_extra']); unset($channel['pay_type'], $channel['pay_type_value'], $channel['pay_type_extra']);
$skuAuditRulerService = new SupplierSkuAuditRulerService(); $skuAuditRulerService = new SupplierSkuAuditRulerService();
...@@ -142,7 +143,7 @@ class SupplierService ...@@ -142,7 +143,7 @@ class SupplierService
$supplierId = $this->newSupplierId = $channel['supplier_id']; $supplierId = $this->newSupplierId = $channel['supplier_id'];
//要做进一步判断,部分字段修改不需要审核 //要做进一步判断,部分字段修改不需要审核
$auditService = new SupplierAuditService(); $auditService = new SupplierAuditService();
$needAudit = $auditService->checkNeedAudit($supplierId, $channel, $attachment,$payTypeData); $needAudit = $auditService->checkNeedAudit($supplierId, $channel, $attachment, $payTypeData);
if ($needAudit) { if ($needAudit) {
$channel['status'] = SupplierChannelModel::STATUS_PENDING; $channel['status'] = SupplierChannelModel::STATUS_PENDING;
} }
...@@ -446,9 +447,26 @@ class SupplierService ...@@ -446,9 +447,26 @@ class SupplierService
'status' => SupplierChannelModel::STATUS_PENDING, 'status' => SupplierChannelModel::STATUS_PENDING,
'is_type' => 0 'is_type' => 0
]); ]);
// $searchTagService = new SupplierSearchTagService();
// $searchTagService->saveSupplierSearchTags($supplier['supplier_id']);
} }
} }
//搜索供应商
public static function searchSupplier($params)
{
$filter = new SupplierFilter();
$limit = array_get($params, 'limit', 10);
$query = SupplierChannelModel::with('pay_type')->select([
'supplier_id',
'supplier_code',
'supplier_name',
'pay_type'
]);
$query = $filter->listFilter($params, $query);
$suppliers = $query->paginate($limit);
$suppliers = $suppliers->toArray();
$suppliers['data'] = SupplierTransformer::transformSearch($suppliers['data']);
return $suppliers;
}
} }
\ No newline at end of file
...@@ -129,8 +129,8 @@ class SupplierTransformer ...@@ -129,8 +129,8 @@ class SupplierTransformer
$log['add_time']) : '无'; $log['add_time']) : '无';
$supplier['has_certification_name'] = array_get(config('fixed.CertificationStatus'), $supplier['has_certification_name'] = array_get(config('fixed.CertificationStatus'),
array_get($supplier, 'has_certification', ''), ''); array_get($supplier, 'has_certification', ''), '');
$supplier['sku_tag_name'] = array_get(config('field.SkuTag'), array_get($supplier,'sku_tag',''), '无'); $supplier['sku_tag_name'] = array_get(config('field.SkuTag'), array_get($supplier, 'sku_tag', ''), '无');
$supplier['sku_mode_name'] = array_get(config('field.SkuMode'), array_get($supplier,'sku_mode',''), '无'); $supplier['sku_mode_name'] = array_get(config('field.SkuMode'), array_get($supplier, 'sku_mode', ''), '无');
return $supplier; return $supplier;
} }
...@@ -251,4 +251,18 @@ class SupplierTransformer ...@@ -251,4 +251,18 @@ class SupplierTransformer
return $channel; return $channel;
} }
public static function transformSearch($suppliers)
{
if (!empty($suppliers)) {
foreach ($suppliers as &$supplier) {
foreach ($supplier['pay_type'] as &$payType) {
$payType['pay_type_name'] = array_get(config('fixed.SupplierPayType'), $payType['pay_type']);
}
unset($payType);
}
unset($supplier);
}
return $suppliers;
}
} }
\ No newline at end of file
...@@ -42,4 +42,10 @@ class SupplierChannelModel extends Model ...@@ -42,4 +42,10 @@ class SupplierChannelModel extends Model
{ {
return $this->hasOne(SupplierAttachmentModel::class, 'supplier_id', 'supplier_id'); return $this->hasOne(SupplierAttachmentModel::class, 'supplier_id', 'supplier_id');
} }
//交易方式
public function pay_type()
{
return $this->hasMany(SupplierPayTypeModel::class, 'supplier_id', 'supplier_id');
}
} }
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