| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | 
							- <?php
 
- /**
 
-  * Income.php UTF-8
 
-  * 计算收益
 
-  *
 
-  * @date    : 2018/9/17 14:24
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : wuyonghong <wyh@huosdk.com>
 
-  * @version : HuoMp 1.0
 
-  */
 
- namespace huomp\controller\agent;
 
- use huo\controller\common\CommonFunc;
 
- use huo\controller\member\MemCache;
 
- use huo\controller\rate\Rate;
 
- use huo\model\integral\MemItgLogModel;
 
- use huolib\constant\CommonConst;
 
- use huolib\constant\IaConst;
 
- use huolib\status\IntegralStatus;
 
- use huolib\tool\StrUtils;
 
- use think\Log;
 
- class Income {
 
-     /**
 
-      * 获取打开游戏收益
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $app_id 游戏ID
 
-      *
 
-      * @param int $game_id
 
-      *
 
-      * @return array|int
 
-      */
 
-     public function getOpenGain($mem_id, $app_id, $game_id = 0) {
 
-         if (empty($mem_id) || empty($app_id)) {
 
-             Log::write(
 
-                 "func=".__FUNCTION__."&class=".__CLASS__."&step=1&mem_id=".$mem_id."&app_id=".$app_id,
 
-                 LOG::ERROR
 
-             );
 
-             return IntegralStatus::ITG_MEM_NOT_EXISTS;
 
-         }
 
-         /* 判断是否打开过游戏 */
 
-         if ($app_id == $game_id) {
 
-             $_cnt = (new MemItgLogModel())->getSubCnt($mem_id, IaConst::IA_OPEN_GAME);
 
-         } else {
 
-             $_cnt = (new MemItgLogModel())->getSubCnt($mem_id, IaConst::IA_OPEN_GAME, $app_id);
 
-         }
 
-         if ($_cnt > CommonConst::CONST_ZERO) {
 
-             return IntegralStatus::ITG_IA_DONE;
 
-         }
 
-         $_rmb_gain = (new Rate($app_id))->getMemReward();
 
-         $_gold_rmb_rate = CommonFunc::getGoldRmbRate();
 
-         $_gain = StrUtils::formatNumber($_gold_rmb_rate * $_rmb_gain);
 
-         return ['integral' => $_gain];
 
-     }
 
-     /**
 
-      * 获取下级打开游戏收益
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $app_id 游戏ID
 
-      *
 
-      * @return array|int  [parent_id,gain]
 
-      */
 
-     public function getShareGain($mem_id, $app_id) {
 
-         if (empty($mem_id) || empty($app_id)) {
 
-             Log::write(
 
-                 "func=".__FUNCTION__."&class=".__CLASS__."&step=1&mem_id=".$mem_id."&app_id=".$app_id,
 
-                 LOG::ERROR
 
-             );
 
-             return IntegralStatus::ITG_MEM_NOT_EXISTS;
 
-         }
 
-         $_parent_id = MemCache::ins()->getParentIdByMemId($mem_id);
 
-         if (empty($_parent_id)) {
 
-             return [
 
-                 'parent_id' => 0,
 
-                 'integral'  => 0
 
-             ];
 
-         }
 
-         /* 查询是否已计算过收益 */
 
-         $_cnt = (new MemItgLogModel())->getShareCnt($_parent_id, $app_id, $mem_id);
 
-         if ($_cnt > CommonConst::CONST_ZERO) {
 
-             return IntegralStatus::ITG_IA_DONE;
 
-         }
 
-         $_rmb_gain = (new Rate($app_id))->getMemAgentReward();
 
-         $_gold_rmb_rate = CommonFunc::getGoldRmbRate();
 
-         $_gain = StrUtils::formatNumber($_gold_rmb_rate * $_rmb_gain);
 
-         return [
 
-             'parent_id' => $_parent_id,
 
-             'integral'  => $_gain
 
-         ];
 
-     }
 
- }
 
 
  |