初始化代码
This commit is contained in:
138
app/farm/model/ShopGoodsCate.php
Normal file
138
app/farm/model/ShopGoodsCate.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
namespace app\farm\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopGoodsCate extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_shop_goods_cate';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'goods_num'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 13:46
|
||||
* @功能说明:分类下面端商品数量
|
||||
*/
|
||||
public function getGoodsNumAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$num = $goods_model->where(['cate_id'=>$data['id']])->where('status','>',-1)->count();
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 15:51
|
||||
* @功能说明:获取商城分类信息
|
||||
*/
|
||||
public function shopCateList($uniacid,$store_id=0){
|
||||
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.uniacid' => $uniacid,
|
||||
|
||||
'a.status' => 1,
|
||||
|
||||
];
|
||||
|
||||
if(!empty($store_id)){
|
||||
|
||||
$dis['b.store_id'] = $store_id;
|
||||
|
||||
$dis['b.type'] = 2;
|
||||
}
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_goods_store b','a.id = b.goods_id','left')
|
||||
->where($dis)
|
||||
->field('a.*')
|
||||
->group('a.id')
|
||||
->order('a.top desc,a.id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user