|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.bweb.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
@ -7,6 +8,7 @@ import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
import com.hai.common.security.SessionObject; |
|
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
|
import com.hai.common.utils.DateUtil; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.entity.HighDiscount; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
@ -23,6 +25,8 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@ -73,11 +77,19 @@ public class HighDiscountController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 计算销售截止时间
|
|
|
|
|
Calendar salesEndTime = Calendar.getInstance(); |
|
|
|
|
salesEndTime.setTime(highDiscount.getSalesEndTime()); |
|
|
|
|
salesEndTime.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
salesEndTime.set(Calendar.MINUTE, 59); |
|
|
|
|
salesEndTime.set(Calendar.SECOND, 59); |
|
|
|
|
highDiscount.setSalesEndTime(salesEndTime.getTime()); |
|
|
|
|
|
|
|
|
|
highDiscount.setDiscountKey(DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); |
|
|
|
|
highDiscount.setCompanyId(userInfoModel.getBsCompany().getId()); |
|
|
|
|
highDiscount.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
|
highDiscount.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
highDiscount.setStatus(1); |
|
|
|
|
|
|
|
|
|
highDiscountService.insertDiscount(highDiscount); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
@ -114,11 +126,18 @@ public class HighDiscountController { |
|
|
|
|
log.error("HighDiscountController -> updateDiscount() error!","未找到优惠券信息"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_DISCOUNT, ""); |
|
|
|
|
} |
|
|
|
|
// 计算销售截止时间
|
|
|
|
|
Calendar salesEndTime = Calendar.getInstance(); |
|
|
|
|
salesEndTime.setTime(highDiscount.getSalesEndTime()); |
|
|
|
|
salesEndTime.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
salesEndTime.set(Calendar.MINUTE, 59); |
|
|
|
|
salesEndTime.set(Calendar.SECOND, 59); |
|
|
|
|
|
|
|
|
|
discount.setSalesEndTime(salesEndTime.getTime()); |
|
|
|
|
discount.setDiscountName(highDiscount.getDiscountName()); |
|
|
|
|
discount.setDiscountImg(highDiscount.getDiscountImg()); |
|
|
|
|
discount.setDiscountCarouselImg(highDiscount.getDiscountCarouselImg()); |
|
|
|
|
discount.setEffectiveDay(highDiscount.getEffectiveDay()); |
|
|
|
|
discount.setSalesEndTime(highDiscount.getSalesEndTime()); |
|
|
|
|
|
|
|
|
|
highDiscountService.updateDiscount(highDiscount); |
|
|
|
|
|
|
|
|
@ -130,6 +149,29 @@ public class HighDiscountController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/updateDiscountStatus",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "修改优惠券状态") |
|
|
|
|
public ResponseData updateDiscountStatus(@RequestParam(name = "discountId", required = true) Long discountId, |
|
|
|
|
@RequestParam(name = "status", required = true) Integer status) { |
|
|
|
|
try { |
|
|
|
|
// 查询优惠券
|
|
|
|
|
HighDiscount discount = highDiscountService.getDiscountById(discountId); |
|
|
|
|
if (discount == null) { |
|
|
|
|
log.error("HighDiscountController -> updateDiscountStatus() error!","未找到优惠券信息"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_DISCOUNT, ""); |
|
|
|
|
} |
|
|
|
|
discount.setStatus(status); |
|
|
|
|
discount.setUpdateTime(new Date()); |
|
|
|
|
highDiscountService.updateDiscount(discount); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighDiscountController -> updateDiscountStatus() error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/getDiscountById",method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "根据id查询") |
|
|
|
@ -168,5 +210,4 @@ public class HighDiscountController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|