parent
6ce150439e
commit
d993484392
@ -0,0 +1,70 @@ |
||||
package com.cweb.controller; |
||||
|
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.utils.CoordCommonUtil; |
||||
import com.hai.common.utils.PageUtil; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.HighActivityAward; |
||||
import com.hai.entity.HighActivityInfo; |
||||
import com.hai.entity.HighGasDiscountOilPrice; |
||||
import com.hai.entity.SecRegion; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.HighActivityAwardService; |
||||
import com.hai.service.HighActivityInfoService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* |
||||
* @author hurui |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/activity") |
||||
@Api(value = "活动业务接口") |
||||
public class HighActivityController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighActivityController.class); |
||||
|
||||
@Resource |
||||
private HighActivityInfoService highActivityInfoService; |
||||
|
||||
@Resource |
||||
private HighActivityAwardService highActivityAwardService; |
||||
|
||||
@RequestMapping(value="/getActivityByCoupon",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据卡券查询活动信息") |
||||
public ResponseData getActivityByCoupon(@RequestParam(name = "couponId", required = true) Long couponId) { |
||||
try { |
||||
|
||||
// 查询活动
|
||||
Map<String, Object> activity = highActivityInfoService.getNewActivityByCouponId(couponId); |
||||
if (activity != null) { |
||||
Map<String,Object> map = new HashMap<>(); |
||||
map.put("activityInfo", activity); |
||||
map.put("activityAward", highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id"))); |
||||
return ResponseMsgUtil.success(map); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(null); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighActivityController -> getActivityByCoupon() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -1,7 +1,35 @@ |
||||
package com.hai.dao; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface HighActivityInfoMapperExt { |
||||
} |
||||
|
||||
@Select( |
||||
" SELECT" + |
||||
" b.*" + |
||||
" FROM" + |
||||
" high_activity_partake_rule a," + |
||||
" high_activity_info b" + |
||||
" WHERE" + |
||||
" a.activity_info_id = b.id " + |
||||
" AND a.product_type = 1 " + |
||||
" AND a.product_id = 23423538 " + |
||||
" AND b.`status` = 2" + |
||||
" AND NOW() >= b.start_time " + |
||||
" AND NOW() <= b.end_time" + |
||||
" ORDER BY create_time desc" + |
||||
" LIMIT 1" |
||||
) |
||||
/** |
||||
* 根据卡券查询最新一条活动信息 |
||||
* @param couponId 卡券id |
||||
* @return |
||||
*/ |
||||
Map<String,Object> selectNewActivityByCouponId(@Param("couponId") Long couponId); |
||||
} |
||||
|
@ -0,0 +1,22 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighActivityAward; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 活动奖励 |
||||
* @author hurui |
||||
*/ |
||||
public interface HighActivityAwardService { |
||||
|
||||
/** |
||||
* 根据活动信息查询 |
||||
* @param activityId 活动基本信息 |
||||
* @return |
||||
*/ |
||||
List<HighActivityAward> getListByActivityId(Long activityId); |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.HighActivityAwardMapper; |
||||
import com.hai.entity.HighActivityAward; |
||||
import com.hai.entity.HighActivityAwardExample; |
||||
import com.hai.service.HighActivityAwardService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
|
||||
@Service("activityAwardService") |
||||
public class HighActivityAwardServiceImpl implements HighActivityAwardService { |
||||
|
||||
@Resource |
||||
private HighActivityAwardMapper highActivityAwardMapper; |
||||
|
||||
@Override |
||||
public List<HighActivityAward> getListByActivityId(Long activityId) { |
||||
HighActivityAwardExample example = new HighActivityAwardExample(); |
||||
example.createCriteria().andActivityInfoIdEqualTo(activityId).andStatusNotEqualTo(0); |
||||
return highActivityAwardMapper.selectByExample(example); |
||||
} |
||||
} |
Loading…
Reference in new issue