Merge pull request 'dev' (#66) from dev into rose

Reviewed-on: #66
This commit is contained in:
mkm 2024-07-30 10:26:53 +08:00
commit 27f424be34
2 changed files with 30 additions and 2 deletions

View File

@ -16,6 +16,7 @@ use app\common\model\store_order\StoreOrder;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
use think\facade\Db;
use Webman\RedisQueue\Redis;
class OrderController extends BaseApiController
@ -181,7 +182,8 @@ class OrderController extends BaseApiController
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result);
} else {
Redis::send('send-code-pay', ['number' => $order['number']]);
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('用户支付中');
}
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
@ -290,7 +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 {
Redis::send('send-code-pay', ['number' => $order['number']]);
Redis::send('send-code-pay', ['order_id' => $order['order_id']]);
return $this->success('用户支付中');
}
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);

View File

@ -2,13 +2,16 @@
namespace process;
use app\common\logic\PayNotifyLogic;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use app\common\model\user_recharge\UserRecharge;
use think\facade\Db;
use Webman\RedisQueue\Redis;
use Workerman\Crontab\Crontab;
use app\common\service\pay\PayService;
class Task
{
@ -58,5 +61,28 @@ class Task
Redis::send('task-recharge-query', ['order_id' => $v]);
}
});
//每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);
// }
// }
// }
// });
}
}