You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
6 months ago
|
<?php
|
||
|
declare (strict_types=1);
|
||
|
|
||
|
namespace app\job\service\goods;
|
||
|
|
||
|
use app\common\library\helper;
|
||
|
use app\common\service\BaseService;
|
||
|
use app\common\model\Goods as GoodsModel;
|
||
|
use app\common\model\GoodsSku;
|
||
|
use app\store\model\GoodsCategoryRel;
|
||
|
use cores\exception\BaseException;
|
||
|
use think\facade\Log;
|
||
|
use app\common\model\Channel;
|
||
|
use app\common\model\Region;
|
||
|
/**
|
||
|
* 服务类:商品批量导入
|
||
|
* Class Import
|
||
|
* @package app\job\service\goods
|
||
|
*/
|
||
|
class GoodsOffline extends BaseService
|
||
|
{
|
||
|
/**
|
||
|
* 批量导入商品
|
||
|
* @param array $list
|
||
|
* @param int $recordId
|
||
|
* @param int $storeId
|
||
|
* @return bool
|
||
|
* @throws BaseException
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\DbException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
*/
|
||
|
public function batch(array $goodsIds): bool
|
||
|
{
|
||
|
$goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
|
||
|
->where('is_delete',0)
|
||
|
->where(function($query){
|
||
|
$query->where('is_pool',2)->whereOr('is_sale',0);
|
||
|
})
|
||
|
->field(['goods_id','is_sale','is_pool'])
|
||
|
->select();
|
||
|
if ($goods_list->isEmpty()) {
|
||
|
return true;
|
||
|
}
|
||
|
$goodsIds = array_column($goods_list->toArray(), "goods_id");
|
||
|
GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 20, 'is_jd_remove' => 1, 'update_time' => time()]);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|