mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
fix: 修改小程序支付管理回调和获取微信物流公司编码bug
This commit is contained in:
parent
152aae1a64
commit
57267ac20d
@ -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小时未发货时
|
||||
|
||||
@ -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':
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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] ?? '';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user