Authored by michaelcao

Merge branch 'brandDraw' of git.yoho.cn:yoho30/yohobuy-activity into brandDraw

... ... @@ -10,8 +10,8 @@ import com.yoho.error.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
... ... @@ -42,14 +42,15 @@ public class FavoriteController {
*/
@RequestMapping("/addFavorite")
@ResponseBody
public ApiResponse addFavorite(@RequestBody FavoriteAddReq favoriteAddReq) throws ServiceException {
log.info("getBrandActInfoById req is {}", favoriteAddReq);
if (favoriteAddReq == null) {
log.warn("getBrandActInfoById req is {}", favoriteAddReq);
public ApiResponse addFavorite(@RequestParam(value = "productSkn") int skn, @RequestParam(value = "uid") int uid) throws ServiceException {
log.info("getBrandActInfoById req is {},{}", skn,uid);
if (skn ==0||uid==0) {
log.warn("getBrandActInfoById req is {},{}", skn, uid);
return new ApiResponse(403, "参数异常");
}
favoriteAddReq.setProductSkn(512579932);
favoriteAddReq.setUid(8041532);
FavoriteAddReq favoriteAddReq=new FavoriteAddReq();
favoriteAddReq.setProductSkn(skn);
favoriteAddReq.setUid(uid);
ApiResponse apiResponse = favoriteActivityService.addUserFavorite(favoriteAddReq);
return apiResponse;
}
... ...
... ... @@ -6,6 +6,7 @@ package com.yoho.activity.service.impl;
import com.alibaba.fastjson.JSON;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.common.bo.ActNewBrandBo;
import com.yoho.activity.common.redis.CacheKeyHelper;
import com.yoho.activity.common.utils.BeanTool;
import com.yoho.activity.common.utils.DateUtils;
import com.yoho.activity.dal.ActNewBrandMapper;
... ... @@ -14,6 +15,7 @@ import com.yoho.activity.dal.model.ActNewBrand;
import com.yoho.activity.dal.model.ActNewBrandResult;
import com.yoho.activity.service.IBrandActivityService;
import com.yoho.activity.service.ICouponActivityService;
import com.yoho.core.redis.YHValueOperations;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.request.YohoCoinCostReqBO;
... ... @@ -27,6 +29,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 描述:品牌抽奖活动
... ... @@ -51,6 +54,14 @@ public class BrandActivityServiceImpl implements IBrandActivityService {
@Resource
private ServiceCaller serviceCaller;
@Resource(name = "yhValueOperations")
private YHValueOperations<String, String> yhValueOperations;
private static String BRAND_ACTIVITY_DRAW="yh:activity:brand:drawlist";
private static String BRAND_ACTIVITY_DRAW_DETAIL="yh:activity:brand:drawdetail:";
/**
* 根据当前时间查询品牌活动奖项列表
*
... ... @@ -61,15 +72,41 @@ public class BrandActivityServiceImpl implements IBrandActivityService {
public List<ActNewBrandBo> getBrandActList() throws ServiceException {
//获取当前时间
String dt = DateUtils.getToday(DateUtils.DAY_FOMARTPATTER);
List<ActNewBrand> actNewBrandList = actNewBrandMapper.selectListByTime(dt);
logger.info("getBrandActList db res={}", JSON.toJSONString(actNewBrandList));
List<ActNewBrand> actNewBrandList = null;
try {
actNewBrandList= CacheKeyHelper.string2Value(yhValueOperations.get(BRAND_ACTIVITY_DRAW),List.class);
}catch (Exception e){
logger.warn("getBrandActList cache error={}", e);
}
if(actNewBrandList==null){
actNewBrandList = actNewBrandMapper.selectListByTime(dt);
try {
yhValueOperations.set(BRAND_ACTIVITY_DRAW, CacheKeyHelper.value2String(actNewBrandList),1, TimeUnit.MINUTES);
}catch (Exception e){
logger.warn("getBrandActList cache error={}", e.getMessage());
}
}
logger.info("getBrandActList res={}", JSON.toJSONString(actNewBrandList));
List<ActNewBrandBo> actNewBrandBoList = BeanTool.copyList(actNewBrandList, ActNewBrandBo.class);
return actNewBrandBoList;
}
@Override
public ActNewBrandBo getBrandActInfoById(Integer id) throws ServiceException {
ActNewBrand actNewBrand = actNewBrandMapper.selectByPrimaryKey(id);
ActNewBrand actNewBrand = null;
try {
actNewBrand= CacheKeyHelper.string2Value(yhValueOperations.get(BRAND_ACTIVITY_DRAW_DETAIL),ActNewBrand.class);
}catch (Exception e){
logger.warn("getBrandActInfoById cache error={}", e);
}
if(actNewBrand==null){
actNewBrand = actNewBrandMapper.selectByPrimaryKey(id);
try {
yhValueOperations.set(BRAND_ACTIVITY_DRAW_DETAIL, CacheKeyHelper.value2String(actNewBrand),1, TimeUnit.MINUTES);
}catch (Exception e){
logger.warn("getBrandActList cache error={}", e.getMessage());
}
}
ActNewBrandBo actNewBrandBo = BeanTool.copyObject(actNewBrand, ActNewBrandBo.class);
return actNewBrandBo;
}
... ...
... ... @@ -16,6 +16,7 @@
<script>
var aArr = new Array();//每个盒子的点击状态
var boxNumLimit = 9;//箱子个数
var uid;
$(
function () {
... ... @@ -24,10 +25,10 @@
$.getJSON(dataRequestUrl+"?callback=?",
function(json) {
if (json.code === 200) {
alert('登录成功!!!!ID:' + json.data);
uid=json.data;
} else {
alert("请先登录!!!");
var url = `https://m.yohobuy.com/signin.html?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/localhost\/%E6%8A%BD%E5%A5%96%E6%B4%BB%E5%8A%A8v3\/index.html","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"Y"}}`;
var url ='https://m.yohobuy.com/signin.html?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":'
+'/activity/brand/index.html'+'","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"Y"}}';
window.location.href=url;
}
}
... ... @@ -46,15 +47,14 @@
var arr = data.data;
if (aArr[liNnm] === 0) {
aArr[liNnm] = 1;
opened(liNnm);
if (arr.prize == 1) {
var newCover = awaCover(arr.prizeRemark);
var res = addPrize(88, arr.id);
var res = addPrize(uid, arr.id);
if (res.code == 200) {
$("body").append(newCover);
} else {
}
$("body").append(noAwa());
}
} else {
var newCover = noAwa();
$("body").append(newCover);
... ... @@ -73,22 +73,6 @@
}
);
//测试用,假数据
/* var dataRequestUrl="http://new.yohoboys.com/customerevent/default/page";
var _cid=0;
$.getJSON(dataRequestUrl+"?cid="+_cid+"&offset=0"+"&callback=?",
function(json) {
var arr=JSON.parse(json);
for(var i=0; i<boxNumLimit; i++){
aArr[i] = 0;
var _obj=arr[i];
$(".a-box-ul").append('<li awa="no"><img src='+_obj.pic+' /></li>');
$(".awa-list-ul ul").append('<li><span>'+ _obj.title+'</span><span>2016/08/08 16:00</span></li>');
$(".act-list-ul").append('<a><li>'+ _obj.title+'</li></a>');
}
}
);*/
$.ajax({
url: '/activity/brandDraw/getBrandActList',
type: "get",
... ... @@ -113,14 +97,16 @@
$(function () {
$(".check-awa-btn").live("click", function () {
$(".awa-list-ul ul").empty();
$.ajax({
url: '/activity/brandDraw/getBrandPrizeListByUid?uid=' + 2,
url: '/activity/brandDraw/getBrandPrizeListByUid?uid=' + uid,
type: "get",
contentType: "application/json",
dataType: 'json',
success: function (data) {
if (data.code === 200) {
var arr = data.data;
$(".awa-list-ul ul").empty();
for (var i = 0; i < arr.length; i++) {
var _obj = arr[i];
if (_obj != null) {
... ... @@ -128,7 +114,6 @@
if (dtime > 0) {
var strTime = new Date(parseInt(dtime) * 1000).toISOString().slice(0, 16).replace("T", " ");
}
$(".awa-list-ul ul").empty();
$(".awa-list-ul ul").append('<li><span>' + _obj.prizeRemark + '</span><span>' + strTime + '</span></li>');
$(".act-list-ul").append('<a><li>' + _obj.brandInfo + '</li></a>');
}
... ...
... ... @@ -96,8 +96,8 @@ function noAwa() {
'<div class="dia-bg"></div>'
return cHtml;
}
function opened(thisBox){
function opened(thisBox,imgurl){
$(".a-box-ul li:eq("+ thisBox +")").find("img").remove();
$(".a-box-ul li:eq("+ thisBox +")").append("<img src='images/awa.png' />");
$(".a-box-ul li:eq("+ thisBox +")").append("<img src="+imgurl+" />");
}
... ...
... ... @@ -398,7 +398,8 @@
<script type="text/javascript" src="http://cdn.yoho.cn/huodong/libs/jquery.min.js"></script>
<script type="text/javascript">
var voteNum = 0;//已选投票数目
var limitVoteNum = 3;//最大投票数目
//活动细则
$('.detail_click').click(function(){
if($(this).hasClass('isclick')){
... ... @@ -419,34 +420,58 @@
}else{
e.currentTarget.classList.add('vote_click');
}
voteNum = $(".vote_click").length;
if (voteNum <= limitVoteNum) {
//alert(voteNum);
} else {
alert("最多只能选3个!!!");
$(this).removeClass("vote_click");
}
});
//AJAX获取数据
$.ajax({
url:"",
type:"post",
data:"",
success: function () {
// $.ajax({
// url:"",
// type:"post",
// data:"",
// success: function () {
},
error:function(){
// },
// error:function(){
},
complete:function(){
// },
// complete:function(){
}
// }
});
// });
//确认投票
//判定登录,确认投票
$('#float_bottom').click(function(){
var dataRequestUrl="http://m.yohobuy.com/passport/login/user";
$.getJSON(dataRequestUrl+"?callback=?",
function(json) {
if (json.code === 200) {
var num=$('.vote_click').length;
// alert(num);
if(num>3){
//alert(num);
if(num>limitVoteNum){
alert('您最多只能选择三位设计师!');
}else{
alert('投票成功!');
}else if(num<=0){
alert('至少选一位!');
} else{
var arr = new Array(num);
for (var i = 0; i < num; i ++) {
arr[i] = $('.vote_click:eq('+ i +')').attr("id");
}
alert('投票成功!投票账号a为:' + json.data + ',投票数为:' + num + ',所投id是:' + arr);
}
} else {
alert("请先登录!!!");
var url = `https://m.yohobuy.com/signin.html?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/localhost\/YOHOPE\/index.html","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"Y"}}`;
window.location.href=url;
}
}
);
});
... ...
... ... @@ -160,21 +160,35 @@ img{
<div style="height:167px; width: 100%; background:#ffffff;text-align: center;">
<input type="button" class="vote_button" />
</div>
<script type="text/javascript" src="http://cdn.yoho.cn/huodong/libs/jquery.min.js"></script>
<script>
$(
function () {
$(".vote_button").click(
function () {
}
);
}
);
</script>
<script type="text/javascript" src="http://cdn.yoho.cn/huodong/libs/jquery.min.js"></script>
<script type="text/javascript">
<script type="text/javascript">
var voteNum = 0;//已选投票数目
var maxVoteNum = 3;//最大投票数目
//活动细则
$('.detail_click').click(function(){
if($(this).hasClass('isclick')){
$('.detail').slideUp(500);
$(this).css("background-image","url(images/bg_04.jpg)");
$(this).css("background-image", "url(images/bg_04.jpg)");
$(this).removeClass('isclick');
}else{
$('.detail').slideDown(500);
... ... @@ -190,19 +204,63 @@ img{
}else{
e.currentTarget.classList.add('vote_click');
}
voteNum = $(".vote_click").length;
if (voteNum <= maxVoteNum) {
//alert(voteNum);
} else {
alert("最多只能选3个!!!");
$(this).removeClass("vote_click");
}
});
//确认投票
//判定登录,确认投票
$('.vote_button').click(function(){
var num=$('.vote_click').length;
// alert(num);
if(num>3){
alert('您最多只能选择三位设计师!');
}else{
alert('投票成功!');
var dataRequestUrl="http://m.yohobuy.com/passport/login/user";
$.getJSON(dataRequestUrl+"?callback=?",
function(json) {
if (json.code === 200) {
/* $.getJSON("activity/ActVoteResultController/getActVoteNumByUid?debug=XYZ?callback=?",
function (json){
if (json.code === 200) {
alert("ok");
}
}
); */
$.ajax({
type: "POST",
url: '/activity/ActVoteResultController/getActVoteNumByUid?debug=XYZ',
data: {"uid":99},
dataType: 'json',
success: function(result) {
alert("ok");
}
});
// var num=$('.vote_click').length;
// if(num>maxVoteNum){
// alert('您最多只能选择三位设计师!');
// }else if(num<=0){
// alert('至少选一位!');
// } else{
// var arr = new Array(num);
// for (var i = 0; i < num; i ++) {
// arr[i] = $('.vote_click:eq('+ i +')').attr("id");
// }
// alert('投票成功!投票账号a为:' + json.data + ',投票数为:' + num + ',所投id是:' + arr);
// }
} else {
alert("请先登录!!!");
window.location.href="https://www.yohobuy.com/signin.html?refer=http://localhost:8090/activity/brandVote/YOHOPEPC/index.html";
}
}
);
});
//统计点击量
(function(w, d, s, j, f) {
var a = d.createElement(s);
... ... @@ -220,6 +278,5 @@ img{
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas');
</script>
</body>
</html>
... ...