| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 | 
							- <?php
 
- /**
 
-  * IncomeOut.php UTF-8
 
-  * 获取收益
 
-  *
 
-  * @date    : 2017/9/29 22:55
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : wuyonghong <wyh@huosdk.com>
 
-  * @version : HUOSDK 7.5
 
-  */
 
- namespace huomp\controller\finance;
 
- use huo\controller\agent\AgentCache;
 
- use huo\controller\common\Base;
 
- use huo\controller\common\CommonFunc;
 
- use huo\controller\integral\IaCache;
 
- use huo\controller\integral\MemIa;
 
- use huo\controller\member\MemCache;
 
- use huo\model\user\UserModel;
 
- use huolib\constant\IaConst;
 
- use huolib\status\IntegralStatus;
 
- use huolib\tool\StrUtils;
 
- use huomp\controller\member\MemberOut;
 
- class IncomeOut extends Base {
 
-     /**
 
-      * 获取分享收益
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $app_id 应用ID
 
-      *
 
-      * @return array
 
-      */
 
-     public function getShareIncome($mem_id, $app_id = 0) {
 
-         $_ia_id = IaConst::IA_INVITE_3;
 
-         $_mem_out = new MemberOut();
 
-         $_share_cnt = $_mem_out->getShareCnt($mem_id);
 
-         if (IaConst::IA_STATUS_REWARD == $_share_cnt['status']) {
 
-             $_code = IntegralStatus::ITG_IA_DONE;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         if (IaConst::IA_STATUS_SUC != $_share_cnt['status']) {
 
-             $_code = IntegralStatus::ITG_IA_NOT_DONE;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         $_ext = [
 
-             'app_id'  => $app_id,
 
-             'game_id' => $app_id
 
-         ];
 
-         $_rs = (new MemIa($mem_id))->doItgAct($_ia_id, $_ext);
 
-         if (IntegralStatus::NO_ERROR != $_rs['code']) {
 
-             return $this->huoReturn($_rs);
 
-         }
 
-         $_ia_data = IaCache::ins()->getIa($_ia_id);
 
-         $_integral = $_ia_data['integral'];
 
-         $_mem_out->setShareCnt($mem_id, 0, IaConst::IA_STATUS_REWARD);
 
-         return $this->getReturnData($mem_id, $_integral);
 
-     }
 
-     /**
 
-      * 获取领取试玩奖励
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $app_id 应用ID
 
-      *
 
-      * @return array
 
-      */
 
-     public function getPlayIncome($mem_id, $app_id = 0) {
 
-         $_ia_id = IaConst::IA_PLAY_3;
 
-         $_mem_out = new MemberOut();
 
-         $_play_cnt = $_mem_out->getPlayCnt($mem_id);
 
-         if (IaConst::IA_STATUS_REWARD == $_play_cnt['status']) {
 
-             $_code = IntegralStatus::ITG_IA_DONE;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         if (IaConst::IA_STATUS_SUC != $_play_cnt['status']) {
 
-             $_code = IntegralStatus::ITG_IA_NOT_DONE;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         $_ext = [
 
-             'app_id'  => $app_id,
 
-             'game_id' => $app_id
 
-         ];
 
-         $_rs = (new MemIa($mem_id))->doItgAct($_ia_id, $_ext);
 
-         if (IntegralStatus::NO_ERROR != $_rs['code'] && IntegralStatus::ITG_IA_NOT_DONE != $_rs['code']) {
 
-             return $this->huoReturn($_rs);
 
-         }
 
-         $_ia_data = IaCache::ins()->getIa($_ia_id);
 
-         $_integral = $_ia_data['integral'];
 
-         $_mem_out->setPlayCnt($mem_id, 0, IaConst::IA_STATUS_REWARD, $_ext);
 
-         if (IntegralStatus::ITG_IA_NOT_DONE == $_rs['code']) {
 
-             return $this->huoReturn($_rs);
 
-         }
 
-         return $this->getReturnData($mem_id, $_integral);
 
-     }
 
-     /**
 
-      * 获取游戏奖励
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      *
 
-      * @return array
 
-      */
 
-     public function getGameIncome($mem_id) {
 
-         $_ia_id = IaConst::IA_PLAY_3;
 
-         $_play_cnt = (new MemberOut())->getPlayCnt($mem_id);
 
-         if (IaConst::IA_STATUS_REWARD == $_play_cnt['status']) {
 
-             $_code = IntegralStatus::ITG_IA_DONE;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         if (IaConst::IA_STATUS_SUC != $_play_cnt['status']) {
 
-             $_code = IntegralStatus::ITG_IA_NOT_DONE;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         $_rs = (new MemIa($mem_id))->doItgAct($_ia_id);
 
-         if (IntegralStatus::NO_ERROR != $_rs['code']) {
 
-             return $this->huoReturn($_rs);
 
-         }
 
-         $_ia_data = IaCache::ins()->getIa($_ia_id);
 
-         $_integral = $_ia_data['integral'];
 
-         return $this->getReturnData($mem_id, $_integral);
 
-     }
 
-     /**
 
-      * 领取签到奖励
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $app_id 应用ID
 
-      *
 
-      * @return array
 
-      */
 
-     public function getSignIncome($mem_id, $app_id = 0) {
 
-         $_ia_id = IaConst::IA_SIGN;
 
-         $_rs = (new MemIa($mem_id))->doItgAct($_ia_id, $app_id);
 
-         if (IntegralStatus::NO_ERROR != $_rs['code']) {
 
-             return $this->huoReturn($_rs);
 
-         }
 
-         $_integral = $_rs['data']['gain_integral'];
 
-         return $this->getReturnData($mem_id, $_integral);
 
-     }
 
-     /**
 
-      * 领取签到奖励
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $app_id 应用ID
 
-      *
 
-      * @return array
 
-      */
 
-     public function getFavoriteIncome($mem_id, $app_id = 0) {
 
-         $_ia_id = IaConst::IA_FAVORITE;
 
-         $_ext = [
 
-             'app_id'  => $app_id,
 
-             'game_id' => $app_id
 
-         ];
 
-         $_rs = (new MemIa($mem_id))->doItgAct($_ia_id, $_ext);
 
-         if (IntegralStatus::NO_ERROR != $_rs['code']) {
 
-             return $this->huoReturn($_rs);
 
-         }
 
-         $_ia_data = IaCache::ins()->getIa($_ia_id);
 
-         $_integral = $_ia_data['integral'];
 
-         return $this->getReturnData($mem_id, $_integral);
 
-     }
 
-     /**
 
-      * 获取返回信息
 
-      *
 
-      * @param int $mem_id 玩家ID
 
-      * @param int $itg    积分
 
-      *
 
-      * @return array
 
-      */
 
-     public function getReturnData($mem_id, $itg = 0) {
 
-         $_agent_id = (new UserModel())->getIdByMemId($mem_id);
 
-         $_agent_ext_info = AgentCache::ins()->getAgentExtByAgentId($_agent_id);
 
-         if (empty($_agent_ext_info)) {
 
-             $_code = IntegralStatus::INVALID_PARAMS;
 
-             return $this->huoError($_code, IntegralStatus::getMsg($_code));
 
-         }
 
-         $_gold_rmb_rate = CommonFunc::getGoldRmbRate();
 
-         $_me_data = MemCache::ins()->getMeInfoById($mem_id);
 
-         $_rdata = [
 
-             'my_integral'   => $_me_data['my_integral'],
 
-             'gain_integral' => $itg,
 
-             'balance'       => !empty($_agent_ext_info) ? $_agent_ext_info['share_remain'] : 0,
 
-             'gain_amount'   => StrUtils::formatNumber($itg / $_gold_rmb_rate)
 
-         ];
 
-         $_code = IntegralStatus::NO_ERROR;
 
-         return $this->huoSuccess($_code, IntegralStatus::getMsg($_code), $_rdata);
 
-     }
 
- }
 
 
  |