Browse Source

find best goods

stanley-king 7 years ago
parent
commit
37d927d0f8
2 changed files with 25 additions and 2 deletions
  1. 22 1
      helper/async/order.php
  2. 3 1
      qwatch.py

+ 22 - 1
helper/async/order.php

@@ -23,8 +23,29 @@ use Log;
 class simple_order
 {
     private $info;
+    private $rgoods;
     public function __construct($order_info) {
         $this->info = $order_info;
+        $this->rgoods = $this->find_recommend();
+    }
+    private function find_recommend()
+    {
+        $result = null;
+        foreach ($this->info['order_goods'] as $good)
+        {
+            if(empty($result)) {
+                $result = $good;
+            }
+            else
+            {
+                if($result['goods_price'] < $good['goods_price']) {
+                    $result = $good;
+                }
+
+            }
+        }
+
+        return $result;
     }
     public function user() {
         return $this->info['order_info']['buyer_id'];
@@ -33,7 +54,7 @@ class simple_order
         return $this->info['order_info']['pd_amount'];
     }
     public function recommend_goods() {
-        return $this->info['order_goods'][0];
+        return $this->rgoods;
     }
     public function total() {
         return $this->info['order_info']['order_amount'];

+ 3 - 1
qwatch.py

@@ -123,10 +123,12 @@ def main():
 
 	if mac_sys() :
 		cmds = ["php", "./crontab.php", "queue", "index"]
+		proc_num = 1
 	else:
 		cmds = ["/usr/local/php/bin/php", "./crontab.php", "queue", "index"]
+		proc_num = 10
 
-	for i in range(0, 10):
+	for i in range(0, proc_num):
 		subproc = subprocess.Popen(cmds, close_fds=True, stdin=None, stdout=None, stderr=None)
 		queue_process.append(subproc)
 		print "create queue process pid=", subproc.pid