$id, 'sceneId' => $sceneId, 'addTime' => $time, 'type' => $type, 'sjId' => $sjId]; //过期时间默认30天,即2592000 $respond = wxUtil::qrcodeCreate($merchant, $sceneId, 2592000); $url = isset($respond['url']) ? $respond['url'] : ''; if (empty($url)) { util::fail('没有生成微信场景二维码'); } self::add($data); return $url; } //生成支付成功领卷的场景 ssh 2019.9.17 public static function generatePayGetCouponScene($userId,$sjId,$merchant) { $time = time(); $sceneId = stringUtil::generateSceneId($sjId); $type = 1; $data = ['targetId' => $userId, 'sceneId' => $sceneId, 'addTime' => $time, 'type' => $type, 'sjId' => $sjId]; //过期时间默认30天,即2592000 $respond = wxUtil::qrcodeCreate($merchant, $sceneId, 2592000); $url = isset($respond['url']) ? $respond['url'] : ''; if (empty($url)) { util::fail('没有生成微信场景二维码'); } self::add($data); return $url; } //响应扫码场景事件 ssh 2019.9.5 public static function respondScanEvent($merchant, $user, $sceneId) { $sjId = $merchant['id']; $info = self::getByCondition(['sjId' => $sjId, 'sceneId' => (string)$sceneId], true); if (empty($info)) { Yii::info('sjId:' . $sjId . ' sceneId:' . $sceneId . '没有找到场景信息'); return false; } //刮刮卡 if ($info->type == 0) { $targetId = $info->targetId; $openId = $user['openId']; $allTM = xhTMessageService::getList($sjId); $shortTempId = 'OPENTM207430125'; if (isset($allTM[$shortTempId])) { $tempId = $allTM[$shortTempId]; $url = Yii::$app->params['mobileUrl'] . '/gua/index?account=' . $sjId . '&id=' . $targetId; $data = [ "touser" => $openId, "template_id" => $tempId, "url" => $url, "data" => ["first" => ["value" => '扫码成功,欢迎参与会员活动', "color" => "#173177"], "keyword1" => ["value" => "点此参与抽奖哦", "color" => "#173177"], "keyword2" => ["value" => date("Y-m-d H:i"), "color" => "#173177"], "remark" => ["value" => "", "color" => "#173177"]]]; wxUtil::sendTaskInform($data, $merchant); } } elseif ($info->type == 1) { if ($info->status == 1) { return false; } CouponService::paySuccessGetCoupon($userId,$sjId); $info->status = 1; $info->save(); } else { } } }