<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class notice_uqcms extends control { function __construct() { $this->uid = @$_SESSION['user']['uid']; parent::__construct(); } function send() { $uq0 = G('id/i', '提交错误'); $uq1 = $this->module("api")->notice_send($uq0); if($uq1){ right_json(); }else{ error_json($uq1['msg']); } } function pay_notice() { $uq2 = G('name'); if($uq2!=''){ $uq3 = plug("pay_".$uq2); $uq4 = $uq3->check(); if($uq4['error'] == '0'){ if(is_numeric($uq4['trade_no']) && is_code($uq4['out_trade_no'])){ $uq5 = $this->pay_success($uq4['trade_no'], $uq4['out_trade_no'], $uq2); if($uq5['error'] == '0'){ $uq3->success(); }else{ sys_log('系统确认支付失败或者已经支付成功，逻辑错误。'); $uq3->fail(); } }else{ sys_log('返回的格式不正确'); return false; } }else{ return false; } }else{ sys_log('不存在支付名称'); return false; } } private function pay_success($uq6, $uq7, $uq2) { $uq5 = $this->db->get_one("select * from ".table('admin_pay')." where trade_no = '".$uq6."'"); if($uq5['id'] && $uq5['pay_status'] == '0'){ if($uq5['pay_type'] == '1'){ $uq8 = $this->db->get_all("select * from ".table('admin_pay')." where trade_no = '".$uq6."'"); if($uq8){ foreach($uq8 as $uq9){ $uq1 = $this->module('order')->buy_success($uq9['order_no'], $uq7, $uq2); $uq10 = [ 'payment' =>$uq2, 'payment_no'=>$uq7, 'pay_status'=>'1', 'pay_time' =>time() ]; $uq11 = $this->db->update(table('admin_pay'), $uq10, "id = '".$uq9['id']."'"); if($uq1['error'] == '0'){ $uq12[] = ''; $uq10['order_no'] = $uq9['order_no']; $uq10['price'] = $uq9['pay_price']; $uq10['title'] = $uq9['title']; $uq10['time'] = date('Y-m-d H:i:s'); $uq10['link'] = cfg('site_domain').'seller/order/index'; } } if(count($uq8) == count($uq12)){ return ['error'=>'0']; }else{ return false; } }else{ return false; } }elseif($uq5['pay_type'] == '2'){ $this->db->autocommit(); $q1 = $this->db->query("update ".table('member')." SET price = price + ".$uq5['pay_price']." where `uid` = ".$uq5['uid']); $q2 = $this->db->update(table('member_bill'), ['status'=>'1'], "type = 2 and order_no = '".$uq5['order_no']."'"); $uq10 = [ 'payment' =>$uq2, 'payment_no'=>$uq7, 'pay_status'=>'1', 'pay_time' =>time() ]; $q3 = $this->db->update(table('admin_pay'), $uq10, "trade_no = '".$uq5['trade_no']."'"); if($q1 && $q2 && $q3){ $this->db->commit(); return ['error'=>'0']; }else{ $this->db->rollback(); return error_arr('交易支付失败'); } }else{ return error_arr('不存在此类型'); } }else{ return error_arr('已经支付'); } } function pay_return() { $uq14 = G('name', false); if($uq14!=''){ $uq3 = plug("pay_".$uq14); $uq4 = $uq3->jump(); if($uq4['error'] == '0'){ if(is_numeric($_GET['out_trade_no'])){ $uq5 = $this->db->get_one("select id,uid,trade_no,pay_type,pay_status from ".table("admin_pay")." where trade_no = '".$uq4['trade_no']."' limit 1"); if($uq5['id']){ if($uq5['pay_status'] == '1'){ showmsg('支付成功', $this->return_page($uq5['pay_type'])); }else{ showmsg('支付失败', $this->return_page($uq5['pay_type'])); } }else{ error_404('订单不存在'); } }else{ error_404('支付参数错误'); } }else{ error_404('访问失败'); } }else{ error_404('访问错误'); } } function return_page($uq15 = '1') { if($uq15 == '1'){ if(cfg['browser'] == 'pc'){ return 'order/index?status=2'; }else{ return 'wap/order/index?status=2'; } }elseif($uq15 == '2'){ if(cfg['browser'] == 'pc'){ return 'account/index'; }else{ return 'wap/account/index'; } } } function balance_pay() { $uq6 = G('trade_no/c', '交易号不能为空'); $uq16 = $this->module('account')->admin_pay(['trade_no'=>$uq6]); if($uq16['error'] == '1'){ error_404($uq16['msg']); }else{ $uq17 = $uq16['price']; $uq18 = $uq16['title']; $uq19 = $this->db->get_one("select uid,price from ".table('member')." where uid = ".$this->uid); if($uq19['uid'] && (($uq19['price'] - $uq17) >= 0)){ $uq20 = $this->db->query("update ".table("member")." set price = price - ".$uq17." where uid = ".$this->uid); $uq1 = $this->pay_success($uq16['trade_no'], '', 'balance'); if($uq1['error'] == '0'){ showmsg('支付成功', $this->return_page($uq16['pay_type'])); }else{ showmsg('支付失败，请重新支付。', $this->return_page($uq16['pay_type'])); } }else{ error_404('账户余额不足'); } } } public function check_pay_status() { $uq6 = G('trade_no', '获取订单号失败'); $uq5 = $this->db->get_one("select id,uid,trade_no,pay_type,pay_status from ".table("admin_pay")." where trade_no = '".$uq6."'"); if($uq5['pay_status']){ $uq10['pay_type'] = $uq5['pay_type']; right_json($uq10); }else{ error_json('产品未支付'); } } } 