12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 用户钻石流水记录模型
- */
- class UserJewelLog extends Model
- {
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- /**
- * 用户钻石余额变更
- */
- public function addUserJewelLog($user_id, $money, $mode, $before, $detail, $type = 1)
- {
- if ($mode == "+") {
- $balance = $before + $money;
- } else {
- $balance = $before - $money;
- }
- // 添加当前用户钻石流水记录
- $data = [];
- $data["user_id"] = $user_id;
- $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);
- }
- }
|