Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	whepi-web/src/main/resources/application.yml
Longlin 5 years ago
parent
commit
24874deece

+ 1 - 1
whepi-doc/group.sql

@@ -9,7 +9,7 @@ create table jm_buy (
     buy_count       int(11)         NOT NULL DEFAULT 0          COMMENT '购买数量',
     buy_money       varchar(6)      NOT NULL DEFAULT 0.00       COMMENT '购买金额',
     phone           varchar(20)     NOT NULL DEFAULT ''         COMMENT '联系电话',
-    buy_status      int(11)         NOT NULL DEFAULT 0          COMMENT '状态 1 在团 2 发货 3取消 4撤销 5完成',
+    buy_status      int(11)         NOT NULL DEFAULT 1          COMMENT '状态 1 在团 2 撤单',
     my_remark       varchar(200)    NOT NULL DEFAULT ''         COMMENT '备注',
     user_create     bigint(20)      NOT NULL DEFAULT 0          COMMENT '新增人',
     time_create     datetime(0)     NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间(订单提交时间)',

+ 21 - 6
whepi-ui/templates/home/buy.ftl

@@ -91,7 +91,7 @@
                     '                    <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + v.tgTitle + '</div>\n' +
                     '                    <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' + v.count + '/' + v.tgMinNum + '</div>\n' +
                     '                    <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + timestampToTime(v.tgEndTime) + '</div>\n' +
-                    '                    <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + v.tgStatus + '</div>\n' +
+                    '                    <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + getStatus(v.tgStatus) + '</div>\n' +
                     '                </div>\n' +
                     '            </a>');
         }
@@ -130,19 +130,21 @@
                     '                        <div style="display: flex; flex-direction: row; text-align: center; font-size: x-small; line-height: 5vh;">\n' +
                     '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + v.tgTitle + '</div>\n' +
                     '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + timestampToTime(v.timeCreate) + '</div>\n' +
-                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + v.tgStatus + '</div>\n' +
-                    '                        </div>\n' +
-                    '                    </a>')
+                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">' + getStatus(v.tgStatus) + '</div>\n' +
+                    '                        </div>\n' + '                    </a>')
         }
 
         function myBuyClick2(v) {
-            window.location.href = "/home/buytc.html?userId=" + $('#userId').val()+ "&jmId=" + v.jmId+"&type="+2;
+            if (v.buyStatus != 1) {
+                return $.alert("该订单已经取消");
+            }
+            window.location.href = "/home/buytc.html?userId=" + $('#userId').val() + "&jmId=" + v.jmId + "&type=" + 2 + "&tgStatus=" + v.tgStatus;
         }
 
 
         /*居民求助信息*/
         function myBuyClick(v) {
-            window.location.href = "/home/buytc.html?userId=" + $('#userId').val() + "&jmId=" + v.jmId+"&type="+1;
+            window.location.href = "/home/buytc.html?userId=" + $('#userId').val() + "&jmId=" + v.jmId + "&type=" + 1 + "&tgStatus=" + v.tgStatus;
         }
 
 
@@ -155,4 +157,17 @@
                 return "<span style='color:green;'>已完成</span>";
             }
         }
+
+        //1 在团 2 发货 3完成 4取消',
+        function getStatus(v) {
+            if (v == 1) {
+                return "<span style='color:green;'>在团</span>";
+            } else if (v == 2) {
+                return "<span style='color:Black;'>发货</span>";
+            } else if (v == 3) {
+                return "完成";
+            } else if (v == 4) {
+                return "<span style='color:red;'>取消</span>";
+            }
+        }
     </script>

+ 89 - 89
whepi-ui/templates/home/buyClient.ftl

@@ -2,26 +2,29 @@
     <div style="display:flex; flex-direction: row; justify-content: space-between">
         <div class="weui-flex__item">
             <div class="placeholder" style="display: inline;align-items: flex-start">当前参团:</div>
-            <div style="display: inline;align-items: flex-start">107</div>
-        </div>
-        <div class="weui-flex__item" style="display:flex; flex-direction: row; justify-content: space-between">
-            <div style="display: inline;align-items: flex-end">状态:</div>
-            <div style="align-items: flex-end">在团</div>
+            <div style="display: inline;align-items: flex-start" id="Buycount"></div>
         </div>
     </div>
+
+    <div class="weui-flex__item">
+        <div style="display: inline;align-items: flex-end">状&nbsp;&nbsp;&nbsp;&nbsp;态:</div>
+        <div style="display: inline;" id="myStatus"></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: 20%;"
-                       maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');">
+                       maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1"
+                       onchange="changeBuy()">
             </div>
         </div>
-        <div class="weui-flex__item" style="display:flex; flex-direction: row; justify-content: space-between">
-            <div style="display: inline;align-items: flex-end">金额¥:</div>
-            <div style="display: inline;align-items: flex-end" id="myMenory">金额钱啊</div>
-        </div>
+    </div>
+    <div class="weui-flex__item" >
+        <div style="display: inline;">金&nbsp;&nbsp;&nbsp;&nbsp;额¥:</div>
+        <div style="display: inline;" id="myMenory"></div>
     </div>
     <div class="weui-flex">
         <div class="weui-flex__item">
@@ -40,47 +43,74 @@
     </div>
     <div style="display:flex; flex-direction: row; justify-content: space-between; margin-top: 1vh; margin-bottom: 5vh;">
     <#if type==1>
-      <a id="buyBack" onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
-         style="width: 30%;">返回</a>
+        <a id="buyBack" onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
+           style="width: 30%;">返回</a>
     <#else>
       <a id="MybuyRepeal" onclick="MybuyBack()" href="javascript:;" class="weui-btn weui-btn_default"
          style="width: 30%;">撤销</a>
     </#if>
         <a id="buyCommit" onclick="buyCommit()" href="javascript:;" class="weui-btn weui-btn_primary"
            style="margin-top: 0;width: 30%;">提交</a>
+
     </div>
 
 </div>
 <#include "/home/frag.foot.ftl" />
 <script>
 
+
+    (function ($) {
+        $.ajax({
+            url: '/query/getAll/status',
+            data: {
+                jmId: $('#jmBuy').val(),
+            },
+            type: 'GET',
+            success: function (data) {
+                console.log(data);
+                $("#Buycount").html(data.data.count)
+                $("#myStatus").html(getStatus(data.data.tgStatus))
+                /* $("#myMenory").html(data.data.tgPrice)*/
+            },
+            error: function () {
+            }
+        });
+    })(jQuery);
+
+
+
     <#--返回-->
     function buyBack() {
         window.location.href = "/user/homeIndex.html?userId=" + $('#buyuserId').val() + "&userType=" + 1 + '#tab3';
     }
 
     /*撤销*/
-    /*   function MybuyBack() {
-           $.ajax({
-               url: '/home/home/buyGroup',
-               data: {
-                   userId: $('#buyuserId').val(),
-                   buyCount: $('#buyCount').val(),
-                   phone: $('#myPhone').val(),
-                   remark: $('#Myremarks').val(),
-                   buyMoney: $('#myMenory').text(),
-                   jmId: $('#jmBuy').val(),
-               },
-               type: 'GET',
-               success: function (data) {
-                   console.log(data);
-                   buyBack();
-               },
-               error: function () {
-               }
-           });
-
-       }*/
+    function MybuyBack() {
+        $.ajax({
+            url: '/home/back/buyBack',
+            data: {
+                userId: $('#buyuserId').val(),
+                buyCount: $('#buyCount').val(),
+                phone: $('#myPhone').val(),
+                myRemark: $('#Myremarks').val(),
+                buyMoney: $('#myMenory').text(),
+                jmId: $('#jmBuy').val(),
+            },
+            type: 'GET',
+            success: function (data) {
+                console.log(data);
+                if (data.data == 1) {
+                    buyBack();
+                } else {
+                    $.alert("该套餐已过截止日期或者已发货中不允许撤单");
+                }
+
+            },
+            error: function () {
+            }
+        });
+
+    }
 
     //提交
     function buyCommit() {
@@ -92,23 +122,23 @@
             $.alert("请填写联系电话");
             return;
         }
-        if ($('#Myremarks').val() == undefined || $('#Myremarks').val() == '') {
-            $.alert("请填写备注");
-            return;
-        }
+        /* if ($('#Myremarks').val() == undefined || $('#Myremarks').val() == '') {
+             $.alert("请填写备注");
+             return;
+         }*/
         $.ajax({
             url: '/home/home/buyGroup',
             data: {
                 userId: $('#buyuserId').val(),
                 buyCount: $('#buyCount').val(),
                 phone: $('#myPhone').val(),
-                remark: $('#Myremarks').val(),
+                myRemark: $('#Myremarks').val(),
                 buyMoney: $('#myMenory').text(),
                 jmId: $('#jmBuy').val(),
             },
             type: 'GET',
             success: function (data) {
-                console.log(data);
+                console.log(data.data);
                 buyBack();
             },
             error: function () {
@@ -116,64 +146,34 @@
         });
     }
 
-    (function ($) {
-   /*     $.ajax({
-            url: '/home/querysj/buytj',
+    //输入购买的数量
+    function changeBuy() {
+        $.ajax({
+            url: '/query/getAll/status',
             data: {
-                userId: $('#buyuserId').val(),
                 jmId: $('#jmBuy').val(),
             },
             type: 'GET',
             success: function (data) {
-              var v=data.data;
-                $('#details').append('<div id="myyw">\n' +
-                        '            <div class="weui-loadmore weui-loadmore_line" style="text-align: center;size: 20px">\n' +
-                        '            <span class="weui-loadmore__tips">团购信息</span>\n' +
-                        '            <div class="weui-media-box__bd">\n' +
-                        '                <h3>青菜套餐</h3>\n' +
-                        '            </div>\n' +
-                        '        </div>\n' +
-                        '        <div>\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">供应商:&nbsp;&nbsp;</div>\n' +
-                        '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">套&nbsp;&nbsp;&nbsp;&nbsp;餐:&nbsp;&nbsp;没有套餐</div>\n' +
-                        '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">单&nbsp;&nbsp;&nbsp;&nbsp;价:&nbsp;&nbsp;10</div>\n' +
-                        '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">最新起定量(份):&nbsp;&nbsp;20</div>\n' +
-                        '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">截止时间:&nbsp;&nbsp;2020-02-11</div>\n' +
-                        '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">预计送货时间:&nbsp;&nbsp;2020-02-10</div>\n' +
-                        '\n' +
-                        '            <div style="text-indent: -0em;margin-left: 2em;">服务电话:&nbsp;&nbsp;12345678912</div>\n' +
-                        '        </div>\n' +
-                        '    </div>')
+                console.log(data);
+                $("#myMenory").html($('#buyCount').val() * data.data.tgPrice)
             },
             error: function () {
             }
-        });*/
-     <#if type==2>
-     $.ajax({
-         url: '/home/queryGroup/buyGroup',
-         data: {
-             userId: $('#buyuserId').val(),
-             jmId: $('#jmBuy').val(),
-         },
-         type: 'GET',
-         success: function (data) {
-             $('#buyCount').val(data.data.buyCount);
-             $('#myPhone').val(data.data.phone);
-             $('#Myremarks').val(data.data.myRemark);
-             $('#myMenory').text(data.data.buyMoney);
-
-         },
-         error: function () {
-         }
-     });
-     </#if>
-
-    })(jQuery);
+        });
+    }
 
 
+    //1 在团 2 发货 3完成 4取消',
+    function getStatus(v) {
+        if (v == 1) {
+            return "<span style='color:green;'>在团</span>";
+        } else if (v == 2) {
+            return "<span style='color:Black;'>发货</span>";
+        } else if (v == 3) {
+            return "完成";
+        } else if (v == 4) {
+            return "<span style='color:red;'>取消</span>";
+        }
+    }
 </script>

+ 64 - 57
whepi-ui/templates/home/buytc.ftl

@@ -4,43 +4,27 @@
 <div class="weui-tab__panel">
     <input id="buyuserId" type="text" hidden="hidden" value=${userId}>
     <input id="jmBuy" type="text" hidden="hidden" value=${jmId}>
+    <input id="tgStatusBuy" type="text" hidden="hidden" value=${tgStatus}>
 <#-- <div style="text-align: center ">
      团购信息
  </div>-->
 
-<#--业委会的套餐-->
-    <div id="details">
-        <div id="myyw">
-            <div class="weui-loadmore weui-loadmore_line" style="text-align: center;size: 20px">
-                <span class="weui-loadmore__tips">团购信息</span>
-                <div class="weui-media-box__bd">
-                    <h3>青菜套餐</h3>
+    <div class="page__bd">
+        <div class="weui-tab">
+        <#--业委会的套餐-->
+            <div id="details">
+                <div id="myyw">
                 </div>
-            </div>
-            <div>
-                <div style="text-indent: -0em;margin-left: 2em;">供应商:&nbsp;&nbsp;</div>
-
-                <div style="text-indent: -0em;margin-left: 2em;">套&nbsp;&nbsp;&nbsp;&nbsp;餐:&nbsp;&nbsp;没有套餐</div>
-
-                <div style="text-indent: -0em;margin-left: 2em;">单&nbsp;&nbsp;&nbsp;&nbsp;价:&nbsp;&nbsp;10</div>
-
-                <div style="text-indent: -0em;margin-left: 2em;">最新起定量(份):&nbsp;&nbsp;20</div>
-
-                <div style="text-indent: -0em;margin-left: 2em;">截止时间:&nbsp;&nbsp;2020-02-11</div>
-
-                <div style="text-indent: -0em;margin-left: 2em;">预计送货时间:&nbsp;&nbsp;2020-02-10</div>
-
-                <div style="text-indent: -0em;margin-left: 2em;">服务电话:&nbsp;&nbsp;12345678912</div>
-            </div>
-        </div>
-    <#--团购详情页面的展示-->
-        <div class="weui-btn-area">
-            <div style="text-align: center;size: 20px" class="weui-loadmore weui-loadmore_line">
-                <span class="weui-loadmore__tips">我的团购</span>
-            </div>
-        <#--居民自己填写的-->
-            <div id="client">
+            <#--团购详情页面的展示-->
+                <div class="weui-btn-area">
+                    <div style="text-align: center;size: 20px" class="weui-loadmore weui-loadmore_line">
+                        <span class="weui-loadmore__tips">我的团购</span>
+                    </div>
+                <#--居民自己填写的-->
+                    <div id="client">
             <#include "/home/buyClient.ftl"/>
+                    </div>
+                </div>
             </div>
         </div>
     </div>
@@ -57,34 +41,37 @@
             },
             type: 'GET',
             success: function (data) {
-                /* var v = data.data;
-                 $('#details').append('<div id="myyw">\n' +
-                         '            <div class="weui-loadmore weui-loadmore_line" style="text-align: center;size: 20px">\n' +
-                         '            <span class="weui-loadmore__tips">团购信息</span>\n' +
-                         '            <div class="weui-media-box__bd">\n' +
-                         '                <h3>青菜套餐</h3>\n' +
-                         '            </div>\n' +
-                         '        </div>\n' +
-                         '        <div>\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">供应商:&nbsp;&nbsp;</div>\n' +
-                         '\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">套&nbsp;&nbsp;&nbsp;&nbsp;餐:&nbsp;&nbsp;没有套餐</div>\n' +
-                         '\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">单&nbsp;&nbsp;&nbsp;&nbsp;价:&nbsp;&nbsp;10</div>\n' +
-                         '\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">最新起定量(份):&nbsp;&nbsp;20</div>\n' +
-                         '\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">截止时间:&nbsp;&nbsp;2020-02-11</div>\n' +
-                         '\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">预计送货时间:&nbsp;&nbsp;2020-02-10</div>\n' +
-                         '\n' +
-                         '            <div style="text-indent: -0em;margin-left: 2em;">服务电话:&nbsp;&nbsp;12345678912</div>\n' +
-                         '        </div>\n' +
-                         '    </div>')*/
+                var v = data.data;
+                console.log(v)
+                $('#myyw').append('<div id="myyw">\n' +
+                        '            <div class="weui-loadmore weui-loadmore_line" style="text-align: center;size: 20px">\n' +
+                        '            <span class="weui-loadmore__tips">团购信息</span>\n' +
+                        '            <div class="weui-media-box__bd">\n' +
+                        '                <h3>' + v.tgTitle + '</h3>\n' +
+                        '            </div>\n' +
+                        '        </div>\n' +
+                        '        <div>\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">供应商:&nbsp;&nbsp;' + v.tgSupplier + '</div>\n' +
+                        '\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">套&nbsp;&nbsp;&nbsp;&nbsp;餐:&nbsp;&nbsp;' + v.tgGoods + '</div>\n' +
+                        '\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' +
+                        '\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">截止时间:&nbsp;&nbsp;' + timestampToTime(v.tgEndTime) + '</div>\n' +
+                        '\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">预计送货时间:&nbsp;&nbsp;' + timestampToTime(v.tgDeliverTime) + '</div>\n' +
+                        '\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">服务电话:&nbsp;&nbsp;' + v.tgPhoneNumber + '</div>\n' +
+                        '            <div style="text-indent: -0em;margin-left: 2em;">备&nbsp;&nbsp;&nbsp;&nbsp;注:&nbsp;&nbsp;' + v.remark + '</div>\n'+
+                        '     </div>\n' +
+                        '    </div>')
             },
             error: function () {
             }
         });
+
      <#if type==2>
      $.ajax({
          url: '/home/queryGroup/buyGroup',
@@ -96,15 +83,35 @@
          success: function (data) {
              $('#buyCount').val(data.data.buyCount);
              $('#myPhone').val(data.data.phone);
-             $('#Myremarks').val(data.data.myRemark);
+             $('#Myremarks').text(data.data.myRemark);
              $('#myMenory').text(data.data.buyMoney);
-
          },
          error: function () {
          }
      });
+     //自己的列表的也不允许修改
+     /*if () {
+
+     }*/
      </#if>
+        //套餐不在团不允许添加修改
+        if ($('#tgStatusBuy').val() != 1) {
+            $('#buyCount').attr("disabled", "disabled");
+            $('#myPhone').attr("disabled", "disabled");
+            $('#Myremarks').attr("disabled", "disabled");
+        }
 
     })(jQuery);
 
+    function timestampToTime(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 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 s = (date.getSeconds() < 10) ? ('0' + date.getSeconds()) : (date.getSeconds());
+        return Y + M + D + h + m + s;
+    }
+
 </script>

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

@@ -22,10 +22,10 @@
             <div class="weui-tabbar__icon"><img src="/static/images/wx/customer_service.png" alt=""></div>
             <p class="weui-tabbar__label" onclick="familyClick()">家庭求助</p>
         </a>
-        <#--<a href="#tab3" class="weui-tabbar__item">
+        <a href="#tab3" class="weui-tabbar__item">
             <div class="weui-tabbar__icon"><img src="/static/images/wx/upload.png" alt=""></div>
             <p class="weui-tabbar__label" onclick="buyGroup()">商品团购</p>
-        </a>-->
+        </a>
     <#--<a href="#tab4" class="weui-tabbar__item">-->
     <#--<div class="weui-tabbar__icon"> <img src="./images/icon_nav_cell.png" alt=""> </div>-->
     <#--<p class="weui-tabbar__label">我</p>-->

+ 6 - 2
whepi-web/src/main/java/com/bofeng/dao/BuyMapper.java

@@ -13,11 +13,15 @@ import java.util.List;
 @Repository
 public interface BuyMapper extends BaseMapper<Buy> {
 
+  Buy selectBuyOne(@Param("userId") Long userId, @Param("jmId") Long jmId);
+
   List<JmTuangou> group(@Param("userId") Long userId);
 
   List<Buy> MyGroup(@Param("userId") Long userId);
 
-  Buy queryGroup(@Param("userId") Long userId,@Param("jmId")Long jmId);
+  Buy queryGroup(@Param("userId") Long userId, @Param("jmId") Long jmId);
+
+  JmTuangou selectGroup(@Param("userId") Long userId, @Param("jmId") Long jmId);
 
-  JmTuangou selectGroup(@Param("userId") Long userId,@Param("jmId")Long jmId);
+  Buy status(@Param("jmId") Long jmId);
 }

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

@@ -49,5 +49,9 @@ public class Buy {
 
   @TableField(exist = false)
   private Integer tgStatus;
+  @TableField(exist = false)
+  private Integer count;
+  @TableField(exist = false)
+  private String tgPrice;
 
 }

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

@@ -21,14 +21,14 @@ public class BuyService {
 
   @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
   public int buyGroup(Buy buy) {
-
+    Buy buy1 = buyMapper.selectBuyOne(buy.getUserId(), buy.getJmId());
+    if (buy1 != null) {
+      buy.setBuyId(buy1.getBuyId());
+      return buyMapper.updateById(buy);
+    }
     buy.setBuyId(IdWorker.getId());
     buy.setUserCreate(buy.getUserId());
     buy.setTimeCreate(new DateTime());
-    //在添加的时候 进行检测该团购是否在规定时间里 已经达到了最小起订量的要求
-/*    if () {
-
-    }*/
     buy.setBuyStatus(1);//在团
     return buyMapper.insert(buy);
   }
@@ -46,7 +46,25 @@ public class BuyService {
   }
 
 
-  public JmTuangou selectGroup(Long userId,Long jmId){
-    return buyMapper.selectGroup(userId,jmId);
+  public JmTuangou selectGroup(Long userId, Long jmId) {
+    return buyMapper.selectGroup(userId, jmId);
+  }
+
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+  public int buyBack(Buy buy) {
+    //在该套餐截止日期之前 并且是在团状态的才能撤单
+    JmTuangou jmTuangou = buyMapper.selectGroup(buy.getUserId(), buy.getJmId());
+    if (jmTuangou.getTgEndTime().getTime() >= new DateTime().getMillis() && jmTuangou.getTgStatus() == 1) {
+      Buy buy1 = buyMapper.selectBuyOne(buy.getUserId(), buy.getJmId());
+      buy.setBuyId(buy1.getBuyId());
+      buy.setBuyStatus(2);//撤单
+      return buyMapper.updateById(buy);
+    }
+    //不允许更改
+    return 2;
+  }
+
+  public Buy status(Buy buy) {
+    return buyMapper.status(buy.getJmId());
   }
 }

+ 14 - 13
whepi-web/src/main/java/com/bofeng/wx/controller/BuyController.java

@@ -28,10 +28,11 @@ public class BuyController {
 
   @GetMapping("/home/buytc.html")
   public ModelAndView buytc(@Pd(name = "userId") Long userId, @Pd(name = "jmId") Long jmId,
-                            @Pd(name = "type") Integer type, ModelMap model) {
+                            @Pd(name = "type") Integer type, @Pd(name = "tgStatus") Integer tgStatus, ModelMap model) {
     model.put("userId", userId);
     model.put("jmId", jmId);
     model.put("type", type);
+    model.put("tgStatus", tgStatus);
     return new ModelAndView("/home/buytc.ftl", model);
   }
 
@@ -52,17 +53,17 @@ public class BuyController {
   }
 
   @GetMapping("/home/querysj/buytj")
-  public ModelAndView buytj(@Pd(name = "userId") Long userId, @Pd(name = "jmId") Long jmId,ModelMap model){
-    JmTuangou jmTuangou = buyService.selectGroup(userId, jmId);
-    model.put("userId", userId);
-    model.put("jmId", jmId);
-    model.put("tgSupplier", jmTuangou.getTgSupplier());
-    model.put("tgGoods", jmTuangou.getTgGoods());
-    model.put("tgPrice", jmTuangou.getTgPrice());
-    model.put("tgMinNum", jmTuangou.getTgMinNum());
-    model.put("tgEndTime", jmTuangou.getTgEndTime());
-    model.put("tgDeliverTime", jmTuangou.getTgDeliverTime());
-    model.put("tgPhoneNumber", jmTuangou.getTgPhoneNumber());
-    return new ModelAndView("/home/buytc.ftl", model);
+  public Model<JmTuangou> buytj(@Pd(name = "userId") Long userId, @Pd(name = "jmId") Long jmId, ModelMap model) {
+    return Model.newSuccess(buyService.selectGroup(userId, jmId));
+  }
+
+  @GetMapping("/home/back/buyBack")
+  public ModelOps buyBack(Buy buy) {
+    return ModelOps.newSuccess(buyService.buyBack(buy));
+  }
+
+  @GetMapping("/query/getAll/status")
+  public Model<Buy> status(Buy buy) {
+    return Model.newSuccess(buyService.status(buy));
   }
 }

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

@@ -2,9 +2,14 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.bofeng.dao.BuyMapper">
 
+
+    <select id="selectBuyOne" resultType="com.bofeng.entity.Buy">
+        select * from jm_buy where user_id=#{userId} and jm_id=#{jmId}  and buy_status=1 limit 1
+    </select>
+
     <select id="group" resultType="com.bofeng.entity.JmTuangou">
        select *,
-       (select SUM(jb.buy_count) FROM jm_buy jb where jb.jm_id=jt.jm_id) as count
+       IFNULL((select SUM(jb.buy_count) FROM jm_buy jb where jb.jm_id=jt.jm_id and buy_status=1),0) as count
        FROM jm_tuangou jt
        where jt.uptown_id =(select c.uptown_id
        from sys_user_role a
@@ -14,10 +19,10 @@
     </select>
 
     <select id="MyGroup" resultType="com.bofeng.entity.Buy">
-        select DISTINCT a.tg_title,b.time_create,a.tg_status,a.jm_id
+        select DISTINCT a.tg_title,b.time_create,a.tg_status,a.jm_id,b.buy_status
         from  jm_tuangou a
         INNER JOIN jm_buy b on a.jm_id=b.jm_id
-        where a.user_id=#{userId}
+        where a.user_id=#{userId} and buy_status=1
     </select>
 
 
@@ -29,5 +34,12 @@
         select * from jm_tuangou where jm_id=#{jmId} limit 1
     </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
+      FROM jm_tuangou a
+      WHERE a.jm_id = #{jmId} limit 1
+    </select>
 
 </mapper>