|
@@ -1,6 +1,7 @@
|
|
|
package com.zhentao.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.api.IErrorCode;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -30,18 +31,54 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon>
|
|
|
if (couponDto==null || StringUtils.checkValNull(couponDto.getTacticsType())
|
|
|
|| StringUtils.checkValNull(couponDto.getName())
|
|
|
|| StringUtils.checkValNull(couponDto.getGetWay())
|
|
|
+ || StringUtils.checkValNull(couponDto.getFaceValue())
|
|
|
|| StringUtils.checkValNull(couponDto.getProductType())
|
|
|
|| StringUtils.checkValNull(couponDto.getLimitMinFlag())
|
|
|
+ || StringUtils.checkValNull(couponDto.getImgUrl())
|
|
|
|| StringUtils.checkValNull(couponDto.getValidFlag())
|
|
|
|| StringUtils.checkValNull(couponDto.getGetTimeLimit())
|
|
|
+ || StringUtils.checkValNull(couponDto.getShopId())
|
|
|
|| StringUtils.checkValNull(couponDto.getTotalLimit())) {
|
|
|
throw new RRException(BestConstants.PARAMS_ERROR_MSG);
|
|
|
}else {
|
|
|
Coupon coupon=new Coupon();
|
|
|
BeanUtil.copyProperties(couponDto,coupon);
|
|
|
- coupon.setCreateddTime(new Date());
|
|
|
- boolean save = this.save(coupon);
|
|
|
- return null;
|
|
|
+ if (coupon.getId()==null){
|
|
|
+ coupon.setCreateddTime(new Date());
|
|
|
+ this.save(coupon);
|
|
|
+ }else {
|
|
|
+ coupon.setUpdatedTime(new Date());
|
|
|
+ this.updateById(coupon);
|
|
|
+ }
|
|
|
+ return R.ok(BestConstants.ADDITION_WAS_SUCCESSFUL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R hide(Long couponId) {
|
|
|
+ if (couponId==null) {
|
|
|
+ throw new RRException(BestConstants.PARAMS_ERROR_MSG);
|
|
|
+ }else {
|
|
|
+ Coupon coupon=this.getById(couponId);
|
|
|
+ if (coupon==null) {
|
|
|
+ throw new RRException(BestConstants.COUPON_NOT_FOUND_MSG);
|
|
|
+ }else {
|
|
|
+ coupon.setStatus(BestConstants.HIDE_FLAG);
|
|
|
+ this.updateById(coupon);
|
|
|
+ return R.ok(BestConstants.HIDE_WAS_SUCCESSFUL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R delCoupon(Long couponId) {
|
|
|
+ if (couponId==null){
|
|
|
+ throw new RRException(BestConstants.PARAMS_ERROR_MSG);
|
|
|
+ }
|
|
|
+ if (this.removeById(couponId)){
|
|
|
+ return R.ok(BestConstants.DELETE_SUCCESS_MSG);
|
|
|
+ }else {
|
|
|
+ throw new RRException(BestConstants.DELETE_FAILED_MSG);
|
|
|
}
|
|
|
}
|
|
|
}
|