增加活动开始与结束时间

master
yuan 8 years ago
parent 288f7d5e1f
commit 8ce79a8e16

@ -1,16 +1,23 @@
package au.com.royalpay.payment.manage.activities.app_index.beans; package au.com.royalpay.payment.manage.activities.app_index.beans;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import javax.xml.crypto.Data;
import java.text.ParseException;
import java.util.Date;
/** /**
* Created by yuan on 2018/3/14. * Created by yuan on 2018/3/14.
*/ */
public class AppActBean { public class AppActBean {
private static final String[] DATE_PATTERNS = {"yyyy-MM-dd"};
private String act_name; private String act_name;
private String act_url; private String act_url;
private String parms_json; private String params_json;
private Boolean is_valid = true; private Boolean is_valid = true;
private String desc; private String desc;
private String act_content; private String act_content;
@ -18,6 +25,8 @@ public class AppActBean {
private Boolean is_show_window; private Boolean is_show_window;
private String act_img; private String act_img;
private String window_img; private String window_img;
private String active_date;
private String expire_date;
public JSONObject toJsonParam(){ public JSONObject toJsonParam(){
@ -28,8 +37,8 @@ public class AppActBean {
if(StringUtils.isNotEmpty(act_url)){ if(StringUtils.isNotEmpty(act_url)){
params.put("act_url",act_url); params.put("act_url",act_url);
} }
if(StringUtils.isNotEmpty(parms_json)){ if(StringUtils.isNotEmpty(params_json)){
params.put("parms_json",parms_json); params.put("params_json",params_json);
} }
if(StringUtils.isNotEmpty(desc)){ if(StringUtils.isNotEmpty(desc)){
params.put("desc",desc); params.put("desc",desc);
@ -46,6 +55,22 @@ public class AppActBean {
if(StringUtils.isNotEmpty(window_img)){ if(StringUtils.isNotEmpty(window_img)){
params.put("window_img",window_img); params.put("window_img",window_img);
} }
if (active_date != null) {
try {
Date fromDate = DateUtils.parseDate(active_date, DATE_PATTERNS);
params.put("active_date", fromDate);
} catch (ParseException e) {
throw new ParamInvalidException("active_date", "error.payment.valid.invalid_date_format");
}
}
if (expire_date != null) {
try {
Date fromDate = DateUtils.parseDate(expire_date, DATE_PATTERNS);
params.put("expire_date", fromDate);
} catch (ParseException e) {
throw new ParamInvalidException("expire_date", "error.payment.valid.invalid_date_format");
}
}
params.put("is_show_window",is_show_window); params.put("is_show_window",is_show_window);
params.put("is_valid",is_valid); params.put("is_valid",is_valid);
return params; return params;
@ -67,12 +92,12 @@ public class AppActBean {
this.act_url = act_url; this.act_url = act_url;
} }
public String getParms_json() { public String getParams_json() {
return parms_json; return params_json;
} }
public void setParms_json(String parms_json) { public void setParams_json(String params_json) {
this.parms_json = parms_json; this.params_json = params_json;
} }
public String getDesc() { public String getDesc() {
@ -130,4 +155,20 @@ public class AppActBean {
public void setIs_valid(Boolean is_valid) { public void setIs_valid(Boolean is_valid) {
this.is_valid = is_valid; this.is_valid = is_valid;
} }
public String getActive_date() {
return active_date;
}
public void setActive_date(String active_date) {
this.active_date = active_date;
}
public String getExpire_date() {
return expire_date;
}
public void setExpire_date(String expire_date) {
this.expire_date = expire_date;
}
} }

@ -283,6 +283,11 @@ margin-bottom: 10%;"/>
ng-if="('1011110'|withRole) || currentUser.org_id==null">营销服务|Promotion ng-if="('1011110'|withRole) || currentUser.org_id==null">营销服务|Promotion
</li> </li>
<li ui-sref-active="active" ng-if="'appAct'|withModule">
<a ui-sref="appAct">
<i class="fa fa-file-text-o"></i> <span>活动管理|Activity Manage</span>
</a>
</li>
<li ui-sref-active="active" ng-if="('activities'|withModule) && (currentUser.org_id==1 || currentUser.org_id==null)"> <li ui-sref-active="active" ng-if="('activities'|withModule) && (currentUser.org_id==1 || currentUser.org_id==null)">
<a ui-sref="activity.detail({act_id:'3'})" ui-sref-opts="{reload:true}"> <a ui-sref="activity.detail({act_id:'3'})" ui-sref-opts="{reload:true}">
<i class="fa fa-compass"></i> <span>店长行动|Activities</span> <i class="fa fa-compass"></i> <span>店长行动|Activities</span>
@ -413,12 +418,6 @@ margin-bottom: 10%;"/>
</a> </a>
</li> </li>
<li ui-sref-active="active" ng-if="'appAct'|withModule">
<a ui-sref="appAct">
<i class="fa fa-file-text-o"></i> <span>App Act</span>
</a>
</li>
<li ui-sref-active="active" ng-if="('10'|withRole)||('1000000'|withRole)||('10000000'|withRole)"> <li ui-sref-active="active" ng-if="('10'|withRole)||('1000000'|withRole)||('10000000'|withRole)">
<a href="https://customer.royalpay.com.au/manage/sign_in" target="_blank"> <a href="https://customer.royalpay.com.au/manage/sign_in" target="_blank">
<i class="fa fa-file-text-o"></i> <span>积分商城|Integral Mall</span> <i class="fa fa-file-text-o"></i> <span>积分商城|Integral Mall</span>

@ -21,7 +21,7 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
} }
}) })
}]); }]);
app.controller('appActListCtrl', ['$scope', '$state', '$http','commonDialog', function ($scope, $state, $http,commonDialog) { app.controller('appActListCtrl', ['$scope', '$state', '$http','commonDialog','$filter', function ($scope, $state, $http,commonDialog,$filter) {
$scope.pagination = {}; $scope.pagination = {};
$scope.params = {}; $scope.params = {};
$scope.loadActAppList = function (page) { $scope.loadActAppList = function (page) {
@ -33,7 +33,8 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
}); });
}; };
$scope.publishedOrIsValid = function (act) { $scope.publishedOrIsValid = function (act) {
$scope.act = angular.copy(act); $scope.act = {};
$scope.act.act_id = act.act_id;
$scope.act.is_valid = !act.is_valid; $scope.act.is_valid = !act.is_valid;
$http.put('/manager/app/act/' + $scope.act.act_id, $scope.act).then(function (resp) { $http.put('/manager/app/act/' + $scope.act.act_id, $scope.act).then(function (resp) {
commonDialog.alert({title: 'Success', content: '修改成功', type: 'success'}); commonDialog.alert({title: 'Success', content: '修改成功', type: 'success'});
@ -45,8 +46,9 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
$scope.loadActAppList(1); $scope.loadActAppList(1);
}]); }]);
app.controller('appActNewCtrl', ['$rootScope', '$scope', '$http', 'commonDialog','$state', function ($rootScope, $scope, $http, commonDialog,$state) { app.controller('appActNewCtrl', ['$rootScope', '$scope', '$http', 'commonDialog','$state','$filter', function ($rootScope, $scope, $http, commonDialog,$state,$filter) {
$scope.actDetail = {}; $scope.actDetail = {};
$scope.ctrl = {dateInput: false};
$scope.submit = function (form) { $scope.submit = function (form) {
$scope.errmsg = null; $scope.errmsg = null;
if (form.$invalid) { if (form.$invalid) {
@ -57,6 +59,12 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
}); });
return; return;
} }
if ($scope.actDetail.active_date) {
$scope.actDetail.active_date = $filter('date')($scope.actDetail.active_date, 'yyyy-MM-dd');
}
if ($scope.actDetail.expire_date) {
$scope.actDetail.expire_date = $filter('date')($scope.actDetail.expire_date, 'yyyy-MM-dd');
}
$http.put('/manager/app/act/new', $scope.actDetail).then(function (resp) { $http.put('/manager/app/act/new', $scope.actDetail).then(function (resp) {
commonDialog.alert({title: 'Success', content: '新增成功', type: 'success'}); commonDialog.alert({title: 'Success', content: '新增成功', type: 'success'});
$state.go('^.detail',{act_id:resp.data.act_id},{reload:true}); $state.go('^.detail',{act_id:resp.data.act_id},{reload:true});
@ -65,9 +73,18 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
}) })
} }
}]); }]);
app.controller('appActDetailCtrl', ['$rootScope', '$scope', '$http', 'commonDialog', 'actDetail','$state', function ($rootScope, $scope, $http, commonDialog,actDetail,$state) { app.controller('appActDetailCtrl', ['$rootScope', '$scope', '$http', 'commonDialog', 'actDetail','$state','$filter', function ($rootScope, $scope, $http, commonDialog,actDetail,$state,$filter) {
$scope.actDetail = actDetail.data; $scope.actDetail = actDetail.data;
$scope.ctrl = {dateInput: false};
$scope.actDetail.active_date = new Date($scope.actDetail.active_date);
$scope.actDetail.expire_date = new Date($scope.actDetail.expire_date);
$scope.submit = function () { $scope.submit = function () {
if ($scope.actDetail.active_date) {
$scope.actDetail.active_date = $filter('date')($scope.actDetail.active_date, 'yyyy-MM-dd');
}
if ($scope.actDetail.expire_date) {
$scope.actDetail.expire_date = $filter('date')($scope.actDetail.expire_date, 'yyyy-MM-dd');
}
$http.put('/manager/app/act/' + $scope.actDetail.act_id, $scope.actDetail).then(function (resp) { $http.put('/manager/app/act/' + $scope.actDetail.act_id, $scope.actDetail).then(function (resp) {
commonDialog.alert({title: 'Success', content: '修改成功', type: 'success'}); commonDialog.alert({title: 'Success', content: '修改成功', type: 'success'});
$state.reload(); $state.reload();

@ -44,11 +44,37 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-4 col-sm-2" for="actDetail.parms_json">Parms <label class="control-label col-xs-4 col-sm-2"
for="actDetail.act_name">活动时间 *</label>
<div class="col-xs-8 col-sm-4">
<div style="display: inline-block" ng-class="{'has-error':appActForm.active_date.$invalid && appActForm.active_date.$dirty}">
<input class="form-control" id="date-from-input"
ng-model="actDetail.active_date"
uib-datepicker-popup size="10" placeholder="Active Date"
is-open="dateBegin.open" ng-click="dateBegin.open=true"
name="active_date" required>
<div ng-messages="appActForm.active_date.$error" ng-if="appActForm.active_date.$dirty">
<p class="small text-danger" ng-message="required">Active Date is required</p>
</div>
</div>
~
<div style="display: inline-block" ng-class="{'has-error':appActForm.expire_date.$invalid && appActForm.expire_date.$dirty}">
<input class="form-control" id="date-to-input" ng-model="actDetail.expire_date"
uib-datepicker-popup size="10" placeholder="Expire Date"
is-open="dateTo.open" ng-click="dateTo.open=true"
name="expire_date" required>
<div ng-messages="appActForm.expire_date.$error" ng-if="appActForm.expire_date.$dirty">
<p class="small text-danger" ng-message="required">Expire Date is required</p>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-2" for="actDetail.params_json">Parms
Json</label> Json</label>
<div class="col-xs-8 col-sm-4"> <div class="col-xs-8 col-sm-4">
<textarea class="form-control" id="actDetail.parms_json" <textarea class="form-control" id="actDetail.params_json"
ng-model="actDetail.parms_json"></textarea> ng-model="actDetail.params_json"></textarea>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

@ -37,9 +37,10 @@
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Title</th> <th>Title</th>
<th>Add Time</th> <th>Add Time</th>
<th>Active Date</th>
<th>Expire Date</th>
<th>Published</th> <th>Published</th>
<th>Operation</th> <th>Operation</th>
</tr> </tr>
@ -48,6 +49,8 @@
<tr ng-repeat="act in app_acts"> <tr ng-repeat="act in app_acts">
<td ng-bind="act.act_name"></td> <td ng-bind="act.act_name"></td>
<td ng-bind="act.create_time"></td> <td ng-bind="act.create_time"></td>
<td ng-bind="act.active_date"></td>
<td ng-bind="act.expire_date"></td>
<td> <td>
<span ng-click="publishedOrIsValid(act)"> <span ng-click="publishedOrIsValid(act)">
<i class="text-success fa fa-check" ng-if="act.is_valid"></i> <i class="text-success fa fa-check" ng-if="act.is_valid"></i>

Loading…
Cancel
Save