|
|
@@ -0,0 +1,51 @@
|
|
|
+package com.uas.platform.b2c.common.lottery.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.uas.platform.b2c.common.lottery.service.WinningHistoryService;
|
|
|
+import com.uas.platform.b2c.core.config.SysConf;
|
|
|
+import com.uas.platform.b2c.trade.support.CodeType;
|
|
|
+import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
+import com.uas.platform.core.util.HttpUtil;
|
|
|
+import com.uas.platform.core.util.HttpUtil.Response;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by wangyc on 2018/9/12.
|
|
|
+ *
|
|
|
+ * @version 2018/9/12 18:48 wangyc
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class WinningHistoryServiceImpl implements WinningHistoryService {
|
|
|
+
|
|
|
+ private final SysConf sysConf;
|
|
|
+
|
|
|
+ // 获取当前等级奖品路径
|
|
|
+ private static final String GET_WINNING_HOSTORIES_TOP_URL = "/winninghistorys/top";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public WinningHistoryServiceImpl(SysConf sysConf) {
|
|
|
+ this.sysConf = sysConf;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultMap getWinningHistories(String activityCode, Integer size) {
|
|
|
+ if (StringUtils.isEmpty(activityCode)) {
|
|
|
+ return new ResultMap(CodeType.PARAMETER_ERROR, "活动信息不完全,请确认活动信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("activityCode", activityCode);
|
|
|
+ params.put("size", size == null ? 20 : size);
|
|
|
+
|
|
|
+ try {
|
|
|
+ Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_WINNING_HOSTORIES_TOP_URL, params);
|
|
|
+ return JSON.parseObject(response.getResponseText(), ResultMap.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return new ResultMap(CodeType.ERROR_STATE, "获取中奖信息错误,请重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|