From 57267ac20dc6df3c2a28d0c7f5c1a763fa00f270 Mon Sep 17 00:00:00 2001 From: Gosowong <1329847115@qq.com> Date: Thu, 15 Jun 2023 17:40:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=94=AF=E4=BB=98=E7=AE=A1=E7=90=86=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=92=8C=E8=8E=B7=E5=8F=96=E5=BE=AE=E4=BF=A1=E7=89=A9=E6=B5=81?= =?UTF-8?q?=E5=85=AC=E5=8F=B8=E7=BC=96=E7=A0=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crmeb/services/app/MiniProgramService.php | 31 +++++++++ crmeb/crmeb/services/app/WechatService.php | 29 -------- .../easywechat/orderShipping/BaseOrder.php | 67 ------------------- .../easywechat/orderShipping/OrderClient.php | 7 +- 4 files changed, 33 insertions(+), 101 deletions(-) diff --git a/crmeb/crmeb/services/app/MiniProgramService.php b/crmeb/crmeb/services/app/MiniProgramService.php index 0698d8300..456f1b693 100644 --- a/crmeb/crmeb/services/app/MiniProgramService.php +++ b/crmeb/crmeb/services/app/MiniProgramService.php @@ -12,12 +12,14 @@ namespace crmeb\services\app; use app\services\order\StoreOrderTakeServices; +use app\services\pay\PayServices; use crmeb\exceptions\AdminException; use crmeb\services\easywechat\orderShipping\MiniOrderService; use crmeb\services\SystemConfigService; use app\services\pay\PayNotifyServices; use crmeb\services\easywechat\Application; use EasyWeChat\Payment\Order; +use think\facade\Event; use think\facade\Log; use crmeb\utils\Hook; use think\facade\Cache; @@ -876,6 +878,35 @@ class MiniProgramService switch ($message->MsgType) { case 'event': switch (strtolower($message->Event)) { + case 'funds_order_pay': // 小程序支付管理的 + if (($count = strpos($message['order_info']['trade_no'], '_')) !== false) { + $trade_no = substr($message['order_info']['trade_no'], $count + 1); + } else { + $trade_no = $message['order_info']['trade_no']; + } + $prefix = substr($trade_no, 0, 2); + //处理一下参数 + switch ($prefix) { + case 'cp': + $data['attach'] = 'Product'; + break; + case 'hy': + $data['attach'] = 'Member'; + break; + case 'cz': + $data['attach'] = 'UserRecharge'; + break; + } + $data['out_trade_no'] = $message['order_info']['trade_no']; + $data['transaction_id'] = $message['order_info']['transaction_id']; + $data['opneid'] = $message['FromUserName']; + if (Event::until('NotifyListener', [$data, PayServices::WEIXIN_PAY])) { + $response = 'success'; + } else { + $response = 'faild'; + } + Log::error(['data' => $data, 'res' => $response, 'message' => $message]); + break; case 'trade_manage_remind_access_api': // 小程序完成账期授权时 小程序产生第一笔交易时 已产生交易但从未发货的小程序,每天一次 break; case 'trade_manage_remind_shipping': // 曾经发过货的小程序,订单超过48小时未发货时 diff --git a/crmeb/crmeb/services/app/WechatService.php b/crmeb/crmeb/services/app/WechatService.php index 76a24c935..8aaaa378a 100644 --- a/crmeb/crmeb/services/app/WechatService.php +++ b/crmeb/crmeb/services/app/WechatService.php @@ -143,35 +143,6 @@ class WechatService case 'view': $response = $messageService->wechatEventView($message); break; - case 'funds_order_pay': - if (($count = strpos($message['order_info']['trade_no'], '_')) !== false) { - $trade_no = substr($message['order_info']['trade_no'], $count + 1); - } else { - $trade_no = $message['order_info']['trade_no']; - } - $prefix = substr($trade_no, 0, 2); - //处理一下参数 - switch ($prefix) { - case 'cp': - $data['attach'] = 'Product'; - break; - case 'hy': - $data['attach'] = 'Member'; - break; - case 'cz': - $data['attach'] = 'UserRecharge'; - break; - } - $data['out_trade_no'] = $message['order_info']['trade_no']; - $data['transaction_id'] = $message['order_info']['transaction_id']; - $data['opneid'] = $message['FromUserName']; - if (Event::until('NotifyListener', [$data, PayServices::WEIXIN_PAY])) { - $response = 'success'; - } else { - $response = 'faild'; - } - Log::error(['data' => $data, 'res' => $response, 'message' => $message]); - break; } break; case 'text': diff --git a/crmeb/crmeb/services/easywechat/orderShipping/BaseOrder.php b/crmeb/crmeb/services/easywechat/orderShipping/BaseOrder.php index def23811c..fd6e81f2d 100644 --- a/crmeb/crmeb/services/easywechat/orderShipping/BaseOrder.php +++ b/crmeb/crmeb/services/easywechat/orderShipping/BaseOrder.php @@ -42,73 +42,6 @@ class BaseOrder extends AbstractAPI } } - - /** - * request. - * - * @param string $endpoint - * @param string $method - * @param array $options - * @param bool $returnResponse - */ - public function request(string $method, string $endpoint, array $options = []) - { - - if (isset($options['json'])) { - $body = json_encode($options['json']); - $options['body'] = $body; - unset($options['json']); - } - - $headers = [ - 'Content-Type' => 'text/plain', - 'User-Agent' => 'curl', - 'Accept' => 'text/plain', - ]; - - $options['headers'] = array_merge($headers, ($options['headers'] ?? [])); - - - return $this->_doRequestCurl($method, self::BASE_API . $endpoint, $options); - } - - /** - * @param $method - * @param $location - * @param array $options - * @return mixed - */ - private function _doRequestCurl($method, $location, $options = []) - { - //拼接$accessToken - $location .= $this->accessToken->getToken(); - var_dump($location); - $curl = curl_init(); - // POST数据设置 - if (strtolower($method) === 'post') { - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $options['data'] ?? $options['body'] ?? ''); - } - // CURL头信息设置 - if (!empty($options['headers'])) { - $headers = []; - foreach ($options['headers'] as $k => $v) { - $headers[] = "$k: $v"; - } - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - } - curl_setopt($curl, CURLOPT_URL, $location); - curl_setopt($curl, CURLOPT_HEADER, true); - curl_setopt($curl, CURLOPT_TIMEOUT, 60); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - $content = curl_exec($curl); - $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); - curl_close($curl); - return json_decode(substr($content, $headerSize), true); - } - /** * 发货 * @param $params diff --git a/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php b/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php index ef226a651..a5910585b 100644 --- a/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php +++ b/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php @@ -102,7 +102,7 @@ class OrderClient extends BaseOrder ]; } // 跳转路径 -// $this->setMesJumpPath($path); + $this->setMesJumpPath($path); return $this->shipping($params); } @@ -277,10 +277,7 @@ class OrderClient extends BaseOrder $key = self::redis_prefix . '_delivery_list'; if (!$this->getRedis()->exists($key)) { $date = $this->setDeliveryList(); - if (!isset($date[$company_name])) { -// throw new AdminException('物流公司异常1'); - } - $express_company = $date[$company_name]; + $express_company = $date[$company_name] ?? ''; } else { $express_company = $this->getRedis()->hMGet($key, [$company_name])[$company_name] ?? ''; }