* @version : HUOSDK 8.0 */ namespace huoAccountDeal\model; use huo\model\common\CommonModel; use huolib\constant\AccountConst; use huolib\constant\CommonConst; class AccountGoodsModel extends CommonModel { protected $name = 'account_goods'; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = true; public function mem() { return $this->belongsTo('huo\model\member\MemberModel', 'mem_id', 'id'); } public function game() { return $this->belongsTo('huo\model\game\GameModel', 'app_id', 'id')->field('id,name,icon,publicity'); } public function account() { return $this->belongsTo('huo\model\member\MemGameModel', 'mg_mem_id', 'id'); } protected function base($query) { $query->where('is_delete', '=', CommonConst::CONST_NOT_DELETE); } public function addData($data) { if (empty($data)) { return false; } if ($_obj = self::create($data, true)) { return $_obj->id; } else { return false; } } public function updateData($_data, $ags_id) { $_map['id'] = $ags_id; $_rs = self::update($_data, $_map, true); if (false == $_rs) { return false; } else { return true; } } public function getIdsByTitle($title) { return $this->where(['title' => ['like', "%{$title}%"]])->column('id'); } public function isSell($mg_mem_id) { $_map['status'] = ['in', [ AccountConst::STATUS_AUDITING, AccountConst::STATUS_PULL_ON_SHELVES, AccountConst::STATUS_LOCKED, ]]; $_map['mg_mem_id'] = $mg_mem_id; $_cnt = $this->where($_map)->count(); if ($_cnt > 0) { return AccountConst::ACCOUNT_IS_SELL; } return 0; } }