예제 #1
0
 /**
  * 创建文件夹
  * @param $ordername 品牌id
  * @param $ordername 订单号名字
  * @param $brandnumberarray	款号数组
  */
 public static function create_order($brandid, $ordername, $brandnumberarray = array())
 {
     $arr = array();
     $output = '';
     $memcache = md5('getbrandsku' . $brandid);
     $boo = Yii::app()->cache->get($memcache);
     //缓存 不存在时候调用
     if (empty($boo)) {
         $arr = Yii::app()->db->createCommand()->select('code_start,code_end')->from('beu_brand')->where("id={$brandid}")->queryRow();
         if (!empty($arr)) {
             $output = json_encode($arry);
             Yii::app()->cache->set($output, $memcache, 18000);
             //添加缓存
         }
     } else {
         $arr = json_decode($boo, true);
     }
     if (count($brandnumberarray) > 0) {
         if (!empty($arr)) {
             $start = $arr['code_start'];
             //开始
             $end = $arr['code_end'];
             //结束
             foreach ($brandnumberarray as $value) {
                 $brand_sku = substr($value, $start, $end - $start);
                 if (!empty($value)) {
                     $url = $_SERVER['DOCUMENT_ROOT'] . '/orderlist/' . $ordername . '/' . $brand_sku . '/' . $value . '/product/';
                     orderclass::createFolder($url);
                     $url = $_SERVER['DOCUMENT_ROOT'] . '/orderlist/' . $ordername . '/' . $brand_sku . '/' . $value . '/model/';
                     orderclass::createFolder($url);
                     $url = $_SERVER['DOCUMENT_ROOT'] . '/orderlist/' . $ordername . '/' . $brand_sku . '/' . $value . '/details/';
                     orderclass::createFolder($url);
                 }
             }
         }
     }
     return true;
     //创建成功返回
 }