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

[场景发券疲劳度生效][新增]

release_toaliyun_real
Stormeye.Wu 7 лет назад
Родитель
Сommit
c8d337dd34
6 измененных файлов: 62 добавлений и 45 удалений
  1. +15
    -14
      mallinkService/src/main/java/com/iformall/domain/po/WxCouponActionLog.java
  2. +3
    -2
      mallinkService/src/main/java/com/iformall/service/PushLimitService.java
  3. +5
    -4
      mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java
  4. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java
  5. +14
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java
  6. +24
    -24
      mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml

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

@@ -79,8 +79,8 @@ public class WxCouponActionLog implements Serializable {
@io.swagger.annotations.ApiModelProperty(value="",name="channelId")
private Long channelId;
/***/
@io.swagger.annotations.ApiModelProperty(value="",name="createtime")
private Date createtime;
@io.swagger.annotations.ApiModelProperty(value="",name="createTime")
private Date createTime;
public String getTenantId() {
return tenantId;
}
@@ -111,24 +111,24 @@ public class WxCouponActionLog implements Serializable {
public void setChannelId(Long _channelId) {
channelId = _channelId;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date _createtime) {
createtime = _createtime;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public static enum Field
{
Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC")
,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC")
,CouponOrderId_ASC("`couponOrderId` ASC"),CouponOrderId_DESC("`couponOrderId` DESC")
,ChannelType_ASC("`channelType` ASC"),ChannelType_DESC("`channelType` DESC")
,ChannelId_ASC("`channelId` ASC"),ChannelId_DESC("`channelId` DESC")
,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC")
,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
,CouponId_ASC("`coupon_id` ASC"),CouponId_DESC("`coupon_id` DESC")
,CouponOrderId_ASC("`coupon_order_id` ASC"),CouponOrderId_DESC("`coupon_order_id` DESC")
,ChannelType_ASC("`channel_type` ASC"),ChannelType_DESC("`channel_type` DESC")
,ChannelId_ASC("`channel_id` ASC"),ChannelId_DESC("`channel_id` DESC")
,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC")
;
private String value;
Field(String value){
@@ -161,6 +161,7 @@ public class WxCouponActionLog implements Serializable {
sb.append(",");
sb.append(fields[k].toString());
}
this.sortColumns = sb.toString();

}



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

@@ -57,10 +57,11 @@ public interface PushLimitService {

/**
* 主动发券检查
* @param user
* @param tenantId
* @param cUserId
* @param coupon
* @return
*/
boolean checkCoupon(WxCUser user, WxCoupon coupon);
boolean checkCoupon(String tenantId, Long cUserId, Long couponId);

}

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

@@ -92,10 +92,10 @@ public class PushLimitServiceImpl implements PushLimitService {
}

@Override
public boolean checkCoupon(WxCUser user, WxCoupon coupon) {
public boolean checkCoupon(String tenantId, Long cUserId, Long couponId) {
Date curDate = new Date();
// 1. get tenant limit
PushLimit pushLimit = getPushLimit(user.getTenantId());
PushLimit pushLimit = getPushLimit(tenantId);
// 2. check time 是否在给定的时间段内
boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd());
if (!isInDate) {
@@ -103,13 +103,14 @@ public class PushLimitServiceImpl implements PushLimitService {
}
// 3. check 每人每天多少张券
Map params = new HashMap<String, Object>();
params.put("tenantId", user.getTenantId());
params.put("c_user_id", user.getId());
params.put("tenantId", tenantId);
params.put("cUserId", cUserId);
int countForUser = wxCouponActionLogMapper.getCountByUser(params);
if (countForUser >= pushLimit.getCouponAmount()) {
throw new MallinkException(ErrorCode.COUPON_SEND_UP_TO_COUPONLIMIT);
}
// 4. check 每人多少天内不会重复收到一张券
params.put("couponId", couponId);
params.put("dayNum", pushLimit.getCouponDay());
int countForUserCoupon = wxCouponActionLogMapper.getCountByUserAndCoupon(params);
if (countForUserCoupon >= pushLimit.getCouponDay()) {


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

@@ -55,7 +55,7 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService {
actionLog.setChannelId(channelId);
actionLog.setCouponOrderId(coupon_order_id);
actionLog.setChannelType(channelType);
actionLog.setCreatetime(new Date());
actionLog.setCreateTime(new Date());
saveOrUpdate(actionLog);
}



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

@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.*;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxCouponOrderMapper;
import com.iformall.mapper.WxCouponSendMapper;
import com.iformall.service.*;
@@ -37,6 +38,9 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
@Autowired
WxCouponOrderMapper wxCouponOrderMapper;

@Autowired
PushLimitService pushLimitService;


@Override
public PageInfo<WxCouponSend> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) {
@@ -72,6 +76,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
//查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch
WxCouponSend wxCouponSendQuery = new WxCouponSend();
wxCouponSendQuery.setTenantId(tenantId);
wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode());
int actionType = EnumCouponSendSendType.UNKNOWN.getCode();
String configKey = "";
if (type == EnumCouponSendSendType.CAR_STOP) {
@@ -101,6 +106,15 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {

List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery);
for (WxCouponSend send : wxCouponSends) {
boolean checkLimit = false;
try {
checkLimit = pushLimitService.checkCoupon(tenantId, cUserId, send.getCouponId());
} catch (MallinkException e) {
logger.error(e.getMessage());
}
if (!checkLimit) {
continue;
}
// 发放免费券
WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId());
if (couponOrder != null) {


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

@@ -8,11 +8,11 @@
<result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
<result column="channel_type" jdbcType="INTEGER" property="channelType" />
<result column="channel_id" jdbcType="BIGINT" property="channelId" />
<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`createtime`
`id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time`
</sql>

<sql id="dynamicWhereConditions">
@@ -48,14 +48,14 @@
</if>
<if test=" null != createtime ">
and `createtime` = #{createtime}
<if test=" null != createTime ">
and `create_time` = #{createTime}
</if>
<if test=" null != startTime ">
and `createtime` >= #{startTime}
and `create_time` >= #{startTime}
</if>
<if test=" null != endTime ">
and `createtime` &lt;= #{endTime}
and `create_time` &lt;= #{endTime}
</if>

<if test=" null != ids ">
@@ -75,24 +75,24 @@
<select id="findCountByDateLimit" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_action_log
where tenant_id = #{tenantId}
and `createtime` >= #{startTime}
and `createtime` &lt;= #{endTime}
and `create_time` >= #{startTime}
and `create_time` &lt;= #{endTime}
</select>

<select id="sceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
select DATE_FORMAT(createtime,'%m/%d') as xTime,
select DATE_FORMAT(create_time,'%m/%d') as xTime,
(select Count(*) from wx_coupon_action_log c
where DATE_FORMAT(createtime,'%m/%d')=xTime
where DATE_FORMAT(create_time,'%m/%d')=xTime
and c.channel_type=2
and tenant_id=#{tenantId} ) as parkSendCount,
(select Count(*) from wx_coupon_action_log c
where DATE_FORMAT(createtime,'%m/%d')=xTime
where DATE_FORMAT(create_time,'%m/%d')=xTime
and c.channel_type=3
and tenant_id=#{tenantId}) as verifySendCount
from wx_coupon_action_log
where tenant_id=#{tenantId}
and createtime &gt;= #{startTime}
and createtime &lt;= #{endTime}
and create_time &gt;= #{startTime}
and create_time &lt;= #{endTime}
group by xTime
order by xTime desc
</select>
@@ -102,30 +102,30 @@
left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
where wx_coupon_action_log.tenant_id=#{tenantId}
and wx_coupon_order.coupon_order_status = 1
and wx_coupon_action_log.createtime &gt;= #{startTime}
and wx_coupon_action_log.createtime &lt;= #{endTime}
and wx_coupon_action_log.create_time &gt;= #{startTime}
and wx_coupon_action_log.create_time &lt;= #{endTime}
and wx_coupon_action_log.channel_type = #{channelType}
group by xTime
order by xTime desc
</select>

<select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
select DATE_FORMAT(createtime,'%Y-%m-%d') as xTime,
select DATE_FORMAT(create_time,'%Y-%m-%d') as xTime,
(select Count(*) from wx_coupon_action_log c
where DATE_FORMAT(createtime,'%Y-%m-%d')=xTime
where DATE_FORMAT(create_time,'%Y-%m-%d')=xTime
and c.channel_type=2
and tenant_id=#{tenantId} ) as parkSendCount,
(select Count(*) from wx_coupon_action_log c
where DATE_FORMAT(createtime,'%Y-%m-%d')=xTime
where DATE_FORMAT(create_time,'%Y-%m-%d')=xTime
and c.channel_type=3
and tenant_id=#{tenantId}) as verifySendCount
from wx_coupon_action_log
where tenant_id=#{tenantId}
<if test=" null != startTime ">
and createtime &gt;= #{startTime}
and create_time &gt;= #{startTime}
</if>
<if test=" null != endTime ">
and createtime &lt;= #{endTime}
and create_time &lt;= #{endTime}
</if>
group by xTime
order by xTime desc
@@ -136,10 +136,10 @@
where wx_coupon_action_log.tenant_id=#{tenantId}
and wx_coupon_order.coupon_order_status = 1
<if test=" null != startTime ">
and wx_coupon_action_log.createtime &gt;= #{startTime}
and wx_coupon_action_log.create_time &gt;= #{startTime}
</if>
<if test=" null != endTime ">
and wx_coupon_action_log.createtime &lt;= #{endTime}
and wx_coupon_action_log.create_time &lt;= #{endTime}
</if>
and wx_coupon_action_log.channel_type = #{channelType}
group by xTime
@@ -155,7 +155,7 @@
</select>

<select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
select COUNT(a.*)
select COUNT(*)
FROM wx_coupon_action_log a, wx_coupon_order o
WHERE a.coupon_order_id = o.id
AND a.tenant_id = #{tenantId}
@@ -164,7 +164,7 @@
</select>

<select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
select COUNT(a.*)
select COUNT(*)
FROM wx_coupon_action_log a, wx_coupon_order o
WHERE a.coupon_order_id = o.id
AND a.tenant_id = #{tenantId}


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