Просмотр исходного кода

Merge remote-tracking branch 'origin/release-201827-wangcz' into release-201827-wangcz

yangc 7 лет назад
Родитель
Сommit
7a8b6daef5

+ 30 - 1
src/main/java/com/uas/platform/b2c/common/lottery/controller/LotteryController.java

@@ -1,7 +1,9 @@
 package com.uas.platform.b2c.common.lottery.controller;
 
 import com.uas.platform.b2c.common.lottery.service.ActivityItemService;
+import com.uas.platform.b2c.common.lottery.service.PrizeService;
 import com.uas.platform.b2c.common.lottery.service.UserInfoService;
+import com.uas.platform.b2c.common.lottery.service.WinningHistoryService;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,10 +24,16 @@ public class LotteryController {
 
     private final ActivityItemService activityItemService;
 
+    private final PrizeService prizeService;
+
+    private final WinningHistoryService winningHistoryService;
+
     @Autowired
-    public LotteryController(UserInfoService userInfoService, ActivityItemService activityItemService) {
+    public LotteryController(UserInfoService userInfoService, ActivityItemService activityItemService, PrizeService prizeService, WinningHistoryService winningHistoryService) {
         this.userInfoService = userInfoService;
         this.activityItemService = activityItemService;
+        this.prizeService = prizeService;
+        this.winningHistoryService = winningHistoryService;
     }
 
     /**
@@ -48,4 +56,25 @@ public class LotteryController {
         return activityItemService.getActivityItems(activityCode);
     }
 
+    /**
+     * 获取当前等级奖品
+     * @param activityCode 活动编号
+     * @param itemCode 等级编号
+     * @return
+     */
+    @RequestMapping(value = "/user/prizes", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap getPrizesByUser(String activityCode, String itemCode) {
+        return prizeService.getPrizesByUser(activityCode, itemCode);
+    }
+
+    /**
+     * 获取获奖记录
+     * @param activityCode 活动编号
+     * @param size 条数
+     * @return
+     */
+    @RequestMapping(value = "/user/winninghistories", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap getWinningHistories(String activityCode, Integer size) {
+        return winningHistoryService.getWinningHistories(activityCode, size);
+    }
 }

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/PrizeService.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 17:34 wangyc
+ */
+public interface PrizeService {
+
+    /**
+     * 获取当前等级奖品
+     * @param activityCode 活动编号
+     * @param itemCode 等级编号
+     * @return
+     */
+    ResultMap getPrizesByUser(String activityCode, String itemCode);
+}

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/WinningHistoryService.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 18:45 wangyc
+ */
+public interface WinningHistoryService {
+
+    /**
+     * 获取获奖记录
+     * @param activityCode 活动编号
+     * @param size 条数
+     * @return
+     */
+    ResultMap getWinningHistories(String activityCode, Integer size);
+}

+ 3 - 3
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/ActivityItemServiceImpl.java

@@ -22,8 +22,8 @@ import org.springframework.util.StringUtils;
 @Service
 public class ActivityItemServiceImpl implements ActivityItemService {
 
-    // 获取单个用户信息路径
-    private static final String GET_USER_URL = "/activityItem/user";
+    // 获取单个用户等级信息路径
+    private static final String GET_ITEMS_USER_URL = "/activityItem/user";
 
     private final SysConf sysConf;
 
@@ -44,7 +44,7 @@ public class ActivityItemServiceImpl implements ActivityItemService {
         params.put("activityCode", activityCode);
 
         try {
-            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_USER_URL, params);
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_ITEMS_USER_URL, params);
             return JSON.parseObject(response.getResponseText(), ResultMap.class);
         } catch (Exception e) {
             return new ResultMap(CodeType.ERROR_STATE, "获取等级信息错误,请重试");

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

@@ -0,0 +1,54 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.platform.b2c.common.lottery.service.PrizeService;
+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.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 17:36 wangyc
+ */
+@Service
+public class PrizeServiceImpl implements PrizeService {
+
+    private final SysConf sysConf;
+
+    // 获取当前等级奖品路径
+    private static final String GET_PRIZES_USER_URL = "/prizes/user";
+
+    @Autowired
+    public PrizeServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap getPrizesByUser(String activityCode, String itemCode) {
+        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() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+        params.put("activityCode", activityCode);
+        params.put("itemCode", itemCode == null ? "" : itemCode);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_PRIZES_USER_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            return new ResultMap(CodeType.ERROR_STATE, "获取奖品信息错误,请重试");
+        }
+    }
+}

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

@@ -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, "获取中奖信息错误,请重试");
+        }
+    }
+}

+ 2 - 2
src/main/java/com/uas/platform/b2c/prod/store/facade/impl/StoreApplyFacadeImpl.java

@@ -44,8 +44,6 @@ public class StoreApplyFacadeImpl implements StoreApplyFacade {
 	@Override
 	public ResultMap handlerApply(String uuid, StoreApply.ApplyStatus status, StoreApply apply) {
 		// 通过uuid找到店铺申请信息
-		Date date = new Date();
-		StoreApply storeApply = storeApplyService.findByUuid(uuid);
 		User user = SystemSession.getUser();
 		if (user == null || user.getEnterprise() == null) {
 			return new ResultMap(CodeType.NOT_PERMIT, "请进行用户登录操作");
@@ -60,6 +58,7 @@ public class StoreApplyFacadeImpl implements StoreApplyFacade {
 		if (apply == null) {
 			return new ResultMap(CodeType.NO_INFO, "店铺申请信息不能为空");
 		}
+		StoreApply storeApply = storeApplyService.findByUuid(uuid);
 		// 检测资质信息
 		if (StoreApply.ApplyStatus.PASS == status) {
 			// TODO 检测企业信息以及品牌信息
@@ -102,6 +101,7 @@ public class StoreApplyFacadeImpl implements StoreApplyFacade {
 			}
 			storeApply.setReason(apply.getReason());
 		}
+		Date date = new Date();
 		// 保存审核时的审核人信息和是否通过状态
 		storeApply.setAuthPerson(user.getUserName());
 		storeApply.setAuthTime(date);

+ 2 - 3
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java

@@ -28,7 +28,6 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
-import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -103,12 +102,12 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 		}
 		// 检测是否存在待处理开铺申请
 		StoreApply existApply = storeApplyDao.findByEnUUAndStatus(user.getEnterprise().getUu(), StoreApply.ApplyStatus.PREPARE);
-		if(existApply != null) {
+		if (existApply != null) {
 			return new ResultMap(CodeType.SAVED, "AUTH_PREPARE");
 		}
 		// 检测是否存在待处理开铺申请
 		existApply = storeApplyDao.findByEnUUAndStatus(user.getEnterprise().getUu(), StoreApply.ApplyStatus.PASS);
-		if(existApply != null) {
+		if (existApply != null) {
 			return new ResultMap(CodeType.SAVED, "AUTH_PASS");
 		}
 

+ 2 - 4
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreInServiceImpl.java

@@ -126,9 +126,6 @@ public class StoreInServiceImpl implements StoreInService {
 		if (storeApply == null || storeApply.getEnUU() == null) {
 			return null;
 		}
-
-		StoreIn store;
-		Date date = new Date();
 		StoreIn existStore = storeDao.findByStoreName(storeApply.getStoreName());
 		if (existStore != null) {
 			throw new IllegalStatusException("店铺信息已经存在");
@@ -137,7 +134,8 @@ public class StoreInServiceImpl implements StoreInService {
 		if (existStore != null) {
 			throw new IllegalStatusException("店铺英文缩写已经存在");
 		}
-		store = new StoreIn();
+		StoreIn store = new StoreIn();
+		Date date = new Date();
 		if (StringUtils.isEmpty(storeApply.getStoreUuid())) {
 			store.setUuid(UuidUtils.generatedUuid());
 		} else {