コード例 #1
0
ファイル: CustomerTest.java プロジェクト: ndong211/bo
 @Test
 public void testClientInfo() throws Exception {
   ModelMap model = new ModelMap();
   Long shopId = createShop();
   request.getSession().setAttribute("shopId", shopId);
   CustomerRecordDTO customerRecordDTO = new CustomerRecordDTO();
   CustomerDTO customer = new CustomerDTO();
   CustomerVehicleDTO customerVehicleDTO = new CustomerVehicleDTO();
   VehicleDTO vehicleDTO = new VehicleDTO();
   createCustomerDTO(customer, shopId);
   createCustomerRecordDTO(customerRecordDTO, shopId);
   createVehicleDTO(vehicleDTO, shopId);
   IUserService userService = ServiceManager.getService(IUserService.class);
   userService.createCustomerRecord(customerRecordDTO);
   CustomerDTO customerDTO = userService.createCustomer(customer);
   VehicleDTO vehicleDTO1 = userService.createVehicle(vehicleDTO);
   userService.addVehicleToCustomer(vehicleDTO1.getId(), customerDTO.getId());
   txnController.clientInfo(model, request, "MRS.SHAO", "15151774444", "phone", "2343545", "", "");
   CustomerRecordDTO customerRecordDTO2 = (CustomerRecordDTO) model.get("customerRecordDTO");
   Assert.assertEquals("MRS.SHAO", customerRecordDTO2.getName());
   Assert.assertEquals("", customerRecordDTO2.getContact());
   Assert.assertEquals("15151774444", customerRecordDTO2.getMobile());
   txnController.clientInfo(model, request, "邵磊", "15151774443", "", "", "小邵", "");
   CustomerRecordDTO customerRecordDTO3 = (CustomerRecordDTO) model.get("customerRecordDTO");
   Assert.assertEquals("邵磊", customerRecordDTO3.getName());
   Assert.assertEquals("15151774443", customerRecordDTO3.getMobile());
 }
コード例 #2
0
ファイル: CustomerTest.java プロジェクト: ndong211/bo
 public VehicleDTO createVehicleDTO(VehicleDTO vehicleDTO, Long shopId) {
   vehicleDTO.setShopId(shopId);
   vehicleDTO.setLicenceNo("苏A00098");
   vehicleDTO.setBrand("奥迪");
   vehicleDTO.setModel("A6");
   vehicleDTO.setYear("2012");
   return vehicleDTO;
 }
コード例 #3
0
  public CustomerSupplierSolrIndexDTO(CustomerDTO customerDTO, String doc_type) {
    this.doc_type = doc_type;
    this.id = customerDTO.getId();
    this.shop_id = customerDTO.getShopId();
    this.customer_or_supplier = "customer";
    this.customer_or_supplier_shop_id =
        customerDTO.getCustomerShopId() == null ? "" : customerDTO.getCustomerShopId().toString();
    this.name = customerDTO.getName();
    this.address = customerDTO.getAddress();
    this.contactDTOList = customerDTO.getContactDTOList();
    this.created_time = customerDTO.getCreationDate();
    if (CollectionUtils.isNotEmpty(customerDTO.getVehicleDTOList())) {
      license_nos = new ArrayList<String>();
      vehicle_brands = new ArrayList<String>();
      vehicle_models = new ArrayList<String>();
      vehicle_colors = new ArrayList<String>();
      vehicle_details = new ArrayList<String>();
      for (VehicleDTO vehicleDTO : customerDTO.getVehicleDTOList()) {
        StringBuffer sb = new StringBuffer();
        if (StringUtils.isNotBlank(vehicleDTO.getLicenceNo())) {
          license_nos.add(vehicleDTO.getLicenceNo());
          sb.append(vehicleDTO.getLicenceNo());
        }
        if (StringUtils.isNotBlank(vehicleDTO.getBrand())) {
          vehicle_brands.add(vehicleDTO.getBrand());
          sb.append(" ").append(vehicleDTO.getBrand());
        }
        if (StringUtils.isNotBlank(vehicleDTO.getModel())) {
          vehicle_models.add(vehicleDTO.getModel());
          sb.append(" ").append(vehicleDTO.getModel());
        }
        if (StringUtils.isNotBlank(vehicleDTO.getColor())) {
          vehicle_colors.add(vehicleDTO.getColor());
          sb.append(" ").append(vehicleDTO.getColor());
        }
        vehicle_details.add(sb.toString().trim());
      }
    }
    this.total_amount = customerDTO.getTotalAmount();
    this.total_debt = customerDTO.getTotalReceivable();
    this.last_expense_time = customerDTO.getLastExpenseTime();
    this.total_return_debt = customerDTO.getTotalReturnDebt();

    if (customerDTO.getMemberDTO() != null
        && customerDTO.getMemberDTO().getStatus() != MemberStatus.DISABLED) {
      this.member_no = customerDTO.getMemberDTO().getMemberNo();
      this.member_type = customerDTO.getMemberDTO().getType();
      this.balance = NumberUtil.doubleVal(customerDTO.getMemberDTO().getBalance());
    } else {
      this.member_type = "非会员";
    }
    this.status = customerDTO.getStatus();
    this.relationType = customerDTO.getRelationType();
    this.vehicles = customerDTO.getVehicleDTOList();
    List<Long> areaIdList = new ArrayList<Long>();
    if (customerDTO.getProvince() != null) {
      areaIdList.add(customerDTO.getProvince());
    }
    if (customerDTO.getCity() != null) {
      areaIdList.add(customerDTO.getCity());
    }
    if (customerDTO.getRegion() != null) {
      areaIdList.add(customerDTO.getRegion());
    }
    this.setArea_ids(areaIdList);
    this.setArea_info(customerDTO.getAreaInfo());
    this.setDual_identity_id(customerDTO.getSupplierId());
    this.total_deposit = customerDTO.getDeposit();
    this.is_obd = customerDTO.getIsObd();
    this.setAppUser(customerDTO.isAppUser());
  }
コード例 #4
0
ファイル: CustomerTest.java プロジェクト: ndong211/bo
  @Test
  public void testDeleteCustomer() throws Exception {
    Long shopId = createShop();
    CustomerRecordDTO customerRecordDTO = new CustomerRecordDTO();
    CustomerDTO customerDTO = new CustomerDTO();
    customerDTO.setName("cfl");
    customerDTO.setShopId(shopId);
    customerDTO.setArea("苏州");
    customerDTO.setBankAccountName("test");
    customerDTO.setShortName("test");
    customerDTO.setCustomerKind("s");
    customerDTO.setMobile("15151774444");
    customerDTO.setAddress("shanghai");
    customerDTO.setContact("MR.SHAO");
    customerDTO.setFax("test");
    customerDTO.setBank("test");
    customerDTO.setQq("test");
    customerDTO.setAccount("test");
    customerDTO.setEmail("test");
    customerDTO.setBirthday(222L);
    customerDTO.setLandLine("44444444");
    ContactDTO[] contactDTOs = new ContactDTO[3];
    ContactDTO contactDTO = new ContactDTO();
    contactDTO.setCustomerId(customerDTO.getId());
    contactDTO.setMobile("15151774444");
    contactDTO.setIsMainContact(1);
    contactDTO.setShopId(shopId);
    contactDTO.setLevel(0);
    contactDTOs[0] = contactDTO;
    customerDTO.setContacts(contactDTOs);
    customerDTO = userService.createCustomer(customerDTO);

    customerRecordDTO.setShopId(shopId);
    customerRecordDTO.setName(customerDTO.getName());
    customerRecordDTO.setCustomerId(customerDTO.getId());
    customerRecordDTO.setArea(customerDTO.getArea());
    customerRecordDTO.setBankAccountName(customerDTO.getBankAccountName());
    customerRecordDTO.setShortName(customerDTO.getShortName());
    customerRecordDTO.setCustomerKind(customerDTO.getCustomerKind());
    customerRecordDTO.setMobile(customerDTO.getMobile());
    customerRecordDTO.setAddress(customerDTO.getAddress());
    customerRecordDTO.setContact(customerDTO.getContact());
    customerRecordDTO.setPhone(customerDTO.getMobile());
    customerRecordDTO.setFax(customerDTO.getFax());
    customerRecordDTO.setBank(customerDTO.getBank());
    customerRecordDTO.setQq(customerDTO.getQq());
    customerRecordDTO.setAccount(customerDTO.getAccount());
    customerRecordDTO.setMemberNumber(customerDTO.getMemberNumber());
    customerRecordDTO.setEmail(customerDTO.getEmail());
    customerRecordDTO = userService.createCustomerRecord(customerRecordDTO);

    VehicleDTO vehicleDTO = new VehicleDTO();
    vehicleDTO.setLicenceNo("苏U66666");
    vehicleDTO.setShopId(shopId);

    vehicleDTO = userService.createVehicle(vehicleDTO);

    CustomerVehicle customerVehicle = new CustomerVehicle();
    customerVehicle.setCustomerId(customerDTO.getId());
    customerVehicle.setVehicleId(vehicleDTO.getId());

    UserWriter writer = userDaoManager.getWriter();

    Object status = writer.begin();

    try {
      writer.save(customerVehicle);
      writer.commit(status);
    } finally {
      writer.rollback(status);
    }
    Customer customer = userService.getCustomerByCustomerId(customerDTO.getId(), shopId);

    Assert.assertNotNull(customer);
    List<CustomerDTO> customerDTOList = userService.getCustomerByBirth(customerDTO.getBirthday());
    Assert.assertEquals(1, customerDTOList.size());

    customerDTOList = userService.getCustomerByLicenceNo(shopId, vehicleDTO.getLicenceNo());

    Assert.assertEquals(1, customerDTOList.size());

    customerDTOList = userService.getCustomerByMobile(shopId, customerDTO.getMobile());
    Assert.assertEquals(1, customerDTOList.size());

    customerDTOList = userService.getCustomerByName(shopId, customerDTO.getName());

    Assert.assertEquals(1, customerDTOList.size());

    customerDTOList = userService.getCustomerByTelephone(shopId, customerDTO.getLandLine());
    Assert.assertEquals(1, customerDTOList.size());

    List<CustomerRecordDTO> customerRecordDTOList =
        userService.getCustomerRecordByName(customerDTO.getName());
    Assert.assertEquals(1, customerRecordDTOList.size());

    List<VehicleDTO> vehicleDTOList =
        userService.getVehicleByLicenceNo(shopId, vehicleDTO.getLicenceNo());
    Assert.assertEquals(1, vehicleDTOList.size());

    vehicleDTOList = userService.getVehicleByMobile(shopId, customerDTO.getMobile());
    Assert.assertEquals(1, vehicleDTOList.size());

    request.setParameter("customerId", customerDTO.getId().toString());
    customerController.deleteCustomer(modelMap, request, response);

    customer = userService.getCustomerByCustomerId(customerDTO.getId(), shopId);

    Assert.assertNotNull(customer);
    customerDTOList = userService.getCustomerByBirth(customerDTO.getBirthday());
    Assert.assertEquals(0, customerDTOList.size());

    customerDTOList = userService.getCustomerByLicenceNo(shopId, vehicleDTO.getLicenceNo());

    Assert.assertEquals(0, customerDTOList.size());

    customerDTOList = userService.getCustomerByMobile(shopId, customerDTO.getMobile());
    Assert.assertEquals(0, customerDTOList.size());

    customerDTOList = userService.getCustomerByName(shopId, customerDTO.getName());

    Assert.assertNull(customerDTOList);

    customerDTOList = userService.getCustomerByTelephone(shopId, customerDTO.getLandLine());
    Assert.assertEquals(0, customerDTOList.size());

    customerRecordDTOList = userService.getCustomerRecordByName(customerDTO.getName());
    Assert.assertEquals(0, customerRecordDTOList.size());

    vehicleDTOList = userService.getVehicleByLicenceNo(shopId, vehicleDTO.getLicenceNo());
    Assert.assertEquals(0, vehicleDTOList.size());

    vehicleDTOList = userService.getVehicleByMobile(shopId, customerDTO.getMobile());
    Assert.assertEquals(0, vehicleDTOList.size());
  }