1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 模型
- */
- class UserMoneyLog extends Model
- {
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- public function addRecord($userId=0, $money=0, $mode='+', $before=0, $detail='', $type = 1)
- {
- if ($mode == "+") {
- $balance = $before + $money;
- } else {
- $balance = $before - $money;
- }
- // 添加当前用户钻石流水记录
- $data = [];
- $data["user_id"] = $userId;
- $data['type'] = $type;
- $data["value"] = $money;
- $data["mode"] = $mode;
- $data["before"] = $before;
- $data["balance"] = $balance;
- $data["detail"] = $detail;
- $data["createtime"] = time();
- return $this->insertGetId($data);
- }
- }
|