diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 51e544cd..460e6503 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -85,11 +85,18 @@ public class HighCouponController { || highCoupon.getRecycleDay() == null || highCoupon.getLimitNumber()== null || highCoupon.getSalesPrice()== null + || highCoupon.getDiscountPrice() == null || highCoupon.getIsPresent() == null) { log.error("HighCouponController -> insertCoupon() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + // 折扣价格 大于 销售价格 + if (highCoupon.getDiscountPrice().compareTo(highCoupon.getSalesPrice()) == 1) { + log.error("HighCouponController -> insertCoupon() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.DISCOUNT_PRICE_BIG_SALES_PRICE_ERROR, ""); + } + // 是否赠送卡卷 if (highCoupon.getIsPresent() == true) { if (highCoupon.getHandselCouponId() == null || highCoupon.getHandselCouponId().size() == 0) { @@ -140,7 +147,8 @@ public class HighCouponController { try { SessionObject sessionObject = userCenter.getSessionObject(request); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - if (highCoupon.getMerchantId() == null + if (highCoupon.getId() == null + || highCoupon.getMerchantId() == null || StringUtils.isBlank(highCoupon.getCouponName()) || StringUtils.isBlank(highCoupon.getCouponImg()) || StringUtils.isBlank(highCoupon.getCouponCarouselImg()) @@ -151,11 +159,18 @@ public class HighCouponController { || highCoupon.getRecycleDay() == null || highCoupon.getLimitNumber()== null || highCoupon.getSalesPrice()== null + || highCoupon.getDiscountPrice() == null || highCoupon.getIsPresent() == null) { log.error("HighCouponController -> insertCoupon() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + // 折扣价格 大于 销售价格 + if (highCoupon.getDiscountPrice().compareTo(highCoupon.getSalesPrice()) == 1) { + log.error("HighCouponController -> insertCoupon() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.DISCOUNT_PRICE_BIG_SALES_PRICE_ERROR, ""); + } + // 查询卡券 HighCouponModel coupon = highCouponService.getCouponById(highCoupon.getId()); if (coupon == null) { diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java index 95d3fb91..cef6b47b 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java @@ -9,12 +9,14 @@ 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.HighCoupon; import com.hai.entity.HighCouponHandsel; import com.hai.entity.HighGoodsPriceRefer; import com.hai.entity.HighMerchant; import com.hai.model.HighCouponModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.HighCouponService; import com.hai.service.HighGoodsPriceReferService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -49,6 +51,9 @@ public class HighGoodsPriceReferController { @Resource private HighGoodsPriceReferService highGoodsPriceReferService; + @Resource + private HighCouponService highCouponService; + @RequestMapping(value="/insertGoodsPriceRefer",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "增加产品销售价格") @@ -58,8 +63,10 @@ public class HighGoodsPriceReferController { UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); if (highGoodsPriceRefer.getObjectType() == null || highGoodsPriceRefer.getObjectId() == null + || highGoodsPriceRefer.getPriceType() == null + || highGoodsPriceRefer.getNewSalePrice() == null || highGoodsPriceRefer.getPromptlyType() == null - || highGoodsPriceRefer.getNewSalePrice() == null) { + ) { log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } @@ -70,6 +77,31 @@ public class HighGoodsPriceReferController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + // 失效时间 大于 生效时间 + if (highGoodsPriceRefer.getInvalidTime() != null + && highGoodsPriceRefer.getEffectiveTime() != null + && highGoodsPriceRefer.getInvalidTime().after(highGoodsPriceRefer.getEffectiveTime())) { + log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","失效时间不能大于生效时间"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.INVALID_TIME_BIG_EFFECTIVE_TIME_ERROR, ""); + } + + // 是否满足增加条件 + if (highGoodsPriceReferService.isAddCondition(highGoodsPriceRefer.getObjectType(),highGoodsPriceRefer.getObjectId(),highGoodsPriceRefer.getPriceType()) == false) { + log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","暂时无法增加,有处于在待编辑、待生效、审批中的价格"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PRICE_REFER_STATUS_ERROR, ""); + } + + // 获取旧价格 类型 1.卡卷 + if (highGoodsPriceRefer.getObjectType() == 1) { + HighCouponModel coupon = highCouponService.getCouponById(highGoodsPriceRefer.getId()); + if (coupon != null && highGoodsPriceRefer.getPriceType() == 1) { + highGoodsPriceRefer.setOldSalePrice(coupon.getSalesPrice()); + } + if (coupon != null && highGoodsPriceRefer.getPriceType() == 2) { + highGoodsPriceRefer.setOldSalePrice(coupon.getDiscountPrice()); + } + } + highGoodsPriceRefer.setCreateTime(new Date()); highGoodsPriceRefer.setStatus(101); // 状态: 0:删除 1:待编辑 2:待生效 3:已生效 4:已失效 101.审批中 102.审批驳回 highGoodsPriceRefer.setOperatorId(userInfoModel.getSecUser().getId()); @@ -84,7 +116,7 @@ public class HighGoodsPriceReferController { } } - @RequestMapping(value="/updateGoodsPriceRefer",method = RequestMethod.POST) +/* @RequestMapping(value="/updateGoodsPriceRefer",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "修改产品销售价格") public ResponseData updateGoodsPriceRefer(@RequestBody HighGoodsPriceRefer highGoodsPriceRefer, HttpServletRequest request) { @@ -134,13 +166,14 @@ public class HighGoodsPriceReferController { log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!",e); return ResponseMsgUtil.exception(e); } - } + }*/ @RequestMapping(value="/getPriceReferList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询价格列表") public ResponseData getPriceReferList(@RequestParam(name = "objectType", required = true) Integer objectType, @RequestParam(name = "objectId", required = true) Long objectId, + @RequestParam(name = "priceType", required = false) Integer priceType, @RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { @@ -148,6 +181,7 @@ public class HighGoodsPriceReferController { Map map = new HashMap<>(); map.put("objectType", objectType); map.put("objectId", objectId); + map.put("priceType", priceType); map.put("status", status); PageHelper.startPage(pageNum,pageSize); diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index 9c97a781..cb907935 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -89,6 +89,9 @@ public enum ErrorCode { COUPON_TYPE_ERROR("2117","卡卷类型错误"), COUPON_STATUS_ERROR("2118","卡卷状态错误"), GOODS_PRICE_REFER_ERROR("2119","未找到价格信息"), + DISCOUNT_PRICE_BIG_SALES_PRICE_ERROR("2120","折扣价格不能大于原价"), + INVALID_TIME_BIG_EFFECTIVE_TIME_ERROR("2121","失效时间不能大于生效时间"), + PRICE_REFER_STATUS_ERROR("2122","暂时无法增加,有处于在待编辑、待生效、审批中的价格"), STATUS_ERROR("3000","状态错误"), ADD_DATA_ERROR("3001","增加数据失败"), diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponMapper.java index 3a696510..5f7a6a4c 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponMapper.java @@ -45,22 +45,24 @@ public interface HighCouponMapper extends HighCouponMapperExt { "coupon_carousel_img, coupon_desc, ", "coupon_type, sales_end_time, ", "recycle_day, limit_number, ", - "sales_price, sales_count, ", - "is_present, create_time, ", - "update_time, operator_id, ", - "operator_name, `status`, ", - "ext_1, ext_2, ext_3)", + "sales_price, discount_price, ", + "sales_count, is_present, ", + "create_time, update_time, ", + "operator_id, operator_name, ", + "`status`, ext_1, ext_2, ", + "ext_3)", "values (#{companyId,jdbcType=BIGINT}, #{merchantId,jdbcType=BIGINT}, ", "#{couponKey,jdbcType=VARCHAR}, #{couponName,jdbcType=VARCHAR}, ", "#{couponPrice,jdbcType=DECIMAL}, #{couponImg,jdbcType=VARCHAR}, ", "#{couponCarouselImg,jdbcType=VARCHAR}, #{couponDesc,jdbcType=VARCHAR}, ", "#{couponType,jdbcType=INTEGER}, #{salesEndTime,jdbcType=TIMESTAMP}, ", "#{recycleDay,jdbcType=INTEGER}, #{limitNumber,jdbcType=INTEGER}, ", - "#{salesPrice,jdbcType=DECIMAL}, #{salesCount,jdbcType=INTEGER}, ", - "#{isPresent,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{updateTime,jdbcType=TIMESTAMP}, #{operatorId,jdbcType=BIGINT}, ", - "#{operatorName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{salesPrice,jdbcType=DECIMAL}, #{discountPrice,jdbcType=DECIMAL}, ", + "#{salesCount,jdbcType=INTEGER}, #{isPresent,jdbcType=BIT}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", + "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", + "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", + "#{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighCoupon record); @@ -85,6 +87,7 @@ public interface HighCouponMapper extends HighCouponMapperExt { @Result(column="recycle_day", property="recycleDay", jdbcType=JdbcType.INTEGER), @Result(column="limit_number", property="limitNumber", jdbcType=JdbcType.INTEGER), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL), @Result(column="sales_count", property="salesCount", jdbcType=JdbcType.INTEGER), @Result(column="is_present", property="isPresent", jdbcType=JdbcType.BIT), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @@ -102,8 +105,8 @@ public interface HighCouponMapper extends HighCouponMapperExt { "select", "id, company_id, merchant_id, coupon_key, coupon_name, coupon_price, coupon_img, ", "coupon_carousel_img, coupon_desc, coupon_type, sales_end_time, recycle_day, ", - "limit_number, sales_price, sales_count, is_present, create_time, update_time, ", - "operator_id, operator_name, `status`, ext_1, ext_2, ext_3", + "limit_number, sales_price, discount_price, sales_count, is_present, create_time, ", + "update_time, operator_id, operator_name, `status`, ext_1, ext_2, ext_3", "from high_coupon", "where id = #{id,jdbcType=BIGINT}" }) @@ -122,6 +125,7 @@ public interface HighCouponMapper extends HighCouponMapperExt { @Result(column="recycle_day", property="recycleDay", jdbcType=JdbcType.INTEGER), @Result(column="limit_number", property="limitNumber", jdbcType=JdbcType.INTEGER), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL), @Result(column="sales_count", property="salesCount", jdbcType=JdbcType.INTEGER), @Result(column="is_present", property="isPresent", jdbcType=JdbcType.BIT), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @@ -159,6 +163,7 @@ public interface HighCouponMapper extends HighCouponMapperExt { "recycle_day = #{recycleDay,jdbcType=INTEGER},", "limit_number = #{limitNumber,jdbcType=INTEGER},", "sales_price = #{salesPrice,jdbcType=DECIMAL},", + "discount_price = #{discountPrice,jdbcType=DECIMAL},", "sales_count = #{salesCount,jdbcType=INTEGER},", "is_present = #{isPresent,jdbcType=BIT},", "create_time = #{createTime,jdbcType=TIMESTAMP},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponSqlProvider.java index e4145954..27c5fcf7 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponSqlProvider.java @@ -80,6 +80,10 @@ public class HighCouponSqlProvider { sql.VALUES("sales_price", "#{salesPrice,jdbcType=DECIMAL}"); } + if (record.getDiscountPrice() != null) { + sql.VALUES("discount_price", "#{discountPrice,jdbcType=DECIMAL}"); + } + if (record.getSalesCount() != null) { sql.VALUES("sales_count", "#{salesCount,jdbcType=INTEGER}"); } @@ -143,6 +147,7 @@ public class HighCouponSqlProvider { sql.SELECT("recycle_day"); sql.SELECT("limit_number"); sql.SELECT("sales_price"); + sql.SELECT("discount_price"); sql.SELECT("sales_count"); sql.SELECT("is_present"); sql.SELECT("create_time"); @@ -226,6 +231,10 @@ public class HighCouponSqlProvider { sql.SET("sales_price = #{record.salesPrice,jdbcType=DECIMAL}"); } + if (record.getDiscountPrice() != null) { + sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}"); + } + if (record.getSalesCount() != null) { sql.SET("sales_count = #{record.salesCount,jdbcType=INTEGER}"); } @@ -288,6 +297,7 @@ public class HighCouponSqlProvider { sql.SET("recycle_day = #{record.recycleDay,jdbcType=INTEGER}"); sql.SET("limit_number = #{record.limitNumber,jdbcType=INTEGER}"); sql.SET("sales_price = #{record.salesPrice,jdbcType=DECIMAL}"); + sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}"); sql.SET("sales_count = #{record.salesCount,jdbcType=INTEGER}"); sql.SET("is_present = #{record.isPresent,jdbcType=BIT}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); @@ -360,6 +370,10 @@ public class HighCouponSqlProvider { sql.SET("sales_price = #{salesPrice,jdbcType=DECIMAL}"); } + if (record.getDiscountPrice() != null) { + sql.SET("discount_price = #{discountPrice,jdbcType=DECIMAL}"); + } + if (record.getSalesCount() != null) { sql.SET("sales_count = #{salesCount,jdbcType=INTEGER}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferMapper.java b/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferMapper.java index 6d5c4eb6..a4d75a00 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferMapper.java @@ -40,17 +40,21 @@ public interface HighGoodsPriceReferMapper extends HighGoodsPriceReferMapperExt @Insert({ "insert into high_goods_price_refer (object_type, object_id, ", + "price_type, old_sale_price, ", "new_sale_price, promptly_type, ", - "effective_time, remark, ", - "create_time, operator_id, ", - "operator_name, `status`, ", - "ext_1, ext_2, ext_3)", + "effective_time, invalid_time, ", + "remark, create_time, ", + "operator_id, operator_name, ", + "`status`, ext_1, ext_2, ", + "ext_3)", "values (#{objectType,jdbcType=INTEGER}, #{objectId,jdbcType=BIGINT}, ", + "#{priceType,jdbcType=INTEGER}, #{oldSalePrice,jdbcType=DECIMAL}, ", "#{newSalePrice,jdbcType=DECIMAL}, #{promptlyType,jdbcType=BIT}, ", - "#{effectiveTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{operatorId,jdbcType=BIGINT}, ", - "#{operatorName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{effectiveTime,jdbcType=TIMESTAMP}, #{invalidTime,jdbcType=TIMESTAMP}, ", + "#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", + "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", + "#{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighGoodsPriceRefer record); @@ -64,9 +68,12 @@ public interface HighGoodsPriceReferMapper extends HighGoodsPriceReferMapperExt @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="object_type", property="objectType", jdbcType=JdbcType.INTEGER), @Result(column="object_id", property="objectId", jdbcType=JdbcType.BIGINT), + @Result(column="price_type", property="priceType", jdbcType=JdbcType.INTEGER), + @Result(column="old_sale_price", property="oldSalePrice", jdbcType=JdbcType.DECIMAL), @Result(column="new_sale_price", property="newSalePrice", jdbcType=JdbcType.DECIMAL), @Result(column="promptly_type", property="promptlyType", jdbcType=JdbcType.BIT), @Result(column="effective_time", property="effectiveTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="invalid_time", property="invalidTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), @@ -80,8 +87,9 @@ public interface HighGoodsPriceReferMapper extends HighGoodsPriceReferMapperExt @Select({ "select", - "id, object_type, object_id, new_sale_price, promptly_type, effective_time, remark, ", - "create_time, operator_id, operator_name, `status`, ext_1, ext_2, ext_3", + "id, object_type, object_id, price_type, old_sale_price, new_sale_price, promptly_type, ", + "effective_time, invalid_time, remark, create_time, operator_id, operator_name, ", + "`status`, ext_1, ext_2, ext_3", "from high_goods_price_refer", "where id = #{id,jdbcType=BIGINT}" }) @@ -89,9 +97,12 @@ public interface HighGoodsPriceReferMapper extends HighGoodsPriceReferMapperExt @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="object_type", property="objectType", jdbcType=JdbcType.INTEGER), @Result(column="object_id", property="objectId", jdbcType=JdbcType.BIGINT), + @Result(column="price_type", property="priceType", jdbcType=JdbcType.INTEGER), + @Result(column="old_sale_price", property="oldSalePrice", jdbcType=JdbcType.DECIMAL), @Result(column="new_sale_price", property="newSalePrice", jdbcType=JdbcType.DECIMAL), @Result(column="promptly_type", property="promptlyType", jdbcType=JdbcType.BIT), @Result(column="effective_time", property="effectiveTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="invalid_time", property="invalidTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), @@ -116,9 +127,12 @@ public interface HighGoodsPriceReferMapper extends HighGoodsPriceReferMapperExt "update high_goods_price_refer", "set object_type = #{objectType,jdbcType=INTEGER},", "object_id = #{objectId,jdbcType=BIGINT},", + "price_type = #{priceType,jdbcType=INTEGER},", + "old_sale_price = #{oldSalePrice,jdbcType=DECIMAL},", "new_sale_price = #{newSalePrice,jdbcType=DECIMAL},", "promptly_type = #{promptlyType,jdbcType=BIT},", "effective_time = #{effectiveTime,jdbcType=TIMESTAMP},", + "invalid_time = #{invalidTime,jdbcType=TIMESTAMP},", "remark = #{remark,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "operator_id = #{operatorId,jdbcType=BIGINT},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferSqlProvider.java index 73117401..f6ca8a95 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGoodsPriceReferSqlProvider.java @@ -36,6 +36,14 @@ public class HighGoodsPriceReferSqlProvider { sql.VALUES("object_id", "#{objectId,jdbcType=BIGINT}"); } + if (record.getPriceType() != null) { + sql.VALUES("price_type", "#{priceType,jdbcType=INTEGER}"); + } + + if (record.getOldSalePrice() != null) { + sql.VALUES("old_sale_price", "#{oldSalePrice,jdbcType=DECIMAL}"); + } + if (record.getNewSalePrice() != null) { sql.VALUES("new_sale_price", "#{newSalePrice,jdbcType=DECIMAL}"); } @@ -48,6 +56,10 @@ public class HighGoodsPriceReferSqlProvider { sql.VALUES("effective_time", "#{effectiveTime,jdbcType=TIMESTAMP}"); } + if (record.getInvalidTime() != null) { + sql.VALUES("invalid_time", "#{invalidTime,jdbcType=TIMESTAMP}"); + } + if (record.getRemark() != null) { sql.VALUES("remark", "#{remark,jdbcType=VARCHAR}"); } @@ -92,9 +104,12 @@ public class HighGoodsPriceReferSqlProvider { } sql.SELECT("object_type"); sql.SELECT("object_id"); + sql.SELECT("price_type"); + sql.SELECT("old_sale_price"); sql.SELECT("new_sale_price"); sql.SELECT("promptly_type"); sql.SELECT("effective_time"); + sql.SELECT("invalid_time"); sql.SELECT("remark"); sql.SELECT("create_time"); sql.SELECT("operator_id"); @@ -132,6 +147,14 @@ public class HighGoodsPriceReferSqlProvider { sql.SET("object_id = #{record.objectId,jdbcType=BIGINT}"); } + if (record.getPriceType() != null) { + sql.SET("price_type = #{record.priceType,jdbcType=INTEGER}"); + } + + if (record.getOldSalePrice() != null) { + sql.SET("old_sale_price = #{record.oldSalePrice,jdbcType=DECIMAL}"); + } + if (record.getNewSalePrice() != null) { sql.SET("new_sale_price = #{record.newSalePrice,jdbcType=DECIMAL}"); } @@ -144,6 +167,10 @@ public class HighGoodsPriceReferSqlProvider { sql.SET("effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP}"); } + if (record.getInvalidTime() != null) { + sql.SET("invalid_time = #{record.invalidTime,jdbcType=TIMESTAMP}"); + } + if (record.getRemark() != null) { sql.SET("remark = #{record.remark,jdbcType=VARCHAR}"); } @@ -187,9 +214,12 @@ public class HighGoodsPriceReferSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("object_type = #{record.objectType,jdbcType=INTEGER}"); sql.SET("object_id = #{record.objectId,jdbcType=BIGINT}"); + sql.SET("price_type = #{record.priceType,jdbcType=INTEGER}"); + sql.SET("old_sale_price = #{record.oldSalePrice,jdbcType=DECIMAL}"); sql.SET("new_sale_price = #{record.newSalePrice,jdbcType=DECIMAL}"); sql.SET("promptly_type = #{record.promptlyType,jdbcType=BIT}"); sql.SET("effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP}"); + sql.SET("invalid_time = #{record.invalidTime,jdbcType=TIMESTAMP}"); sql.SET("remark = #{record.remark,jdbcType=VARCHAR}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("operator_id = #{record.operatorId,jdbcType=BIGINT}"); @@ -216,6 +246,14 @@ public class HighGoodsPriceReferSqlProvider { sql.SET("object_id = #{objectId,jdbcType=BIGINT}"); } + if (record.getPriceType() != null) { + sql.SET("price_type = #{priceType,jdbcType=INTEGER}"); + } + + if (record.getOldSalePrice() != null) { + sql.SET("old_sale_price = #{oldSalePrice,jdbcType=DECIMAL}"); + } + if (record.getNewSalePrice() != null) { sql.SET("new_sale_price = #{newSalePrice,jdbcType=DECIMAL}"); } @@ -228,6 +266,10 @@ public class HighGoodsPriceReferSqlProvider { sql.SET("effective_time = #{effectiveTime,jdbcType=TIMESTAMP}"); } + if (record.getInvalidTime() != null) { + sql.SET("invalid_time = #{invalidTime,jdbcType=TIMESTAMP}"); + } + if (record.getRemark() != null) { sql.SET("remark = #{remark,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCoupon.java b/hai-service/src/main/java/com/hai/entity/HighCoupon.java index fa7d1efa..863bb678 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCoupon.java +++ b/hai-service/src/main/java/com/hai/entity/HighCoupon.java @@ -84,6 +84,11 @@ public class HighCoupon implements Serializable { */ private BigDecimal salesPrice; + /** + * 折扣价格 + */ + private BigDecimal discountPrice; + /** * 销售数量 */ @@ -239,6 +244,14 @@ public class HighCoupon implements Serializable { this.salesPrice = salesPrice; } + public BigDecimal getDiscountPrice() { + return discountPrice; + } + + public void setDiscountPrice(BigDecimal discountPrice) { + this.discountPrice = discountPrice; + } + public Integer getSalesCount() { return salesCount; } @@ -345,6 +358,7 @@ public class HighCoupon implements Serializable { && (this.getRecycleDay() == null ? other.getRecycleDay() == null : this.getRecycleDay().equals(other.getRecycleDay())) && (this.getLimitNumber() == null ? other.getLimitNumber() == null : this.getLimitNumber().equals(other.getLimitNumber())) && (this.getSalesPrice() == null ? other.getSalesPrice() == null : this.getSalesPrice().equals(other.getSalesPrice())) + && (this.getDiscountPrice() == null ? other.getDiscountPrice() == null : this.getDiscountPrice().equals(other.getDiscountPrice())) && (this.getSalesCount() == null ? other.getSalesCount() == null : this.getSalesCount().equals(other.getSalesCount())) && (this.getIsPresent() == null ? other.getIsPresent() == null : this.getIsPresent().equals(other.getIsPresent())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) @@ -375,6 +389,7 @@ public class HighCoupon implements Serializable { result = prime * result + ((getRecycleDay() == null) ? 0 : getRecycleDay().hashCode()); result = prime * result + ((getLimitNumber() == null) ? 0 : getLimitNumber().hashCode()); result = prime * result + ((getSalesPrice() == null) ? 0 : getSalesPrice().hashCode()); + result = prime * result + ((getDiscountPrice() == null) ? 0 : getDiscountPrice().hashCode()); result = prime * result + ((getSalesCount() == null) ? 0 : getSalesCount().hashCode()); result = prime * result + ((getIsPresent() == null) ? 0 : getIsPresent().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); @@ -408,6 +423,7 @@ public class HighCoupon implements Serializable { sb.append(", recycleDay=").append(recycleDay); sb.append(", limitNumber=").append(limitNumber); sb.append(", salesPrice=").append(salesPrice); + sb.append(", discountPrice=").append(discountPrice); sb.append(", salesCount=").append(salesCount); sb.append(", isPresent=").append(isPresent); sb.append(", createTime=").append(createTime); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponExample.java index cb4d79d7..7dd3cec4 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponExample.java @@ -1016,6 +1016,66 @@ public class HighCouponExample { return (Criteria) this; } + public Criteria andDiscountPriceIsNull() { + addCriterion("discount_price is null"); + return (Criteria) this; + } + + public Criteria andDiscountPriceIsNotNull() { + addCriterion("discount_price is not null"); + return (Criteria) this; + } + + public Criteria andDiscountPriceEqualTo(BigDecimal value) { + addCriterion("discount_price =", value, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceNotEqualTo(BigDecimal value) { + addCriterion("discount_price <>", value, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceGreaterThan(BigDecimal value) { + addCriterion("discount_price >", value, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("discount_price >=", value, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceLessThan(BigDecimal value) { + addCriterion("discount_price <", value, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("discount_price <=", value, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceIn(List values) { + addCriterion("discount_price in", values, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceNotIn(List values) { + addCriterion("discount_price not in", values, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("discount_price between", value1, value2, "discountPrice"); + return (Criteria) this; + } + + public Criteria andDiscountPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("discount_price not between", value1, value2, "discountPrice"); + return (Criteria) this; + } + public Criteria andSalesCountIsNull() { addCriterion("sales_count is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/entity/HighGoodsPriceRefer.java b/hai-service/src/main/java/com/hai/entity/HighGoodsPriceRefer.java index 3c582633..8dd1831b 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGoodsPriceRefer.java +++ b/hai-service/src/main/java/com/hai/entity/HighGoodsPriceRefer.java @@ -29,6 +29,16 @@ public class HighGoodsPriceRefer implements Serializable { */ private Long objectId; + /** + * 价格类型 1:原价 2:折扣价 + */ + private Integer priceType; + + /** + * 旧销售价格 + */ + private BigDecimal oldSalePrice; + /** * 新销售价格 */ @@ -44,6 +54,11 @@ public class HighGoodsPriceRefer implements Serializable { */ private Date effectiveTime; + /** + * 新销售价格 失效时间 + */ + private Date invalidTime; + /** * 备注 */ @@ -101,6 +116,22 @@ public class HighGoodsPriceRefer implements Serializable { this.objectId = objectId; } + public Integer getPriceType() { + return priceType; + } + + public void setPriceType(Integer priceType) { + this.priceType = priceType; + } + + public BigDecimal getOldSalePrice() { + return oldSalePrice; + } + + public void setOldSalePrice(BigDecimal oldSalePrice) { + this.oldSalePrice = oldSalePrice; + } + public BigDecimal getNewSalePrice() { return newSalePrice; } @@ -125,6 +156,14 @@ public class HighGoodsPriceRefer implements Serializable { this.effectiveTime = effectiveTime; } + public Date getInvalidTime() { + return invalidTime; + } + + public void setInvalidTime(Date invalidTime) { + this.invalidTime = invalidTime; + } + public String getRemark() { return remark; } @@ -204,9 +243,12 @@ public class HighGoodsPriceRefer implements Serializable { return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getObjectType() == null ? other.getObjectType() == null : this.getObjectType().equals(other.getObjectType())) && (this.getObjectId() == null ? other.getObjectId() == null : this.getObjectId().equals(other.getObjectId())) + && (this.getPriceType() == null ? other.getPriceType() == null : this.getPriceType().equals(other.getPriceType())) + && (this.getOldSalePrice() == null ? other.getOldSalePrice() == null : this.getOldSalePrice().equals(other.getOldSalePrice())) && (this.getNewSalePrice() == null ? other.getNewSalePrice() == null : this.getNewSalePrice().equals(other.getNewSalePrice())) && (this.getPromptlyType() == null ? other.getPromptlyType() == null : this.getPromptlyType().equals(other.getPromptlyType())) && (this.getEffectiveTime() == null ? other.getEffectiveTime() == null : this.getEffectiveTime().equals(other.getEffectiveTime())) + && (this.getInvalidTime() == null ? other.getInvalidTime() == null : this.getInvalidTime().equals(other.getInvalidTime())) && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getOperatorId() == null ? other.getOperatorId() == null : this.getOperatorId().equals(other.getOperatorId())) @@ -224,9 +266,12 @@ public class HighGoodsPriceRefer implements Serializable { result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getObjectType() == null) ? 0 : getObjectType().hashCode()); result = prime * result + ((getObjectId() == null) ? 0 : getObjectId().hashCode()); + result = prime * result + ((getPriceType() == null) ? 0 : getPriceType().hashCode()); + result = prime * result + ((getOldSalePrice() == null) ? 0 : getOldSalePrice().hashCode()); result = prime * result + ((getNewSalePrice() == null) ? 0 : getNewSalePrice().hashCode()); result = prime * result + ((getPromptlyType() == null) ? 0 : getPromptlyType().hashCode()); result = prime * result + ((getEffectiveTime() == null) ? 0 : getEffectiveTime().hashCode()); + result = prime * result + ((getInvalidTime() == null) ? 0 : getInvalidTime().hashCode()); result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getOperatorId() == null) ? 0 : getOperatorId().hashCode()); @@ -247,9 +292,12 @@ public class HighGoodsPriceRefer implements Serializable { sb.append(", id=").append(id); sb.append(", objectType=").append(objectType); sb.append(", objectId=").append(objectId); + sb.append(", priceType=").append(priceType); + sb.append(", oldSalePrice=").append(oldSalePrice); sb.append(", newSalePrice=").append(newSalePrice); sb.append(", promptlyType=").append(promptlyType); sb.append(", effectiveTime=").append(effectiveTime); + sb.append(", invalidTime=").append(invalidTime); sb.append(", remark=").append(remark); sb.append(", createTime=").append(createTime); sb.append(", operatorId=").append(operatorId); diff --git a/hai-service/src/main/java/com/hai/entity/HighGoodsPriceReferExample.java b/hai-service/src/main/java/com/hai/entity/HighGoodsPriceReferExample.java index e2ee1161..ac2779b6 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGoodsPriceReferExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGoodsPriceReferExample.java @@ -306,6 +306,126 @@ public class HighGoodsPriceReferExample { return (Criteria) this; } + public Criteria andPriceTypeIsNull() { + addCriterion("price_type is null"); + return (Criteria) this; + } + + public Criteria andPriceTypeIsNotNull() { + addCriterion("price_type is not null"); + return (Criteria) this; + } + + public Criteria andPriceTypeEqualTo(Integer value) { + addCriterion("price_type =", value, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeNotEqualTo(Integer value) { + addCriterion("price_type <>", value, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeGreaterThan(Integer value) { + addCriterion("price_type >", value, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("price_type >=", value, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeLessThan(Integer value) { + addCriterion("price_type <", value, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeLessThanOrEqualTo(Integer value) { + addCriterion("price_type <=", value, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeIn(List values) { + addCriterion("price_type in", values, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeNotIn(List values) { + addCriterion("price_type not in", values, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeBetween(Integer value1, Integer value2) { + addCriterion("price_type between", value1, value2, "priceType"); + return (Criteria) this; + } + + public Criteria andPriceTypeNotBetween(Integer value1, Integer value2) { + addCriterion("price_type not between", value1, value2, "priceType"); + return (Criteria) this; + } + + public Criteria andOldSalePriceIsNull() { + addCriterion("old_sale_price is null"); + return (Criteria) this; + } + + public Criteria andOldSalePriceIsNotNull() { + addCriterion("old_sale_price is not null"); + return (Criteria) this; + } + + public Criteria andOldSalePriceEqualTo(BigDecimal value) { + addCriterion("old_sale_price =", value, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceNotEqualTo(BigDecimal value) { + addCriterion("old_sale_price <>", value, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceGreaterThan(BigDecimal value) { + addCriterion("old_sale_price >", value, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("old_sale_price >=", value, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceLessThan(BigDecimal value) { + addCriterion("old_sale_price <", value, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("old_sale_price <=", value, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceIn(List values) { + addCriterion("old_sale_price in", values, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceNotIn(List values) { + addCriterion("old_sale_price not in", values, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("old_sale_price between", value1, value2, "oldSalePrice"); + return (Criteria) this; + } + + public Criteria andOldSalePriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("old_sale_price not between", value1, value2, "oldSalePrice"); + return (Criteria) this; + } + public Criteria andNewSalePriceIsNull() { addCriterion("new_sale_price is null"); return (Criteria) this; @@ -486,6 +606,66 @@ public class HighGoodsPriceReferExample { return (Criteria) this; } + public Criteria andInvalidTimeIsNull() { + addCriterion("invalid_time is null"); + return (Criteria) this; + } + + public Criteria andInvalidTimeIsNotNull() { + addCriterion("invalid_time is not null"); + return (Criteria) this; + } + + public Criteria andInvalidTimeEqualTo(Date value) { + addCriterion("invalid_time =", value, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeNotEqualTo(Date value) { + addCriterion("invalid_time <>", value, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeGreaterThan(Date value) { + addCriterion("invalid_time >", value, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeGreaterThanOrEqualTo(Date value) { + addCriterion("invalid_time >=", value, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeLessThan(Date value) { + addCriterion("invalid_time <", value, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeLessThanOrEqualTo(Date value) { + addCriterion("invalid_time <=", value, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeIn(List values) { + addCriterion("invalid_time in", values, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeNotIn(List values) { + addCriterion("invalid_time not in", values, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeBetween(Date value1, Date value2) { + addCriterion("invalid_time between", value1, value2, "invalidTime"); + return (Criteria) this; + } + + public Criteria andInvalidTimeNotBetween(Date value1, Date value2) { + addCriterion("invalid_time not between", value1, value2, "invalidTime"); + return (Criteria) this; + } + public Criteria andRemarkIsNull() { addCriterion("remark is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java b/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java index 0d4d9912..0f06eaba 100644 --- a/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java +++ b/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java @@ -39,10 +39,17 @@ public interface HighGoodsPriceReferService { /** * @Author 胡锐 - * @Description 卡卷价格 处于待编辑、已生效、待生效、审批中 全部失效 + * @Description 卡卷原价价格 处于待编辑、已生效、待生效、审批中 全部失效 * @Date 2021/3/14 20:14 **/ - void couponAllPriceInvalid(Long couponId); + void couponAllSalesPriceInvalid(Long couponId); + + /** + * @Author 胡锐 + * @Description 卡卷折扣价格 处于待编辑、已生效、待生效、审批中 全部失效 + * @Date 2021/3/24 14:37 + **/ + void couponAllDiscountPriceInvalid(Long couponId); /** * @Author 胡锐 @@ -61,4 +68,12 @@ public interface HighGoodsPriceReferService { * @return java.util.List **/ List getPriceList(Map map); + + /** + * @Author 胡锐 + * @Description 是否满足增加价格条件 + * @Date 2021/3/24 15:50 + **/ + Boolean isAddCondition(Integer objectType,Long objectId,Integer priceType); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index 663c1965..2c27214a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -62,18 +62,36 @@ public class HighCouponServiceImpl implements HighCouponService { } } - HighGoodsPriceRefer goodsPriceRefer = new HighGoodsPriceRefer(); - goodsPriceRefer.setObjectType(1); - goodsPriceRefer.setObjectId(highCouponModel.getId()); - goodsPriceRefer.setNewSalePrice(highCouponModel.getSalesPrice()); - goodsPriceRefer.setPromptlyType(true); - goodsPriceRefer.setEffectiveTime(new Date()); - goodsPriceRefer.setRemark("【创建产品】初始销售价格"); - goodsPriceRefer.setStatus(1); // 状态: 0:删除 1:待编辑 2:未生效 3:已生效 4:已失效 101.审批中 102.审批驳回 - goodsPriceRefer.setCreateTime(new Date()); - goodsPriceRefer.setOperatorId(highCouponModel.getOperatorId()); - goodsPriceRefer.setOperatorName(highCouponModel.getOperatorName()); - highGoodsPriceReferService.insertPriceRefer(goodsPriceRefer); + HighGoodsPriceRefer salePrice = new HighGoodsPriceRefer(); + salePrice.setObjectType(1); + salePrice.setObjectId(highCouponModel.getId()); + salePrice.setPriceType(1); // 价格类型 1:原价 2:折扣价 + salePrice.setOldSalePrice(highCouponModel.getSalesPrice()); + salePrice.setNewSalePrice(highCouponModel.getSalesPrice()); + salePrice.setPromptlyType(true); + salePrice.setEffectiveTime(new Date()); + salePrice.setRemark("【创建产品】初始原价价格"); + salePrice.setStatus(1); // 状态: 0:删除 1:待编辑 2:未生效 3:已生效 4:已失效 101.审批中 102.审批驳回 + salePrice.setCreateTime(new Date()); + salePrice.setOperatorId(highCouponModel.getOperatorId()); + salePrice.setOperatorName(highCouponModel.getOperatorName()); + highGoodsPriceReferService.insertPriceRefer(salePrice); + + + HighGoodsPriceRefer discountPrice = new HighGoodsPriceRefer(); + discountPrice.setObjectType(1); + discountPrice.setObjectId(highCouponModel.getId()); + discountPrice.setPriceType(2); // 价格类型 1:原价 2:折扣价 + discountPrice.setOldSalePrice(highCouponModel.getDiscountPrice()); + discountPrice.setNewSalePrice(highCouponModel.getDiscountPrice()); + discountPrice.setPromptlyType(true); + discountPrice.setEffectiveTime(new Date()); + discountPrice.setRemark("【创建产品】初始折扣价格"); + discountPrice.setStatus(1); // 状态: 0:删除 1:待编辑 2:未生效 3:已生效 4:已失效 101.审批中 102.审批驳回 + discountPrice.setCreateTime(new Date()); + discountPrice.setOperatorId(highCouponModel.getOperatorId()); + discountPrice.setOperatorName(highCouponModel.getOperatorName()); + highGoodsPriceReferService.insertPriceRefer(discountPrice); } @Override @@ -96,27 +114,48 @@ public class HighCouponServiceImpl implements HighCouponService { } } - // 查询卡卷 如果卡卷销售价格进行了修改 HighCouponModel coupon = getCouponById(highCouponModel.getId()); + + // 如果卡卷销售价格进行了修改 if (!coupon.getCouponPrice().equals(highCouponModel.getCouponPrice())) { // 所有价格失效 - highGoodsPriceReferService.couponAllPriceInvalid(highCouponModel.getId()); + highGoodsPriceReferService.couponAllSalesPriceInvalid(highCouponModel.getId()); + // 增加新销售价格 + HighGoodsPriceRefer salePrice = new HighGoodsPriceRefer(); + salePrice.setObjectType(1); + salePrice.setObjectId(highCouponModel.getId()); + salePrice.setPriceType(1); // 价格类型 1:原价 2:折扣价 + salePrice.setOldSalePrice(coupon.getSalesPrice()); + salePrice.setNewSalePrice(highCouponModel.getSalesPrice()); + salePrice.setPromptlyType(true); + salePrice.setEffectiveTime(new Date()); + salePrice.setRemark("【修改产品】初始原价价格"); + salePrice.setStatus(1); // 状态: 0:删除 1:待编辑 2:未生效 3:已生效 4:已失效 101.审批中 102.审批驳回 + salePrice.setCreateTime(new Date()); + salePrice.setOperatorId(highCouponModel.getOperatorId()); + salePrice.setOperatorName(highCouponModel.getOperatorName()); + highGoodsPriceReferService.insertPriceRefer(salePrice); + } + if (!coupon.getDiscountPrice().equals(highCouponModel.getDiscountPrice())) { + // 所有价格失效 + highGoodsPriceReferService.couponAllDiscountPriceInvalid(highCouponModel.getId()); // 增加新价格 - HighGoodsPriceRefer goodsPriceRefer = new HighGoodsPriceRefer(); - goodsPriceRefer.setObjectType(1); - goodsPriceRefer.setObjectId(highCouponModel.getId()); - goodsPriceRefer.setNewSalePrice(highCouponModel.getSalesPrice()); - goodsPriceRefer.setPromptlyType(true); - goodsPriceRefer.setEffectiveTime(new Date()); - goodsPriceRefer.setRemark("【修改卡卷】修改销售价格"); - goodsPriceRefer.setStatus(1); // 状态: 0:删除 1:待编辑 2:未生效 3:已生效 4:已失效 101.审批中 102.审批驳回 - goodsPriceRefer.setCreateTime(new Date()); - goodsPriceRefer.setOperatorId(highCouponModel.getOperatorId()); - goodsPriceRefer.setOperatorName(highCouponModel.getOperatorName()); - highGoodsPriceReferService.insertPriceRefer(goodsPriceRefer); + HighGoodsPriceRefer salePrice = new HighGoodsPriceRefer(); + salePrice.setObjectType(1); + salePrice.setObjectId(highCouponModel.getId()); + salePrice.setPriceType(2); // 价格类型 1:原价 2:折扣价 + salePrice.setOldSalePrice(coupon.getDiscountPrice()); + salePrice.setNewSalePrice(highCouponModel.getDiscountPrice()); + salePrice.setPromptlyType(true); + salePrice.setEffectiveTime(new Date()); + salePrice.setRemark("【修改产品】初始折扣价格"); + salePrice.setStatus(1); // 状态: 0:删除 1:待编辑 2:未生效 3:已生效 4:已失效 101.审批中 102.审批驳回 + salePrice.setCreateTime(new Date()); + salePrice.setOperatorId(highCouponModel.getOperatorId()); + salePrice.setOperatorName(highCouponModel.getOperatorName()); + highGoodsPriceReferService.insertPriceRefer(salePrice); } - } @Override @@ -225,7 +264,9 @@ public class HighCouponServiceImpl implements HighCouponService { } // 状态: 1:待审批 2:驳回 3:通过 + // 价格类型 1:原价 2:折扣价 if (highApprove.getStatus() == 1) { + // 及时生效 0:否 1:是 if (highGoodsPriceRefer.getPromptlyType() == true) { coupon.setCouponPrice(highGoodsPriceRefer.getNewSalePrice()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java index 39782565..96216c8a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java @@ -40,14 +40,41 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic } @Override - public void couponAllPriceInvalid(Long couponId) { + public void couponAllSalesPriceInvalid(Long couponId) { List statusList = new ArrayList<>(); statusList.add(1); statusList.add(2); statusList.add(3); statusList.add(101); HighGoodsPriceReferExample example = new HighGoodsPriceReferExample(); - example.createCriteria().andObjectIdEqualTo(couponId).andStatusIn(statusList); + example.createCriteria() + .andObjectTypeEqualTo(1) + .andObjectIdEqualTo(couponId) + .andPriceTypeEqualTo(1) + .andStatusIn(statusList); + + List referList = highGoodsPriceReferMapper.selectByExample(example); + if (referList != null && referList.size() > 0) { + for (HighGoodsPriceRefer refer : referList) { + refer.setStatus(4); + highGoodsPriceReferMapper.updateByPrimaryKey(refer); + } + } + } + + @Override + public void couponAllDiscountPriceInvalid(Long couponId) { + List statusList = new ArrayList<>(); + statusList.add(1); + statusList.add(2); + statusList.add(3); + statusList.add(101); + HighGoodsPriceReferExample example = new HighGoodsPriceReferExample(); + example.createCriteria() + .andObjectTypeEqualTo(1) + .andObjectIdEqualTo(couponId) + .andPriceTypeEqualTo(2) + .andStatusIn(statusList); List referList = highGoodsPriceReferMapper.selectByExample(example); if (referList != null && referList.size() > 0) { @@ -98,5 +125,26 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic return highGoodsPriceReferMapper.selectByExample(example); } + @Override + public Boolean isAddCondition(Integer objectType, Long objectId, Integer priceType) { + List statusList = new ArrayList<>(); + statusList.add(1); + statusList.add(2); + statusList.add(101); + + HighGoodsPriceReferExample example = new HighGoodsPriceReferExample(); + example.createCriteria() + .andObjectTypeEqualTo(objectType) + .andObjectIdEqualTo(objectId) + .andPriceTypeEqualTo(objectType) + .andStatusIn(statusList); + + List list = highGoodsPriceReferMapper.selectByExample(example); + if (list.size() > 0) { + return false; + } + return true; + } + }