My.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <?php
  2. /**
  3. *
  4. * User: anyluck
  5. * Date: 2020/6/3
  6. * Time: 13:13
  7. */
  8. namespace app\web\controller;
  9. use app\common\model\About;
  10. use app\common\model\Bond;
  11. use app\common\model\BondFinance;
  12. use app\common\model\CommissionFinance;
  13. use app\common\model\Feedback;
  14. use app\common\model\GeneralFinance;
  15. use app\common\model\GeneralTransfer;
  16. use app\common\model\Message;
  17. use app\common\model\Notice;
  18. use app\common\model\Problem;
  19. use app\common\model\User;
  20. use app\common\model\UserMessage;
  21. use app\web\model\Tripartite;
  22. use think\Db;
  23. class My extends Base
  24. {
  25. // todo 个人中心
  26. // 获取个人信息
  27. public function index()
  28. {
  29. // 给用户加活跃度
  30. $where["id"]=$this->user_id;
  31. $update["update_time"]=time();
  32. User::update($update,$where);
  33. json_result(200, "", $this->user);
  34. }
  35. // 更新头像
  36. public function update_image()
  37. {
  38. $image = input("image");
  39. if (!$image) json_result(400, "请上传图片路径");
  40. $where["id"] = $this->user_id;
  41. $update["image"] = $image;
  42. User::update($update, $where);
  43. json_result(200, "设置成功");
  44. }
  45. // 更新用户名
  46. public function update_name()
  47. {
  48. $name = input("name");
  49. $where["id"] = $this->user_id;
  50. $update["name"] = $name;
  51. User::update($update, $where);
  52. json_result(200, "设置成功");
  53. }
  54. // 更新手机号码
  55. public function update_phone()
  56. {
  57. $phone = input("phone");
  58. if (!$phone) json_result(400, "请输入手机号");
  59. $code = input("code");
  60. if (!$code) json_result(400, "请输入验证码");
  61. $rest = Tripartite::push_code($phone, 0);
  62. if ($rest != $code) {
  63. json_result(400, "验证码错误");
  64. }
  65. $where["id"] = $this->user_id;
  66. $update["phone"] = $phone;
  67. User::update($update, $where);
  68. json_result(200, "设置成功");
  69. }
  70. // 更新邮箱
  71. public function update_mail()
  72. {
  73. $phone = input("mail");
  74. if (!$phone) json_result(400, "请输入邮箱");
  75. $code = input("code");
  76. if (!$code) json_result(400, "请输入验证码");
  77. $rest = Tripartite::push_code($phone, 1);
  78. if ($rest != $code) {
  79. json_result(400, "验证码错误");
  80. }
  81. $where["id"] = $this->user_id;
  82. $update["mail"] = $phone;
  83. User::update($update, $where);
  84. json_result(200, "设置成功");
  85. }
  86. // 显示收账信息
  87. public function receivable_show()
  88. {
  89. $where["user_id"] = $this->user_id;
  90. $user_message = UserMessage::where($where)->find();
  91. if (!$user_message) {// 没有数据就添加数据
  92. $add["user_id"] = $this->user_id;
  93. UserMessage::create($add);
  94. $user_message = UserMessage::where($where)->find();
  95. }
  96. json_result(200, $user_message);
  97. }
  98. // 修改收账信息
  99. public function update_receivable()
  100. {
  101. $id = input("id");
  102. if (!$id) json_result(400, "请上传更新id");
  103. $data["phone"] = input("phone");
  104. $data["name"] = input("name");
  105. $data["bank_name"] = input("bank_name");
  106. $data["bank_number"] = input("bank_number");
  107. $data["bank_branch"] = input("bank_branch");
  108. $data["ali_pay"] = input("ali_pay");
  109. $data["wx_pay"] = input("wx_pay");
  110. $data["ali_pay_image"] = input("ali_pay_image");
  111. $data["wx_pay_image"] = input("wx_pay_image");
  112. $where["id"] = $id;
  113. UserMessage::update($data, $where);
  114. json_result(200, "操作成功");
  115. }
  116. // 消息 获取最新的三条数据
  117. public function notice()
  118. {
  119. $notice = Message::where(["type" => 0])->order("id desc")->find(); // 公告
  120. $message_jiaoyi = Message::where(["type" => 2])->order("id desc")->find();// 交易
  121. $message_zijin = Message::where(["type" => 1])->order("id desc")->find();// 资金
  122. $data["notice"] = $notice;
  123. $data["message_jiaoyi"] = $message_jiaoyi;
  124. $data["message_zijin"] = $message_zijin;
  125. json_result(200, "", $data);
  126. }
  127. // 消息列表
  128. public function notice_list()
  129. {
  130. $type = input("type") ?: 0;
  131. $page = input("page") ?: 1;
  132. $limit = input("limit") ?: 10;
  133. $where["type"] = $type;
  134. $where["user_id"] = $this->user_id;
  135. $list = Message::where($where)->order("id desc,status asc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  136. $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
  137. return $item;
  138. });
  139. json_result(200, "", $list);
  140. }
  141. // 更新消息是否已读
  142. public function notice_status()
  143. {
  144. $id = input("id");
  145. $where["id"] = $id;
  146. $update["status"] = 1;
  147. Message::update($update, $where);
  148. json_result(200);
  149. }
  150. // 反馈意见
  151. public function feedback()
  152. {
  153. $content = input("content");
  154. $image = input("image");
  155. $add["user_id"] = $this->user_id;
  156. $add["content"] = $content;
  157. $add["image"] = $image;
  158. $add["add_time"] = time();
  159. Feedback::create($add);
  160. json_result(200, "反馈成功");
  161. }
  162. // 常见问题
  163. public function problem()
  164. {
  165. $page = input("page") ?: 1;
  166. $limit = input("limit") ?: 10;
  167. $list = Problem::order("id desc")->paginate(['list_rows' => $limit, 'page' => $page]);
  168. json_result(200, "", $list);
  169. }
  170. // 常见问题详情
  171. public function problem_show()
  172. {
  173. $id = input("id");
  174. $where["id"] = $id;
  175. $data = Problem::where($where)->find();
  176. json_result(200, "", $data);
  177. }
  178. // 修改密码
  179. public function update_pwd()
  180. {
  181. // $phone=input("phone");// 系统内置手机号或邮件
  182. $yuan = input("ypwd");
  183. if (!$yuan) json_result(400, "请输入原密码");
  184. $pwd = input("pwd");
  185. if (!$pwd) json_result(400, "请输入新密码");
  186. $where["id"] = $this->user_id;
  187. $update["pwd"] = password_hash($pwd, PASSWORD_DEFAULT);;
  188. $user = User::where($where)->find();
  189. if ($user->pwd == $update["pwd"]) {
  190. json_result(400, "原密码不能和新密码一样");
  191. }
  192. User::update($update, $where);
  193. json_result(200, "设置成功");
  194. }
  195. // 关于我们
  196. public function about()
  197. {
  198. $where["id"] = 1;
  199. $about = About::where($where)->find();
  200. json_result(200, "", $about);
  201. }
  202. // 我的推广显示页面
  203. public function extension()
  204. {
  205. $where["pid"] = $this->user_id;
  206. $count = User::where($where)->count();
  207. $data["push"] = $count;
  208. $data["team"] = $this->user["team"];
  209. json_result(200, "", $data);
  210. }
  211. // 直推列表
  212. public function extension_list()
  213. {
  214. $pid = input("pid");
  215. $page = input("page") ?: 1;
  216. $limit = input("limit") ?: 10;
  217. $where = [];
  218. if ($pid) {
  219. $where["pid"] = $pid;
  220. } else {
  221. $where["pid"] = $this->user_id;
  222. }
  223. $list = Problem::where($where)->order("id desc")->field("id,image,phone,name,mail,add_time")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  224. // 统计人数
  225. $where["pid"] = $item["id"];
  226. $count = User::where($where)->count();
  227. $item["team"] = $count;
  228. if ($item["add_time"]) {
  229. $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
  230. }
  231. return $item;
  232. });
  233. json_result(200,"",$list);
  234. }
  235. // 可售额度
  236. public function vendibility_list()
  237. {
  238. $page = input("page") ?: 1;
  239. $limit = input("limit") ?: 10;
  240. $where["user_id"]=$this->user_id;
  241. $list = Problem::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  242. if ($item["add_time"]) {
  243. $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
  244. }
  245. return $item;
  246. });
  247. json_result(200,"",$list);
  248. }
  249. // 保证金交易明细
  250. public function bond_list()
  251. {
  252. $page = input("page") ?: 1;
  253. $limit = input("limit") ?: 10;
  254. $where["user_id"]=$this->user_id;
  255. $list = BondFinance::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  256. if ($item["add_time"]) {
  257. $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
  258. }
  259. return $item;
  260. });
  261. json_result(200,"",$list);
  262. }
  263. //佣金记录
  264. public function commission_list()
  265. {
  266. $page = input("page") ?: 1;
  267. $limit = input("limit") ?: 10;
  268. $where["user_id"]=$this->user_id;
  269. $list = CommissionFinance::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  270. if ($item["add_time"]) {
  271. $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
  272. }
  273. return $item;
  274. });
  275. json_result(200,"",$list);
  276. }
  277. // 充值和提现保证金
  278. public function bond()
  279. {
  280. $money=input("money");if (!$money)json_result(400,"请输入提现金额");
  281. $type=input("type")?:0;//0 充值 1 提现
  282. // 查看账号余额
  283. if ($this->user->ensure_money<$money){
  284. json_result(400,"账号保证金不足");
  285. }
  286. $add["money"]=$money;
  287. $add["type"]=$type;
  288. $add["status"]=0;
  289. $add["add_time"]=time();
  290. $add["user_id"]=$this->user_id;
  291. Bond::create($add);
  292. json_result(200,"申请成功");
  293. }
  294. // 通证充值
  295. public function general()
  296. {
  297. $money=input("money");
  298. $actual_money=input("actual_money");
  299. $charge_money=input("charge_money");
  300. $add["money"]=$money;
  301. $add["user_id"]=$this->user_id;
  302. $add["actual_money"]=$actual_money;
  303. $add["charge_money"]=$charge_money;
  304. $add["status"]=0;
  305. $add["add_time"]=time();
  306. GeneralFinance::create($add);
  307. json_result(200,"申请成功");
  308. }
  309. //通证转账
  310. public function general_transfer()
  311. {
  312. $account=input("account");
  313. $money=input("money");
  314. if ($money>$this->user->money){
  315. json_result(400,"账号通证余额不足");
  316. }
  317. $where["phone|mail"]=$account;
  318. $user=User::where($where)->find();
  319. if (!$user){
  320. json_result(200,"账号不存在");
  321. }
  322. $add["user_id"]=$this->user_id;
  323. $add["puser_id"]=$user->id;
  324. $add["account"]=$account;
  325. $add["money"]=$money;
  326. $add["status"]=0;
  327. $add["add_time"]=time();
  328. GeneralTransfer::create($add);
  329. json_result(200,"申请成功");
  330. }
  331. }