<?php
/**
 * Created by PhpStorm.
 * User: z-yang
 * Date: 2020/12/24
 * Time: 17:04
 */

namespace App\Modules\Channel\Services;



use App\Modules\Channel\Models\ReportToChannelOrders;
use App\Modules\Channel\Models\ReportToChannelUsers;

class ReportToChannelUserAndOrderService
{
    public static $user_type = 'user';
    public static $order_type = 'order';

    const SUCCESS = 'success';

    public static function getReportUrl($distribution_channel_id,$type){
        if($distribution_channel_id == 10500){
            return 'https://sitewyn29mk4rrn53r7e.wd.pinyuew.com.cn/channelOrderAndUserReport';
        }
        if($distribution_channel_id == 10543){
            return 'http://yx1.hncwzx88.cn/api/app/home/wdy';
        }

        if($distribution_channel_id == 10545){
            return 'http://yx1.hncwzx88.cn/api/app/home/wdy';
        }
		
		if($distribution_channel_id == 10588){
            return 'https://xdd.guozhen6.com/ysh/wdapi/';
        }
		
        if($distribution_channel_id == 10590){
            return 'https://xdd.guozhen6.com/ysh/wdapi/';
        }
        
        return '';
    }


    public static function updateUserErrorRecord($id,$data){
        ReportToChannelUsers::where('id',$id)->update($data);
    }

    public static function updateOrderErrorRecord($id,$data){
        ReportToChannelOrders::where('id',$id)->update($data);
    }

    public static function getUserErrorRecord($date){
        return ReportToChannelUsers::where('report_status',0)
            ->where('created_at','>=',$date)
            ->select('id','uid','distribution_channel_id','register_ip','user_agent','user_created_at')
            ->get();
    }

    public static function getOrderErrorRecord($date){
        return ReportToChannelOrders::where('report_status',0)
            ->where('created_at','>=',$date)
            ->select('id','uid','distribution_channel_id','price','order_created_at')
            ->get();
    }
}