Ejemplo n.º 1
0
 /**
  * 开始转移产品信息到新表
  * @param $pid
  * @return boolean
  */
 public function moveProduct($pid)
 {
     echo $pid . "\n";
     $productMysql = Fproducton::findFirst(array("conditions" => "tid = ?1", "bind" => array(1 => $pid), "limit" => 1));
     if (empty($productMysql)) {
         return false;
     }
     $this->newProduct = array();
     /** 开始转换生成新的产品信息 */
     $this->newProduct["pid"] = $productMysql->tid;
     $this->newProduct["proname"] = $productMysql->productname;
     $this->newProduct["prokey"] = $productMysql->prokey;
     /** -1或者9为删除 */
     if ($productMysql->status < 0 || $productMysql->status == 9) {
         return false;
     }
     $this->newProduct["state"] = $this->convertStatus($productMysql->status);
     $this->newProduct["pubtime"] = $productMysql->pubtime;
     $this->newProduct["uptime"] = $productMysql->repubtime;
     $this->newProduct["picurl"] = $this->convertPic($productMysql->pic);
     $res = $this->convertCate($productMysql->cate1, $productMysql->cate2, $productMysql->cate3, $productMysql->cate4);
     /** 类目转换失败 */
     if (!$res) {
         return false;
     }
     $this->newProduct["minprice"] = floatval($productMysql->startprice);
     $this->newProduct["maxprice"] = floatval($productMysql->endprice);
     $this->newProduct["mincount"] = $productMysql->minorder;
     $this->newProduct["star"] = $this->convertStar($productMysql->toArray());
     $this->newProduct["uid"] = $productMysql->aid;
     $this->newProduct["cid"] = $productMysql->cid;
     //$this->newProduct["unit"]        = $productMysql->supplyunit ? $productMysql->supplyunit : 0;
     $this->newProduct["priceunit"] = $productMysql->pricemethod;
     $this->newProduct["measureunit"] = $productMysql->minorderunit;
     $this->newProduct["video"] = "";
     $this->convertProperty($productMysql->property);
     /** 开始存入新的数据库 */
     $obj = new Pdinfo();
     $res = $obj->save($this->newProduct);
     if (!$res) {
         return false;
     }
     $newpid = $obj->pid;
     /** 获取下详情信息 */
     Fproductoncontent::$pid = $pid;
     $descArr = Fproductoncontent::findFirst(array("conditions" => "tid = ?1", "bind" => array(1 => $pid), "limit" => 1))->toArray();
     $descArr = array("pid" => $newpid, "detail" => $descArr['content'], "paymod" => "", "payperiod" => 0, "harbour" => "", "supply" => 0);
     $tmp = array();
     $paymod = $productMysql->paymentmethod;
     $paymod = json_decode($paymod, true);
     foreach ($paymod as $key => $value) {
         $tmp[] = $key;
     }
     $descArr["paymod"] = implode("|", $tmp);
     $descArr["payperiod"] = $productMysql->supplyperiod;
     $descArr["harbour"] = $productMysql->port;
     $obj = new Pdinfodata();
     $obj->save($descArr);
     return true;
 }
Ejemplo n.º 2
0
 /**
  * 将现在英文站产品库数据拷到本地
  *
  * @Author   tianyunzi
  * @DateTime 2016-02-15T10:58:28+0800
  * @return   [type]                   [description]
  */
 public function copyDbAction()
 {
     global $argv;
     if (!isset($argv[3]) || !isset($argv[4]) || $argv[4] <= $argv[3]) {
         exit("请传入区间参数!");
     }
     $id = $argv[3];
     $endid = $argv[4];
     while (1) {
         $productMysql = Fproducton::find(array("conditions" => "tid > ?1", "bind" => array(1 => $id), "limit" => 100));
         $productRs = $productMysql->toArray();
         if (empty($productRs)) {
             break;
         }
         foreach ($productRs as $product) {
             $id = $product["tid"];
             if ($id > $endid) {
                 exit("区间执行完毕\n");
             }
             /* 存入本地 */
             $obj = new Fproduct();
             $rs = $obj->save($product);
             if (!$rs) {
                 echo $product["tid"] . " 存入本地失败!\n";
             } else {
                 echo $id . "\n";
             }
         }
     }
 }