Authored by wangxin

活动内容修改

... ... @@ -208,5 +208,25 @@ public class OrderShareActivityBO extends BaseModel{
public void setOldUserCouponPic(String oldUserCouponPic) {
this.oldUserCouponPic = oldUserCouponPic;
}
public String getFormatActivityDesc() {
if (null == activityDesc) {
return "";
}
String[] array = activityDesc.split("(\\r\\n|\\r|\\n|\\n\\r)");
if (array.length > 0) {
StringBuffer sb = new StringBuffer();
for(String s : array) {
sb.append("<P>");
sb.append(s);
sb.append("</P>");
}
return sb.toString();
}
return "";
}
}
... ...
... ... @@ -33,4 +33,26 @@ public class TencentMktBO extends TencentMktActivityBO{
public void setShareUrl(String shareUrl) {
this.shareUrl = shareUrl;
}
public String getFormatActivityDesc() {
String activityDesc = getActivityDesc();
if (null == activityDesc) {
return "";
}
String[] array = activityDesc.split("(\\r\\n|\\r|\\n|\\n\\r)");
if (array.length > 0) {
StringBuffer sb = new StringBuffer();
for(String s : array) {
sb.append("<P>");
sb.append(s);
sb.append("</P>");
}
return sb.toString();
}
return "";
}
}
... ...
... ... @@ -17,5 +17,5 @@ public interface IOrderShareCouponDAO {
int updateByPrimaryKey(OrderShareCoupon record);
OrderShareCoupon selectCouponByDateAndType(@Param("useDate") String useDate, @Param("couponType") int couponType);
OrderShareCoupon selectCouponByDateAndType(@Param("useDate") String useDate, @Param("couponType") int couponType, @Param("activityId") int activityId);
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,7 @@ package com.yoho.coupon.dal.model;
import com.yoho.queue.dal.model.BaseModel;
public class OrderShareCoupon extends BaseModel {
public class OrderShareCoupon extends BaseModel {
/**
*
*/
... ... @@ -18,6 +18,10 @@ public class OrderShareCoupon extends BaseModel {
private Integer couponType;
private Integer activityId;
private String couponPic;
public Integer getId() {
return id;
}
... ... @@ -57,4 +61,20 @@ public class OrderShareCoupon extends BaseModel {
public void setCouponType(Integer couponType) {
this.couponType = couponType;
}
public Integer getActivityId() {
return activityId;
}
public void setActivityId(Integer activityId) {
this.activityId = activityId;
}
public String getCouponPic() {
return couponPic;
}
public void setCouponPic(String couponPic) {
this.couponPic = couponPic;
}
}
\ No newline at end of file
... ...
... ... @@ -7,9 +7,11 @@
<result column="coupon_name" property="couponName" jdbcType="VARCHAR" />
<result column="use_date" property="useDate" jdbcType="VARCHAR" />
<result column="coupon_type" property="couponType" jdbcType="TINYINT" />
<result column="activity_id" property="activityId" jdbcType="INTEGER" />
<result column="coupon_pic" property="couponPic" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, coupon_id, coupon_name, use_date, coupon_type
id, coupon_id, coupon_name, use_date, coupon_type,activity_id,coupon_pic
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
... ... @@ -19,7 +21,7 @@
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectCouponByDateAndType" resultMap="BaseResultMap">
select * from order_share_coupon where 1=1
select * from order_share_coupon where activity_id=#{activityId}
<if test="useDate != null">
and use_date=#{useDate}
</if>
... ...
... ... @@ -105,6 +105,16 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
}
activityBO = OrderShareActivityConvert.db2bo(db);
//重新设置新老用户券
OrderShareCoupon newCoupon = orderShareCouponDAO.selectCouponByDateAndType(null, Constant.ORDER_SHARE_USERTYPE_NEW, activityBO.getId());
if (null != newCoupon) {
activityBO.setCouponPic(newCoupon.getCouponPic());
}
OrderShareCoupon oldCoupon = orderShareCouponDAO.selectCouponByDateAndType(DateUtils.getToday("yyyy-MM-dd"), Constant.ORDER_SHARE_USERTYPE_OLD, activityBO.getId());
if (null != oldCoupon) {
activityBO.setOldUserCouponPic(oldCoupon.getCouponPic());
}
yhValueOperations.set(ORDER_SHARE_ACTIVITY_CACHEKEY, CacheKeyHelper.value2String(activityBO));
yHRedisTemplate.longExpire(ORDER_SHARE_ACTIVITY_CACHEKEY, 1, TimeUnit.MINUTES);
... ... @@ -306,7 +316,7 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
// 发送优惠券
// 获取老人优惠券
OrderShareCouponVO couponVO = drawCoupon(profileInfo.getUid(), Constant.ORDER_SHARE_USERTYPE_OLD);
OrderShareCouponVO couponVO = drawCoupon(profileInfo.getUid(), Constant.ORDER_SHARE_USERTYPE_OLD, activityInfo.getId());
if (!couponVO.isDrawCouponSuccess()) {
respBO.setReturnCode(Constant.ORDER_SHARE_SENDCOUPON_ERROR);
respBO.setReturnMsg("优惠券已被抢光");
... ... @@ -364,7 +374,7 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
// 3、发送优惠券
// 获取新人优惠券
OrderShareCouponVO couponVO = drawCoupon(model.getUid(), Constant.ORDER_SHARE_USERTYPE_NEW);
OrderShareCouponVO couponVO = drawCoupon(model.getUid(), Constant.ORDER_SHARE_USERTYPE_NEW, activityInfo.getId());
if (!couponVO.isDrawCouponSuccess()) {
respBO.setReturnCode(Constant.ORDER_SHARE_SENDCOUPON_ERROR);
respBO.setReturnMsg("优惠券已被抢光");
... ... @@ -507,17 +517,17 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
* @param userType
* @return
*/
private OrderShareCouponVO drawCoupon(int uid, int userType) {
private OrderShareCouponVO drawCoupon(int uid, int userType, int activityId) {
log.info("draw orderShare coupon: uid: {}, userType: {}", uid, userType);
OrderShareCouponVO couponVO = new OrderShareCouponVO();
//新人券、老人全不一样
OrderShareCoupon coupon = null;
if(userType == Constant.ORDER_SHARE_USERTYPE_OLD) {
coupon = orderShareCouponDAO.selectCouponByDateAndType(DateUtils.getToday("yyyy-MM-dd"), Constant.ORDER_SHARE_USERTYPE_OLD);
coupon = orderShareCouponDAO.selectCouponByDateAndType(DateUtils.getToday("yyyy-MM-dd"), Constant.ORDER_SHARE_USERTYPE_OLD, activityId);
}
else if(userType == Constant.ORDER_SHARE_USERTYPE_NEW) {
coupon = orderShareCouponDAO.selectCouponByDateAndType(null, Constant.ORDER_SHARE_USERTYPE_NEW);
coupon = orderShareCouponDAO.selectCouponByDateAndType(null, Constant.ORDER_SHARE_USERTYPE_NEW, activityId);
}
if(coupon == null) {
... ...
... ... @@ -84,7 +84,8 @@
<div class="receive-coupon-page">
<div class="bg-contain">
<img src="http://img11.static.yhbimg.com/yhb-img01/2016/06/17/16/019b5b887d2e78098f9448927df3427da4.png">
<img class="img1" src="http://img11.static.yhbimg.com/yhb-img01/2016/06/17/16/019b5b887d2e78098f9448927df3427da4.png">
<img class="img2">
</div>
<p class="hidden" id="activityEnded"></p>
<p class="hidden" id="newUser"></p>
... ... @@ -164,7 +165,13 @@
<div class="mask hidden"></div>
<div class="dialog hidden" id="message">
<span class="close"></span>
<span id="activityDesc"></span>
<span id="activityDesc">
<div class="activity-message">
<h3>活动说明</h3>
<div class="message">
</div>
</div>
</span>
</div>
... ...
var tipMessage = $('#tipMessage').html();
var activityID = $('#activityID').html();
$('#phone').bind('input propertychange', function() {
if ($(this).val().length === 11) {
$('.input-content div').eq('0').addClass('verification-code');
} else {
$('.input-content div').eq('0').removeClass();
if ($(this).val().length >= 1) {
$('.input-content i').eq('0').removeClass('hidden');
} else {
$('.input-content i').eq('0').addClass('hidden');
}
}
});
$('#verification').bind('input propertychange', function() {
if ($(this).val().length === 4) {
$('.input-content div').eq('1').addClass('get');
} else {
$('.input-content div').eq('1').removeClass();
if ($(this).val().length >= 1) {
$('.input-content i').eq('1').removeClass('hidden');
} else {
$('.input-content i').eq('1').addClass('hidden');
}
}
});
if ($('#activityEnded').html()) {
$('.tip-wrap').removeClass('hidden');
$('.tip-wrap .title').html(tipMessage);
var tipMessage = $('#tipMessage').html();
var activityID = $('#activityID').html();
$('#phone').bind('input propertychange', function() {
if ($(this).val().length === 11) {
$('.input-content div').eq('0').addClass('verification-code');
} else {
$('.input-content div').eq('0').removeClass();
if ($(this).val().length >= 1) {
$('.input-content i').eq('0').removeClass('hidden');
} else {
$('.input-content i').eq('0').addClass('hidden');
}
function showToast(messages, time) {
$('#dialog').removeClass('hidden');
$('.mask').removeClass('hidden');
$('#dialog .content').html('<p class="phone-error">' + messages + '<p>');
setTimeout(function() {
$('.messages').addClass('hidden');
$('.mask').addClass('hidden');
$('#dialog .content').html(' ');
}, time);
}
});
$('#verification').bind('input propertychange', function() {
if ($(this).val().length === 4) {
$('.input-content div').eq('1').addClass('get');
} else {
$('.input-content div').eq('1').removeClass();
if ($(this).val().length >= 1) {
$('.input-content i').eq('1').removeClass('hidden');
} else {
$('.input-content i').eq('1').addClass('hidden');
}
$(function(){
$.ajax({
url: '/activity/tencentMkt/TencentMktController/getActivityInfo',
data: {
activityCode: activityCode
},
success: function(data) {
data = getPageInfo(data);
if (data.code === 200 || data.code === 502 || data.code === 503) {
/*if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID,
returnCode: data.returnCode
}, false);
}*/
if (data.code === 200) {
$('.receive-coupon-page .bg-contain img').attr('src', data.bgImg);
$('.gain-coupon-centent .coupon img').attr('src', data.couponPic);
$('#activityEnded').text(data.ended);
$('#newUser').text(data.newUser);
$('#tipMessage').text(data.message);
$('#activityID').text(data.activityID);
$('#shareTitle').val(data.shareTitle);
$('#shareDesc').val(data.shareDesc);
$('#shareImg').val(data.shareImg);
$('#shareLink').val(data.shareLink);
$('#activityCode').val(data.activityCode);
$('.gain-coupon-centent .use-coupon-btn .use-coupon').attr('href', data.buttonLink);
$('.gain-coupon-centent .go-wep').attr('href', data.pcLink);
$('.tip .title').html(data.message);
$('#activityDesc').html(data.activityDesc);
if(data.ended) {
$('.tip-wrap').removeClass('hidden');
$('.tip-wrap .title').html(data.message);
}
} else {
showToast(data.message, 1400);
}
}
});
if ($('#activityEnded').html()) {
$('.tip-wrap').removeClass('hidden');
$('.tip-wrap .title').html(tipMessage);
}
function showToast(messages, time) {
$('#dialog').removeClass('hidden');
$('.mask').removeClass('hidden');
$('#dialog .content').html('<p class="phone-error">' + messages + '<p>');
setTimeout(function() {
$('.messages').addClass('hidden');
$('.mask').addClass('hidden');
$('#dialog .content').html(' ');
}, time);
}
$(function() {
$.ajax({
url: '/activity/tencentMkt/TencentMktController/getActivityInfo',
data: {
activityCode: activityCode
},
success: function(data) {
data = getPageInfo(data);
if (data.code === 200 || data.code === 502 || data.code === 503) {
/*if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID,
returnCode: data.returnCode
}, false);
}*/
if (data.code === 200) {
$('.receive-coupon-page .bg-contain .img1').attr('src', data.bgImg);
if (data.secondScreenPic) {
$('.receive-coupon-page .bg-contain .img2').attr('src', data.secondScreenPic);
} else {
showToast('网络错误,稍后再试!', 1400);
$('.receive-coupon-page .bg-contain .img2').addClass('hidden');
}
},
error: function() {
showToast('网络错误,稍后再试!', 1400);
},
dataType : "json"
});
});
$('#getCoupon').on('click', function() {
phone = $(this).siblings('input').val();
reg = /[0-9]{11}/;
if (!reg.test(phone)) {
showToast('手机号错误,请重新输入。', 1400);
return;
}
$.ajax({
url: '/activity/tencentMkt/TencentMktController/sendSms',
data: {
mobile: $('#phone').val(),
activityCode: activityCode
},
success: function(data) {
if (data.code === 200 || data.code === 502 || data.code === 503 || data.code === 404) {
if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID,
returnCode: data.returnCode
}, false);
}
if (data.code === 200) {
$('.coupon-centent .phone-input-content').addClass('hidden');
$('.coupon-centent .vertify-input-content').removeClass('hidden');
} else {
showToast(data.message, 1400);
}
} else {
showToast('网络错误,稍后再试!', 1400);
$('.gain-coupon-centent .coupon img').attr('src', data.couponPic);
$('#activityEnded').text(data.ended);
$('#newUser').text(data.newUser);
$('#tipMessage').text(data.message);
$('#activityID').text(data.activityID);
$('#shareTitle').val(data.shareTitle);
$('#shareDesc').val(data.shareDesc);
$('#shareImg').val(data.shareImg);
$('#shareLink').val(data.shareLink);
$('#activityCode').val(data.activityCode);
$('.gain-coupon-centent .use-coupon-btn .use-coupon').attr('href', data.buttonLink);
$('.gain-coupon-centent .go-wep').attr('href', data.pcLink);
$('.tip .title').html(data.message);
$('#activityDesc .message').html(data.formatActivityDesc);
if (data.ended) {
$('.tip-wrap').removeClass('hidden');
$('.tip-wrap .title').html(data.message);
}
},
error: function() {
showToast('网络错误,稍后再试!', 1400);
},
dataType : "json"
});
});
$('.input-content').on('click', '.get', function() {
$('.input-content div').eq('1').removeClass('get');
if ($(this).siblings('input').val().length === 4) {
$.ajax({
url: '/activity/tencentMkt/TencentMktController/validRegCodeAndSendCode',
data: {
code: $('#verification').val(),
mobile: $('#phone').val(),
activityCode: activityCode
},
dataType: 'json',
success: function(data) {
if (data.code === 200) {
if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID,
returnCode: data.returnCode
}, false);
}
$('.coupon-centent').addClass('hidden');
$('.gain-coupon-centent').removeClass('hidden');
} else {
showToast(data.message, 1400);
}
},
error: function() {
showToast('网络错误,稍后再试!', 1400);
},
dataType : "json"
});
} else {
showToast(data.message, 1400);
}
} else {
showToast('网络错误,稍后再试!', 1400);
}
});
$('.close').on('click', function() {
$('.dialog').addClass('hidden');
$('.mask').addClass('hidden');
$('#dialog .content').html(' ');
});
$('.description-btn').on('click', function() {
$('#message').removeClass('hidden');
$('.mask').removeClass('hidden');
});
$('.gain-description-btn').on('click', function() {
$('#message').removeClass('hidden');
$('.mask').removeClass('hidden');
});
$('.description').on('click', function() {
$('#message').removeClass('hidden');
$('.mask').removeClass('hidden');
});
},
error: function() {
showToast('网络错误,稍后再试!', 1400);
},
dataType: "json"
});
});
$('#getCoupon').on('click', function() {
phone = $(this).siblings('input').val();
reg = /[0-9]{11}/;
if (!reg.test(phone)) {
showToast('手机号错误,请重新输入。', 1400);
return;
}
$.ajax({
url: '/activity/tencentMkt/TencentMktController/sendSms',
data: {
mobile: $('#phone').val(),
activityCode: activityCode
},
success: function(data) {
if (data.code === 200 || data.code === 502 || data.code === 503 || data.code === 404) {
if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID,
returnCode: data.returnCode
}, false);
}
if (data.code === 200) {
$('.use-coupon-btn').on('click', function() {
if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID
}, true);
}
});
$('.coupon-centent .phone-input-content').addClass('hidden');
$('.coupon-centent .vertify-input-content').removeClass('hidden');
$('.input-content .clear-mobile').on('click', function() {
$('.input-content input').eq('0').val('');
$(this).addClass('hidden');
$('.input-content div').eq('0').removeClass();
});
$('.input-content .clear-verify').on('click', function() {
$('.input-content input').eq('1').val('');
$(this).addClass('hidden');
$('.input-content div').eq('1').removeClass();
});
/**
* 分享页面基础参数
* @param {object} sizeInfo [接口原始数据]
* @return {object} [description]
*/
function getPageInfo(pageInfo) {
var dest = {};
dest.shareTitle = pageInfo.data.shareTitle;
dest.shareDesc = pageInfo.data.shareContent;
dest.shareImg = pageInfo.data.shareImgUrl;
dest.shareLink = pageInfo.data.shareUrl;
dest.code = pageInfo.code;
dest.activityID = pageInfo.id;
dest.title = pageInfo.data.h5Title;
dest.activityDesc = pageInfo.data.activityDesc;
dest.couponPic = pageInfo.data.couponPic;
dest.oldUserCouponPic = pageInfo.data.oldUserCouponPic;
dest.mobile = pageInfo.data.mobile;
dest.pcLink = pageInfo.data.pcLink;
dest.buttonLink = pageInfo.data.buttonLink;
if (pageInfo.data.flag === 1) {
dest.bgImg = pageInfo.data.activityNormalPic;
} else {
showToast(data.message, 1400);
}
} else {
dest.bgImg = pageInfo.data.activityEndPic;
dest.ended = true;
showToast('网络错误,稍后再试!', 1400);
}
dest.message = pageInfo.data.returnMsg;
},
error: function() {
showToast('网络错误,稍后再试!', 1400);
},
dataType: "json"
});
});
$('.input-content').on('click', '.get', function() {
$('.input-content div').eq('1').removeClass('get');
if ($(this).siblings('input').val().length === 4) {
$.ajax({
url: '/activity/tencentMkt/TencentMktController/validRegCodeAndSendCode',
data: {
code: $('#verification').val(),
mobile: $('#phone').val(),
activityCode: activityCode
},
dataType: 'json',
success: function(data) {
if (data.code === 200) {
if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID,
returnCode: data.returnCode
}, false);
}
$('.coupon-centent').addClass('hidden');
$('.gain-coupon-centent').removeClass('hidden');
// 清空变量,释放内存
pageInfo = {};
return dest;
};
\ No newline at end of file
} else {
showToast(data.message, 1400);
}
},
error: function() {
showToast('网络错误,稍后再试!', 1400);
},
dataType: "json"
});
} else {
showToast('网络错误,稍后再试!', 1400);
}
});
$('.close').on('click', function() {
$('.dialog').addClass('hidden');
$('.mask').addClass('hidden');
$('#dialog .content').html(' ');
});
$('.description-btn').on('click', function() {
$('#message').removeClass('hidden');
$('.mask').removeClass('hidden');
});
$('.gain-description-btn').on('click', function() {
$('#message').removeClass('hidden');
$('.mask').removeClass('hidden');
});
$('.description').on('click', function() {
$('#message').removeClass('hidden');
$('.mask').removeClass('hidden');
});
$('.use-coupon-btn').on('click', function() {
if (window._yas) {
window._yas.sendCustomInfo({
activityID: activityID
}, true);
}
});
$('.input-content .clear-mobile').on('click', function() {
$('.input-content input').eq('0').val('');
$(this).addClass('hidden');
$('.input-content div').eq('0').removeClass();
});
$('.input-content .clear-verify').on('click', function() {
$('.input-content input').eq('1').val('');
$(this).addClass('hidden');
$('.input-content div').eq('1').removeClass();
});
/**
* 分享页面基础参数
* @param {object} sizeInfo [接口原始数据]
* @return {object} [description]
*/
function getPageInfo(pageInfo) {
var dest = {};
dest.shareTitle = pageInfo.data.shareTitle;
dest.shareDesc = pageInfo.data.shareContent;
dest.shareImg = pageInfo.data.shareImgUrl;
dest.shareLink = pageInfo.data.shareUrl;
dest.code = pageInfo.code;
dest.activityID = pageInfo.id;
dest.title = pageInfo.data.h5Title;
dest.activityDesc = pageInfo.data.activityDesc;
dest.couponPic = pageInfo.data.couponPic;
dest.oldUserCouponPic = pageInfo.data.oldUserCouponPic;
dest.mobile = pageInfo.data.mobile;
dest.pcLink = pageInfo.data.pcLink;
dest.buttonLink = pageInfo.data.buttonLink;
dest.secondScreenPic = pageInfo.data.secondScreenPic;
dest.formatActivityDesc = pageInfo.data.formatActivityDesc;
if (pageInfo.data.flag === 1) {
dest.bgImg = pageInfo.data.activityNormalPic;
} else {
dest.bgImg = pageInfo.data.activityEndPic;
dest.ended = true;
}
dest.message = pageInfo.data.returnMsg;
// 清空变量,释放内存
pageInfo = {};
return dest;
};
\ No newline at end of file
... ...