UserBalanceLog.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\common\model;
  3. use fast\Asset;
  4. use fast\Http;
  5. use fast\Random;
  6. use think\Cache;
  7. use think\Log;
  8. use think\Model;
  9. use think\Request;
  10. class UserBalanceLog extends Model
  11. {
  12. protected $name = "user_balance_log";
  13. /*
  14. * 获取ETC的USDT价格
  15. */
  16. //0支付 1转让支付 2 转让收款 3 充值 4 提现
  17. const Popular = 0;
  18. const Payment = 1;
  19. const Receive = 2;
  20. const Recharge = 3;
  21. const Withdraw = 4;
  22. const Share = 5;
  23. /*
  24. * 支付状态
  25. * 0未支付 100支付中 200支付成功 400支付失败
  26. */
  27. public $pay_status = [
  28. '-1' => '全部',
  29. self::Popular => '热销支付',
  30. self::Payment => '转让支付',
  31. self::Receive => '转让收款',
  32. self::Recharge => '充值',
  33. self::Withdraw => '提现',
  34. self::Share => '分享',
  35. ];
  36. /**
  37. * 更新钱包余额并添加账变记录
  38. * @param int $uid 用户ID
  39. * @param string $asset 资产类型
  40. * @param string $amount 金额 正:表示加 负:表示减
  41. * @param int $action 账变类型
  42. * @return void
  43. * @throws Exception
  44. */
  45. public static function changeWalletAccount(int $uid, int $type_id, string $amount, int $before, string $after, int $from_id, string $action = '+')
  46. {
  47. // 更新钱包余额
  48. UserModel::updateForRBalance($uid, $amount, $action);
  49. // 创建账变记录
  50. $insertRs = self::create([
  51. 'user_id' => $uid,
  52. 'from_id' => $from_id,
  53. 'type_id' => $type_id,
  54. 'amount' => $amount,
  55. 'before' => $before,
  56. 'after' => $after,
  57. 'action' => $action
  58. ]);
  59. if (empty($insertRs)) return false;
  60. }
  61. }