Quellcode durchsuchen

Merge branch 'master' of http://git.yvanui.com/hust/wuhan_epi

Longlin vor 5 Jahren
Ursprung
Commit
966dedf79d

+ 11 - 6
admin-ui/app/whepi/tugou/dialogTugou.js

@@ -85,7 +85,7 @@ define(function (require) {
               }],
             [{
               xtype: 'yvselect',
-              name: 'uptownIds',
+              name: 'xqType',
               label: '需求类型',
               data: [{id: '1', text: '食蔬采购'}, {id: '2', text: '药品采购'}, {id: '3', text: '医疗服务'}, {
                 id: '4',
@@ -97,12 +97,17 @@ define(function (require) {
 
               },
             },{
-              name: 'tgPrice',
+              name: 'tgSupplier',
               label: '单价',
               readonly: context.isEdit ? true : false,
               maxlength: 4, validType: 'integer',
               width: 450, height: 35,
-            }
+            },
+              {
+                name: 'tgPrice',
+                label: '供应商',
+                xtype: 'hidden',
+              }
               /*{
                 name: 'tgTitle',
                 label: '发布标题',
@@ -181,14 +186,14 @@ define(function (require) {
             else {
               isLoading = true;
             }
-            if ($form.formGet().uptownIds.trim() == '') {
+            if ($form.formGet().uptownIds == '') {
               $.yvan.msg('请先选择小区');
               return;
             }
-            if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
+           /* if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
               $.yvan.msg('最大上限必须大于等于最小起订量');
               return;
-            }
+            }*/
             if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
               $.yvan.msg('团购截止时间必须小于预计送货时间');
               return;

+ 2 - 1
whepi-doc/group.sql

@@ -53,4 +53,5 @@ ADD  tg_type        varchar(20)     NOT NULL DEFAULT 0          COMMENT '团购
 ADD  user_create    bigint(20)      NOT NULL DEFAULT 0          COMMENT '新增人',
 ADD  time_create    datetime(0)     NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
 ADD  user_update    bigint(20)      NOT NULL DEFAULT 0          COMMENT '修改人',
-ADD  time_update    datetime(0)     NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间';
+ADD  time_update    datetime(0)     NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间';
+ADD  role_type      int(11)         NOT NULL DEFAULT 0          COMMENT '角色类型  1 业委会角色 2 指挥部' AFTER tg_min_num;

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

@@ -80,7 +80,11 @@
                 $("#Buycount").html(data.data.count);
                 $("#myStatus").html(getStatus(data.data.tgStatus));
                 $("#myPhone").val(data.data.phone);
-                $("#tc").html(data.data.tgMaxNum - data.data.count);
+                if (data.data.roleType == 1) {
+                    $("#tc")[0].style.display = 'none';
+                }else {
+                    $("#tc").html(data.data.tgMaxNum - data.data.count);
+                }
                 if (data.data.myRemark != null)
                     $('#Myremarks').text(data.data.myRemark);
                 if (data.data.buyMoney != null)

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

@@ -38,4 +38,7 @@ public interface JmTuangouDao extends BaseMapper<JmTuangou> {
   JmTuangou selectByUserId();
 
   JmTuangou getSelectOne(@Param("jmId") Long jmId);
+
+  JmTuangou getSelectOneRoleId(@Param("jmId") Long jmId);
+
 }

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

@@ -56,5 +56,7 @@ public class Buy {
   private Integer tgMaxNum;
   @TableField(exist = false)
   private String tgSupplier;
+  @TableField(exist = false)
+  private Integer roleType;
 
 }

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

@@ -89,6 +89,9 @@ public class JmTuangou implements Serializable {
     @TableField(exist = false)
     private String deliverTime;
 
+    @TableField(exist = false)
+    private Integer roleType;
+
     /**
      * 联系人电话
      */

+ 18 - 8
whepi-web/src/main/java/com/bofeng/service/BuyService.java

@@ -27,21 +27,31 @@ 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 (jmTuangou.getTgMaxNum().intValue() >= jmTuangou.getCurrentNum().intValue() - buy2.getBuyCount().intValue() + buy.getBuyCount().intValue()) {
+      if (roleType.getRoleType() != 1) {
+        if (jmTuangou.getTgMaxNum().intValue() >= jmTuangou.getCurrentNum().intValue() - buy2.getBuyCount().intValue() + buy.getBuyCount().intValue()) {
+          buy.setBuyId(buy1.getBuyId());
+          return buyMapper.updateById(buy);
+        } else {
+          return 3;//不允许更改团购数量
+        }
+      } else {
         buy.setBuyId(buy1.getBuyId());
         return buyMapper.updateById(buy);
-      } else {
-        return 3;//不允许更改团购数量
       }
     }
-    //第一次购买团购数量大于最大上限数量不允许
-    JmTuangou jmTuangou = jmTuangouDao.selectById(buy.getJmId());
-    if (jmTuangou.getTgMaxNum().intValue() < jmTuangou.getCurrentNum().intValue() + buy.getBuyCount().intValue()) {
-      return 3;
+    //1 是指挥部
+    if (roleType.getRoleType() != 1) {
+      //第一次购买团购数量大于最大上限数量不允许
+      JmTuangou jmTuangou = jmTuangouDao.selectJmTuangouByJmId(buy.getJmId());
+      if (jmTuangou.getTgMaxNum().intValue() < jmTuangou.getCurrentNum().intValue() + buy.getBuyCount().intValue()) {
+        return 3;
+      }
     }
+
     buy.setBuyId(IdWorker.getId());
     buy.setUserCreate(buy.getUserId());
     buy.setTimeCreate(new DateTime());
@@ -95,7 +105,7 @@ public class BuyService {
     if (jmTuangous != null && jmTuangous.size() > 0) {
       for (JmTuangou list : jmTuangous) {
         //判断是指挥部还是管理员
-        if (list.getTgSupplier().equals("指挥部")) {
+        if (list.getRoleType()==1) {
           if (list.getTgEndTime().getTime() < new DateTime().getMillis()) {
             jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
           }

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

@@ -32,7 +32,7 @@
     </select>
 
     <select id="status" resultType="com.bofeng.entity.Buy">
-       SELECT a.tg_status, a.tg_price,a.tg_max_num,b.buy_count,b.buy_money,b.my_remark,
+       SELECT a.tg_status, a.tg_price,a.tg_max_num,b.buy_count,b.buy_money,b.my_remark,a.role_type,
        IFNULL(( SELECT SUM(b.buy_count)
        FROM jm_buy b WHERE a.jm_id = b.jm_id AND buy_status = 1 ), 0 ) AS count,
        ( SELECT phone FROM sys_user_role aa

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

@@ -86,4 +86,10 @@
     <select id="getSelectOne" resultType="com.bofeng.entity.JmTuangou">
         select *,uptown_id as uptownIds from jm_tuangou where jm_id=#{jmId}
     </select>
+
+    <select id="getSelectOneRoleId" resultType="com.bofeng.entity.JmTuangou">
+        select * from jm_tuangou where jm_id=#{jmId}
+    </select>
+
+
 </mapper>