Ver código fonte

预约选号功能升级

git 6 anos atrás
pai
commit
8d2323b1f5
2 arquivos alterados com 42 adições e 2 exclusões
  1. 5 0
      Home/Conf/config.php
  2. 37 2
      Home/Lib/Action/CronAction.class.php

+ 5 - 0
Home/Conf/config.php

@@ -0,0 +1,5 @@
+<?php
+return array(
+	'订单状态_待开户' => 0,
+	'订单状态_已开户' => 1,
+);

+ 37 - 2
Home/Lib/Action/CronAction.class.php

@@ -22,11 +22,46 @@ class CronAction extends Action {
 				echo "LicensePlate empty!".PHP_EOL;
 				continue;
 			}
-			//过期预约车牌,释放到公选池
+			
+			
+			//检测车牌是否已生成待开户订单,已生成的丢弃,未生成释放到公选池
+			$cond = array(
+				'LicensePlate' => $info['LicensePlate'],
+				'OrderStatus' => C('订单状态_待开户')
+			);
+			$order_info = M('jms_order')->where($cond)->field('LicensePlate,OrderStatus')->find();
+			if(!$order_info){
+				$cond = array(
+					'LicensePlate' => $info['LicensePlate'],
+					'OrderStatus' => C('订单状态_已开户')
+				);
+				$order_info = M('jms_order')->where($cond)->field('LicensePlate,OrderStatus')->find();
+			}
+			if($order_info && $order_info['OrderStatus'] === C('订单状态_待开户')){
+				echo 'LicensePlate: '.$info['LicensePlate'].' has waiting order,discard!'.PHP_EOL;
+				continue;
+			}
+			if($order_info && $order_info['OrderStatus'] === C('订单状态_已开户')){
+				echo 'LicensePlate: '.$info['LicensePlate'].' has finish order,discard!'.PHP_EOL;
+				continue;
+			}
+			//过期的预约车牌,释放到公选池
 			if(time()>$info['ExpireTime']){
-				$plate_preselect_pool -> add($info['LicensePlate']);
+				$result = $plate_preselect_pool -> add($info['LicensePlate']);
+				if(!$result){
+					echo 'LicensePlate: '.$info['LicensePlate'].' push to plate_preselect_pool failed!'.PHP_EOL;
+					continue;
+				}
 				echo 'LicensePlate: '.$info['LicensePlate'].' timeout, push to plate_preselect_pool'.PHP_EOL;
+				continue;
+			}
+			//没有过期的,放回队列
+			$result = $plate_preselect_pool -> push($info);
+			if(!$result){
+				echo 'info push to plate_preselect_pool failed!'.PHP_EOL;
+				continue;
 			}
+			usleep(1000);
 		}while(time()-$start<60);