ソースを参照

业主购买2月13号

guojing 5 年 前
コミット
cdfd25d861

+ 12 - 7
whepi-ui/templates/home/buy.ftl

@@ -103,9 +103,9 @@
             $('#buyAll').append(' <a href="javascript:void(0);" style="color: grey;font-size: large" data-id="form"\n' +
                     '                                             onclick=\'myBuyClick(' + JSON.stringify(v) + ')\'>\n' +
                     '                <div style="display: flex; flex-direction: row; text-align: center; font-size: x-small; line-height: 4vh;">\n' +
-                    '                    <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + v.tgTitle + '</div>\n' +
+                    '                    <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px;text-align: left;text-indent:25%;">' + v.tgTitle + '</div>\n' +
                     '                    <div style="width: 20%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">\n' + v.count + '/' + v.tgMinNum + '</div>\n' +
-                    '                    <div style="width: 35%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + v.tgEndTime + '</div>\n' +
+                    '                    <div style="width: 35%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + sub(v.tgEndTime) + '</div>\n' +
                     '                    <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + getStatus(v.tgStatus) + '</div>\n' +
                     '                <div class="weui-textarea-counter">\n' + '</div></div>\n' +
                     '            </a>');
@@ -143,7 +143,7 @@
         function MybuyList(v) {
             $('#MyBuyAll').append('<a href="javascript:void(0);" style="color: grey;font-size: large" data-id="form" onclick=\'myBuyClick2(' + JSON.stringify(v) + ')\'>\n' +
                     '                        <div style="display: flex; flex-direction: row; text-align: center; font-size: x-small; line-height: 4vh;">\n' +
-                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + v.tgTitle + '</div>\n' +
+                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px;text-align: left;text-indent:21%;">' + v.tgTitle + '</div>\n' +
                     '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + timestampY(v.timeCreate) + '</div>\n' +
                     '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 14px">' + getStatus(v.tgStatus) + '</div>\n' +
                     '                        </div>\n' + '                    </a>')
@@ -188,12 +188,17 @@
 
         function timestampY(timestamp) {
             var date = new Date(timestamp); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
-            var Y = date.getFullYear() + '/';
-            var M = ((date.getMonth() + 1) < 10) ? ('0' + (date.getMonth() + 1) + '/') : ((date.getMonth() + 1) + '/');
+            var Y = date.getFullYear() + '-';
+            var M = ((date.getMonth() + 1) < 10) ? ('0' + (date.getMonth() + 1) + '-') : ((date.getMonth() + 1) + '-');
             var D = (date.getDate() < 10) ? ('0' + date.getDate() + ' ') : (date.getDate() + ' ');
             var h = (date.getHours() < 10) ? ('0' + date.getHours() + ':') : (date.getHours() + ':');
-            var m = (date.getMinutes() < 10) ? ('0' + date.getMinutes() + ':') : (date.getMinutes() + ':');
+            var m = (date.getMinutes() < 10) ? ('0' + date.getMinutes() + '') : (date.getMinutes() + '');
             var s = (date.getSeconds() < 10) ? ('0' + date.getSeconds()) : (date.getSeconds());
-            return M + D + h + m + s;
+            return M + D + h + m;
+        }
+
+        //保留月日时间
+        function sub(v) {
+            return v.substring(5, v.length);
         }
     </script>

+ 20 - 4
whepi-ui/templates/home/buyClient.ftl

@@ -11,13 +11,17 @@
         <div style="display: inline;margin-top: 1vh;" id="myStatus"></div>
     </div>
 
+    <div class="weui-flex__item">
+        <div style="display: inline;align-items: flex-end">剩余套餐(份):</div>
+        <div style="display: inline;margin-top: 1vh;" id="tc"></div>
+    </div>
     <div class="weui-flex" style="display:flex; flex-direction: row; justify-content: space-between">
         <div class="weui-flex__item">
             <div style="display: inline;align-items: flex-start">我的团购:</div>
             <div style="display: inline;">
                 <input type="text" id="buyCount"
                        style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh; width: 50%;font-size: 16px;margin-top: 1vh;"
-                       maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1"
+                       onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1" maxlength="6"
                        onchange="changeBuy()">
             </div>
         </div>
@@ -76,6 +80,13 @@
                 $("#Buycount").html(data.data.count);
                 $("#myStatus").html(getStatus(data.data.tgStatus));
                 $("#myPhone").val(data.data.phone);
+                $("#tc").html(data.data.tgMaxNum - data.data.count);
+                if (data.data.myRemark != null)
+                    $('#Myremarks').text(data.data.myRemark);
+                if (data.data.buyMoney != null)
+                    $('#buyCount').val(data.data.buyCount);
+                if (data.data.buyMoney != null)
+                    $('#myMenory').text(data.data.buyMoney);
             },
             error: function () {
             }
@@ -149,11 +160,16 @@
                 myRemark: $('#Myremarks').val(),
                 buyMoney: $('#myMenory').text(),
                 jmId: $('#jmBuy').val(),
+                count: $('#tc').html(),
             },
             type: 'GET',
             async: false,
             success: function (data) {
                 console.log(data.data);
+                if (data.data == 3) {
+                    $.alert("团购数量已经超过最大上限");
+                    return false;
+                }
                 buyBack();
             },
             error: function () {
@@ -163,10 +179,10 @@
 
     //输入购买的数量
     function changeBuy() {
-        if ($('#buyCount').val() > 20 || $('#buyCount').val() < 1) {
+        if ($('#buyCount').val() < 1) {
             $('#buyCount').val('')
-            $.alert('请输入1到20以内的整数')
-            return ;
+            $.alert('请输入大于0的整数')
+            return;
         }
         $.ajax({
             url: '/query/getAll/status',

+ 2 - 1
whepi-ui/templates/home/buytc.ftl

@@ -60,8 +60,9 @@
                         '\n' +
                         '            <div style="text-indent: -0em;margin-left: 2em;">单&nbsp;&nbsp;&nbsp;&nbsp;价:&nbsp;&nbsp;' + v.tgPrice + '</div>\n' +
                         '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">最低起送:&nbsp;&nbsp;' + v.tgMinNum + '</div>\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">最低起送(份):&nbsp;&nbsp;' + v.tgMinNum + '</div>\n' +
                         '\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">最大上限(份):&nbsp;&nbsp;' + v.tgMaxNum + '</div>\n' +
                         '            <div style="text-indent: -0em;margin-left: 2em;">截止时间:&nbsp;&nbsp;' + v.tgEndTime + '</div>\n' +
                         '\n' +
                         '            <div style="text-indent: -0em;margin-left: 2em;">预计送货时间:&nbsp;&nbsp;' + v.tgDeliverTime + '</div>\n' +

+ 2 - 0
whepi-web/src/main/java/com/bofeng/entity/Buy.java

@@ -52,5 +52,7 @@ public class Buy {
   private Integer count;
   @TableField(exist = false)
   private String tgPrice;
+  @TableField(exist = false)
+  private Integer tgMaxNum;
 
 }

+ 25 - 17
whepi-web/src/main/java/com/bofeng/service/BuyService.java

@@ -28,8 +28,19 @@ public class BuyService {
   public int buyGroup(Buy buy) {
     Buy buy1 = buyMapper.selectBuyOne(buy.getUserId(), buy.getJmId());
     if (buy1 != null) {
-      buy.setBuyId(buy1.getBuyId());
-      return buyMapper.updateById(buy);
+      JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy1.getJmId());
+      Buy buy2 = buyMapper.selectById(buy1.getBuyId());
+      if (jmTuangou.getTgMaxNum().intValue() >= jmTuangou.getCurrentNum().intValue() - buy2.getBuyCount().intValue() + buy.getBuyCount().intValue()) {
+        buy.setBuyId(buy1.getBuyId());
+        return buyMapper.updateById(buy);
+      } else {
+        return 3;//不允许更改团购数量
+      }
+    }
+    //第一次购买团购数量大于最大上限数量不允许
+    JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy.getJmId());
+    if (jmTuangou.getTgMaxNum().intValue() < buy.getBuyCount().intValue()) {
+      return 3;
     }
     buy.setBuyId(IdWorker.getId());
     buy.setUserCreate(buy.getUserId());
@@ -82,12 +93,12 @@ public class BuyService {
   public int updateStatus() {
     List<JmTuangou> jmTuangous = jmTuangouDao.selectAll();
     if (jmTuangous != null && jmTuangous.size() > 0) {
-      //已经到截止时间
-      for (JmTuangou list : jmTuangous)
+      for (JmTuangou list : jmTuangous) {
+        // 团购数量  最小起订量
+        Buy buy = buyMapper.selectCountNum(list.getJmId());
+        //已经到截止时间
         if (list.getTgEndTime().getTime() < new DateTime().getMillis()) {
 
-          // 团购数量  最小起订量
-          Buy buy = buyMapper.selectCountNum(list.getJmId());
           if (buy != null) { //最小起订量
             if (list.getTgMinNum().intValue() > buy.getCount().intValue()) {
               jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
@@ -97,19 +108,16 @@ public class BuyService {
           } else {
             jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
           }
-      /*    if (buys != null && buys.size() > 0) {
-            for (Buy v : buys) {
-              if (v.getCount().intValue() < list.getTgMinNum().intValue()) {
-                jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
-              } else {
-                jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
-              }
+        } else {
+          //团购数量已经过了最大起订量的 就直接发货
+          if (buy != null) {
+            if (list.getTgMaxNum().intValue() == buy.getCount().intValue()) {
+              jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
             }
-          } else {
-            jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
-          }*/
-
+          }
         }
+
+      }
     }
     return 1;
   }

+ 2 - 2
whepi-web/src/main/resources/application-guojing.yml

@@ -65,8 +65,8 @@ spring:
     #driverClassName: com.mysql.jdbc.Driver
     #url: jdbc:mysql://localhost:3306/bofeng_test?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
     driverClassName: net.sf.log4jdbc.DriverSpy
-    url: jdbc:log4jdbc:mysql://39.99.148.1:3306/whepi_test?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
-    username: whepi_test
+    url: jdbc:log4jdbc:mysql://localhost:3306/whepi_test?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    username: root
     password: 123456
 
   redis:

+ 1 - 1
whepi-web/src/main/resources/application.yml

@@ -43,7 +43,7 @@ endpoints:
 #  whitelabel.enabled: false
 
 spring:
-  profiles.active: lll
+  profiles.active: guojing
 
   application:
     name: bofeng-web

+ 10 - 3
whepi-web/src/main/resources/mapper/BuyMapper.xml

@@ -32,9 +32,16 @@
     </select>
 
     <select id="status" resultType="com.bofeng.entity.Buy">
-       SELECT a.tg_status, a.tg_price, IFNULL(( SELECT SUM(b.buy_count) FROM jm_buy b WHERE a.jm_id = b.jm_id AND buy_status = 1 ), 0 ) AS count,
-       ( SELECT phone FROM sys_user_role aa INNER JOIN sys_uptown_home bb ON aa.property_id = bb.house_id WHERE aa.role_id = 1 AND aa.user_id = #{userId}
-       LIMIT 1 ) AS phone FROM jm_tuangou a WHERE a.jm_id = #{jmId} LIMIT 1
+       SELECT a.tg_status, a.tg_price,a.tg_max_num,b.buy_count,b.buy_money,b.my_remark,
+       IFNULL(( SELECT SUM(b.buy_count)
+       FROM jm_buy b WHERE a.jm_id = b.jm_id AND buy_status = 1 ), 0 ) AS count,
+       ( SELECT phone FROM sys_user_role aa
+       INNER JOIN sys_uptown_home bb ON aa.property_id = bb.house_id
+       WHERE aa.role_id = 1 AND aa.user_id = #{userId}
+       LIMIT 1 ) AS phone
+       FROM jm_tuangou a
+       LEFT JOIN jm_buy b on a.jm_id=b.jm_id and b.user_id=#{userId} and b.buy_status=1
+       WHERE a.jm_id = #{jmId} LIMIT 1
     </select>
 
     <select id="selectCountNum" resultType="com.bofeng.entity.Buy">