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

defined('IN_UQ') or exit('Access Denied'); class ajax_uqcms extends control { function __construct() { $this->uid = @$_SESSION['user']['uid']; parent::__construct(); } public function check_login() { if(!empty($this->uid)){ echo json_encode(['error'=>'0']); }else{ echo json_encode(['error'=>'4', 'msg'=>'还未登录']); } } public function get_area() { $uq0 = $this->module('area')->get_list(); echo json_encode($uq0); } public function qrcode() { $uq1 = isset($_GET['code'])?trim($_GET['code']):''; $uq2 = !empty($_GET['size'])?$_GET['size']:'5'; $uq3 = !empty($_GET['level'])?$_GET['level']:'L'; $uq1 = base64_decode($uq1); include FRAME_PATH.'vendor/phpqrcode.php'; QRcode::png($uq1, false, $uq3, $uq2, 2); } public function vcode() { $uq1 = get_vcode_rand('4'); vcode::init()->get_img($uq1); $_SESSION['vcode'] = strtolower($uq1); } public function collect_shop() { $uq4 = P('spid/i', '提交错误'); if(empty($this->uid)){ echo json_encode(['error'=>'4']); }else{ $uq5 = $this->db->get_one("select * from ".table('collect_shop')." where spid = ".$uq4." and uid = ".$this->uid); if($uq5['id']){ $uq6 = $this->db->delete(table('collect_shop'),'id = '.$uq5['id']); $query2 = $this->db->query("update ".table('shop')." set collect=collect-1 where id = ".$uq4); if($uq6 && $query2){ echo json_encode(['error'=>'0','status'=>'0']); }else{ error_json('操作失败'); } }else{ $uq6 = $this->db->add(table('collect_shop'), ['uid'=>$this->uid, 'spid'=>$uq4,'addtime'=>time()]); $query2 = $this->db->query("update ".table('shop')." set collect=collect+1 where id = ".$uq4); if($uq6 && $query2){ echo json_encode(['error'=>'0','status'=>'1']); }else{ error_json('操作失败'); } } } } public function collect_goods() { $uq7 = P('gid/i', '提交错误'); if(empty($this->uid)){ echo json_encode(['error'=>'4']); }else{ $uq5 = $this->db->get_one("select * from ".table('collect_goods')." where gid = ".$uq7." and uid = ".$this->uid); if($uq5['id']){ $uq8 = $this->db->delete(table('collect_goods'), 'id = '.$uq5['id']); $q2 = $this->db->query("update ".table('goods')." set collect=collect-1 where id = ".$uq7); if($uq8 && $q2){ echo json_encode(['error'=>'0','status'=>'0']); }else{ error_json('操作失败'); } }else{ $uq9['uid'] = $this->uid; $uq9['gid'] = $uq7; $uq9['addtime'] = time(); $uq8 = $this->db->add(table('collect_goods'), $uq9); $q2 = $this->db->query("update ".table('goods')." set collect=collect+1 where id = ".$uq7); if($uq8 && $q2){ echo json_encode(['error'=>'0','status'=>'1']); }else{ error_json('操作失败'); } } } } public function coupon_receive() { if(empty($this->uid)){ echo json_encode(['error'=>'4']); }else{ $uq10 = P('id/i', '访问错误'); $uq11 = time(); $uq5 = $this->db->get_one("select * from ".table('promote_coupon')." where start_time < ".$uq11." and end_time > ".$uq11." and id = ".$uq10); if($uq5['id']){ if($uq5['num'] > $uq5['grant_num']){ $uq12 = $this->db->get_one("select count(id) as total from ".table('member_coupon')." where start_time < ".$uq11." and end_time > ".$uq11." and uid = ".$this->uid." and cpid = ".$uq5['id']." and status = 1"); if($uq12['total'] == '0'){ $this->db->autocommit(); $uq9['uid'] = $this->uid; $uq9['cpid'] = $uq5['id']; $uq9['spid'] = $uq5['spid']; $uq9['name'] = $uq5['name']; $uq9['price'] = $uq5['price']; $uq9['full_price'] = $uq5['full_price']; $uq9['start_time'] = $uq5['start_time']; $uq9['end_time'] = $uq5['end_time']; $uq9['range'] = $uq5['range']; $uq9['status'] = '1'; $uq9['addtime'] = time(); $uq8 = $this->db->add(table('member_coupon'), $uq9); $q2 = $this->db->query("update ".table('promote_coupon')." set grant_num = grant_num+1 where id = ".$uq5['id']); if($uq8 && $q2){ $this->db->commit(); right_json(); }else{ $this->db->rollback(); error_json('领取失败'); } }else{ error_json('已经领取'); } }else{ error_json('已经发放完毕'); } }else{ error_json('优惠券不存在或者过期'); } } } public function express() { $uq1 = G('code', '物流编号不能为空'); $uq13 = G('nu', '物流号不能为空'); $uq14 = api('express_kdniao')->query($uq1, $uq13); if($uq14['error'] == '0'){ $uq0['msg'] = $uq14['list']; right_json($uq0); }else{ error_json($uq14['msg']); } } public function notice_run() { $uq10 = G('id/i', 'error'); $this->module('notice')->notice_run($uq10); } function pay() { $uq15 = P('payment/c', '支付方式不能为空'); $uq16 = P('trade_no/i', '交易编号不能为空'); $uq5 = $this->module('account')->admin_pay(['trade_no'=>$uq16]); if($uq5['error'] == '0'){ $uq17['trade_no'] = $uq5['trade_no']; $uq17['title'] = $uq5['title']; $uq17['price'] = $uq5['price']; $uq18 = $this->api('pay_'.$uq15)->pay($uq17); echo json_encode($uq18); }else{ error_json('订单不存在'); } } } 