dev-discount
yuanye 3 years ago
commit 1f5614261b
  1. 28
      hai-bweb/src/main/java/com/bweb/controller/HighActivityController.java
  2. 46
      hai-cweb/src/main/java/com/cweb/controller/HighActivityController.java
  3. 5
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  4. 5
      hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java
  5. 3
      hai-service/src/main/java/com/hai/dao/HighActivityAwardSerialNumMapperExt.java
  6. 29
      hai-service/src/main/java/com/hai/dao/HighActivityAwardUserMapperExt.java
  7. 2
      hai-service/src/main/java/com/hai/dao/HighActivityInfoMapperExt.java
  8. 9
      hai-service/src/main/java/com/hai/service/HighActivityAwardUserService.java
  9. 8
      hai-service/src/main/java/com/hai/service/HighActivityPrizeService.java
  10. 5
      hai-service/src/main/java/com/hai/service/impl/HighActivityAwardUserServiceImpl.java
  11. 24
      hai-service/src/main/java/com/hai/service/impl/HighActivityPrizeServiceImpl.java
  12. 5
      hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java
  13. 6
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -1,11 +1,14 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.PageUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighActivityAward;
import com.hai.entity.HighActivityInfo;
@ -15,6 +18,7 @@ import com.hai.enum_type.ActivityInfoStatus;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.HighActivityAwardService;
import com.hai.service.HighActivityAwardUserService;
import com.hai.service.HighActivityInfoService;
import com.hai.service.HighActivityUserLotteryNumService;
import io.swagger.annotations.Api;
@ -50,6 +54,9 @@ public class HighActivityController {
@Resource
private HighActivityUserLotteryNumService highActivityUserLotteryNumService;
@Resource
private HighActivityAwardUserService highActivityAwardUserService;
@RequestMapping(value="/editActivityAward",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增中奖名次")
@ -128,5 +135,26 @@ public class HighActivityController {
}
}
@RequestMapping(value="/getWinLotteryList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询活动中奖记录")
public ResponseData getWinLotteryList(@RequestParam(name = "activityId", required = true) Long activityId,
@RequestParam(name = "userPhone", required = false) String userPhone,
@RequestParam(name = "awardName", required = false) String awardName,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
Map<String, Object> param = new HashMap<>();
param.put("userPhone", userPhone);
param.put("awardName", awardName);
PageHelper.startPage(pageSize,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highActivityAwardUserService.getWinLotteryUserList(activityId, param)));
} catch (Exception e) {
log.error("HighActivityController -> getWinLotteryList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,5 +1,6 @@
package com.cweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -14,10 +15,7 @@ import com.hai.entity.*;
import com.hai.enum_type.ActivityInfoStatus;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.HighActivityAwardService;
import com.hai.service.HighActivityAwardUserService;
import com.hai.service.HighActivityInfoService;
import com.hai.service.HighActivityUserLotteryNumService;
import com.hai.service.*;
import com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -57,6 +55,9 @@ public class HighActivityController {
@Resource
private HighActivityAwardUserService highActivityAwardUserService;
@Resource
private HighActivityPrizeService highActivityPrizeService;
@Resource
private HighActivityUserLotteryNumService highActivityUserLotteryNumService;
@ -132,7 +133,24 @@ public class HighActivityController {
if (activity != null) {
Map<String,Object> map = new HashMap<>();
map.put("activityInfo", activity);
map.put("activityAward", highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id")));
// 奖励
JSONArray awardList = JSONArray.parseArray(JSONArray.toJSONString(highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id"))));
for (Object awardObject : awardList) {
JSONObject award = (JSONObject) awardObject;
// 查询奖品
String prizeStr = "";
List<HighActivityPrize> list = highActivityPrizeService.getListByAwardId(award.getLong("id"));
for (HighActivityPrize prize : list) {
if (StringUtils.isBlank(prizeStr)) {
prizeStr = prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
} else {
prizeStr += "、"+prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
}
}
award.put("prizeStr", prizeStr);
}
map.put("activityAward", awardList);
return ResponseMsgUtil.success(map);
}
return ResponseMsgUtil.success(null);
@ -153,7 +171,23 @@ public class HighActivityController {
if (detail != null) {
Map<String,Object> map = new HashMap<>();
map.put("activityInfo", detail);
map.put("activityAward", highActivityAwardService.getListByActivityId(detail.getId()));
// 奖励
JSONArray awardList = JSONArray.parseArray(JSONArray.toJSONString(highActivityAwardService.getListByActivityId(activityId)));
for (Object awardObject : awardList) {
JSONObject award = (JSONObject) awardObject;
// 查询奖品
String prizeStr = "";
List<HighActivityPrize> list = highActivityPrizeService.getListByAwardId(award.getLong("id"));
for (HighActivityPrize prize : list) {
if (StringUtils.isBlank(prizeStr)) {
prizeStr = prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
} else {
prizeStr += "、"+prize.getPrizeName() +"("+ prize.getPrizeNum() +"张)";
}
}
award.put("prizeStr", prizeStr);
}
map.put("activityAward", awardList);
return ResponseMsgUtil.success(map);
}
return ResponseMsgUtil.success(null);

@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -285,6 +286,10 @@ public class HighOrderController {
return ResponseMsgUtil.success(highOrderService.getOrderById(highOrder.getId()));
} catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) {
log.error("HighActivityController -> userLottery() error!", "服务器繁忙");
return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null);
} catch (Exception e) {
log.error("HighOrderController -> addOrder() error!",e);
return ResponseMsgUtil.exception(e);

@ -23,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -75,6 +76,10 @@ public class HighUserDiscountController {
highDiscountUserRelService.receiveDiscount(userInfoModel.getHighUser().getId(), codeId);
return ResponseMsgUtil.success("领取成功");
} catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) {
log.error("HighActivityController -> userLottery() error!", "服务器繁忙");
return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null);
} catch (Exception e) {
log.error("HighDiscountController -> receiveDiscount() error!",e);
return ResponseMsgUtil.exception(e);

@ -4,4 +4,5 @@ package com.hai.dao;
* mapper扩展类
*/
public interface HighActivityAwardSerialNumMapperExt {
}
}

@ -18,4 +18,33 @@ public interface HighActivityAwardUserMapperExt {
" ORDER BY a.create_time desc LIMIT 50) a" +
" LEFT JOIN high_user b on b.id = a.user_id")
List<Map<String, Object>> selectWinLotteryList(@Param("activityId") Long activityId);
/**
* 查询活动中奖的用户
* @param activityId
* @param param
* @return
*/
@Select("<script>" +
" select " +
" b.phone userPhone," +
" b.`name` userName," +
" a.`name` awardName," +
" a.create_time winLotteryTime " +
" from " +
" (select a.user_id,b.name,a.create_time from high_activity_award_user a,high_activity_award b" +
" where " +
" a.activity_award_id = b.id " +
" and b.activity_info_id = #{activityId}" +
" <if test='param.awardName != null'> and b.`name` LIKE concat('%',#{param.awardName},'%') </if>" +
" GROUP BY a.id" +
" ORDER BY a.create_time desc) a" +
" LEFT JOIN high_user b on a.user_id = b.id" +
" where 1 = 1" +
" <if test='param.userPhone != null'> and b.phone = #{param.userPhone} </if>" +
"</script>")
List<Map<String, Object>> selectWinLotteryUserList(@Param("activityId") Long activityId, @Param("param") Map<String, Object> param);
}

@ -19,7 +19,7 @@ public interface HighActivityInfoMapperExt {
" WHERE" +
" a.activity_info_id = b.id " +
" AND a.product_type = 1 " +
" AND a.product_id = 23423538 " +
" AND a.product_id = #{couponId} " +
" AND b.`status` = 2" +
" AND NOW() >= b.start_time " +
" AND NOW() <= b.end_time" +

@ -20,4 +20,13 @@ public interface HighActivityAwardUserService {
* @return
*/
List<Map<String, Object>> getWinLotteryList(Long activityId);
/**
* 查询活动中奖记录
* @param activityId 活动id
* @param param 参数
* @return
*/
List<Map<String,Object>> getWinLotteryUserList(Long activityId,Map<String, Object> param);
}

@ -1,6 +1,6 @@
package com.hai.service;
import com.hai.entity.HighActivityAward;
import com.hai.entity.HighActivityPrize;
import java.util.List;
@ -10,5 +10,11 @@ import java.util.List;
*/
public interface HighActivityPrizeService {
/**
* 根据活动 查询奖励
* @param AwardId
* @return
*/
List<HighActivityPrize> getListByAwardId(Long activityAwardId);
}

@ -40,4 +40,9 @@ public class HighActivityAwardUserServiceImpl implements HighActivityAwardUserSe
public List<Map<String, Object>> getWinLotteryList(Long activityId) {
return highActivityAwardUserMapper.selectWinLotteryList(activityId);
}
@Override
public List<Map<String, Object>> getWinLotteryUserList(Long activityId, Map<String, Object> param) {
return highActivityAwardUserMapper.selectWinLotteryUserList(activityId,param);
}
}

@ -0,0 +1,24 @@
package com.hai.service.impl;
import com.hai.dao.HighActivityPrizeMapper;
import com.hai.entity.HighActivityPrize;
import com.hai.entity.HighActivityPrizeExample;
import com.hai.service.HighActivityPrizeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("highActivityPrizeService")
public class HighActivityPrizeServiceImpl implements HighActivityPrizeService {
@Resource
private HighActivityPrizeMapper highActivityPrizeMapper;
@Override
public List<HighActivityPrize> getListByAwardId(Long activityAwardId) {
HighActivityPrizeExample example = new HighActivityPrizeExample();
example.createCriteria().andActivityAwardIdEqualTo(activityAwardId).andStatusEqualTo(1);
return highActivityPrizeMapper.selectByExample(example);
}
}

@ -1,5 +1,6 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
@ -32,6 +33,9 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo
@Resource
private HighActivityAwardUserService highActivityAwardUserService;
@Resource
private HighActivityPrizeService highActivityPrizeService;
@Resource
private HighActivityUserLotteryNumMapper highActivityUserLotteryNumMapper;
@ -61,6 +65,7 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo
// 增加中奖记录
highActivityAwardUserService.insertAwardUser(serialNum.getId(),userId);
// 异步领取奖品,减少接口响应时间
new Thread(() -> {
// 领取奖品
receivePrize(serialNum,userId);

@ -20,6 +20,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -92,7 +93,9 @@ public class HighOrderServiceImpl implements HighOrderService {
private HighActivityUserLotteryNumService highActivityUserLotteryNumService;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
@Transactional(
isolation = Isolation.SERIALIZABLE,
propagation= Propagation.REQUIRES_NEW)
public void insertOrder(HighOrder highOrder) throws Exception {
highOrderMapper.insert(highOrder);
@ -129,6 +132,7 @@ public class HighOrderServiceImpl implements HighOrderService {
childOrder.setExt1(list.get(0).getExt1());
highChildOrderMapper.updateByPrimaryKey(childOrder);
}
if(!childOrder.getGiveawayType()) {
// 查看是否需要赠送卡卷
List<HighCouponHandselModel> handselListByCoupon = highCouponHandselService.getHandselListByCoupon(childOrder.getGoodsId());

Loading…
Cancel
Save