FinanceController.class.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <?php
  2. namespace Admin\Controller;
  3. class FinanceController extends AdminController
  4. {
  5. protected function _initialize(){
  6. parent::_initialize();
  7. $allow_action=array("index","myzr","myzc","adopttb","reject","adoptzr","rejectzr","taxlist","adopttax","rejecttax");
  8. if(!in_array(ACTION_NAME,$allow_action)){
  9. $this->error("页面不存在!");
  10. }
  11. }
  12. //驳回税金缴纳
  13. public function rejecttax($id = null){
  14. if($id <= 0){
  15. $this->error("缺少重要参数");exit();
  16. }
  17. $info = M("recharge")->where(array('id'=>$id))->find();
  18. if(empty($info)){
  19. $this->error("充币订单不存在");exit();
  20. }
  21. if($info['status'] != 1){
  22. $this->error("此订单已处理");exit();
  23. }
  24. //修改订单状态
  25. $save['updatetime'] = date("Y-m-d H:i:s",time());
  26. $save['status'] = 3;
  27. $upre = M("taxlist")->where(array('id'=>$id))->save($save);
  28. if($upre){
  29. $data['uid'] = $info['uid'];
  30. $data['account'] = $info['username'];
  31. $data['title'] = L('税金审核');
  32. $data['content'] = L('缴纳税金审核被驳回,请联系客服');
  33. $data['addtime'] = date("Y-m-d H:i:s",time());
  34. $data['status'] = 1;
  35. M("taxlist")->add($data);
  36. $this->success("税金审核驳回成功");
  37. }else{
  38. $this->error("税金审核驳回失败");
  39. }
  40. }
  41. //确认税金
  42. public function adopttax($id = null){
  43. if($id <= 0){
  44. $this->error("缺少重要参数");exit();
  45. }
  46. $info = M("taxlist")->where(array('id'=>$id))->find();
  47. if(empty($info)){
  48. $this->error("记录不存在");exit();
  49. }
  50. if($info['status'] != 1){
  51. $this->error("记录已处理");exit();
  52. }
  53. $uid = $info['uid'];
  54. $save['updatetime'] = date("Y-m-d H:i:s",time());
  55. $save['status'] = 2;
  56. $upre = M("taxlist")->where(array('id'=>$id))->save($save);
  57. if($upre){
  58. $notice['uid'] = $info['uid'];
  59. $notice['account'] = $info['username'];
  60. $notice['title'] = L('税金审核');
  61. $notice['content'] = L('缴纳税金审核成功');
  62. $notice['addtime'] = date("Y-m-d H:i:s",time());
  63. $notice['status'] = 1;
  64. M("notice")->add($notice);
  65. M("user")->where(array('id'=>$uid))->save(array('taxstatus'=>1));
  66. $this->success("操作成功");
  67. }else{
  68. $this->error("操作失败");
  69. }
  70. }
  71. //税金列表
  72. public function taxlist($name=null){
  73. if($name != ''){
  74. $where['username'] = $name;
  75. }
  76. $count = M('taxlist')->where($where)->count();
  77. $Page = new \Think\Page($count, 15);
  78. $show = $Page->show();
  79. $list = M('taxlist')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  80. $this->assign('list', $list);
  81. $this->assign('page', $show);
  82. $this->display();
  83. }
  84. //驳回充币
  85. public function rejectzr($id = null){
  86. if($id <= 0){
  87. $this->error("缺少重要参数");exit();
  88. }
  89. $info = M("recharge")->where(array('id'=>$id))->find();
  90. if(empty($info)){
  91. $this->error("充币订单不存在");exit();
  92. }
  93. if($info['status'] != 1){
  94. $this->error("此订单已处理");exit();
  95. }
  96. //修改订单状态
  97. $save['updatetime'] = date("Y-m-d H:i:s",time());
  98. $save['status'] = 3;
  99. $upre = M("recharge")->where(array('id'=>$id))->save($save);
  100. if($upre){
  101. $data['uid'] = $info['uid'];
  102. $data['account'] = $info['username'];
  103. $data['title'] = L('充币审核');
  104. $data['content'] = L('您的充币记录被系统驳回,请联系客服');
  105. $data['addtime'] = date("Y-m-d H:i:s",time());
  106. $data['status'] = 1;
  107. M("notice")->add($data);
  108. $this->success("充值驳回成功");
  109. }else{
  110. $this->error("驳回失败");
  111. }
  112. }
  113. //确认充币
  114. public function adoptzr($id = null){
  115. if($id <= 0){
  116. $this->error("缺少重要参数");exit();
  117. }
  118. $info = M("recharge")->where(array('id'=>$id))->find();
  119. if(empty($info)){
  120. $this->error("充币订单不存在");exit();
  121. }
  122. if($info['status'] != 1){
  123. $this->error("此订单已处理");exit();
  124. }
  125. $uid = $info['uid'];
  126. $num = $info['num'];
  127. if ($info['coin'] == 'TRC20-USDT' || $info['coin'] == 'ERC20-USDT'){
  128. $info['coin'] = 'USDT';
  129. }
  130. $coinname = strtolower(trim($info['coin']));
  131. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  132. //修改订单状态
  133. $save['updatetime'] = date("Y-m-d H:i:s",time());
  134. $save['status'] = 2;
  135. $upre = M("recharge")->where(array('id'=>$id))->save($save);
  136. //增加会员资产
  137. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc($coinname,$num);
  138. //增加充值日志
  139. $data['uid'] = $info['uid'];
  140. $data['username'] = $info['username'];
  141. $data['num'] = $num;
  142. $data['coinname'] = $coinname;
  143. $data['afternum'] = $minfo[$coinname] + $num;
  144. $data['type'] = 17;
  145. $data['addtime'] = date("Y-m-d H:i:s",time());
  146. $data['st'] = 1;
  147. $data['remark'] = L('充幣到賬');
  148. $addre = M("bill")->add($data);
  149. if($upre && $incre && $addre){
  150. $notice['uid'] = $info['uid'];
  151. $notice['account'] = $info['username'];
  152. $notice['title'] = L('充币审核');
  153. $notice['content'] = L('您的充值金额已到账,请注意查收');
  154. $notice['addtime'] = date("Y-m-d H:i:s",time());
  155. $notice['status'] = 1;
  156. M("notice")->add($notice);
  157. $this->success("处理成功");
  158. }else{
  159. $this->error("处理失败");
  160. }
  161. }
  162. //驳回提币记录
  163. public function reject($id = null){
  164. if($id <= 0){
  165. $this->error("缺少重要参数");exit();
  166. }
  167. $info = M("myzc")->where(array('id'=>$id))->find();
  168. if(empty($info)){
  169. $this->error("提币订单不存在");exit();
  170. }
  171. if($info['status'] != 1){
  172. $this->error("此订单已处理");exit();
  173. }
  174. $uid = $info['userid'];
  175. $num = $info['num'];
  176. $coinname = strtolower(trim($info['coinname']));
  177. //修改记录状态
  178. $save['endtime'] = date("Y-m-d H:i:s",time());
  179. $save['status'] = 3;
  180. $upre = M("myzc")->where(array('id'=>$id))->save($save);
  181. //把提币的数量返回给账号户,并写入日志
  182. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  183. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc($coinname,$num);
  184. $bill['uid'] = $uid;
  185. $bill['username'] = $info['username'];
  186. $bill['num'] =$num;
  187. $bill['coinname'] = $info['coinname'];
  188. $bill['afternum'] = $minfo[$coinname] + $num;
  189. $bill['type'] = 16;
  190. $bill['addtime'] = date("Y-m-d H:i:s",time());
  191. $bill['st'] = 1;
  192. $bill['remark'] = L('提币驳回,退回资金');;
  193. $billre = M("bill")->add($bill);
  194. if($upre && $incre && $billre){
  195. $notice['uid'] = $uid;
  196. $notice['account'] = $info['username'];
  197. $notice['title'] = L('提币审核');
  198. $notice['content'] = L('您的提币申请被驳回,请联系管理员');
  199. $notice['addtime'] = date("Y-m-d H:i:s",time());
  200. $notice['status'] = 1;
  201. M("notice")->add($notice);
  202. $this->success("操作成功");exit();
  203. }else{
  204. $this->error("操作失败");exit();
  205. }
  206. }
  207. //通过提币处理
  208. public function adopttb($id = null){
  209. if($id <= 0){
  210. $this->error("缺少重要参数");exit();
  211. }
  212. $info = M("myzc")->where(array('id'=>$id))->find();
  213. if(empty($info)){
  214. $this->error("提币订单不存在");exit();
  215. }
  216. if($info['status'] != 1){
  217. $this->error("此订单已处理");exit();
  218. }
  219. $save['endtime'] = date("Y-m-d H:i:s",time());
  220. $save['status'] = 2;
  221. $result = M("myzc")->where(array('id'=>$id))->save($save);
  222. if($result){
  223. $notice['uid'] = $info['userid'];
  224. $notice['account'] = $info['username'];
  225. $notice['title'] = L('提币审核');
  226. $notice['content'] = L('您的提币申请已通过,请及时查询');
  227. $notice['addtime'] = date("Y-m-d H:i:s",time());
  228. $notice['status'] = 1;
  229. M("notice")->add($notice);
  230. $this->success('处理成功!',U('Finance/myzc'));
  231. }else{
  232. $this->error("处理失败");exit();
  233. }
  234. }
  235. //账务明细
  236. public function index($name=null){
  237. if($name != ''){
  238. $where['username'] = $name;
  239. }
  240. $count = M('bill')->where($where)->count();
  241. $Page = new \Think\Page($count, 15);
  242. $show = $Page->show();
  243. $list = M('bill')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  244. $this->assign('list', $list);
  245. $this->assign('page', $show);
  246. $this->display();
  247. }
  248. //充币列表
  249. public function myzr($name=null){
  250. if($name != ''){
  251. $where['username'] = $name;
  252. }
  253. $count = M('recharge')->where($where)->count();
  254. $Page = new \Think\Page($count, 15);
  255. $show = $Page->show();
  256. $list = M('recharge')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  257. $this->assign('list', $list);
  258. $this->assign('page', $show);
  259. $this->display();
  260. }
  261. //提币列表
  262. public function myzc($name=null){
  263. if($name != ''){
  264. $where['username'] = $name;
  265. }
  266. $count = M('myzc')->where($where)->count();
  267. $Page = new \Think\Page($count, 15);
  268. $show = $Page->show();
  269. $list = M('myzc')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  270. $this->assign('list', $list);
  271. $this->assign('page', $show);
  272. $this->display();
  273. }
  274. }
  275. ?>