123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586 |
- <?php
- namespace App\Http\Controllers\Wechat;
- use App\Exceptions\AlertException;
- use App\Exceptions\WeChatException;
- use App\Http\Controllers\Core\User as CoreUser;
- use App\Http\Controllers\Fpdx\RoomController;
- use App\Models\Common\NoticeManageModel;
- use App\Models\User\AuthKey;
- use App\Models\User\Openid;
- use App\Services\Deed\InvitationService;
- use App\Services\Deed\NoticeService;
- use App\Services\Notice\ManageService;
- use App\Services\NoticeService\Channels\WeChatTemplateChannel;
- use App\Services\User\ProfileService;
- use App\Services\User\TaskService;
- use Illuminate\Database\Eloquent\ModelNotFoundException;
- use Illuminate\Support\Facades\Redis;
- use App\Http\Controllers\Controller;
- use Ixudra\Curl\Facades\Curl;
- /**
- * Class Event
- * @package App\Http\Controllers\Wechat
- */
- class Event extends Controller
- {
- /**
- * 绑定微信身份的模版消息
- * @param string $openid
- * @param string $key
- * @return string
- */
- public function bindTemplate(string $openid, string $key)
- {
- $user_info = Fans::getUserInfo($openid);
- $template_id = "alWufNQA9zhVec2RynEUqEUIl2l7TJZjvI6K0YZLzJM";
- $page = "https://m.fenpeiduixiang.com/login/index.html?action=bind&key={$key}";
- $parameters = [
- 'first' => [
- 'value' => "请完成账号关联后继续进行该操作。"
- ],
- 'keyword1' => [
- 'value' => "{$user_info['nickname']}"
- ],
- 'keyword2' => [
- 'value' => date("Y-m-d H:i:s")
- ],
- 'remark' => [
- 'value' => "点此继续",
- "color" => "#FF7E98"
- ],
- ];
- $app = (new WeChatTemplateChannel())->setAppId(config("wechat.fpdx.public_id"));
- $app->setTitle("绑定微信身份")->toUser($openid)->setPage("")->setUrl($page)
- ->setTemplateId($template_id)->setParameters($parameters)
- ->send();
- return "success";
- }
- /**
- * 关注事件
- * @param $object
- * @return bool|string
- * @throws AlertException
- * @throws WeChatException
- * @throws \App\Exceptions\ApiException
- */
- public static function subscribe($object)
- {
- $user_info = Fans::getUserInfo($object->FromUserName);
- try {
- self::setTag($user_info);
- } catch (\Exception $e) {
- app('sentry')->captureException($e);
- }
- $openid = $object->FromUserName;
- $public_id = $object->ToUserName;
- /** @var string $public_id */
- $userinfo = \WeChat::Fans($public_id)->info($openid);
- $unionid = $userinfo['unionid'];
- $auth = AuthKey::where('auth_key', $unionid)->first();
- if ($auth) {
- $uid = $auth->uid;
- $response = Curl::to("http://api.deep.fenpeiduixiang.com/api/analytic/check/new/scan?uid={$uid}")->asJsonResponse(false)->get();
- $isexsts = Redis::Sismember("log:bevip:page:tag", $uid);
- if ((isset($response->isScan) && 1 == $response->isScan) || $isexsts) {
- $ps = new ProfileService();
- $ps->beVip($uid, true);
- }
- AuthKey::updateOrCreate(
- ['auth_key' => $openid, 'auth_type' => $public_id],
- ['uid' => $uid, 'login_at' => time()]
- );
- } else {
- if (empty($object->EventKey)) {
- return (new Event())->bindTemplate($openid, "tobe_vip");
- }
- }
- if (substr($object->EventKey, 0, 8) == 'qrscene_') {
- try {
- $object->EventKey = substr($object->EventKey, 8);
- parse_str($object->EventKey, $param);
- $from = isset($param['from']) ? $param['from'] : '';
- if (\DB::table('kdgx_fpdx_ta_event')->where('openid', $object->FromUserName)->first()) {
- \DB::table('kdgx_fpdx_ta_event')->where('openid', $object->FromUserName)->update([
- 'from' => $from,
- 'updated_at' => $object->CreateTime
- ]);
- } else {
- \DB::table('kdgx_fpdx_ta_event')->insert([
- 'openid' => $object->FromUserName,
- 'from' => $from,
- 'created_at' => $object->CreateTime,
- 'updated_at' => $object->CreateTime
- ]);
- }
- } catch (\Exception $exception) {
- app('sentry')->captureException($exception);
- }
- return static::scan($object);
- }
- return 'Success';
- }
- /**
- * @param $user_info
- * @throws \App\Services\WeChat\WeChatException
- */
- public static function setTag($user_info)
- {
- switch ($user_info['sex']) {
- case "1":
- $tagId = \WeChat::Tags(Config('wechat.fpdx.public_id'))->get("性别-男");
- if ($tagId) {
- \WeChat::Tags(Config('wechat.fpdx.public_id'))->batchTagging($user_info['openid'], $tagId);
- }
- break;
- case "2":
- $tagId = \WeChat::Tags(Config('wechat.fpdx.public_id'))->get("性别-女");
- if ($tagId) {
- \WeChat::Tags(Config('wechat.fpdx.public_id'))->batchTagging($user_info['openid'], $tagId);
- }
- break;
- default:
- $tagId = \WeChat::Tags(Config('wechat.fpdx.public_id'))->get("性别-未知");
- if ($tagId) {
- \WeChat::Tags(Config('wechat.fpdx.public_id'))->batchTagging($user_info['openid'], $tagId);
- }
- break;
- }
- }
- /**
- * 取关事件
- * @param $object
- * @return string
- * @throws WeChatException
- */
- public static function unsubscribe($object)
- {
- try {
- Openid::where('openid', $object->FromUserName)->update(['subscribe' => 0]);
- $openData = CoreUser::getUidByOpenid($object->FromUserName);
- $profs = new ProfileService();
- $profs->beVip($openData['uid'], false);
- } catch (\Exception $exception) {
- throw new WeChatException();
- }
- return 'Success';
- }
- /**
- * 扫码事件
- * @param $object
- * @return string
- * @throws AlertException
- * @throws WeChatException
- * @throws \App\Exceptions\ApiException
- */
- public static function scan($object)
- {
- parse_str($object->EventKey, $param);
- \DB::table('kdgx_fpdx_event')->insert([
- 'openid' => $object->FromUserName,
- 'key' => $object->EventKey,
- 'from' => isset($param['from']) ? $param['from'] : '',
- 'created_at' => $object->CreateTime
- ]);
- if (!isset($param['event'])) {
- throw new WeChatException();
- }
- switch ($param['event']) {
- case 'fpdx_task':
- $array = array(
- [
- 'Title' => '恋爱任务入口',
- 'Description' => '点此进入',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/http/mediaCouple?media_id=gh_b598cb7474d8&page=task'
- ]
- );
- return SendMsg::news($object, $array);
- case 'proenroll':
- $array = [
- [
- 'Title' => '欢迎来到分配对象',
- 'Description' => '点此互选对象,完成活动报名',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/Http/index?media_id=' . $object->ToUserName . '&media_name=fpdx&base_route=couple&page=matching&from=fpdx',
- ]
- ];
- return SendMsg::news($object, $array);
- case 'secret':
- if (isset($param['secret'])) {
- $secret = $param['secret'];
- } else {
- $user_info = Fans::getUserInfo($object->FromUserName);
- if ($user_info['sex'] == 2) {
- $secret_list = \DB::table('koudai.kdgx_partner_charge_partner')->where([
- 'sex' => 1,
- 'is_sell' => 1
- ])->orderBy('praises', 'desc')->limit(100)->pluck('secret');
- $secret = $secret_list[rand(0, $secret_list->count() - 1)];
- } else {
- $secret_list = \DB::table('koudai.kdgx_partner_charge_partner')->where([
- 'sex' => 2,
- 'is_sell' => 1
- ])->orderBy('praises', 'desc')->limit(500)->pluck('secret');
- $secret = $secret_list[rand(0, $secret_list->count() - 1)];
- }
- }
- $partner = \DB::table('kdgx_partner_charge_partner')->where([
- 'secret' => $secret,
- 'is_sell' => 1
- ])->first();
- if (!$partner) {
- $object->Content = '是想要联系方式吗?你的暗号错误或经本人要求暗号已失效,换个暗号试试吧!^-^!';
- return SendMsg::text($object);
- }
- if ($partner) {
- $array = [
- [
- 'Title' => $partner->introduce,
- 'PicUrl' => 'http://oss.pocketuniversity.cn/' . $partner->photo_src,
- 'Url' => "http://www.pocketuniversity.cn/ChargePartner/http/index?page=date&id={$partner->id}&media_id={$object->ToUserName}",
- ],
- [
- 'Title' => "\n🏫学校:{$partner->school}\n\n🕴身高:{$partner->height}cm\n\n🏝家乡:{$partner->home}\n\n💞魅力值:{($partner->praises/10)}",
- 'Url' => "http://www.pocketuniversity.cn/ChargePartner/http/index?page=date&id={$partner->id}&media_id={$object->ToUserName}",
- ],
- [
- 'Title' => "💁点此解锁Ta的联系方式(微信)☞",
- 'Url' => "http://www.pocketuniversity.cn/ChargePartner/http/index?page=date&id={$partner->id}&media_id={$object->ToUserName}",
- ]
- ];
- return SendMsg::news($object, $array);
- }
- break;
- case 'qbj_enroll':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=gh_01c089b58dda&sd=23#/home/attend-form?type=qbj\">点此继续报名参与时遇记情报局~</a>";
- return SendMsg::text($object);
- case 'enroll':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=gh_01c089b58dda#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_ce5103f65339':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_ce5103f65339#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_5edc93aa148e':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_5edc93aa148e#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_qqzonesaohui':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_qqzonesaohui#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_b598cb7474d8':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_b598cb7474d8#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_wxkefuxiaoyu':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_wxkefuxiaoyu#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_qzoneguanzhu':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_qzoneguanzhu#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_fuwuhaoqunfa':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_fuwuhaoqunfa#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_dingyuequnfa':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_dingyuequnfa#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'enrollkd_laiyuanpuapp':
- $object->Content = "<a href=\"https://m.fenpeiduixiang.com/fpdx-attend/index.html?media_id=kd_laiyuanpuapp#/home/attend-form\">点此继续报名参与72小时恋爱体验活动~</a>";
- return SendMsg::text($object);
- case 'invite':
- try {
- // 获取uid
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- $nms = new ManageService();
- $nms->getNoticeByUser($openData['uid']);
- NoticeManageModel::where([
- ['uid', $openData['uid']],
- ['key', 'flipped_notice']
- ])->update(['isopen' => 1]);
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/index/index'>已开启好友申请|心动通知</a>";
- } catch (ModelNotFoundException $e) {
- return (new Event())->bindTemplate($object->FromUserName, "invitation");
- }
- return SendMsg::text($object);
- case 'ofogp':
- $array = [
- [
- 'Title' => 'ofo小黄车为杭州大学生分配对象啦,点此领取~',
- 'PicUrl' => 'https://mmbiz.qpic.cn/mmbiz_png/nAiaqJTVXP8Xr5jVPxltlVCqzqGRrASZJ3Fj9zn4k5SLX8M4K3gpJYERuyTUFYEjFVSDTboCftOicGfzs7XHdmhg/0?wx_fmt=png',
- 'Url' => 'https://mp.weixin.qq.com/s/ud7xj12AILkipA5WLiqREQ',
- ],
- [
- 'Title' => 'ofo校园缘分4元月卡,助力脱单,点此领取~',
- 'PicUrl' => 'https://mmbiz.qpic.cn/mmbiz_png/nAiaqJTVXP8Xr5jVPxltlVCqzqGRrASZJicViaGl0HtAv45pQTsic3X4icF8mkYDfMRmtkqXPas4kaPgrIckQ17v9hA/0?wx_fmt=png',
- 'Url' => 'https://mp.weixin.qq.com/s/F3TgQQTjKgBibUGFkX2doQ',
- ]
- ];
- return SendMsg::news($object, $array);
- case 'newuser':
- $array = [
- [
- 'Title' => '这是你们学校的交友名单,点此免费领取对象~',
- 'PicUrl' => 'http://oss.pocketuniversity.cn/media/2018-07-16/5b4c51b4a93e8.jpg',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/Http/index?need_school=1&media_id=gh_b598cb7474d8&media_name=fpdx',
- ],
- [
- 'Title' => '“新用户免费获取联系方式”教程',
- 'PicUrl' => 'https://mmbiz.qpic.cn/mmbiz_png/nAiaqJTVXP8W3fKRkOqCL69Z2b8YwJHCELGsl9FCBbDU3jeX4oszjvz5HNmXbSYhicKSeKlAhREwibWDkXrB5TDrg/0?wx_fmt=png',
- 'Url' => 'http://mp.weixin.qq.com/s/hr2e2RoKwQYIm4n4NgcdHQ',
- ]
- ];
- return SendMsg::news($object, $array);
- case 'pair_fail':
- $array = [
- [
- 'Title' => '点此退款或报名下一期',
- 'Description' => '分配对象,让美好的校园恋爱发生',
- 'PicUrl' => 'http://oss.pocketuniversity.cn/public/common/2017-11-08/4daf52864fc97b2d2c0b9b0f2f6afc95.png',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/http?media_id=gh_b598cb7474d8&media_name=fpdx&page=couple/list'
- ]
- ];
- return SendMsg::news($object, $array);
- case 'remind':
- $object->Content = "提醒订阅成功~";
- return SendMsg::text($object);
- break;
- case 'custom_service':
- $array = [
- [
- 'Title' => '点此联系客服',
- 'PicUrl' => 'http://wxpublic-1251448646.file.myqcloud.com/public/common/files/2018/06/640_356_21103007229201eaa6c.png',
- 'Url' => 'http://www.pocketuniversity.cn/wxpay/jsapi/roommate.html?media_id=gh_b598cb7474d8&page=couple/list&media_name=fpdx&show_xxd=1#/couple/list?media_id=gh_b598cb7474d8&page=couple%2Flist&media_name=fpdx&show_xxd=1'
- ]
- ];
- return SendMsg::news($object, $array);
- case 'enroll_fpdx':
- $array = [
- [
- 'Title' => '点此报名“72小时恋爱体验”活动',
- 'PicUrl' => 'http://oss.pocketuniversity.cn/media/2018-08-01/5b6177baa39bb.jpg',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/Http/index?media_id=gh_b598cb7474d8&media_name=fpdx&page=couple'
- ],
- [
- 'Title' => '点此查看“玩法介绍和往期活动”',
- 'PicUrl' => 'http://oss.pocketuniversity.cn/media/2018-08-01/5b6179e274720.png',
- 'Url' => 'http://mp.weixin.qq.com/mp/homepage?__biz=MzU0NTU4NDcxNA==&hid=1&sn=c21f26c011cada6395e492d9607995d6&scene=18#wechat_redirect'
- ]
- ];
- return SendMsg::news($object, $array);
- case 'into_room':
- // 进入房间
- try {
- // 获取uid
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- // 获取进房动作
- $param = Redis::hget("fpdx_mini_action:{$openData['uid']}", "mini_into_room");
- if (empty($param)) {
- throw new AlertException("无动作");
- }
- // 进入房间
- RoomController::into($openData['uid'], $param);
- } catch (\Exception $e) {
- $array = [
- [
- 'Title' => '聊天已建立,点此继续~',
- 'PicUrl' => 'http://oss.pocketuniversity.cn/media/2018-08-01/5b61996091933.png',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/http/mediaCouple#/fpdx-msg/list'
- ]
- ];
- return SendMsg::news($object, $array);
- }
- break;
- case 'pair_query':
- $array = [
- [
- 'Title' => '点此查看匹配详情',
- 'PicUrl' => 'http://oss.pocketuniversity.cn/media/2018-08-11/5b6e5999edfec.png',
- 'Url' => 'http://www.pocketuniversity.cn/ChargePartner/http?media_name=fpdx&base_route=couple&media_id=gh_b598cb7474d8'
- ]
- ];
- return SendMsg::news($object, $array);
- // 激活会员
- case 'tobe_vip':
- // 获取uid
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- } catch (AlertException $exception) {
- return (new Event())->bindTemplate($object->FromUserName, "tobe_vip");
- }
- $ps = new ProfileService();
- $ps->beVip($openData['uid'], true, true);
- break;
- // 领取会员红包
- case 'get_vip_flower':
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- } catch (ModelNotFoundException $exception) {
- return (new Event())->bindTemplate($object->FromUserName, "get_vip_flower");
- }
- $ts = new TaskService();
- try {
- $flower = $ts->getVipFlowerEveryDay($openData['uid']);
- $content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Frest-of-money%2Frest-of-money'>恭喜你获得小fa:{$flower}朵,点此继续赚小fa。</a>";
- } catch (AlertException $exception) {
- $content = $exception->getMessage();
- if ($exception->getCode() == 102) {
- $content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Fvip%2Fvip'>{$content}</a>";
- } else {
- $content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Frest-of-money%2Frest-of-money'>{$content}</a>";
- }
- }
- $object->Content = $content;
- return SendMsg::text($object);
- break;
- case 'open_pair_notice':
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- $uid = $openData['uid'];
- $group = 'fpdx';
- $open = 1;
- $ms = new ManageService();
- $ms->updateNoticeByGroup($uid, $group, $open);
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path=''>活动提醒开启成功!点此查看报名状态,提升匹配成功率~</a>";
- return SendMsg::text($object);
- } catch (\Exception $e) {
- return (new Event())->bindTemplate($object->FromUserName, "pair_notice");
- }
- break;
- case 'notice': # 通知
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Fnotice-setting%2Fnotice-setting'>通知功能开启成功,继续设置通知开关。</a>";
- return SendMsg::text($object);
- break;
- } catch (\Exception $e) {
- return (new Event())->bindTemplate($object->FromUserName, "notice");
- }
- break;
- case 'lottery_remind': # 抽奖提醒
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Fnotice-setting%2Fnotice-setting'>抽奖提醒开启成功,继续设置通知开关。</a>";
- return SendMsg::text($object);
- break;
- } catch (\Exception $e) {
- return (new Event())->bindTemplate($object->FromUserName, "lotteryremind");
- }
- break;
- case 'gteam_notice': # 开黑提醒
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- $uid = $openData['uid'];
- $notice = new ManageService();
- $is_open = $notice->updateNoticeByKey($uid, "gteam_match_success_notice", 1);
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=black&action=free&url=%2Fblack%2Fpages%2Fpersonal%2Fpersonal%3Flist_type%3Dbookhistory'>开黑通知订阅成功, 点此返回</a>";
- return SendMsg::text($object);
- } catch (\Exception $e) {
- return (new Event())->bindTemplate($object->FromUserName, "gteam_notice");
- }
- break;
- case 'goodnight_chat':
- try {
- $core = new CoreUser();
- $openData = $core->getUidByOpenid($object->FromUserName);
- $uid = $openData['uid'];
- $notice = new ManageService();
- $is_open = $notice->updateNoticeByKey($uid, "goodnight_room_chat_notice", 1);
- $object->Content = "已订阅晚安伴侣提醒";
- return SendMsg::text($object);
- } catch (\Exception $e) {
- return (new Event())->bindTemplate($object->FromUserName, "goodnight_chat");
- }
- break;
- case "hangzhou":
- try {
- $object->Content = "象友你好,终于来啦![玫瑰][玫瑰]在今后的日子中,我将带你认识异性,遇见心动~
- [跳跳]「72小时CP恋爱体验」杭州专场正在进行中,杭州的小伙伴不要错过哦,回复“<a href=\"weixin://bizmsgmenu?msgmenucontent=杭州&msgmenuid=234234\">杭州</a>”参与活动
- [爱心]更多有趣功能等你发现~~点击菜单“<a href=\"weixin://bizmsgmenu?msgmenucontent=进入小程序&msgmenuid=234234\">进入小程序</a>”试试
- 分配对象 · 火爆的95后恋爱社交小程序
- ————————
- <a href=\" \" data-miniprogram-appid=\"wx4c1722a4055bd229\" data-miniprogram-path=\"/pages/starter/starter?scene=media_id%3Dkd_hangzhou\">点此报名参与“72小时CP恋爱体验”杭州专场活动~</a>";
- return SendMsg::text($object);
- } catch (\Exception $e) {
- }
- break;
- }
- return 'Success';
- }
- /**
- * 点击事件
- * @param $object
- * @return string
- */
- public static function click($object)
- {
- switch ($object->EventKey) {
- case "menu_35410":
- $uid = \DB::table('kddx_user_openid')->where('openid', $object->FromUserName)->where(
- 'public_id',
- $object->ToUserName
- )->value('uid');
- if ($uid) {
- $notice = new NoticeService();
- $profile = NoticeManageModel::firstOrCreate([
- 'uid' => $uid,
- 'key' => 'flipped_notice'
- ], [
- 'group' => 'flipped',
- 'isopen' => 0
- ]);
- if ($profile->isopen == 0) {
- $notice->subscribe($uid);
- $content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Ffriend%2Ffriend'>已订阅心动提醒, 点此进入小程序</a>";
- $object->Content = $content;
- } else {
- $content = "你正在退订「好友/心动」消息提醒!退订后,将无法收到心动提醒\n\n确定退订请【<a href='weixin://bizmsgmenu?msgmenucontent=退订心动提醒&msgmenuid=234234'>点此</a>】";
- $object->Content = $content;
- }
- return SendMsg::text($object);
- } else {
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Ffriend%2Ffriend'>及时接收Ta的心动通知 点此订阅「心动通知」</a>";
- return SendMsg::text($object);
- }
- break;
- case "menu_36694":
- try {
- $openData = CoreUser::getUidByOpenid($object->FromUserName);
- $ins = new InvitationService();
- $dcnt = $ins->invitecnt($openData['uid']);
- $dmsg = "点此查看收到的好友申请,共收到{$dcnt['total']}条好友申请";
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Ffriend%2Ffriend'>" . $dmsg . "</a>";
- return SendMsg::text($object);
- } catch (\Exception $e) {
- $dmsg = "点此查看收到的好友申请";
- $object->Content = "<a data-miniprogram-appid='wx4c1722a4055bd229' data-miniprogram-path='pages/starter/starter?launch_type=free&url=%2Fpages%2Ffriend%2Ffriend'>" . $dmsg . "</a>";
- return SendMsg::text($object);
- }
- break;
- }
- }
- }
|