}
}
Iterator<?> taxes = orderItemDetail.getOrderDetailTaxes().iterator();
while (taxes.hasNext()) {
OrderDetailTax orderDetailTax = (OrderDetailTax) taxes.next();
if (orderDetailTax.getRecCreateDatetime() == null) {
orderDetailTax.setRecCreateBy(userId);
orderDetailTax.setRecCreateDatetime(current);
}
orderDetailTax.setRecUpdateBy(userId);
orderDetailTax.setRecUpdateDatetime(current);
if (orderDetailTax.getOrderDetailTaxId() == null) {
em.persist(orderDetailTax);
}
}
}
iterator = orderHeader.getOrderOtherDetails().iterator();
while (iterator.hasNext()) {
OrderOtherDetail orderOtherDetail = (OrderOtherDetail) iterator.next();
if (isDirty(orderOtherDetail.getCoupon())) {
if (orderOtherDetail.getRecCreateDatetime() == null) {
orderOtherDetail.setRecCreateBy(userId);
orderOtherDetail.setRecCreateDatetime(current);
orderOtherDetail.setOrderHeader(orderHeader);
}
orderOtherDetail.setRecUpdateBy(userId);
orderOtherDetail.setRecUpdateDatetime(current);
if (orderOtherDetail.getOrderOtherDetailId() == null) {
em.persist(orderOtherDetail);
}
}
}
PaymentTran paymentTran = orderHeader.getPaymentTran();
if (paymentTran != null) {
if (paymentTran.getRecUpdateDatetime() == null) {
paymentTran.setRecCreateBy(userId);
paymentTran.setRecCreateDatetime(current);
paymentTran.setRecUpdateBy(userId);
paymentTran.setRecUpdateDatetime(current);
if (paymentTran.getPaymentTranId() == null) {
em.persist(paymentTran);
}
}
}
paymentTran = orderHeader.getVoidPaymentTran();
if (paymentTran != null) {
if (paymentTran.getRecUpdateDatetime() == null) {
paymentTran.setRecCreateBy(userId);
paymentTran.setRecCreateDatetime(current);
paymentTran.setRecUpdateBy(userId);
paymentTran.setRecUpdateDatetime(current);
if (paymentTran.getPaymentTranId() == null) {
em.persist(paymentTran);
}
}
}
if (orderHeader.getCustAddress() != null) {
OrderAddress custAddress = orderHeader.getCustAddress();
if (custAddress.getRecCreateBy() == null) {
custAddress.setRecCreateBy(userId);
custAddress.setRecCreateDatetime(current);
}
custAddress.setRecUpdateBy(userId);
custAddress.setRecUpdateDatetime(current);
if (orderHeader.getCustAddress().getOrderAddressId() == null) {
em.persist(orderHeader.getCustAddress());
}
}
if (orderHeader.getShippingAddress() != null) {
OrderAddress shippingAddress = orderHeader.getShippingAddress();
if (shippingAddress.getRecCreateBy() == null) {
shippingAddress.setRecCreateBy(userId);
shippingAddress.setRecCreateDatetime(current);
}
shippingAddress.setRecUpdateBy(userId);
shippingAddress.setRecUpdateDatetime(current);
if (orderHeader.getShippingAddress().getOrderAddressId() == null) {
em.persist(orderHeader.getShippingAddress());
}
}
if (orderHeader.getBillingAddress() != null) {
OrderAddress billingAddress = orderHeader.getBillingAddress();
if (billingAddress.getRecCreateBy() == null) {
billingAddress.setRecCreateBy(userId);
billingAddress.setRecCreateDatetime(current);
}
billingAddress.setRecUpdateBy(userId);
billingAddress.setRecUpdateDatetime(current);
if (orderHeader.getBillingAddress().getOrderAddressId() == null) {
em.persist(orderHeader.getBillingAddress());
}
}
Iterator<?> taxes = orderHeader.getOrderTaxes().iterator();
while (taxes.hasNext()) {
OrderDetailTax orderDetailTax = (OrderDetailTax) taxes.next();
if (orderDetailTax.getRecCreateDatetime() == null) {
orderDetailTax.setRecCreateBy(userId);
orderDetailTax.setRecCreateDatetime(current);
}
orderDetailTax.setRecUpdateBy(userId);
orderDetailTax.setRecUpdateDatetime(current);
if (orderDetailTax.getOrderDetailTaxId() == null) {
em.persist(orderDetailTax);
}
}
// orderHeader.setOrderStatus(calcStatus(orderHeader));