Sys.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018-2020 rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | [ 系统配置 ]
  8. // +----------------------------------------------------------------------
  9. // | Date: 2020-08-31 20:43
  10. // +----------------------------------------------------------------------
  11. namespace app\system\controller\v1;
  12. use app\BaseController;
  13. use app\Request;
  14. use library\services\UtilService;
  15. use app\model\api\Sys as SysModel;
  16. use app\model\api\Bank as BankModel;
  17. class Sys extends BaseController
  18. {
  19. /**
  20. * 基本设置
  21. */
  22. public function index(){
  23. $sys = (new SysModel)->where("id", 1)->find();
  24. return app('json')->success($sys->toArray());
  25. }
  26. /**
  27. * 编辑用户条款
  28. * @param Request $request
  29. */
  30. public function agreeSave(Request $request){
  31. $post = UtilService::getMore([
  32. ['user_agreement', '','empty','请输入用户协议'],
  33. ['privacy_policy', '','empty','请输入用户隐私声明'],
  34. ], $request);
  35. (new SysModel())->saveSys($post);
  36. return app('json')->success("数据保存成功");
  37. }
  38. /**
  39. * 保存数据
  40. */
  41. public function save(Request $request){
  42. $post = UtilService::getMore([
  43. ['title', ''],
  44. ['system_url', ''],
  45. ['tag', ''],
  46. ['custom_tel', ''],
  47. ['ip_income_per',0,'empty','IP商品收益百分比大于0'],
  48. ['tree_income_per',0],
  49. ['tree_income_per_two',0],
  50. ['money_to_score_per',0,'empty','消费转积分百分比大于0'],
  51. ['tx_limit_money',0],
  52. ['tx_process_per',0],
  53. ['tx_process_max',0],
  54. ], $request);
  55. $post["tx_limit_money"] = (int)$post["tx_limit_money"];
  56. $post["tx_process_per"] = (int)$post["tx_process_per"];
  57. $post["tx_process_max"] = (int)$post["tx_process_max"];
  58. if(!empty($post["custom_tel"])){
  59. $post["custom_tel"] = str_replace(",", ",", $post["custom_tel"]);
  60. }
  61. (new SysModel())->saveSys($post);
  62. return app('json')->success("数据保存成功");
  63. }
  64. /**
  65. * 提现方式列表
  66. * @param Request $request
  67. * @return type
  68. */
  69. public function bankList(Request $request) {
  70. $pageSize = 50;
  71. $post = UtilService::getMore([
  72. ['page',1],
  73. ['status',''],
  74. ],$request);
  75. $where=[];
  76. if((string)$post["status"]!=""){
  77. $where[]=["status","=",(int)$post["status"] == 1 ? 1 : 0];
  78. }
  79. $data = (new BankModel)
  80. ->where($where)
  81. ->page((int)$post["page"], (int)$pageSize)
  82. ->order("seq","desc")
  83. ->order("id","desc")
  84. ->select()
  85. ->toArray();
  86. $pageCount = (new BankModel)->where($where)->count();
  87. $data = empty($data)?[]:$data;
  88. return app('json')->success([
  89. 'list' => $data,
  90. 'pageCount' => $pageCount,
  91. 'pageSize' => $pageSize,
  92. 'page' => $post["page"]
  93. ]);
  94. }
  95. /**
  96. * 添加编辑提现方式
  97. * @param Request $request
  98. */
  99. public function bankSave(Request $request){
  100. $post = UtilService::getMore([
  101. ['id','0'],
  102. ['name','','empty','请填写银行名称'],
  103. ['code','','empty','请填写银行编码'],
  104. ['seq','0'],
  105. ['status','0']
  106. ],$request);
  107. $id = (int)$post["id"];
  108. unset($post["id"]);
  109. $post["seq"] = intval($post["seq"]);
  110. $post["status"] = intval($post["status"])==1?1:0;
  111. $r=0;
  112. $count = (new BankModel)->where("id","<>",$id)->where("code",$post["code"])->count();
  113. if($count>0){
  114. return app('json')->fail("银行编码不能重复");
  115. }
  116. if(empty($id)){
  117. $r = (new BankModel)->insert($post);
  118. }else{
  119. $r = (new BankModel)->where("id",$id)->update($post);
  120. }
  121. if($r){
  122. return app('json')->success("数据保存成功");
  123. }else{
  124. return app('json')->fail("数据保存失败");
  125. }
  126. }
  127. /**
  128. * 删除提现方式
  129. * @param Request $request
  130. */
  131. public function bankDel(Request $request) {
  132. [$id] = UtilService::getMore([
  133. ['id',0,'empty','参数错误']
  134. ],$request,true);
  135. $bool = (new BankModel)->where("id",$id)->delete();
  136. return app('json')->success("删除成功");
  137. }
  138. }