| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Http\Controllers\Manager\Process;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request;
- use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
- use App\Models\Manager\Process\ViolationProduct as ViolationProductModel;
- use App\Models\Manager\Process\ViolationStore as ViolationStoreModel;
- /**
- * 清洗后的数据处理
- * @author 唐远望
- * @version 1.0
- * @date 2026-04-29
- */
- class CollectData extends Controller
- {
- /**
- * 低价商品清洗数据回填
- * @author: 唐远望
- * @version: 1.0
- * @date: 2026-04-29
- */
- public function low_price_product_collect_data(LowPriceGoodsModel $LowPriceGoodsModel)
- {
- //获取非导入的低价商品清洗数据
- $map = [];
- $map[] = ['process_lowprice_product.source_id', '!=', '0'];
- $map[] = ['process_lowprice_product.collection_time', '==', '0'];
- $map[] = ['scrape_data.insert_time', '!=', 'null'];
- $limit = '10000';
- $result = $LowPriceGoodsModel->leftjoin('scrape_data', 'scrape_data.id', '=', 'process_lowprice_product.source_id')
- ->where($map)->select(['process_lowprice_product.id', 'scrape_data.insert_time as collect_collection_time'])
- ->orderByDesc('id')->paginate($limit)->toarray();
- if (!empty($result['data'])) {
- foreach ($result['data'] as $key => $value) {
- if (empty($value['collect_collection_time'])) {
- continue;
- }
- $update_data['collection_time'] = strtotime($value['collect_collection_time']);
- $LowPriceGoodsModel->where('id', $value['id'])->update($update_data);
- }
- }
- return json_send(['code' => 'success', 'msg' => '执行成功', 'data' => count($result['data'])]);
- }
- /**
- * 禁止商品清洗数据回填
- * @author: 唐远望
- * @version: 1.0
- * @date: 2026-04-29
- */
- public function violation_product_collect_data(ViolationProductModel $ViolationProductModel)
- {
- //获取非导入的低价商品清洗数据
- $map = [];
- $map[] = ['process_violation_product.source_id', '!=', '0'];
- $map[] = ['process_violation_product.collection_time', '==', '0'];
- $map[] = ['scrape_data.insert_time', '!=', 'null'];
- $limit = '10000';
- $result = $ViolationProductModel->leftjoin('scrape_data', 'scrape_data.id', '=', 'process_violation_product.source_id')
- ->where($map)->select(['process_violation_product.id', 'scrape_data.insert_time as collect_collection_time'])
- ->orderByDesc('id')->paginate($limit)->toarray();
- if (!empty($result['data'])) {
- foreach ($result['data'] as $key => $value) {
- if (empty($value['collect_collection_time'])) {
- continue;
- }
- $update_data['collection_time'] = strtotime($value['collect_collection_time']);
- $ViolationProductModel->where('id', $value['id'])->update($update_data);
- }
- }
- return json_send(['code' => 'success', 'msg' => '执行成功', 'data' => count($result['data'])]);
- }
- /**
- * 违规店铺清洗数据回填
- * @author: 唐远望
- * @version: 1.0
- * @date: 2026-04-29
- */
- public function violation_store_collect_data(ViolationStoreModel $ViolationStoreModel)
- {
- //获取非导入的低价商品清洗数据
- $map = [];
- $map[] = ['process_violation_store.source_id', '!=', '0'];
- $map[] = ['process_violation_store.collection_time', '==', '0'];
- $map[] = ['scrape_data.insert_time', '!=', 'null'];
- $limit = '10000';
- $result = $ViolationStoreModel->leftjoin('scrape_data', 'scrape_data.id', '=', 'process_violation_store.source_id')
- ->where($map)->select(['process_violation_store.id', 'scrape_data.insert_time as collect_collection_time'])
- ->orderByDesc('id')->paginate($limit)->toarray();
- if (!empty($result['data'])) {
- foreach ($result['data'] as $key => $value) {
- if (empty($value['collect_collection_time'])) {
- continue;
- }
- $update_data['collection_time'] = strtotime($value['collect_collection_time']);
- $ViolationStoreModel->where('id', $value['id'])->update($update_data);
- }
- }
- return json_send(['code' => 'success', 'msg' => '执行成功', 'data' => count($result['data'])]);
- }
- }
|