stanley-king il y a 9 ans
Parent
commit
2ffb25fd8d
2 fichiers modifiés avec 107 ajouts et 6 suppressions
  1. 97 3
      crontab/crawl/body_filter.php
  2. 10 3
      mobile/control/member_order.php

+ 97 - 3
crontab/crawl/body_filter.php

@@ -14,8 +14,8 @@ class body_filder
     static $save_path = BASE_DATA_PATH . '/upload/detail';
     static $down_path = BASE_DATA_PATH . '/Download/detail';
 
-    static $req_path = 'http://p.lrlz.com/data/upload/detail/';
-    //static $req_path = 'http://localhost/data/upload/detail/';
+    //static $req_path = 'http://p.lrlz.com/data/upload/detail/';
+    static $req_path = 'http://localhost/data/upload/detail/';
 
     public function __construct()
     {
@@ -122,7 +122,7 @@ class body_filder
                     copy($path,$newpath);
 
                     ++$num;
-                    array_push($name);
+                    array_push($imgs,$name);
                 }
             }
             if(isset($imgs)) {
@@ -149,6 +149,76 @@ class body_filder
         }
     }
 
+    private function img_width($img)
+    {
+        $path = self::$save_path . '/' . $img;
+        $img_info = getimagesize($path);
+        if (empty($img_info) || count($img_info) == 0) return 0;
+
+        return $img_info[0];
+
+    }
+    private function group($pics,$max_width)
+    {
+        $ret = array();
+
+        $row = array();
+        $width_count = 0;
+        foreach($pics as $img)
+        {
+            $width = $this->img_width($img);
+            $width_count += $width;
+            if($width_count > $max_width) {
+                array_push($ret,$row);
+                $row = array();
+                array_push($row,$img);
+                $width_count = 0;
+            }
+            else if($width_count == $max_width){
+                array_push($row,$img);
+                array_push($ret,$row);
+                $row = array();
+                $width_count = 0;
+            } else {
+                array_push($row,$img);
+            }
+        }
+
+        return $ret;
+    }
+
+    private function layout($pics)
+    {
+        $table_start = "<table style=\"width:100%%;\" cellpadding=\"0\" cellspacing=\"0\">";
+        $table_end = "</table>";
+
+        //1. 枚举图片
+        $max_width = $this->max_width($pics);
+        $table = $this->group($pics,$max_width);
+
+        $html = $table_start;;
+        foreach($table as $row)
+        {
+//            if(count($row) == 1) {
+//                $name = $row[0];
+//                $html .= "<img src=\"" . self::$req_path . "{$name}\">";
+//            }
+//            else
+//            {
+
+                $html .= "<tr>";
+                foreach($row as $col) {
+                    $tmp = "<img src=\"" . self::$req_path . "{$col}\">";
+                    $html .= "<td> {$tmp} </td>";
+                }
+                $html .= "</tr>";
+//            }
+        }
+        $html .= $table_end;
+
+        return $html;
+    }
+
     public function proc()
     {
         $goods = $this->goods_common->field('goods_commonid,goods_body')->limit(false)->select();
@@ -157,6 +227,9 @@ class body_filder
             $body = $val['goods_body'];
             $comm_id = $val['goods_commonid'];
             $body = $this->filter_gif($body);
+
+            $this->filterex($body,$comm_id);
+
             $imgs = $this->filter_table($body,$comm_id);
 
             if($imgs == false) continue;
@@ -167,6 +240,27 @@ class body_filder
             }
         }
     }
+
+    /**
+     * @param $pics
+     * @return array
+     */
+    private function max_width(&$pics)
+    {
+        $max_width = 0;
+        foreach ($pics as &$img)
+        {
+            $path = self::$save_path . '/' . $img;
+            $img_info = getimagesize($path);
+            if (empty($img_info) || count($img_info) == 0) {
+                continue;
+            }
+
+            $max_width = $img_info[0] > $max_width ? $img_info[0] : $max_width;
+        }
+
+        return $max_width;
+    }
 }
 
 

+ 10 - 3
mobile/control/member_order.php

@@ -136,9 +136,16 @@ class member_orderControl extends mobileMemberControl
         $condition['order_id'] = $order_id;
         $condition['buyer_id'] = $this->member_info['member_id'];
         $order_info = $model_order->getOrderInfo($condition);
-        $if_allow = $model_order->getOrderOperateState('buyer_cancel', $order_info);
-        if (!$if_allow) {
-            return joutput_error(errcode::ErrOrder, '无权操作');
+//        $if_allow = $model_order->getOrderOperateState('buyer_cancel', $order_info);
+//        if (!$if_allow) {
+//            return joutput_error(errcode::ErrOrder, '无权操作');
+//        }
+
+        if($order_info['order_id'] == $order_id)
+        {
+            if($order_info['order_state'] != ORDER_STATE_NEW) {
+                return joutput_error(errcode::ErrOrder, "已支付和已发货订单不能取消.");
+            }
         }
 
         $result = $logic_order->changeOrderStateCancel($order_info, 'buyer', $this->member_info['member_name'], '其它原因');