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.
60 lines
1.5 KiB
60 lines
1.5 KiB
<?php
|
|
|
|
namespace app\api\model\sharing;
|
|
|
|
use app\common\model\sharing\Goods as GoodsModel;
|
|
|
|
/**
|
|
* 拼团商品模型
|
|
* Class Goods
|
|
* @package app\api\model\sharing
|
|
*/
|
|
class Goods extends GoodsModel
|
|
{
|
|
/**
|
|
* 隐藏字段
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'sales_initial',
|
|
'sales_actual',
|
|
'is_delete',
|
|
'wxapp_id',
|
|
'create_time',
|
|
'update_time'
|
|
];
|
|
|
|
/**
|
|
* 商品详情:HTML实体转换回普通字符
|
|
* @param $value
|
|
* @return string
|
|
*/
|
|
public function getContentAttr($value)
|
|
{
|
|
return htmlspecialchars_decode($value);
|
|
}
|
|
|
|
/**
|
|
* 根据商品id集获取商品列表
|
|
* @param $goodsIds
|
|
* @param null $status
|
|
* @return false|\PDOStatement|string|\think\Collection
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function getListByIds($goodsIds, $status = null)
|
|
{
|
|
// 筛选条件
|
|
$filter = ['goods_id' => ['in', $goodsIds]];
|
|
$status > 0 && $filter['goods_status'] = $status;
|
|
if (!empty($goodsIds)) {
|
|
$this->orderRaw('field(goods_id, ' . implode(',', $goodsIds) . ')');
|
|
}
|
|
// 获取商品列表数据
|
|
return $this->with(['category', 'image.file', 'sku', 'spec_rel.spec', 'delivery.rule'])
|
|
->where($filter)
|
|
->select();
|
|
}
|
|
|
|
}
|
|
|