| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 | <?php/** * AccountGoodsModel.php UTF-8 * * * @date    : 2018/6/12 18:31 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : luowei <lw@huosdk.com> * @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;    }}
 |