浏览代码

团购任务发布

Longlin 5 年之前
父节点
当前提交
bd7ee1f7b2

+ 119 - 10
whepi-ui/templates/yeweihui/tgPublish.ftl

@@ -8,16 +8,28 @@
     </div>
 
     <div class="weui-btn-area">
-
-        <p class="weui-media-box__desc">求助标题</p>
-        <h4 class="weui-media-box__title">sss</h4>
-        <br>
-        <p class="weui-media-box__desc">求助对象</p>
-        <h4 class="weui-media-box__title">sasa</h4>
-        <br>
-        <p class="weui-media-box__desc">求助内容</p>
-        <h4 class="weui-media-box__title">fda</h4>
-        <br>
+        <p class="weui-media-box__desc">组团标题:</p>
+        <input id="tg_input_title" class="weui-input" autofocus="" type="text" placeholder="请输入" maxlength="20" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;" />
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">供应商:</p>
+        <input id="tg_input_supplier" class="weui-input" autofocus="" type="text" placeholder="请输入" maxlength="20" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;" />
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">套餐:</p>
+        <input id="tg_input_goods" class="weui-input" autofocus="" type="text" placeholder="请输入" maxlength="50" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;" />
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">单价(元):</p>
+        <input id="tg_input_price" class="weui-input" autofocus="" type="number" placeholder="请输入" maxlength="50" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;" />
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">最小起订量(份):</p>
+        <input id="tg_input_mixnum" class="weui-input" autofocus="" type="number" placeholder="请输入" maxlength="50" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;" />
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">截止时间:</p>
+        <input id="tg_input_end_time" type="text" placeholder="请选择时间" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;"/>
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">预计送货时间:</p>
+        <input id="tg_input_deliver_time" type="text" placeholder="请选择时间" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;"/>
+        前
+        <p class="weui-media-box__desc" style="margin-top: 1vh;">服务电话:</p>
+        <input id="tg_input_phone_number" class="weui-input" autofocus="" type="text" placeholder="请输入" maxlength="50" style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh;" />
+        <div class="weui-btn-area">
+            <a id="tg_publish" class="weui-btn weui-btn_primary" style="width: 30%;">
+                发布
+            </a>
+        </div>
     </div>
 </div>
 
@@ -26,7 +38,104 @@
 <script>
     var userId = ${userId};
 
+    $("#tg_input_end_time").datetimePicker();
+    $("#tg_input_deliver_time").datetimePicker();
+
     function goback() {
         window.location.href = "/yeweihui/home.html?show=tuangou&userId=" + userId;
     }
+
+    $("#tg_publish").on('click', function () {
+
+        let title = $("#tg_input_title").val();
+        if (title.length <= 0) {
+            alert("请输入组团标题");
+            return;
+        }
+
+        let supplier = $("#tg_input_supplier").val();
+        if (supplier.length <= 0) {
+            alert("请输入供应商名称");
+            return;
+        }
+
+        let goods = $("#tg_input_goods").val();
+        if (goods.length <= 0) {
+            alert("请输入套餐内容");
+            return;
+        }
+
+        let price = $("#tg_input_price").val();
+        if (price.length <= 0) {
+            alert("请输入套餐单价");
+            return;
+        }
+
+        let mixnum = $("#tg_input_mixnum").val();
+        if (mixnum.length <= 0) {
+            alert("请输入最小起订量");
+            return;
+        }
+
+        let end_time = $("#tg_input_end_time").val();
+        if (end_time.length <= 0) {
+            alert("请选择截止时间");
+            return;
+        }
+
+        let deliver_time = $("#tg_input_deliver_time").val();
+        if (deliver_time.length <= 0) {
+            alert("请选择送货时间");
+            return;
+        }
+
+        let phone_number = $("#tg_input_phone_number").val();
+        if (phone_number.length <= 0) {
+            alert("请输入服务电话");
+            return;
+        }
+
+        console.log(
+            "发布",
+            title + "---" +
+            supplier + "---" +
+            goods + "---" +
+            price + "---" +
+            mixnum + "---" +
+            end_time + "---" +
+            deliver_time + "---" +
+            phone_number
+        );
+
+        let sendData = {
+            userId: userId,
+            tgTitle: title,
+            tgSupplier: supplier,
+            tgGoods: goods,
+            tgPrice: price,
+            tgMinNum: mixnum,
+            endTime: end_time,
+            deliverTime: deliver_time,
+            tgPhoneNumber: phone_number,
+
+        };
+
+        $.ajax({
+            url: '/yeweihui/tgPublish.json',
+            type: 'post',
+            data: sendData,
+            success: function (data) {
+                // console.log(data);
+                if (data.success) {
+                    window.location.href = "/yeweihui/home.html?show=tuangou&userId=" + userId;
+                }
+                else  {
+                    $.alert(data.data);
+                }
+            },
+            error: function () {
+                $.alert("网络异常");
+            }
+        });
+    })
 </script>

+ 30 - 104
whepi-ui/templates/yeweihui/tuangou.ftl

@@ -31,102 +31,22 @@
                         <div style="width: 15%; text-align: center;">状态</div>
                     </div>
                     <div id="tg_list1" class="weui-panel__bd">
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                            <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                            <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                            <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                            <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                        </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
+<#--                        <a href="javascript:void(0);" style="color: grey;">-->
+<#--                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">-->
+<#--                            <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>-->
+<#--                            <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>-->
+<#--                            <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>-->
+<#--                            <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>-->
+<#--                        </div>-->
+<#--                        </a>-->
+<#--                        <a href="javascript:void(0);" style="color: grey;">-->
+<#--                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">-->
+<#--                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>-->
+<#--                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>-->
+<#--                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>-->
+<#--                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>-->
+<#--                            </div>-->
+<#--                        </a>-->
                     </div>
                     <div class="weui-btn-area">
                         <a id="tg_publish" class="weui-btn weui-btn_primary">
@@ -150,15 +70,21 @@
                 </div>
 
                 <div class="weui-panel weui-panel_access">
+                    <div style="display: flex; flex-direction: row; color: grey; font-size: medium; line-height: 7vh;">
+                        <div style="width: 40%; text-align: center;">标题</div>
+                        <div style="width: 15%; text-align: center;">已团</div>
+                        <div style="width: 30%; text-align: center;">截止时间</div>
+                        <div style="width: 15%; text-align: center;">状态</div>
+                    </div>
                     <div id="tg_list2" class="weui-panel__bd">
-                        <a href="javascript:void(0);" style="color: grey;">
-                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">
-                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>
-                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>
-                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>
-                            </div>
-                        </a>
+<#--                        <a href="javascript:void(0);" style="color: grey;">-->
+<#--                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">-->
+<#--                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">蔬菜套餐,猪肉牛肉金针菇等</div>-->
+<#--                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">24/100</div>-->
+<#--                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">02/02 14:30</div>-->
+<#--                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">在团</div>-->
+<#--                            </div>-->
+<#--                        </a>-->
                     </div>
                     <div class="weui-btn-area">
                         <a id="tg_publish" class="weui-btn weui-btn_primary">

+ 120 - 1
whepi-ui/templates/yeweihui/tuangou.js

@@ -2,4 +2,123 @@ function tuangou_init(tt) {
     $('#tg_publish').on('click', function () {
         window.location.href = "/yeweihui/tgPublish.html?userId=" + $('#userId').val();
     });
-};
+
+    $.ajax({
+        url: '/yeweihui/tuangou/list/query.json',
+        type: 'post',
+        data: {
+            userId: $('#userId').val()
+        },
+        success: function (data) {
+            if (data.success) {
+                makeList(data.data);
+            }
+            else  {
+                $.alert("操作失败");
+            }
+        },
+        error: function () {
+            $.alert("网络异常");
+        }
+    });
+
+    $.ajax({
+        url: '/yeweihui/tuangou/mylist/query.json',
+        type: 'post',
+        data: {
+            userId: $('#userId').val()
+        },
+        success: function (data) {
+            if (data.success) {
+                makeMyPublishList(data.data);
+            }
+            else  {
+                $.alert("操作失败");
+            }
+        },
+        error: function () {
+            $.alert("网络异常");
+        }
+    });
+};
+
+function makeList(list) {
+    $('#tg_list1').empty();
+
+    if (list == undefined || list.length <= 0) {
+        $('#tg_list1').append('<div class="weui-loadmore weui-loadmore_line">\n' +
+            '    <span class="weui-loadmore__tips">暂无数据</span>\n' +
+            '</div>');
+        return;
+    }
+
+    for (let i = 0; i < list.length; i++) {
+        let item = list[i];
+        let status = '';
+        if (item.tgStatus == 1) {
+            status = "在团";
+        }
+        else if (item.tgStatus == 2) {
+            status = "发货";
+        }
+        else if (item.tgStatus == 3) {
+            status = "完成";
+        }
+        else if (item.tgStatus == 4) {
+            status = "取消";
+        }
+        $('#tg_list1').append($('<a href="javascript:tgItemSelect(' + "'" + item.jmId + "'" + ');" style="color: grey;">\n' +
+            '                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">\n' +
+            '                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgTitle + '</div>\n' +
+            '                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.currentNum + '/' + item.tgMinNum + '</div>\n' +
+            '                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgEndTime.toString() + '</div>\n' +
+            '                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + status + '</div>\n' +
+            '                            </div>\n' +
+            '                        </a>'));
+    }
+}
+
+function makeMyPublishList(list) {
+
+    $('#tg_list2').empty();
+
+    if (list == undefined || list.length <= 0) {
+        $('#tg_list2').append('<div class="weui-loadmore weui-loadmore_line">\n' +
+            '    <span class="weui-loadmore__tips">暂无数据</span>\n' +
+            '</div>');
+        return;
+    }
+
+    for (let i = 0; i < list.length; i++) {
+        let item = list[i];
+        let status = '';
+        if (item.tgStatus == 1) {
+            status = "在团";
+        }
+        else if (item.tgStatus == 2) {
+            status = "发货";
+        }
+        else if (item.tgStatus == 3) {
+            status = "完成";
+        }
+        else if (item.tgStatus == 4) {
+            status = "取消";
+        }
+        $('#tg_list2').append($('<a href="javascript:tgMyItemSelect(' + "'" + item.jmId + "'" + ');" style="color: grey;">\n' +
+            '                            <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">\n' +
+            '                                <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgTitle + '</div>\n' +
+            '                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.currentNum + '/' + item.tgMinNum + '</div>\n' +
+            '                                <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgEndTime.toString() + '</div>\n' +
+            '                                <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + status + '</div>\n' +
+            '                            </div>\n' +
+            '                        </a>'));
+    }
+}
+
+function tgItemSelect(jmId) {
+    console.log(jmId);
+}
+
+function tgMyItemSelect(jmId) {
+    console.log(jmId);
+}

+ 23 - 0
whepi-web/src/main/java/com/bofeng/dao/JmTuangouDao.java

@@ -0,0 +1,23 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.JmTuangou;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface JmTuangouDao extends BaseMapper<JmTuangou> {
+
+    List<JmTuangou> queryTuangouListByUptownId (@Param("uptownId") Long uptownId);
+
+    List<JmTuangou> queryTuangouListByUptownIdAndTitle (@Param("uptownId") Long uptownId, @Param("title") String title);
+
+    List<JmTuangou> queryTuangouListByUserId (@Param("userId") Long userId);
+
+    List<JmTuangou> queryTuangouListByUserIdAndTitle (@Param("userId") Long userId, @Param("title") String title);
+
+}

+ 13 - 0
whepi-web/src/main/java/com/bofeng/entity/JmTuangou.java

@@ -1,5 +1,7 @@
 package com.bofeng.entity;
 
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -51,16 +53,27 @@ public class JmTuangou implements Serializable {
      */
     private Integer tgMinNum;
 
+    @TableField(exist = false)
+    private Integer currentNum;
+
     /**
      * 团购截止时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
     private Date tgEndTime;
 
+    @TableField(exist = false)
+    private String endTime;
+
     /**
      * 预计送货时间
      */
+    @JsonFormat(pattern = "MM-dd HH:mm", timezone = "GMT+8")
     private Date tgDeliverTime;
 
+    @TableField(exist = false)
+    private String deliverTime;
+
     /**
      * 联系人电话
      */

+ 78 - 0
whepi-web/src/main/java/com/bofeng/service/JmTuangouService.java

@@ -0,0 +1,78 @@
+package com.bofeng.service;
+
+import com.baomidou.mybatisplus.toolkit.IdWorker;
+import com.bofeng.dao.JmTuangouDao;
+import com.bofeng.dao.YeweihuiSysOwnerMapper;
+import com.bofeng.dao.YeweihuiUserRoleMapper;
+import com.bofeng.entity.JmTuangou;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+@Service
+@Transactional(readOnly = true)
+public class JmTuangouService {
+
+    @Autowired
+    private JmTuangouDao jmTuangouDao;
+
+    @Autowired
+    private YeweihuiUserRoleMapper yeweihuiUserRoleMapper;
+
+    @Autowired
+    private YeweihuiSysOwnerMapper yeweihuiSysOwnerMapper;
+
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public Integer tuangouPublish(JmTuangou jmTuangou) {
+
+        jmTuangou.setJmId(IdWorker.getId());
+
+        Long propertyId = yeweihuiUserRoleMapper.queryPropertyIdByUserId(jmTuangou.getUserId());
+        Long uptownId = yeweihuiSysOwnerMapper.queryUptownIdByUserId(propertyId);
+        jmTuangou.setUptownId(uptownId);
+
+        jmTuangou.setTgStatus(1);
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+        Date tgEndTime = new Date();
+        Date tgDeliverTime = new Date();
+        try {
+            tgEndTime = sdf.parse(jmTuangou.getEndTime());
+            tgDeliverTime = sdf.parse(jmTuangou.getDeliverTime());
+        }
+        catch (ParseException e) {
+            e.printStackTrace();
+        }
+
+        jmTuangou.setTgEndTime(tgEndTime);
+        jmTuangou.setTgDeliverTime(tgDeliverTime);
+
+        return jmTuangouDao.insert(jmTuangou);
+    }
+
+    public List<JmTuangou> queryTuangouListByTitle(Long userId, String title) {
+
+        Long propertyId = yeweihuiUserRoleMapper.queryPropertyIdByUserId(userId);
+        Long uptownId = yeweihuiSysOwnerMapper.queryUptownIdByUserId(propertyId);
+
+        if (title.equals("")) {
+            return jmTuangouDao.queryTuangouListByUptownId(uptownId);
+        }
+        return jmTuangouDao.queryTuangouListByUptownIdAndTitle(uptownId, title);
+    }
+
+    public List<JmTuangou> queryTuangouMyListByTitle(Long userId, String title) {
+
+        if (title.equals("")) {
+            return jmTuangouDao.queryTuangouListByUserId(userId);
+        }
+        return jmTuangouDao.queryTuangouListByUserIdAndTitle(userId, title);
+    }
+}

+ 33 - 5
whepi-web/src/main/java/com/bofeng/wx/controller/YeWeiHuiController.java

@@ -4,10 +4,7 @@ import com.bofeng.dao.RbMapper;
 import com.bofeng.dao.UptownMapper;
 import com.bofeng.entity.*;
 import com.bofeng.excel.ExcelUtils;
-import com.bofeng.service.HomeService;
-import com.bofeng.service.QzTaskReplyService;
-import com.bofeng.service.QzTaskService;
-import com.bofeng.service.RbService;
+import com.bofeng.service.*;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -46,6 +43,9 @@ public class YeWeiHuiController {
     private HomeService homeService;
 
     @Autowired
+    private JmTuangouService jmTuangouService;
+
+    @Autowired
     private UptownMapper uptownMapper;
 
     @Autowired
@@ -272,9 +272,37 @@ public class YeWeiHuiController {
     }
 
     @GetMapping("/yeweihui/tgPublish.html")
-    public ModelAndView tuangouPublish(@Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
+    public ModelAndView tgPublish(@Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
         model.put("userId", "\""+userId+"\"");
 
         return new ModelAndView("/yeweihui/tgPublish.ftl", model);
     }
+
+    @PostMapping("/yeweihui/tgPublish.json")
+    public Model tuangouPublish(JmTuangou jmTuangou) {
+
+        Integer success = jmTuangouService.tuangouPublish(jmTuangou);
+        if (success == 1) {
+            return Model.newSuccess("操作成功");
+        }
+        else {
+            return Model.newFail("操作失败");
+        }
+    }
+
+    @PostMapping("/yeweihui/tuangou/list/query.json")
+    public Model queryTuangouListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) {
+
+        List<JmTuangou> list = jmTuangouService.queryTuangouListByTitle(userId, title);
+
+        return Model.newSuccess(list);
+    }
+
+    @PostMapping("/yeweihui/tuangou/mylist/query.json")
+    public Model queryTuangouMyListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) {
+
+        List<JmTuangou> myList = jmTuangouService.queryTuangouMyListByTitle(userId, title);
+
+        return Model.newSuccess(myList);
+    }
 }

+ 28 - 0
whepi-web/src/main/resources/mapper/JmTuangouMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bofeng.dao.JmTuangouDao">
+
+    <select id="queryTuangouListByUptownId" resultType="com.bofeng.entity.JmTuangou">
+        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        from jm_tuangou a
+        where uptown_id=#{uptownId}
+    </select>
+
+    <select id="queryTuangouListByUptownIdAndTitle" resultType="com.bofeng.entity.JmTuangou">
+        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        from jm_tuangou a
+        where uptown_id=#{uptownId} and tg_title like concat('%', #{title}, '%')
+    </select>
+
+    <select id="queryTuangouListByUserId" resultType="com.bofeng.entity.JmTuangou">
+        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        from jm_tuangou a
+        where user_id=#{userId}
+    </select>
+
+    <select id="queryTuangouListByUserIdAndTitle" resultType="com.bofeng.entity.JmTuangou">
+        select a.*, (select count(1) from jm_buy where jm_id=a.jm_id) as currentNum
+        from jm_tuangou a
+        where user_id=#{userId} and tg_title like concat('%', #{title}, '%')
+    </select>
+</mapper>