Browse Source

业主购买2月10号

guojing 5 năm trước cách đây
mục cha
commit
2da1fdbbd5

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

@@ -17,7 +17,7 @@
             <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: 50%;font-size: 16px;margin-top: 1vh;"
-                       maxlength="6" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1"
+                       maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1"
                        onchange="changeBuy()">
             </div>
         </div>

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

@@ -22,4 +22,6 @@ public interface BuyMapper extends BaseMapper<Buy> {
   JmTuangou selectGroup(@Param("userId") Long userId, @Param("jmId") Long jmId);
 
   Buy status(@Param("jmId") Long jmId);
+
+  List<Buy> selectCountNum(@Param("jmId") Long jmId);
 }

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

@@ -63,7 +63,7 @@ public class BuyService {
   public int buyBack(Buy buy) {
     //在该套餐截止日期之前 并且是在团状态的才能撤单
     JmTuangou jmTuangou = buyMapper.selectGroup(buy.getUserId(), buy.getJmId());
-    if (jmTuangou.getTgEndTime().getTime() < new DateTime().getMillis() && jmTuangou.getTgStatus() == 1) {
+    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);//撤单
@@ -82,14 +82,25 @@ public class BuyService {
   public int updateStatus() {
     List<JmTuangou> jmTuangous = jmTuangouDao.selectAll();
     if (jmTuangous != null && jmTuangous.size() > 0) {
-      for (JmTuangou list : jmTuangous) {
+      //已经到截止时间
+      for (JmTuangou list : jmTuangous)
         if (list.getTgEndTime().getTime() < new DateTime().getMillis()) {
-          JmTuangou jmTuangou = new JmTuangou();
-          jmTuangou.setJmId(list.getJmId());
-          jmTuangou.setTgStatus(4);//截止时间已到 取消
-          jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);
+
+          // 团购数量  最小起订量
+          List<Buy> buys = buyMapper.selectCountNum(list.getJmId());
+          if (buys != null && buys.size() > 0) {
+            for (Buy v : buys) {                //最小起订量
+              if (v.getCount().intValue() < list.getTgMinNum().intValue()) {
+                jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
+              } else {
+                jmTuangouDao.updateStatusByJmId(list.getJmId(), 2L);//发货
+              }
+            }
+          } else {
+            jmTuangouDao.updateStatusByJmId(list.getJmId(), 4L);//取消
+          }
+
         }
-      }
     }
     return 1;
   }

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

@@ -39,4 +39,8 @@
       WHERE a.jm_id = #{jmId} limit 1
     </select>
 
+    <select id="selectCountNum" resultType="com.bofeng.entity.Buy">
+        select sum(buy_count) as count,buy_id from jm_buy where jm_id=#{jmId} GROUP BY buy_id
+    </select>
+
 </mapper>