Longlin před 5 roky
rodič
revize
0aff19c7f5

+ 20 - 0
whepi-ui/templates/yeweihui/tgPublish.ftl

@@ -95,6 +95,26 @@
             return;
         }
 
+        let curTimestamp =(new Date()).valueOf();
+        let endTimestamp = end_time.replace(/-/g,'/');
+        endTimestamp = Date.parse(endTimestamp);
+        let deliverTimestamp = deliver_time.replace(/-/g,'/');
+        deliverTimestamp = Date.parse(deliverTimestamp);
+        if (endTimestamp < curTimestamp) {
+            $.alert("团购截止时间不能早于当前时间");
+            return;
+        }
+
+        if (deliverTimestamp < curTimestamp) {
+            $.alert("送货时间不能早于当前时间");
+            return;
+        }
+
+        if (endTimestamp > deliverTimestamp) {
+            $.alert("团购截止时间不能大于送货时间");
+            return;
+        }
+
         console.log(
             "发布",
             title + "---" +

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

@@ -20,6 +20,9 @@ import java.util.List;
 public class JmTuangouService {
 
     @Autowired
+    private BuyService buyService;
+
+    @Autowired
     private JmTuangouDao jmTuangouDao;
 
     @Autowired
@@ -57,8 +60,11 @@ public class JmTuangouService {
         return jmTuangouDao.insert(jmTuangou);
     }
 
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public List<JmTuangou> queryTuangouListByTitle(Long userId, String title) {
 
+        buyService.updateStatus();
+
         Long propertyId = yeweihuiUserRoleMapper.queryPropertyIdByUserId(userId);
         Long uptownId = yeweihuiSysOwnerMapper.queryUptownIdByUserId(propertyId);
 
@@ -68,15 +74,22 @@ public class JmTuangouService {
         return jmTuangouDao.queryTuangouListByUptownIdAndTitle(uptownId, title);
     }
 
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public List<JmTuangou> queryTuangouMyListByTitle(Long userId, String title) {
 
+        buyService.updateStatus();
+
         if (title.equals("")) {
             return jmTuangouDao.queryTuangouListByUserId(userId);
         }
         return jmTuangouDao.queryTuangouListByUserIdAndTitle(userId, title);
     }
 
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public JmTuangou queryByJmId(Long jmId) {
+
+        buyService.updateStatus();
+
         return jmTuangouDao.selectJmTuangouByJmId(jmId);
     }
 

+ 0 - 26
whepi-web/src/main/java/com/bofeng/wx/controller/YeWeiHuiController.java

@@ -18,7 +18,6 @@ import com.yvan.platform.YvanUtil;
 import com.yvan.springmvc.HttpParameterParser;
 import io.swagger.annotations.ApiOperation;
 import lombok.SneakyThrows;
-import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -284,9 +283,6 @@ public class YeWeiHuiController {
     public ModelAndView groupBuyingCx(@Pd(name = "jmId") Long jmId, @Pd(name = "userId") Long userId, @Pd(name = "operation") String operation, ModelMap model) throws JsonProcessingException {
 
         JmTuangou item = jmTuangouService.queryByJmId(jmId);
-        if (item.getTgEndTime().getTime() < new DateTime().getMillis() && item.getTgStatus() == 1) {
-            item.setTgStatus(4);
-        }
 
         model.put("tgItemJson", new JsonWapper(item));
         model.put("tgItem", item);
@@ -303,10 +299,6 @@ public class YeWeiHuiController {
 
         JmTuangou item = jmTuangouService.queryByJmId(jmId);
 
-        if (item.getTgEndTime().getTime() < new DateTime().getMillis() && item.getTgStatus() == 1) {
-            item.setTgStatus(4);
-        }
-
         if (item.getUserId().equals(userId)) {
             model.put("isMine", "mine");
         }
@@ -326,10 +318,6 @@ public class YeWeiHuiController {
 
         JmTuangou item = jmTuangouService.queryByJmId(jmId);
 
-        if (item.getTgEndTime().getTime() < new DateTime().getMillis() && item.getTgStatus() == 1) {
-            item.setTgStatus(4);
-        }
-
         List<JmTuangouMember> members = jmTuangouMemberService.querMemberListByJmId(jmId);
 
         model.put("tgItemJson", new JsonWapper(item));
@@ -385,13 +373,6 @@ public class YeWeiHuiController {
 
         List<JmTuangou> list = jmTuangouService.queryTuangouListByTitle(userId, title);
 
-        for (int i = 0; i < list.size(); i++) {
-            JmTuangou item = list.get(i);
-            if (item.getTgEndTime().getTime() < new DateTime().getMillis() && item.getTgStatus() == 1) {
-                item.setTgStatus(4);
-            }
-        }
-
         return Model.newSuccess(list);
     }
 
@@ -400,13 +381,6 @@ public class YeWeiHuiController {
 
         List<JmTuangou> myList = jmTuangouService.queryTuangouMyListByTitle(userId, title);
 
-        for (int i = 0; i < myList.size(); i++) {
-            JmTuangou item = myList.get(i);
-            if (item.getTgEndTime().getTime() < new DateTime().getMillis() && item.getTgStatus() == 1) {
-                item.setTgStatus(4);
-            }
-        }
-
         return Model.newSuccess(myList);
     }