テストタイトル

16448 ワード

<?php
/**
* ebay
*/
namespace Wish\Controller;
use Think\Controller;
class CronController extends Controller{
   /**
    * 3
    */
   public function test(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       D("Test","Service")->changeDataS();

       echo " ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   /**
    * 2
    */
   public function testRB(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       D("Test","Service")->changeDataSRB();

       echo " ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   /**
    * 0
    */
   public function testR(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       D("Test","Service")->changeDataSR();

       echo " ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   public function calculateProfit(){
       vendor("phpRPC/phprpc_client");
       $clientCur = new \PHPRPC_Client('http://192.168.5.5:901/ordertool/index.php/Ordertool/Api/getcurrentcur');
       $rmbCur = $clientCur->getValue("RMB");
       dump($rmbCur);
       if (!is_string($rmbCur)) {
           echo " !";
           exit;
       }
       echo "
";
       echo "StartTime :".date("Y-m-d H:i:s");
       $this->m_pro = new \Wish\Model\ProfitModel();
       $map = array();
       $map['status_profit'] = 0;
       $map['status_fee'] = 1;
       $data = $this->_profit  = $this->m_pro->field("account_id,transaction_id")->where($map)->select();
       foreach ($data as $v){
           $m_cal
               = new \Wish\Model\CalculateModel($v["account_id"],$v["transaction_id"],$rmbCur);
           print_r($m_cal ->run());
           $m_cal ->save();
       }
       echo "EndTime :".date("Y-m-d H:i:s");
   }

   /**
    * sku
    */
   public function skuCost(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       D("SkuCost","Service")->getSkuCost();

       echo "Success! ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   /**
    *
    */
   public function sourceData(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       $c = D("ShipFee","Service")->getSourceData();

       echo " ".$c." Success! ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   /**
    * ERP
    */
   public function shipFee(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       $c = D("ShipFee","Service")->getShipFee();

       echo " Insert : ".$c['i']." Update : ".$c['u']." Success! ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   /**
    * ERP ex
    */
   public function exShipFee(){
       $s_time = 'startTime:'.date('Y-m-d H:i:s');

       $c = D("ShipFee","Service")->getExShipFee();

       echo " Insert : ".$c['i']." Update : ".$c['u']." Success! ".$s_time." endTime:".date('Y-m-d H:i:s')."
";
   }

   /**
    * erp
    */
   public function otoM(){
       $m_erp = M("erp_database"," ","DB_RERP");

       $m_profit  =M("profit","wish_","DB_PROFIT");

       $m_account = M("wishaccounts");

       $m_countrycodes = M("country_codes");
       $num = 0;
       do{
           $sql = "SELECT *  FROM `erp_orders` WHERE `orders_type` in(53,225) and ( `pay_id`  like '54%'  or  `pay_id`  like '5.4%')  and orders_status >=5 and orders_shipping_time< '2015-01-01' limit $num,1000";
           $result = $m_erp->query($sql);
           echo $m_erp->getLastSql();
           foreach($result as $v){
               $sql1 = "SELECT * FROM  `erp_orders_products` WHERE  `erp_orders_id` ='".$v['erp_orders_id']."';";
               $result1 = $m_erp->query($sql1);
               foreach($result1 as $key => $v1){
                   if($key == 0){
                       $data['order_total'] = $v['orders_total'];
                   }else{
                       $data['order_total'] = 0;
                   }
                   $data['incid'] = "99".$v1['orders_products_id'];
                   $data["transaction_id"] =$v['pay_id'];
                   $data['sku'] = $v1['orders_sku'];
                   $data['shipped_time'] = $v['orders_shipping_time'];
                   $data['sku_quantity'] = $v1['item_count'];
                   $data['country_code'] = $m_countrycodes->where("country_en_name = '".$v['buyer_country']."'")->getField("country_code");
                   $data['account_id'] = $m_account->where("account='".$v['sales_account']."'")->getField('id');
                   $m_profit->add($data);
               }
           }
           $num= $num + 1000;
       }while(!empty($result));

   }
}