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