Commit 0d095e7a by 杨树贤

修改导出方式

parent e5ce16e7
......@@ -943,12 +943,10 @@ class DataService
'is_export' => 1,
'is_type' => 0,
];
$suppliers = SupplierChannelModel::where('uploaded_sku', 1)->where('is_type',
$suppliers = SupplierChannelModel::where('uploaded_sku', -1)->where('is_type',
0)->whereRaw('supplier_name NOT LIKE "%-1"')->get()->toArray();
//获取最近修改信息
$logModel = new LogModel();
$firstUploadSkuTimes = SkuService::getUploadTimeBySupplierCodes(array_column($suppliers, 'supplier_code'),
'first');
foreach ($suppliers as $supplier) {
$log = $logModel->where('supplier_id', $supplier['supplier_id'])
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
......@@ -958,9 +956,8 @@ class DataService
$supplier['create_name'] = array_get($userInfo, 'name');
}
$supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : '';
$supplier['first_upload_sku_time'] = array_get($firstUploadSkuTimes,
$supplier['supplier_code']) ? date('Y-m-d H:i:s',
$firstUploadSkuTimes[$supplier['supplier_code']]) : '';
$firstUploadSkuTime = SkuService::getUploadTimeBySupplierCode($supplier['supplier_code'], 'first');
$supplier['first_upload_sku_time'] = $firstUploadSkuTime ? date('Y-m-d H:i:s', $firstUploadSkuTime) : '';
$supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置');
$itemData = [
$supplier['supplier_code'],
......
......@@ -253,6 +253,27 @@ class SkuService
}
//获取第一次上传sku时间和最后一次上传sku时间
public static function getUploadTimeBySupplierCode($supplierCode = '', $type = 'first')
{
if ($type == 'last') {
$rawSql = 'SELECT supplier_code,create_time FROM (SELECT supplier_code,max(create_time) AS create_time FROM lie_sku_upload_log GROUP BY supplier_code) AS temp WHERE supplier_code = ?';
} else {
$rawSql = 'SELECT supplier_code,create_time FROM (SELECT supplier_code,min(create_time) AS create_time FROM lie_sku_upload_log GROUP BY supplier_code) AS temp WHERE supplier_code = ?';
}
$time = 0;
$data = DB::connection('spu')
->select($rawSql, [$supplierCode]);
foreach ($data as $item) {
if ($item['supplier_code'] == $supplierCode) {
$time = $item['create_time'];
}
}
return $time;
}
//获取第一次上传sku时间和最后一次上传sku时间
public static function getUploadTimeBySupplierCodes($supplierCodes = [], $type = 'first')
{
$supplierCodeInSql = implode(',', $supplierCodes);
......@@ -278,7 +299,7 @@ class SkuService
public function getSystemTags()
{
$tags = TagsModel::where('tag_use', 16)->where('tag_type', 2)->where('status', TagsModel::STATUS_OK)
$tags = TagsModel::where('tag_use', 16)->where('tag_type', 2)->where('status', TagsModel::STATUS_OK)
->pluck('tag_name', 'tag_name')->toArray();
$result = [];
foreach ($tags as $key => $value) {
......
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