diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTyAgentPriceController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTyAgentPriceController.java index 8ddcc751..87b2d63f 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTyAgentPriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTyAgentPriceController.java @@ -13,6 +13,7 @@ import com.hai.model.ResponseData; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -123,12 +124,7 @@ public class HighTyAgentPriceController { // 价格 HighTyAgentPrice priceRate = tyAgentPriceService.getDetail(station.getId(), price.getOilNo().toString()); if (priceRate == null) { - HighGasDiscountOilPrice oilNo = gasDiscountOilPriceService.getDetailByOilNo(price.getOilNo().toString()); - if (oilNo == null) { - oilPriceMap.put("priceRate", 0); - } else { - oilPriceMap.put("priceRate", oilNo.getPriceRate()); - } + oilPriceMap.put("priceRate", MapUtils.getLong(oilPriceMap, "lowPrice")); } else { oilPriceMap.put("priceRate", priceRate.getPriceRate()); } diff --git a/hai-service/src/main/java/com/hai/service/HighTyAgentService.java b/hai-service/src/main/java/com/hai/service/HighTyAgentService.java index 75cc8782..b5b7da38 100644 --- a/hai-service/src/main/java/com/hai/service/HighTyAgentService.java +++ b/hai-service/src/main/java/com/hai/service/HighTyAgentService.java @@ -21,7 +21,7 @@ public interface HighTyAgentService { * 增加代理商 * @param tyAgent */ - void addAgent(HighTyAgent tyAgent); + void addAgent(HighTyAgent tyAgent) throws Exception; /** * 修改代理商 diff --git a/hai-service/src/main/java/com/hai/service/HighTySalesmanService.java b/hai-service/src/main/java/com/hai/service/HighTySalesmanService.java index fb8b4d83..1b9317d2 100644 --- a/hai-service/src/main/java/com/hai/service/HighTySalesmanService.java +++ b/hai-service/src/main/java/com/hai/service/HighTySalesmanService.java @@ -20,7 +20,7 @@ public interface HighTySalesmanService { * 增加业务员 * @param tySalesman */ - void addSalesman(HighTySalesman tySalesman); + void addSalesman(HighTySalesman tySalesman) throws Exception; /** * 修改业务员 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTyAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTyAgentServiceImpl.java index 62a416af..2d364938 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighTyAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighTyAgentServiceImpl.java @@ -52,29 +52,25 @@ public class HighTyAgentServiceImpl implements HighTyAgentService { @Override @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) - public void addAgent(HighTyAgent tyAgent) { - try { - if (secUserService.findByPhone(tyAgent.getAgentPhone()) != null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已存在,请更换"); - } - - editTyAgent(tyAgent); - - SecUser secUser = new SecUser(); - secUser.setUserName(tyAgent.getAgentName()); - secUser.setLoginName(tyAgent.getAgentPhone()); - secUser.setPassword(MD5Util.encode("123456".getBytes())); - secUser.setAdminFlag(1); - secUser.setStatus(1); - secUser.setRoleId(7L); - secUser.setObjectType(UserObjectTypeEnum.type6.getType()); - secUser.setObjectId(tyAgent.getId()); - secUser.setCreateTime(new Date()); - secUser.setUpdateTime(new Date()); - secUserService.addUser(secUser); - } catch (Exception e) { - e.printStackTrace(); + public void addAgent(HighTyAgent tyAgent) throws Exception { + if (secUserService.findByPhone(tyAgent.getAgentPhone()) != null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已存在,请更换"); } + + editTyAgent(tyAgent); + + SecUser secUser = new SecUser(); + secUser.setUserName(tyAgent.getAgentName()); + secUser.setLoginName(tyAgent.getAgentPhone()); + secUser.setPassword(MD5Util.encode("123456".getBytes())); + secUser.setAdminFlag(1); + secUser.setStatus(1); + secUser.setRoleId(7L); + secUser.setObjectType(UserObjectTypeEnum.type6.getType()); + secUser.setObjectId(tyAgent.getId()); + secUser.setCreateTime(new Date()); + secUser.setUpdateTime(new Date()); + secUserService.addUser(secUser); } @Override diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTySalesmanServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTySalesmanServiceImpl.java index 20288f67..0eccac97 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighTySalesmanServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighTySalesmanServiceImpl.java @@ -52,31 +52,29 @@ public class HighTySalesmanServiceImpl implements HighTySalesmanService { } @Override - public void addSalesman(HighTySalesman tySalesman) { - try { - if (secUserService.findByPhone(tySalesman.getSalesmanPhone()) != null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已存在,请更换"); - } - editTySalesman(tySalesman); - - SecUser secUser = new SecUser(); - secUser.setUserName(tySalesman.getSalesmanName()); - secUser.setLoginName(tySalesman.getSalesmanPhone()); - secUser.setPassword(MD5Util.encode("123456".getBytes())); - secUser.setAdminFlag(1); - secUser.setStatus(1); - secUser.setRoleId(8L); - secUser.setObjectType(UserObjectTypeEnum.type7.getType()); - secUser.setObjectId(tySalesman.getId()); - secUser.setCreateTime(new Date()); - secUser.setUpdateTime(new Date()); - secUserService.addUser(secUser); - } catch (Exception e) { - e.printStackTrace(); + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void addSalesman(HighTySalesman tySalesman) throws Exception { + if (secUserService.findByLoginName(tySalesman.getSalesmanPhone()) != null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "在系统中此联系电话已存在,请更换"); } + editTySalesman(tySalesman); + + SecUser secUser = new SecUser(); + secUser.setUserName(tySalesman.getSalesmanName()); + secUser.setLoginName(tySalesman.getSalesmanPhone()); + secUser.setPassword(MD5Util.encode("123456".getBytes())); + secUser.setAdminFlag(1); + secUser.setStatus(1); + secUser.setRoleId(8L); + secUser.setObjectType(UserObjectTypeEnum.type7.getType()); + secUser.setObjectId(tySalesman.getId()); + secUser.setCreateTime(new Date()); + secUser.setUpdateTime(new Date()); + secUserService.addUser(secUser); } @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) public void updateSalesman(HighTySalesman tySalesman) { // 查询账户 SecUser account = secUserService.getMainAccount(UserObjectTypeEnum.type7.getType(), tySalesman.getId());