|
@@ -3,8 +3,13 @@ package com.pj.project.app_user;
|
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
|
import com.pj.api.client.level_two_server.LevelTwoServerInterface;
|
|
|
import com.pj.api.client.transport.TransportInterface;
|
|
|
+import com.pj.api.dto.DriverDto;
|
|
|
+import com.pj.api.dto.EnterpriseDto;
|
|
|
import com.pj.api.dto.PeopleDto;
|
|
|
+import com.pj.api.dto.PurchaserDto;
|
|
|
import com.pj.common.core.exception.ServiceException;
|
|
|
+import com.pj.project.app_user.vo.AppUserVo;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -34,37 +39,110 @@ public class MethodAppUserService {
|
|
|
* (4,"司机"),
|
|
|
* (5,"国内收购商");
|
|
|
*/
|
|
|
- public boolean insertEntity(AppUser appUser,Integer userType){
|
|
|
+ public AppUserVo getRoleName(AppUserVo appUser, Integer userType){
|
|
|
if(userType == null || userType.toString().trim().equals(""))
|
|
|
- throw new ServiceException("注册身份选择错误!");
|
|
|
+ throw new ServiceException("身份错误!");
|
|
|
+ //创建返回值对象
|
|
|
+ AppUserVo appUserVo = new AppUserVo();
|
|
|
+ BeanUtils.copyProperties(appUser,appUserVo);
|
|
|
switch (userType){
|
|
|
case 1:
|
|
|
- people(appUser);
|
|
|
+ appUserVo = setPeopleProperties(appUser);
|
|
|
break;
|
|
|
case 2:
|
|
|
+ appUserVo = setPeopleProperties(appUser);
|
|
|
break;
|
|
|
case 3:
|
|
|
+ appUserVo = setEnterprise(appUser);
|
|
|
break;
|
|
|
case 4:
|
|
|
+ appUserVo = setDriver(appUser);
|
|
|
break;
|
|
|
case 5:
|
|
|
+ appUserVo = setPurchaser(appUser);
|
|
|
break;
|
|
|
default:
|
|
|
throw new RuntimeException("用户身份选择错误!");
|
|
|
}
|
|
|
|
|
|
|
|
|
- return false;
|
|
|
+ return appUser;
|
|
|
}
|
|
|
|
|
|
- public void people(AppUser appUser){
|
|
|
- PeopleDto peopleDto = new PeopleDto();
|
|
|
- //设置基本信息
|
|
|
- peopleDto.setPhone(appUser.getPhone());
|
|
|
- peopleDto.setRegisterTime(appUser.getCreateTime());
|
|
|
- peopleDto.setName(appUser.getName());
|
|
|
-// peopleDto.setCode(); // 边民号
|
|
|
- levelOneServerInterface.peopleDto(peopleDto);
|
|
|
+ /**
|
|
|
+ * 二级市场商户
|
|
|
+ * @param appUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ AppUserVo setPurchaser(AppUserVo appUser){
|
|
|
+ //查询国内收购商
|
|
|
+ PurchaserDto purchaserDto = levelTwoServerInterface.getByPurchaserId(appUser.getFk());
|
|
|
+ if(purchaserDto == null)throw new ServiceException("二级市场商户远程调用失败!");
|
|
|
+ //设置基本属性
|
|
|
+ appUser.setRoleName("国内收购商");
|
|
|
+ appUser.setTradeAreaName("国内");
|
|
|
+ appUser.setGenderName("待填");
|
|
|
+ appUser.setAge(purchaserDto.getAge() + "岁");
|
|
|
+ appUser.setAddress(purchaserDto.getAddress());
|
|
|
+
|
|
|
+ return appUser;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 司机
|
|
|
+ * @param appUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ AppUserVo setDriver(AppUserVo appUser){
|
|
|
+ //查询货运司机
|
|
|
+ DriverDto driverDto = transportInterface.getByDriverId(appUser.getFk());
|
|
|
+ if(driverDto == null)throw new ServiceException("司机远程调用失败!");
|
|
|
+ //设置基本属性
|
|
|
+ appUser.setRoleName("司机");
|
|
|
+ appUser.setTradeAreaName(driverDto.getTradeAreaName());
|
|
|
+ appUser.setGenderName(driverDto.getSex() == 1? "男" : "女");
|
|
|
+ appUser.setAge(driverDto.getAge() + "岁");
|
|
|
+ appUser.setAddress(driverDto.getAddress());
|
|
|
+ return appUser;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商家
|
|
|
+ * @param appUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ AppUserVo setEnterprise(AppUserVo appUser){
|
|
|
+ //查询一级市场商户表
|
|
|
+ EnterpriseDto enterprise = levelOneServerInterface.getEnterpriseById(appUser.getFk());
|
|
|
+ if(enterprise == null)throw new ServiceException("一级市场商户远程调用失败!");
|
|
|
+ //设置基本属性
|
|
|
+ appUser.setRoleName("一级市场商户");
|
|
|
+ appUser.setTradeAreaName("待填");
|
|
|
+ appUser.setGenderName(enterprise.getSex() == 1? "男" : "女");
|
|
|
+ appUser.setAge(enterprise.getAge() + "岁");
|
|
|
+ appUser.setAddress(enterprise.getAddress());
|
|
|
+ return appUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 边民
|
|
|
+ * @param appUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ AppUserVo setPeopleProperties(AppUserVo appUser){
|
|
|
+ //查询边民表
|
|
|
+ PeopleDto peopleDto = levelOneServerInterface.getRpcById(appUser.getFk());
|
|
|
+ if(peopleDto == null)throw new ServiceException("一级市场边民远程调用失败!");
|
|
|
+ //设置基本属性
|
|
|
+ appUser.setRoleName(peopleDto.getRole() == 1? "普通边民" : "边民组组长");
|
|
|
+ appUser.setTradeAreaName(peopleDto.getTradeAreaName());
|
|
|
+ appUser.setGroupName(peopleDto.getGroupName());
|
|
|
+ appUser.setAge(peopleDto.getAge() + "岁");
|
|
|
+ appUser.setGenderName(peopleDto.getSex() == 1? "男" : "女");
|
|
|
+ appUser.setAddress(peopleDto.getAddress());
|
|
|
+ return appUser;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|