Data_UserProfile.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 玩家付费模式数据画像
  5. */
  6. class Data_UserPaymentProfile extends Object_ext {
  7. /**
  8. * @var int 付费总额
  9. */
  10. public $payAmount = 0;
  11. /**
  12. * @var int 付费次数
  13. */
  14. public $payTimes = 0;
  15. /**
  16. * @var ts 上次付费时间戳
  17. */
  18. public $lastPayTs = 0;
  19. /**
  20. * 获得当前付费数据的分类
  21. * 0:none(免费),1:fish(小R),2: Dolphin(海豚), 3: while(鲸鱼)
  22. * @return int
  23. */
  24. public function GetClass() {
  25. if ($this->payAmount <= 0) { # 免费用户
  26. return 0;
  27. } else if ($this->payAmount < 100) { # 100以下,小R
  28. return 1;
  29. } else if ($this->payAmount < 1000) { # 1000以下,中产
  30. return 2;
  31. } else { # 大于1k的都算大R了
  32. return 3;
  33. }
  34. }
  35. }
  36. /**
  37. * 用户画像
  38. * @version
  39. * 1.0.0 Created at 2017-9-23. by --gwang
  40. * @author gwang (mail@wanggangzero.cn)
  41. * @copyright ? 2017-9-23, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  42. */
  43. class Data_UserProfile extends Object_ext {
  44. //put your code here
  45. /**
  46. * 付费画像
  47. * @var Data_UserPaymentProfile
  48. */
  49. public $payment;
  50. public function OnPay($args = null) {
  51. // 提取参数 extract or 直接按照名字提取
  52. // 更新付费总额, 次数, 最后一次付费
  53. if (null === $args || !is_array($args)) {
  54. return false;
  55. }
  56. $amt = $args['amt'];
  57. if ($amt) { # 参数不为空
  58. $this->payment->lastPayTs = now();
  59. $this->payment->payAmount += $amt;
  60. $this->payment->payTimes++;
  61. return true;
  62. }
  63. return false;
  64. }
  65. public function __construct($arg = null) {
  66. parent::__construct($arg);
  67. $this->payment = new Data_UserPaymentProfile($this->payment);
  68. }
  69. }