Sys.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. * @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. $saveType = $request->param("saveType", "sys");
  43. if($saveType=="sys"){
  44. $post = UtilService::getMore([
  45. ['title', ''],
  46. ['system_url', ''],
  47. ['tag', ''],
  48. ['custom_tel', ''],
  49. // ['ip_income_per',0,'empty','IP商品收益百分比大于0'],
  50. // ['tree_income_per',0],
  51. // ['tree_income_per_two',0],
  52. // ['money_to_score_per',0,'empty','消费转积分百分比大于0'],
  53. // ['tx_limit_money',0],
  54. // ['tx_process_per',0],
  55. // ['tx_process_max',0],
  56. ], $request);
  57. if(!empty($post["custom_tel"])){
  58. $post["custom_tel"] = str_replace(",", ",", $post["custom_tel"]);
  59. }
  60. (new SysModel())->saveSys($post);
  61. }
  62. if($saveType=="weixin"){
  63. $post = UtilService::getMore([
  64. ['appid', ''],
  65. ['secret', ''],
  66. ['mchid', ''],
  67. ['apiv2key', ''],
  68. ['apiclient_key', ''],
  69. ['apiclient_cert', ''],
  70. ['notify_url', ''],
  71. ], $request);
  72. (new SysModel())->saveWxConfig($post);
  73. }
  74. if($saveType=="share"){
  75. $post = UtilService::getMore([
  76. ['title', ''],
  77. ['img', ''],
  78. ['content', ''],
  79. ['query', ''],
  80. ['is_show', ''],
  81. ], $request);
  82. @file_put_contents('quanju.txt', json_encode($post)."-接受的传参\r\n", 8);
  83. (new SysModel())->saveShareConfig($post);
  84. $a=(new SysModel())->where('id',1)->update(['is_show'=>$post['is_show']]);
  85. @file_put_contents('quanju.txt', $a."-接受的传参结果\r\n", 8);
  86. }
  87. if($saveType=="invite"){
  88. $post = UtilService::getMore([
  89. ['img', ''],
  90. ], $request);
  91. (new SysModel())->saveInviteConfig($post);
  92. }
  93. if($saveType=="score"){
  94. $post = UtilService::getMore([
  95. ['points_transformation', 0],
  96. ['points_share', 0],
  97. ['chat_num', 0], //新用户赠送聊天次数
  98. ['chat_price', 0], //聊天次数价格
  99. ], $request);
  100. (new SysModel())->saveScoreConfig($post);
  101. }
  102. return app('json')->success("数据保存成功");
  103. }
  104. /**
  105. * 提现方式列表
  106. * @param Request $request
  107. * @return type
  108. */
  109. public function bankList(Request $request) {
  110. $pageSize = 50;
  111. $post = UtilService::getMore([
  112. ['page',1],
  113. ['status',''],
  114. ],$request);
  115. $where=[];
  116. if((string)$post["status"]!=""){
  117. $where[]=["status","=",(int)$post["status"] == 1 ? 1 : 0];
  118. }
  119. $data = (new BankModel)
  120. ->where($where)
  121. ->page((int)$post["page"], (int)$pageSize)
  122. ->order("seq","desc")
  123. ->order("id","desc")
  124. ->select()
  125. ->toArray();
  126. $pageCount = (new BankModel)->where($where)->count();
  127. $data = empty($data)?[]:$data;
  128. return app('json')->success([
  129. 'list' => $data,
  130. 'pageCount' => $pageCount,
  131. 'pageSize' => $pageSize,
  132. 'page' => $post["page"]
  133. ]);
  134. }
  135. /**
  136. * 添加编辑提现方式
  137. * @param Request $request
  138. */
  139. public function bankSave(Request $request){
  140. $post = UtilService::getMore([
  141. ['id','0'],
  142. ['name','','empty','请填写银行名称'],
  143. ['code','','empty','请填写银行编码'],
  144. ['seq','0'],
  145. ['status','0']
  146. ],$request);
  147. $id = (int)$post["id"];
  148. unset($post["id"]);
  149. $post["seq"] = intval($post["seq"]);
  150. $post["status"] = intval($post["status"])==1?1:0;
  151. $r=0;
  152. $count = (new BankModel)->where("id","<>",$id)->where("code",$post["code"])->count();
  153. if($count>0){
  154. return app('json')->fail("银行编码不能重复");
  155. }
  156. if(empty($id)){
  157. $r = (new BankModel)->insert($post);
  158. }else{
  159. $r = (new BankModel)->where("id",$id)->update($post);
  160. }
  161. if($r){
  162. return app('json')->success("数据保存成功");
  163. }else{
  164. return app('json')->fail("数据保存失败");
  165. }
  166. }
  167. /**
  168. * 删除提现方式
  169. * @param Request $request
  170. */
  171. public function bankDel(Request $request) {
  172. [$id] = UtilService::getMore([
  173. ['id',0,'empty','参数错误']
  174. ],$request,true);
  175. $bool = (new BankModel)->where("id",$id)->delete();
  176. return app('json')->success("删除成功");
  177. }
  178. }