123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- /**
- * ReportData.php UTF-8
- *
- *
- * @date : 2021-03-08 16:17
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : luowei <lw@huosdk.com>
- * @version : HUOSDK 9.0
- */
- namespace huoMpAd;
- use huo\controller\agent\AgentCache;
- use huo\controller\common\Base;
- use huo\controller\member\MemCache;
- use huo\controller\pay\SdkOrderCache;
- use huo\model\member\MemGameModel;
- use huo\model\member\MemoauthModel;
- use huolib\constant\AgentConst;
- use huolib\constant\CommonConst;
- use huolib\constant\MpConfConst;
- use huolib\constant\PaywayConst;
- use huomp\model\weixin\MpConfModel;
- class MpReportData extends Base {
- /**
- * 付费回传
- *
- * @param $order_id
- *
- * @return bool
- */
- public function payReport($order_id) {
- $_order_info = (new SdkOrderCache())->getInfoByOrderId($order_id);
- // if (!in_array($_order_info['payway'], [PaywayConst::PAYWAY_MPAY, PaywayConst::PAYWAY_MPAY_TEST])) {
- // // 非米大师支付不回传
- // return true;
- // }
- $_mem_info = (new MemCache())->getInfoById($_order_info['mem_id']);
- $_mem_game_info = (new MemGameModel())->getInfoByAppMemId($_order_info['app_id'], $_order_info['mem_id']);
- $_agent_id = $_mem_game_info['guided_agent_id'] ?? 0;
- if (empty($_agent_id)) {
- $_agent_id = $_mem_info['agent_id'] ?? 0;
- }
- $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
- if (!empty($_agent_info)
- && in_array($_agent_info['role_id'], [AgentConst::AGENT_ROLE_MP_ACCOUNT, AgentConst::AGENT_ROLE_MP_AD])
- ) {
- $_mp_conf_model = new MpConfModel();
- $_mp_conf_info = $_mp_conf_model->getDataByAppId($_order_info['app_id'], MpConfConst::MP_CONF_TYPE_6);
- if (empty($_mp_conf_info)) {
- return false;
- }
- $_conf_id = $_mp_conf_info['id'];
- $_openid = (new MemoauthModel())->getOpenIdByMpMemId($_conf_id, $_order_info['mem_id']);
- $_action_data = [];
- $_action_data['url'] = 'http://www.qq.com';
- $_action_data['action_time'] = $_order_info['pay_time'];
- $_action_data['action_type'] = 'PURCHASE';
- $_action_data['openid'] = $_openid;
- $_action_data['action_param_value'] = $_order_info['amount'];
- $_action_data['agent_id'] = $_agent_id;
- $_action_data['mem_id'] = $_order_info['mem_id'];
- $_action_data['app_id'] = $_order_info['app_id'];
- $_action_data['mg_mem_id'] = $_order_info['mg_mem_id'];
- $_action_data['server_id'] = $_order_info['payext']['server_id'] ?? '';
- $_action_data['role_id'] = $_order_info['payext']['role_id'] ?? '';
- $_mp_open_mkt = new MpOpenMktNew();
- $_mp_open_mkt->dataReport($_mp_conf_info, $_agent_id, $_action_data);
- }
- return true;
- }
- /**
- *
- * 创角回传
- *
- * @param $mem_game_id
- * @param string $server_id
- * @param string $role_id
- *
- * @return bool
- */
- public function createRoleReport($mem_game_id, $server_id = '', $role_id = '') {
- $_mem_game_info = (new MemGameModel())->getInfoById($mem_game_id);
- $_mem_info = (new MemCache())->getInfoById($_mem_game_info['mem_id']);
- $_agent_id = $_mem_game_info['guided_agent_id'] ?? 0;
- if (empty($_agent_id)) {
- $_agent_id = $_mem_info['agent_id'] ?? 0;
- }
- $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
- if (!empty($_agent_info)
- && in_array($_agent_info['role_id'], [AgentConst::AGENT_ROLE_MP_ACCOUNT, AgentConst::AGENT_ROLE_MP_AD])
- ) {
- $_mp_conf_model = new MpConfModel();
- $_mp_conf_info = $_mp_conf_model->getDataByAppId($_mem_game_info['app_id'], MpConfConst::MP_CONF_TYPE_6);
- if (empty($_mp_conf_info)) {
- return false;
- }
- $_conf_id = $_mp_conf_info['id'];
- $_openid = (new MemoauthModel())->getOpenIdByMpMemId($_conf_id, $_mem_game_info['mem_id']);
- $_action_data = [];
- $_action_data['url'] = 'http://www.qq.com';
- $_action_data['action_time'] = $_mem_game_info['create_time'];
- $_action_data['action_type'] = 'CREATE_ROLE';
- $_action_data['openid'] = $_openid;
- $_action_data['action_param_value'] = '';
- $_action_data['mem_id'] = $_mem_game_info['mem_id'];
- $_action_data['agent_id'] = $_agent_id;
- $_action_data['app_id'] = $_mem_game_info['app_id'];
- $_action_data['mg_mem_id'] = $mem_game_id;
- $_action_data['server_id'] = $server_id;
- $_action_data['role_id'] = $role_id;
- $_mp_open_mkt = new MpOpenMktNew();
- $_mp_open_mkt->dataReport($_mp_conf_info, $_agent_id, $_action_data);
- }
- return true;
- }
- }
|