| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\api\model\massager;
- use app\api\model\BaseModel;
- class Wallet extends BaseModel
- {
- // 表名
- protected $name = 'massager_wallet';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- static function MWKey($m_id) {
- return "massager:w:update:{$m_id}";
- }
- public function massager()
- {
- return $this->hasOne(Massager::class, 'id', 'massager_id');
- }
- function getWallet($m_id)
- {
- $w = $this->where("massager_id", $m_id)->find();
- if ($w)
- return $w;
- return self::create([
- "massager_id" => $m_id,
- "score" => 0,
- "profit_amount" => 0,
- "total_profit_amount" => 0,
- "createtime" => time(),
- "updatetime" => time()
- ]);
- }
- }
|