| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\controller\notify;
- use app\extra\basic\Base;
- use app\extra\dyMini\PlanLive;
- use LinFly\Annotation\Attributes\Route\Controller;
- use LinFly\Annotation\Attributes\Route\GetMapping;
- use LinFly\Annotation\Attributes\Route\PostMapping;
- use support\Request;
- use support\Response;
- /**
- * 生活应用解决方案接入
- */
- #[Controller("/life")]
- class Life extends Base
- {
- #[GetMapping("test")]
- public function test2data(Request $request): Response
- {
- try {
- $param = $this->_valid([
- "order.require" => trans("empty.require"),
- ],$request->method());
- if (!is_array($param)) return error($param);
- $data = (new PlanLive)->config([
- "appid" => sConf("wechat.mini_appid"),
- "secret" => sConf("wechat.mini_secret"),
- ])->token()->planOrder($param['order']);
- return success('success',$data);
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[PostMapping("spi")]
- public function getLifeSpi(Request $request): Response
- {
- try {
- $param = $request->all();
- echo getDateFull()."===自研应用回调===\n";
- print_r($param);
- return error("ddd");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[PostMapping("hook")]
- public function getLifeHook(Request $request): Response
- {
- try {
- $data = $request->all();
- echo getDateFull()."===自研应用回调WebHook===\n";
- print_r($data);
- if (isset($data['event']) && $data['event'] == "verify_webhook") {
- return json(['challenge' => $data['content']['challenge']]);
- }
- return error("ddd");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[PostMapping("mini")]
- public function getMiniHook(Request $request): Response
- {
- try {
- $data = $request->all();
- echo getDateFull()."===小程序WebHook===\n";
- print_r($data);
- if (isset($data['event']) && $data['event'] == "verify_webhook") {
- return json(['challenge' => $data['content']['challenge']]);
- }
- return error("ddd");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- }
|