From 283a9bd5ef71fef25831ea72ea31564688a094c7 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 20 May 2024 10:03:03 +0800 Subject: [PATCH 1/3] Changes --- .../goods/DeliveryAddressController.java | 30 +++++++++++++++++++ .../impl/GoodsUserAddressServiceImpl.java | 16 ++++++++++ 2 files changed, 46 insertions(+) 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 e44cc61..bcffc1d 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java @@ -9,6 +9,7 @@ import com.hfkj.entity.GoodsUserAddress; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; import com.hfkj.service.goods.GoodsUserAddressService; +import com.hfkj.service.goods.impl.GoodsUserAddressServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -29,6 +30,7 @@ public class DeliveryAddressController { @Resource private UserCenter userCenter; + private GoodsUserAddressServiceImpl goodsUserAddressService; @RequestMapping(value = "/getDeliveryAddressList", method = RequestMethod.GET) @@ -197,4 +199,32 @@ public class DeliveryAddressController { } } + @RequestMapping(value = "/getUserAddress", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取默认地址") + public ResponseData getUserAddress() { + try { + + // 用户session + UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); + + Map map = new HashMap<>(); + map.put("userId" , userSession.getUser().getId()); + map.put("whetherDefault" , true); + + GoodsUserAddress userAddress = goodsUserAddressService.queryDetailByMap(map); + + if (userAddress == null) { + log.error("GoodsDetailController -> findGoodsDetailById() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相信息"); + } + + return ResponseMsgUtil.success(userAddress); + + } catch (Exception e) { + log.error("GoodsDetailController --> findGoodsDetailById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java index 048aedd..fe526f1 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsUserAddressServiceImpl.java @@ -41,6 +41,22 @@ public class GoodsUserAddressServiceImpl implements GoodsUserAddressService { @Override public GoodsUserAddress queryDetailByMap(Map map) { + GoodsUserAddressExample example = new GoodsUserAddressExample(); + GoodsUserAddressExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); + } + if (MapUtils.getBoolean(map, "whetherDefault") != null) { + criteria.andWhetherDefaultEqualTo(MapUtils.getBoolean(map, "whetherDefault")); + } + + List list = goodsUserAddressMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + return null; } From 8ab08a6941aa832cc0de39644636b30eb9cda758 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 20 May 2024 14:36:06 +0800 Subject: [PATCH 2/3] Changes --- .../discount/DiscountPackageController.java | 233 ++++++++++++++++++ .../hfkj/dao/CouponDiscountPackageMapper.java | 26 +- .../CouponDiscountPackageRecordMapper.java | 30 +-- ...ouponDiscountPackageRecordSqlProvider.java | 20 +- .../dao/CouponDiscountPackageSqlProvider.java | 22 +- .../hfkj/entity/CouponDiscountPackage.java | 22 +- .../entity/CouponDiscountPackageExample.java | 68 ++--- .../entity/CouponDiscountPackageRecord.java | 22 +- .../CouponDiscountPackageRecordExample.java | 90 +------ .../CouponDiscountPackageService.java | 32 +++ .../CouponDiscountPackageServiceImpl.java | 111 +++++++++ 11 files changed, 474 insertions(+), 202 deletions(-) create mode 100644 bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java create mode 100644 service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java diff --git a/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java b/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java new file mode 100644 index 0000000..fb66022 --- /dev/null +++ b/bweb/src/main/java/com/bweb/controller/discount/DiscountPackageController.java @@ -0,0 +1,233 @@ +package com.bweb.controller.discount; + +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.*; +import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; +import com.hfkj.service.discount.CouponDiscountPackageService; +import com.hfkj.service.discount.impl.CouponDiscountServiceImpl; +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.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value="/discountPackage") +@Api(value="优惠券包") +public class DiscountPackageController { + + private static final Logger log = LoggerFactory.getLogger(DiscountPackageController.class); + + @Resource + private CouponDiscountPackageService couponDiscountPackageService; + + @Resource + private UserCenter userCenter; + + @Resource + private CouponDiscountServiceImpl couponDiscountService; + + @RequestMapping(value = "/getDiscountPackageList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取优惠券包列表") + public ResponseData getDiscountPackageList( + @RequestParam(name = "title", required = false) String title, + @RequestParam(name = "key", required = false) String key, + @RequestParam(name = "status", required = false) Integer status) { + try { + + Map map = new HashMap<>(); + + map.put("title" , title); + map.put("key" , key); + map.put("status" , status); + + return ResponseMsgUtil.success(couponDiscountPackageService.getList(map)); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getDiscountPackageRecordList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取优惠券包记录列表") + public ResponseData getDiscountPackageRecordList(@RequestParam(name = "discountPackageId", required = false) Long discountPackageId) { + try { + + + Map map = new HashMap<>(); + + map.put("discountPackageId" , discountPackageId); + + return ResponseMsgUtil.success(couponDiscountPackageService.getListRecordByMap(map)); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/editCouponPackageInfo", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增优惠券包基本信息") + public ResponseData editCouponPackageInfo(@RequestBody CouponDiscountPackage body, HttpServletRequest request) { + try { + + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + + if (StringUtils.isBlank(body.getTitle()) + || body.getEffectiveTime() == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + + CouponDiscountPackage discountPackage; + + if (body.getId() != null) { + // 查询 + discountPackage = couponDiscountPackageService.queryDetail(body.getId()); + if (discountPackage == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.CONTENT_NOT_FOUND, ""); + } + } else { + discountPackage = new CouponDiscountPackage(); + discountPackage.setCreatedUserId(userModel.getAccount().getId().intValue()); + discountPackage.setStatus(1); + discountPackage.setTotalStock(0); + discountPackage.setSurplusStock(0); + discountPackage.setCreatedTime(new Date()); + } + + discountPackage.setUpdatedTime(new Date()); + discountPackage.setUpdatedUserId(userModel.getAccount().getId().intValue()); + + if (body.getId() != null) { + couponDiscountPackageService.update(discountPackage); + } else { + couponDiscountPackageService.create(discountPackage); + } + + return ResponseMsgUtil.success("成功"); + + } catch (Exception e) { + log.error("HighAgentController --> insertCouponPackageInfo() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/insertCouponPackageDetail", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增优惠券包详情") + public ResponseData insertCouponPackageDetail(@RequestBody CouponDiscountPackageDetails discountPackageDetails, HttpServletRequest request) { + try { + + + if ( discountPackageDetails.getDiscountPackageId() == null + || discountPackageDetails.getDiscountId() == null + || discountPackageDetails.getNum() == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + + CouponDiscount discount = couponDiscountService.queryDetail(discountPackageDetails.getDiscountId().longValue()); + + if (discount == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券不存在!"); + } + + + discountPackageDetails.setStatus(1); + discountPackageDetails.setDiscountName(discount.getName()); + discountPackageDetails.setCreatedTime(new Date()); + discountPackageDetails.setUpdatedTime(new Date()); + + couponDiscountPackageService.createDetail(discountPackageDetails); + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("HighAgentController --> insertAgent() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteDetail", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除券包详情") + public ResponseData deleteDetail(@RequestParam(name = "detailId", required = false) Long detailId) { + try { + + couponDiscountPackageService.deleteDetail(detailId); + + return ResponseMsgUtil.success("删除成功!"); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/delete", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除券包") + public ResponseData delete(@RequestParam(name = "id", required = false) Long id) { + try { + + couponDiscountPackageService.delete(id , false); + + return ResponseMsgUtil.success("删除成功!"); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/discountPackageAudit",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "券包上下架") + public ResponseData discountPackageAudit(@RequestParam(value = "id" , required = false) Long id) { + try { + + + CouponDiscountPackage discountPackage = couponDiscountPackageService.queryDetail(id); + + if (discountPackage.getStatus() == 1) { + discountPackage.setStatus(2); + discountPackage.setUpdatedTime(new Date()); + } else if (discountPackage.getStatus() == 2) { + discountPackage.setStatus(3); + discountPackage.setUpdatedTime(new Date()); + } + + couponDiscountPackageService.update(discountPackage); + + return ResponseMsgUtil.success("成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageMapper.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageMapper.java index 84c52a5..3ec9d7b 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageMapper.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageMapper.java @@ -34,19 +34,19 @@ public interface CouponDiscountPackageMapper extends CouponDiscountPackageMapper @Delete({ "delete from coupon_discount_package", - "where id = #{id,jdbcType=INTEGER}" + "where id = #{id,jdbcType=BIGINT}" }) - int deleteByPrimaryKey(Integer id); + int deleteByPrimaryKey(Long id); @Insert({ "insert into coupon_discount_package (`key`, title, ", - "effective_tiem, created_user_id, ", + "effective_time, created_user_id, ", "created_time, updated_user_id, ", "updated_time, `status`, ", "total_stock, surplus_stock, ", "ext_1, ext_2, ext_3)", "values (#{key,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, ", - "#{effectiveTiem,jdbcType=TIMESTAMP}, #{createdUserId,jdbcType=INTEGER}, ", + "#{effectiveTime,jdbcType=TIMESTAMP}, #{createdUserId,jdbcType=INTEGER}, ", "#{createdTime,jdbcType=TIMESTAMP}, #{updatedUserId,jdbcType=INTEGER}, ", "#{updatedTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", "#{totalStock,jdbcType=INTEGER}, #{surplusStock,jdbcType=INTEGER}, ", @@ -61,10 +61,10 @@ public interface CouponDiscountPackageMapper extends CouponDiscountPackageMapper @SelectProvider(type=CouponDiscountPackageSqlProvider.class, method="selectByExample") @Results({ - @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="key", property="key", jdbcType=JdbcType.VARCHAR), @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), - @Result(column="effective_tiem", property="effectiveTiem", jdbcType=JdbcType.TIMESTAMP), + @Result(column="effective_time", property="effectiveTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="created_user_id", property="createdUserId", jdbcType=JdbcType.INTEGER), @Result(column="created_time", property="createdTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="updated_user_id", property="updatedUserId", jdbcType=JdbcType.INTEGER), @@ -80,16 +80,16 @@ public interface CouponDiscountPackageMapper extends CouponDiscountPackageMapper @Select({ "select", - "id, `key`, title, effective_tiem, created_user_id, created_time, updated_user_id, ", + "id, `key`, title, effective_time, created_user_id, created_time, updated_user_id, ", "updated_time, `status`, total_stock, surplus_stock, ext_1, ext_2, ext_3", "from coupon_discount_package", - "where id = #{id,jdbcType=INTEGER}" + "where id = #{id,jdbcType=BIGINT}" }) @Results({ - @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="key", property="key", jdbcType=JdbcType.VARCHAR), @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), - @Result(column="effective_tiem", property="effectiveTiem", jdbcType=JdbcType.TIMESTAMP), + @Result(column="effective_time", property="effectiveTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="created_user_id", property="createdUserId", jdbcType=JdbcType.INTEGER), @Result(column="created_time", property="createdTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="updated_user_id", property="updatedUserId", jdbcType=JdbcType.INTEGER), @@ -101,7 +101,7 @@ public interface CouponDiscountPackageMapper extends CouponDiscountPackageMapper @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) }) - CouponDiscountPackage selectByPrimaryKey(Integer id); + CouponDiscountPackage selectByPrimaryKey(Long id); @UpdateProvider(type=CouponDiscountPackageSqlProvider.class, method="updateByExampleSelective") int updateByExampleSelective(@Param("record") CouponDiscountPackage record, @Param("example") CouponDiscountPackageExample example); @@ -116,7 +116,7 @@ public interface CouponDiscountPackageMapper extends CouponDiscountPackageMapper "update coupon_discount_package", "set `key` = #{key,jdbcType=VARCHAR},", "title = #{title,jdbcType=VARCHAR},", - "effective_tiem = #{effectiveTiem,jdbcType=TIMESTAMP},", + "effective_time = #{effectiveTime,jdbcType=TIMESTAMP},", "created_user_id = #{createdUserId,jdbcType=INTEGER},", "created_time = #{createdTime,jdbcType=TIMESTAMP},", "updated_user_id = #{updatedUserId,jdbcType=INTEGER},", @@ -127,7 +127,7 @@ public interface CouponDiscountPackageMapper extends CouponDiscountPackageMapper "ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_2 = #{ext2,jdbcType=VARCHAR},", "ext_3 = #{ext3,jdbcType=VARCHAR}", - "where id = #{id,jdbcType=INTEGER}" + "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(CouponDiscountPackage record); } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java index 87bf336..44edfe6 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordMapper.java @@ -34,21 +34,21 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Delete({ "delete from coupon_discount_package_record", - "where id = #{id,jdbcType=INTEGER}" + "where id = #{id,jdbcType=BIGINT}" }) - int deleteByPrimaryKey(Integer id); + int deleteByPrimaryKey(Long id); @Insert({ "insert into coupon_discount_package_record (discount_package_title, discount_package_id, ", "order_id, child_order_id, ", - "record_no, serial_no, ", - "`type`, user_id, user_phone, ", + "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}, ", - "#{recordNo,jdbcType=VARCHAR}, #{serialNo,jdbcType=VARCHAR}, ", - "#{type,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{userPhone,jdbcType=VARCHAR}, ", + "#{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})" }) @@ -61,12 +61,11 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @SelectProvider(type=CouponDiscountPackageRecordSqlProvider.class, method="selectByExample") @Results({ - @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @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="child_order_id", property="childOrderId", jdbcType=JdbcType.INTEGER), - @Result(column="record_no", property="recordNo", jdbcType=JdbcType.VARCHAR), @Result(column="serial_no", property="serialNo", jdbcType=JdbcType.VARCHAR), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER), @@ -81,19 +80,17 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Select({ "select", - "id, discount_package_title, discount_package_id, order_id, child_order_id, record_no, ", - "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, 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=INTEGER}" + "where id = #{id,jdbcType=BIGINT}" }) @Results({ - @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @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="child_order_id", property="childOrderId", jdbcType=JdbcType.INTEGER), - @Result(column="record_no", property="recordNo", jdbcType=JdbcType.VARCHAR), @Result(column="serial_no", property="serialNo", jdbcType=JdbcType.VARCHAR), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER), @@ -104,7 +101,7 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) }) - CouponDiscountPackageRecord selectByPrimaryKey(Integer id); + CouponDiscountPackageRecord selectByPrimaryKey(Long id); @UpdateProvider(type=CouponDiscountPackageRecordSqlProvider.class, method="updateByExampleSelective") int updateByExampleSelective(@Param("record") CouponDiscountPackageRecord record, @Param("example") CouponDiscountPackageRecordExample example); @@ -121,7 +118,6 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage "discount_package_id = #{discountPackageId,jdbcType=INTEGER},", "order_id = #{orderId,jdbcType=INTEGER},", "child_order_id = #{childOrderId,jdbcType=INTEGER},", - "record_no = #{recordNo,jdbcType=VARCHAR},", "serial_no = #{serialNo,jdbcType=VARCHAR},", "`type` = #{type,jdbcType=INTEGER},", "user_id = #{userId,jdbcType=INTEGER},", @@ -131,7 +127,7 @@ public interface CouponDiscountPackageRecordMapper extends CouponDiscountPackage "ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_2 = #{ext2,jdbcType=VARCHAR},", "ext_3 = #{ext3,jdbcType=VARCHAR}", - "where id = #{id,jdbcType=INTEGER}" + "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(CouponDiscountPackageRecord record); } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java index 6151856..13e2388 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageRecordSqlProvider.java @@ -44,10 +44,6 @@ public class CouponDiscountPackageRecordSqlProvider { sql.VALUES("child_order_id", "#{childOrderId,jdbcType=INTEGER}"); } - if (record.getRecordNo() != null) { - sql.VALUES("record_no", "#{recordNo,jdbcType=VARCHAR}"); - } - if (record.getSerialNo() != null) { sql.VALUES("serial_no", "#{serialNo,jdbcType=VARCHAR}"); } @@ -98,7 +94,6 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SELECT("discount_package_id"); sql.SELECT("order_id"); sql.SELECT("child_order_id"); - sql.SELECT("record_no"); sql.SELECT("serial_no"); sql.SELECT("`type`"); sql.SELECT("user_id"); @@ -126,7 +121,7 @@ public class CouponDiscountPackageRecordSqlProvider { sql.UPDATE("coupon_discount_package_record"); if (record.getId() != null) { - sql.SET("id = #{record.id,jdbcType=INTEGER}"); + sql.SET("id = #{record.id,jdbcType=BIGINT}"); } if (record.getDiscountPackageTitle() != null) { @@ -145,10 +140,6 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SET("child_order_id = #{record.childOrderId,jdbcType=INTEGER}"); } - if (record.getRecordNo() != null) { - sql.SET("record_no = #{record.recordNo,jdbcType=VARCHAR}"); - } - if (record.getSerialNo() != null) { sql.SET("serial_no = #{record.serialNo,jdbcType=VARCHAR}"); } @@ -193,12 +184,11 @@ public class CouponDiscountPackageRecordSqlProvider { SQL sql = new SQL(); sql.UPDATE("coupon_discount_package_record"); - sql.SET("id = #{record.id,jdbcType=INTEGER}"); + sql.SET("id = #{record.id,jdbcType=BIGINT}"); 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("child_order_id = #{record.childOrderId,jdbcType=INTEGER}"); - sql.SET("record_no = #{record.recordNo,jdbcType=VARCHAR}"); sql.SET("serial_no = #{record.serialNo,jdbcType=VARCHAR}"); sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); sql.SET("user_id = #{record.userId,jdbcType=INTEGER}"); @@ -234,10 +224,6 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SET("child_order_id = #{childOrderId,jdbcType=INTEGER}"); } - if (record.getRecordNo() != null) { - sql.SET("record_no = #{recordNo,jdbcType=VARCHAR}"); - } - if (record.getSerialNo() != null) { sql.SET("serial_no = #{serialNo,jdbcType=VARCHAR}"); } @@ -274,7 +260,7 @@ public class CouponDiscountPackageRecordSqlProvider { sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); } - sql.WHERE("id = #{id,jdbcType=INTEGER}"); + sql.WHERE("id = #{id,jdbcType=BIGINT}"); return sql.toString(); } diff --git a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageSqlProvider.java b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageSqlProvider.java index c0c8d46..c2dbd25 100644 --- a/service/src/main/java/com/hfkj/dao/CouponDiscountPackageSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/CouponDiscountPackageSqlProvider.java @@ -36,8 +36,8 @@ public class CouponDiscountPackageSqlProvider { sql.VALUES("title", "#{title,jdbcType=VARCHAR}"); } - if (record.getEffectiveTiem() != null) { - sql.VALUES("effective_tiem", "#{effectiveTiem,jdbcType=TIMESTAMP}"); + if (record.getEffectiveTime() != null) { + sql.VALUES("effective_time", "#{effectiveTime,jdbcType=TIMESTAMP}"); } if (record.getCreatedUserId() != null) { @@ -92,7 +92,7 @@ public class CouponDiscountPackageSqlProvider { } sql.SELECT("`key`"); sql.SELECT("title"); - sql.SELECT("effective_tiem"); + sql.SELECT("effective_time"); sql.SELECT("created_user_id"); sql.SELECT("created_time"); sql.SELECT("updated_user_id"); @@ -121,7 +121,7 @@ public class CouponDiscountPackageSqlProvider { sql.UPDATE("coupon_discount_package"); if (record.getId() != null) { - sql.SET("id = #{record.id,jdbcType=INTEGER}"); + sql.SET("id = #{record.id,jdbcType=BIGINT}"); } if (record.getKey() != null) { @@ -132,8 +132,8 @@ public class CouponDiscountPackageSqlProvider { sql.SET("title = #{record.title,jdbcType=VARCHAR}"); } - if (record.getEffectiveTiem() != null) { - sql.SET("effective_tiem = #{record.effectiveTiem,jdbcType=TIMESTAMP}"); + if (record.getEffectiveTime() != null) { + sql.SET("effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP}"); } if (record.getCreatedUserId() != null) { @@ -184,10 +184,10 @@ public class CouponDiscountPackageSqlProvider { SQL sql = new SQL(); sql.UPDATE("coupon_discount_package"); - sql.SET("id = #{record.id,jdbcType=INTEGER}"); + sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("`key` = #{record.key,jdbcType=VARCHAR}"); sql.SET("title = #{record.title,jdbcType=VARCHAR}"); - sql.SET("effective_tiem = #{record.effectiveTiem,jdbcType=TIMESTAMP}"); + sql.SET("effective_time = #{record.effectiveTime,jdbcType=TIMESTAMP}"); sql.SET("created_user_id = #{record.createdUserId,jdbcType=INTEGER}"); sql.SET("created_time = #{record.createdTime,jdbcType=TIMESTAMP}"); sql.SET("updated_user_id = #{record.updatedUserId,jdbcType=INTEGER}"); @@ -216,8 +216,8 @@ public class CouponDiscountPackageSqlProvider { sql.SET("title = #{title,jdbcType=VARCHAR}"); } - if (record.getEffectiveTiem() != null) { - sql.SET("effective_tiem = #{effectiveTiem,jdbcType=TIMESTAMP}"); + if (record.getEffectiveTime() != null) { + sql.SET("effective_time = #{effectiveTime,jdbcType=TIMESTAMP}"); } if (record.getCreatedUserId() != null) { @@ -260,7 +260,7 @@ public class CouponDiscountPackageSqlProvider { sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); } - sql.WHERE("id = #{id,jdbcType=INTEGER}"); + sql.WHERE("id = #{id,jdbcType=BIGINT}"); return sql.toString(); } diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackage.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackage.java index 6b0abab..acb378d 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackage.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackage.java @@ -16,7 +16,7 @@ public class CouponDiscountPackage implements Serializable { /** * 主键 */ - private Integer id; + private Long id; /** * 编码 @@ -31,7 +31,7 @@ public class CouponDiscountPackage implements Serializable { /** * 有效期 */ - private Date effectiveTiem; + private Date effectiveTime; /** * 创建人 @@ -85,11 +85,11 @@ public class CouponDiscountPackage implements Serializable { private static final long serialVersionUID = 1L; - public Integer getId() { + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } @@ -109,12 +109,12 @@ public class CouponDiscountPackage implements Serializable { this.title = title; } - public Date getEffectiveTiem() { - return effectiveTiem; + public Date getEffectiveTime() { + return effectiveTime; } - public void setEffectiveTiem(Date effectiveTiem) { - this.effectiveTiem = effectiveTiem; + public void setEffectiveTime(Date effectiveTime) { + this.effectiveTime = effectiveTime; } public Integer getCreatedUserId() { @@ -212,7 +212,7 @@ public class CouponDiscountPackage implements Serializable { return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getKey() == null ? other.getKey() == null : this.getKey().equals(other.getKey())) && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle())) - && (this.getEffectiveTiem() == null ? other.getEffectiveTiem() == null : this.getEffectiveTiem().equals(other.getEffectiveTiem())) + && (this.getEffectiveTime() == null ? other.getEffectiveTime() == null : this.getEffectiveTime().equals(other.getEffectiveTime())) && (this.getCreatedUserId() == null ? other.getCreatedUserId() == null : this.getCreatedUserId().equals(other.getCreatedUserId())) && (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime())) && (this.getUpdatedUserId() == null ? other.getUpdatedUserId() == null : this.getUpdatedUserId().equals(other.getUpdatedUserId())) @@ -232,7 +232,7 @@ public class CouponDiscountPackage implements Serializable { result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getKey() == null) ? 0 : getKey().hashCode()); result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode()); - result = prime * result + ((getEffectiveTiem() == null) ? 0 : getEffectiveTiem().hashCode()); + result = prime * result + ((getEffectiveTime() == null) ? 0 : getEffectiveTime().hashCode()); result = prime * result + ((getCreatedUserId() == null) ? 0 : getCreatedUserId().hashCode()); result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode()); result = prime * result + ((getUpdatedUserId() == null) ? 0 : getUpdatedUserId().hashCode()); @@ -255,7 +255,7 @@ public class CouponDiscountPackage implements Serializable { sb.append(", id=").append(id); sb.append(", key=").append(key); sb.append(", title=").append(title); - sb.append(", effectiveTiem=").append(effectiveTiem); + sb.append(", effectiveTime=").append(effectiveTime); sb.append(", createdUserId=").append(createdUserId); sb.append(", createdTime=").append(createdTime); sb.append(", updatedUserId=").append(updatedUserId); diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageExample.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageExample.java index 509629a..c600302 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageExample.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageExample.java @@ -135,52 +135,52 @@ public class CouponDiscountPackageExample { return (Criteria) this; } - public Criteria andIdEqualTo(Integer value) { + public Criteria andIdEqualTo(Long value) { addCriterion("id =", value, "id"); return (Criteria) this; } - public Criteria andIdNotEqualTo(Integer value) { + public Criteria andIdNotEqualTo(Long value) { addCriterion("id <>", value, "id"); return (Criteria) this; } - public Criteria andIdGreaterThan(Integer value) { + public Criteria andIdGreaterThan(Long value) { addCriterion("id >", value, "id"); return (Criteria) this; } - public Criteria andIdGreaterThanOrEqualTo(Integer value) { + public Criteria andIdGreaterThanOrEqualTo(Long value) { addCriterion("id >=", value, "id"); return (Criteria) this; } - public Criteria andIdLessThan(Integer value) { + public Criteria andIdLessThan(Long value) { addCriterion("id <", value, "id"); return (Criteria) this; } - public Criteria andIdLessThanOrEqualTo(Integer value) { + public Criteria andIdLessThanOrEqualTo(Long value) { addCriterion("id <=", value, "id"); return (Criteria) this; } - public Criteria andIdIn(List values) { + public Criteria andIdIn(List values) { addCriterion("id in", values, "id"); return (Criteria) this; } - public Criteria andIdNotIn(List values) { + public Criteria andIdNotIn(List values) { addCriterion("id not in", values, "id"); return (Criteria) this; } - public Criteria andIdBetween(Integer value1, Integer value2) { + public Criteria andIdBetween(Long value1, Long value2) { addCriterion("id between", value1, value2, "id"); return (Criteria) this; } - public Criteria andIdNotBetween(Integer value1, Integer value2) { + public Criteria andIdNotBetween(Long value1, Long value2) { addCriterion("id not between", value1, value2, "id"); return (Criteria) this; } @@ -325,63 +325,63 @@ public class CouponDiscountPackageExample { return (Criteria) this; } - public Criteria andEffectiveTiemIsNull() { - addCriterion("effective_tiem is null"); + public Criteria andEffectiveTimeIsNull() { + addCriterion("effective_time is null"); return (Criteria) this; } - public Criteria andEffectiveTiemIsNotNull() { - addCriterion("effective_tiem is not null"); + public Criteria andEffectiveTimeIsNotNull() { + addCriterion("effective_time is not null"); return (Criteria) this; } - public Criteria andEffectiveTiemEqualTo(Date value) { - addCriterion("effective_tiem =", value, "effectiveTiem"); + public Criteria andEffectiveTimeEqualTo(Date value) { + addCriterion("effective_time =", value, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemNotEqualTo(Date value) { - addCriterion("effective_tiem <>", value, "effectiveTiem"); + public Criteria andEffectiveTimeNotEqualTo(Date value) { + addCriterion("effective_time <>", value, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemGreaterThan(Date value) { - addCriterion("effective_tiem >", value, "effectiveTiem"); + public Criteria andEffectiveTimeGreaterThan(Date value) { + addCriterion("effective_time >", value, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemGreaterThanOrEqualTo(Date value) { - addCriterion("effective_tiem >=", value, "effectiveTiem"); + public Criteria andEffectiveTimeGreaterThanOrEqualTo(Date value) { + addCriterion("effective_time >=", value, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemLessThan(Date value) { - addCriterion("effective_tiem <", value, "effectiveTiem"); + public Criteria andEffectiveTimeLessThan(Date value) { + addCriterion("effective_time <", value, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemLessThanOrEqualTo(Date value) { - addCriterion("effective_tiem <=", value, "effectiveTiem"); + public Criteria andEffectiveTimeLessThanOrEqualTo(Date value) { + addCriterion("effective_time <=", value, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemIn(List values) { - addCriterion("effective_tiem in", values, "effectiveTiem"); + public Criteria andEffectiveTimeIn(List values) { + addCriterion("effective_time in", values, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemNotIn(List values) { - addCriterion("effective_tiem not in", values, "effectiveTiem"); + public Criteria andEffectiveTimeNotIn(List values) { + addCriterion("effective_time not in", values, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemBetween(Date value1, Date value2) { - addCriterion("effective_tiem between", value1, value2, "effectiveTiem"); + public Criteria andEffectiveTimeBetween(Date value1, Date value2) { + addCriterion("effective_time between", value1, value2, "effectiveTime"); return (Criteria) this; } - public Criteria andEffectiveTiemNotBetween(Date value1, Date value2) { - addCriterion("effective_tiem not between", value1, value2, "effectiveTiem"); + public Criteria andEffectiveTimeNotBetween(Date value1, Date value2) { + addCriterion("effective_time not between", value1, value2, "effectiveTime"); 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 5f48183..f8276f6 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecord.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecord.java @@ -16,7 +16,7 @@ public class CouponDiscountPackageRecord implements Serializable { /** * 主键 */ - private Integer id; + private Long id; /** * 优惠券包名称 @@ -38,11 +38,6 @@ public class CouponDiscountPackageRecord implements Serializable { */ private Integer childOrderId; - /** - * 记录订单 - */ - private String recordNo; - /** * 记录序号 */ @@ -90,11 +85,11 @@ public class CouponDiscountPackageRecord implements Serializable { private static final long serialVersionUID = 1L; - public Integer getId() { + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } @@ -130,14 +125,6 @@ public class CouponDiscountPackageRecord implements Serializable { this.childOrderId = childOrderId; } - public String getRecordNo() { - return recordNo; - } - - public void setRecordNo(String recordNo) { - this.recordNo = recordNo; - } - public String getSerialNo() { return serialNo; } @@ -227,7 +214,6 @@ public class CouponDiscountPackageRecord implements Serializable { && (this.getDiscountPackageId() == null ? other.getDiscountPackageId() == null : this.getDiscountPackageId().equals(other.getDiscountPackageId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId())) - && (this.getRecordNo() == null ? other.getRecordNo() == null : this.getRecordNo().equals(other.getRecordNo())) && (this.getSerialNo() == null ? other.getSerialNo() == null : this.getSerialNo().equals(other.getSerialNo())) && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) @@ -248,7 +234,6 @@ public class CouponDiscountPackageRecord implements Serializable { result = prime * result + ((getDiscountPackageId() == null) ? 0 : getDiscountPackageId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode()); - result = prime * result + ((getRecordNo() == null) ? 0 : getRecordNo().hashCode()); result = prime * result + ((getSerialNo() == null) ? 0 : getSerialNo().hashCode()); result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); @@ -272,7 +257,6 @@ public class CouponDiscountPackageRecord implements Serializable { sb.append(", discountPackageId=").append(discountPackageId); sb.append(", orderId=").append(orderId); sb.append(", childOrderId=").append(childOrderId); - sb.append(", recordNo=").append(recordNo); sb.append(", serialNo=").append(serialNo); sb.append(", type=").append(type); sb.append(", userId=").append(userId); diff --git a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java index 3bc5d62..a868823 100644 --- a/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java +++ b/service/src/main/java/com/hfkj/entity/CouponDiscountPackageRecordExample.java @@ -135,52 +135,52 @@ public class CouponDiscountPackageRecordExample { return (Criteria) this; } - public Criteria andIdEqualTo(Integer value) { + public Criteria andIdEqualTo(Long value) { addCriterion("id =", value, "id"); return (Criteria) this; } - public Criteria andIdNotEqualTo(Integer value) { + public Criteria andIdNotEqualTo(Long value) { addCriterion("id <>", value, "id"); return (Criteria) this; } - public Criteria andIdGreaterThan(Integer value) { + public Criteria andIdGreaterThan(Long value) { addCriterion("id >", value, "id"); return (Criteria) this; } - public Criteria andIdGreaterThanOrEqualTo(Integer value) { + public Criteria andIdGreaterThanOrEqualTo(Long value) { addCriterion("id >=", value, "id"); return (Criteria) this; } - public Criteria andIdLessThan(Integer value) { + public Criteria andIdLessThan(Long value) { addCriterion("id <", value, "id"); return (Criteria) this; } - public Criteria andIdLessThanOrEqualTo(Integer value) { + public Criteria andIdLessThanOrEqualTo(Long value) { addCriterion("id <=", value, "id"); return (Criteria) this; } - public Criteria andIdIn(List values) { + public Criteria andIdIn(List values) { addCriterion("id in", values, "id"); return (Criteria) this; } - public Criteria andIdNotIn(List values) { + public Criteria andIdNotIn(List values) { addCriterion("id not in", values, "id"); return (Criteria) this; } - public Criteria andIdBetween(Integer value1, Integer value2) { + public Criteria andIdBetween(Long value1, Long value2) { addCriterion("id between", value1, value2, "id"); return (Criteria) this; } - public Criteria andIdNotBetween(Integer value1, Integer value2) { + public Criteria andIdNotBetween(Long value1, Long value2) { addCriterion("id not between", value1, value2, "id"); return (Criteria) this; } @@ -435,76 +435,6 @@ public class CouponDiscountPackageRecordExample { return (Criteria) this; } - public Criteria andRecordNoIsNull() { - addCriterion("record_no is null"); - return (Criteria) this; - } - - public Criteria andRecordNoIsNotNull() { - addCriterion("record_no is not null"); - return (Criteria) this; - } - - public Criteria andRecordNoEqualTo(String value) { - addCriterion("record_no =", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoNotEqualTo(String value) { - addCriterion("record_no <>", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoGreaterThan(String value) { - addCriterion("record_no >", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoGreaterThanOrEqualTo(String value) { - addCriterion("record_no >=", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoLessThan(String value) { - addCriterion("record_no <", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoLessThanOrEqualTo(String value) { - addCriterion("record_no <=", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoLike(String value) { - addCriterion("record_no like", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoNotLike(String value) { - addCriterion("record_no not like", value, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoIn(List values) { - addCriterion("record_no in", values, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoNotIn(List values) { - addCriterion("record_no not in", values, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoBetween(String value1, String value2) { - addCriterion("record_no between", value1, value2, "recordNo"); - return (Criteria) this; - } - - public Criteria andRecordNoNotBetween(String value1, String value2) { - addCriterion("record_no not between", value1, value2, "recordNo"); - return (Criteria) this; - } - public Criteria andSerialNoIsNull() { addCriterion("serial_no 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 c1055d1..5a415d8 100644 --- a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java +++ b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java @@ -2,6 +2,8 @@ package com.hfkj.service.discount; import com.hfkj.entity.CouponDiscount; import com.hfkj.entity.CouponDiscountPackage; +import com.hfkj.entity.CouponDiscountPackageDetails; +import com.hfkj.entity.CouponDiscountPackageRecord; import java.util.List; import java.util.Map; @@ -68,4 +70,34 @@ public interface CouponDiscountPackageService { */ List getList(Map map); + /** + * @Author Sum1Dream + * @Name getListRecordByMap + * @Description // 根据多条件查询列表 + * @Date 15:13 2024/4/19 + * @Param map + * @return java.util.List + */ + List getListRecordByMap(Map map); + + /** + * @Author Sum1Dream + * @Name create + * @Description // 创建 + * @Date 15:11 2024/4/19 + * @Param CouponDiscount + * @return void + */ + void createDetail(CouponDiscountPackageDetails discountPackageDetails); + + /** + * @Author Sum1Dream + * @Name delete + * @Description // 修改 + * @Date 15:12 2024/4/19 + * @Param id + * @return void + */ + void deleteDetail(Long id); + } 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 new file mode 100644 index 0000000..7403d3d --- /dev/null +++ b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java @@ -0,0 +1,111 @@ +package com.hfkj.service.discount.impl; + +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 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; + +@Service("couponDiscountPackageService") +public class CouponDiscountPackageServiceImpl implements CouponDiscountPackageService { + + @Resource + private CouponDiscountPackageMapper couponDiscountPackageMapper; + + @Resource + private CouponDiscountPackageRecordMapper couponDiscountPackageRecordMapper; + + @Resource + private CouponDiscountPackageDetailsMapper couponDiscountPackageDetailsMapper; + + @Override + public void create(CouponDiscountPackage discountPackage) { + couponDiscountPackageMapper.insert(discountPackage); + } + + @Override + public void update(CouponDiscountPackage discountPackage) { + couponDiscountPackageMapper.updateByPrimaryKeySelective(discountPackage); + } + + @Override + public void delete(Long id, Boolean fullDelete) { + + if (fullDelete) { + couponDiscountPackageMapper.deleteByPrimaryKey(id); + } else { + CouponDiscountPackage discountPackage = queryDetail(id); + discountPackage.setStatus(0); + discountPackage.setUpdatedTime(new Date()); + update(discountPackage); + } + } + + @Override + public CouponDiscountPackage queryDetail(Long id) { + return null; + } + + @Override + public CouponDiscountPackage queryDetailByMap(Map map) { + return null; + } + + @Override + public List getList(Map map) { + + CouponDiscountPackageExample example = new CouponDiscountPackageExample(); + CouponDiscountPackageExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isNotBlank(MapUtils.getString(map, "title"))) { + criteria.andTitleLike("%"+MapUtils.getString(map, "title")+"%"); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "key"))) { + criteria.andKeyEqualTo(MapUtils.getString(map, "key")); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } else { + criteria.andStatusNotEqualTo(0); + } + + return couponDiscountPackageMapper.selectByExample(example); + } + + @Override + public List getListRecordByMap(Map map) { + + CouponDiscountPackageRecordExample example = new CouponDiscountPackageRecordExample(); + CouponDiscountPackageRecordExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(map, "discountPackageId") != null) { + criteria.andDiscountPackageIdEqualTo(MapUtils.getInteger(map, "discountPackageId")); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } else { + criteria.andStatusNotEqualTo(0); + } + + return couponDiscountPackageRecordMapper.selectByExample(example); + } + + @Override + public void createDetail(CouponDiscountPackageDetails discountPackageDetails) { + couponDiscountPackageDetailsMapper.insert(discountPackageDetails); + } + + @Override + public void deleteDetail(Long id) { + CouponDiscountPackageDetails discountPackageDetails = new CouponDiscountPackageDetails(); + } +} From e5a19b4f0fd20e03095e08c54c69e56c5ab8fbad Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 20 May 2024 17:52:39 +0800 Subject: [PATCH 3/3] 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); + } + + +}