UserBalance.php 602 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * 用户余额组相关
  4. * @author benzhan
  5. */
  6. class UserBalance extends Model {
  7. protected $tableName = 'user_balance';
  8. protected $dbKey = 'dw_chat_user';
  9. /**
  10. * 增加余额
  11. * @param $user_id
  12. * @param $amount
  13. */
  14. public function incr($user_id, $token_id, $amount) {
  15. $count = $this->objTable->getCount(compact('user_id'));
  16. if (!$count) {
  17. $data = compact('user_id', 'token_id');
  18. $data['create_time'] = $data['update_time'] = date('Y-m-d H:i:s');
  19. $this->objTable->addObjectNx2($data);
  20. }
  21. }
  22. }