mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-11-12 13:43:44 +08:00
优化收银台API逻辑,后台新增监听模式功能
This commit is contained in:
@@ -109,9 +109,11 @@ class PayController
|
||||
if ($order_id) {
|
||||
$act_order = Order::where('order_id', $order_id)->find();
|
||||
if ($act_order) {
|
||||
$passtime = strtotime($act_order->close_time) - time();
|
||||
$data = [];
|
||||
if ($act_order->state === 0) {
|
||||
$data['order_id'] = $act_order->order_id;
|
||||
$data['passtime'] = $passtime > 0 ? $passtime : 0;
|
||||
$data['state'] = $act_order->state;
|
||||
return json($data);
|
||||
} elseif ($act_order->state === 1) {
|
||||
@@ -125,6 +127,7 @@ class PayController
|
||||
$res_return_url = $act_order->return_url . '?' . http_build_query($notify);
|
||||
// 响应消息
|
||||
$data['order_id'] = $act_order->order_id;
|
||||
$data['passtime'] = $passtime > 0 ? $passtime : 0;
|
||||
$data['state'] = $act_order->state;
|
||||
$data['return_url'] = $res_return_url;
|
||||
return json($data);
|
||||
@@ -245,21 +248,19 @@ class PayController
|
||||
// 检测本账号订单
|
||||
$orders = [];
|
||||
foreach ($order_list as $key => $val) {
|
||||
if ($pid == $val['pid'] && $aid == $val['aid']) {
|
||||
if ($pid == $val['pid'] && $aid == $val['aid'] && $val['patt'] == 1) {
|
||||
$orders[] = $order_list[$key];
|
||||
}
|
||||
}
|
||||
if (!$orders) {
|
||||
return \json(['code' => 0, 'msg' => '非本账号订单']);
|
||||
}
|
||||
// 收款平台
|
||||
$platform = ['sqbpay' => 'ShouQianBa', 'storepay' => 'ZhiHuiJingYing', 'mqpay' => 'MaQian', 'ysepay' => 'Ysepay'];
|
||||
// 登陆账号
|
||||
$config = ['username' => $pay_config['account'], 'password' => $pay_config['password']];
|
||||
// 收款查询
|
||||
$query = $pay_config['query'];
|
||||
// 实例监听客户端
|
||||
$payclient_name = $platform[$pay_config['platform']];
|
||||
$payclient_name = $pay_config['payclass'];
|
||||
$payclient_path = "\\payclient\\{$payclient_name}";
|
||||
$Payclient = new $payclient_path($config);
|
||||
// 获取支付明细
|
||||
@@ -281,7 +282,7 @@ class PayController
|
||||
$is_user = User::checkUser($pid, $sign);
|
||||
$path = '../runtime/order.json';
|
||||
if ($is_user) {
|
||||
$orders = Order::scope('activeOrder')->field('id,pid,aid,cid')->select();
|
||||
$orders = Order::scope('activeOrder')->field('id,pid,aid,cid,patt')->select();
|
||||
if (!file_exists($path)) {
|
||||
file_put_contents($path, '[]');
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ class PayManageController extends BaseController
|
||||
'platform' => $acc->getData('platform'),
|
||||
'account' => $acc->account,
|
||||
'password' => $acc->password,
|
||||
'payclass' => $platform->class_name,
|
||||
'query' => \var_export($query, \true)
|
||||
];
|
||||
$config = View::fetch('tpl/account_config', $data);
|
||||
|
||||
@@ -44,6 +44,8 @@ class Order extends BaseModel
|
||||
'param' => serialize(self::getParams($data)),
|
||||
// 等待/过期:0, 支付成功:1
|
||||
'state' => 0,
|
||||
// 开启监听:1, 关闭监听:0
|
||||
'patt' => $channel['patt'],
|
||||
// 订单创建时间
|
||||
'create_time' => self::getFormatTime($my_time),
|
||||
// 订单关闭时间
|
||||
@@ -109,9 +111,6 @@ class Order extends BaseModel
|
||||
$order->qrcode = $a_list->payChannel[0]->qrcode ?? '···';
|
||||
return $order->toArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 选择收款通道
|
||||
private static function setChannel($pid): array
|
||||
{
|
||||
@@ -120,7 +119,8 @@ class Order extends BaseModel
|
||||
if (!$channel_info || !$aids) {
|
||||
return [];
|
||||
}
|
||||
$channel = ['aid' => $channel_info->account_id, 'cid' => $channel_info->id];
|
||||
$patt = PayAccount::find($channel_info->account_id);
|
||||
$channel = ['aid' => $channel_info->account_id, 'cid' => $channel_info->id, 'patt' => $patt->pattern];
|
||||
PayChannel::update(['last_time' => self::getFormatTime(), 'id' => $channel['cid']]);
|
||||
return $channel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user