|
@@ -70,82 +70,6 @@ class Payios extends Api
|
|
$this->success('success',$data['out_trade_no']);
|
|
$this->success('success',$data['out_trade_no']);
|
|
}
|
|
}
|
|
|
|
|
|
- //vip,苹果内购支付回调
|
|
|
|
- //因前端不传入订单号,作废,且与gold_notify_iosnew 已完成合并
|
|
|
|
- public function vip_notify_ios(){
|
|
|
|
-
|
|
|
|
- //苹果内购的验证收据
|
|
|
|
- $receipt_data = input('apple_receipt', '', 'trim');
|
|
|
|
- $order_no = input('order_no', '', 'trim');
|
|
|
|
- filePut('VIP ios充值:参数apple_receipt='.$receipt_data.',order_no='.$order_no);
|
|
|
|
- if (!$receipt_data || !$order_no) {
|
|
|
|
- $this->error('缺少参数');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Db::startTrans();
|
|
|
|
- // 查找订单
|
|
|
|
- $order_info = Db::name('pay_order')->where(['out_trade_no' => $order_no])->lock(true)->find();
|
|
|
|
- if (!$order_info) {
|
|
|
|
- Db::rollback();
|
|
|
|
- filePut('VIP ios充值:订单丢失out_trade_no='.$order_no);
|
|
|
|
- $this->error('订单丢失');
|
|
|
|
- }
|
|
|
|
- if ($order_info['order_status'] == 1) {
|
|
|
|
- Db::rollback();
|
|
|
|
- $this->success('充值成功');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 验证支付状态
|
|
|
|
- $result = $this->validate_apple_pay($receipt_data);
|
|
|
|
- if (!$result['status']) {// 验证不通过
|
|
|
|
- Db::rollback();
|
|
|
|
- filePut('VIP ios充值:验证out_trade_no='.$order_no.','.$result['message']);
|
|
|
|
- $this->error($result['message']);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $count = count($result['data']['receipt']['in_app']);
|
|
|
|
- $use_count = $count - 1;
|
|
|
|
- $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'].'!='.$order_info['bundle_id']);
|
|
|
|
- $this->error('非法请求,请立刻停止');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //逻辑开始
|
|
|
|
- //先充值
|
|
|
|
- $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)
|
|
|
|
- {
|
|
|
|
- Db::rollback();
|
|
|
|
- filePut('VIP ios充值:验证out_trade_no='.$order_no.',逻辑续费vip时间失败');
|
|
|
|
- $this->error('充值失败');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 修改订单状态
|
|
|
|
- $ros = Db::name('pay_order')->where(['out_trade_no' => $order_no])->update(['order_status'=>1,'notifytime'=>time()]);
|
|
|
|
- if($ros === false) {
|
|
|
|
- filePut('VIP ios充值:充值失败out_trade_no='.$order_no.','.$result['message'].','.'修改订单状态失败');
|
|
|
|
- Db::rollback();
|
|
|
|
- $this->error('充值失败');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Db::commit();
|
|
|
|
- $this->success('充值成功');
|
|
|
|
-
|
|
|
|
- //逻辑结束
|
|
|
|
- }
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
////////////////////////////////
|
|
|
|
|
|
@@ -210,6 +134,8 @@ class Payios extends Api
|
|
$this->success('success',$data['out_trade_no']);
|
|
$this->success('success',$data['out_trade_no']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+////////////////////////////////////////
|
|
|
|
+
|
|
//订阅信息处理,续订情况下,单独分支方法
|
|
//订阅信息处理,续订情况下,单独分支方法
|
|
public function expires(){
|
|
public function expires(){
|
|
|
|
|
|
@@ -542,80 +468,15 @@ class Payios extends Api
|
|
//逻辑结束
|
|
//逻辑结束
|
|
}
|
|
}
|
|
|
|
|
|
- //因前端不传入订单号,作废
|
|
|
|
- public function gold_notify_ios(){
|
|
|
|
-
|
|
|
|
- //苹果内购的验证收据
|
|
|
|
-
|
|
|
|
- $receipt_data = input('apple_receipt', '', 'trim');
|
|
|
|
- $order_no = input('order_no', '', 'trim');
|
|
|
|
- filePut('金币 ios充值:参数apple_receipt='.$receipt_data.',order_no='.$order_no);
|
|
|
|
- if (!$receipt_data || !$order_no) {
|
|
|
|
- $this->error('缺少参数');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Db::startTrans();
|
|
|
|
- // 查找订单
|
|
|
|
- $order_info = Db::name('pay_order')->where(['out_trade_no' => $order_no])->lock(true)->find();
|
|
|
|
- if (!$order_info) {
|
|
|
|
- Db::rollback();
|
|
|
|
- filePut('金币 ios充值:订单丢失out_trade_no='.$order_no);
|
|
|
|
- $this->error('订单丢失');
|
|
|
|
- }
|
|
|
|
- if ($order_info['order_status'] == 1) {
|
|
|
|
- Db::rollback();
|
|
|
|
- $this->success('充值成功');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 验证支付状态
|
|
|
|
- $result = $this->validate_apple_pay($receipt_data);
|
|
|
|
- if (!$result['status']) {// 验证不通过
|
|
|
|
- Db::rollback();
|
|
|
|
- filePut('金币 ios充值:验证out_trade_no='.$order_no.','.$result['message']);
|
|
|
|
- $this->error($result['message']);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $count = count($result['data']['receipt']['in_app']);
|
|
|
|
- $use_count = $count - 1;
|
|
|
|
- $args = json_decode($order_info['args'],true);
|
|
|
|
- if ($result['data']['receipt']['in_app'][$use_count]['product_id'] != $order_info['bundle_id']) {
|
|
|
|
- Db::rollback();
|
|
|
|
- filePut('金币 ios充值:非法请求,请立刻停止out_trade_no='.$order_no.','.$result['message'].','.$result['data']['receipt']['in_app'][$use_count]['product_id'].'!='.$order_info['bundle_id']);
|
|
|
|
- $this->error('非法请求,请立刻停止');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //逻辑开始
|
|
|
|
- //先充值
|
|
|
|
- $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_no.',逻辑添加金币失败');
|
|
|
|
- Db::rollback();
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 修改订单状态
|
|
|
|
- $ros = Db::name('pay_order')->where(['out_trade_no' => $order_no])->update(['order_status'=>1,'notifytime'=>time()]);
|
|
|
|
- if($ros === false) {
|
|
|
|
- filePut('金币 ios充值:充值失败out_trade_no='.$order_no.','.$result['message'].','.'修改订单状态失败');
|
|
|
|
- Db::rollback();
|
|
|
|
- $this->error('充值失败');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Db::commit();
|
|
|
|
- $this->success('充值成功');
|
|
|
|
-
|
|
|
|
- //逻辑结束
|
|
|
|
- }
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
////////////////////////////////////
|
|
|
|
|
|
- //苹果自动扣费回调
|
|
|
|
|
|
+ //苹果自动扣费回调,server to server
|
|
public function auto_renewal_vip_notify(){
|
|
public function auto_renewal_vip_notify(){
|
|
$this->notify_log_start('ios');
|
|
$this->notify_log_start('ios');
|
|
}
|
|
}
|
|
|
|
|
|
-///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
+////////////////////////////////私有方法///////////////////////////////////////////////////////////////
|
|
//异步日志
|
|
//异步日志
|
|
private function notify_log_start($paytype = 'ios'){
|
|
private function notify_log_start($paytype = 'ios'){
|
|
//记录支付回调数据
|
|
//记录支付回调数据
|