MpReportData.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * ReportData.php UTF-8
  4. *
  5. *
  6. * @date : 2021-03-08 16:17
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 9.0
  11. */
  12. namespace huoMpAd;
  13. use huo\controller\agent\AgentCache;
  14. use huo\controller\common\Base;
  15. use huo\controller\member\MemCache;
  16. use huo\controller\pay\SdkOrderCache;
  17. use huo\model\member\MemGameModel;
  18. use huo\model\member\MemoauthModel;
  19. use huolib\constant\AgentConst;
  20. use huolib\constant\CommonConst;
  21. use huolib\constant\MpConfConst;
  22. use huolib\constant\PaywayConst;
  23. use huomp\model\weixin\MpConfModel;
  24. class MpReportData extends Base {
  25. /**
  26. * 付费回传
  27. *
  28. * @param $order_id
  29. *
  30. * @return bool
  31. */
  32. public function payReport($order_id) {
  33. $_order_info = (new SdkOrderCache())->getInfoByOrderId($order_id);
  34. // if (!in_array($_order_info['payway'], [PaywayConst::PAYWAY_MPAY, PaywayConst::PAYWAY_MPAY_TEST])) {
  35. // // 非米大师支付不回传
  36. // return true;
  37. // }
  38. $_mem_info = (new MemCache())->getInfoById($_order_info['mem_id']);
  39. $_mem_game_info = (new MemGameModel())->getInfoByAppMemId($_order_info['app_id'], $_order_info['mem_id']);
  40. $_agent_id = $_mem_game_info['guided_agent_id'] ?? 0;
  41. if (empty($_agent_id)) {
  42. $_agent_id = $_mem_info['agent_id'] ?? 0;
  43. }
  44. $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
  45. if (!empty($_agent_info)
  46. && in_array($_agent_info['role_id'], [AgentConst::AGENT_ROLE_MP_ACCOUNT, AgentConst::AGENT_ROLE_MP_AD])
  47. ) {
  48. $_mp_conf_model = new MpConfModel();
  49. $_mp_conf_info = $_mp_conf_model->getDataByAppId($_order_info['app_id'], MpConfConst::MP_CONF_TYPE_6);
  50. if (empty($_mp_conf_info)) {
  51. return false;
  52. }
  53. $_conf_id = $_mp_conf_info['id'];
  54. $_openid = (new MemoauthModel())->getOpenIdByMpMemId($_conf_id, $_order_info['mem_id']);
  55. $_action_data = [];
  56. $_action_data['url'] = 'http://www.qq.com';
  57. $_action_data['action_time'] = $_order_info['pay_time'];
  58. $_action_data['action_type'] = 'PURCHASE';
  59. $_action_data['openid'] = $_openid;
  60. $_action_data['action_param_value'] = $_order_info['amount'];
  61. $_action_data['agent_id'] = $_agent_id;
  62. $_action_data['mem_id'] = $_order_info['mem_id'];
  63. $_action_data['app_id'] = $_order_info['app_id'];
  64. $_action_data['mg_mem_id'] = $_order_info['mg_mem_id'];
  65. $_action_data['server_id'] = $_order_info['payext']['server_id'] ?? '';
  66. $_action_data['role_id'] = $_order_info['payext']['role_id'] ?? '';
  67. $_mp_open_mkt = new MpOpenMktNew();
  68. $_mp_open_mkt->dataReport($_mp_conf_info, $_agent_id, $_action_data);
  69. }
  70. return true;
  71. }
  72. /**
  73. *
  74. * 创角回传
  75. *
  76. * @param $mem_game_id
  77. * @param string $server_id
  78. * @param string $role_id
  79. *
  80. * @return bool
  81. */
  82. public function createRoleReport($mem_game_id, $server_id = '', $role_id = '') {
  83. $_mem_game_info = (new MemGameModel())->getInfoById($mem_game_id);
  84. $_mem_info = (new MemCache())->getInfoById($_mem_game_info['mem_id']);
  85. $_agent_id = $_mem_game_info['guided_agent_id'] ?? 0;
  86. if (empty($_agent_id)) {
  87. $_agent_id = $_mem_info['agent_id'] ?? 0;
  88. }
  89. $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
  90. if (!empty($_agent_info)
  91. && in_array($_agent_info['role_id'], [AgentConst::AGENT_ROLE_MP_ACCOUNT, AgentConst::AGENT_ROLE_MP_AD])
  92. ) {
  93. $_mp_conf_model = new MpConfModel();
  94. $_mp_conf_info = $_mp_conf_model->getDataByAppId($_mem_game_info['app_id'], MpConfConst::MP_CONF_TYPE_6);
  95. if (empty($_mp_conf_info)) {
  96. return false;
  97. }
  98. $_conf_id = $_mp_conf_info['id'];
  99. $_openid = (new MemoauthModel())->getOpenIdByMpMemId($_conf_id, $_mem_game_info['mem_id']);
  100. $_action_data = [];
  101. $_action_data['url'] = 'http://www.qq.com';
  102. $_action_data['action_time'] = $_mem_game_info['create_time'];
  103. $_action_data['action_type'] = 'CREATE_ROLE';
  104. $_action_data['openid'] = $_openid;
  105. $_action_data['action_param_value'] = '';
  106. $_action_data['mem_id'] = $_mem_game_info['mem_id'];
  107. $_action_data['agent_id'] = $_agent_id;
  108. $_action_data['app_id'] = $_mem_game_info['app_id'];
  109. $_action_data['mg_mem_id'] = $mem_game_id;
  110. $_action_data['server_id'] = $server_id;
  111. $_action_data['role_id'] = $role_id;
  112. $_mp_open_mkt = new MpOpenMktNew();
  113. $_mp_open_mkt->dataReport($_mp_conf_info, $_agent_id, $_action_data);
  114. }
  115. return true;
  116. }
  117. }