From 015e8c7a611da648058148c16e533887e79cc01d Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 20 May 2024 17:52:39 +0800 Subject: [PATCH] Changes --- .../com/bweb/controller/BsUserController.java | 2 +- .../discount/DiscountController.java | 4 +- .../discount/DiscountPackageController.java | 79 +++++++++-- .../discount/DiscountController.java | 75 ++++++++++ .../goods/DeliveryAddressController.java | 2 + .../CouponDiscountPackageDetailsMapper.java | 23 +-- ...uponDiscountPackageDetailsSqlProvider.java | 14 ++ .../CouponDiscountPackageRecordMapper.java | 20 +-- ...ouponDiscountPackageRecordSqlProvider.java | 14 ++ .../entity/CouponDiscountPackageDetails.java | 16 +++ .../CouponDiscountPackageDetailsExample.java | 70 +++++++++ .../entity/CouponDiscountPackageRecord.java | 16 +++ .../CouponDiscountPackageRecordExample.java | 70 +++++++++ .../CouponDiscountPackageService.java | 15 +- .../discount/CouponDiscountService.java | 2 + .../CouponDiscountUserRelService.java | 30 ++++ .../CouponDiscountPackageServiceImpl.java | 133 +++++++++++++++++- .../impl/CouponDiscountServiceImpl.java | 2 + .../CouponDiscountUserRelServiceImpl.java | 46 ++++++ 19 files changed, 592 insertions(+), 41 deletions(-) create mode 100644 cweb/src/main/java/com/cweb/controller/discount/DiscountController.java create mode 100644 service/src/main/java/com/hfkj/service/discount/CouponDiscountUserRelService.java create mode 100644 service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountUserRelServiceImpl.java diff --git a/bweb/src/main/java/com/bweb/controller/BsUserController.java b/bweb/src/main/java/com/bweb/controller/BsUserController.java index 1e45f12..7d6c0ba 100644 --- a/bweb/src/main/java/com/bweb/controller/BsUserController.java +++ b/bweb/src/main/java/com/bweb/controller/BsUserController.java @@ -31,7 +31,7 @@ import java.util.Map; **/ @Controller @RequestMapping(value="/user") -@Api(value="系统菜单管理") +@Api(value="用户管理") public class BsUserController { private static Logger log = LoggerFactory.getLogger(BsUserController.class); @Resource diff --git a/bweb/src/main/java/com/bweb/controller/discount/DiscountController.java b/bweb/src/main/java/com/bweb/controller/discount/DiscountController.java index 5d3da3d..d026d9b 100644 --- a/bweb/src/main/java/com/bweb/controller/discount/DiscountController.java +++ b/bweb/src/main/java/com/bweb/controller/discount/DiscountController.java @@ -125,8 +125,8 @@ public class DiscountController { @ResponseBody @ApiOperation(value = "查询列表") public ResponseData getListDiscount(@RequestParam(value = "name" , required = false) String name, - @RequestParam(value = "type" , required = false) Integer type, - @RequestParam(value = "status" , required = false) Integer status, + @RequestParam(value = "type" , required = false) Integer type, + @RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "pageNum" , required = true) Integer pageNum, @RequestParam(value = "pageSize" , required = true) Integer pageSize) { try { diff --git a/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java b/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java index fb66022..4b32034 100644 --- a/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java +++ b/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java @@ -1,10 +1,14 @@ package com.bweb.controller.discount; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; import com.hfkj.model.ResponseData; @@ -47,7 +51,9 @@ public class DiscountPackageController { public ResponseData getDiscountPackageList( @RequestParam(name = "title", required = false) String title, @RequestParam(name = "key", required = false) String key, - @RequestParam(name = "status", required = false) Integer status) { + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(value = "pageNum" , required = true) Integer pageNum, + @RequestParam(value = "pageSize" , required = true) Integer pageSize) { try { Map map = new HashMap<>(); @@ -56,7 +62,9 @@ public class DiscountPackageController { map.put("key" , key); map.put("status" , status); - return ResponseMsgUtil.success(couponDiscountPackageService.getList(map)); + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(couponDiscountPackageService.getList(map))); + } catch (Exception e) { log.error("HighOrderController --> getUserOrderList() error!", e); @@ -86,7 +94,7 @@ public class DiscountPackageController { @RequestMapping(value = "/editCouponPackageInfo", method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "新增优惠券包基本信息") + @ApiOperation(value = "编辑优惠券包基本信息") public ResponseData editCouponPackageInfo(@RequestBody CouponDiscountPackage body, HttpServletRequest request) { try { @@ -112,12 +120,15 @@ public class DiscountPackageController { } else { discountPackage = new CouponDiscountPackage(); discountPackage.setCreatedUserId(userModel.getAccount().getId().intValue()); + discountPackage.setKey(OrderUtil.generateOrderNo()); discountPackage.setStatus(1); discountPackage.setTotalStock(0); - discountPackage.setSurplusStock(0); discountPackage.setCreatedTime(new Date()); } + discountPackage.setSurplusStock(body.getSurplusStock()); + discountPackage.setTitle(body.getTitle()); + discountPackage.setEffectiveTime(body.getEffectiveTime()); discountPackage.setUpdatedTime(new Date()); discountPackage.setUpdatedUserId(userModel.getAccount().getId().intValue()); @@ -156,15 +167,23 @@ public class DiscountPackageController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券不存在!"); } + CouponDiscountPackageDetails details = couponDiscountPackageService.discountPackageDetail(discountPackageDetails.getDiscountPackageId() , discountPackageDetails.getDiscountId()); - discountPackageDetails.setStatus(1); - discountPackageDetails.setDiscountName(discount.getName()); - discountPackageDetails.setCreatedTime(new Date()); - discountPackageDetails.setUpdatedTime(new Date()); - couponDiscountPackageService.createDetail(discountPackageDetails); + if (details == null) { + discountPackageDetails.setStatus(1); + discountPackageDetails.setDiscountName(discount.getName()); + discountPackageDetails.setDiscountImg(discount.getImg()); + discountPackageDetails.setCreatedTime(new Date()); + discountPackageDetails.setUpdatedTime(new Date()); + couponDiscountPackageService.createDetail(discountPackageDetails); + } else { + details.setNum(discountPackageDetails.getNum() + details.getNum()); + details.setUpdatedTime(new Date()); + couponDiscountPackageService.updateDetail(details); + } - return ResponseMsgUtil.success("新增成功"); + return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighAgentController --> insertAgent() error!", e); @@ -175,7 +194,7 @@ public class DiscountPackageController { @RequestMapping(value = "/deleteDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除券包详情") - public ResponseData deleteDetail(@RequestParam(name = "detailId", required = false) Long detailId) { + public ResponseData deleteDetail(@RequestParam(name = "detailId", required = false) Integer detailId) { try { couponDiscountPackageService.deleteDetail(detailId); @@ -188,6 +207,20 @@ public class DiscountPackageController { } } + @RequestMapping(value = "/getDetailList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "券包详情列表") + public ResponseData getDetailList(@RequestParam(name = "discountPackageId", required = false) Integer discountPackageId) { + try { + + return ResponseMsgUtil.success( couponDiscountPackageService.getDetailList(discountPackageId)); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/delete", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "删除券包") @@ -210,7 +243,6 @@ public class DiscountPackageController { public ResponseData discountPackageAudit(@RequestParam(value = "id" , required = false) Long id) { try { - CouponDiscountPackage discountPackage = couponDiscountPackageService.queryDetail(id); if (discountPackage.getStatus() == 1) { @@ -230,4 +262,27 @@ public class DiscountPackageController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value = "/giveDiscountPackage", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "赠送券包") + public ResponseData giveDiscountPackage(@RequestBody JSONObject body) { + try { + + if ( body == null + || body.getInteger("discountPackageId") == null + || body.getString("phone") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + couponDiscountPackageService.giveDiscountPackage(body.getInteger("discountPackageId") , body.getString("phone")); + + return ResponseMsgUtil.success("成功!"); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java b/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java new file mode 100644 index 0000000..50ced44 --- /dev/null +++ b/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java @@ -0,0 +1,75 @@ +package com.cweb.controller.discount; + +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.SessionObject; +import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.CouponDiscount; +import com.hfkj.entity.CouponDiscountGoodsRel; +import com.hfkj.entity.GoodsMsg; +import com.hfkj.entity.GoodsSpecs; +import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; +import com.hfkj.model.UserSessionObject; +import com.hfkj.model.discount.DiscountGoodsModel; +import com.hfkj.service.discount.CouponDiscountService; +import com.hfkj.service.discount.CouponDiscountUserRelService; +import com.hfkj.service.goods.impl.GoodsMsgServiceImpl; +import com.hfkj.service.goods.impl.GoodsSpecsServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +@Controller +@RequestMapping(value="/discount") +@Api(value="优惠券") +public class DiscountController { + + private static final Logger log = LoggerFactory.getLogger(DiscountController.class); + + @Resource + private UserCenter userCenter; + + @Resource + private CouponDiscountUserRelService discountUserRelService; + + @RequestMapping(value = "/getListUserDiscount", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取用户优惠券列表") + public ResponseData getListUserDiscount(@RequestParam(value = "status", required = true) Integer status) { + try { + + // 用户session + UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); + + Map map = new HashMap<>(); + + map.put("userId", userSession.getUser().getId()); + map.put("status", status); + + return ResponseMsgUtil.success(discountUserRelService.getList(map)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + +} diff --git a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java index bcffc1d..33f5b58 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java @@ -30,6 +30,8 @@ public class DeliveryAddressController { @Resource private UserCenter userCenter; + + @Resource private GoodsUserAddressServiceImpl goodsUserAddressService; diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsMapper.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsMapper.java index aa5715c..808c0fe 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsMapper.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsMapper.java @@ -40,15 +40,15 @@ public interface CouponDiscountPackageDetailsMapper extends CouponDiscountPackag @Insert({ "insert into coupon_discount_package_details (discount_package_id, discount_id, ", - "discount_name, num, ", - "created_time, updated_time, ", - "`status`, ext_1, ext_2, ", - "ext_3)", + "discount_name, discount_img, ", + "num, created_time, ", + "updated_time, `status`, ", + "ext_1, ext_2, ext_3)", "values (#{discountPackageId,jdbcType=INTEGER}, #{discountId,jdbcType=INTEGER}, ", - "#{discountName,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER}, ", - "#{createdTime,jdbcType=TIMESTAMP}, #{updatedTime,jdbcType=TIMESTAMP}, ", - "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", - "#{ext3,jdbcType=VARCHAR})" + "#{discountName,jdbcType=VARCHAR}, #{discountImg,jdbcType=VARCHAR}, ", + "#{num,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, ", + "#{updatedTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(CouponDiscountPackageDetails record); @@ -63,6 +63,7 @@ public interface CouponDiscountPackageDetailsMapper extends CouponDiscountPackag @Result(column="discount_package_id", property="discountPackageId", jdbcType=JdbcType.INTEGER), @Result(column="discount_id", property="discountId", jdbcType=JdbcType.INTEGER), @Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR), + @Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR), @Result(column="num", property="num", jdbcType=JdbcType.INTEGER), @Result(column="created_time", property="createdTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="updated_time", property="updatedTime", jdbcType=JdbcType.TIMESTAMP), @@ -75,8 +76,8 @@ public interface CouponDiscountPackageDetailsMapper extends CouponDiscountPackag @Select({ "select", - "id, discount_package_id, discount_id, discount_name, num, created_time, updated_time, ", - "`status`, ext_1, ext_2, ext_3", + "id, discount_package_id, discount_id, discount_name, discount_img, num, created_time, ", + "updated_time, `status`, ext_1, ext_2, ext_3", "from coupon_discount_package_details", "where id = #{id,jdbcType=INTEGER}" }) @@ -85,6 +86,7 @@ public interface CouponDiscountPackageDetailsMapper extends CouponDiscountPackag @Result(column="discount_package_id", property="discountPackageId", jdbcType=JdbcType.INTEGER), @Result(column="discount_id", property="discountId", jdbcType=JdbcType.INTEGER), @Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR), + @Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR), @Result(column="num", property="num", jdbcType=JdbcType.INTEGER), @Result(column="created_time", property="createdTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="updated_time", property="updatedTime", jdbcType=JdbcType.TIMESTAMP), @@ -109,6 +111,7 @@ public interface CouponDiscountPackageDetailsMapper extends CouponDiscountPackag "set discount_package_id = #{discountPackageId,jdbcType=INTEGER},", "discount_id = #{discountId,jdbcType=INTEGER},", "discount_name = #{discountName,jdbcType=VARCHAR},", + "discount_img = #{discountImg,jdbcType=VARCHAR},", "num = #{num,jdbcType=INTEGER},", "created_time = #{createdTime,jdbcType=TIMESTAMP},", "updated_time = #{updatedTime,jdbcType=TIMESTAMP},", diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsSqlProvider.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsSqlProvider.java index 581db3a..48d42b0 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageDetailsSqlProvider.java @@ -40,6 +40,10 @@ public class CouponDiscountPackageDetailsSqlProvider { sql.VALUES("discount_name", "#{discountName,jdbcType=VARCHAR}"); } + if (record.getDiscountImg() != null) { + sql.VALUES("discount_img", "#{discountImg,jdbcType=VARCHAR}"); + } + if (record.getNum() != null) { sql.VALUES("num", "#{num,jdbcType=INTEGER}"); } @@ -81,6 +85,7 @@ public class CouponDiscountPackageDetailsSqlProvider { sql.SELECT("discount_package_id"); sql.SELECT("discount_id"); sql.SELECT("discount_name"); + sql.SELECT("discount_img"); sql.SELECT("num"); sql.SELECT("created_time"); sql.SELECT("updated_time"); @@ -121,6 +126,10 @@ public class CouponDiscountPackageDetailsSqlProvider { sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}"); } + if (record.getDiscountImg() != null) { + sql.SET("discount_img = #{record.discountImg,jdbcType=VARCHAR}"); + } + if (record.getNum() != null) { sql.SET("num = #{record.num,jdbcType=INTEGER}"); } @@ -161,6 +170,7 @@ public class CouponDiscountPackageDetailsSqlProvider { sql.SET("discount_package_id = #{record.discountPackageId,jdbcType=INTEGER}"); sql.SET("discount_id = #{record.discountId,jdbcType=INTEGER}"); sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}"); + sql.SET("discount_img = #{record.discountImg,jdbcType=VARCHAR}"); sql.SET("num = #{record.num,jdbcType=INTEGER}"); sql.SET("created_time = #{record.createdTime,jdbcType=TIMESTAMP}"); sql.SET("updated_time = #{record.updatedTime,jdbcType=TIMESTAMP}"); @@ -190,6 +200,10 @@ public class CouponDiscountPackageDetailsSqlProvider { sql.SET("discount_name = #{discountName,jdbcType=VARCHAR}"); } + if (record.getDiscountImg() != null) { + sql.SET("discount_img = #{discountImg,jdbcType=VARCHAR}"); + } + if (record.getNum() != null) { sql.SET("num = #{num,jdbcType=INTEGER}"); } diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java index 44edfe6..bdb89cf 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java @@ -40,15 +40,15 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Insert({ "insert into coupon_discount_package_record (discount_package_title, discount_package_id, ", - "order_id, child_order_id, ", - "serial_no, `type`, ", - "user_id, user_phone, ", + "order_id, order_no, ", + "child_order_id, serial_no, ", + "`type`, user_id, user_phone, ", "created_time, `status`, ", "ext_1, ext_2, ext_3)", "values (#{discountPackageTitle,jdbcType=VARCHAR}, #{discountPackageId,jdbcType=INTEGER}, ", - "#{orderId,jdbcType=INTEGER}, #{childOrderId,jdbcType=INTEGER}, ", - "#{serialNo,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, ", - "#{userId,jdbcType=INTEGER}, #{userPhone,jdbcType=VARCHAR}, ", + "#{orderId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, ", + "#{childOrderId,jdbcType=INTEGER}, #{serialNo,jdbcType=VARCHAR}, ", + "#{type,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{userPhone,jdbcType=VARCHAR}, ", "#{createdTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @@ -65,6 +65,7 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Result(column="discount_package_title", property="discountPackageTitle", jdbcType=JdbcType.VARCHAR), @Result(column="discount_package_id", property="discountPackageId", jdbcType=JdbcType.INTEGER), @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.INTEGER), @Result(column="serial_no", property="serialNo", jdbcType=JdbcType.VARCHAR), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @@ -80,8 +81,9 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Select({ "select", - "id, discount_package_title, discount_package_id, order_id, child_order_id, serial_no, ", - "`type`, user_id, user_phone, created_time, `status`, ext_1, ext_2, ext_3", + "id, discount_package_title, discount_package_id, order_id, order_no, child_order_id, ", + "serial_no, `type`, user_id, user_phone, created_time, `status`, ext_1, ext_2, ", + "ext_3", "from coupon_discount_package_record", "where id = #{id,jdbcType=BIGINT}" }) @@ -90,6 +92,7 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Result(column="discount_package_title", property="discountPackageTitle", jdbcType=JdbcType.VARCHAR), @Result(column="discount_package_id", property="discountPackageId", jdbcType=JdbcType.INTEGER), @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.INTEGER), @Result(column="serial_no", property="serialNo", jdbcType=JdbcType.VARCHAR), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @@ -117,6 +120,7 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage "set discount_package_title = #{discountPackageTitle,jdbcType=VARCHAR},", "discount_package_id = #{discountPackageId,jdbcType=INTEGER},", "order_id = #{orderId,jdbcType=INTEGER},", + "order_no = #{orderNo,jdbcType=VARCHAR},", "child_order_id = #{childOrderId,jdbcType=INTEGER},", "serial_no = #{serialNo,jdbcType=VARCHAR},", "`type` = #{type,jdbcType=INTEGER},", diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java index 13e2388..4be7c05 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java @@ -40,6 +40,10 @@ public class CouponDiscountPackageRecordSqlProvider { sql.VALUES("order_id", "#{orderId,jdbcType=INTEGER}"); } + if (record.getOrderNo() != null) { + sql.VALUES("order_no", "#{orderNo,jdbcType=VARCHAR}"); + } + if (record.getChildOrderId() != null) { sql.VALUES("child_order_id", "#{childOrderId,jdbcType=INTEGER}"); } @@ -93,6 +97,7 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SELECT("discount_package_title"); sql.SELECT("discount_package_id"); sql.SELECT("order_id"); + sql.SELECT("order_no"); sql.SELECT("child_order_id"); sql.SELECT("serial_no"); sql.SELECT("`type`"); @@ -136,6 +141,10 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SET("order_id = #{record.orderId,jdbcType=INTEGER}"); } + if (record.getOrderNo() != null) { + sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); + } + if (record.getChildOrderId() != null) { sql.SET("child_order_id = #{record.childOrderId,jdbcType=INTEGER}"); } @@ -188,6 +197,7 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SET("discount_package_title = #{record.discountPackageTitle,jdbcType=VARCHAR}"); sql.SET("discount_package_id = #{record.discountPackageId,jdbcType=INTEGER}"); sql.SET("order_id = #{record.orderId,jdbcType=INTEGER}"); + sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); sql.SET("child_order_id = #{record.childOrderId,jdbcType=INTEGER}"); sql.SET("serial_no = #{record.serialNo,jdbcType=VARCHAR}"); sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); @@ -220,6 +230,10 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SET("order_id = #{orderId,jdbcType=INTEGER}"); } + if (record.getOrderNo() != null) { + sql.SET("order_no = #{orderNo,jdbcType=VARCHAR}"); + } + if (record.getChildOrderId() != null) { sql.SET("child_order_id = #{childOrderId,jdbcType=INTEGER}"); } diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetails.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetails.java index 5f19665..66a1bb4 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetails.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetails.java @@ -33,6 +33,11 @@ public class CouponDiscountPackageDetails implements Serializable { */ private String discountName; + /** + * 优惠券图片 + */ + private String discountImg; + /** * 数量 */ @@ -102,6 +107,14 @@ public class CouponDiscountPackageDetails implements Serializable { this.discountName = discountName; } + public String getDiscountImg() { + return discountImg; + } + + public void setDiscountImg(String discountImg) { + this.discountImg = discountImg; + } + public Integer getNum() { return num; } @@ -174,6 +187,7 @@ public class CouponDiscountPackageDetails implements Serializable { && (this.getDiscountPackageId() == null ? other.getDiscountPackageId() == null : this.getDiscountPackageId().equals(other.getDiscountPackageId())) && (this.getDiscountId() == null ? other.getDiscountId() == null : this.getDiscountId().equals(other.getDiscountId())) && (this.getDiscountName() == null ? other.getDiscountName() == null : this.getDiscountName().equals(other.getDiscountName())) + && (this.getDiscountImg() == null ? other.getDiscountImg() == null : this.getDiscountImg().equals(other.getDiscountImg())) && (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum())) && (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime())) && (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime())) @@ -191,6 +205,7 @@ public class CouponDiscountPackageDetails implements Serializable { result = prime * result + ((getDiscountPackageId() == null) ? 0 : getDiscountPackageId().hashCode()); result = prime * result + ((getDiscountId() == null) ? 0 : getDiscountId().hashCode()); result = prime * result + ((getDiscountName() == null) ? 0 : getDiscountName().hashCode()); + result = prime * result + ((getDiscountImg() == null) ? 0 : getDiscountImg().hashCode()); result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode()); result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode()); result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode()); @@ -211,6 +226,7 @@ public class CouponDiscountPackageDetails implements Serializable { sb.append(", discountPackageId=").append(discountPackageId); sb.append(", discountId=").append(discountId); sb.append(", discountName=").append(discountName); + sb.append(", discountImg=").append(discountImg); sb.append(", num=").append(num); sb.append(", createdTime=").append(createdTime); sb.append(", updatedTime=").append(updatedTime); diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetailsExample.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetailsExample.java index 3192810..d560ace 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetailsExample.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageDetailsExample.java @@ -375,6 +375,76 @@ public class CouponDiscountPackageDetailsExample { return (Criteria) this; } + public Criteria andDiscountImgIsNull() { + addCriterion("discount_img is null"); + return (Criteria) this; + } + + public Criteria andDiscountImgIsNotNull() { + addCriterion("discount_img is not null"); + return (Criteria) this; + } + + public Criteria andDiscountImgEqualTo(String value) { + addCriterion("discount_img =", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgNotEqualTo(String value) { + addCriterion("discount_img <>", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgGreaterThan(String value) { + addCriterion("discount_img >", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgGreaterThanOrEqualTo(String value) { + addCriterion("discount_img >=", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgLessThan(String value) { + addCriterion("discount_img <", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgLessThanOrEqualTo(String value) { + addCriterion("discount_img <=", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgLike(String value) { + addCriterion("discount_img like", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgNotLike(String value) { + addCriterion("discount_img not like", value, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgIn(List values) { + addCriterion("discount_img in", values, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgNotIn(List values) { + addCriterion("discount_img not in", values, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgBetween(String value1, String value2) { + addCriterion("discount_img between", value1, value2, "discountImg"); + return (Criteria) this; + } + + public Criteria andDiscountImgNotBetween(String value1, String value2) { + addCriterion("discount_img not between", value1, value2, "discountImg"); + return (Criteria) this; + } + public Criteria andNumIsNull() { addCriterion("num is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecord.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecord.java index f8276f6..96c8392 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecord.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecord.java @@ -33,6 +33,11 @@ public class CouponDiscountPackageRecord implements Serializable { */ private Integer orderId; + /** + * 订单号 + */ + private String orderNo; + /** * 子订单id */ @@ -117,6 +122,14 @@ public class CouponDiscountPackageRecord implements Serializable { this.orderId = orderId; } + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + public Integer getChildOrderId() { return childOrderId; } @@ -213,6 +226,7 @@ public class CouponDiscountPackageRecord implements Serializable { && (this.getDiscountPackageTitle() == null ? other.getDiscountPackageTitle() == null : this.getDiscountPackageTitle().equals(other.getDiscountPackageTitle())) && (this.getDiscountPackageId() == null ? other.getDiscountPackageId() == null : this.getDiscountPackageId().equals(other.getDiscountPackageId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) + && (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo())) && (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId())) && (this.getSerialNo() == null ? other.getSerialNo() == null : this.getSerialNo().equals(other.getSerialNo())) && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) @@ -233,6 +247,7 @@ public class CouponDiscountPackageRecord implements Serializable { result = prime * result + ((getDiscountPackageTitle() == null) ? 0 : getDiscountPackageTitle().hashCode()); result = prime * result + ((getDiscountPackageId() == null) ? 0 : getDiscountPackageId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); + result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode()); result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode()); result = prime * result + ((getSerialNo() == null) ? 0 : getSerialNo().hashCode()); result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); @@ -256,6 +271,7 @@ public class CouponDiscountPackageRecord implements Serializable { sb.append(", discountPackageTitle=").append(discountPackageTitle); sb.append(", discountPackageId=").append(discountPackageId); sb.append(", orderId=").append(orderId); + sb.append(", orderNo=").append(orderNo); sb.append(", childOrderId=").append(childOrderId); sb.append(", serialNo=").append(serialNo); sb.append(", type=").append(type); diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java index a868823..2060c91 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java @@ -375,6 +375,76 @@ public class CouponDiscountPackageRecordExample { return (Criteria) this; } + public Criteria andOrderNoIsNull() { + addCriterion("order_no is null"); + return (Criteria) this; + } + + public Criteria andOrderNoIsNotNull() { + addCriterion("order_no is not null"); + return (Criteria) this; + } + + public Criteria andOrderNoEqualTo(String value) { + addCriterion("order_no =", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotEqualTo(String value) { + addCriterion("order_no <>", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoGreaterThan(String value) { + addCriterion("order_no >", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoGreaterThanOrEqualTo(String value) { + addCriterion("order_no >=", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoLessThan(String value) { + addCriterion("order_no <", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoLessThanOrEqualTo(String value) { + addCriterion("order_no <=", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoLike(String value) { + addCriterion("order_no like", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotLike(String value) { + addCriterion("order_no not like", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoIn(List values) { + addCriterion("order_no in", values, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotIn(List values) { + addCriterion("order_no not in", values, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoBetween(String value1, String value2) { + addCriterion("order_no between", value1, value2, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotBetween(String value1, String value2) { + addCriterion("order_no not between", value1, value2, "orderNo"); + return (Criteria) this; + } + public Criteria andChildOrderIdIsNull() { addCriterion("child_order_id is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java index 5a415d8..107ef23 100644 --- a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java +++ b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java @@ -80,6 +80,8 @@ public interface CouponDiscountPackageService { */ List getListRecordByMap(Map map); + void createRecord(CouponDiscountPackageRecord discountPackageRecord); + /** * @Author Sum1Dream * @Name create @@ -90,6 +92,14 @@ public interface CouponDiscountPackageService { */ void createDetail(CouponDiscountPackageDetails discountPackageDetails); + void updateDetail(CouponDiscountPackageDetails discountPackageDetails); + + List getDetailList(Integer discountPackageId); + + + CouponDiscountPackageDetails discountPackageDetail(Integer discountPackageId , Integer discountId); + + /** * @Author Sum1Dream * @Name delete @@ -98,6 +108,9 @@ public interface CouponDiscountPackageService { * @Param id * @return void */ - void deleteDetail(Long id); + void deleteDetail(Integer id); + + + void giveDiscountPackage(Integer discountPackageId , String phone); } diff --git a/service/src/main/java/com/hfkj/service/discount/CouponDiscountService.java b/service/src/main/java/com/hfkj/service/discount/CouponDiscountService.java index 9e52dce..751c052 100644 --- a/service/src/main/java/com/hfkj/service/discount/CouponDiscountService.java +++ b/service/src/main/java/com/hfkj/service/discount/CouponDiscountService.java @@ -2,6 +2,7 @@ package com.hfkj.service.discount; import com.hfkj.entity.CouponDiscount; import com.hfkj.entity.CouponDiscountGoodsRel; +import com.hfkj.entity.CouponDiscountPackageDetails; import java.util.List; import java.util.Map; @@ -105,6 +106,7 @@ public interface CouponDiscountService { */ void deleteDiscountGoodsRel(Long id); + /** * @Author Sum1Dream * @Name deleteDiscountGoodsRelDiscountId diff --git a/service/src/main/java/com/hfkj/service/discount/CouponDiscountUserRelService.java b/service/src/main/java/com/hfkj/service/discount/CouponDiscountUserRelService.java new file mode 100644 index 0000000..a834249 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/discount/CouponDiscountUserRelService.java @@ -0,0 +1,30 @@ +package com.hfkj.service.discount; + +import com.hfkj.entity.CouponDiscount; +import com.hfkj.entity.CouponDiscountUserRel; + +import java.util.List; +import java.util.Map; + +public interface CouponDiscountUserRelService { + + /** + * @Author Sum1Dream + * @Name create + * @Description // 创建 + * @Date 15:11 2024/4/19 + * @Param CouponDiscount + * @return void + */ + void create(CouponDiscountUserRel couponDiscountUserRel); + + /** + * @Author Sum1Dream + * @Name getList + * @Description // 根据多条件查询列表 + * @Date 15:13 2024/4/19 + * @Param map + * @return java.util.List + */ + List getList(Map map); +} diff --git a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java index 7403d3d..ef58e00 100644 --- a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java @@ -1,19 +1,25 @@ package com.hfkj.service.discount.impl; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.OrderUtil; import com.hfkj.dao.CouponDiscountPackageDetailsMapper; import com.hfkj.dao.CouponDiscountPackageMapper; import com.hfkj.dao.CouponDiscountPackageRecordMapper; import com.hfkj.entity.*; import com.hfkj.service.discount.CouponDiscountPackageService; +import com.hfkj.service.discount.CouponDiscountService; +import com.hfkj.service.discount.CouponDiscountUserRelService; +import com.hfkj.service.user.BsUserService; +import com.hfkj.sysenum.UserStatusEnum; +import io.swagger.models.auth.In; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @Service("couponDiscountPackageService") public class CouponDiscountPackageServiceImpl implements CouponDiscountPackageService { @@ -27,6 +33,15 @@ public class CouponDiscountPackageServiceImpl implements CouponDiscountPackageSe @Resource private CouponDiscountPackageDetailsMapper couponDiscountPackageDetailsMapper; + @Resource + private CouponDiscountUserRelService discountUserRelService; + + @Resource + private BsUserService bsUserService; + + @Resource + private CouponDiscountService discountService; + @Override public void create(CouponDiscountPackage discountPackage) { couponDiscountPackageMapper.insert(discountPackage); @@ -52,7 +67,7 @@ public class CouponDiscountPackageServiceImpl implements CouponDiscountPackageSe @Override public CouponDiscountPackage queryDetail(Long id) { - return null; + return couponDiscountPackageMapper.selectByPrimaryKey(id); } @Override @@ -99,13 +114,117 @@ public class CouponDiscountPackageServiceImpl implements CouponDiscountPackageSe return couponDiscountPackageRecordMapper.selectByExample(example); } + @Override + public void createRecord(CouponDiscountPackageRecord discountPackageRecord) { + couponDiscountPackageRecordMapper.insert(discountPackageRecord); + } + @Override public void createDetail(CouponDiscountPackageDetails discountPackageDetails) { couponDiscountPackageDetailsMapper.insert(discountPackageDetails); } @Override - public void deleteDetail(Long id) { - CouponDiscountPackageDetails discountPackageDetails = new CouponDiscountPackageDetails(); + public void updateDetail(CouponDiscountPackageDetails discountPackageDetails) { + couponDiscountPackageDetailsMapper.updateByPrimaryKeySelective(discountPackageDetails); + } + + @Override + public List getDetailList(Integer discountPackageId) { + CouponDiscountPackageDetailsExample example = new CouponDiscountPackageDetailsExample(); + example.createCriteria().andStatusEqualTo(1).andDiscountPackageIdEqualTo(discountPackageId); + + return couponDiscountPackageDetailsMapper.selectByExample(example); + } + + @Override + public CouponDiscountPackageDetails discountPackageDetail(Integer discountPackageId , Integer discountId) { + CouponDiscountPackageDetailsExample example = new CouponDiscountPackageDetailsExample(); + example.createCriteria().andDiscountPackageIdEqualTo(discountPackageId).andDiscountIdEqualTo(discountId).andStatusEqualTo(1); + + List list = couponDiscountPackageDetailsMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } + + @Override + public void deleteDetail(Integer id) { + couponDiscountPackageDetailsMapper.deleteByPrimaryKey(id); + } + + @Override + public void giveDiscountPackage(Integer discountPackageId, String phone) { + CouponDiscountPackage discountPackage = queryDetail(Long.valueOf(discountPackageId)); + + BsUser bsUser = bsUserService.getUser(phone); + if (bsUser == null) { + bsUser = new BsUser(); + bsUser.setPhone(phone); + bsUser.setStatus(UserStatusEnum.status1.getCode()); + bsUserService.editData(bsUser); + } + + if (discountPackage == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前券包不存在!"); + } + + CouponDiscountUserRel discountUserRel; + + List details = getDetailList(discountPackageId); + + for (CouponDiscountPackageDetails detail : details) { + CouponDiscount discount = discountService.queryDetail(Long.valueOf(detail.getDiscountId())); + for (int i = 0; i < detail.getNum(); i++) { + discountUserRel = new CouponDiscountUserRel(); + discountUserRel.setDiscountId(Long.valueOf(detail.getDiscountId())); + discountUserRel.setDiscountImg(detail.getDiscountImg()); + discountUserRel.setDiscountName(detail.getDiscountName()); + discountUserRel.setDiscountCondition(discount.getCondition()); + discountUserRel.setDiscountPrice(discount.getPrice()); + discountUserRel.setDiscountType(discount.getType()); + discountUserRel.setDiscountPercentage(discount.getPercentage()); + discountUserRel.setUserId(bsUser.getId()); + discountUserRel.setStatus(1); + discountUserRel.setCreateTime(new Date()); + + // 计算使用有效期 + Calendar userEndTime = Calendar.getInstance(); + userEndTime.setTime(new Date()); + userEndTime.set(Calendar.HOUR_OF_DAY, 23); + userEndTime.set(Calendar.MINUTE, 59); + userEndTime.set(Calendar.SECOND, 59); + userEndTime.add(Calendar.DATE, discount.getEffectiveDay()); + + if (userEndTime.getTime().compareTo(discount.getSalesEndTime()) > 0) { + discountUserRel.setUseEndTime(discount.getSalesEndTime()); + } else { + discountUserRel.setUseEndTime(userEndTime.getTime()); + } + + discountUserRelService.create(discountUserRel); + } + } + + CouponDiscountPackageRecord discountPackageRecord = new CouponDiscountPackageRecord(); + discountPackageRecord.setDiscountPackageId(discountPackageId); + discountPackageRecord.setDiscountPackageTitle(discountPackage.getTitle()); + discountPackageRecord.setType(2); + discountPackageRecord.setSerialNo(OrderUtil.generateOrderNo()); + discountPackageRecord.setUserId(bsUser.getId().intValue()); + discountPackageRecord.setUserPhone(bsUser.getPhone()); + discountPackageRecord.setCreatedTime(new Date()); + discountPackageRecord.setStatus(1); + + createRecord(discountPackageRecord); + + + discountPackage.setSurplusStock(discountPackage.getSurplusStock() - 1); + + update(discountPackage); + } } diff --git a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountServiceImpl.java b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountServiceImpl.java index 9cc2a91..4561bc2 100644 --- a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountServiceImpl.java @@ -98,6 +98,8 @@ public class CouponDiscountServiceImpl implements CouponDiscountService { couponDiscountGoodsRelMapper.deleteByPrimaryKey(id); } + + @Override public void deleteDiscountGoodsRelDiscountId(Long discountId) { CouponDiscountGoodsRelExample example = new CouponDiscountGoodsRelExample(); diff --git a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountUserRelServiceImpl.java b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountUserRelServiceImpl.java new file mode 100644 index 0000000..8d85d0b --- /dev/null +++ b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountUserRelServiceImpl.java @@ -0,0 +1,46 @@ +package com.hfkj.service.discount.impl; + +import com.hfkj.dao.CouponDiscountUserRelMapper; +import com.hfkj.entity.CouponDiscountExample; +import com.hfkj.entity.CouponDiscountUserRel; +import com.hfkj.entity.CouponDiscountUserRelExample; +import com.hfkj.service.discount.CouponDiscountUserRelService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +@Service("couponDiscountUserRelService") +public class CouponDiscountUserRelServiceImpl implements CouponDiscountUserRelService { + + @Resource + private CouponDiscountUserRelMapper couponDiscountUserRelMapper; + + @Override + public void create(CouponDiscountUserRel couponDiscountUserRel) { + couponDiscountUserRelMapper.insert(couponDiscountUserRel); + } + + @Override + public List getList(Map map) { + CouponDiscountUserRelExample example = new CouponDiscountUserRelExample(); + CouponDiscountUserRelExample.Criteria criteria = example.createCriteria(); + + + if (MapUtils.getInteger(map, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); + } + + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + + return couponDiscountUserRelMapper.selectByExample(example); + } + + +}