123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- 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');
- }
-
- public function addData($data) {
- if (empty($data)) {
- return false;
- }
- $_data = $data;
- $_obj = self::create($_data, true);
- if ($_obj) {
- return true;
- }
- return false;
- }
-
- public function updateData($data, $id) {
- $_map['id'] = $id;
- $_data = $data;
- $_rs = self::update($_data, $_map, true);
- if (false == $_rs) {
- return false;
- }
- return true;
- }
-
- 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;
- }
-
- public function deleteData($id) {
- $_map = ['id' => $id];
- return $this->where($_map)->delete();
- }
-
- public function getMemIds() {
- return $this->column('mem_id');
- }
- }
|