123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <?php
- namespace app\data\controller\api\business;
- use app\data\model\ShopFeedback;
- use app\data\model\SystemUserAmount;
- use app\data\model\SystemUserBank;
- use app\data\model\SystemUserWithdrawal;
- use think\admin\Controller;
- use hg\apidoc\annotation\Title;
- use hg\apidoc\annotation\Method;
- use hg\apidoc\annotation\Param;
- use hg\apidoc\annotation\Returned;
- use think\admin\model\SystemUser;
- /**
- * 商家个人中心
- */
- class User extends Controller
- {
- /**
- * 控制器初始化
- */
- protected function initialize()
- {
- $purchase_model = new Common($this->app);
- $user = $purchase_model->uuid();
- $this->user = $user;
- }
- /**
- * @Title ("用户信息")
- * @Method ("get")
- * @return void
- */
- public function user_info(){
- $user_info = $this->user;
- $this->success('用户信息',$user_info);
- }
- /**
- * @Title ("意见反馈")
- * @Method ("post")
- * @Param ("title",desc="反馈标题")
- * @Param ("content",desc="反馈内容")
- * @Param ("image",desc="图片")
- * @return void
- */
- public function feedback(){
- $data = $this->_vali([
- 'title.require'=>'反馈标题不能为空',
- 'content.require'=>'反馈内容不能为空',
- 'image.default'=>''
- ]);
- $feedback_data= [
- 'admin_id'=>$this->user->id,
- 'title'=>$data['title'],
- 'content'=>$data['content'],
- 'image'=>$data['image'],
- 'status'=>1,
- 'create_time'=>date('Y-m-d H:i:s')
- ];
- ShopFeedback::mk()->insert($feedback_data);
- $this->success('意见反馈已提交');
- }
- /**
- * @Title ("反馈意见列表")
- * @Method ("get")
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function feedback_list(){
- $admin_id = $this->user->id;
- $list = ShopFeedback::mk()->where('admin_id',$admin_id)->select();
- $this->success('反馈意见列表',$list);
- }
- /**
- * @Title ("删除意见")
- * @Method ("post")
- * @Param ("feedback_id",desc="删除意见数据id")
- * @return void
- */
- public function del_feedback(){
- $data = $this->_vali(
- [
- 'feedback_id.require'=>"参数不能为空",
- ]
- );
- $admin_id =$this->user->id;
- ShopFeedback::mk()->where('id',$data['feedback'])->where('admin_id',$admin_id)->delete();
- $this->success('反馈记录已删除');
- }
- /**
- * @Title ("编辑意见信息")
- * @Method ("post")
- * @Param ("feedback_id",desc="编辑意见数据id")
- * @Param ("title",desc="反馈标题")
- * @Param ("content",desc="反馈内容")
- * @Param ("image",desc="图片")
- * @return void
- */
- public function save_feedback(){
- $data = $this->_vali(
- [
- 'feedback_id.require'=>"参数不能为空",
- 'title.require'=>'反馈标题不能为空',
- 'content.require'=>'反馈内容不能为空',
- 'image.default'=>''
- ]
- );
- $feedback_data=[
- 'title'=>$data['title'],
- 'content'=>$data['content'],
- 'image'=>$data['image'],
- 'status'=>1,
- 'create_time'=>date('Y-m-d H:i:s')
- ];
- $admin_id =$this->user->id;
- ShopFeedback::mk()->where('id',$data['feedback'])->where('admin_id',$admin_id)->save($feedback_data);
- $this->success('反馈记录已删除');
- }
- /**
- * @Title ("添加用户银行卡")
- * @Method("post")
- * @Param ("bank",desc="银行名称")
- * @Param ("number",desc="银行卡号")
- * @Param ("address",desc="开户行")
- * @Param ("real_name",desc="持卡人真是姓名")
- * @return void
- */
- public function bank_add(){
- $admin_id = $this->user->id;
- $data = $this->_vali([
- 'bank.require'=>'银行名称不能空',
- 'number.require'=>'银行卡号不能为空',
- 'address.require'=>'开户行信息不能为空',
- 'real_name.require'=>'持卡人姓名不能为空'
- ]);
- $bank_data = [
- 'admin_id'=>$admin_id,
- 'bank'=>$data['bank'],
- 'number'=>$data['number'],
- 'address'=>$data['address'],
- 'real_name'=>$data['real_name']
- ];
- SystemUserBank::mk()->insertGetId($bank_data);
- $this->success('银行卡添加成功');
- }
- /**
- * @Title ("我的银行卡列表")
- * @Method ("get")
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function user_bank(){
- echo 222;die;
- $admin_id = $this->user->id;
- $query = SystemUserBank::mQuery();
- $list = $query->where('admin_id',$admin_id->id)->order('id desc')->page(true, false, false, 10);
- echo SystemUserBank::getLastSql();
- $this->success('银行卡列表',$list);
- }
- /**
- * @Title ("银行卡解绑")
- * @Method ("post")
- * @Param ("bank_id",desc="银行卡id")
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function bank_del(){
- $admin_id = $this->user->id;
- $data = $this->_vali(
- ['id.require'=>'请选择解绑银行']
- );
- $is_have = SystemUserBank::mk()->where(['admin_id'=>$admin_id,'id'=>$data])->find();
- if(empty($is_have)){
- $this->error('解绑信息错误');
- }
- SystemUserBank::mk()->where(['admin_id'=>$admin_id,'id'=>$data])->delete();
- $this->success('银行卡已解绑');
- }
- /**
- * @Title ("邮箱绑定")
- * @Method ("post")
- * @Param ("mailbox",desc="邮箱")
- * @return void
- */
- public function user_mailbox(){
- $admin_id = $this->user->id;
- $data = $this->_vali(
- ['mailbox.require'=>'邮箱不能为空!']
- );
- SystemUser::mk()->where('id',$admin_id)->save(['contact_mail'=>$data['mailbox']]);
- $this->success('邮箱绑定成功');
- }
- /**
- * @Title ("修改密码")
- * @Method ("post")
- * @Param ("old_password",desc="原始密码")
- * @Param ("new_password",desc="新密码")
- * @return void
- */
- public function user_password(){
- $admin_id= $this->user->id;
- $data = $this->_vali(
- [
- 'old_password.require'=>'原始密码不能为空',
- 'new_password.require'=>'新密码不能为空'
- ]
- );
- if($this->user->password!=md5($data['old_password'])){
- $this->error('原始密码不正确');
- }
- $token=rand('00000','99999');
- SystemUser::mk()->where('id',$admin_id)->save(['password'=>md5($data['new_password']),'token'=>$token]);
- $this->success('密码重置成功请重新登录!');
- }
- /**
- * @Title ("商家提现申请")
- * @Method ("post")
- * @Param ("bank_number",desc="提现卡号")
- * @Param ("money",desc="提现金额")
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function user_withdrawal(){
- $admin_id= $this->user->id;
- $data = $this->_vali(
- [
- 'bank_number.require'=>'提现卡号不能为空',
- 'money.require'=>'提现金额不能为空'
- ]
- );
- if($data['money']<1){
- $this->error('提现金额不能小于'.'1');
- }
- if($data['money']>$this->user->money){
- $this->error('余额不足');
- }
- $bank_info = SystemUserBank::mk()->where(['admin_id'=>$admin_id,'number'=>$data['bank_number']])->find();
- if($bank_info){
- $this->error('提现账号有问题');
- }
- $withdrawal_data = [
- 'admin_id'=>$admin_id,
- 'real_name'=>$data['real_name'],
- 'bank'=>$bank_info['bank'],
- 'number'=>$bank_info['number'],
- 'address'=>$bank_info['address'],
- 'money'=>$data['money'],
- 'before'=>$this->user->money,
- 'after'=>$this->user->money-$data['money'],
- 'charges'=>10,
- 'amount'=>$data['money']-10,
- 'create_time'=>date('Y-m-d H:i:s'),
- 'status'=>1
- ];
- SystemUserWithdrawal::mk()->insertGetId($withdrawal_data);
- $this->success('提现申请已提交,等待打款');
- }
- /**
- * @Title ("余额记录")
- * @Method ("get")
- * @return void
- */
- public function user_amount(){
- $admin_id = $this->user->id;
- $query = SystemUserAmount::mQuery();
- $list = $query->where('admin_id',$admin_id->id)->order('id desc')->page(true, false, false, 10);
- $this->success('余额记录明细',$list);
- }
- }
|