|  | @@ -1,15 +1,15 @@
 | 
	
		
			
				|  |  |  package com.yonge.cooleshow.tenant.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | +import com.google.gson.JsonObject;
 | 
	
		
			
				|  |  | +import com.timevale.tech.sdk.seal.IFontsLoader;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.service.SmsCodeService;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.service.*;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.constant.SysConfigConstant;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.controller.BaseController;
 | 
	
	
		
			
				|  | @@ -17,18 +17,20 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.security.SecurityConstants;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.tenant.io.request.SysUserWrapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.tenant.io.request.TenantInfoVo;
 | 
	
		
			
				|  |  | +import com.yonge.toolset.base.exception.BizException;
 | 
	
		
			
				|  |  | +import com.yonge.toolset.utils.obj.ObjectUtil;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParam;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParams;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | +import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | +import org.springframework.beans.BeanInstantiationException;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.PostMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RequestBody;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.validation.Valid;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @Author:haonan
 | 
	
	
		
			
				|  | @@ -89,11 +91,11 @@ public class TenantInfoController extends BaseController {
 | 
	
		
			
				|  |  |      @ApiOperation(value = "修改机构信息", notes = "传入TenantInfo")
 | 
	
		
			
				|  |  |  //    @PreAuthorize("@pcs.hasPermissions('tenantInfoUpdate/update')")
 | 
	
		
			
				|  |  |      public HttpResponseResult<Boolean> updateTenantInfo(@Valid @RequestBody TenantInfoVo.TenantInfo info) {
 | 
	
		
			
				|  |  | -        SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -        Long id = sysUser.getId();
 | 
	
		
			
				|  |  | -        TenantStaff staff = tenantStaffService.lambdaQuery().eq(TenantStaff::getUserId, id).list().get(0);
 | 
	
		
			
				|  |  | -        Long tenantId = staff.getTenantId();
 | 
	
		
			
				|  |  | -        return succeed(tenantInfoService.updateTenantInfo(JSON.parseObject(info.jsonString(), TenantInfo.class), tenantId));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        TenantInfo tenantInfo = JSON.parseObject(info.jsonString(), TenantInfo.class);
 | 
	
		
			
				|  |  | +            tenantInfoService.updateById(tenantInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return  HttpResponseResult.succeed(true);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -110,10 +112,13 @@ public class TenantInfoController extends BaseController {
 | 
	
		
			
				|  |  |          TenantInfoWrapper.TenantInfo info = new TenantInfoWrapper.TenantInfo();
 | 
	
		
			
				|  |  |          SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  |          Long id = sysUser.getId();
 | 
	
		
			
				|  |  | -        TenantStaff staff = tenantStaffService.lambdaQuery().eq(TenantStaff::getUserId, id).list().get(0);
 | 
	
		
			
				|  |  | -        Long tenantId = staff.getTenantId();
 | 
	
		
			
				|  |  | -        if (!(tenantId == null)){
 | 
	
		
			
				|  |  | -            info = tenantInfoService.detailTenantInfo(id);
 | 
	
		
			
				|  |  | +        List<TenantStaff> list = tenantStaffService.lambdaQuery().eq(TenantStaff::getUserId, id).list();
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(list)){
 | 
	
		
			
				|  |  | +            TenantStaff staff = list.get(0);
 | 
	
		
			
				|  |  | +            Long tenantId = staff.getTenantId();
 | 
	
		
			
				|  |  | +            if (!(tenantId == null)){
 | 
	
		
			
				|  |  | +                info = tenantInfoService.detailTenantInfo(tenantId);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return succeed(info);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -140,34 +145,67 @@ public class TenantInfoController extends BaseController {
 | 
	
		
			
				|  |  |      @PostMapping("/sysUserUpdate")
 | 
	
		
			
				|  |  |      @ApiOperation(value = "用户修改", notes = "用户修改")
 | 
	
		
			
				|  |  |  //    @PreAuthorize("@pcs.hasPermissions('tenantInfoUpdate/sysUserUpdate')")
 | 
	
		
			
				|  |  | -    public HttpResponseResult<Boolean> sysUserUpdate(SysUserWrapper.SysUser sysUser) {
 | 
	
		
			
				|  |  | -        com.yonge.cooleshow.biz.dal.entity.SysUser sysUser1 = JSON.parseObject(sysUser.jsonString(), com.yonge.cooleshow.biz.dal.entity.SysUser.class);
 | 
	
		
			
				|  |  | -        SysUser user = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -        tenantInfoService.updateSysUser(sysUser1,user.getId());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //判断更改的手机所属的机构信息
 | 
	
		
			
				|  |  | +    public HttpResponseResult<Boolean> sysUserUpdate(@RequestBody SysUserWrapper.SysUser sysUser) {
 | 
	
		
			
				|  |  | +        String code = sysUser.getCode();
 | 
	
		
			
				|  |  |          String phone = sysUser.getPhone();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //设置默认头像
 | 
	
		
			
				|  |  | -        if (sysUser.getAvatar().isEmpty()){
 | 
	
		
			
				|  |  | -            sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        com.yonge.cooleshow.biz.dal.entity.SysUser sysUser1 = JSON.parseObject(sysUser.jsonString(), com.yonge.cooleshow.biz.dal.entity.SysUser.class);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        TenantInfo info = tenantInfoService.lambdaQuery().eq(TenantInfo::getPhone, phone).list().get(0);
 | 
	
		
			
				|  |  | -        if (!(info == null)){
 | 
	
		
			
				|  |  | -            //更新tennatInfo
 | 
	
		
			
				|  |  | -            tenantInfoService.lambdaUpdate().set(TenantInfo::getPhone,phone)
 | 
	
		
			
				|  |  | -                                            .eq(TenantInfo::getUserId,user.getId());
 | 
	
		
			
				|  |  | +        //如果传手机号
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotBlank(phone)){
 | 
	
		
			
				|  |  | +            boolean re = smsCodeService.verifyValidCode(phone, code, "PHONE");
 | 
	
		
			
				|  |  | +            if (re){
 | 
	
		
			
				|  |  | +                SysUser user = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | +                tenantInfoService.updateSysUser(sysUser1, user.getId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //设置默认头像
 | 
	
		
			
				|  |  | +                if (StringUtils.isEmpty(sysUser.getAvatar())) {
 | 
	
		
			
				|  |  | +                    sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //判断更改的手机所属的机构信息
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                String oldPhone = user.getPhone();
 | 
	
		
			
				|  |  | +                //查看原机构信息
 | 
	
		
			
				|  |  | +                List<TenantInfo> list = tenantInfoService.lambdaQuery().eq(TenantInfo::getPhone, oldPhone).list();
 | 
	
		
			
				|  |  | +                if (CollectionUtils.isNotEmpty(list)){
 | 
	
		
			
				|  |  | +                    TenantInfo info = list.get(0);
 | 
	
		
			
				|  |  | +                    if (ObjectUtil.isEmpty(info)) {
 | 
	
		
			
				|  |  | +                        //更新tennatInfo
 | 
	
		
			
				|  |  | +                        info.setPhone(phone);
 | 
	
		
			
				|  |  | +                        tenantInfoService.updateById(info);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //更新员工表
 | 
	
		
			
				|  |  | +                Long id = user.getId();
 | 
	
		
			
				|  |  | +                TenantStaff staff = tenantStaffService.getByUserId(id);
 | 
	
		
			
				|  |  | +                if (staff != null){
 | 
	
		
			
				|  |  | +                    staff.setNickname(sysUser.getUsername());
 | 
	
		
			
				|  |  | +                    staff.setAvatar(sysUser.getAvatar());
 | 
	
		
			
				|  |  | +                    tenantStaffService.updateById(staff);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                throw new BizException("手机号校验有误");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }  else {
 | 
	
		
			
				|  |  | +            SysUser user = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | +            tenantInfoService.updateSysUser(sysUser1, user.getId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //设置默认头像
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(sysUser.getAvatar())) {
 | 
	
		
			
				|  |  | +                sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //更新员工表
 | 
	
		
			
				|  |  | -            tenantStaffService.lambdaUpdate().set(TenantStaff::getNickname,sysUser.getUsername())
 | 
	
		
			
				|  |  | -                                             .set(TenantStaff::getAvatar,sysUser.getAvatar())
 | 
	
		
			
				|  |  | -                                             .eq(TenantStaff::getUserId,user.getId());
 | 
	
		
			
				|  |  | +            Long id = user.getId();
 | 
	
		
			
				|  |  | +            TenantStaff staff = tenantStaffService.getByUserId(id);
 | 
	
		
			
				|  |  | +            if (staff != null){
 | 
	
		
			
				|  |  | +                staff.setNickname(sysUser.getUsername());
 | 
	
		
			
				|  |  | +                staff.setAvatar(sysUser.getAvatar());
 | 
	
		
			
				|  |  | +                tenantStaffService.updateById(staff);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +            return HttpResponseResult.succeed(true);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        return HttpResponseResult.succeed(true);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  }
 |