12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * DayBaseModel.php UTF-8
- *
- *
- * @date : 5/21/2018 2:11 PM
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : luowei <lw@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\model\data;
- use huo\model\common\CommonModel;
- class DayBaseModel extends CommonModel {
- /**
- * DayBaseModel 切换为db_hw_dw数据库
- *
- * @param array $data
- */
- public function __construct($data = []) {
- parent::__construct($data);
- $_db_dw_config = include CMF_ROOT.'data/conf/database_dw.php';
- $this->connect($_db_dw_config);
- }
- /**
- * 计算费率
- * @param $divisor 除数
- * @param $dividend 被除数
- * @param int $precision 保留小数
- *
- * @return float
- */
- public static function calculateRate($divisor, $dividend, $precision = 2) {
- $result = 0;
- if (empty($dividend)) {
- return round($result, $precision);
- }
- return round(($divisor / $dividend), $precision);
- }
- /**
- * 新增付费率
- * @param int $precision 保留小数
- *
- * @return float
- */
- public function getNewPaymentRate($precision = 2) {
- return static::calculateRate($this->reg_pay_cnt, $this->reg_cnt, $precision);
- }
- /**
- * 活跃付费率
- *
- * @param int $precision 保留小数
- *
- * @return float
- */
- public function getActivePaymentRate($precision = 2) {
- return static::calculateRate($this->pay_user_cnt, $this->user_cnt, $precision);
- }
- /**
- * 新增注册ARPU
- *
- * @param int $precision 保留小数
- *
- * @return float
- */
- public function getNewRegARPU($precision = 2) {
- return static::calculateRate($this->first_pay_sum_money, $this->reg_cnt, $precision);
- }
- /**
- * 活跃ARPU
- *
- * @param int $precision 保留小数
- *
- * @return float
- */
- public function getActiveARPU($precision = 2) {
- return static::calculateRate($this->sum_money, $this->user_cnt, $precision);
- }
- /**
- * 付费ARPU
- *
- * @param int $precision 保留小数
- *
- * @return float
- */
- public function getPaidARPU($precision = 2) {
- return static::calculateRate($this->sum_money, $this->pay_user_cnt, $precision);
- }
- }
|