fix update customer code
This commit is contained in:
+5
-4
@@ -157,17 +157,18 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
logger.setContent(jackson.writeValueAsString(customer));
|
logger.setContent(jackson.writeValueAsString(customer));
|
||||||
GaoCustomer dbCustomer = get(customer.getId());
|
GaoCustomer dbCustomer = get(customer.getId());
|
||||||
TimiException.requiredTrue(dbCustomer.getStoreId().equals(customer.getStoreId()), "customer.storeId invalid");
|
TimiException.requiredTrue(dbCustomer.getStoreId().equals(customer.getStoreId()), "customer.storeId invalid");
|
||||||
dbCustomer.setCode(TimiJava.defaultIfEmpty(customer.getCode(), null));
|
String code = TimiJava.defaultIfEmpty(customer.getCode(), null);
|
||||||
{
|
{
|
||||||
if (!Objects.equals(dbCustomer.getCode(), customer.getCode()) && TimiJava.isNotEmpty(customer.getCode())) {
|
if (!Objects.equals(dbCustomer.getCode(), code) && TimiJava.isNotEmpty(code)) {
|
||||||
GaoCustomer byCode = getByCode(customer.getStoreId(), customer.getCode());
|
GaoCustomer byCode = getByCode(customer.getStoreId(), code);
|
||||||
TimiException.requiredTrue(byCode == null || !byCode.getId().equals(dbCustomer.getId()), "该姓名客户已登记");
|
TimiException.requiredTrue(byCode == null || byCode.getId().equals(dbCustomer.getId()), "该编码客户已登记");
|
||||||
}
|
}
|
||||||
if (!Objects.equals(dbCustomer.getName(), customer.getName())) {
|
if (!Objects.equals(dbCustomer.getName(), customer.getName())) {
|
||||||
GaoCustomer byName = getByName(customer.getStoreId(), customer.getName());
|
GaoCustomer byName = getByName(customer.getStoreId(), customer.getName());
|
||||||
TimiException.requiredTrue(byName == null || !byName.getId().equals(dbCustomer.getId()), "该姓名客户已登记");
|
TimiException.requiredTrue(byName == null || !byName.getId().equals(dbCustomer.getId()), "该姓名客户已登记");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dbCustomer.setCode(code);
|
||||||
dbCustomer.setName(customer.getName());
|
dbCustomer.setName(customer.getName());
|
||||||
fillPinyin(dbCustomer);
|
fillPinyin(dbCustomer);
|
||||||
dbCustomer.setGender(customer.getGender());
|
dbCustomer.setGender(customer.getGender());
|
||||||
|
|||||||
Reference in New Issue
Block a user