123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- require_once 'DB_PDO.class.php';
- require_once 'TBK_v2.class.php';
- require_once 'confv2.class.php';
- define("DETAILDEBUG", 0);//打印流程详细信息,如有需要,设为1
- define("LIMIT_NUM", 0);//限制导入条数,0不限制,方便测试,上线设为0
- date_default_timezone_set('PRC');
-
- sync_vq();
- /**
- * 同步维权订单
- */
- function sync_vq(){
- //同步订单脚本
- # 1.同步1天内维权订单
-
- $orderResult = array();
- $start_time = date("Y-m-d 00:00:00", strtotime('-1 day'));
- //渠道二方维权订单
- for($i=1;$i<100;$i++){
- $res = TBK::syncVqOrder($i, $start_time, 1, 1);
- if(empty($res)){
- break;
- }
- $orderResult = array_merge($orderResult, $res);
- }
- //会员二方维权订单
- for($i=1;$i<100;$i++){
- $res = TBK::syncVqOrder($i, $start_time, 1, 2);
- if(empty($res)){
- break;
- }
- $orderResult = array_merge($orderResult, $res);
- }
- //渠道三方维权订单
- for($i=1;$i<100;$i++){
- $res = TBK::syncVqOrder($i, $start_time, 2, 1);
- if(empty($res)){
- break;
- }
- $orderResult = array_merge($orderResult, $res);
- }
- //会员三方维权订单
- for($i=1;$i<100;$i++){
- $res = TBK::syncVqOrder($i, $start_time, 2, 2);
- if(empty($res)){
- break;
- }
- $orderResult = array_merge($orderResult, $res);
- }
- # 统计
- $res_count = array(
- 'total_num' => 0,
- 'generalupdate_num' => 0,
- 'fail_update_num' => 0,
- );
- #初始化pdo
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- foreach($orderResult as $k=>$orderDetail){
- $res_count['total_num']++;
-
- $order_id=$orderDetail['tb_trade_id'];
- if($orderDetail['refund_status'] == '2'){
- $maintain_power = 3;
- }else{
- continue;
- }
- $power_create_at = $orderDetail['tk_refund_time'];
- $power_end_at = isset($orderDetail['tk_refund_suit_time']) ? $orderDetail['tk_refund_suit_time'] : null;
-
- echo 'order_id:'.$order_id.'|| goods_name:'.$orderDetail['tb_auction_title'].'|| maintain_power:'.$maintain_power.'|| power_create_at:'.$power_create_at;
- echo "\n";
-
- try{
- $_PDO->beginTransaction();
- //更新order_rebate
- $sql="update order_rebate set maintain_power=:maintain_power,power_create_at=:power_create_at,power_end_at=:power_end_at where order_id=:order_id";
- if($maintain_power==3) $sql="update order_rebate set maintain_power=:maintain_power,power_create_at=:power_create_at,power_end_at=:power_end_at,status=0 where order_id=:order_id";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute(array(':maintain_power'=>$maintain_power,':power_create_at'=>$power_create_at,':power_end_at'=>$power_end_at,':order_id'=>$order_id));
- $res = $stmt->rowCount();
- echo "更新order_rebate:".$res."\n";
- //更新order_rebate_profit
- $sql="update order_rebate_profit set maintain_power=:maintain_power,power_create_at=:power_create_at,power_end_at=:power_end_at where order_id=:order_id";
- if($maintain_power==3) $sql="update order_rebate_profit set maintain_power=:maintain_power,power_create_at=:power_create_at,power_end_at=:power_end_at,status=0 where order_id=:order_id";
-
- $stmt = $_PDO->prepare($sql);
- $stmt->execute(array(':maintain_power'=>$maintain_power,':power_create_at'=>$power_create_at,':power_end_at'=>$power_end_at,':order_id'=>$order_id));
- $res = $stmt->rowCount();
- echo "更新order_rebate_profit:".$res."\n";
-
- if($res){
- $res_count['generalupdate_num']++;
- }else{
- $res_count['fail_update_num']++;
- }
- $_PDO->commit();
- }catch(Exception $e){
- echo 'err_msg'.$e->getMessage()."\n";
- $_PDO->rollback();
- }
- echo "\n/ ** order{$res_count['total_num']}-End ** /";
- echo "\n\n\n";
- }
- echo "\n维权订单:";
- var_dump($res_count);
- }
-
|