123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- namespace app\controller\out;
- use app\Request;
- use app\services\out\UserServices;
- use app\services\user\UserAddressServices;
- use app\services\user\UserMoneyServices;
- class User
- {
-
- protected $services;
- public function __construct(UserServices $services)
- {
- $this->services = $services;
- }
-
- public function index($uid)
- {
- return app('json')->success($this->services->getUserInfo($uid, 'uid,phone,nickname,now_money,integral,addres'));
- }
-
- public function update_other(Request $request, $id = 0)
- {
- $data = $request->postMore([
- ['money_status', 0],
- ['money', 0],
- ['integration_status', 0],
- ['integration', 0],
- ]);
- if (!$id) return $this->fail('数据不存在');
- $data['adminId'] = $request->outId;
- $data['money'] = (string)$data['money'];
- $data['integration'] = (string)$data['integration'];
- $data['is_other'] = true;
- return app('json')->success($this->services->updateInfo($id, $data) ? '修改成功' : '修改失败');
- }
-
- public function update(Request $request, $id)
- {
- $data = $request->postMore([
- ['phone', 0],
- ['addres', ''],
- ['real_name', ''],
- ['card_id', ''],
- ['birthday', '']
- ]);
- if ($data['phone']) {
- if (!check_phone($data['phone'])) return app('json')->fail('手机号码格式不正确');
- }
- if ($data['card_id']) {
- try {
- if (!check_card($data['card_id'])) return app('json')->fail('请输入正确的身份证');
- } catch (\Throwable $e) {
- }
- }
- if (!$id) return app('json')->fail('数据不存在');
- $data['adminId'] = $request->outId;
- return app('json')->success($this->services->updateInfo($id, $data) ? '修改成功' : '修改失败');
- }
-
- public function address_list(Request $request, UserAddressServices $services, $uid = 0)
- {
- if (!$uid) return app('json')->fail('数据不存在');
- return app('json')->successful($services->getUserAddressList($uid, 'id,real_name,phone,province,city,district,detail,is_default,city_id'));
- }
-
- public function money(Request $request, $uid)
- {
- if (!$uid) return app('json')->fail('数据不存在');
- return app('json')->success($this->services->getUserInfo($uid, 'now_money'));
- }
-
- public function spread_commission(UserMoneyServices $services, $uid)
- {
- if (!$uid) return app('json')->fail('数据不存在');
- return app('json')->successful($services->userMoneyList($uid, 1));
- }
- }
|