Index.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\controller\users;
  10. use app\admin\controller\Auth;
  11. use app\admin\service\users\Finance as FinanceService;
  12. use mall\response\Response;
  13. use think\facade\Request;
  14. use think\facade\View;
  15. use app\admin\service\users\Users as UsersService;
  16. class Index extends Auth {
  17. /**
  18. * 列表
  19. * @return string|\think\response\Json
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\DbException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. */
  24. public function index(){
  25. if(Request::isAjax()){
  26. $list = UsersService::getList(Request::param());
  27. return Response::returnArray("ok",0,$list['data'],$list['count']);
  28. }
  29. return View::fetch("",UsersService::getSearchData());
  30. }
  31. /**
  32. * 编辑
  33. * @return string|\think\response\Json
  34. */
  35. public function editor(){
  36. try{
  37. if(Request::isAjax()){
  38. UsersService::save(Request::param());
  39. return Response::returnArray("操作成功!");
  40. }
  41. return View::fetch("",UsersService::detail(Request::param("id",0,"intval")));
  42. }catch (\Exception $ex){
  43. return Response::returnArray("操作失败,请重试。",0);
  44. }
  45. }
  46. /**
  47. * 删除会员
  48. * @return \think\response\Json
  49. */
  50. public function delete(){
  51. try{
  52. UsersService::delete(Request::get("id",""));
  53. return Response::returnArray("删除成功");
  54. }catch (\Exception $ex){
  55. return Response::returnArray($ex->getMessage(),0);
  56. }
  57. }
  58. /**
  59. * 财务明细
  60. * @return string|\think\response\Json
  61. */
  62. public function finance(){
  63. try{
  64. if(Request::isAjax()){
  65. UsersService::financeSave(Request::param());
  66. return Response::returnArray("操作成功!");
  67. }
  68. return View::fetch("",UsersService::financeDetail(Request::param("id",0,"intval")));
  69. }catch (\Exception $ex){
  70. if(Request::isAjax()) {
  71. return Response::returnArray($ex->getMessage(), 0);
  72. }
  73. $this->error($ex->getMessage());
  74. }
  75. }
  76. /**
  77. * 会员日志
  78. * @return string|\think\response\Json
  79. * @throws \think\db\exception\DataNotFoundException
  80. * @throws \think\db\exception\DbException
  81. * @throws \think\db\exception\ModelNotFoundException
  82. */
  83. public function log(){
  84. if(Request::isAjax()){
  85. $list = FinanceService::getList(Request::param(),["users_log.user_id"=>Request::param("id",0,"intval")]);
  86. return Response::returnArray("ok",0,$list['data'],$list['count']);
  87. }
  88. return View::fetch("",[ "id"=>Request::param("id",0,"intval") ]);
  89. }
  90. /**
  91. * 编辑标签
  92. * @return \think\response\Json
  93. */
  94. public function tags(){
  95. UsersService::updateUsersTags(Request::param());
  96. return Response::returnArray("ok",0);
  97. }
  98. /**
  99. * 会员收藏
  100. * @return string|\think\response\Json
  101. */
  102. public function collect(){
  103. try{
  104. if(Request::isAjax()){
  105. $list = UsersService::getFavoriteList(Request::param("id"));
  106. return Response::returnArray("ok",0,$list["data"],$list["count"]);
  107. }
  108. return View::fetch("",["id"=>Request::param("id","0","intval")]);
  109. }catch (\Exception $ex){
  110. return Response::returnArray($ex->getMessage(),0);
  111. }
  112. }
  113. /**
  114. * 会员地址
  115. * @return string|\think\response\Json
  116. */
  117. public function address(){
  118. try{
  119. if(Request::isAjax()){
  120. $result = UsersService::getAddressList(Request::param("id","0","intval"));
  121. return Response::returnArray("ok",0, $result, count($result));
  122. }
  123. return View::fetch("",[ "id" => Request::param("id","0","intval") ]);
  124. }catch (\Exception $ex){
  125. return Response::returnArray($ex->getMessage(),1);
  126. }
  127. }
  128. }