Browse Source

Merge remote-tracking branch 'origin/master'

Longlin 5 years ago
parent
commit
686156fc1f

+ 10 - 5
admin-ui/app/whepi/tugou/dialogTugou.js

@@ -153,14 +153,14 @@ define(function (require) {
               },
               {
                 name: 'tgSupplier', width: 450, height: 35,
-                label: '供应商', maxlength: 20,
+                label: '供应商', maxlength: 20, required: true,
                 readonly: context.isEdit != 1 ? true : false,
               }],
             [
               {
                 name: 'remark', width: 900, height: 120,
                 label: '备注', maxlength: 500, multiline: true,
-                required: true, xtype: context.isEdit==1 ? 'hidden' : '',
+                required: true, xtype: context.isEdit == 1 ? 'hidden' : '',
               }
             ]
           ],
@@ -173,10 +173,15 @@ define(function (require) {
               $.yvan.msg('请先选择小区');
               return;
             }
-            if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
-              $.yvan.msg('最大上限必须大于等于最小起订量');
-              return;
+            if ($form.formGet().tgMinNum != '') {
+              if ($form.formGet().tgMaxNum != '') {
+                if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
+                  $.yvan.msg('最大上限必须大于等于最小起订量');
+                  return;
+                }
+              }
             }
+
             if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
               $.yvan.msg('团购截止时间必须小于预计送货时间');
               return;

+ 42 - 1
whepi-doc/mrsb.sql

@@ -53,4 +53,45 @@ CREATE TABLE ms_suspected  (
   user_update       bigint(20) NOT NULL DEFAULT 0                           COMMENT '修改人',
   time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   PRIMARY KEY (suspected_id) USING BTREE
-) ENGINE = InnoDB default charset=utf8mb4 comment = '家庭疑似表';
+) ENGINE = InnoDB default charset=utf8mb4 comment = '家庭疑似表';
+
+
+-- ----------------------------
+-- Table structure for ms_trip
+-- ----------------------------
+DROP TABLE IF EXISTS ms_trip;
+CREATE TABLE ms_trip  (
+  trip_id           bigint(20) NOT NULL DEFAULT 0                           COMMENT '出行ID:和疑似ID一对一关系',
+  work_local        int(11)    NOT NULL DEFAULT 0                           COMMENT '工作驻地:0未填写,1武汉市,2宜昌市,3当阳市,其他地点',
+  work_local_other  varchar(50)  NOT NULL DEFAULT ''                        COMMENT '工作驻地其他地点',
+  today_local       int(11)    NOT NULL DEFAULT 0                           COMMENT '今日驻地:0未填写,1武汉市,2宜昌市,3当阳市,其他地点',
+  today_local_other varchar(50)  NOT NULL DEFAULT ''                        COMMENT '今日驻地其他地点',
+  is_trip           int(11)    NOT NULL DEFAULT 0                           COMMENT '是否出行:0否,1是',
+  user_create       bigint(20) NOT NULL DEFAULT 0                           COMMENT '新增人',
+  time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0)       COMMENT '新增时间',
+  user_update       bigint(20) NOT NULL DEFAULT 0                           COMMENT '修改人',
+  time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
+  PRIMARY KEY (trip_id) USING BTREE
+) ENGINE = InnoDB default charset=utf8mb4 comment = '家庭出行表';
+
+
+-- ----------------------------
+-- Table structure for ms_trip_det
+-- ----------------------------
+DROP TABLE IF EXISTS ms_trip_det;
+CREATE TABLE ms_trip_det  (
+  trip_det_id       bigint(20) NOT NULL DEFAULT 0                           COMMENT '出行详细ID',
+  trip_id           bigint(20) NOT NULL DEFAULT 0                           COMMENT '出行ID:和疑似ID一对一关系',
+  sort              int(11)    NOT NULL DEFAULT 0                           COMMENT '序号',
+  start_local       int(11)    NOT NULL DEFAULT 0                           COMMENT '出发地:0未填写,1武汉市,2宜昌市,3当阳市,其他地点',
+  start_local_other varchar(50)  NOT NULL DEFAULT ''                        COMMENT '出发地其他地点',
+  end_local         int(11)    NOT NULL DEFAULT 0                           COMMENT '目的地:0未填写,1武汉市,2宜昌市,3当阳市,其他地点',
+  end_local_other   varchar(50)  NOT NULL DEFAULT ''                        COMMENT '目的地其他地点',
+  trip_type         int(11)    NOT NULL DEFAULT 0                           COMMENT '出行方式:0未填写,1长途汽车,2火车,3飞机',
+  user_create       bigint(20) NOT NULL DEFAULT 0                           COMMENT '新增人',
+  time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0)       COMMENT '新增时间',
+  user_update       bigint(20) NOT NULL DEFAULT 0                           COMMENT '修改人',
+  time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
+  PRIMARY KEY (trip_det_id) USING BTREE
+) ENGINE = InnoDB default charset=utf8mb4 comment = '家庭出行详细表';
+

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

@@ -85,7 +85,7 @@
                 $("#Buycount").html(data.data.count);
                 $("#myStatus").html(getStatus(data.data.tgStatus));
                 $("#myPhone").val(data.data.phone);
-                if (data.data.roleType == 1) {
+                if (data.data.tgMaxNum - data.data.count <= 0) {
                     $("#tc1").toggle();
                 } else {
                     $("#tc").html(data.data.tgMaxNum - data.data.count);

+ 39 - 57
whepi-web/src/main/java/com/bofeng/service/BuyService.java

@@ -27,44 +27,29 @@ public class BuyService {
   @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
   public int buyGroup(Buy buy) {
     Buy buy1 = buyMapper.selectBuyOne(buy.getUserId(), buy.getJmId());
-    JmTuangou roleType = jmTuangouDao.getSelectOneRoleId(buy.getJmId());
-    if (buy1 != null) {
-      JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy1.getJmId());
-      Buy buy2 = buyMapper.selectById(buy1.getBuyId());
-      if (roleType.getRoleType() != 1) {
-        if (jmTuangou.getTgMaxNum().intValue() >= jmTuangou.getCurrentNum().intValue() - buy2.getBuyCount().intValue() + buy.getBuyCount().intValue()) {
-          //个人限额(指挥部的限额 和 管理员的限额)
-          if (roleType.getTgItemNum().intValue() != 0 && roleType.getTgItemNum().intValue() < buy.getBuyCount().intValue()) {
-            return 4;
-          }
-          buy.setBuyId(buy1.getBuyId());
-          return buyMapper.updateById(buy);
-        } else {
-          return 3;//不允许更改团购数量
-        }
-      } else {
-        //指挥部的更改
-        //个人限额(指挥部的限额 和 管理员的限额)
-        if (roleType.getTgItemNum().intValue() != 0 && roleType.getTgItemNum().intValue() < buy.getBuyCount().intValue()) {
-          return 4;
-        }
-        buy.setBuyId(buy1.getBuyId());
-        return buyMapper.updateById(buy);
-      }
-    }
-    //1 是指挥部
-    if (roleType.getRoleType() != 1) {
-      //第一次购买团购数量大于最大上限数量不允许
-      JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy.getJmId());
-      if (jmTuangou.getTgMaxNum().intValue() < jmTuangou.getCurrentNum().intValue() + buy.getBuyCount().intValue()) {
+    JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy.getJmId());//团购主表
+    if (buy1 != null) {//判断是否是第一次添加
+      //JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy.getJmId());
+
+      //最大上限有的话就遵循
+      if (jmTuangou.getTgMaxNum().intValue() != 0 && jmTuangou.getTgMaxNum().intValue() < jmTuangou.getCurrentNum().intValue() + buy.getBuyCount().intValue()) {
         return 3;
       }
+      //单人限额有的话的遵循
+      if (jmTuangou.getTgItemNum().intValue() != 0 && jmTuangou.getTgItemNum().intValue() < buy.getBuyCount().intValue()) {
+        return 4;
+      }
+      buy.setBuyId(buy1.getBuyId());
+      return buyMapper.updateById(buy);
     }
-    //个人限额(指挥部的限额 和 管理员的限额)
-    if (roleType.getTgItemNum().intValue() != 0 && roleType.getTgItemNum().intValue() < buy.getBuyCount().intValue()) {
+    //最大上限有的话就遵循
+    if (jmTuangou.getTgMaxNum() != 0 && jmTuangou.getTgMaxNum().intValue() < jmTuangou.getCurrentNum().intValue() + buy.getBuyCount().intValue()) {
+      return 3;
+    }
+    //单人限额有的话的遵循
+    if (jmTuangou.getTgItemNum().intValue() != 0 && jmTuangou.getTgItemNum().intValue() < buy.getBuyCount().intValue()) {
       return 4;
     }
-
     buy.setBuyId(IdWorker.getId());
     buy.setUserCreate(buy.getUserId());
     buy.setTimeCreate(new DateTime());
@@ -114,38 +99,35 @@ public class BuyService {
   //截止日期状态的更改
   @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
   public int updateStatus() {
+    //团购的在团状态
     List<JmTuangou> jmTuangous = jmTuangouDao.selectAll();
     if (jmTuangous != null && jmTuangous.size() > 0) {
       for (JmTuangou list : jmTuangous) {
-        //判断是指挥部还是管理员
-        if (list.getRoleType() == 1) {
-          if (list.getTgEndTime().getTime() < new DateTime().getMillis()) {
-            jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
-          }
-        } else {
-          // 团购数量  最小起订量
+        //到了截止日期
+        if (list.getTgEndTime().getTime() < new DateTime().getMillis()) {
+          //已经到了截止日期  判断有没有人购买
           Buy buy = buyMapper.selectCountNum(list.getJmId());
-          //已经到截止时间
-          if (list.getTgEndTime().getTime() < new DateTime().getMillis()) {
-
-            if (buy != null) { //最小起订量
-              if (list.getTgMinNum().longValue() > buy.getCount().longValue()) {
-                jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
+          if (buy.getCount().intValue() > 0) {
+            //判断是否有最小起订量 只有达到最小量的并且是到截止时间的
+            if (list.getTgMinNum().intValue() != 0) {
+              if (buy.getCount().intValue() >= list.getTgMinNum().intValue()) {
+                if (buy.getCount().intValue() == 0 && list.getTgMinNum().intValue() == 0) {
+                  jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
+                } else if (buy.getCount().intValue() != 0) {
+                  jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
+                }
               } else {
-                jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
+                jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
               }
             } else {
-              jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
+              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;

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

@@ -45,7 +45,7 @@
     </select>
 
     <select id="selectCountNum" resultType="com.bofeng.entity.Buy">
-        select sum(buy_count) as count,jm_id from jm_buy where jm_id=#{jmId} and buy_status=1 GROUP BY jm_id
+        select IFNULL(sum(buy_count),0) as count from jm_buy where jm_id=#{jmId} and buy_status=1
     </select>
 
 </mapper>