diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java new file mode 100644 index 000000000..d0466e968 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java @@ -0,0 +1,140 @@ +package com.iformall.controller.market; + +import com.github.pagehelper.PageInfo; +import com.iformall.annotation.SystemControllerLog; +import com.iformall.common.ErrorCode; +import com.iformall.common.Result; +import com.iformall.common.ResultData; +import com.iformall.controller.base.BaseController; +import com.iformall.domain.po.AliBusinessCircleOrder; +import com.iformall.domain.po.WxBusinessCircleOrder; +import com.iformall.domain.po.WxCoupon; +import com.iformall.domain.po.WxPressBatch; +import com.iformall.domain.po.WxPressBatchItem; +import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumCouponContentType; +import com.iformall.enums.EnumCouponSourceType; +import com.iformall.enums.EnumRentContractAppStatus; +import com.iformall.service.AliBusinessCircleOrderService; +import com.iformall.service.WxPressBatchService; +import com.iformall.utils.Constant; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("pressBatch") +public class WxPressBatchController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxPressBatchService wxPressBatchService; + + @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 WxPressBatch record, Integer pageNum, Integer pageSize) { + if (null == record) { + record = new WxPressBatch(); + } + record.updateTenantInfo(getTenantInfo()); + record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); + final PageInfo page = wxPressBatchService.listAsPage(record, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增&修改接口") + @PostMapping("saveOrUpdate") + public ResultData saveOrUpdate(@RequestBody WxPressBatch record) { + TenantEntity tenantEntity = getTenantInfo(); + record.updateTenantInfo(tenantEntity); + wxPressBatchService.saveOrUpdate(record); + return new ResultData(); + } + + @ApiOperation("详情接口") + @GetMapping("detail") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) + public ResultData detail(Long id) { + if (null == id) { + return new ResultData(Result.ERROR,"参数错误"); + } + WxPressBatch order = wxPressBatchService.getById(id, getTenantInfo().getTenantId()); + return new ResultData(order); + } + + @ApiOperation("详情接口") + @GetMapping("itemList") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) + public ResultData itemList(Long id) { + if (null == id) { + return new ResultData(Result.ERROR,"参数错误"); + } + List list = wxPressBatchService.getItemList(id, getTenantInfo().getTenantId()); + return new ResultData(list); + } + + @ApiOperation("详情接口") + @PostMapping("delete") + public ResultData delete(@RequestBody WxPressBatch record) { + if (null == record.getId()) { + return new ResultData(Result.ERROR,"参数错误"); + } + wxPressBatchService.deleteBatch(record.getId(), getTenantInfo().getTenantId()); + return new ResultData(); + } + + + @ApiOperation("新增items") + @PostMapping("addItems") + public ResultData addItems(@RequestBody WxPressBatch record) { + TenantEntity tenantEntity = getTenantInfo(); + record.updateTenantInfo(tenantEntity); + if (null == record.getId()) { + return new ResultData(Result.ERROR,"参数错误"); + } + String cidstr = record.getCouponChannelIds(); + if (StringUtils.isBlank(cidstr)) { + return new ResultData(Result.ERROR,"参数错误"); + } + String[] cids = cidstr.split(","); + WxPressBatch order = wxPressBatchService.getById(record.getId(), tenantEntity.getTenantId()); + wxPressBatchService.saveItems(order, cids); + return new ResultData(); + } + + @ApiOperation("详情接口") + @PostMapping("deleteItem") + public ResultData deleteItem(@RequestBody WxPressBatchItem record) { + if (null == record.getId()) { + return new ResultData(Result.ERROR,"参数错误"); + } + wxPressBatchService.deleteItemById(record.getId(), getTenantInfo().getTenantId()); + return new ResultData(); + } + + + +} diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022090100001_press_batch.sql b/mallinkAdmin/src/main/resources/db/migration/V2022090100001_press_batch.sql new file mode 100644 index 000000000..af92a9efb --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V2022090100001_press_batch.sql @@ -0,0 +1,25 @@ +CREATE TABLE `wx_press_batch` ( + `id` bigint(20) unsigned NOT NULL, + `tenant_id` varchar(5) NOT NULL, + `parent_tenant_id` varchar(5) DEFAULT NULL, + `name` varchar(100) DEFAULT NULL COMMENT '批次名称', + `status` int(1) NOT NULL DEFAULT '0' COMMENT '状态0-草稿 1-进行中 2-已停止', + `create_date` datetime DEFAULT NULL, + `update_date` datetime DEFAULT NULL, + `promoter_allow_count` int(3) NOT NULL DEFAULT '0' COMMENT '发起人允许发起次数', + `bargainer_allow_same` int(1) NOT NULL DEFAULT '0' COMMENT '同一个用户是否可以砍相同商品', + `bargainer_allow_count` int(3) NOT NULL DEFAULT '0' COMMENT '同一个用户可砍价次数', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE `wx_press_batch_item` ( + `id` bigint(20) unsigned NOT NULL, + `tenant_id` varchar(5) NOT NULL, + `parent_tenant_id` varchar(5) DEFAULT NULL, + `press_batch_id` bigint(20) NOT NULL COMMENT '批次id', + `coupon_channel_id` bigint(20) NOT NULL COMMENT '砍价券id', + `press_batch_status` int(1) NOT NULL COMMENT '批次状态', + `create_date` datetime DEFAULT NULL, + `update_date` datetime DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java index 009f3d7b3..d6d3d95e4 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java @@ -86,8 +86,8 @@ public class CouponOrderExpiringSchedule { } - //@Scheduled(cron = "0 0 5 * * ?") // 每天凌晨00:05 - @Scheduled(cron = "0 */10 * * * ?") // 测试10秒中一次 + @Scheduled(cron = "0 0 5 * * ?") // 每天凌晨00:05 + //@Scheduled(cron = "0 */10 * * * ?") // 测试10秒中一次 public void couponOrderRefundSchedule() { CouponOrderExpiringSchedule proxy = (CouponOrderExpiringSchedule) AopContext.currentProxy(); List malls = getMalls(); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPressBatch.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPressBatch.java new file mode 100644 index 000000000..585f853de --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPressBatch.java @@ -0,0 +1,39 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +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_press_batch") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxPressBatch extends TenantEntity { + + private static final long serialVersionUID = 6722507735075416305L; + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="批次名称",name="name") + private String name; + @io.swagger.annotations.ApiModelProperty(value="EnumPressBatchStatus",name="status") + private Integer status; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + @io.swagger.annotations.ApiModelProperty(value="发起人允许发起次数",name="promoterAllowCount") + private Integer promoterAllowCount; + @io.swagger.annotations.ApiModelProperty(value="同一个用户是否可以砍相同商品",name="bargainerAllowSame") + private Integer bargainerAllowSame; + @io.swagger.annotations.ApiModelProperty(value="同一个用户可砍价次数",name="bargainerAllowCount") + private Integer bargainerAllowCount; + + @TableField(exist = false) + private String couponChannelIds; + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPressBatchItem.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPressBatchItem.java new file mode 100644 index 000000000..70eb7ca7c --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPressBatchItem.java @@ -0,0 +1,30 @@ +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_press_batch_item") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class WxPressBatchItem extends TenantEntity { + + private static final long serialVersionUID = 6722507735075416305L; + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="批次id",name="pressBatchId") + private Long pressBatchId; + @io.swagger.annotations.ApiModelProperty(value="砍价券id",name="couponChannelId") + private Long couponChannelId; + @io.swagger.annotations.ApiModelProperty(value="EnumPressBatchStatus",name="pressBatchStatus") + private Integer pressBatchStatus; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumPressBatchStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumPressBatchStatus.java new file mode 100644 index 000000000..35a3d3d1e --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumPressBatchStatus.java @@ -0,0 +1,37 @@ +package com.iformall.enums; + + +/** + * @author gongbiao + */ +public enum EnumPressBatchStatus { + + DRAFT(0, "草稿"), + RUNNING(1, "进行中"), + STOPED(2, "已停止"); + + public static EnumPressBatchStatus getEnum(Integer code) { + for (EnumPressBatchStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumPressBatchStatus(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/WxPressBatchItemMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxPressBatchItemMapper.java new file mode 100644 index 000000000..185461cec --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxPressBatchItemMapper.java @@ -0,0 +1,21 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxPressBatchItem; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +public interface WxPressBatchItemMapper extends CommonMapper { + + List findList(WxPressBatchItem record); + + WxPressBatchItem getById(@Param("id")Long id,@Param("tenantId")String tenantId); + + void updateWxPressBatchStatus(WxPressBatchItem record); + + void deleteItem(WxPressBatchItem record); + + void deleteAllItem(WxPressBatchItem record); +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxPressBatchMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxPressBatchMapper.java new file mode 100644 index 000000000..5dff9197e --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxPressBatchMapper.java @@ -0,0 +1,19 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxPressBatch; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +public interface WxPressBatchMapper extends CommonMapper { + + List findList(WxPressBatch record); + + WxPressBatch getById(@Param("id")Long id,@Param("tenantId")String tenantId); + + void updateWxPressBatchStatus(WxPressBatch record); + + void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxPressBatchService.java b/mallinkService/src/main/java/com/iformall/service/WxPressBatchService.java new file mode 100644 index 000000000..27125fb18 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxPressBatchService.java @@ -0,0 +1,48 @@ +package com.iformall.service; + +import java.util.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.TtCouponChannelPoi; +import com.iformall.domain.po.WxAppinfo; +import com.iformall.domain.po.WxCoupon; +import com.iformall.domain.po.WxPressBatch; +import com.iformall.domain.po.WxPressBatchItem; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.TtCouponVo; +import com.iformall.domain.vo.WxCouponCVo; +import com.iformall.domain.vo.WxCouponStatisVo; +import com.iformall.domain.vo.WxMerchantVo; + +public interface WxPressBatchService { + + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(WxPressBatch record, Integer pageIndex, Integer pageSize); + + List list(WxPressBatch wxCoupon); + + void saveOrUpdate(WxPressBatch wxCoupon); + + WxPressBatch getById(Long id,String tenantId); + + List getItemList(Long batchId,String tenantId); + + void saveItems(WxPressBatch pressBatch,String[] couponChannelIds); + + void deleteBatch(Long id,String tenantId); + void deleteItemById(Long itemId,String tenantId); + void deleteItemByBatchId(Long batchId,String tenantId); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPressBatchServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPressBatchServiceImpl.java new file mode 100644 index 000000000..81250c5d3 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPressBatchServiceImpl.java @@ -0,0 +1,106 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.*; +import com.iformall.domain.po.base.TenantEntity; +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 org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +@Service +public class WxPressBatchServiceImpl implements WxPressBatchService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxPressBatchMapper wxPressBatchMapper; + @Autowired + WxPressBatchItemMapper wxPressBatchItemMapper; + + + @Override + public List list(WxPressBatch record){ + return wxPressBatchMapper.findList(record); + } + + @Override + public PageInfo listAsPage(WxPressBatch record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPressBatchMapper.findList(record)); + } + + @Override + public void saveOrUpdate(WxPressBatch record) { + if (null == record.getId()) { + record.setCreateDate(new Date()); + record.setUpdateDate(new Date()); + wxPressBatchMapper.insert(record); + }else { + record.setUpdateDate(new Date()); + wxPressBatchMapper.updateById(record); + } + } + + @Override + public WxPressBatch getById(Long id,String tenantId) { + return wxPressBatchMapper.getById(id, tenantId); + } + + @Override + public List getItemList(Long batchId, String tenantId) { + WxPressBatchItem iteq = new WxPressBatchItem(); + iteq.setTenantId(tenantId); + iteq.setPressBatchId(batchId); + return wxPressBatchItemMapper.findList(iteq); + } + + @Override + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void saveItems(WxPressBatch pressBatch, String[] couponChannelIds) { + for (String cid : couponChannelIds) { + WxPressBatchItem iteq = new WxPressBatchItem(); + iteq.updateTenantInfo(pressBatch); + iteq.setPressBatchId(pressBatch.getId()); + iteq.setCouponChannelId(Long.parseLong(cid)); + iteq.setPressBatchStatus(pressBatch.getStatus()); + iteq.setCreateDate(new Date()); + iteq.setUpdateDate(new Date()); + wxPressBatchItemMapper.insert(iteq); + } + } + + @Override + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void deleteBatch(Long id, String tenantId) { + wxPressBatchMapper.deleteById(id, tenantId); + deleteItemByBatchId(id, tenantId); + } + + @Override + public void deleteItemById(Long itemId, String tenantId) { + WxPressBatchItem iteq = new WxPressBatchItem(); + iteq.setTenantId(tenantId); + iteq.setId(itemId); + wxPressBatchItemMapper.deleteItem(iteq); + } + + @Override + public void deleteItemByBatchId(Long batchId, String tenantId) { + WxPressBatchItem iteq = new WxPressBatchItem(); + iteq.setTenantId(tenantId); + iteq.setPressBatchId(batchId); + wxPressBatchItemMapper.deleteAllItem(iteq); + } + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/WxPressBatchItemMapper.xml b/mallinkService/src/main/resources/mapper/WxPressBatchItemMapper.xml new file mode 100644 index 000000000..9d0df69dc --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxPressBatchItemMapper.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + `id`, `tenant_id`, `parent_tenant_id`, `press_batch_id`, `coupon_channel_id`, `create_date`,`update_date`,`press_batch_status` + + + + where `tenant_id` = #{tenantId} + + + and `id` = #{id} + + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `press_batch_id` = #{pressBatchId} + + + + and `coupon_channel_id` = #{couponChannelId} + + + + and `press_batch_status` = #{pressBatchStatus} + + + + and `id` in + + #{idItem} + + + + + + + + + + + update wx_press_batch_item set press_batch_status = #{status} where `press_batch_id` = #{pressBatchId} and tenant_id=#{tenantId} + + + + delete from wx_press_batch_item where `id` = #{id} and tenant_id=#{tenantId} and `press_batch_id` = #{pressBatchId} + + + + delete from wx_press_batch_item where `press_batch_id` = #{pressBatchId} and tenant_id=#{tenantId} + + + diff --git a/mallinkService/src/main/resources/mapper/WxPressBatchMapper.xml b/mallinkService/src/main/resources/mapper/WxPressBatchMapper.xml new file mode 100644 index 000000000..37587714c --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxPressBatchMapper.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + `id`, `tenant_id`, `parent_tenant_id`, `name`, `status`, `create_date`,`update_date`,`promoter_allow_count`, `bargainer_allow_same`, `bargainer_allow_count` + + + + where `tenant_id` = #{tenantId} + + + and `id` = #{id} + + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `status` = #{status} + + + + and `bargainer_allow_same` = #{bargainerAllowSame} + + + + and `id` in + + #{idItem} + + + + + + + + + + + update wx_press_batch set status = #{status} where `id` = #{id} and tenant_id=#{tenantId} + + + + delete from wx_press_batch where `id` = #{id} and tenant_id=#{tenantId} + +