|
@@ -70,6 +70,7 @@ class Payios extends Api
|
|
|
}
|
|
|
|
|
|
//vip,苹果内购支付回调
|
|
|
+ //因前端不传入订单号,作废,且与gold_notify_iosnew 已完成合并
|
|
|
public function vip_notify_ios(){
|
|
|
|
|
|
//苹果内购的验证收据
|
|
@@ -106,7 +107,7 @@ class Payios extends Api
|
|
|
$args = json_decode($order_info['args'],true);
|
|
|
if ($result['data']['receipt']['in_app'][$use_count]['product_id'] != $order_info['bundle_id']) {
|
|
|
Db::rollback();
|
|
|
- filePut('VIP ios充值:非法请求,请立刻停止out_trade_no='.$order_no.','.$result['message'].','.$result['data']['receipt']['in_app'][$use_count]['product_id'].'!='.$args['bundle_id']);
|
|
|
+ filePut('VIP ios充值:非法请求,请立刻停止out_trade_no='.$order_no.','.$result['message'].','.$result['data']['receipt']['in_app'][$use_count]['product_id'].'!='.$order_info['bundle_id']);
|
|
|
$this->error('非法请求,请立刻停止');
|
|
|
}
|
|
|
|
|
@@ -217,12 +218,12 @@ class Payios extends Api
|
|
|
$this->error('缺少参数');
|
|
|
}
|
|
|
filePut("\r\n\r\n");
|
|
|
- filePut('金币 ios充值:参数apple_receipt['.$receipt_data.']');
|
|
|
+ filePut('ios充值:参数apple_receipt['.$receipt_data.']');
|
|
|
|
|
|
// 验证支付状态
|
|
|
$result = $this->validate_apple_pay($receipt_data);
|
|
|
if (!$result['status']) {// 验证不通过
|
|
|
- filePut('金币 ios充值:验证'.$result['message']);
|
|
|
+ filePut('ios充值:验证'.$result['message']);
|
|
|
$this->error($result['message']);
|
|
|
}
|
|
|
|
|
@@ -241,7 +242,7 @@ class Payios extends Api
|
|
|
];
|
|
|
$order_check = Db::name('pay_order')->where($order_map)->find();
|
|
|
if (!empty($order_check)) {
|
|
|
- filePut('金币 ios充值:检查到out_trade_no='.$order_check['out_trade_no'].',订单已支付,不需要重复');
|
|
|
+ filePut('ios充值:检查到out_trade_no='.$order_check['out_trade_no'].',订单已支付,不需要重复');
|
|
|
$this->success('充值完成');
|
|
|
}
|
|
|
|
|
@@ -255,35 +256,60 @@ class Payios extends Api
|
|
|
$order_info = Db::name('pay_order')->where($order_map)->order('id desc')->lock(true)->find();
|
|
|
if (!$order_info) {
|
|
|
Db::rollback();
|
|
|
- filePut('金币 ios充值:订单不存在order_map='.json_encode($order_map));
|
|
|
+ filePut('ios充值:订单不存在order_map='.json_encode($order_map));
|
|
|
$this->error('订单不存在');
|
|
|
}
|
|
|
$args = json_decode($order_info['args'],true);
|
|
|
|
|
|
//逻辑开始
|
|
|
//先充值
|
|
|
- $result = model('Wallet')->lockChangeAccountRemain($order_info['user_id'],'gold',$args['gold'],10, '金币充值','pay_order',$order_info['id']);
|
|
|
- if($result['status']===false)
|
|
|
- {
|
|
|
- filePut('金币 ios充值:逻辑开始out_trade_no='.$order_info['out_trade_no'].',逻辑添加金币失败');
|
|
|
- Db::rollback();
|
|
|
- $this->error('充值失败');
|
|
|
+ if($order_info['table_name'] == 'gold_recharge'){
|
|
|
+ $result = model('Wallet')->lockChangeAccountRemain($order_info['user_id'],'gold',$args['gold'],10, '金币充值','pay_order',$order_info['id']);
|
|
|
+ if($result['status']===false)
|
|
|
+ {
|
|
|
+ filePut('ios充值:逻辑开始out_trade_no='.$order_info['out_trade_no'].',逻辑添加金币失败');
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('充值失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //先充值
|
|
|
+ if($order_info['table_name'] == 'vip_recharge'){
|
|
|
+ $user_info = Db::name('user_wallet')->where('user_id',$order_info['user_id'])->lock(true)->find();
|
|
|
+ if($user_info['vip_endtime'] < time()){
|
|
|
+ //过期了
|
|
|
+ $vip_endtime = time() + (intval($args['days']) * 86400);
|
|
|
+ }else{
|
|
|
+ //追加vip
|
|
|
+ $vip_endtime = $user_info['vip_endtime'] + (intval($args['days']) * 86400);
|
|
|
+ }
|
|
|
+ $update_data = [
|
|
|
+ 'vip_endtime'=>$vip_endtime,
|
|
|
+ ];
|
|
|
+ $result = Db::name('user_wallet')->where('user_id',$order_info['user_id'])->update($update_data);
|
|
|
+ if($result === false)
|
|
|
+ {
|
|
|
+ filePut('ios充值:逻辑开始out_trade_no='.$order_info['out_trade_no'].',逻辑续费vip时间失败');
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('充值失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 修改订单状态
|
|
|
$ros = Db::name('pay_order')->where(['id' => $order_info['id']])->update(['order_status'=>1,'transaction_id' => $transaction_id,'notifytime'=>time()]);
|
|
|
if($ros === false) {
|
|
|
- filePut('金币 ios充值:订单修改out_trade_no='.$order_info['out_trade_no'].',修改订单状态失败');
|
|
|
+ filePut('ios充值:订单修改out_trade_no='.$order_info['out_trade_no'].',修改订单状态失败');
|
|
|
Db::rollback();
|
|
|
$this->error('充值失败');
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
|
- filePut('金币 ios充值:逻辑结束out_trade_no='.$order_info['out_trade_no'].',订单完成');
|
|
|
+ filePut('ios充值:逻辑结束out_trade_no='.$order_info['out_trade_no'].',订单完成');
|
|
|
$this->success('充值成功');
|
|
|
|
|
|
//逻辑结束
|
|
|
}
|
|
|
+
|
|
|
+ //因前端不传入订单号,作废
|
|
|
public function gold_notify_ios(){
|
|
|
|
|
|
//苹果内购的验证收据
|