|
@@ -209,6 +209,70 @@ class Payios extends Api
|
|
|
}
|
|
|
|
|
|
//vip,苹果内购支付回调,app请求的接口
|
|
|
+ public function gold_notify_iosnew(){
|
|
|
+
|
|
|
+ //苹果内购的验证收据
|
|
|
+
|
|
|
+ $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'].'!='.$args['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('充值成功');
|
|
|
+
|
|
|
+ //逻辑结束
|
|
|
+ }
|
|
|
public function gold_notify_ios(){
|
|
|
|
|
|
//苹果内购的验证收据
|