| @@ -1,6 +1,6 @@ | |||
| alter table wx_coupon_password add column price int(11) not null default 0 comment '面额'; | |||
| update wx_coupon_password cp inner join wx_coupon_89 c on cp.coupon_id = c.id set cp.price = c.price where cp.price = 0 and c.price > 0 ; | |||
| ###已上线已执行### | |||
| #alter table wx_coupon_password add column price int(11) not null default 0 comment '面额'; | |||
| #update wx_coupon_password cp inner join wx_coupon_89 c on cp.coupon_id = c.id set cp.price = c.price where cp.price = 0 and c.price > 0 ; | |||
| @@ -0,0 +1,24 @@ | |||
| CREATE TABLE `wx_coupon_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, | |||
| `allow_count` int(3) NOT NULL DEFAULT '0' COMMENT '限购次数', | |||
| PRIMARY KEY (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| CREATE TABLE `wx_coupon_batch_item` ( | |||
| `id` bigint(20) unsigned NOT NULL, | |||
| `coupon_batch_id` bigint(20) NOT NULL COMMENT '批次id', | |||
| `coupon_id` bigint(20) NOT NULL COMMENT '砍价券id', | |||
| `coupon_batch_status` int(1) NOT NULL COMMENT '批次状态', | |||
| `create_date` datetime DEFAULT NULL, | |||
| `update_date` datetime DEFAULT NULL, | |||
| `tenant_id` varchar(5) NOT NULL, | |||
| `parent_tenant_id` varchar(5) DEFAULT NULL, | |||
| PRIMARY KEY (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| @@ -199,54 +199,50 @@ public class WxCardPayController extends BaseController { | |||
| } | |||
| // @ApiOperation("C端扫B端储值卡交易流水列表接口") | |||
| // @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 cardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend, Integer pageNum, Integer pageSize) { | |||
| // String ipStr = getIpAddr(); | |||
| // logger.info("list: " + ipStr + " :" + wxCardSpend.toString()); | |||
| // Long memberId; | |||
| // try { | |||
| // memberId = getMemberId(); | |||
| // } catch (Exception e) { | |||
| // return new ResultData(Result.ERROR,e.getMessage()); | |||
| // } | |||
| // return cardSpendList(wxCardSpend,memberId, pageNum, pageSize); | |||
| // } | |||
| // | |||
| // private ResultData cardSpendList(WxCardSpendVo wxCardSpend,Long cUserId,Integer pageNum, Integer pageSize) { | |||
| // if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); | |||
| // wxCardSpend.updateTenantInfo(getTenantInfo()); | |||
| // wxCardSpend.setOwnerId(cUserId); | |||
| // List<Integer> sources = new ArrayList<Integer>(); | |||
| // sources.add(EnumMerchantSubsidySource.CARD.getCode()); | |||
| // wxCardSpend.setSources(sources); | |||
| // wxCardSpend.setCardSpendListShow(1); | |||
| // final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpend, pageNum, pageSize); | |||
| // return new ResultData(page); | |||
| // } | |||
| // | |||
| // @ApiOperation("C端扫B端储值卡交易流水SUM接口") | |||
| // @GetMapping("sum") | |||
| // public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { | |||
| // String ipStr = getIpAddr(); | |||
| // logger.info("sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); | |||
| // Long memberId; | |||
| // try { | |||
| // memberId = getMemberId(); | |||
| // } catch (Exception e) { | |||
| // return new ResultData(Result.ERROR,e.getMessage()); | |||
| // } | |||
| // return sumCardSpendList(wxCardSpend,memberId); | |||
| // } | |||
| // | |||
| // private ResultData sumCardSpendList(WxCardSpendVo wxCardSpend,Long cUserId) { | |||
| // if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); | |||
| // wxCardSpend.updateTenantInfo(getTenantInfo()); | |||
| // wxCardSpend.setOwnerId(cUserId); | |||
| // final List<Map<String, Object>> mapList = wxCardSpendService.sumCardSpendForOwner(wxCardSpend); | |||
| // return new ResultData(mapList); | |||
| // } | |||
| @ApiOperation("C端扫B端储值卡交易流水列表接口") | |||
| @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 cardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("list: " + ipStr + " :" + wxCardSpend.toString()); | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| return cardSpendList(wxCardSpend,memberId, pageNum, pageSize); | |||
| } | |||
| private ResultData cardSpendList(WxCardSpendVo wxCardSpend,Long cUserId,Integer pageNum, Integer pageSize) { | |||
| if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); | |||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | |||
| wxCardSpend.setOwnerId(cUserId); | |||
| final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpend, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("C端扫B端储值卡交易流水SUM接口") | |||
| @GetMapping("sum") | |||
| public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| return sumCardSpendList(wxCardSpend,memberId); | |||
| } | |||
| private ResultData sumCardSpendList(WxCardSpendVo wxCardSpend,Long cUserId) { | |||
| if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); | |||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | |||
| wxCardSpend.setOwnerId(cUserId); | |||
| final Map<String, BigDecimal> mapList = wxCardSpendService.sumCardSpend(wxCardSpend); | |||
| return new ResultData(mapList); | |||
| } | |||
| } | |||
| @@ -0,0 +1,41 @@ | |||
| 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; | |||
| import java.util.List; | |||
| @TableName(value = "wx_coupon_batch") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCouponBatch extends TenantEntity { | |||
| private static final long serialVersionUID = 6722507735075416305L; | |||
| protected Long id; | |||
| @TableField(exist = false) | |||
| private List<Long> ids; | |||
| @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="allowCount") | |||
| private Integer allowCount; | |||
| @TableField(exist = false) | |||
| private String couponIds; | |||
| @TableField(exist = false) | |||
| private String couponName; | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| 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_coupon_batch_item") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCouponBatchItem extends TenantEntity { | |||
| private static final long serialVersionUID = 6722507735075416305L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="批次id",name="couponBatchId") | |||
| private Long couponBatchId; | |||
| @io.swagger.annotations.ApiModelProperty(value="砍价券id",name="couponId") | |||
| private Long couponId; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumPressBatchStatus",name="pressBatchStatus") | |||
| private Integer couponBatchStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private WxCoupon coupon; | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| package com.iformall.domain.vo; | |||
| import java.io.Serializable; | |||
| import java.text.DecimalFormat; | |||
| import java.util.List; | |||
| import com.iformall.domain.po.WxCouponBatch; | |||
| import com.iformall.domain.po.WxDateAmountRecord; | |||
| import com.iformall.domain.po.WxPressBatch; | |||
| import lombok.Data; | |||
| @Data | |||
| public class CouponBatchVo implements Serializable{ | |||
| private static final long serialVersionUID = 4494858079134918638L; | |||
| //核销金额记录 | |||
| private WxCouponBatch couponBatch; | |||
| private List<Long> couponIdList; | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCouponBatchItem; | |||
| import java.util.List; | |||
| import org.apache.ibatis.annotations.Param; | |||
| public interface WxCouponBatchItemMapper extends CommonMapper<WxCouponBatchItem, Long> { | |||
| List<WxCouponBatchItem> findList(WxCouponBatchItem record); | |||
| List<Long> getBatchIdList(@Param("couponIds")List<Long> couponIds,@Param("tenantId")String tenantId,@Param("pressBatchStatus")Integer pressBatchStatus); | |||
| WxCouponBatchItem getById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void updateWxPressBatchStatus(WxCouponBatchItem record); | |||
| void deleteItem(WxCouponBatchItem record); | |||
| void deleteAllItem(WxCouponBatchItem record); | |||
| List<Long> getCouponIds(@Param("pressBatchId")Long pressBatchId,@Param("tenantId")String tenantId,@Param("pressBatchStatus")Integer pressBatchStatus); | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCouponBatch; | |||
| import java.util.List; | |||
| import org.apache.ibatis.annotations.Param; | |||
| public interface WxCouponBatchMapper extends CommonMapper<WxCouponBatch, Long> { | |||
| List<WxCouponBatch> findList(WxCouponBatch record); | |||
| WxCouponBatch getById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void updateWxPressBatchStatus(WxCouponBatch record); | |||
| void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| } | |||
| @@ -0,0 +1,60 @@ | |||
| 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.WxCouponBatch; | |||
| import com.iformall.domain.po.WxCouponBatchItem; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.WxPressBatch; | |||
| import com.iformall.domain.po.WxPressBatchItem; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.CouponBatchVo; | |||
| import com.iformall.domain.vo.CouponPressBatchVo; | |||
| 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 WxCouponBatchService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxCouponBatch> listAsPage(WxCouponBatch record, Integer pageIndex, Integer pageSize); | |||
| List<WxCouponBatch> list(WxCouponBatch wxCoupon); | |||
| void saveOrUpdate(WxCouponBatch wxCoupon); | |||
| WxCouponBatch getById(Long id,String tenantId); | |||
| PageInfo<WxCouponBatchItem> getItemPage(Long batchId,String tenantId, Integer pageIndex, Integer pageSize); | |||
| List<WxCouponBatchItem> getItemList(Long batchId,String tenantId); | |||
| List<Long> getItemCouponIdList(Long batchId,String tenantId); | |||
| List<Long> getCouponIds(String tenantId); | |||
| void saveItems(WxCouponBatch pressBatch,List<Long> couponIds); | |||
| void deleteBatch(Long id,String tenantId); | |||
| void deleteItemById(Long itemId,String tenantId); | |||
| void deleteItemByBatchId(Long batchId,String tenantId); | |||
| void updateStatus(WxCouponBatch pressBatch); | |||
| CouponBatchVo getCouponPressBatch(WxCoupon coupon, Long cUserId); | |||
| } | |||
| @@ -0,0 +1,197 @@ | |||
| package com.iformall.service.impl; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.CouponBatchVo; | |||
| import com.iformall.domain.vo.CouponPressBatchVo; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.enums.EnumPressBatchStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.exception.MallinkException; | |||
| 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 WxCouponBatchServiceImpl implements WxCouponBatchService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxCouponBatchMapper wxCouponBatchMapper; | |||
| @Autowired | |||
| WxCouponBatchItemMapper wxCouponBatchItemMapper; | |||
| @Autowired | |||
| WxCouponOrderMapper wxCouponOrderMapper; | |||
| @Autowired | |||
| WxCouponMapper wxCouponMapper; | |||
| @Override | |||
| public List<WxCouponBatch> list(WxCouponBatch record){ | |||
| return wxCouponBatchMapper.findList(record); | |||
| } | |||
| @Override | |||
| public PageInfo<WxCouponBatch> listAsPage(WxCouponBatch record, Integer pageIndex, Integer pageSize) { | |||
| if (!StringUtils.isBlank(record.getCouponName())) { | |||
| WxCoupon cq = new WxCoupon(); | |||
| cq.updateTenantInfo(record); | |||
| cq.setTitle(StringUtils.trimToNull(record.getCouponName())); | |||
| List<Long> cids = wxCouponMapper.findIdList(cq); | |||
| if (null == cids || cids.size() <= 0 ) { | |||
| record.setId(0L); | |||
| }else { | |||
| List<Long> ids = wxCouponBatchItemMapper.getBatchIdList(cids, record.getTenantId(), record.getStatus()); | |||
| if (null == ids || ids.size() <= 0) { | |||
| record.setId(0L); | |||
| }else { | |||
| record.setIds(ids); | |||
| } | |||
| } | |||
| } | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponBatchMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxCouponBatch record) { | |||
| if (null == record.getId()) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| wxCouponBatchMapper.insert(record); | |||
| }else { | |||
| record.setUpdateDate(new Date()); | |||
| wxCouponBatchMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public WxCouponBatch getById(Long id,String tenantId) { | |||
| return wxCouponBatchMapper.getById(id, tenantId); | |||
| } | |||
| @Override | |||
| public PageInfo<WxCouponBatchItem> getItemPage(Long batchId,String tenantId, Integer pageIndex, Integer pageSize) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.setTenantId(tenantId); | |||
| iteq.setCouponBatchId(batchId); | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponBatchItemMapper.findList(iteq)); | |||
| } | |||
| @Override | |||
| public List<WxCouponBatchItem> getItemList(Long batchId, String tenantId) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.setTenantId(tenantId); | |||
| iteq.setCouponBatchId(batchId); | |||
| return wxCouponBatchItemMapper.findList(iteq); | |||
| } | |||
| @Override | |||
| public List<Long> getItemCouponIdList(Long batchId, String tenantId) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.setTenantId(tenantId); | |||
| iteq.setCouponBatchId(batchId); | |||
| return wxCouponBatchItemMapper.getCouponIds(batchId, tenantId, null); | |||
| } | |||
| @Override | |||
| public List<Long> getCouponIds(String tenantId) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.setTenantId(tenantId); | |||
| return wxCouponBatchItemMapper.getCouponIds(null, tenantId, null); | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void saveItems(WxCouponBatch pressBatch, List<Long> couponIds) { | |||
| for (Long cid : couponIds) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.updateTenantInfo(pressBatch); | |||
| iteq.setCouponBatchId(pressBatch.getId()); | |||
| iteq.setCouponId(cid); | |||
| iteq.setCouponBatchStatus(pressBatch.getStatus()); | |||
| iteq.setCreateDate(new Date()); | |||
| iteq.setUpdateDate(new Date()); | |||
| wxCouponBatchItemMapper.insert(iteq); | |||
| } | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void deleteBatch(Long id, String tenantId) { | |||
| wxCouponBatchMapper.deleteById(id, tenantId); | |||
| deleteItemByBatchId(id, tenantId); | |||
| } | |||
| @Override | |||
| public void deleteItemById(Long itemId, String tenantId) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.setTenantId(tenantId); | |||
| iteq.setId(itemId); | |||
| wxCouponBatchItemMapper.deleteItem(iteq); | |||
| } | |||
| @Override | |||
| public void deleteItemByBatchId(Long batchId, String tenantId) { | |||
| WxCouponBatchItem iteq = new WxCouponBatchItem(); | |||
| iteq.setTenantId(tenantId); | |||
| iteq.setCouponBatchId(batchId); | |||
| wxCouponBatchItemMapper.deleteAllItem(iteq); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void updateStatus(WxCouponBatch pressBatch) { | |||
| wxCouponBatchMapper.updateWxPressBatchStatus(pressBatch); | |||
| WxCouponBatchItem item = new WxCouponBatchItem(); | |||
| item.updateTenantInfo(pressBatch); | |||
| item.setCouponBatchId(pressBatch.getId()); | |||
| item.setCouponBatchStatus(pressBatch.getStatus()); | |||
| wxCouponBatchItemMapper.updateWxPressBatchStatus(item); | |||
| } | |||
| @Override | |||
| public CouponBatchVo getCouponPressBatch(WxCoupon coupon, Long cUserId) { | |||
| WxCouponBatchItem query = new WxCouponBatchItem(); | |||
| query.updateTenantInfo(coupon); | |||
| query.setCouponId(coupon.getId()); | |||
| query.setCouponBatchStatus(EnumPressBatchStatus.RUNNING.getCode()); | |||
| List<WxCouponBatchItem> batchList = wxCouponBatchItemMapper.findList(query); | |||
| //一个砍价商品只能存在一个有效的批次 | |||
| if (null != batchList && batchList.size() > 0 ) { | |||
| if (batchList.size() > 1) { | |||
| throw new MallinkException(Result.ERROR,"该券["+coupon.getTitle()+"]存在多个有效批次活动,请联系管理员重新设置."); | |||
| }else { | |||
| WxCouponBatchItem batchItem = batchList.get(0); | |||
| WxCouponBatch pressBatch = wxCouponBatchMapper.getById(batchItem.getCouponBatchId(), batchItem.getTenantId()); | |||
| //查询该批次下所有的砍价商品, | |||
| List<Long> batchCouponIds = wxCouponBatchItemMapper.getCouponIds(batchItem.getCouponBatchId(), batchItem.getTenantId(), EnumPressBatchStatus.RUNNING.getCode()); | |||
| if (null == batchCouponIds || batchCouponIds.size() <= 0 ) { | |||
| throw new MallinkException(Result.ERROR,"未查询到砍价["+coupon.getTitle()+"]有效批次活动记录,"); | |||
| } | |||
| CouponBatchVo vo = new CouponBatchVo(); | |||
| vo.setCouponBatch(pressBatch); | |||
| vo.setCouponIdList(batchCouponIds); | |||
| return vo; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -237,6 +237,11 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Autowired | |||
| WxPressBatchService wxPressBatchService; | |||
| @Lazy | |||
| @Autowired | |||
| WxCouponBatchService wxCouponBatchService; | |||
| @Override | |||
| public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | |||
| @@ -775,51 +780,13 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| // } | |||
| //如果是砍价,则需要判断批次规则 | |||
| if (isPressOrder) { | |||
| CouponPressBatchVo checkPressResult = wxPressBatchService.getCouponPressBatch(counpon, user.getId()); | |||
| if (null != checkPressResult) { | |||
| WxPressBatch pressBatch = checkPressResult.getPressBatch(); | |||
| List<Long> cids = checkPressResult.getCouponIdList(); | |||
| if (null != cids && cids.size() > 0 ) { | |||
| couponOrderQ.setCouponIds(cids); | |||
| //判断这些券发起中+已完成的 | |||
| WxOrder orderq = new WxOrder(); | |||
| orderq.updateTenantInfo(counpon); | |||
| orderq.setCouponIds(cids); | |||
| orderq.setCUserId(user.getId()); | |||
| //if (pressBatch.getPromoterLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| List<Integer> statusS = new ArrayList<Integer>(); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PRESSING.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PRESS_COMPLETE.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_REFUND_FAILD.getCode()); | |||
| orderq.setStatusS(statusS); | |||
| //} | |||
| int _count = wxOrderMapper.countCouponConditionType1(orderq); | |||
| if (_count >= pressBatch.getPromoterAllowCount()) { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"当前用户发起砍价次数已超限.["+pressBatch.getName()+"]"); | |||
| } | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| }else { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"砍价批次["+pressBatch.getName()+"]未设置券."); | |||
| } | |||
| }else { | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| } | |||
| checkPressBatchRule(counpon, couponOrderQ, user); | |||
| }else { | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| checkCouponBatchRule(counpon, couponOrderQ, user); | |||
| // if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| // couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| // } | |||
| // couponOrderQ.setCouponId(counpon.getId()); | |||
| } | |||
| return wxCouponOrderMapper.findProductCount(couponOrderQ)+couponNumber; | |||
| } catch(MallinkException e1) { | |||
| @@ -830,6 +797,88 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| } | |||
| private void checkPressBatchRule(WxCoupon counpon,WxCouponOrder couponOrderQ,WxCUserBasicInfo user) { | |||
| CouponPressBatchVo checkPressResult = wxPressBatchService.getCouponPressBatch(counpon, user.getId()); | |||
| if (null != checkPressResult) { | |||
| WxPressBatch pressBatch = checkPressResult.getPressBatch(); | |||
| List<Long> cids = checkPressResult.getCouponIdList(); | |||
| if (null != cids && cids.size() > 0 ) { | |||
| couponOrderQ.setCouponIds(cids); | |||
| //判断这些券发起中+已完成的 | |||
| WxOrder orderq = new WxOrder(); | |||
| orderq.updateTenantInfo(counpon); | |||
| orderq.setCouponIds(cids); | |||
| orderq.setCUserId(user.getId()); | |||
| //if (pressBatch.getPromoterLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| List<Integer> statusS = new ArrayList<Integer>(); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PRESSING.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PRESS_COMPLETE.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_REFUND_FAILD.getCode()); | |||
| orderq.setStatusS(statusS); | |||
| //} | |||
| int _count = wxOrderMapper.countCouponConditionType1(orderq); | |||
| if (_count >= pressBatch.getPromoterAllowCount()) { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"当前用户发起砍价次数已批次超限.["+pressBatch.getName()+"]"); | |||
| } | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| }else { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"砍价批次["+pressBatch.getName()+"]未设置券."); | |||
| } | |||
| }else { | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| } | |||
| } | |||
| private void checkCouponBatchRule(WxCoupon counpon,WxCouponOrder couponOrderQ,WxCUserBasicInfo user) { | |||
| CouponBatchVo checkPressResult = wxCouponBatchService.getCouponPressBatch(counpon, user.getId()); | |||
| if (null != checkPressResult) { | |||
| WxCouponBatch pressBatch = checkPressResult.getCouponBatch(); | |||
| List<Long> cids = checkPressResult.getCouponIdList(); | |||
| if (null != cids && cids.size() > 0 ) { | |||
| couponOrderQ.setCouponIds(cids); | |||
| //判断这些券发起中+已完成的 | |||
| WxOrder orderq = new WxOrder(); | |||
| orderq.updateTenantInfo(counpon); | |||
| orderq.setCouponIds(cids); | |||
| orderq.setCUserId(user.getId()); | |||
| List<Integer> statusS = new ArrayList<Integer>(); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_REFUND_FAILD.getCode()); | |||
| orderq.setStatusS(statusS); | |||
| int _count = wxOrderMapper.countCouponConditionType1(orderq); | |||
| if (_count >= pressBatch.getAllowCount()) { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"当前用户购买次数已批次超限.["+pressBatch.getName()+"]"); | |||
| } | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| }else { | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券批次["+pressBatch.getName()+"]未设置券."); | |||
| } | |||
| }else { | |||
| if (counpon.getUseLimitRule().equals(EnumCouponUseLimitRule.TOBEUSED_USELIMIT.getCode())) { | |||
| couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } | |||
| couponOrderQ.setCouponId(counpon.getId()); | |||
| } | |||
| } | |||
| /** | |||
| * 商户注券减库存 | |||
| @@ -0,0 +1,103 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxCouponBatchItemMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponBatchItem"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="coupon_batch_id" jdbcType="BIGINT" property="couponBatchId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="coupon_batch_status" jdbcType="INTEGER" property="couponBatchStatus"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `tenant_id`, `parent_tenant_id`, `coupon_batch_id`, `coupon_id`, `create_date`,`update_date`,`coupon_batch_status` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where `tenant_id` = #{tenantId} | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != pressBatchId"> | |||
| and `press_batch_id` = #{pressBatchId} | |||
| </if> | |||
| <if test=" null != couponId"> | |||
| and `coupon_id` = #{couponId} | |||
| </if> | |||
| <if test=" null != pressBatchStatus"> | |||
| and `press_batch_status` = #{pressBatchStatus} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and `id` in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponBatchItem" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_coupon_batch_item | |||
| <include refid="dynamicWhereConditions"/> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| <select id="getBatchIdList" parameterType="java.util.HashMap" resultType="Long"> | |||
| select distinct coupon_batch_id from wx_coupon_batch_item where `tenant_id` = #{tenantId} | |||
| <if test=" null != pressBatchStatus"> | |||
| and `coupon_batch_status` = #{couponBatchStatus} | |||
| </if> | |||
| <if test=" null != couponIds "> | |||
| and `coupon_id` in | |||
| <foreach collection="couponIds" index="index" item="cIdItem" open="(" separator="," close=")"> | |||
| #{cIdItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| <select id="getById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_coupon_batch_item | |||
| where `id` = #{id} | |||
| and tenant_id=#{tenantId} | |||
| </select> | |||
| <update id="updateWxPressBatchStatus" parameterType="com.iformall.domain.po.WxCouponBatchItem" > | |||
| update wx_coupon_batch_item set coupon_batch_status = #{couponBatchStatus} where `coupon_batch_id` = #{couponBatchId} and tenant_id=#{tenantId} | |||
| </update> | |||
| <delete id= "deleteItem" parameterType="com.iformall.domain.po.WxCouponBatchItem" > | |||
| delete from wx_coupon_batch_item where `id` = #{id} and tenant_id=#{tenantId} | |||
| </delete> | |||
| <delete id= "deleteAllItem" parameterType="com.iformall.domain.po.WxCouponBatchItem" > | |||
| delete from wx_coupon_batch_item where `coupon_batch_id` = #{couponBatchId} and tenant_id=#{tenantId} | |||
| </delete> | |||
| <select id="getCouponIds" parameterType="java.util.HashMap" resultType="Long"> | |||
| select coupon_id from wx_coupon_batch_item where tenant_id=#{tenantId} | |||
| <if test=" null != couponBatchId"> | |||
| and `coupon_batch_id` = #{couponBatchId} | |||
| </if> | |||
| <if test=" null != couponBatchStatus"> | |||
| and `coupon_batch_status` = #{couponBatchStatus} | |||
| </if> | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,67 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxCouponBatchMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponBatch"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="allow_count" jdbcType="INTEGER" property="allowCount"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `tenant_id`, `parent_tenant_id`, `name`, `status`, `create_date`,`update_date`,`allow_count` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where `tenant_id` = #{tenantId} | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != status"> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != name and '' != name"> | |||
| and `name` like concat('%', #{name},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and `id` in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponBatch" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_coupon_batch | |||
| <include refid="dynamicWhereConditions"/> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| <select id="getById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from wx_coupon_batch where `id` = #{id} and tenant_id=#{tenantId} | |||
| </select> | |||
| <update id="updateWxPressBatchStatus" parameterType="com.iformall.domain.po.WxCouponBatch" > | |||
| update wx_coupon_batch set status = #{status} where `id` = #{id} and tenant_id=#{tenantId} | |||
| </update> | |||
| <delete id="deleteById" parameterType="java.util.HashMap" > | |||
| delete from wx_coupon_batch where `id` = #{id} and tenant_id=#{tenantId} | |||
| </delete> | |||
| </mapper> | |||