Beispiel #1
0
 public CustomerRecordDTO createCustomerRecordDTO(
     CustomerRecordDTO customerRecordDTO, Long shopId) {
   customerRecordDTO.setShopId(shopId);
   customerRecordDTO.setName("MRS.SHAO");
   customerRecordDTO.setCustomerId(2343545L);
   customerRecordDTO.setArea("苏州");
   customerRecordDTO.setBankAccountName("test");
   customerRecordDTO.setShortName("test");
   customerRecordDTO.setCustomerKind("s");
   customerRecordDTO.setMobile("15151774444");
   customerRecordDTO.setAddress("shanghai");
   customerRecordDTO.setContact("MR.SHAO");
   customerRecordDTO.setPhone("0512-0808");
   customerRecordDTO.setFax("test");
   customerRecordDTO.setBank("test");
   customerRecordDTO.setQq("test");
   customerRecordDTO.setAccount("test");
   customerRecordDTO.setMemberNumber("test");
   customerRecordDTO.setEmail("test");
   return customerRecordDTO;
 }
Beispiel #2
0
  /**
   * 创建100个客户,客户记录 用于测试
   *
   * @param shopId
   * @throws BcgogoException
   */
  private void createCustomerAndCustomerRecordDTO(Long shopId) throws BcgogoException {
    for (int i = 0; i < 100; i++) {
      CustomerRecordDTO customerRecordDTO = new CustomerRecordDTO();
      CustomerDTO customerDTO = new CustomerDTO();
      customerDTO.setName("MRS.SHAO" + i);
      customerDTO.setShopId(shopId);
      customerDTO.setArea("苏州" + i);
      customerDTO.setBankAccountName("test" + i);
      customerDTO.setShortName("test" + i);
      customerDTO.setCustomerKind("s" + i);
      customerDTO.setMobile("15151774444" + i);
      customerDTO.setAddress("shanghai" + i);
      customerDTO.setContact("MR.SHAO" + i);
      customerDTO.setFax("test" + i);
      customerDTO.setBank("test" + i);
      customerDTO.setQq("test" + i);
      customerDTO.setAccount("test" + i);
      customerDTO.setEmail("test" + i);

      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());
      userService.createCustomerRecord(customerRecordDTO);
      userService.createCustomer(customerDTO);
    }
  }
Beispiel #3
0
  @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());
  }