Added fromDate and thruDate fields to the ProductPromoCode entity; if the dates are set they are used to specify the validity range of the promotion code.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@581961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+11
-1
@@ -512,6 +512,17 @@ public class ProductPromoWorker {
|
||||
if (productPromoCode == null) {
|
||||
return "The promotion code [" + productPromoCodeId + "] is not valid.";
|
||||
}
|
||||
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
|
||||
if (productPromoCode.getTimestamp("thruDate") != null) {
|
||||
if (nowTimestamp.after(productPromoCode.getTimestamp("thruDate"))) {
|
||||
return "The promotion code [" + productPromoCodeId + "] is expired in: " + productPromoCode.getTimestamp("thruDate");
|
||||
}
|
||||
}
|
||||
if (productPromoCode.getTimestamp("fromDate") != null) {
|
||||
if (nowTimestamp.before(productPromoCode.getTimestamp("fromDate"))) {
|
||||
return "The promotion code [" + productPromoCodeId + "] will be activated in: " + productPromoCode.getTimestamp("fromDate");
|
||||
}
|
||||
}
|
||||
|
||||
if ("Y".equals(productPromoCode.getString("requireEmailOrParty"))) {
|
||||
boolean hasEmailOrParty = false;
|
||||
@@ -524,7 +535,6 @@ public class ProductPromoWorker {
|
||||
}
|
||||
|
||||
// check email address in ProductPromoCodeEmail
|
||||
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
|
||||
List validEmailCondList = new ArrayList();
|
||||
validEmailCondList.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId));
|
||||
validEmailCondList.add(new EntityExpr("productPromoCodeId", EntityOperator.EQUALS, productPromoCodeId));
|
||||
|
||||
@@ -2794,6 +2794,8 @@ under the License.
|
||||
<field name="requireEmailOrParty" type="indicator"></field>
|
||||
<field name="useLimitPerCode" type="numeric"></field>
|
||||
<field name="useLimitPerCustomer" type="numeric"></field>
|
||||
<field name="fromDate" type="date-time"></field>
|
||||
<field name="thruDate" type="date-time"></field>
|
||||
<field name="createdDate" type="date-time"></field>
|
||||
<field name="createdByUserLogin" type="id-vlong"></field>
|
||||
<field name="lastModifiedDate" type="date-time"></field>
|
||||
|
||||
@@ -160,6 +160,9 @@ under the License.
|
||||
<field-to-result field-name="productPromoCodeId" map-name="newEntity"/>
|
||||
|
||||
<now-timestamp-to-env env-name="nowTimestamp"/>
|
||||
<if-empty field-name="newEntity.fromDate">
|
||||
<set field="newEntity.fromDate" from-field="nowTimestamp"/>
|
||||
</if-empty>
|
||||
<set from-field="nowTimestamp" field="newEntity.createdDate"/>
|
||||
<set from-field="nowTimestamp" field="newEntity.lastModifiedDate"/>
|
||||
<set from-field="userLogin.userLoginId" field="newEntity.lastModifiedByUserLogin"/>
|
||||
|
||||
Reference in New Issue
Block a user