* @version : HUOSDK 8.0 */ namespace huo\logic\game; use huo\model\common\CommonModel; use huo\model\game\ChannelModel; class ChannelLogic extends CommonModel { /** * 获取CPS平台列表 * * @param array $map * @param string $order * @param int $offset * * @return \think\Paginator * @throws \think\exception\DbException */ public function getChannelList($map = [], $order = 'id desc', $offset = 10) { $field = 'id, channel_name, company_name, link_man, mobile, position, create_time, update_time'; $_items = (new ChannelModel())->field($field)->where($map)->order($order)->paginate($offset); return $_items; } /** * 获取CP名称列表 * * @return array */ public static function getNamesById() { $_arr = (new ChannelModel())->where('is_delete', 2)->order('id desc')->column('channel_name name', 'id'); return $_arr; } /*** * 添加cp * * @param $param * * @param bool $return_id * * @return false|int */ public function addChannel($param, $return_id = false) { $_model = (new ChannelModel()); $_rs = $_model->allowField(true)->save($param); if (true == $return_id) { return $_model->id; } return $_rs; } /** * @param $id * * @return array|false|\PDOStatement|string|\think\Model * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getChannelById($id) { $_rs = (new ChannelModel())->where('id', $id)->find(); return $_rs; } public function updateChannel($id, $param) { $_rs = (new ChannelModel())->allowField(true)->save($param, ['id' => $id]); return $_rs; } }