Sys.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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;
  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)->getDataInfo();
  24. return app('json')->success($sys);
  25. }
  26. /**
  27. * 微信配置
  28. * @return type
  29. */
  30. public function wxSave(){
  31. $post = UtilService::getMore([
  32. ['appid', ''],
  33. ['secret', ''],
  34. ['mchid', ''],
  35. ['apiv2key', ''],
  36. ['apiclient_key', ''],
  37. ['apiclient_cert', ''],
  38. ['notify_url', ''],
  39. ], $request);
  40. (new SysModel())->saveWxConfig($post);
  41. return app('json')->success("数据保存成功");
  42. }
  43. /**
  44. * 分享配置
  45. * @return type
  46. */
  47. public function shareSave(){
  48. $post = UtilService::getMore([
  49. ['title', ''],
  50. ['img', ''],
  51. ['query', ''],
  52. ], $request);
  53. (new SysModel())->saveShareConfig($post);
  54. return app('json')->success("数据保存成功");
  55. }
  56. /**
  57. * 编辑用户条款
  58. * @param Request $request
  59. */
  60. public function agreeSave(Request $request){
  61. $post = UtilService::getMore([
  62. ['user_agreement', '','empty','请输入用户协议'],
  63. ['privacy_policy', '','empty','请输入用户隐私声明'],
  64. ], $request);
  65. (new SysModel())->saveSys($post);
  66. return app('json')->success("数据保存成功");
  67. }
  68. /**
  69. * 保存数据
  70. */
  71. public function save(Request $request){
  72. $post = UtilService::getMore([
  73. ['title', ''],
  74. ['system_url', ''],
  75. ['tag', ''],
  76. ['custom_tel', ''],
  77. // ['ip_income_per',0,'empty','IP商品收益百分比大于0'],
  78. // ['tree_income_per',0],
  79. // ['tree_income_per_two',0],
  80. // ['money_to_score_per',0,'empty','消费转积分百分比大于0'],
  81. // ['tx_limit_money',0],
  82. // ['tx_process_per',0],
  83. // ['tx_process_max',0],
  84. ], $request);
  85. // $post["tx_limit_money"] = (int)$post["tx_limit_money"];
  86. // $post["tx_process_per"] = (int)$post["tx_process_per"];
  87. // $post["tx_process_max"] = (int)$post["tx_process_max"];
  88. if(!empty($post["custom_tel"])){
  89. $post["custom_tel"] = str_replace(",", ",", $post["custom_tel"]);
  90. }
  91. (new SysModel())->saveSys($post);
  92. return app('json')->success("数据保存成功");
  93. }
  94. /**
  95. * 提现方式列表
  96. * @param Request $request
  97. * @return type
  98. */
  99. public function bankList(Request $request) {
  100. $pageSize = 50;
  101. $post = UtilService::getMore([
  102. ['page',1],
  103. ['status',''],
  104. ],$request);
  105. $where=[];
  106. if((string)$post["status"]!=""){
  107. $where[]=["status","=",(int)$post["status"] == 1 ? 1 : 0];
  108. }
  109. $data = (new BankModel)
  110. ->where($where)
  111. ->page((int)$post["page"], (int)$pageSize)
  112. ->order("seq","desc")
  113. ->order("id","desc")
  114. ->select()
  115. ->toArray();
  116. $pageCount = (new BankModel)->where($where)->count();
  117. $data = empty($data)?[]:$data;
  118. return app('json')->success([
  119. 'list' => $data,
  120. 'pageCount' => $pageCount,
  121. 'pageSize' => $pageSize,
  122. 'page' => $post["page"]
  123. ]);
  124. }
  125. /**
  126. * 添加编辑提现方式
  127. * @param Request $request
  128. */
  129. public function bankSave(Request $request){
  130. $post = UtilService::getMore([
  131. ['id','0'],
  132. ['name','','empty','请填写银行名称'],
  133. ['code','','empty','请填写银行编码'],
  134. ['seq','0'],
  135. ['status','0']
  136. ],$request);
  137. $id = (int)$post["id"];
  138. unset($post["id"]);
  139. $post["seq"] = intval($post["seq"]);
  140. $post["status"] = intval($post["status"])==1?1:0;
  141. $r=0;
  142. $count = (new BankModel)->where("id","<>",$id)->where("code",$post["code"])->count();
  143. if($count>0){
  144. return app('json')->fail("银行编码不能重复");
  145. }
  146. if(empty($id)){
  147. $r = (new BankModel)->insert($post);
  148. }else{
  149. $r = (new BankModel)->where("id",$id)->update($post);
  150. }
  151. if($r){
  152. return app('json')->success("数据保存成功");
  153. }else{
  154. return app('json')->fail("数据保存失败");
  155. }
  156. }
  157. /**
  158. * 删除提现方式
  159. * @param Request $request
  160. */
  161. public function bankDel(Request $request) {
  162. [$id] = UtilService::getMore([
  163. ['id',0,'empty','参数错误']
  164. ],$request,true);
  165. $bool = (new BankModel)->where("id",$id)->delete();
  166. return app('json')->success("删除成功");
  167. }
  168. }