GoodsModel.php
798 字节
<?php
namespace app\goods\model;
use think\Model;
use think\Db;
class GoodsModel extends Model
{
public function getGoods($is_shove = null, $cid = null)
{
$map['g.is_sta'] = ['eq', 1];
$map['g.delete_time'] = ['eq', 0];
if ($cid != null) {
$map['g.cid'] = ['eq', $cid];
}
if($is_shove != null) {
$map['g.is_shove'] = ['eq', $is_shove];
}
$res = Db::name('zj_goods')->alias('g')->join('zj_category c','g.cid=c.id')
->field('g.id,g.name,g.intro,g.price,g.thumb,c.cid as caid')->where($map)
->order('listorder')
->select()->toArray();
foreach ($res as $k => $v) {
$res[$k]['thumb'] = cmf_get_image_url($v['thumb']);
}
return $res;
}
}