| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 | <?php/** * MemberModel.php UTF-8 * 玩家Model * * @date    : 2017/11/18 17:18 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : wuyonghong <wyh@huosdk.com> * @version : HUOSDK 8.0 */namespace huo\logic\member;use huo\model\common\CommonModel;use huo\model\game\CpModel;use huolib\constant\CommonConst;use huolib\constant\GameConst;class CpLogic extends CommonModel {    public function getList() {        $_model = (new CpModel())->select()->toArray();        return $_model;    }    /**     * 获取CP列表     *     * @param array  $map     * @param string $order     * @param int    $offset     *     * @return \think\Paginator     * @throws \think\exception\DbException     */    public function getCpList($map = [], $order = 'id desc', $offset = 10) {        $field = 'id, company_name, link_man, mobile, position, create_time, update_time';        $_items = (new CpModel())->field($field)->where($map)->order($order)->paginate($offset);        return $_items;    }    /**     * 获取CP名称列表     *     * @param int $type 类型 1 CP 2 媒体     *     * @return array     */    public static function getNamesById($type = GameConst::CP_TYPE_CP) {        $_map = [            'type'      => $type,            'is_delete' => CommonConst::CONST_NOT_DELETE        ];        $_arr = (new CpModel())->where($_map)->order('id desc')->column('company_name name', 'id');        return $_arr;    }    /***     * 添加cp     *     * @param      $param     *     * @param bool $return_id     *     * @return false|int     */    public function addCp($param, $return_id = false) {        $_model = (new CpModel());        $_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 getCpById($id) {        $_rs = (new CpModel())->where('id', $id)->find();        return $_rs;    }    public function getCpNameById($id) {        $_rs = (new CpModel())->where('id', $id)->value('company_name');        return $_rs;    }    public function updateCp($id, $param) {        $_rs = (new CpModel())->allowField(true)->save($param, ['id' => $id]);        return $_rs;    }    /**     * 获取指定CP名称     *     * @return array     */    public static function getNamesByData($where = []) {        $_map = $where;        $_map['is_delete'] = 2;        $_arr = (new CpModel())->where($_map)->order('id desc')->column('company_name name', 'id');        return $_arr;    }}
 |