| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- /**
- * Created by PhpStorm
- * Author: 向往那片天空
- * Date: 2020/6/9
- * Time: 9:07
- * 微信/QQ: 250023777
- * 格言: 抓住中心,宁精勿杂,宁专勿多
- */
- namespace app\admin\model\ump;
- use app\admin\model\order\StoreOrder;
- use crmeb\basic\BaseModel;
- use crmeb\services\PHPExcelService;
- use crmeb\traits\ModelTrait;
- class StoreLiveProduct extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'store_live_product';
- use ModelTrait;
- public static function validWhere()
- {
- return self::where('is_del', 0);
- }
- /**
- * 导出EXCEL表格,并下载
- * @param $where
- */
- public static function SaveExcel($where)
- {
- }
- /**
- * 设置拼团 where 条件
- * @param $where
- * @param null $model
- * @return mixed
- */
- public static function setWhere($where, $model = null)
- {
- $model = $model === null ? new self() : $model;
- $model = $model->alias('c');
- $model = $model->field('c.*,p.store_name,p.price as ot_price');
- $model = $model->join('StoreProduct p', 'p.id=c.product_id', 'LEFT');
- if (isset($where['is_show']) && $where['is_show'] != '') $model = $model->where('c.is_show', $where['is_show']);
- if (isset($where['is_host']) && $where['is_host'] != '') $model = $model->where('c.is_host', $where['is_host']);
- if (isset($where['store_name']) && $where['store_name'] != '') $model = $model->where('p.store_name|p.id|c.id|c.title', 'LIKE', "%$where[store_name]%");
- return $model->order('c.id desc')->where('c.is_del', 0);
- }
- /**
- * @param $where
- * @return array
- */
- public static function systemPage($where)
- {
- $model = self::setWhere($where)->where('c.is_del=0')->limit(bcmul($where['page'], $where['limit'], 0), $where['limit']);
- return self::page($model, function ($item) {
- $item['count_people_all'] = StoreOrder::where('live_id', $item['id'])->count();//参与人数
- }, $where, $where['limit']);
- }
- }
|