123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace loyalsoft;
- /**
- * 玩家付费模式数据画像
- */
- class Data_UserPaymentProfile extends Object_ext {
- /**
- * @var int 付费总额
- */
- public $payAmount = 0;
- /**
- * @var int 付费次数
- */
- public $payTimes = 0;
- /**
- * @var ts 上次付费时间戳
- */
- public $lastPayTs = 0;
- /**
- * 获得当前付费数据的分类
- * 0:none(免费),1:fish(小R),2: Dolphin(海豚), 3: while(鲸鱼)
- * @return int
- */
- public function GetClass() {
- if ($this->payAmount <= 0) { # 免费用户
- return 0;
- } else if ($this->payAmount < 100) { # 100以下,小R
- return 1;
- } else if ($this->payAmount < 1000) { # 1000以下,中产
- return 2;
- } else { # 大于1k的都算大R了
- return 3;
- }
- }
- }
- /**
- * 用户画像
- * @version
- * 1.0.0 Created at 2017-9-23. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-9-23, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
- class Data_UserProfile extends Object_ext {
- //put your code here
- /**
- * 付费画像
- * @var Data_UserPaymentProfile
- */
- public $payment;
- public function OnPay($args = null) {
- // 提取参数 extract or 直接按照名字提取
- // 更新付费总额, 次数, 最后一次付费
- if (null === $args || !is_array($args)) {
- return false;
- }
- $amt = $args['amt'];
- if ($amt) { # 参数不为空
- $this->payment->lastPayTs = now();
- $this->payment->payAmount += $amt;
- $this->payment->payTimes++;
- return true;
- }
- return false;
- }
- public function __construct($arg = null) {
- parent::__construct($arg);
- $this->payment = new Data_UserPaymentProfile($this->payment);
- }
- }
|