123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /**
- * HunterRankModel.php UTF-8
- * 猎人平台虚拟排行
- *
- * @date : 2018/9/20 19:36
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : HuoMP 1.0
- */
- namespace huomp\model\hunter;
- use huomp\model\common\CommonModel;
- class HunterRankModel extends CommonModel {
- protected $table = 'mp_hunter_rank';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- public function mem() {
- return $this->hasone('\huo\model\member\MemberModel', 'id', 'mem_id')->field('id,nickname,avatar');
- }
- /**
- * 添加数据
- *
- * @param $data
- *
- * @return bool
- */
- public function addData($data) {
- if (empty($data)) {
- return false;
- }
- $_data = $data;
- $_obj = self::create($_data, true);
- if ($_obj) {
- return true;
- }
- return false;
- }
- /**
- * 更新数据
- *
- * @param array $data 数据
- * @param int $id ID
- *
- * @return bool
- */
- public function updateData($data, $id) {
- $_map['id'] = $id;
- $_data = $data;
- $_rs = self::update($_data, $_map, true);
- if (false == $_rs) {
- return false;
- }
- return true;
- }
- /**
- * 获取数据
- *
- * @param $id
- */
- public function getInfoById($id) {
- $_map = ['id' => $id];
- $_data = $this->with('mem')->where($_map)->find();
- if (is_object($_data)) {
- $_data = $_data->toArray();
- }
- $_rdata = [
- 'id' => get_val($_data, 'id', 0),
- 'mem_id' => get_val($_data, 'mem_id', 0),
- 'nickname' => empty($_data['mem']) ? '' : $_data['mem']['nickname'],
- 'day_money' => get_val($_data, 'day_money', 0),
- 'month_money' => get_val($_data, 'month_money', 0),
- 'total_money' => get_val($_data, 'total_money', 0),
- ];
- return $_rdata;
- }
- /**
- * 删除数据
- *
- * @param $id
- *
- * @return int
- */
- public function deleteData($id) {
- $_map = ['id' => $id];
- return $this->where($_map)->delete();
- }
- /**
- * 获取列表中的所有mem_id
- *
- * @return array
- */
- public function getMemIds() {
- return $this->column('mem_id');
- }
- }
|