Forráskód Böngészése

业主购买2月10号

guojing 5 éve
szülő
commit
905a224d37

+ 2 - 2
whepi-doc/group.sql

@@ -7,10 +7,10 @@ create table jm_buy (
     jm_id           bigint(20)      NOT NULL DEFAULT 0          COMMENT '团购参团id',
     user_id         bigint(20)      NOT NULL DEFAULT 0          COMMENT '居民id',
     buy_count       int(11)         NOT NULL DEFAULT 0          COMMENT '购买数量',
-    buy_money       Decimal(4,2)    NOT NULL DEFAULT 0.00       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完成',
-    remark          varchar(200)    NOT NULL DEFAULT ''         COMMENT '备注',
+    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 '新增时间(订单提交时间)',
     PRIMARY KEY (buy_id) USING BTREE,

+ 24 - 41
whepi-ui/templates/home/buy.ftl

@@ -23,19 +23,6 @@
                     </div>
                 </div>
                 <div id="MyBuyAll">
-                    <a href="javascript:void(0);" style="color: grey;font-size: large">
-                        <div style="display: flex; flex-direction: row; text-align: center; font-size: x-small; line-height: 5vh;">
-                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">
-                                蔬菜套餐,猪肉牛肉金针菇等
-                            </div>
-                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">
-                                02/02 14:30
-                            </div>
-                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">
-                                在团
-                            </div>
-                        </div>
-                    </a>
                 </div>
             </div>
         </div>
@@ -49,7 +36,7 @@
             </div>
         </div>
         <div id="buyAll" class="weui-panel__bd">
-         <#--   <a href="javascript:void(0);" style="color: grey;font-size: large">
+        <#--   <a href="javascript:void(0);" style="color: grey;font-size: large">
                 <div style="display: flex; flex-direction: row; text-align: center; font-size: x-small; line-height: 5vh;"
                      onclick=" myBuyClick()">
                     <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">
@@ -72,6 +59,7 @@
     <script>
         //商品的团购信息的展示
         function buyGroup() {
+            console.log('商品团购')
             $('#buy_nav1')[0].style.display = '';
             $('#buyListGroup')[0].style.display = '';
             $('#buy_nav2')[0].style.display = 'none';
@@ -80,7 +68,7 @@
             $.ajax({
                 url: '/home/buy/group',
                 type: 'get',
-                data: {},
+                data: {userId: $('#userId').val()},
                 success: function (data) {
                     if (data.success) {
                         if (data.data.length > 0) {
@@ -91,7 +79,6 @@
                         }
                         else {
                         }
-
                     }
                 },
             });
@@ -101,18 +88,10 @@
             $('#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: 5vh;">\n' +
-                    '                    <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                        蔬菜套餐,猪肉牛肉金针菇等\n' +
-                    '                    </div>\n' +
-                    '                    <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                        24/100\n' +
-                    '                    </div>\n' +
-                    '                    <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                        02/02 14:30\n' +
-                    '                    </div>\n' +
-                    '                    <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                        在团\n' +
-                    '                    </div>\n' +
+                    '                    <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>\n' +
                     '            </a>');
         }
@@ -126,9 +105,9 @@
             $('#buy_nav2')[0].style.display = '';
             $('#MyBuyAll').empty();
             $.ajax({
-                url: '',
+                url: '/home/Mygroup/group',
                 type: 'get',
-                data: {},
+                data: {userId: $('#userId').val()},
                 success: function (data) {
                     if (data.success) {
                         if (data.data.length > 0) {
@@ -149,27 +128,31 @@
         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: 5vh;">\n' +
-                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                                蔬菜套餐,猪肉牛肉金针菇等\n' +
-                    '                            </div>\n' +
-                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                                02/02 14:30\n' +
-                    '                            </div>\n' +
-                    '                            <div style="width: 33%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size: 12px">\n' +
-                    '                                在团\n' +
-                    '                            </div>\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>')
         }
 
         function myBuyClick2(v) {
-            window.location.href = "/home/buytc.html?userId=" + $('#userId').val();
+            window.location.href = "/home/buytc.html?userId=" + $('#userId').val()+ "&jmId=" + v.jmId+"&type="+2;
         }
 
 
         /*居民求助信息*/
         function myBuyClick(v) {
-            window.location.href = "/home/buytc.html?userId=" + $('#userId').val();
+            window.location.href = "/home/buytc.html?userId=" + $('#userId').val() + "&jmId=" + v.jmId+"&type="+1;
         }
 
+
+        function tugouStatus(status) {
+            if (status == 1) {
+                return "<span style='color:Black;'>在团</span>";
+            } else if (status == 2) {
+                return "<span style='color:Black;'>处理中</span>";
+            } else {
+                return "<span style='color:green;'>已完成</span>";
+            }
+        }
     </script>

+ 56 - 29
whepi-ui/templates/home/buyClient.ftl

@@ -20,7 +20,7 @@
         </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">107</div>
+            <div style="display: inline;align-items: flex-end" id="myMenory">金额钱啊</div>
         </div>
     </div>
     <div class="weui-flex">
@@ -39,46 +39,37 @@
                   style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; margin-top: 1vh;"></textarea>
     </div>
     <div style="display:flex; flex-direction: row; justify-content: space-between; margin-top: 1vh; margin-bottom: 5vh;">
-        <a id="buyBack" onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
-           style="width: 30%;">返回</a>
-        <a id="buyRepeal" onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
-           style="width: 30%;display: none">撤销</a>
+    <#if type==1>
+      <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 buyBack() {
-        window.location.href = "/user/homeIndex.html?userId=" + $('#buyuserId').val()+ "&userType=" + 1 + '#tab3';
+        window.location.href = "/user/homeIndex.html?userId=" + $('#buyuserId').val() + "&userType=" + 1 + '#tab3';
     }
 
-    //提交
-    function buyCommit() {
-        if ($('#buyCount').val() == '' || $('#buyCount').val() == undefined) {
-            $.alert("请填写团购数量");
-            return;
-        }
-        if ($('#myPhone').val() == undefined || $('#myPhone').val() == '') {
-            $.alert("请填写联系电话");
-            return;
-        }
-        if ($('#Myremarks').val() == undefined || $('#Myremarks').val() == '') {
-            $.alert("请填写备注");
-            return;
-        }
-        /*   $.ajax({
+    /*撤销*/
+    /*   function MybuyBack() {
+           $.ajax({
                url: '/home/home/buyGroup',
                data: {
-                   userId: $('#userId').val(),
+                   userId: $('#buyuserId').val(),
                    buyCount: $('#buyCount').val(),
                    phone: $('#myPhone').val(),
                    remark: $('#Myremarks').val(),
                    buyMoney: $('#myMenory').text(),
-
+                   jmId: $('#jmBuy').val(),
                },
                type: 'GET',
                success: function (data) {
@@ -87,12 +78,48 @@
                },
                error: function () {
                }
-           });*/
+           });
+
+       }*/
+
+    //提交
+    function buyCommit() {
+        if ($('#buyCount').val() == '' || $('#buyCount').val() == undefined) {
+            $.alert("请填写团购数量");
+            return;
+        }
+        if ($('#myPhone').val() == undefined || $('#myPhone').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(),
+                buyMoney: $('#myMenory').text(),
+                jmId: $('#jmBuy').val(),
+            },
+            type: 'GET',
+            success: function (data) {
+                console.log(data);
+                buyBack();
+            },
+            error: function () {
+            }
+        });
     }
 
-    /* //输入数量自动结算金额
-     function menory() {
-      $('#myMenory').val($('#buyCount').val()*6)
-     }*/
+       <#if type==2>
+           (function ($) {
+                alert('12')
+           })
+       </#if>
 
 </script>

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

@@ -3,6 +3,7 @@
 
 <div class="weui-tab__panel">
     <input id="buyuserId" type="text" hidden="hidden" value=${userId}>
+    <input id="jmBuy" type="text" hidden="hidden" value=${jmId}>
     <div style="text-align: center ">
         团购信息
     </div>

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

@@ -8,8 +8,8 @@
             <#include "/home/ribao.ftl" /></div>
         <div id="tab2" class="weui-tab__bd-item">
             <#include "/home/qiuzhu.ftl" /></div>
-        <#--<div id="tab3" class="weui-tab__bd-item">-->
-           <#--<#include "/home/buy.ftl" /></div>-->
+        <div id="tab3" class="weui-tab__bd-item">
+           <#include "/home/buy.ftl" /></div>
     <#--<div id="tab4" class="weui-tab__bd-item">-->
     <#--<h1>页面四</h1> </div>-->
     </div>
@@ -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">-->
-            <#--<div class="weui-tabbar__icon"><img src="/static/images/wx/upload.png" alt=""></div>-->
-            <#--<p class="weui-tabbar__label" onclick="buyGroup()">商品团购</p>-->
-        <#--</a>-->
+        <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 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>-->

+ 8 - 0
whepi-web/src/main/java/com/bofeng/dao/BuyMapper.java

@@ -2,10 +2,18 @@ package com.bofeng.dao;
 
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.bofeng.entity.Buy;
+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 BuyMapper extends BaseMapper<Buy> {
+
+  List<JmTuangou> group(@Param("userId") Long userId);
+
+  List<Buy> MyGroup(@Param("userId") Long userId);
 }

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

@@ -14,12 +14,15 @@ import java.math.BigDecimal;
 @TableName("jm_buy")
 public class Buy {
 
-  @TableId("jm_id")
+  @TableId("buy_id")
+  private Long buyId;
+
+  @TableField("jm_id")
   private Long jmId;
 
   @TableField("user_id")
   private Long userId;
-  
+
   @TableField("buy_count")
   private Integer buyCount;
 
@@ -41,4 +44,10 @@ public class Buy {
   @TableField("time_create")
   private DateTime timeCreate;
 
+  @TableField(exist = false)
+  private String tgTitle;
+
+  @TableField(exist = false)
+  private Integer tgStatus;
+
 }

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

@@ -76,5 +76,7 @@ public class JmTuangou implements Serializable {
      */
     private Integer tgStatus;
 
+    private Integer count;
+
     private static final long serialVersionUID = 1L;
 }

+ 23 - 2
whepi-web/src/main/java/com/bofeng/service/BuyService.java

@@ -3,21 +3,42 @@ package com.bofeng.service;
 import com.baomidou.mybatisplus.toolkit.IdWorker;
 import com.bofeng.dao.BuyMapper;
 import com.bofeng.entity.Buy;
+import com.bofeng.entity.JmTuangou;
 import org.joda.time.DateTime;
 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.util.List;
 
 @Service
+@Transactional(readOnly = true)
 public class BuyService {
 
   @Autowired
   private BuyMapper buyMapper;
 
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
   public int buyGroup(Buy buy) {
-    buy.setJmId(IdWorker.getId());
+
+    buy.setBuyId(IdWorker.getId());
     buy.setUserCreate(buy.getUserId());
     buy.setTimeCreate(new DateTime());
+    //在添加的时候 进行检测该团购是否在规定时间里 已经达到了最小起订量的要求
+/*    if () {
+
+    }*/
+    buy.setBuyStatus(1);//在团
+    return buyMapper.insert(buy);
+  }
 
-    return 1;
+  public List<JmTuangou> group(Long userId) {
+    return buyMapper.group(userId);
   }
+
+  public List<Buy> MyGroup(Long userId) {
+    return buyMapper.MyGroup(userId);
+  }
+
 }

+ 12 - 3
whepi-web/src/main/java/com/bofeng/wx/controller/BuyController.java

@@ -1,6 +1,7 @@
 package com.bofeng.wx.controller;
 
 import com.bofeng.entity.Buy;
+import com.bofeng.entity.JmTuangou;
 import com.bofeng.service.BuyService;
 import com.yvan.Model;
 import com.yvan.ModelOps;
@@ -26,14 +27,22 @@ public class BuyController {
   }
 
   @GetMapping("/home/buytc.html")
-  public ModelAndView buytc(@Pd(name = "userId") Long userId, ModelMap model) {
+  public ModelAndView buytc(@Pd(name = "userId") Long userId, @Pd(name = "jmId") Long jmId,
+                            @Pd(name = "type") Integer type, ModelMap model) {
     model.put("userId", userId);
+    model.put("jmId", jmId);
+    model.put("type", type);
     return new ModelAndView("/home/buytc.ftl", model);
   }
 
   @GetMapping("/home/buy/group")
-  public Model<List<>> group(){
-    return Model.newSuccess();
+  public Model<List<JmTuangou>> group(@Pd(name = "userId") Long userId) {
+    return Model.newSuccess(buyService.group(userId));
+  }
+
+  @GetMapping("/home/Mygroup/group")
+  public Model<List<Buy>> MyGroup(@Pd(name = "userId") Long userId) {
+    return Model.newSuccess(buyService.MyGroup(userId));
   }
 
 }

+ 4 - 4
whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java

@@ -64,10 +64,10 @@ public class UserOpenController {
                              @RequestParam(value = "userType", required = false,defaultValue = "0") Integer userType) throws JsonProcessingException {
         List<UserRole> list = new ArrayList<>();
         if (userId == 0) {
-            UserOpen userOpen = homeService.getUserOpen();
-            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
-//            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
-//            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
+           /* UserOpen userOpen = homeService.getUserOpen();
+            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());*/
+            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
+            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
             userId = userOpen.getUserId();
             model.put("user", userOpen);
             model.put("user_id", "\""+userOpen.getUserId()+"\"");

+ 18 - 0
whepi-web/src/main/resources/mapper/BuyMapper.xml

@@ -2,4 +2,22 @@
 <!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="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
+       FROM jm_tuangou jt
+       where jt.uptown_id =(select c.uptown_id
+       from sys_user_role a
+       INNER JOIN sys_uptown_house b on a.property_id=b.house_id
+       INNER JOIN sys_uptown_unit c on b.unit_id=c.unit_id
+       where a.user_id=#{userId} and a.role_id=1)
+    </select>
+
+    <select id="MyGroup" resultType="com.bofeng.entity.Buy">
+        select DISTINCT a.tg_title,b.time_create,a.tg_status,a.jm_id
+        from  jm_tuangou a
+        INNER JOIN jm_buy b on a.jm_id=b.jm_id
+        where a.user_id=#{userId}
+    </select>
+
 </mapper>