commit
a944304865
@ -20,9 +20,7 @@ class ExceptionHandler extends Handler
|
|||||||
{
|
{
|
||||||
if ($exception instanceof Dumper) {
|
if ($exception instanceof Dumper) {
|
||||||
return \response(self::convertToHtml($exception));
|
return \response(self::convertToHtml($exception));
|
||||||
} elseif ($exception instanceof ErrorException) {
|
}elseif ($exception instanceof BusinessException) {
|
||||||
return response($exception->getMessage(), 401);
|
|
||||||
} elseif ($exception instanceof BusinessException) {
|
|
||||||
return response($exception->getMessage());
|
return response($exception->getMessage());
|
||||||
} elseif ($exception instanceof \Exception) {
|
} elseif ($exception instanceof \Exception) {
|
||||||
$isDebug = config('app.debug');
|
$isDebug = config('app.debug');
|
||||||
|
@ -292,6 +292,7 @@ class OrderController extends BaseApiController
|
|||||||
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||||
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
||||||
} else {
|
} else {
|
||||||
|
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||||
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
|
2
app/common/cache/UserAccountSafeCache.php
vendored
2
app/common/cache/UserAccountSafeCache.php
vendored
@ -20,7 +20,7 @@ class UserAccountSafeCache extends BaseCache
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$ip = \request()->getLocalIp();
|
$ip = \request()->getRealIp();
|
||||||
$this->key = $this->tagName . $ip;
|
$this->key = $this->tagName . $ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +280,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
||||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
||||||
}
|
}
|
||||||
|
if($order['pay_type']==9){
|
||||||
|
Db::name('wechat_micropay')->where(['order_id'=>$order['order_id']])->delete();
|
||||||
|
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,12 +465,12 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$uid = $order['other_uid'];
|
$uid = $order['other_uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||||
if (!empty($extra['payer']['openid'])) {
|
if (!empty($extra['payer']['openid'])) {
|
||||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
|
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
|
||||||
}
|
}
|
||||||
|
Db::name('wechat_micropay')->where(['order_id'=>$order['order_id']])->delete();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,12 @@ use app\common\model\store_product_unit\StoreProductUnit;
|
|||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
use app\common\model\system_store\SystemStoreStaff;
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
use app\common\model\user_recharge\UserRecharge;
|
use app\common\model\user_recharge\UserRecharge;
|
||||||
|
use app\common\service\pay\PayService;
|
||||||
use app\store\validate\store_order\StoreOrderValidate;
|
use app\store\validate\store_order\StoreOrderValidate;
|
||||||
use support\Cache;
|
use support\Cache;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
|
use think\facade\Db;
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,6 +248,7 @@ class StoreOrderController extends BaseAdminController
|
|||||||
Log::error(json_encode($result));
|
Log::error(json_encode($result));
|
||||||
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
||||||
} else {
|
} else {
|
||||||
|
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||||
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
@ -318,6 +321,7 @@ class StoreOrderController extends BaseAdminController
|
|||||||
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
||||||
} else {
|
} else {
|
||||||
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
|
||||||
|
Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]);
|
||||||
return $this->success('用户支付中');
|
return $this->success('用户支付中');
|
||||||
}
|
}
|
||||||
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]);
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]);
|
||||||
@ -501,4 +505,41 @@ class StoreOrderController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
return $this->success('获取成功', $find?->toArray());
|
return $this->success('获取成功', $find?->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 查询订单支付状态
|
||||||
|
*/
|
||||||
|
public function wechatQuery()
|
||||||
|
{
|
||||||
|
$order_no = $this->request->get('order_no');
|
||||||
|
$order = [
|
||||||
|
'out_trade_no' => $order_no,
|
||||||
|
];
|
||||||
|
$app = new PayService(0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$res = $app->wechat->query($order);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->fail($e->extra['message'] ?? $e->getMessage());
|
||||||
|
}
|
||||||
|
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
||||||
|
$attach = $res['attach'];
|
||||||
|
switch ($attach) {
|
||||||
|
case 'recharge':
|
||||||
|
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
||||||
|
$app->wechat->success();
|
||||||
|
break;
|
||||||
|
case 'wechat_common':
|
||||||
|
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||||
|
$app->wechat->success();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log::error('支付回调失败,订单号:' . $res['out_trade_no'], $res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $this->success('支付成功');
|
||||||
|
} else {
|
||||||
|
return $this->fail('订单支付中');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ return [
|
|||||||
'constructor' => [
|
'constructor' => [
|
||||||
runtime_path() . '/logs/'.date('Ym').'/.log',
|
runtime_path() . '/logs/'.date('Ym').'/.log',
|
||||||
2048,
|
2048,
|
||||||
Monolog\Logger::NOTICE,
|
Monolog\Logger::INFO,
|
||||||
true,
|
true,
|
||||||
0755
|
0755
|
||||||
],
|
],
|
||||||
|
@ -63,27 +63,27 @@ class Task
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//每10秒执行一次
|
//每10秒执行一次
|
||||||
// new Crontab('*/10 * * * * *', function () {
|
new Crontab('*/10 * * * * *', function () {
|
||||||
// $select=Db::name('wechat_micropay')->limit(100)->select();
|
$select=Db::name('wechat_micropay')->limit(100)->select();
|
||||||
// $pay = new PayService();
|
$pay = new PayService();
|
||||||
// foreach ($select as $k=>$v) {
|
foreach ($select as $k=>$v) {
|
||||||
// $time = time();
|
$time = time();
|
||||||
// if ($time - $v['create_time'] > 60){
|
if ($time - $v['create_time'] > 60){
|
||||||
// Db::name('wechat_micropay')->where('id',$v['id'])->delete();
|
Db::name('wechat_micropay')->where('id',$v['id'])->delete();
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// $order = [
|
$order = [
|
||||||
// 'out_trade_no' => $v['order_id'],
|
'out_trade_no' => $v['order_id'],
|
||||||
// ];
|
];
|
||||||
// $res = $pay->wechat->query($order);
|
$res = $pay->wechat->query($order);
|
||||||
// if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
||||||
// if(isset($data['pay_type']) && $data['pay_type']=='recharge'){
|
if(isset($data['pay_type']) && $data['pay_type']=='recharge'){
|
||||||
// PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
||||||
// }else{
|
}else{
|
||||||
// PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user