Ver código fonte

feat(lottery):新增推广活动获取用户个人信息接口

wangyc 7 anos atrás
pai
commit
6383d864b6

+ 36 - 0
src/main/java/com/uas/platform/b2c/common/lottery/controller/LotteryController.java

@@ -0,0 +1,36 @@
+package com.uas.platform.b2c.common.lottery.controller;
+
+import com.uas.platform.b2c.common.lottery.service.UserInfoService;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 推广抽奖活动接口
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 10:25 wangyc
+ */
+@RestController
+@RequestMapping(value = "/lottery")
+public class LotteryController {
+
+    private final UserInfoService userInfoService;
+
+    @Autowired
+    public LotteryController(UserInfoService userInfoService) {
+        this.userInfoService = userInfoService;
+    }
+
+    /**
+     * 获取单个用户信息
+     * @param activityCode 活动编号
+     * @return
+     */
+    @RequestMapping(value = "/userInfo", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap findUserInfo(String activityCode) {
+        return userInfoService.findUserInfo(activityCode);
+    }
+}

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/UserInfoService.java

@@ -0,0 +1,19 @@
+package com.uas.platform.b2c.common.lottery.service;
+
+import com.uas.platform.b2c.trade.support.ResultMap;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 10:28 wangyc
+ */
+public interface UserInfoService {
+
+    /**
+     * 获取单个用户信息
+     * @param activityCode 活动编号
+     * @return
+     */
+    ResultMap findUserInfo(String activityCode);
+
+}

+ 53 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/UserInfoServiceImpl.java

@@ -0,0 +1,53 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.platform.b2c.common.lottery.service.UserInfoService;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.ps.core.util.HttpUtil;
+import com.uas.ps.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 10:30 wangyc
+ */
+@Service
+public class UserInfoServiceImpl implements UserInfoService {
+
+    // 获取单个用户信息路径
+    private static final String GET_USER_URL = "/users/user";
+
+    private final SysConf sysConf;
+
+    @Autowired
+    public UserInfoServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap findUserInfo(String activityCode) {
+        if (StringUtils.isEmpty(activityCode)) {
+            return new ResultMap(CodeType.PARAMETER_ERROR, "活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("useruu", SystemSession.getUser().getUserUU());
+        params.put("enuu", SystemSession.getUser().getEnterprise().getUu() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+        params.put("activityCode", activityCode);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_USER_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            return new ResultMap(CodeType.ERROR_STATE, "获取用户信息错误,请重试");
+        }
+    }
+}

+ 14 - 0
src/main/java/com/uas/platform/b2c/core/config/SysConf.java

@@ -175,6 +175,12 @@ public class SysConf {
 	@Value(("#{sys.profile}"))
 	private String profile;
 
+	/**
+	 * 推广抽奖活动地址
+	 */
+	@Value(("#{sys.lottery}"))
+	private String lottery;
+
 	/**
 	 * 物料id
 	 */
@@ -394,6 +400,14 @@ public class SysConf {
 		return this;
 	}
 
+	public String getLottery() {
+		return lottery;
+	}
+
+	public void setLottery(String lottery) {
+		this.lottery = lottery;
+	}
+
 	public String getProductServiceIp() {
 		return productServiceIp;
 	}

+ 3 - 0
src/main/resources/dev/sys.properties

@@ -55,3 +55,6 @@ messageServiceUrl=http://192.168.253.12:24000/message/
 #b2b
 b2b=http://218.17.158.219/b2b_test
 b2bDomain=218.17.158.219:9000/b2b_test
+
+#lottery
+lottery=http://10.1.51.79:20000