AgentGame.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * AgentGame.php UTF-8
  4. * 小程序
  5. *
  6. * @date : 2018/10/15 17:38
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HuoMp 1.0
  11. */
  12. namespace huomp\controller\agent;
  13. use huo\controller\agent\AgentCache;
  14. use huo\controller\game\GameCache;
  15. use huolib\constant\GameConst;
  16. use huolib\status\CommonStatus;
  17. use huolib\status\GameStatus;
  18. use huomp\controller\share\QrCodeOut;
  19. class AgentGame {
  20. /**
  21. * 设置渠道二维码
  22. *
  23. * @param $ag_id
  24. *
  25. * @return int
  26. */
  27. public function setQrUrl($ag_id) {
  28. $_app_id = AgentCache::ins()->getAppIdByAgId($ag_id);
  29. if (empty($_app_id)) {
  30. return GameStatus::NOT_YET_ADDED_GAME;
  31. }
  32. $_game_data = GameCache::ins()->getInfoByAppId($_app_id);
  33. $_classify = substr($_game_data['classify'], 0, 1);
  34. if (GameConst::GAME_MP == $_classify) {
  35. $_mp_qr_arr = (new QrCodeOut())->getQrCode(
  36. 0, $_app_id, '', 430, false, '{"r":"0","g":"0","b":"0"}', false, $ag_id
  37. );
  38. if (CommonStatus::NO_ERROR != $_mp_qr_arr['code']) {
  39. return GameStatus::QR_URL_ERROR;
  40. }
  41. $_update_data['package_url'] = $_mp_qr_arr['data']['image'];
  42. AgentCache::ins()->updateAg($ag_id, $_update_data);
  43. }
  44. return GameStatus::NO_ERROR;
  45. }
  46. }