瀏覽代碼

自动接单,优惠卷查询缺少字段

lijie 2 年之前
父節點
當前提交
36e95f6e5e

+ 1 - 14
mhotel/src/com/happy/action/bookAction.java

@@ -600,19 +600,6 @@ public class bookAction extends ActionSupport implements ServletRequestAware {
      * 定时任务
      */
     public void setBookStatus(){
-        JSONObject resultJson = new JSONObject();
-        try {
-            int i = bookService.updateBookStatus();
-            resultJson.put("message", "已自动接单:"+ i + "条");
-            resultJson.put("code", 200);
-            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-
-        }catch (Exception e){
-            e.printStackTrace();
-            resultJson.put("message", "未知异常:"+ e);
-            resultJson.put("code", 205);
-            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-        }
-        System.out.println(1111);
+        int i = bookService.updateBookStatus();
     }
 }

+ 2 - 15
mhotel/src/com/happy/action/hotelCoupomAction.java

@@ -237,21 +237,8 @@ public class hotelCoupomAction extends BaseController implements ServletRequestA
      * 描述:定时任务修改优惠卷状态
      */
     public void setCoupomStatus(){
-        JSONObject resultJson = new JSONObject();
-        try {
-            int n =  hotelCoupomService.updateExpire();
-            int m =   hotelCoupomStatusService.updateExpir();
-            resultJson.put("message", "修改成功");
-            resultJson.put("code", 200);
-            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-
-        }catch (Exception e){
-            e.printStackTrace();
-            resultJson.put("message", "未知异常:"+ e);
-            resultJson.put("code", 205);
-            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-        }
-        System.out.println(1111);
+        int n =  hotelCoupomService.updateExpire();
+        int m =  hotelCoupomStatusService.updateExpir();
     }
 
 }

+ 1 - 1
mhotel/src/com/happy/dao/impl/HotelCouponImplDao.java

@@ -36,7 +36,7 @@ public class HotelCouponImplDao implements HotelCouponDao {
 
     private String selectSql = "select " +
             "id,hotelIds,name,type,rebate_price,deduction_price,max_deduction,grant_number,limit_number,grant_start_date,grant_end_date," +
-            "meet_price,effective_start_date,effective_end_date,effective_day,effective_lose_day,create_id,create_date,modify_date,status" +
+            "meet_price,effective_start_date,effective_end_date,effective_type,effective_day,effective_lose_day,create_id,create_date,modify_date,status,remainder_number,remainder_number" +
             " from hotel_coupon where 1=1";
 
 

+ 22 - 2
mhotel/src/com/happy/service/impl/BookImplService.java

@@ -8,6 +8,7 @@ import com.happy.Until.DateUtil;
 import com.happy.Until.Enum.PayEnum;
 import com.happy.Until.Func;
 import com.happy.Until.HttpUtils;
+import com.happy.Until.UUIDUtil;
 import com.happy.dao.BookDao;
 import com.happy.dto.BookTypeEto;
 import com.happy.dto.IPage;
@@ -24,6 +25,7 @@ import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 @Service("BookService")
 public class BookImplService implements BookService {
@@ -32,6 +34,7 @@ public class BookImplService implements BookService {
     public BookDao bookDao;
     @Resource
     public BookinglogService bookinglogService;
+
     @Resource
     public AdminManagerService adminManagerService;
 
@@ -182,9 +185,10 @@ public class BookImplService implements BookService {
         HotelDict operate = hotelDictService.getById(1997956736);//响应时间 1自动接单 2自动拒单
         String sqlx = " and create_time <= DATE_SUB(NOW(), INTERVAL " + times + " MINUTE) and order_status = 2 ";
         List<Booking> bookings = bookDao.queryList(sqlx);
-        List<HouseNumberStatus> list = new ArrayList<>();
+        AtomicInteger n = new AtomicInteger();
         if (operate.getCode() == 1){
             bookings.forEach(booking -> {
+                List<HouseNumberStatus> list = new ArrayList<>();
                 //不可入住的房间
                 List<HouseNumber> houseNumbers = houseNumberService.queryHouseStatus(booking);
                 //所有房间
@@ -199,6 +203,15 @@ public class BookImplService implements BookService {
                             i.getAndIncrement();
                         }
                     });
+                }else {
+                    //所有房间都可以预定
+                    houseNumberList.forEach(houseNumber -> {
+                        //添加的房间不在不可添加的房间当中并且数量小于订房总数
+                        if (i.get() < booking.getHouseOrderNumber()){
+                            Ids.add(houseNumber.getId());
+                            i.getAndIncrement();
+                        }
+                    });
                 }
 
                 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@@ -229,8 +242,15 @@ public class BookImplService implements BookService {
                         list.add(houseNumberStatus);
                     }
                 }
+                int m = houseNumberStatusService.saveBatch(list);
+                if (m > 0){
+                    n.getAndIncrement();
+                    booking.setOrderStatus("3");
+                    booking.setUpdateTime(UUIDUtil.getNewDate());
+                    bookDao.updateBooking(booking);
+                }
             });
-            return houseNumberStatusService.saveBatch(list);
+            return n.get();
         }else {
             String ip = request.getServerName();
             ip += "/mhotel/abkchargeback.action";