Browse Source

求购模块

liusw 8 years ago
parent
commit
3108426743

+ 4 - 17
src/main/java/com/uas/platform/b2c/trade/seek/controller/SeekPurchaseController.java

@@ -47,27 +47,14 @@ public class SeekPurchaseController {
      *
      * @param params 分页参数
      * @param keyWord 型号或品牌
-     * @param deadline 截止日期
-     * @param status 报价状态
-     * @param minReleaseDate 最小发布时间
-     * @param maxReleaseDate 最大发布时间
-     * @param releaseDateSort 发布时间排序
-     * @param deadlineSort 截止日期排序
-     * @param offerAmountSort 报价次数排序
      * @return 分页数据
      */
     @RequestMapping(value = "/getSeekPageInfo", method = RequestMethod.GET)
-    public Page<SeekPurchase> getSeekPageInfo(PageParams params, String keyWord, String deadline,
-            Integer status, String minReleaseDate, String maxReleaseDate,
-            String releaseDateSort, String deadlineSort, String offerAmountSort) {
+    public Page<SeekPurchase> getSeekPageInfo(PageParams params, String keyWord) {
         logger.log("求购", "分页获取采购列表,参数为" + params);
-        User user = SystemSession.getUser();
         PageInfo info = new PageInfo(params);
         return seekPurchaseService
-                .getSeekPageInfo(info, keyWord, deadline, user == null ? null : user.getUserUU(),
-                        status, minReleaseDate,
-                        maxReleaseDate, releaseDateSort, deadlineSort,
-                        offerAmountSort);
+                .getSeekPageInfo(info, keyWord);
     }
 
     /**
@@ -103,9 +90,9 @@ public class SeekPurchaseController {
      * @return 更新后的求购信息
      */
     @RequestMapping(value = "/updateSeekPurchaseStatus", method = RequestMethod.PUT)
-    public SeekPurchase updateSeekPurchaseStatus(Long spId, Long ofId) {
+    public SeekPurchase updateSeekPurchaseStatus(Long spId, Long ofId, Integer purchaseQuantity) {
         logger.log("求购", "采纳报价,求购id:" + spId + ",报价id为" + ofId);
-        return seekPurchaseService.updateSeekPurchaseStatus(spId, ofId);
+        return seekPurchaseService.updateSeekPurchaseStatus(spId, ofId, purchaseQuantity);
     }
 
     /**

+ 10 - 0
src/main/java/com/uas/platform/b2c/trade/seek/model/SeekPurchase.java

@@ -143,6 +143,12 @@ public class SeekPurchase {
     @Column(name = "sp_boughtAmount")
     private Integer boughtAmount;
 
+    /**
+     * 剩余时间
+     */
+    @Transient
+    private Long remainingTime;
+
     public Long getId() {
         return id;
     }
@@ -295,4 +301,8 @@ public class SeekPurchase {
     public void setBoughtAmount(Integer boughtAmount) {
         this.boughtAmount = boughtAmount;
     }
+
+    public Long getRemainingTime() {
+        return deadline.getTime() - System.currentTimeMillis();
+    }
 }

+ 3 - 13
src/main/java/com/uas/platform/b2c/trade/seek/model/SeekPurchaseGoods.java

@@ -137,7 +137,7 @@ public class SeekPurchaseGoods {
      * 剩余时间
      */
     @Transient
-    private String remainingTime;
+    private Long remainingTime;
 
     public Long getSpId() {
         return spId;
@@ -291,17 +291,7 @@ public class SeekPurchaseGoods {
         this.releaseDate = releaseDate;
     }
 
-    public String getRemainingTime() {
-        long date = deadline.getTime() - System.currentTimeMillis();
-        long day = date / (1000 * 60 * 60 * 24);
-        long hour = (date / (1000 * 60 * 60) - day * 24);
-        if (day < 0 && hour < 0) {
-            remainingTime = "已截止";
-        } else if (day < 0) {
-            remainingTime = "剩余" + hour + "小时";
-        } else {
-            remainingTime = "剩余" + day + "天" + hour + "小时";
-        }
-        return remainingTime;
+    public Long getRemainingTime() {
+        return deadline.getTime() - System.currentTimeMillis();
     }
 }

+ 3 - 13
src/main/java/com/uas/platform/b2c/trade/seek/model/SeekPurchaseOfferGoods.java

@@ -156,7 +156,7 @@ public class SeekPurchaseOfferGoods {
      * 剩余时间
      */
     @Transient
-    private String remainingTime;
+    private Long remainingTime;
 
     public Long getId() {
         return id;
@@ -316,17 +316,7 @@ public class SeekPurchaseOfferGoods {
         this.deadline = deadline;
     }
 
-    public String getRemainingTime() {
-        long date = deadline.getTime() - System.currentTimeMillis();
-        long day = date / (1000 * 60 * 60 * 24);
-        long hour = (date / (1000 * 60 * 60) - day * 24);
-        if (day < 0 && hour < 0) {
-            remainingTime = "已截止";
-        } else if (day < 0) {
-            remainingTime = "剩余" + hour + "小时";
-        } else {
-            remainingTime = "剩余" + day + "天" + hour + "小时";
-        }
-        return remainingTime;
+    public Long getRemainingTime() {
+        return deadline.getTime() - System.currentTimeMillis();
     }
 }

+ 3 - 13
src/main/java/com/uas/platform/b2c/trade/seek/model/SeekPurchasePushGoods.java

@@ -146,7 +146,7 @@ public class SeekPurchasePushGoods {
      * 剩余时间
      */
     @Transient
-    private String remainingTime;
+    private Long remainingTime;
 
     public Long getSpId() {
         return spId;
@@ -309,17 +309,7 @@ public class SeekPurchasePushGoods {
         this.goEnUu = goEnUu;
     }
 
-    public String getRemainingTime() {
-        long date = deadline.getTime() - System.currentTimeMillis();
-        long day = date / (1000 * 60 * 60 * 24);
-        long hour = (date / (1000 * 60 * 60) - day * 24);
-        if (day < 0 && hour < 0) {
-            remainingTime = "已截止";
-        } else if (day < 0) {
-            remainingTime = "剩余" + hour + "小时";
-        } else {
-            remainingTime = "剩余" + day + "天" + hour + "小时";
-        }
-        return remainingTime;
+    public Long getRemainingTime() {
+       return deadline.getTime() - System.currentTimeMillis();
     }
 }

+ 2 - 4
src/main/java/com/uas/platform/b2c/trade/seek/service/SeekPurchaseService.java

@@ -23,9 +23,7 @@ public interface SeekPurchaseService {
      * @param pageInfo 分页信息
      * @return 采购列表
      */
-    Page<SeekPurchase> getSeekPageInfo(PageInfo pageInfo, String keyWord, String deadline, Long uu,
-            Integer status, String minReleaseDate, String maxReleaseDate, String releaseDateSort,
-            String deadlineSort, String offerAmountSort);
+    Page<SeekPurchase> getSeekPageInfo(PageInfo pageInfo, String keyWord);
 
     /**
      * 获取求购排行榜
@@ -48,7 +46,7 @@ public interface SeekPurchaseService {
      * @param ofId
      * @return
      */
-    SeekPurchase updateSeekPurchaseStatus(Long spId, Long ofId);
+    SeekPurchase updateSeekPurchaseStatus(Long spId, Long ofId, Integer purchaseQuantity);
 
 
     /**

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/seek/service/impl/SeekPurchaseOfferServiceImpl.java

@@ -108,7 +108,7 @@ public class SeekPurchaseOfferServiceImpl implements SeekPurchaseOfferService {
     public Map<String, Object> getSeekPurchaseRate(final Long uu) {
         // sql语句
         String sql =
-                "select offerAmount,IFNULL(acceptedAmount,0) as acceptedAmount,ifnull(FORMAT(acceptedAmount/offerAmount,2),0) "
+                "select offerAmount,IFNULL(acceptedAmount,0) as acceptedAmount,ifnull(FORMAT(acceptedAmount/offerAmount,2)*100,0) "
                         + "as rate from(select count(1) as offerAmount,sum(of_status=?) as acceptedAmount "
                         + "from trade$seek_purchase_offer where of_enuu=?) a";
         return jdbcTemplate.queryForMap(sql, new Object[]{Status.ACCEPTED.getValue(), uu});

+ 4 - 61
src/main/java/com/uas/platform/b2c/trade/seek/service/impl/SeekPurchaseServiceImpl.java

@@ -68,65 +68,8 @@ public class SeekPurchaseServiceImpl implements SeekPurchaseService {
     private SeekPurchaseGoodsDao seekPurchaseGoodsDao;
 
     @Override
-    public Page<SeekPurchase> getSeekPageInfo(final PageInfo pageInfo, String keyWord,
-            String deadline, Long uu, Integer status, String minReleaseDate,
-            String maxReleaseDate, String releaseDateSort, String deadlineSort,
-            String offerAmountSort) {
-//        // 关键词查询 品牌或者是型号
-//        if (!StringUtils.isEmpty(keyWord)) {
-//            SimpleExpression code = new SimpleExpression("code", keyWord, Operator.LIKE);
-//            SimpleExpression brand = new SimpleExpression("brand", keyWord, Operator.LIKE);
-//            SimpleExpression[] simpleExpressions = new SimpleExpression[]{code, brand};
-//            LogicalExpression logicalExpression = PredicateUtils.or(simpleExpressions);
-//            pageInfo.expression(logicalExpression);
-//        }
-//        // 截止时间查询
-//        if (!StringUtils.isEmpty(deadline)) {
-//            switch (deadline) {
-//                case "全部":
-//                    break;
-//                case "已截止":
-//                    pageInfo.expression(PredicateUtils.lte("deadline", new Date(), false));
-//                    break;
-//                default:
-//                    pageInfo.expression(PredicateUtils.gt("deadline", new Date(), false));
-//                    break;
-//            }
-//        } else {
-//            pageInfo.expression(PredicateUtils.gt("deadline", new Date(), false));
-//        }
-//        // 发布时间
-//        if (!StringUtils.isEmpty(minReleaseDate)) {
-//            pageInfo.expression(PredicateUtils.gte("releaseDate", minReleaseDate, false));
-//        }
-//        if (!StringUtils.isEmpty(maxReleaseDate)) {
-//            pageInfo.expression(PredicateUtils.lte("releaseDate", maxReleaseDate, false));
-//        }
-//
-//        // 求购状态
-//        if (status != null) {
-//            pageInfo.filter("status", status);
-//        }
-//
-//        // 买家中心
-//        if (uu != null) {
-//            pageInfo.filter("uu", uu);
-//        }
-//
-//        // 排序
-        if (!StringUtils.isEmpty(releaseDateSort)) {
-            pageInfo.sorting("releaseDate", Direction.fromString(releaseDateSort));
-        } else {
-            pageInfo.sorting("releaseDate", Direction.DESC);
-        }
-//
-//        if (!StringUtils.isEmpty(deadlineSort)) {
-//            pageInfo.sorting("deadline", Direction.fromString(deadlineSort));
-//        }
-//
-//        if (!StringUtils.isEmpty(offerAmountSort)) {
-//            pageInfo.sorting("offerAmount", Direction.fromString(offerAmountSort));
-//        }
+    public Page<SeekPurchase> getSeekPageInfo(final PageInfo pageInfo, String keyWord) {
+        pageInfo.expression(PredicateUtils.gt("deadline", new Date(), false));
         Page<SeekPurchase> pageSeeks = seekPurchasedao.findAll(new Specification<SeekPurchase>() {
             public Predicate toPredicate(Root<SeekPurchase> root, CriteriaQuery<?> query,
                     CriteriaBuilder builder) {
@@ -197,11 +140,11 @@ public class SeekPurchaseServiceImpl implements SeekPurchaseService {
     }
 
     @Override
-    public SeekPurchase updateSeekPurchaseStatus(Long spId, Long ofId) {
+    public SeekPurchase updateSeekPurchaseStatus(Long spId, Long ofId, Integer purchaseQuantity) {
         // 修改求购表的报价状态
         SeekPurchase seekPurchase = seekPurchasedao.findOne(spId);
         seekPurchase.setStatus(Status.ACCEPTED.getValue());
-        seekPurchase.setBoughtAmount(seekPurchase.getAmount());
+        seekPurchase.setBoughtAmount(purchaseQuantity);
         seekPurchase.setDeadline(new Date(System.currentTimeMillis()));
         seekPurchase = seekPurchasedao.save(seekPurchase);
         // 修改报价表的状态

+ 19 - 4
src/main/webapp/resources/js/usercenter/controllers/forstore/seek_purchase_ctrl.js

@@ -10,11 +10,26 @@ define(['app/app'], function(app) {
 
         // 发布求购
         $scope.release = function() {
-            // 校验
-          $scope.seek.deadline = new Date();
+          if (!$scope.seek.code) {
+            toaster.pop('error', "型号不能为空");
+            return;
+          }
+          if (!$scope.seek.brand) {
+            toaster.pop('error', "品牌不能为空");
+            return;
+          }
+          if (!$scope.seek.deadline) {
+            toaster.pop('error', "截止日期不能为空");
+            return;
+          }
+          if ($scope.seek.amount && $scope.seek.amount > 0 && $scope.seek.amount < 10000) {
+            toaster.pop('error', "请输入正确的数值");
+            return;
+          }
           seekPurchase.saveOneSeekPurchase($scope.seek,function(data){
             $scope.showUseFlag = false;
             $scope.seek = null;
+            $scope.seek.currency='RMB';
             $scope.seekPurchaseTableParams.reload();
             toaster.pop('success', '求购发布成功');
           }, function (res) {
@@ -26,7 +41,7 @@ define(['app/app'], function(app) {
       $scope.searchStatus = 0;
       $scope.seekPurchaseTableParams = new ngTableParams({
         page : 1,
-        count : 5
+        count : 10
       }, {
         total : 0,
         getData : function ($defer, params) {
@@ -57,7 +72,7 @@ define(['app/app'], function(app) {
 
       // 采纳报价
       $scope.adopt = function (){
-        seekPurchase.updateSeekPurchaseStatus({spId: $scope.currentOffer.spId, ofId: $scope.currentOffer.id},{}, function (data) {
+        seekPurchase.updateSeekPurchaseStatus({spId: $scope.currentOffer.spId, ofId: $scope.currentOffer.id, purchaseQuantity: $scope.purchaseQuantity},{}, function (data) {
           $scope.currentOffer = null;
           $scope.seekPurchaseTableParams.reload();
           $scope.showUseFlag = false;

+ 3 - 3
src/main/webapp/resources/js/vendor/controllers/forstore/seek_purchase_ctrl.js

@@ -8,7 +8,7 @@ define(['app/app'], function(app) {
         // 获取当前卖家求购推送列表
         $scope.seekPurchaseTableParams = new ngTableParams({
           page : 1,
-          count : 5
+          count : 10
         }, {
           total : 0,
           getData : function ($defer, params) {
@@ -110,11 +110,11 @@ define(['app/app'], function(app) {
 
       /*获取时间戳代表的天数*/
       $scope.getDay = function (timeStamp) {
-        return Math.floor((timeStamp - new Date().getTime()) / (1000 * 60 * 60 * 24));
+        return Math.floor(timeStamp / (1000 * 60 * 60 * 24));
       }
       /*获取时间戳代表的小时*/
       $scope.getHours = function (timeStamp) {
-        return Math.floor(((timeStamp - new Date().getTime()) / (1000 * 60 * 60)) % 24);
+        return Math.floor((timeStamp / (1000 * 60 * 60)) % 24);
       }
 
       /*设置列表状态*/

+ 8 - 8
src/main/webapp/resources/view/usercenter/forstore/seekPurchase.html

@@ -390,11 +390,11 @@
                 <p>单个发布</p>
                 <div class="form-block">
                     <span><i>*</i>型号</span>
-                    <input type="text" class="form-group" ng-model="seek.code">
+                    <input type="text" class="form-group" ng-model="seek.code" maxlength="30" ng-class="{'has-success': checkSuccess, 'has-error': checkFailed}"/>
                 </div>
                 <div class="form-block">
                     <span><i>*</i>品牌</span>
-                    <input type="text" class="form-group" ng-model="seek.brand">
+                    <input type="text" class="form-group" ng-model="seek.brand" maxlength="20" ng-class="{'has-success': checkSuccess1, 'has-error': checkFailed1}">
                 </div>
                 <div class="form-block">
                     <span><i>*</i>截止日期</span>
@@ -406,7 +406,6 @@
                            min-date="startDate" current-text="今天" clear-text="清除" close-text="关闭"
                            ng-click="openDatePicker($event, condition, 'deadlineOpen',3)"
                            datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
-                           "
                     />
                 </div>
                 <div class="form-block">
@@ -427,7 +426,7 @@
                 </div>
                 <div class="form-block">
                     <span>生产日期</span>
-                    <input type="text" class="form-group" ng-model="seek.produceDate">
+                    <input type="text" class="form-group" ng-model="seek.produceDate" maxlength="20">
                 </div>
                 <a href="javascript:void(0)" ng-click="release()">发布求购</a>
             </div>
@@ -515,7 +514,8 @@
                 </td>
                 <td ng-bind="seek.encapsulation || '-'">盘装</td>
                 <td ng-bind="seek.produceDate || '-'">2012-12-12</td>
-                <td>剩余&nbsp;<span class="red-text">8</span>&nbsp;天</td>
+                <td class="left-time" ng-if="seek.remainingTime > 0">剩余&nbsp;<span ng-bind="getDay(seek.remainingTime)"></span>&nbsp;天&nbsp;<span ng-bind="getHours(seek.remainingTime)">5</span>&nbsp;小时</td>
+                <td class="left-time" ng-if="seek.remainingTime <= 0"><span>已截止</span></td>
                 <td ng-switch="seek.status">
                     <span ng-switch-when="200" style="color:red;">待报价</span>
                     <span ng-switch-when="201">已报价</span>
@@ -605,10 +605,10 @@
                                         <td width="173" ng-bind="(of.enterprise).enName"></td>
                                         <td width="186" class="red-text" ng-bind="of.minDay+'-'+of.maxDay">4-6</td>
                                         <td width="186"><span>{{of.currency + of.unitPrice | currencyStr}}</span></td>
-                                        <td width="212" ng-bind="of.produceDate | date: 'yyyy-MM-dd'"></td>
+                                        <td width="212" ng-bind="(of.produceDate | date: 'yyyy-MM-dd') || '-'"></td>
                                         <td width="221" class="operate">
                                             <a href = "of.user.usertTel">联系卖家 <img src="static/img/seekPurchase/link-buyer.png" alt=""></a>
-                                            <span ng-click="setShowUseFlag(true, of)">采纳报价</span>
+                                            <span ng-if="seek.status != 202" ng-click="setShowUseFlag(true, of)">采纳报价</span>
                                         </td>
                                     </tr>
                                     </tbody>
@@ -637,7 +637,7 @@
         <div class="content">
             <p><i class="fa fa-exclamation-circle"></i>是否要采纳此报价?</p>
             <div class="remind-line"><i class="red-text">*</i>点击【确认】后默认终止该求购</div>
-            <div class="input-line"><i class="red-text">*</i>采购数量&nbsp;<input type="number" placeholder="请输入采购数量" class="form-control"></div>
+            <div class="input-line"><i class="red-text">*</i>采购数量&nbsp;<input type="number" placeholder="请输入采购数量" class="form-control" ng-model="purchaseQuantity"></div>
             <div class="btn-line">
                 <a ng-click="setShowUseFlag(false)">取消</a>
                 <a ng-click="adopt()">确认</a>

+ 8 - 7
src/main/webapp/resources/view/vendor/forstore/purchaseOffer.html

@@ -446,7 +446,7 @@
                     <span ng-bind="seek.releaseDate | date:'HH:mm:ss'"></span>
                     <div class="seek-status">
                         <div ng-show="!seek.goodsEnuu" class="no-grounding">未上架</div>
-                        <a ng-show="!seek.goodsEnuu" href="vendor#/vendor_material">去上架>></a>
+                        <a ng-show="!seek.goodsEnuu" href="vendor#/vendor_material">产品管理>></a>
                         <div ng-show="seek.goodsEnuu">已上架</div>
                     </div>
                 </td>
@@ -460,7 +460,8 @@
                     <div ng-if="!seek.unitPrice || seek.unitPrice == null">-</div>
                     <span ng-if="seek.unitPrice">{{(seek.currency=='RMB'?'¥':'$')+seek.unitPrice | currencyStr}}</span>
                 </td>
-                <td class="left-time" ><span ng-if="seek.remainingTime == '已截止'" ng-bind="seek.remainingTime"></span></td>
+                <td class="left-time" ng-if="seek.remainingTime > 0">剩余&nbsp;<span ng-bind="getDay(seek.remainingTime)"></span>&nbsp;天&nbsp;<span ng-bind="getHours(seek.remainingTime)">5</span>&nbsp;小时</td>
+                <td class="left-time" ng-if="seek.remainingTime <= 0"><span>已截止</span></td>
                 <td class="operate" ng-switch="seek.status">
                     <a>联系买家 <img src="static/img/seekPurchase/link-buyer.png" alt=""></a>
                     <div  ng-switch-when="200" ng-click="setSeekActive(seek, true)">我要报价</div>
@@ -471,13 +472,13 @@
             <tr class="expand-row">
                 <td colspan="10">
                     <div style="width: 173px;">历史报价</div>
-                    <div style="width: 180px;">单价:<span>{{seek.seekPurchaseOffer.currency + seek.seekPurchaseOffer.unitPrice | currencyStr}}</span></div>
-                    <div style="width: 182px;">交期:<span ng-bind="seek.seekPurchaseOffer.minDay"></span>
+                    <div style="width: 180px;">单价:<span>{{seek.currency + seek.unitPrice | currencyStr}}</span></div>
+                    <div style="width: 182px;">交期:<span ng-bind="seek.minDay"></span>
                         -
-                        <span ng-bind="seek.seekPurchaseOffer.maxDay"></span>
-                        <span ng-if="seek.seekPurchaseOffer.minDay && seek.seekPurchaseOffer.maxDay">天</span>
+                        <span ng-bind="seek.maxDay"></span>
+                        <span ng-if="seek.minDay && seek.maxDay">天</span>
                     </div>
-                    <div style="width: 271px;">生产时间:{{seek.seekPurchaseOffer.produceDate || '-'}}</div>
+                    <div style="width: 271px;">生产时间:{{seek.produceDate || '-'}}</div>
                 </td>
             </tr>
             </tbody>

+ 2 - 1
src/main/webapp/resources/view/vendor/forstore/seekPurchase.html

@@ -396,7 +396,8 @@
                         <div ng-if="!seek.unitPrice || seek.unitPrice == null">-</div>
                         <span ng-if="seek.unitPrice">{{(seek.currency=='RMB'?'¥':'$')+seek.unitPrice | currencyStr}}</span>
                     </td>
-                    <td class="left-time" ><span ng-if="seek.remainingTime == '已截止'" ng-bind="seek.remainingTime"></span></td>
+                    <td class="left-time" ng-if="seek.remainingTime > 0">剩余&nbsp;<span ng-bind="getDay(seek.remainingTime)"></span>&nbsp;天&nbsp;<span ng-bind="getHours(seek.remainingTime)">5</span>&nbsp;小时</td>
+                    <td class="left-time" ng-if="seek.remainingTime <= 0"><span>已截止</span></td>
                     <td class="operate" ng-switch="seek.status">
                         <a>联系买家 <img src="static/img/seekPurchase/link-buyer.png" alt=""></a>
                         <div  ng-switch-when="200" ng-click="setSeekActive(seek, true)">我要报价</div>