Authored by 匡佳华

促销活动update

... ... @@ -124,6 +124,7 @@ public class PromotionServiceImpl implements IPromotionService {
activityRsp.setPromotionType(activity.getPromotionType());
activityRsp.setJoinLimitTimes(activity.getJoinLimitTimes());
activityRsp.setProductLimitType(activity.getProductLimitType());
activityRsp.setStatus(activity.getStatus());
if(activity.getProductLimitType().split(",").length == 9){//是否选择全部商品类型
activityRsp.setIsProductTypeAll(1);
}else {
... ... @@ -153,7 +154,7 @@ public class PromotionServiceImpl implements IPromotionService {
productScopeList.add(bo);
}
activityRsp.setProductScopeList(productScopeList);
log.info("getDetailById end. id is {}, rsp is {}", id, activityRsp);
return new ApiResponse.ApiResponseBuilder().data(activityRsp).build();
}
... ... @@ -192,7 +193,8 @@ public class PromotionServiceImpl implements IPromotionService {
PromotionActivity activity = activityMapper.selectByPrimaryKey(id);//获取当前活动的开始结束时间
PromotionActivity activityCheck = activityMapper.selectActivityWithinTime(activity.getStartTime(), activity.getEndTime(), id);
if (activityCheck != null) {
return new ApiResponse.ApiResponseBuilder().code(201).message("活动生效期间有其他活动开启中,无法开启此活动").build();
log.warn("updateStatusById fail: exist same promotionType activity. id is {}, status is {}", id, status);
return new ApiResponse.ApiResponseBuilder().code(201).message("该时段已经存在相同类型的活动,请修改活动时间").build();
}
}
PromotionActivity activity = new PromotionActivity();
... ... @@ -274,23 +276,27 @@ public class PromotionServiceImpl implements IPromotionService {
Integer startTime = DateUtil.getTimeSecondsFromStr(req.getStartTimeStr(), DateUtil.DATE_TIME_FORMAT);
Integer endTime = DateUtil.getTimeSecondsFromStr(req.getEndTimeStr(), DateUtil.DATE_TIME_FORMAT);
if(startTime == null || endTime == null || endTime < startTime){
log.warn("checkParams fail: endTime less than startTime. req is {}", req);
return new ApiResponse.ApiResponseBuilder().code(201).message("结束时间必须大于开始时间").build();
}
if(req.getInitStatus().equals(PromotionStatusEnum.OPEN.getCode())
&&(activityMapper.selectActivityWithinTime(startTime, endTime, req.getId()) != null)){
return new ApiResponse.ApiResponseBuilder().code(201).message("活动生效期间有其他活动开启中,无法开启此活动").build();
log.warn("checkParams fail: exist same promotionType activity. req is {}", req);
return new ApiResponse.ApiResponseBuilder().code(201).message("该时段已经存在相同类型的活动,请修改活动时间").build();
}
for(String params : req.getPromotionProductScopes().split("-")){
PromotionProductScopeBo scopeBo = JSON.parseObject(params, PromotionProductScopeBo.class);
if(scopeBo.getProductScopeType().equals(PromotionProductLimitEnum.ALL.getCode())) continue;
Integer poolId = Integer.valueOf(scopeBo.getScopeValue());
if(ufoProductPoolMapper.selectOneById(poolId) == null){
log.warn("checkParams fail: productPoolId is invalid. req is {}", req);
return new ApiResponse.ApiResponseBuilder().code(201).message("商品池Id无效").build();
}
}
for(String params : req.getPromotionAmountConditions().split("-")){
PromotionAmountConditionBo conditionBo = JSON.parseObject(params,PromotionAmountConditionBo.class);
if(conditionBo.getLimitAmount() * conditionBo.getOfferAmount() > conditionBo.getOfferMaxLimit()){
log.warn("checkParams fail: amountCondition is invalid. req is {}", req);
return new ApiResponse.ApiResponseBuilder().code(201).message("最小折扣不能大于折扣最大值").build();
}
}
... ...
... ... @@ -92,7 +92,7 @@
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>活动是否开启:</label></td>
<td colspan="3">
<input class="easyui-combobox" id="initStatus" name="initStatus" style="width: 200px;"/>
<input class="easyui-combobox" id="initStatus" name="initStatus" data-options="required:true" style="width: 200px;"/>
</td>
</tr>
</table>
... ... @@ -134,6 +134,7 @@
valueField : "value",
data:[{text:"折扣",value:"2"}],
panelHeight : 80,
editable:false,
onSelect : function(record){
if(record.value == 1){
//满减
... ... @@ -158,6 +159,7 @@
$("#promotionEditForm #limitType").combobox({
textField : "text",
valueField : "value",
editable: false,
panelHeight : 80,
data:[{text:"属于",value:"1"},{text:"不属于",value:"2"}],
onLoadSuccess : function(){
... ... @@ -166,13 +168,12 @@
});
$("#promotionEditForm #initStatus").combobox({
prompt:"请选择",
textField : "text",
valueField : "value",
panelHeight : 80,
editable:false,
data:[{text:"开启",value:"1"},{text:"关闭",value:"2"}],
onLoadSuccess : function(){
$("#promotionEditForm #initStatus").combobox("setValue",2);
}
});
$("#promotionEditForm #productScopeType").combobox({
... ... @@ -180,6 +181,7 @@
textField : "text",
valueField : "value",
panelHeight : 80,
editable: false,
url : contextPath + "/PromotionController/getProductLimitEnums.do",
onSelect : function(record){
if(record.value == 1){//全部商品
... ... @@ -249,7 +251,7 @@
}, function (data) {
var loadData = data.data;
$("#promotionEditForm").form("load", loadData);
$("#initStatus").combobox("setValue",loadData.status);
$("#startTimeStr").datetimebox("setValue",loadData.startTimeStr);
$("#endTimeStr").datetimebox("setValue",loadData.endTimeStr);
$("#promotionType").combobox("setValue",loadData.promotionType);
... ...
... ... @@ -130,10 +130,10 @@
align: "center",
formatter: function (value, rowData) {
var str = "<a role='view' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de'>查看</a>";
str += "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #e68900'>编辑</a>";
if(rowData.status == 1){
str += "<a role='close' dataId='" + rowData.id + "' style='margin-left:10px;background-color: red'>关闭</a>";
}else if(rowData.status == 2){
str += "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #e68900'>编辑</a>";
str += "<a role='open' dataId='" + rowData.id + "' style='margin-left:10px;background-color: green'>开启</a>";
}
return str;
... ...