Просмотр исходного кода

[需求][1000201]:定时发放会员停车券

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
6659afe6e6
17 измененных файлов: 352 добавлений и 71 удалений
  1. +4
    -3
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponSendController.java
  2. +17
    -16
      mallinkAdmin/src/main/java/com/iformall/controller/WxLevelConfigController.java
  3. +135
    -0
      mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java
  4. +0
    -11
      mallinkService/src/main/java/com/iformall/domain/po/WxCouponSend.java
  5. +23
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxLevelConfig.java
  6. +70
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxCouponSendVo.java
  7. +2
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumCouponSendSendType.java
  8. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java
  9. +2
    -2
      mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java
  10. +2
    -1
      mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java
  11. +7
    -0
      mallinkService/src/main/java/com/iformall/service/WxLevelConfigService.java
  12. +4
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java
  13. +32
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxLevelConfigServiceImpl.java
  14. +7
    -17
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  15. +22
    -0
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml
  16. +21
    -15
      mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml
  17. +2
    -1
      mallinkService/src/main/resources/mapper/WxLevelConfigMapper.xml

+ 4
- 3
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponSendController.java Просмотреть файл

@@ -6,6 +6,7 @@ import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponSend;
import com.iformall.domain.vo.WxCouponSendVo;
import com.iformall.enums.EnumCouponSendStatus;
import com.iformall.enums.EnumCouponSendType;
import com.iformall.enums.EnumCouponStatus;
@@ -46,9 +47,9 @@ public class WxCouponSendController extends BaseController {
wxCouponSend.setTenantId(getTenantId());
wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode());
wxCouponSend.setSortColumns(WxCouponSend.Field.CreateDate_DESC);
final PageInfo<WxCouponSend> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize);
final PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize);

for (WxCouponSend cs:page.getList())
for (WxCouponSendVo cs:page.getList())
cs.setSendCount(wxCouponActionLogService.getCountByChannelId(getTenantId(), cs.getSendType(), cs.getId()));

return new ResultData(page);
@@ -63,7 +64,7 @@ public class WxCouponSendController extends BaseController {
}
wxCouponSend.setTenantId(getTenantId());
wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode());
List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend, 1, 1).getList();
List<WxCouponSendVo> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend, 1, 1).getList();
if (wxCouponSendList != null && wxCouponSendList.size() > 0) {
return new ResultData(ErrorCode.COUPON_SEND_IS_EXISTED);
}


+ 17
- 16
mallinkAdmin/src/main/java/com/iformall/controller/WxLevelConfigController.java Просмотреть файл

@@ -51,8 +51,6 @@ public class WxLevelConfigController extends BaseController {
@PostMapping("add")
public ResultData add(@RequestBody List<WxLevelConfig> levelConfigs) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add");
//Assert.notNull(wxLevelConfig.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
String tenantId = getTenantId();
try {
wxLevelConfigService.batchSave(tenantId, levelConfigs);
@@ -63,31 +61,34 @@ public class WxLevelConfigController extends BaseController {
return new ResultData();
}

// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// public ResultData update(@RequestBody WxLevelConfig wxLevelConfig) {
// wxLevelConfig.setTenantId(getTenantId());
// wxLevelConfigService.saveOrUpdate(wxLevelConfig);
// return new ResultData();
// }
@ApiOperation("更改会员权益")
@PostMapping("updateCapabilities")
public ResultData updateCapabilities(@RequestBody List<WxLevelConfig> levelConfigs) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add");
String tenantId = getTenantId();
try {
wxLevelConfigService.batchUpdateCapabilities(tenantId, levelConfigs);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResultData(ErrorCode.DB_FAIL);
}
return new ResultData();
}

@ApiOperation("根据id删除接口")
@PostMapping("/del")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(@RequestBody WxLevelConfig wxLevelConfig) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::delete");
wxLevelConfigService.deleteById(wxLevelConfig.getId());
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxLevelConfigController::findById");
return new ResultData(Result.SUCCESS,"查询成功",wxLevelConfigService.getById(id));
}

}

+ 135
- 0
mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java Просмотреть файл

@@ -0,0 +1,135 @@
package com.iformall.schedule;

import com.alibaba.fastjson.JSONObject;
import com.iformall.domain.dto.WxCUserBasicInfoDto;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.WxCouponSendVo;
import com.iformall.enums.EnumCouponSendSendType;
import com.iformall.enums.EnumCouponSendStatus;
import com.iformall.mapper.*;
import com.iformall.service.WxCouponActionLogService;
import com.iformall.service.WxCouponSendService;
import com.iformall.service.WxLevelConfigService;
import com.iformall.service.WxOrderService;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class CouponSendSchedule {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxMallMapper wxMallMapper;

@Autowired
private WxLevelConfigMapper WxLevelConfigMapper;

@Autowired
private WxLevelConfigService wxLevelConfigService;

@Autowired
private WxCUserBasicInfoMapper wxCUserBasicInfoMapper;

@Autowired
private WxCouponSendMapper wxCouponSendMapper;

@Autowired
private WxOrderService wxOrderService;

@Autowired
private WxCouponActionLogService wxCouponActionLogService;


@Scheduled(cron = "0 0 6 1 * ?") // 每月1号发放会员的权益券
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
public void couponSendSchedule() {

List<WxMall> mallList = wxMallMapper.findList(new WxMall());

if (mallList.size()==0) {
logger.info("定时发券: No Mall info found");
return;
}

mallList.stream().forEach(mall-> {

WxLevelConfig wxLevelConfig = new WxLevelConfig();
wxLevelConfig.setTenantId(mall.getTenantId());
List<WxLevelConfig> levelConfigList = WxLevelConfigMapper.findList(wxLevelConfig);
levelConfigList = levelConfigList.stream()
.sorted(Comparator.comparing(WxLevelConfig::getPoints))
.collect(Collectors.toList());

for (int i = 0; i < levelConfigList.size(); i++) {
WxLevelConfig l = levelConfigList.get(i);
if (l.getCapability() == null)
continue;
Integer levelStartScore = l.getPoints();
Integer levelEndScore = levelConfigList.size() < i+1? levelConfigList.get(i+1).getPoints() : null;

JSONObject jo = null;
Long result = null;
try {
jo = JSONObject.parseObject(l.getCapability());
result = wxLevelConfigService.getCapabilitiesOfSendCarConpon(jo);
} catch (Exception e) {
logger.error("定时发券: 不能解析发券规则 levelId=" + l.getId() + e.getMessage());
continue;
}
Long sendCount = result;
if (sendCount > 0) {
WxCouponSend wxCouponSend = new WxCouponSend();
wxCouponSend.setTenantId(l.getTenantId());
wxCouponSend.setSendType(EnumCouponSendSendType.TIMED.getCode());
wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode());
List<WxCouponSendVo> couponSendList = wxCouponSendMapper.findListVo(wxCouponSend);
couponSendList.stream().forEach(cs->{
if (cs.getRemainInventory() < sendCount){
logger.error("定时发券:库存不足 levelId="+ l.getId() +"couponId="+ cs.getCouponId());
return; //下一个券
}
WxCUserBasicInfoDto wxCUserBasicInfoDto = new WxCUserBasicInfoDto();
wxCUserBasicInfoDto.setTenantId(l.getTenantId());
wxCUserBasicInfoDto.setLevelStartScore(levelStartScore);
wxCUserBasicInfoDto.setLevelEndScore(levelEndScore);
List<WxCUserBasicInfo> wxCUserBasicInfoList = wxCUserBasicInfoMapper.findListByScore(wxCUserBasicInfoDto);

wxCUserBasicInfoList.stream().forEach(cu->{
if (cs.getRemainInventory() < sendCount){
logger.error("定时发券:库存不足 levelId="+ l.getId() +"couponId="+ cs.getCouponId()+"userId="+cu.getId());
return; //下一个券
}

for (int count = 0; count<sendCount; count++) {
// 发放免费券
try {
WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs.getCouponId());
wxCouponActionLogService.addOne(l.getTenantId(), cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId());
} catch (Exception e) {
logger.error("定时发券:发券失败 levelId=" + l.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage());
return;
}

logger.info("定时发券:商场[" + mall.getName() +
"]会员等级[" + l.getLevel() +
"]发送券" + cs.getTitle() +
"]给[" + cu.getNickName() +
"] 电话:" + cu.getPhone() + "id:" + cu.getId());
}
});
});
}
}
});
}
}

+ 0
- 11
mallinkService/src/main/java/com/iformall/domain/po/WxCouponSend.java Просмотреть файл

@@ -68,9 +68,6 @@ public class WxCouponSend implements Serializable {
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
private Date updateDate;

/*发卷所属商户名**/
@Transient
private String merchantName;

/*场景发券计数**/
@Transient
@@ -131,14 +128,6 @@ public class WxCouponSend implements Serializable {
}


public String getMerchantName() {
return merchantName;
}

public void setMerchantName(String merchantName) {
this.merchantName = merchantName;
}

public int getSendCount() {
return sendCount;
}


+ 23
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxLevelConfig.java Просмотреть файл

@@ -55,6 +55,13 @@ public class WxLevelConfig implements Serializable {
/**创建时间**/
@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="capability")
private String capability;

/**是否启用,0:未启用,启用1,2,3,分别对应wx_merchant_discount里的rate_vip1, rate_vip2, rate_vip3**/
@io.swagger.annotations.ApiModelProperty(value="是否启用",name="discountEnable")
@@ -112,6 +119,22 @@ public class WxLevelConfig implements Serializable {
this.discountEnable = discountEnable;
}

public Date getUpdateDate() {
return updateDate;
}

public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}

public String getCapability() {
return capability;
}

public void setCapability(String capability) {
this.capability = capability;
}

public static enum Field
{
Id_ASC("`id` ASC"),Id_DESC("`id` DESC")


+ 70
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxCouponSendVo.java Просмотреть файл

@@ -0,0 +1,70 @@
package com.iformall.domain.vo;

import com.iformall.domain.po.WxCouponSend;
import com.iformall.domain.po.WxLevelConfig;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.po.WxTagsType;

import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class WxCouponSendVo extends WxCouponSend implements Serializable{

/*有效日期-开始**/
@io.swagger.annotations.ApiModelProperty(value="有效日期-开始",name="validStartDate")
private Date validStartDate;
/*有效日期-结束**/
@io.swagger.annotations.ApiModelProperty(value="有效日期-结束",name="validEndDate")
private Date validEndDate;
/*剩余库存**/
@io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory")
private Integer remainInventory;
/*总库存**/
@io.swagger.annotations.ApiModelProperty(value="总库存",name="inventory")
private Integer inventory;

/*发卷所属商户名**/
private String merchantName;

public Date getValidStartDate() {
return validStartDate;
}

public void setValidStartDate(Date validStartDate) {
this.validStartDate = validStartDate;
}

public Date getValidEndDate() {
return validEndDate;
}

public void setValidEndDate(Date validEndDate) {
this.validEndDate = validEndDate;
}

public Integer getRemainInventory() {
return remainInventory;
}

public void setRemainInventory(Integer remainInventory) {
this.remainInventory = remainInventory;
}

public Integer getInventory() {
return inventory;
}

public void setInventory(Integer inventory) {
this.inventory = inventory;
}

public String getMerchantName() {
return merchantName;
}

public void setMerchantName(String merchantName) {
this.merchantName = merchantName;
}
}

+ 2
- 1
mallinkService/src/main/java/com/iformall/enums/EnumCouponSendSendType.java Просмотреть файл

@@ -12,7 +12,8 @@ public enum EnumCouponSendSendType {
CAR_STOP(2, "停车发券"),
COUPON_VERIFY(3, "核销发券"),
B_MICROPAY(4, "B端刷卡发券"),
C_ORDER(5, "购买发券")
C_ORDER(5, "购买发券"),
TIMED(6, "定时发券"),
;

public static EnumCouponSendSendType getEnum(Integer code) {


+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java Просмотреть файл

@@ -22,6 +22,8 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S

long findCountByScore(WxCUserBasicInfoDto dto);

List<WxCUserBasicInfo> findListByScore(WxCUserBasicInfoDto dto);

long findCount(WxCUserBasicInfoDto dto);

List<WxCUserBasicInfoVo> findVoList(WxCUserBasicInfo wxCUserBasicInfo);


+ 2
- 2
mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java Просмотреть файл

@@ -3,14 +3,14 @@ package com.iformall.mapper;
import java.util.*;
import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxCouponSend;
import com.iformall.domain.vo.WxCouponSendVo;

public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> {

List<WxCouponSend> findList(WxCouponSend wxCouponSend);
List<WxCouponSendVo> findListVo(WxCouponSend wxCouponSend);

void updateStatusByCouponId(WxCouponSend wxCouponSend);

void offExpiriedCouponSendBySendEndTime();
void offExpiriedCouponSendByCouponStatus();
}

+ 2
- 1
mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java Просмотреть файл

@@ -2,6 +2,7 @@ package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxCouponSend;
import com.iformall.domain.vo.WxCouponSendVo;
import com.iformall.enums.EnumCouponSendSendType;

public interface WxCouponSendService {
@@ -14,7 +15,7 @@ public interface WxCouponSendService {
* @param pageSize
* @return
*/
PageInfo<WxCouponSend> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize);
PageInfo<WxCouponSendVo> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize);
/**
* 根据Id获得实体


+ 7
- 0
mallinkService/src/main/java/com/iformall/service/WxLevelConfigService.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.service;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxLevelConfig;

@@ -7,6 +8,7 @@ import java.util.List;

public interface WxLevelConfigService {

public final static String CAPABILITY_SEND_CAR_COUPON = "carCouponCount";
/**
* 根据实体查询分页列表
*
@@ -45,6 +47,11 @@ public interface WxLevelConfigService {
void batchSave(String tenantId, List<WxLevelConfig> records);


/**
* 批量更新
*/
void batchUpdateCapabilities(String tenantId, List<WxLevelConfig> records);
Long getCapabilitiesOfSendCarConpon(JSONObject jo);
/**
* 根据Id删除实体
*


+ 4
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java Просмотреть файл

@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.WxCouponSendVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxCouponOrderMapper;
@@ -44,8 +45,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {


@Override
public PageInfo<WxCouponSend> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findList(record));
public PageInfo<WxCouponSendVo> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVo(record));
}

@Override
@@ -160,7 +161,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
wxCouponSendQuery.setSendType(type.getCode());
wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode());

List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery);
List<WxCouponSendVo> wxCouponSends = wxCouponSendMapper.findListVo(wxCouponSendQuery);
for (WxCouponSend send : wxCouponSends) {
boolean checkLimit = false;
// 检查疲劳度


+ 32
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxLevelConfigServiceImpl.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxLevelConfig;
@@ -23,7 +24,16 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService {

@Override
public PageInfo<WxLevelConfig> listAsPage(WxLevelConfig record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxLevelConfigMapper.findList(record));
PageInfo<WxLevelConfig> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxLevelConfigMapper.findList(record));
page.getList().stream().forEach(l->{
if (l.getCapability()!= null){
JSONObject jo = JSONObject.parseObject(l.getCapability());
l.setCount(jo.getLong(CAPABILITY_SEND_CAR_COUPON));
}else {
l.setCount(0L);
}
});
return page;
}

@Override
@@ -70,6 +80,27 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService {
}
}

public final static String CAPABILITY_SEND_CAR_COUPON = "carCouponCount";

@Override
public void batchUpdateCapabilities(String tenantId, List<WxLevelConfig> records) {
records.stream()
.filter(l->l.getId() == null && l.getCount() != null)
.forEach(l->{
l.setUpdateDate(new Date());
JSONObject jo = new JSONObject();
jo.put(CAPABILITY_SEND_CAR_COUPON,l.getCount());
l.setCapability(jo.toJSONString());
wxLevelConfigMapper.updateByPrimaryKeySelective(l);
});
}

@Override
public Long getCapabilitiesOfSendCarConpon(JSONObject jo) {
return jo.getLong(CAPABILITY_SEND_CAR_COUPON);
}


@Override
public void deleteById(Long id) {
wxLevelConfigMapper.deleteByPrimaryKey(id);


+ 7
- 17
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Просмотреть файл

@@ -549,28 +549,18 @@ public class WxOrderServiceImpl implements WxOrderService {
private WxCouponOrder createCouponOrder(WxCUser user, WxOrder order, WxCoupon coupon) {
Date curr = new Date();
Date valid_date = null;
if (coupon.getValidType().equals(EnumValidStatus.VALID_RANGE.getCode())){
if (coupon.getValidType().equals(EnumValidStatus.VALID_RANGE.getCode()) ||
coupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode())){
valid_date = coupon.getValidEndDate();
}
else {
Calendar calendar = Calendar.getInstance();
calendar.setTime(curr);
if (!coupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode())) {
// 普通券精确到天
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.add(Calendar.DAY_OF_MONTH, 1+coupon.getValidDays());
valid_date = calendar.getTime();
} else {
// 停车券过期日期到月
calendar.set(Calendar.DAY_OF_MONTH, 0);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.add(Calendar.MONTH, 1);
valid_date = calendar.getTime();
}
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.add(Calendar.DAY_OF_MONTH, 1+coupon.getValidDays());
valid_date = calendar.getTime();
}
boolean isCard = false;
// 检查是否是储值卡


+ 22
- 0
mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml Просмотреть файл

@@ -181,6 +181,28 @@

</select>

<select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
select <include refid="allColumns"/>
from wx_c_user_basic_info where 1=1

<if test=" null != levelStartScore ">
and poins &gt;= #{levelStartScore}
</if>

<if test=" null != levelEndScore">
and poins &lt;= #{levelEndScore}
</if>

<if test=" null == levelStartScore and null == levelEndScore">
and poins is null
</if>

<if test="null != tenantId">
and tenant_id =#{tenantId}
</if>

</select>

<select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
select count(id) from wx_c_user_basic_info where 1=1
<if test=" null != startTime ">


+ 21
- 15
mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml Просмотреть файл

@@ -1,7 +1,7 @@
<?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.WxCouponSendMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponSend">
<resultMap id="BaseResultMap" type="com.iformall.domain.vo.WxCouponSendVo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="coupon_id" jdbcType="BIGINT" property="couponId" />
@@ -11,60 +11,66 @@
<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="merchant_name" jdbcType="VARCHAR" property="merchantName" />
<result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
<result column="inventory" jdbcType="INTEGER" property="inventory"/>
<result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
<result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`coupon_id`,`title`,`send_type`,`conditions`,`status`,`create_date`,`update_date`,
cs.id,cs.tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date,
(case when
(select count(*) from wx_coupon_merchant xcm where xcm.product_id = coupon_id and status = 0)=1
(select count(*) from wx_coupon_merchant xcm where xcm.product_id = cs.coupon_id and xcm.status = 0)=1
then
(select m.name from wx_merchant m, wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id=coupon_id)
(select m.name from wx_merchant m, wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id=cs.coupon_id)
else
'[多商户通用]'
end) as merchant_name
end) as merchant_name,
c.remain_inventory, c.inventory, c.valid_start_date, c.valid_end_date
</sql>

<sql id="dynamicWhereConditions">
where 1 = 1

<if test=" null != id ">
and `id` = #{id}
and cs.id = #{id}

</if>

<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
and cs.tenant_id = #{tenantId}

</if>

<if test=" null != couponId ">
and `coupon_id` = #{couponId}
and cs.coupon_id = #{couponId}

</if>

<if test=" null != title ">
and `title` like concat('%', #{title},'%')
and cs.title like concat('%', #{title},'%')

</if>

<if test=" null != sendType ">
and `send_type` = #{sendType}
and cs.send_type = #{sendType}

</if>

<if test=" null != status ">
and `status` = #{status}
and cs.status = #{status}

</if>

<if test=" null != createDate ">
and `create_date` = #{createDate}
and cs.create_date = #{createDate}

</if>

<if test=" null != updateDate ">
and `update_date` = #{updateDate}
and cs.update_date = #{updateDate}

</if>
<if test=" null != ids ">
@@ -76,8 +82,8 @@
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</sql>

<select id="findList" parameterType="com.iformall.domain.po.WxCouponSend" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_coupon_send
<select id="findListVo" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_coupon_send cs left join wx_coupon c on c.id = cs.coupon_id
<include refid="dynamicWhereConditions" />
</select>



+ 2
- 1
mallinkService/src/main/resources/mapper/WxLevelConfigMapper.xml Просмотреть файл

@@ -9,10 +9,11 @@
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="discount_enable" jdbcType="SMALLINT" property="discountEnable"/>
<result column="capability" jdbcType="VARCHAR" property="capability"/>
</resultMap>

<sql id="allColumns">
`id`, `tenant_id`, `points`, `level`, `description`, `create_date`, `discount_enable`
`id`, `tenant_id`, `points`, `level`, `description`, `create_date`, `discount_enable`, `capability`
</sql>

<sql id="dynamicWhereConditions">


Загрузка…
Отмена
Сохранить