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

defined('IN_UQ') or exit('Access Denied'); class bill_uqcms extends control { function __construct() { $this->spid = $_SESSION['shop']['id']; parent::__construct(); } function withdraw_save() { if($_POST){ $uq0 = P('id', 0); if($uq0){ $uq1 = $this->db->get_one("select * from ".table('member_withdraw')." where spid = ".$this->spid." and id = ".$uq0); if($uq1['id']){ if($uq1['status'] == '1'){ error_json('已经提现成功'); }else{ $uq2 = $this->module('common')->category_name(); $uq3 = P('bank_id', '请选择支付地址'); $uq4['bank'] = $uq2[$uq3]??error_json('不存在银行名称'); $uq4['account'] = P('account', '收款账号不能为空'); $uq4['name'] = P('name', '收款姓名不能为空'); $uq4['status'] = '0'; $uq5 = $this->db->update(table('member_withdraw'), $uq4, "spid = ".$this->spid." and id = ".$uq0); if($uq5){ right_json(); }else{ error_json('提交错误'); } } }else{ error_json('提交错误'); } }else{ $uq6 = P('price', '', '0'); if(($uq6 > '0') && ($uq6%1 == '0')){ $uq7 = $this->db->get_one("select id,price from ".table('shop')." where id = ".$this->spid); if($uq7['price'] >= $uq6){ $uq1 = $this->db->get_one("select * from ".table('member_withdraw')." where spid = ".$this->spid." and status = 0"); if(!$uq1['id']){ $uq2 = $this->module('common')->category_name(); $uq3 = P('bank_id', '支付地址不能为空'); $this->db->autocommit(); $uq4['uid'] = '0'; $uq4['spid'] = $this->spid; $uq4['price'] = $uq6; $uq4['surplus'] = $uq7['price'] - $uq6; $uq4['bank'] = $uq2[$uq3]??error_json('不存在银行名称'); $uq4['account'] = P('account', '收款账号不能为空'); $uq4['name'] = P('name', '收款姓名不能为空'); $uq4['remark'] = P('remark'); $uq4['status'] = '0'; $uq4['addtime'] = time(); $query1 = $this->db->add(table('member_withdraw'), $uq4); $query2 = $this->db->query("update ".table('shop')." set price = price - ".$uq6." where id = ".$this->spid); if($query1 && $query2){ $this->db->commit(); right_json(); }else{ $this->db->rollback(); error_json('申请失败'); } }else{ error_json('有正在进行中的申请，成功后再申请。'); } }else{ error_json('账户金额不足'); } }else{ error_json('提现金额大于0，且为100的整数倍。'); } } }else{ error_json(); } } } 