Files
huangjingfen/pro_v3.5.1/app/jobs/product/ProductLogJob.php
panchengyong 7acbf45ff7 new files
2026-03-07 22:29:07 +08:00

84 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\jobs\product;
use app\services\product\product\StoreProductLogServices;
use app\services\product\product\StoreProductServices;
use app\services\product\product\StoreVisitServices;
use crmeb\basic\BaseJobs;
use crmeb\traits\QueueTrait;
/**
* 商品记录
* Class ProductLogJob
* @package app\jobs
*/
class ProductLogJob extends BaseJobs
{
use QueueTrait;
/**
* @return mixed
*/
public static function queueName()
{
return 'CRMEB_PRO_LOG';
}
/**
* @param $type 'visit','cart','order','pay','collect','refund'
* @param $data
* @return bool
*/
public function doJob($type, $data, $productType = 'product')
{
try {
/** @var StoreProductLogServices $productLogServices */
$productLogServices = app()->make(StoreProductLogServices::class);
$productLogServices->createLog($type, $data);
if ($type == 'visit') {
/** @var StoreVisitServices $storeVisit */
$storeVisit = app()->make(StoreVisitServices::class);
$storeVisit->setView($data['uid'] ?? 0, $data['id'] ?? 0, $productType, $data['product_id'] ?? [], 'view');
}
} catch (\Throwable $e) {
response_log_write([
'message' => '写入商品记录发生错误,错误原因:' . $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine()
]);
}
return true;
}
/**
* 修改警戒库存配置,批量修改商品库存警戒
* @param $page
* @param $limit
* @return true
* @return true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/9/13 17:43
*/
public function productStockTips($page, $limit)
{
/** @var StoreProductServices $storeProductServices */
$storeProductServices = app()->make(StoreProductServices::class);
$storeProductServices->runProductStockTips($page, $limit);
return true;
}
}