|
@@ -98,11 +98,6 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$item_now_page = $message_data['item_now_page']; //清洗商品当前页
|
|
$item_now_page = $message_data['item_now_page']; //清洗商品当前页
|
|
|
|
|
|
|
|
$where = [];
|
|
$where = [];
|
|
|
- if ($platform != '0' && !empty($platform)) {
|
|
|
|
|
- $platform = explode(',', $platform);
|
|
|
|
|
- $ScrapeDataModel = $ScrapeDataModel->whereIn('platform_id', $platform);
|
|
|
|
|
- }
|
|
|
|
|
- $ScrapeDataModel = $ScrapeDataModel->where([['min_price', '>=', '0.01'], ['number', '>=', '1']]);
|
|
|
|
|
$start_time = $message_data['start_time'];
|
|
$start_time = $message_data['start_time'];
|
|
|
$end_time = $message_data['end_time'];
|
|
$end_time = $message_data['end_time'];
|
|
|
$start_time_string = date('Y-m-d H:i:s', $start_time);
|
|
$start_time_string = date('Y-m-d H:i:s', $start_time);
|
|
@@ -111,25 +106,59 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$where[] = ['insert_time', '<=', $end_time_string];
|
|
$where[] = ['insert_time', '<=', $end_time_string];
|
|
|
$where[] = ['product_name', 'like', '%' . $product_name . '%'];
|
|
$where[] = ['product_name', 'like', '%' . $product_name . '%'];
|
|
|
if ($enable_full_quantity == 1) $where[] = ['product_specs', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格
|
|
if ($enable_full_quantity == 1) $where[] = ['product_specs', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格
|
|
|
-
|
|
|
|
|
- $ScrapeDataModel = $ScrapeDataModel->whereRaw('(min_price / NULLIF(number, 0)) < ' . floatval($suggested_price)); //计算单盒价格
|
|
|
|
|
- // if ($product_brand) $where[] = ['product_name', 'like', '%' . $product_brand . '%'];
|
|
|
|
|
if ($product_brand) $where[] = ['product_brand', 'like', '%' . $category_name . '%'];
|
|
if ($product_brand) $where[] = ['product_brand', 'like', '%' . $category_name . '%'];
|
|
|
- if (!empty($product_keyword)) {
|
|
|
|
|
- $ScrapeDataModel = $ScrapeDataModel->where(function ($query) use ($product_keywords) {
|
|
|
|
|
- // 平台条件(固定)
|
|
|
|
|
- $query->where(function ($query_li) use ($product_keywords) {
|
|
|
|
|
- foreach ($product_keywords as $product_keyword) {
|
|
|
|
|
- if (empty($product_keyword)) continue;
|
|
|
|
|
- $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $ScrapeDataModel = $ScrapeDataModel
|
|
|
|
|
+ ->orWhere(function ($q) use ($where, $enable_full_quantity, $product_specs, $product_keywords, $company_scope, $social_credit_code, $suggested_price, $platform) {
|
|
|
|
|
+ $q->where([['min_price', '>=', '0.01'], ['number', '>=', '1']])->whereRaw('(min_price / NULLIF(number, 0)) < ' . floatval($suggested_price)); //计算单盒价格
|
|
|
|
|
+ if ($enable_full_quantity == 1) {
|
|
|
|
|
+ $where[] = ['product_name', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格,从商品名称中查找规格
|
|
|
|
|
+ }
|
|
|
|
|
+ $q->where($where);
|
|
|
|
|
+ if (!empty($product_keywords)) {
|
|
|
|
|
+ $q->where(function ($query) use ($product_keywords) {
|
|
|
|
|
+ // 平台条件(固定)
|
|
|
|
|
+ $query->where(function ($query_li) use ($product_keywords) {
|
|
|
|
|
+ foreach ($product_keywords as $product_keyword) {
|
|
|
|
|
+ if (empty($product_keyword)) continue;
|
|
|
|
|
+ $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($company_scope == 2 && $social_credit_code != '') {
|
|
|
|
|
+ $q->whereIn('qualification_number', $social_credit_code);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($platform != '0' && !empty($platform)) {
|
|
|
|
|
+ $platform = explode(',', $platform);
|
|
|
|
|
+ $q->whereIn('platform_id', $platform);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($where, $enable_full_quantity, $product_specs, $product_keywords, $company_scope, $social_credit_code, $suggested_price, $platform) {
|
|
|
|
|
+ $q->where([['min_price', '>=', '0.01'], ['number', '>=', '1']])->whereRaw('(min_price / NULLIF(number, 0)) < ' . floatval($suggested_price)); //计算单盒价格
|
|
|
|
|
+ if ($enable_full_quantity == 1) {
|
|
|
|
|
+ $where[] = ['product_specs', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格,从商品规格中查找规格
|
|
|
|
|
+ }
|
|
|
|
|
+ $q->where($where);
|
|
|
|
|
+ if (!empty($product_keywords)) {
|
|
|
|
|
+ $q->where(function ($query) use ($product_keywords) {
|
|
|
|
|
+ // 平台条件(固定)
|
|
|
|
|
+ $query->where(function ($query_li) use ($product_keywords) {
|
|
|
|
|
+ foreach ($product_keywords as $product_keyword) {
|
|
|
|
|
+ if (empty($product_keyword)) continue;
|
|
|
|
|
+ $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($company_scope == 2 && $social_credit_code != '') {
|
|
|
|
|
+ $q->whereIn('qualification_number', $social_credit_code);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($platform != '0' && !empty($platform)) {
|
|
|
|
|
+ $platform = explode(',', $platform);
|
|
|
|
|
+ $q->whereIn('platform_id', $platform);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
- if ($company_scope == 2 && $social_credit_code != '') {
|
|
|
|
|
- $ScrapeDataModel->whereIn('qualification_number', $social_credit_code);
|
|
|
|
|
- }
|
|
|
|
|
- $product_data_info = $ScrapeDataModel->select('*', DB::raw('ROUND(min_price / NULLIF(number, 0), 2) as unit_price'))->where($where)->orderbyDesc('id')->paginate($limit, ['*'], 'page', $page)->toarray();
|
|
|
|
|
|
|
+ $product_data_info = $ScrapeDataModel->orderbyDesc('id')->paginate($limit, ['*',DB::raw('ROUND(min_price / NULLIF(number, 0), 2) as unit_price')], 'page', $page)->toarray();
|
|
|
$product_datas = $product_data_info['data'];
|
|
$product_datas = $product_data_info['data'];
|
|
|
|
|
|
|
|
if (empty($product_datas)) {
|
|
if (empty($product_datas)) {
|