1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 数据层模型
- */
- class Activitydetail extends BaseModel
- {
- public $page_info;
- /**
- * 添加
- * @author csdeshang
- * @param array $data
- * @return bool
- */
- public function addActivitydetail($data)
- {
- return Db::name('activitydetail')->insertGetId($data);
- }
- /**
- * 根据条件更新
- * @author csdeshang
- * @param array $data 更新内容
- * @param array $condition 更新条件
- * @return bool
- */
- public function editActivitydetail($data, $condition)
- {
- return Db::name('activitydetail')->where($condition)->update($data);
- }
- /**
- * 根据条件删除
- * @author csdeshang
- * @param array $condition 条件数组
- * @return bool
- */
- public function delActivitydetail($condition)
- {
- return Db::name('activitydetail')->where($condition)->delete();
- }
- /**
- * 根据条件查询活动内容信息
- * @author csdeshang
- * @param array $condition 查询条件数组
- * @param obj $pagesize 分页页数
- * @param string $order 排序
- * @return array 二维数组
- */
- public function getActivitydetailList($condition, $pagesize = '', $order = 'activitydetail_sort desc')
- {
- if ($pagesize) {
- $res = Db::name('activitydetail')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
- $this->page_info = $res;
- return $res->items();
- } else {
- return Db::name('activitydetail')->where($condition)->order($order)->select()->toArray();
- }
- }
- /**
- * 根据条件查询活动商品内容信息
- * @author csdeshang
- * @param array $condition 查询条件数组
- * @param obj $pagesize 分页页数
- * @param string $order 排序
- * @return array 二维数组
- */
- public function getGoodsJoinList($condition, $pagesize = '', $order = '', $group = '')
- {
- $field = 'activitydetail.*,goods.*';
- $res = Db::name('activitydetail')->alias('activitydetail')->join('goods goods', 'activitydetail.item_id=goods.goods_id')->field($field)->where($condition)->order($order);
- if ($group) {
- $res = $res->group($group);
- }
- if ($pagesize) {
- $res = $res->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
- $this->page_info = $res;
- return $res->items();
- } else {
- return $res->select()->toArray();
- }
- }
- }
|