MpAdTestController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * MpAdTestController.php UTF-8
  4. * 广告数据上报测试
  5. *
  6. * @date : 2018/11/16 14:29
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace mini\sdk\controller;
  13. use huo\controller\pay\SdkOrderCache;
  14. use huo\model\member\MemoauthModel;
  15. use huolib\status\CommonStatus;
  16. use huoMpAd\MpOpenMkt;
  17. use think\Controller;
  18. class MpAdTestController extends Controller {
  19. public function index() {
  20. // $_app_id = 2;
  21. // $_ma_out = new MpAdOut();
  22. // $_rs = $_ma_out->createDataSource($_app_id);
  23. // if (CommonStatus::NO_ERROR != $_rs['code']) {
  24. // $_rs['msg'] = '创建数据源错误:'.$_rs['msg'];
  25. // print_r($_rs);
  26. // exit;
  27. // }
  28. // $_action_data = [];
  29. // $_action_data['user_action_set_id'] = $_rs['data']['user_action_set_id'];
  30. // $_action_data['click_id'] = 'qwerasujdexswesw';
  31. // $_action_data['url'] = 'http://www.page/index/index';
  32. // $_rs = $_ma_out->dataReport($_app_id, $_action_data);
  33. // if (CommonStatus::NO_ERROR != $_rs['code']) {
  34. // $_rs['msg'] = '回传数据错误:'.$_rs['msg'];
  35. // print_r($_rs);
  36. // exit;
  37. // }
  38. // $this->success(lang('SUCCESS'));
  39. $this->payTest();
  40. }
  41. protected function payTest() {
  42. // 付费回传
  43. $_app_id = 7;
  44. $_ma_out = new MpOpenMkt();
  45. $_rs = $_ma_out->createDataSource($_app_id);
  46. if (CommonStatus::NO_ERROR != $_rs['code']) {
  47. $_rs['msg'] = '创建数据源错误:'.$_rs['msg'];
  48. print_r($_rs);
  49. exit;
  50. }
  51. $_order_id = 'g1614146601423450098';
  52. $_order_info = (new SdkOrderCache())->getInfoByOrderId($_order_id);
  53. $_openid = (new MemoauthModel())->getOpenIdByMpMemId($_ma_out->getConfId(), $_order_info['mem_id']);
  54. $_action_data = [];
  55. $_action_data['user_action_set_id'] = $_rs['data']['user_action_set_id'];
  56. $_action_data['action_type'] = 'PURCHASE';
  57. $_action_data['openid'] = $_openid;
  58. $_action_data['action_param_value'] = $_order_info['amount'];
  59. $_rs1 = $_ma_out->dataReport($_app_id, $_action_data);
  60. dump($_rs1);
  61. $_rs2 = $_ma_out->getDataSourceReport($_app_id, '2021-02-24','2021-02-24');
  62. halt($_rs2);
  63. }
  64. }