where('is_delete', 0) ->where('order_id',$o_id) ->select(); } /** * @param $o_id * @param int $page * @param int $size * @return \think\Paginator * @throws \think\db\exception\DbException */ public function fetchByOrderId($o_id, $page = 1, $size = 10) { return $this->where('is_delete', 0) ->where('order_id',$o_id) ->page($page) ->paginate($size); } /** * @param $c_id * @param int $is_upload_numerology * @param int $is_upload * @return int * @throws \think\db\exception\DbException */ public function countByCustomerId($c_id, $is_upload_numerology = 1, $is_upload = null) { $where = [ ['is_delete', '=', 0], ['customer_id', '=', $c_id], ['is_upload_numerology', '=', $is_upload_numerology] ]; if ($is_upload) { array_push($where,['is_upload', '=', $is_upload]); } return $this->where($where) ->count(); } public function countByAdviser($adviser_1_id, $start_time = null, $end_time = null) { $where = [ ['is_delete', '=', 0], ['adviser_1_id', '=', $adviser_1_id], ['is_pay' , '=', 1] ]; if($start_time) array_push($where, ['create_time', '>=', $start_time]); if($end_time) array_push($where, ['create_time', '<=', $end_time]); return [ $this->where($where)->sum('real_price'), $this->where(array_merge($where,[ ['is_upload_numerology', '=', 1], ['is_upload', '=', 1] ]))->count(), $this->where(array_merge($where,[['is_upload_numerology', '=', 1]]))->count(), $this->where(array_merge($where, [['is_serve', '=', 0]]))->sum('real_price'), $this->where(array_merge($where, [['teacher_id', '>', 0]]))->sum('real_price'), $this->where(array_merge($where, [['is_serve', '=', 1]]))->sum('real_price'), ]; } public function countByAdviserProductCategoryIds($adviser_1_id, $category_ids = [], $start_time = null, $end_time = null) { if (count($category_ids) == 0) return 0; $where = [ ['is_delete', '=', 0], ['adviser_1_id', '=', $adviser_1_id], ['is_pay' , '=', 1], ['product_category_id', 'in', $category_ids] ]; if($start_time) array_push($where, ['create_time', '>=', $start_time]); if($end_time) array_push($where, ['create_time', '<=', $end_time]); return $this->where($where)->sum('real_price'); } }