123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * QrCodeOut.php UTF-8
- * 二维码对外
- *
- * @date : 2018/8/17 17:42
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HuoMp 1.0
- */
- namespace huomp\controller\share;
- use huo\controller\common\Base;
- use huolib\status\AgentStatus;
- use huolib\status\CommonStatus;
- use huolib\status\OrderStatus;
- use huomp\controller\agent\AgentState;
- use huomp\controller\game\GameMini;
- use huoMpQr\QrCode;
- class QrCodeOut extends Base {
- /**
- * 获取小程序分享信息
- *
- * @param int $mem_id 玩家ID
- * @param int $app_id 应用ID
- *
- * @param string $path 分享路径
- * @param int $width
- * @param bool $auto_color
- * @param string $line_color
- * @param bool $is_hyaline
- *
- * @param int $ag_id 渠道游戏ID
- *
- * @return array
- */
- public function getQrCode(
- $mem_id, $app_id, $path, $width = 430, $auto_color = false, $line_color = '{"r":"0","g":"0","b":"0"}',
- $is_hyaline = false, $ag_id = 0
- ) {
- $_mpay_data = (new GameMini())->getLoginConf($app_id);
- $_mini_app_key = $_mpay_data['APP_KEY'];
- $_mini_app_secret = $_mpay_data['APP_SECRET'];
- if (empty($ag_id)) {
- $_scene = (new AgentState())->getCodeByMemApp($mem_id, $app_id);
- } else {
- $_scene = (new AgentState())->genAgentCode($ag_id);
- }
- $_image = (new QrCode())->getWxACodeUnLimit(
- $_mini_app_key, $_mini_app_secret, $path, $_scene, $width, $auto_color, $line_color, $is_hyaline
- );
- if (is_array($_image)) {
- $_code = CommonStatus::EXCEPTION;
- return $this->huoError($_code, AgentStatus::getMsg($_code), $_image);
- }
- $_rdata['image'] = $_image;
- $_code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($_code, AgentStatus::getMsg($_code), $_rdata);
- }
- /**
- * 获取小程序订单信息
- *
- * @param string $order_id 订单ID
- * @param int $app_id 应用ID
- *
- * @param string $path 分享路径
- * @param $width
- * @param $auto_color
- * @param $line_color
- * @param $is_hyaline
- *
- * @return array
- */
- public function getOrderQrCode(
- $order_id, $app_id, $path, $width = 430, $auto_color = false, $line_color = '{"r":"0","g":"0","b":"0"}',
- $is_hyaline = false
- ) {
- if (empty($order_id)) {
- $_code = OrderStatus::ORDER_ID_EMPTY;
- return $this->huoError($_code, OrderStatus::getMsg($_code));
- }
- $_mpay_data = (new GameMini())->getLoginConf($app_id);
- $_mini_app_key = $_mpay_data['APP_KEY'];
- $_mini_app_secret = $_mpay_data['APP_SECRET'];
- $_image = (new QrCode())->getWxACodeUnLimit(
- $_mini_app_key, $_mini_app_secret, $path, $order_id, $width, $auto_color, $line_color, $is_hyaline
- );
- if (is_array($_image)) {
- $_code = CommonStatus::EXCEPTION;
- return $this->huoError($_code, AgentStatus::getMsg($_code), $_image);
- }
- $_rdata['image'] = $_image;
- $_code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($_code, AgentStatus::getMsg($_code), $_rdata);
- }
- }
|