couponLanguage.setRecCreateBy(adminBean.getUser().getUserId());
couponLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
coupon.setCouponLanguage(couponLanguage);
}
CouponCurrency couponCurrency = coupon.getCouponCurrency();
if (couponCurrency == null) {
couponCurrency = new CouponCurrency();
couponCurrency.setCoupon(coupon);
coupon.getCouponCurrencies().add(couponCurrency);
SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) em.find(SiteCurrencyClass.class, form.getSiteCurrencyClassDefaultId());
couponCurrency.setSiteCurrencyClass(siteCurrencyClass);
couponCurrency.setRecCreateBy(adminBean.getUser().getUserId());
couponCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
coupon.setCouponCurrency(couponCurrency);
}
couponLanguage.setCouponName(form.getCouponName());
couponLanguage.setRecUpdateBy(adminBean.getUser().getUserId());
couponLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
em.persist(couponLanguage);
couponCurrency.setCouponDiscountAmount(null);
couponCurrency.setCouponOrderAmount(null);
if (form.getCouponType().equals(Constants.COUPONTYPE_DISCOUNT_AMOUNT)) {
couponCurrency.setCouponDiscountAmount(Format.getFloat(form.getCouponDiscountAmount()));
}
if (form.getCouponType().equals(Constants.COUPONTYPE_DISCOUNT_OVER_AMOUNT)) {
couponCurrency.setCouponDiscountAmount(Format.getFloat(form.getCouponDiscountAmount()));
couponCurrency.setCouponOrderAmount(Format.getFloatObj(form.getCouponOrderAmount()));
}
couponCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
couponCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
em.persist(couponCurrency);
}