commit
a944304865
@ -20,9 +20,7 @@ class ExceptionHandler extends Handler
|
||||
{
|
||||
if ($exception instanceof Dumper) {
|
||||
return \response(self::convertToHtml($exception));
|
||||
} elseif ($exception instanceof ErrorException) {
|
||||
return response($exception->getMessage(), 401);
|
||||
} elseif ($exception instanceof BusinessException) {
|
||||
}elseif ($exception instanceof BusinessException) {
|
||||
return response($exception->getMessage());
|
||||
} elseif ($exception instanceof \Exception) {
|
||||
$isDebug = config('app.debug');
|
||||
|
@ -292,6 +292,7 @@ class OrderController extends BaseApiController
|
||||
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
|
||||
} 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']]);
|
||||
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()
|
||||
{
|
||||
parent::__construct();
|
||||
$ip = \request()->getLocalIp();
|
||||
$ip = \request()->getRealIp();
|
||||
$this->key = $this->tagName . $ip;
|
||||
}
|
||||
|
||||
|
@ -280,6 +280,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -461,12 +465,12 @@ class PayNotifyLogic extends BaseLogic
|
||||
$uid = $order['other_uid'];
|
||||
}
|
||||
|
||||
|
||||
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]]);
|
||||
if (!empty($extra['payer']['openid'])) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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\SystemStoreStaff;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\service\pay\PayService;
|
||||
use app\store\validate\store_order\StoreOrderValidate;
|
||||
use support\Cache;
|
||||
use support\Log;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use Webman\RedisQueue\Redis;
|
||||
|
||||
/**
|
||||
@ -246,6 +248,7 @@ class StoreOrderController extends BaseAdminController
|
||||
Log::error(json_encode($result));
|
||||
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
||||
} 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']]);
|
||||
return $this->success('用户支付中');
|
||||
}
|
||||
@ -318,6 +321,7 @@ class StoreOrderController extends BaseAdminController
|
||||
PayNotifyLogic::handle('wechat_common', $result['out_trade_no'], $result);
|
||||
} else {
|
||||
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('支付成功', ['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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @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' => [
|
||||
runtime_path() . '/logs/'.date('Ym').'/.log',
|
||||
2048,
|
||||
Monolog\Logger::NOTICE,
|
||||
Monolog\Logger::INFO,
|
||||
true,
|
||||
0755
|
||||
],
|
||||
|
@ -63,27 +63,27 @@ class Task
|
||||
}
|
||||
});
|
||||
//每10秒执行一次
|
||||
// new Crontab('*/10 * * * * *', function () {
|
||||
// $select=Db::name('wechat_micropay')->limit(100)->select();
|
||||
// $pay = new PayService();
|
||||
// foreach ($select as $k=>$v) {
|
||||
// $time = time();
|
||||
// if ($time - $v['create_time'] > 60){
|
||||
// Db::name('wechat_micropay')->where('id',$v['id'])->delete();
|
||||
// continue;
|
||||
// }
|
||||
// $order = [
|
||||
// 'out_trade_no' => $v['order_id'],
|
||||
// ];
|
||||
// $res = $pay->wechat->query($order);
|
||||
// if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
||||
// if(isset($data['pay_type']) && $data['pay_type']=='recharge'){
|
||||
// PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
||||
// }else{
|
||||
// PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
new Crontab('*/10 * * * * *', function () {
|
||||
$select=Db::name('wechat_micropay')->limit(100)->select();
|
||||
$pay = new PayService();
|
||||
foreach ($select as $k=>$v) {
|
||||
$time = time();
|
||||
if ($time - $v['create_time'] > 60){
|
||||
Db::name('wechat_micropay')->where('id',$v['id'])->delete();
|
||||
continue;
|
||||
}
|
||||
$order = [
|
||||
'out_trade_no' => $v['order_id'],
|
||||
];
|
||||
$res = $pay->wechat->query($order);
|
||||
if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') {
|
||||
if(isset($data['pay_type']) && $data['pay_type']=='recharge'){
|
||||
PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res);
|
||||
}else{
|
||||
PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user