WechatService.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. namespace liuniu;
  3. use app\admin\model\Company;
  4. use app\admin\model\WechatPlanRecord;
  5. use app\common\model\WechatContext;
  6. use EasyWeChat\Factory;
  7. use EasyWeChat\Kernel\Messages\Article;
  8. use EasyWeChat\Kernel\Messages\Image;
  9. use EasyWeChat\Kernel\Messages\News;
  10. use EasyWeChat\Kernel\Messages\Text;
  11. use EasyWeChat\Kernel\Messages\Video;
  12. use think\Hook;
  13. use think\Request;
  14. use think\Response;
  15. class WechatService
  16. {
  17. private static $instance = null;
  18. private static $app = null;
  19. public static function options($cid)
  20. {
  21. $info = Company::where('id', $cid)->find();
  22. $config = [
  23. 'app_id' => isset($info['wechat_appid']) ? trim($info['wechat_appid']) : '',
  24. 'secret' => isset($info['wechat_appsecret']) ? trim($info['wechat_appsecret']) : '',
  25. 'token' => isset($info['wechat_token']) ? trim($info['wechat_token']) : '',
  26. 'guzzle' => [
  27. 'timeout' => 10.0, // 超时时间(秒)
  28. 'verify' => false
  29. ],
  30. ];
  31. if (isset($info['wechat_encode']) && (int)$info['wechat_encode'] > 0 && isset($info['wechat_encodingaeskey']) && !empty($info['wechat_encodingaeskey']))
  32. $config['aes_key'] = $info['wechat_encodingaeskey'];
  33. if (isset($info['pay_weixin_open']) && $info['pay_weixin_open'] == 1) {
  34. $config1 = [
  35. 'mch_id' => trim($info['pay_weixin_mchid']),
  36. 'key' => trim($info['pay_weixin_key']),
  37. 'cert_path' => realpath('.' . $info['pay_weixin_client_certfile']),
  38. 'key_path' => realpath('.' . $info['pay_weixin_client_keyfile']),
  39. 'notify_url' => Request::instance()->domain() . "/api/wechat/notify/" . $cid
  40. ];
  41. $config = array_merge($config, $config1);
  42. }
  43. return $config;
  44. }
  45. public static function application($cache = false, $cid = 0)
  46. {
  47. (self::$instance[$cid] === null || $cache === true) && (self::$instance[$cid] = Factory::officialAccount(self::options($cid)));
  48. return self::$instance[$cid];
  49. }
  50. /**
  51. * 支付接口
  52. * @param false $cache
  53. * @param int $cid
  54. * @return \EasyWeChat\Payment\Application|mixed
  55. */
  56. public static function payment($cache = false, $cid = 0)
  57. {
  58. (self::$app[$cid] === null || $cache === true) && (self::$app[$cid] = Factory::payment(self::options($cid)));
  59. return self::$app[$cid];
  60. }
  61. public static function serve($cid = 0): Response
  62. {
  63. $wechat = self::application(true, $cid);
  64. $server = $wechat->server;
  65. self::hook($server);
  66. $response = $server->serve();
  67. return Response($response->getContent());
  68. }
  69. /**
  70. * 监听行为
  71. * @param Guard $server
  72. */
  73. private static function hook($server)
  74. {
  75. $server->push(function ($message) {
  76. switch ($message['MsgType']) {
  77. case 'event':
  78. switch (strtolower($message['Event'])) {
  79. case 'subscribe':
  80. $response = WechatReply::reply('subscribe');
  81. if (isset($message->EventKey)) {
  82. if ($message->EventKey && ($qrInfo = QrcodeService::getQrcode($message->Ticket, 'ticket'))) {
  83. QrcodeService::scanQrcode($message->Ticket, 'ticket');
  84. if (strtolower($qrInfo['third_type']) == 'spread') {
  85. }
  86. }
  87. }
  88. break;
  89. case 'unsubscribe':
  90. event('WechatEventUnsubscribeBefore', [$message]);
  91. break;
  92. case 'scan':
  93. $response = WechatReply::reply('subscribe');
  94. if ($message->EventKey && ($qrInfo = QrcodeService::getQrcode($message->Ticket, 'ticket'))) {
  95. QrcodeService::scanQrcode($message->Ticket, 'ticket');
  96. if (strtolower($qrInfo['third_type']) == 'spread') {
  97. }
  98. }
  99. break;
  100. case 'location':
  101. $response = MessageRepositories::wechatEventLocation($message);
  102. break;
  103. case 'click':
  104. $response = WechatReply::reply($message->EventKey);
  105. break;
  106. case 'view':
  107. $response = MessageRepositories::wechatEventView($message);
  108. break;
  109. }
  110. break;
  111. case 'text':
  112. @file_put_contents("tt.txt", '1');
  113. $response = self::textMessage('绑定推荐人失败');
  114. @file_put_contents("tt.txt", '2', 8);
  115. @file_put_contents("tt.txt", json_encode($response), 8);
  116. break;
  117. $response = WechatReply::reply($message->Content);
  118. break;
  119. case 'image':
  120. $response = MessageRepositories::wechatMessageImage($message);
  121. break;
  122. case 'voice':
  123. $response = MessageRepositories::wechatMessageVoice($message);
  124. break;
  125. case 'video':
  126. $response = MessageRepositories::wechatMessageVideo($message);
  127. break;
  128. case 'location':
  129. $response = MessageRepositories::wechatMessageLocation($message);
  130. break;
  131. case 'link':
  132. $response = MessageRepositories::wechatMessageLink($message);
  133. break;
  134. // ... 其它消息
  135. default:
  136. $response = MessageRepositories::wechatMessageOther($message);
  137. break;
  138. }
  139. return $response ?? false;
  140. });
  141. }
  142. /**
  143. * 多客服消息转发
  144. * @param string $account
  145. * @return \EasyWeChat\Message\Transfer
  146. */
  147. public static function transfer($account = '')
  148. {
  149. $transfer = new \EasyWeChat\Message\Transfer();
  150. return empty($account) ? $transfer : $transfer->to($account);
  151. }
  152. /**
  153. * 上传永久素材接口
  154. * @return \EasyWeChat\Material\Material
  155. */
  156. public static function materialService($cid = 0)
  157. {
  158. return self::application(false, $cid)->material;
  159. }
  160. /**
  161. * 上传临时素材接口
  162. * @return \EasyWeChat\Material\Temporary
  163. */
  164. public static function materialTemporaryService($cid = 0)
  165. {
  166. return self::application(false, $cid)->media;
  167. }
  168. /**
  169. * 用户接口
  170. * @return \EasyWeChat\User\User
  171. */
  172. public static function userService($cid = 0)
  173. {
  174. return self::application(false, $cid)->user;
  175. }
  176. /**
  177. * 客服消息接口
  178. * @param null $to
  179. * @param null $message
  180. */
  181. public static function staffService($cid = 0)
  182. {
  183. return self::application(false, $cid)->staff;
  184. }
  185. /**
  186. * 微信公众号菜单接口
  187. * @return \EasyWeChat\Menu\Menu
  188. */
  189. public static function menuService($cid = 0)
  190. {
  191. return self::application(false, $cid)->menu;
  192. }
  193. /**
  194. * 微信二维码生成接口
  195. * @return \EasyWeChat\QRCode\QRCode
  196. */
  197. public static function qrcodeService($cid = 0)
  198. {
  199. return self::application(false, $cid)->qrcode;
  200. }
  201. /**
  202. * 微信永久二维码生成接口 小于10万个
  203. * @return \EasyWeChat\QRCode\QRCode
  204. */
  205. public static function qrcodeForeverService($sceneValue, $cid = 0)
  206. {
  207. return self::application(false, $cid)->qrcode->forever($sceneValue);
  208. }
  209. /**
  210. * 微信临时二维码生成接口 30天有效期
  211. * @return \EasyWeChat\QRCode\QRCode
  212. */
  213. public static function qrcodeTempService($sceneValue, $expireSeconds = 2592000, $cid = 0)
  214. {
  215. return self::application(false, $cid)->qrcode->temporary($sceneValue, $expireSeconds);
  216. }
  217. /**
  218. * 短链接生成接口
  219. * @return \EasyWeChat\Url\Url
  220. */
  221. public static function urlService($cid = 0)
  222. {
  223. return self::application(false, $cid)->url;
  224. }
  225. /**
  226. * 用户授权
  227. * @return \Overtrue\Socialite\Providers\WeChatProvider
  228. */
  229. public static function oauthService($cid = 0)
  230. {
  231. return self::application(false, $cid)->oauth;
  232. }
  233. /**
  234. * 模板消息接口
  235. * @return \EasyWeChat\Notice\Notice
  236. */
  237. public static function noticeService($cid = 0)
  238. {
  239. return self::application(false, $cid)->template_message;
  240. }
  241. public static function sendTemplate($openid, $templateId, array $data, $url = null, $cid = 0)
  242. {
  243. $notice = self::noticeService($cid);
  244. return $notice->send([
  245. 'touser' => $openid,
  246. 'template_id' => $templateId,
  247. 'url' => $url,
  248. 'data' => $data,
  249. ]);
  250. }
  251. public static function userTagService($cid = 0)
  252. {
  253. return self::application(false, $cid)->user_tag;
  254. }
  255. /**
  256. * 生成支付订单对象
  257. * @param $openid
  258. * @param $out_trade_no
  259. * @param $total_fee
  260. * @param $attach
  261. * @param $body
  262. * @param string $detail
  263. * @param string $trade_type
  264. * @param array $options
  265. * @return Order
  266. */
  267. public static function paymentOrder($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = [], $cid = 0)
  268. {
  269. $total_fee = bcmul($total_fee, 100, 0);
  270. $order = array_merge(compact('out_trade_no', 'total_fee', 'attach', 'body', 'detail', 'trade_type', 'openid'), $options);
  271. if ($order['detail'] == '') unset($order['detail']);
  272. @file_put_contents("quanju.txt", json_encode($order)."-微信支付传值\r\n", 8);
  273. $result = self::payment(false, $cid)->order->unify(
  274. $order
  275. );
  276. return $result;
  277. }
  278. /**
  279. * 使用商户订单号退款
  280. * @param $orderNo
  281. * @param $opt
  282. */
  283. public static function payOrderRefund($cid, $orderNo, array $opt)
  284. {
  285. if (!isset($opt['pay_price'])) exception('缺少pay_price');
  286. $totalFee = floatval(bcmul($opt['pay_price'], 100, 0));
  287. $refundFee = isset($opt['refund_price']) ? floatval(bcmul($opt['refund_price'], 100, 0)) : null;
  288. $refundReason = isset($opt['desc']) ? $opt['desc'] : '';
  289. $refundNo = isset($opt['refund_id']) ? $opt['refund_id'] : $orderNo;
  290. $opUserId = isset($opt['op_user_id']) ? $opt['op_user_id'] : null;
  291. $type = isset($opt['type']) ? $opt['type'] : 'out_trade_no';
  292. /*仅针对老资金流商户使用
  293. REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款)
  294. REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款*/
  295. $refundAccount = isset($opt['refund_account']) ? $opt['refund_account'] : 'REFUND_SOURCE_UNSETTLED_FUNDS';
  296. try {
  297. $res = self::payment('false', $cid)->byOutTradeNumber($orderNo, $refundNo, $totalFee, $refundFee, ['refund_desc' => $refundReason]);
  298. if ($res->return_code == 'FAIL') exception('退款失败:' . $res->return_msg);
  299. if (isset($res->err_code)) exception('退款失败:' . $res->err_code_des);
  300. } catch (\Exception $e) {
  301. exception($e->getMessage());
  302. }
  303. return true;
  304. }
  305. /**
  306. * 微信支付成功回调接口
  307. */
  308. public static function handleNotify($cid)
  309. {
  310. $response = self::payment(true, $cid)->handlePaidNotify(function ($notify, $successful) use ($cid) {
  311. if ($successful && isset($notify['out_trade_no'])) {
  312. if (isset($notify['attach']) && $notify['attach']) {
  313. if (($count = strpos($notify['out_trade_no'], '_')) !== false) {
  314. $notify['out_trade_no'] = substr($notify['out_trade_no'], $count + 1);
  315. }
  316. $params = [$cid, $notify['out_trade_no']];
  317. Hook::exec("\\liuniu\\repositories\\PaymentRepositories", "wechat" . ucfirst($notify['attach']), $params);
  318. }
  319. $data = ['eventkey' => 'notify', 'command' => '', 'refreshtime' => time(), 'openid' => $notify['openid'], 'message' => json_encode($notify)];
  320. $wechatContext = WechatContext::create($data, true);
  321. return true;
  322. }
  323. @file_put_contents("quanju.txt", json_encode($notify)."-签约返回内容\r\n", 8);
  324. // @file_put_contents("quanju.txt", json_encode($successful)."-这是什么\r\n", 8);
  325. if (isset($notify['plan_id'])) {
  326. if (isset($notify['change_type']) && $notify['change_type']) {
  327. @file_put_contents("quanju.txt", $notify['change_type']."-状态\r\n", 8);
  328. if ($notify['change_type']=='ADD'){
  329. $cs=WechatPlanRecord::where('contract_code',$notify['contract_code'])->Update(['contract_id' => $notify['contract_id']]);
  330. if (($count = strpos($notify['contract_code'], '_')) !== false) {
  331. $notify['contract_code'] = substr($notify['contract_code'], $count + 1);
  332. }
  333. $params = [$cid, $notify['contract_code']];
  334. Hook::exec("\\liuniu\\repositories\\PaymentRepositories", "wechat" . ucfirst('MonthLave'), $params);
  335. @file_put_contents("quanju.txt", json_encode($params)."-不知道行不行\r\n", 8);
  336. }elseif ($notify['change_type']=='DELETE'){
  337. @file_put_contents("quanju.txt", "-关闭签约\r\n", 8);
  338. $cs=WechatPlanRecord::where('contract_code',$notify['contract_code'])->Update(['is_signing' => 1,'deletetime'=>time()]);
  339. }
  340. @file_put_contents("quanju.txt", $cs."-修改记录\r\n", 8);
  341. }
  342. $data = ['eventkey' => 'notify', 'command' => '', 'refreshtime' => time(), 'openid' => $notify['openid'], 'message' => json_encode($notify)];
  343. $wechatContext = WechatContext::create($data, true);
  344. return true;
  345. }
  346. });
  347. $response->send();
  348. }
  349. /**
  350. * jsSdk
  351. * @return \EasyWeChat\Js\Js
  352. */
  353. public static function jsService($cid = 0)
  354. {
  355. return self::payment(false, $cid)->jssdk;
  356. }
  357. public static function WeixinJSBridge($cid, $prepayId)
  358. {
  359. $json = self::jsService($cid)->bridgeConfig($prepayId);
  360. return $json;
  361. }
  362. public static function jspay($cid, $prepayId)
  363. {
  364. $json = self::jsService($cid)->sdkConfig($prepayId);
  365. return $json;
  366. }
  367. public static function jsSdk($url = '', $cid = 0)
  368. {
  369. $apiList = ['editAddress', 'openAddress', 'updateTimelineShareData', 'updateAppMessageShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard'];
  370. $jsService = self::jsService($cid);
  371. if ($url) $jsService->setUrl($url);
  372. try {
  373. return $jsService->buildConfig($apiList, false);
  374. } catch (\Exception $e) {
  375. // var_dump($e->getMessage());
  376. return '{}';
  377. }
  378. }
  379. /**
  380. * 回复文本消息
  381. * @param string $content 文本内容
  382. * @return Text
  383. */
  384. public static function textMessage($content)
  385. {
  386. return new Text($content);
  387. }
  388. /**
  389. * 回复图片消息
  390. * @param string $media_id 媒体资源 ID
  391. * @return Image
  392. */
  393. public static function imageMessage($media_id)
  394. {
  395. return new Image('media_id');
  396. }
  397. /**
  398. * 回复视频消息
  399. * @param string $media_id 媒体资源 ID
  400. * @param string $title 标题
  401. * @param string $description 描述
  402. * @param null $thumb_media_id 封面资源 ID
  403. * @return Video
  404. */
  405. public static function videoMessage($media_id, $title = '', $description = '...', $thumb_media_id = null)
  406. {
  407. return new Video(compact('media_id', 'title', 'description', 'thumb_media_id'));
  408. }
  409. /**
  410. * 回复声音消息
  411. * @param string $media_id 媒体资源 ID
  412. * @return Voice
  413. */
  414. public static function voiceMessage($media_id)
  415. {
  416. return new Voice(compact('media_id'));
  417. }
  418. /**
  419. * 回复图文消息
  420. * @param string|array $title 标题
  421. * @param string $description 描述
  422. * @param string $url URL
  423. * @param string $image 图片链接
  424. */
  425. public static function newsMessage($title, $description = '...', $url = '', $image = '')
  426. {
  427. if (is_array($title)) {
  428. if (isset($title[0]) && is_array($title[0])) {
  429. $newsList = [];
  430. foreach ($title as $news) {
  431. $newsList[] = self::newsMessage($news);
  432. }
  433. return $newsList;
  434. } else {
  435. $data = $title;
  436. }
  437. } else {
  438. $data = compact('title', 'description', 'url', 'image');
  439. }
  440. return new News($data);
  441. }
  442. /**
  443. * 回复文章消息
  444. * @param string|array $title 标题
  445. * @param string $thumb_media_id 图文消息的封面图片素材id(必须是永久 media_ID)
  446. * @param string $source_url 图文消息的原文地址,即点击“阅读原文”后的URL
  447. * @param string $content 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS
  448. * @param string $author 作者
  449. * @param string $digest 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空
  450. * @param int $show_cover_pic 是否显示封面,0为false,即不显示,1为true,即显示
  451. * @param int $need_open_comment 是否打开评论,0不打开,1打开
  452. * @param int $only_fans_can_comment 是否粉丝才可评论,0所有人可评论,1粉丝才可评论
  453. * @return Article
  454. */
  455. public static function articleMessage($title, $thumb_media_id, $source_url, $content = '', $author = '', $digest = '', $show_cover_pic = 0, $need_open_comment = 0, $only_fans_can_comment = 1)
  456. {
  457. $data = is_array($title) ? $title : compact('title', 'thumb_media_id', 'source_url', 'content', 'author', 'digest', 'show_cover_pic', 'need_open_comment', 'only_fans_can_comment');
  458. return new Article($data);
  459. }
  460. /**
  461. * 作为客服消息发送
  462. * @param $to
  463. * @param $message
  464. * @return bool
  465. */
  466. public static function staffTo($to, $message)
  467. {
  468. $staff = self::staffService();
  469. $staff = is_callable($message) ? $staff->message($message()) : $staff->message($message);
  470. $res = $staff->to($to)->send();
  471. return $res;
  472. }
  473. /**
  474. * 获得用户信息
  475. * @param array|string $openid
  476. * @return \EasyWeChat\Support\Collection
  477. */
  478. public static function getUserInfo($cid, $openid)
  479. {
  480. $userService = self::userService($cid);
  481. $userInfo = is_array($openid) ? $userService->select($openid) : $userService->get($openid);
  482. return $userInfo;
  483. }
  484. /**
  485. * 生成支付签约订单对象
  486. * @param $openid
  487. * @param $out_trade_no
  488. * @param $total_fee
  489. * @param $attach
  490. * @param $body
  491. * @param string $detail
  492. * @param string $trade_type
  493. * @param array $options
  494. * @return Order
  495. */
  496. public static function paysignedOrder($openid, $out_trade_no, $total_fee, $attach, $body,$contract_code, $plan_id,$spbill_create_ip,$detail = '', $trade_type = 'JSAPI', $options = [], $cid = 0,$contract_display_account='')
  497. {
  498. $total_fee = bcmul($total_fee, 100, 0);
  499. $order = array_merge(compact('out_trade_no', 'total_fee', 'attach', 'body', 'detail', 'trade_type', 'openid','contract_code','plan_id','spbill_create_ip','contract_display_account'), $options);
  500. if ($order['detail'] == '') unset($order['detail']);
  501. $order['contract_notify_url']=Request::instance()->domain() . "/api/wechat/notify/" . $cid;
  502. $result = self::payment(false, $cid)->order->unify(
  503. $order,true
  504. );
  505. // var_dump($result);die();
  506. @file_put_contents("quanju.txt", json_encode($result) . "-签约返回结果\r\n", 8);
  507. return $result;
  508. }
  509. /**
  510. * 签约申请扣款
  511. * @param $openid
  512. * @param $out_trade_no
  513. * @param $total_fee
  514. * @param $attach
  515. * @param $body
  516. * @param string $detail
  517. * @param string $trade_type
  518. * @param array $options
  519. * @return Order
  520. */
  521. public static function papPayApply($mch_id,$out_trade_no, $total_fee, $attach, $detail = '', $trade_type = 'PAP', $options = [], $cid = 0,$contract_id='',$body='月捐款')
  522. {
  523. $total_fee = bcmul($total_fee, 100, 0);
  524. $order = array_merge(compact('mch_id','out_trade_no', 'total_fee', 'attach', 'detail', 'trade_type','contract_id','body'), $options);
  525. if ($order['detail'] == '') unset($order['detail']);
  526. // $order['notify_url']=Request::instance()->domain() . "/api/wechat/notify/" . $cid;
  527. $result = self::payment(false, $cid)->contract->apply(
  528. $order
  529. );
  530. var_dump($result);die();
  531. return $result;
  532. }
  533. /**
  534. * 解除签约
  535. */
  536. public static function deleteSign($mch_id,$contract_code,$plan_id,$version='1.0',$options=[],$cid=0)
  537. {
  538. $contract_termination_remark = '月捐款解约';
  539. $order = array_merge(compact('mch_id','contract_code','plan_id','version','contract_termination_remark'), $options);
  540. // if ($order['detail'] == '') unset($order['detail']);
  541. // $order['notify_url']=Request::instance()->domain() . "/api/wechat/notify/" . $cid;
  542. $result = self::payment(false, $cid)->contract->delete(
  543. $order
  544. );
  545. return $result;
  546. }
  547. /**
  548. * 查询签约
  549. */
  550. public static function querySign($mch_id,$contract_code,$pan_id,$version='1.0',$options=[],$cid=0)
  551. {
  552. $appid='wx5681205d1ef4d9d3';
  553. $order = array_merge(compact('appid','mch_id','contract_code','pan_id','version'), $options);
  554. // if ($order['detail'] == '') unset($order['detail']);
  555. // $order['notify_url']=Request::instance()->domain() . "/api/wechat/notify/" . $cid;
  556. $result = self::payment(false, $cid)->contract->query(
  557. $order
  558. );
  559. @file_put_contents("quanju.txt", json_encode($result) . "-查询签约状态返回结果\r\n", 8);
  560. return $result;
  561. }
  562. }