diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java index a299f8f98..22b73da31 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java @@ -123,7 +123,7 @@ public class TtCouponGoodsController extends DouyinBaseController { return new ResultData(goodsTemplateGet); } } catch (Exception e) { - logger.error("allTreeList error.",e); + logger.error("getTemplate error.",e); return new ResultData(Result.ERROR,e.getMessage()); } } @@ -148,7 +148,7 @@ public class TtCouponGoodsController extends DouyinBaseController { boolean isSaas = this.isGoodLifeSaas(); return ttCouponGoodsService.productSave(coupon,isSaas); } catch (Exception e) { - logger.error("allTreeList error.",e); + logger.error("product save error.",e); return new ResultData(Result.ERROR,e.getMessage()); } } @@ -164,7 +164,7 @@ public class TtCouponGoodsController extends DouyinBaseController { boolean isSaas = this.isGoodLifeSaas(); return ttCouponGoodsService.productDraftGet(getTenantInfo(),id,isSaas); } catch (Exception e) { - logger.error("allTreeList error.",e); + logger.error("product draft error.",e); return new ResultData(Result.ERROR,e.getMessage()); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderReservationController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderReservationController.java new file mode 100644 index 000000000..7f82bed87 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderReservationController.java @@ -0,0 +1,73 @@ +package com.iformall.controller.market; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.controller.base.BaseController; +import com.iformall.domain.po.WxCouponOrderReservation; +import com.iformall.domain.po.base.BaseEntity; +import com.iformall.service.WxCouponOrderReservationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("wxCouponOrderReservation") +@Api(description = "查询预约接口") +public class WxCouponOrderReservationController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxCouponOrderReservationService wxCouponOrderReservationService; + + @ApiOperation("分页列表接口") + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData list(@ModelAttribute WxCouponOrderReservation reservation, Integer pageNum, Integer pageSize) { + if (reservation == null) reservation = new WxCouponOrderReservation(); + reservation.updateTenantInfo(getTenantInfo()); + reservation.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); + PageInfo wxCouponOrderReservationPageInfo = wxCouponOrderReservationService.listAsPage(reservation, pageNum, pageSize); + return new ResultData(wxCouponOrderReservationPageInfo); + } + + @ApiOperation(value = "卡券详情接口") + @GetMapping("detail") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "预约ID", dataType = "Long", paramType = "query", required = true) + }) + public ResultData detail(@RequestParam("id") Long id) { + if(id == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + WxCouponOrderReservation reservation = wxCouponOrderReservationService.getById(id, getTenantInfo().getTenantId()); + return new ResultData(reservation); + } + + @ApiOperation(value = "修改状态") + @PostMapping("updateStatus") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "预约ID", dataType = "Long", paramType = "query", required = true) + }) + public ResultData updateStatus(@RequestBody WxCouponOrderReservation reservation) { + if(reservation.getId() == null || reservation.getStatus() == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + WxCouponOrderReservation updReservation = new WxCouponOrderReservation(); + updReservation.updateTenantInfo(getTenantInfo()); + updReservation.setId(reservation.getId()); + updReservation.setStatus(reservation.getStatus()); + updReservation.setRemark(reservation.getRemark()); + wxCouponOrderReservationService.saveOrUpdate(updReservation); + return new ResultData(); + } + + +} diff --git a/mallinkAdmin/src/main/resources/db/migration/V2023060500002_wx_coupon_order_reservation.sql b/mallinkAdmin/src/main/resources/db/migration/V2023060500002_wx_coupon_order_reservation.sql new file mode 100644 index 000000000..4560e957d --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V2023060500002_wx_coupon_order_reservation.sql @@ -0,0 +1,135 @@ +DROP TABLE IF EXISTS `wx_coupon_order_reservation`; +CREATE TABLE `wx_coupon_order_reservation` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', + `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', + `coupon_order_id` bigint(20) NOT NULL, + `coupon_id` bigint(20) NOT NULL COMMENT '单张券ID', + `coupon_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `c_user_id` bigint(20) UNSIGNED NOT NULL COMMENT 'c端用户id', + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `user_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `user_region` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `user_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `start_date` datetime(0) DEFAULT NULL, + `end_date` datetime(0) DEFAULT NULL, + `describe` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `describe_img` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `status` smallint(1) NOT NULL, + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `finish_time` datetime(0) DEFAULT NULL, + `btenant_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `buser_id` bigint(20) DEFAULT NULL, + `buser_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `buser_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `merchant_id` bigint(20) DEFAULT NULL, + `create_date` datetime(0) DEFAULT CURRENT_TIMESTAMP, + `update_date` datetime(0) DEFAULT CURRENT_TIMESTAMP, + `is_del` smallint(1) NOT NULL, + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `id_UNIQUE`(`id`) USING BTREE, + UNIQUE INDEX `coupon_order_id`(`coupon_order_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '' ROW_FORMAT = Dynamic; + + + +create table wx_coupon_order_reservation_0 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_1 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_2 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_3 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_4 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_5 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_6 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_7 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_8 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_9 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_10 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_11 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_12 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_13 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_14 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_15 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_16 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_17 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_18 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_19 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_20 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_21 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_22 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_23 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_24 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_25 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_26 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_27 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_28 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_29 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_30 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_31 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_32 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_33 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_34 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_35 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_36 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_37 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_38 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_39 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_40 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_41 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_42 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_43 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_44 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_45 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_46 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_47 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_48 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_49 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_50 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_51 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_52 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_53 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_54 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_55 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_56 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_57 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_58 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_59 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_60 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_61 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_62 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_63 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_64 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_65 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_66 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_67 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_68 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_69 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_70 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_71 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_72 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_73 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_74 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_75 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_76 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_77 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_78 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_79 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_80 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_81 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_82 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_83 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_84 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_85 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_86 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_87 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_88 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_89 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_90 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_91 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_92 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_93 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_94 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_95 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_96 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_97 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_98 like wx_coupon_order_reservation; +create table wx_coupon_order_reservation_99 like wx_coupon_order_reservation; \ No newline at end of file diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderReservationController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderReservationController.java new file mode 100644 index 000000000..4fd77df72 --- /dev/null +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderReservationController.java @@ -0,0 +1,99 @@ +package com.iformall.controller; + +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCouponOrderReservation; +import com.iformall.enums.EnumCouponOrderReservationStatus; +import com.iformall.service.WxCouponOrderReservationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("wxCouponOrderReservation") +@Api(description = "查询预约接口") +public class WxCouponOrderReservationController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxCouponOrderReservationService wxCouponOrderReservationService; + + + @ApiOperation("分页列表接口") + @GetMapping("getUserReservation") + @ApiImplicitParams({}) + public ResultData getUserReservation(@RequestParam("couponOrderId") Long couponOrderId) { + if(couponOrderId == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + WxCouponOrderReservation reservation = new WxCouponOrderReservation(); + reservation.updateTenantInfo(getTenantInfo()); + reservation.setCUserId(getMemberId()); + reservation.setCouponOrderId(couponOrderId); + reservation = wxCouponOrderReservationService.findUserReservation(reservation); + return new ResultData(reservation); + } + + @ApiOperation(value = "详情接口") + @GetMapping("detail") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "预约ID", dataType = "Long", paramType = "query", required = true) + }) + public ResultData detail(@RequestParam("id") Long id) { + if(id == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + WxCouponOrderReservation reservation = wxCouponOrderReservationService.getById(id, getTenantInfo().getTenantId()); + if(reservation != null && !getMemberId().equals(reservation.getcUserId())){ + return new ResultData(ErrorCode.SYS_SERVER_ERROR); + } + return new ResultData(reservation); + } + + @ApiOperation(value = "") + @PostMapping("saveOrUpdate") + @ApiImplicitParams({ + }) + public ResultData saveOrUpdate(@RequestBody WxCouponOrderReservation reservation) { + + if(reservation.getId() == null){ + if(reservation.getStartDate() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"startDate is null"); + } + if(reservation.getEndDate() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"endDate is null"); + } + } + if(reservation.getCouponOrderId() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"couponOrderId is null"); + } + reservation.updateTenantInfo(getTenantInfo()); + reservation.setcUserId(getMemberId()); + return wxCouponOrderReservationService.saveOrUpdate(reservation); + } + + + @ApiOperation(value = "取消预约") + @PostMapping("cancelReservation") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "预约ID", dataType = "Long", paramType = "query", required = true) + }) + public ResultData cancelReservation(@RequestBody WxCouponOrderReservation reservation) { + if(reservation.getId() == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + WxCouponOrderReservation updReservation = new WxCouponOrderReservation(); + updReservation.updateTenantInfo(getTenantInfo()); + updReservation.setId(reservation.getId()); + updReservation.setStatus(EnumCouponOrderReservationStatus.reservation_user_cancellation.getCode()); + wxCouponOrderReservationService.saveOrUpdate(updReservation); + return new ResultData(); + } + + +} diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java index 3cbf12770..e0a549726 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java @@ -8,10 +8,7 @@ import com.iformall.domain.po.*; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; -import com.iformall.service.WxCouponOrderService; -import com.iformall.service.WxOrderService; -import com.iformall.service.WxProfitSharingOrderService; -import com.iformall.service.WxRefundOrderService; +import com.iformall.service.*; import com.iformall.service.order.entity.WxComposeChildOrderShare; import com.iformall.utils.DateUtils; import org.slf4j.Logger; @@ -37,6 +34,9 @@ public class CouponOrderExpiringSchedule { @Autowired private WxCouponOrderService wxCouponOrderService; + @Autowired + private WxCouponOrderReservationService wxCouponOrderReservationService; + @Autowired private WxRefundOrderService wxRefundOrderService; @@ -160,6 +160,9 @@ public class CouponOrderExpiringSchedule { updateRecord.updateTenantInfo(co); wxCouponOrderMapper.updateById(updateRecord); + //取消在线预约 + wxCouponOrderReservationService.cancelReservation(co,EnumCouponOrderReservationStatus.reservation_expire_cancellation); + // 库存退回 if(bStockBack) { WxOrder order = wxOrderMapper.selectById(co.getOrderId(),co.getTenantId()); diff --git a/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java b/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java index 36b3b4a6e..0faf49d7c 100644 --- a/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java +++ b/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java @@ -193,6 +193,13 @@ public class BaseMyBatisConfiguration { wxCouponOrderSharding.setCount(100); wxCouponOrderSharding.setRule(EnumShardingRule.HASH.getCode()); shardingList.add(wxCouponOrderSharding); + + ShardingSphere wxCouponOrderReservationSharding = new ShardingSphere(); + wxCouponOrderReservationSharding.setColumn("tenant_id"); + wxCouponOrderReservationSharding.setTableName("wx_coupon_order_reservation"); + wxCouponOrderReservationSharding.setCount(100); + wxCouponOrderReservationSharding.setRule(EnumShardingRule.HASH.getCode()); + shardingList.add(wxCouponOrderReservationSharding); // ShardingSphere wxCouponSendSharding = new ShardingSphere(); // wxCouponSendSharding.setColumn("tenant_id"); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrderReservation.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrderReservation.java new file mode 100644 index 000000000..95ba7e52e --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrderReservation.java @@ -0,0 +1,86 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +@TableName(value = "wx_coupon_order_reservation") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxCouponOrderReservation extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value = "券码", name = "couponOrderId") + private Long couponOrderId; + + @io.swagger.annotations.ApiModelProperty(value = "卡券ID", name = "couponId") + private Long couponId; + @io.swagger.annotations.ApiModelProperty(value = "", name = "couponTitle") + private String couponTitle; + @io.swagger.annotations.ApiModelProperty(value = "c端用户id", name = "cUserId") + private Long cUserId; + @io.swagger.annotations.ApiModelProperty(value = "", name = "userName") + private String userName; + @io.swagger.annotations.ApiModelProperty(value = "", name = "userPhone") + private String userPhone; + @io.swagger.annotations.ApiModelProperty(value = "", name = "userRegion") + private String userRegion; + @io.swagger.annotations.ApiModelProperty(value = "", name = "userAddress") + private String userAddress; + @io.swagger.annotations.ApiModelProperty(value = "", name = "startDate") + private Date startDate; + @io.swagger.annotations.ApiModelProperty(value = "", name = "endDate") + private Date endDate; + @io.swagger.annotations.ApiModelProperty(value = "描述", name = "describe") + private String describe; + @io.swagger.annotations.ApiModelProperty(value = "描述", name = "describeImg") + private String describeImg; + @io.swagger.annotations.ApiModelProperty(value = "EnumCouponOrderReservationStatus", name = "status") + private Integer status; + @io.swagger.annotations.ApiModelProperty(value = "", name = "remark") + private String remark; + + + @io.swagger.annotations.ApiModelProperty(value = "", name = "finishTime") + private Date finishTime; + @io.swagger.annotations.ApiModelProperty(value = "", name = "btenantId") + private String btenantId; + @io.swagger.annotations.ApiModelProperty(value = "", name = "merchantId") + private Long merchantId; + @io.swagger.annotations.ApiModelProperty(value = "", name = "buserId") + private Long buserId; + @io.swagger.annotations.ApiModelProperty(value = "", name = "buserName") + private String buserName; + @io.swagger.annotations.ApiModelProperty(value = "", name = "buserPhone") + private String buserPhone; + + @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") + private Date updateDate; + + + public Long getcUserId() { + return cUserId; + } + + public void setcUserId(Long cUserId) { + this.cUserId = cUserId; + } + + + public Long getCUserId() { + return cUserId; + } + + public void setCUserId(Long cUserId) { + this.cUserId = cUserId; + } + +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderReservationStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderReservationStatus.java new file mode 100644 index 000000000..a1e68529c --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderReservationStatus.java @@ -0,0 +1,45 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumCouponOrderReservationStatus { + + // 0-可投放;1-已作废; + reservation(0, "预约"), + reservation_user_cancellation(1, "用户取消"), + reservation_expire_cancellation(2, "过期取消"), + reservation_refund_cancellation(3, "退款取消"), + reservation_refuse_cancellation(4, "拒绝服务"), + reservation_dispatch(5, "已派单"), + reservation_refuse_dispatch(6, "派单被拒绝"), + reservation_accept_cancellation(7, "派单已接受"), + reservation_finish_cancellation(8, "服务已完成"), + reservation_evaluate_cancellation(9, "服务已评价"), + ; + + public static EnumCouponOrderReservationStatus getEnum(Integer code) { + for (EnumCouponOrderReservationStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponOrderReservationStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderReservationMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderReservationMapper.java new file mode 100644 index 000000000..a0d6cafd9 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderReservationMapper.java @@ -0,0 +1,29 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.dto.MarkingCouponDataReportDto; +import com.iformall.domain.po.WxCouponOrder; +import com.iformall.domain.po.WxCouponOrderReservation; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.*; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface WxCouponOrderReservationMapper extends CommonMapper { + + WxCouponOrderReservation selectById(@Param("id")Long id,@Param("tenantId")String tenantId); + + List findList(WxCouponOrderReservation wxCouponOrderReservation); + + void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); + + WxCouponOrderReservation findUserReservation(WxCouponOrderReservation reservation); + + Long getIdByCouponOrder(@Param("couponOrderId")Long couponOrderId,@Param("tenantId") String tenantId); + + WxCouponOrderReservation getSortByCouponOrder(@Param("couponOrderId")Long couponOrderId,@Param("tenantId") String tenantId); +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderReservationService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderReservationService.java new file mode 100644 index 000000000..a74affdfc --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderReservationService.java @@ -0,0 +1,53 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.domain.po.*; +import com.iformall.enums.EnumCouponOrderReservationStatus; + +public interface WxCouponOrderReservationService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(WxCouponOrderReservation record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxCouponOrderReservation getById(Long id,String tenantId); + + /** + * 保存或更新实体 + * + * @param record + */ + ResultData saveOrUpdate(WxCouponOrderReservation record); + +// WxCouponOrderReservation findOne(WxCouponOrderReservation reservation); + + WxCouponOrderReservation findUserReservation(WxCouponOrderReservation reservation); + + void finishReservation(WxCouponOrder couponOrder); + + void cancelReservation(WxCouponOrder co, EnumCouponOrderReservationStatus enumReservationStatus); + + + /** + * 根据Id删除实体 + * + * @param id + */ + //void deleteById(Long id); + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderReservationServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderReservationServiceImpl.java new file mode 100644 index 000000000..888025307 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderReservationServiceImpl.java @@ -0,0 +1,166 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.common.*; +import com.iformall.domain.po.*; +import com.iformall.enums.*; +import com.iformall.mapper.*; +import com.iformall.service.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.*; + +@Service +public class WxCouponOrderReservationServiceImpl implements WxCouponOrderReservationService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxCouponOrderReservationMapper wxCouponOrderReservationMapper; + + @Autowired + WxCouponOrderMapper wxCouponOrderMapper; + + @Autowired + WxCouponMapper wxCouponMapper; + + @Autowired + WxCUserBasicInfoMapper wxCUserBasicInfoMapper; + + @Autowired + WxMerchantBUserMapper wxMerchantBUserMapper; + + @Override + public PageInfo listAsPage(WxCouponOrderReservation record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderReservationMapper.findList(record)); + } + + @Override + public WxCouponOrderReservation getById(Long id,String tenantId) { + return wxCouponOrderReservationMapper.selectById(id,tenantId); + } + + @Override + public ResultData saveOrUpdate(WxCouponOrderReservation record) { + if(record.getCouponOrderId() != null){ + WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(record.getCouponOrderId(), record.getTenantId()); + if(couponOrder == null){ + return new ResultData(ErrorCode.ORDER_IS_NOT_FIND.getCode(),"未找到该订单"); + } + if(!EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode().equals(couponOrder.getCouponOrderStatus())){ + return new ResultData(ErrorCode.COUPON_ORDER_IS_USED.getCode(),"券订单状态不支持"); + } + record.setCouponId(couponOrder.getCouponId()); + + WxCoupon wxCoupon = wxCouponMapper.selectById(record.getCouponId(), record.getTenantId()); + if(wxCoupon == null){ + return new ResultData(ErrorCode.COUPON_IS_EMPTY); + } + if(!EnumCouponType.COUPON_DOUYIN_GO_HOME.getCode().equals(wxCoupon.getType())){ + return new ResultData(ErrorCode.COUPON_VALID_NOT_SUPPORTED); + } + if(record.getStartDate() != null && wxCoupon.getValidStartDate() != null + && record.getStartDate().before(wxCoupon.getValidStartDate())){ + return new ResultData(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED.getCode(),"当前时间无法预约"); + } + if(record.getEndDate() != null && record.getEndDate().after(couponOrder.getExpiredTime())){ + return new ResultData(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED.getCode(),"当前时间无法预约"); + } + record.setCouponTitle(wxCoupon.getTitle()); + } + if(record.getcUserId() != null){ + WxCUserBasicInfo basicInfo = wxCUserBasicInfoMapper.selectById(record.getcUserId(), record.getFinalTenantId()); + if(basicInfo == null){ + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + record.setUserName(basicInfo.getName()); + record.setUserPhone(basicInfo.getPhone()); + } + if(record.getBuserId() != null){ + WxMerchantBUser bUser = wxMerchantBUserMapper.selectById(record.getBuserId()); + if(bUser == null){ + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + record.setBtenantId(bUser.getTenantId()); + record.setMerchantId(bUser.getMerchantId()); + record.setBuserName(bUser.getName()); + record.setBuserPhone(bUser.getPhone()); + } + + Date now = new Date(); + if(record.getId() == null && record.getCouponOrderId() != null){ + Long id = wxCouponOrderReservationMapper.getIdByCouponOrder(record.getCouponOrderId(),record.getTenantId()); + record.setId(id); + } + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + record.setCreateDate(now); + record.setUpdateDate(now); + wxCouponOrderReservationMapper.insert(record); + } else { + record.setUpdateDate(now); + wxCouponOrderReservationMapper.updateById(record); + } + return new ResultData(); + } + +// @Override +// public WxCouponOrderReservation findOne(WxCouponOrderReservation reservation) { +// return null; +// } + + @Override + public WxCouponOrderReservation findUserReservation(WxCouponOrderReservation reservation) { + return wxCouponOrderReservationMapper.findUserReservation(reservation); + } + + @Override + public void finishReservation(WxCouponOrder couponOrder) { + if(!EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().equals(couponOrder.getCouponOrderStatus())){ + return; + } + Long id = wxCouponOrderReservationMapper.getIdByCouponOrder(couponOrder.getId(), couponOrder.getTenantId()); + if(id == null){ + return; + } + WxCouponOrderReservation updReservation = new WxCouponOrderReservation(); + updReservation.setId(id); + updReservation.updateTenantInfo(couponOrder); + updReservation.setStatus(EnumCouponOrderReservationStatus.reservation_finish_cancellation.getCode()); + if(couponOrder.getBUserId() != null && couponOrder.getBMerchantId() != 0){ + updReservation.setBuserId(couponOrder.getBMerchantId()); + } + updReservation.setFinishTime(couponOrder.getUpdateDate()); + this.saveOrUpdate(updReservation); + } + + @Override + public void cancelReservation(WxCouponOrder couponOrder, EnumCouponOrderReservationStatus enumReservationStatus) { + WxCouponOrderReservation reservation = wxCouponOrderReservationMapper.getSortByCouponOrder(couponOrder.getId(), couponOrder.getTenantId()); + if(reservation == null){ + return; + } + //预约状态下取消 + if(!EnumCouponOrderReservationStatus.reservation.getCode().equals(reservation.getStatus())){ + return; + } + WxCouponOrderReservation updReservation = new WxCouponOrderReservation(); + updReservation.setId(reservation.getId()); + updReservation.updateTenantInfo(couponOrder); + updReservation.setStatus(enumReservationStatus.getCode()); + this.saveOrUpdate(updReservation); + } + + + +// @Override +// public void deleteById(Long id) { +// wxCouponOrderMapper.deleteById(id); +// } + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 7f86405c3..5b82a28f7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -188,6 +188,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { @Lazy @Autowired WxMerchantBUserService wxMerchantBUserService; + + @Lazy + @Autowired + WxCouponOrderReservationService wxCouponOrderReservationService; @Autowired @@ -1764,6 +1768,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { @Override public void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant) { + //完成预约 + try{ + wxCouponOrderReservationService.finishReservation(couponOrder); + }catch(Exception e){ + logger.error("完成预约失败"+e.getMessage(),e); + } try { boolean mulityShare = true; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java index 947906f92..b647491e5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java @@ -111,6 +111,9 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { @Autowired WxCashOutService wxCashOutService; + @Autowired + WxCouponOrderReservationService wxCouponOrderReservationService; + @Autowired private MqBaseProducer mqBaseProducer; @@ -315,6 +318,12 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); } + try{ + wxCouponOrderReservationService.cancelReservation(wxCouponOrder,EnumCouponOrderReservationStatus.reservation_refund_cancellation); + }catch(Exception e){ + logger.error("couponOrder- cancelReservation" + wxCouponOrder.getId() + ", e:" + e.getMessage()); + } + // 卡退款,把卡余额设为0 if (wxCouponOrder.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { WxCardInfo updateCardInfo = new WxCardInfo(); @@ -957,6 +966,12 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); } + try{ + wxCouponOrderReservationService.cancelReservation(wxCouponOrder,EnumCouponOrderReservationStatus.reservation_refund_cancellation); + }catch(Exception e){ + logger.error("couponOrder- cancelReservation" + wxCouponOrder.getId() + ", e:" + e.getMessage()); + } + // 卡退款,把卡余额设为0 if (wxCouponOrder.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { WxCardInfo updateCardInfo = new WxCardInfo(); diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderReservationMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderReservationMapper.xml new file mode 100644 index 000000000..5fb3a3cfe --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderReservationMapper.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`coupon_order_id`,`coupon_id`,`coupon_title`, + `c_user_id`,`user_name`,`user_phone`,`user_region`,`user_address`, + `start_date`,`end_date`,`describe`,`describe_img`,`status`,`remark`, + `btenant_id`,`merchant_id`,`buser_id`,`buser_name`,`buser_phone`,`finish_time`, + `create_date`,`update_date` + + + + where is_del = 0 + + and `id` = #{id} + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `coupon_order_id` = #{couponOrderId} + + + + and `coupon_id` = #{couponId} + + + + and `coupon_title` like concat('%', #{couponTitle},'%') + + + + and `c_user_id` = #{cUserId} + + + + and `user_name` like concat('%', #{userName},'%') + + + + and `user_phone` like concat('%', #{userPhone},'%') + + + + and `status` = #{status} + + + + and `btenant_id` = #{btenantId} + + + + and `buser_id` = #{buserId} + + + + and `buser_name` like concat('%', #{buserName},'%') + + + + and `buser_phone` like concat('%', #{buserPhone},'%') + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + update wx_coupon set is_del = 1,update_date=now() where id = #{id} and tenant_id = #{tenantId} + + + + + + + + + + + \ No newline at end of file