Explorar el Código

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

Hu Jie hace 7 años
padre
commit
b601deda6a

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

+ 8 - 3
src/main/webapp/resources/js/usercenter/controllers/forstore/bomListDetailCtrl.js

@@ -10,7 +10,8 @@ define(['app/app'], function(app) {
             seekPurchase.getBomListDetail({bomId: $stateParams.id}, function (data) {
                 $scope.bomData = data;
                 if ($scope.bomData.seekPurchaseByBatchs) {
-                    angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item) {
+                    angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item, index) {
+                        item.$index = index;
                         item.$checked = false;
                         item.showSimilarCodeList = false;
                         item.showSimilarBrandList = false;
@@ -23,6 +24,11 @@ define(['app/app'], function(app) {
             })
         }
         loadData();
+        var initIndex = function () {
+            angular.forEach($scope.bomData.seekPurchaseByBatchs, function (item, index) {
+                item.$index = index;
+            });
+        }
         // 获取字符长度
         var getRealLen = function (str) {
             var len = 0;
@@ -222,7 +228,6 @@ define(['app/app'], function(app) {
 
         // 新增单条物料信息
         $scope.addNewMateriel = function () {
-            console.log($scope.bomData.seekPurchaseByBatchs)
             $scope.bomData.seekPurchaseByBatchs.unshift({
                 bomId: $scope.bomData.id,
                 brand: '',
@@ -236,9 +241,9 @@ define(['app/app'], function(app) {
                 isInBrandList: false,
                 amount: 0
             });
+            initIndex();
             $scope.tmpEditBom = angular.copy($scope.bomData);
             $scope.setAllCheck(true);
-            console.log($scope.bomData.seekPurchaseByBatchs, $scope.tmpEditBom.seekPurchaseByBatchs)
         };
 
         // 打开日期选择框

+ 28 - 28
src/main/webapp/resources/view/usercenter/forstore/bomListDetail.html

@@ -284,11 +284,11 @@
             </tr>
         </thead>
         <tbody>
-            <tr ng-repeat="detail in bomData.seekPurchaseByBatchs track by $index">
+            <tr ng-repeat="detail in bomData.seekPurchaseByBatchs track by detail.$index">
                 <td>
                     <label class="com-check-box">
-                        <input type="checkbox" id="{{$index}}" ng-click="initCheckAll()" ng-model="detail.$checked">
-                        <label for="{{$index}}"></label>
+                        <input type="checkbox" id="{{detail.$index}}" ng-click="initCheckAll()" ng-model="detail.$checked">
+                        <label for="{{detail.$index}}"></label>
                     </label>
                 </td>
                 <td class="base-info">
@@ -296,18 +296,18 @@
                         <div class="inline-block title">
                             <i class="must">*</i>品牌:
                         </div>
-                        <div class="inline-block" ng-class="{'similar-wrap': tmpEditBom.seekPurchaseByBatchs[$index].showSimilarBrandList}" title="{{detail.brand}}">
+                        <div class="inline-block" ng-class="{'similar-wrap': tmpEditBom.seekPurchaseByBatchs[detail.$index].showSimilarBrandList}" title="{{detail.brand}}">
                             <span ng-show="!editBom || !detail.$checked" ng-bind="detail.brand || '-'"></span>
                             <input ng-show="editBom && detail.$checked"
-                                   ng-model="tmpEditBom.seekPurchaseByBatchs[$index].brand"
-                                   ng-change="onBrandChange(tmpEditBom.seekPurchaseByBatchs[$index])"
-                                   ng-blur="checkBrand(tmpEditBom.seekPurchaseByBatchs[$index])"
+                                   ng-model="tmpEditBom.seekPurchaseByBatchs[detail.$index].brand"
+                                   ng-change="onBrandChange(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
+                                   ng-blur="checkBrand(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
                                    type="text">
                             <ul class="similar-list"
-                                ng-show="tmpEditBom.seekPurchaseByBatchs[$index].showSimilarBrandList"
-                                ng-mouseenter="tmpEditBom.seekPurchaseByBatchs[$index].isInBrandList = true;"
-                                ng-mouseleave="tmpEditBom.seekPurchaseByBatchs[$index].isInBrandList = false">
-                                <li ng-repeat="sBrand in similarBrand" ng-bind="sBrand.nameEn" title="{{sBrand.nameEn}}" ng-click="setBrand(tmpEditBom.seekPurchaseByBatchs[$index], sBrand.nameEn)"></li>
+                                ng-show="tmpEditBom.seekPurchaseByBatchs[detail.$index].showSimilarBrandList"
+                                ng-mouseenter="tmpEditBom.seekPurchaseByBatchs[detail.$index].isInBrandList = true;"
+                                ng-mouseleave="tmpEditBom.seekPurchaseByBatchs[detail.$index].isInBrandList = false">
+                                <li ng-repeat="sBrand in similarBrand" ng-bind="sBrand.nameEn" title="{{sBrand.nameEn}}" ng-click="setBrand(tmpEditBom.seekPurchaseByBatchs[detail.$index], sBrand.nameEn)"></li>
                             </ul>
                         </div>
                     </div>
@@ -318,9 +318,9 @@
                         <div class="inline-block" title="{{detail.kind}}">
                             <span ng-show="!editBom || !detail.$checked" ng-bind="detail.kind || '-'"></span>
                             <input ng-show="editBom && detail.$checked"
-                                   ng-model="tmpEditBom.seekPurchaseByBatchs[$index].kind"
-                                   ng-change="onKindChange(tmpEditBom.seekPurchaseByBatchs[$index])"
-                                   ng-blur="checkKind(tmpEditBom.seekPurchaseByBatchs[$index])"
+                                   ng-model="tmpEditBom.seekPurchaseByBatchs[detail.$index].kind"
+                                   ng-change="onKindChange(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
+                                   ng-blur="checkKind(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
                                    type="text">
                         </div>
                     </div>
@@ -330,18 +330,18 @@
                         <div class="inline-block title">
                             <i class="must">*</i>型号:
                         </div>
-                        <div class="inline-block" ng-class="{'similar-wrap': tmpEditBom.seekPurchaseByBatchs[$index].showSimilarCodeList}" title="{{detail.code}}">
+                        <div class="inline-block" ng-class="{'similar-wrap': tmpEditBom.seekPurchaseByBatchs[detail.$index].showSimilarCodeList}" title="{{detail.code}}">
                             <span ng-show="!editBom || !detail.$checked" ng-bind="detail.code || '-'"></span>
                             <input ng-show="editBom && detail.$checked"
-                                   ng-model="tmpEditBom.seekPurchaseByBatchs[$index].code"
-                                   ng-change="onCodeChange(tmpEditBom.seekPurchaseByBatchs[$index])"
-                                   ng-blur="checkCode(tmpEditBom.seekPurchaseByBatchs[$index])"
+                                   ng-model="tmpEditBom.seekPurchaseByBatchs[detail.$index].code"
+                                   ng-change="onCodeChange(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
+                                   ng-blur="checkCode(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
                                    type="text">
                             <ul class="similar-list"
-                                ng-show="tmpEditBom.seekPurchaseByBatchs[$index].showSimilarCodeList"
-                                ng-mouseenter="tmpEditBom.seekPurchaseByBatchs[$index].isInCodeList = true;"
-                                ng-mouseleave="tmpEditBom.seekPurchaseByBatchs[$index].isInCodeList = false">
-                                <li ng-repeat="sCode in similarCode" ng-bind="sCode.code" title="{{sCode.code}}" ng-click="setCode(tmpEditBom.seekPurchaseByBatchs[$index], sCode.code)"></li>
+                                ng-show="tmpEditBom.seekPurchaseByBatchs[detail.$index].showSimilarCodeList"
+                                ng-mouseenter="tmpEditBom.seekPurchaseByBatchs[detail.$index].isInCodeList = true;"
+                                ng-mouseleave="tmpEditBom.seekPurchaseByBatchs[detail.$index].isInCodeList = false">
+                                <li ng-repeat="sCode in similarCode" ng-bind="sCode.code" title="{{sCode.code}}" ng-click="setCode(tmpEditBom.seekPurchaseByBatchs[detail.$index], sCode.code)"></li>
                             </ul>
                         </div>
                     </div>
@@ -352,15 +352,15 @@
                         <div class="inline-block" title="{{detail.spec}}">
                             <span ng-show="!editBom || !detail.$checked" ng-bind="detail.spec || '-'"></span>
                             <input ng-show="editBom && detail.$checked"
-                                   ng-model="tmpEditBom.seekPurchaseByBatchs[$index].spec"
-                                   ng-change="onSpecChange(tmpEditBom.seekPurchaseByBatchs[$index])"
-                                   ng-blur="checkSpec(tmpEditBom.seekPurchaseByBatchs[$index])"
+                                   ng-model="tmpEditBom.seekPurchaseByBatchs[detail.$index].spec"
+                                   ng-change="onSpecChange(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
+                                   ng-blur="checkSpec(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
                                    type="text">
                         </div>
                     </div>
                 </td>
                 <td class="base-info pcs-line" style="position:relative;">
-                    <div class="content-clear" ng-if="!detail.id" ng-click="tmpEditBom.seekPurchaseByBatchs.splice($index, 1);bomData.seekPurchaseByBatchs.splice($index, 1)">
+                    <div class="content-clear" ng-if="!detail.id" ng-click="tmpEditBom.seekPurchaseByBatchs.splice(detail.$index, 1);bomData.seekPurchaseByBatchs.splice(detail.$index, 1)">
                         <i class="fa fa-close"></i>
                     </div>
                     <div class="content-line">
@@ -370,8 +370,8 @@
                         <div class="inline-block" title="{{detail.amount}}">
                             <span ng-show="!editBom || !detail.$checked" ng-bind="detail.amount || '-'"></span>
                             <input ng-show="editBom && detail.$checked"
-                                   ng-model="tmpEditBom.seekPurchaseByBatchs[$index].amount"
-                                   ng-change="onAmountChange(tmpEditBom.seekPurchaseByBatchs[$index])"
+                                   ng-model="tmpEditBom.seekPurchaseByBatchs[detail.$index].amount"
+                                   ng-change="onAmountChange(tmpEditBom.seekPurchaseByBatchs[detail.$index])"
                                    type="text">
                         </div>
                     </div>