Beispiel #1
0
        public static string apply_taoke_url(CmsForm cmsForm, ContentItem contentItem, string url, string pid)
        {
            if (!string.IsNullOrEmpty(url))
            {
                string out_log;
                int    n = 0;
apply_click:
                LogUtil.log_call(cmsForm, "开始转化活动链接:");
                string[] pid_list = Regex.Split(pid, "_", RegexOptions.IgnoreCase);
                string   adzoneid = "";
                string   siteid   = "";
                if (pid_list.Length > 3)
                {
                    siteid   = pid_list[2];
                    adzoneid = pid_list[3];
                }
                AlimamaClick alimamaClick = AlimamaUtil.query_taoke_click(cmsForm.appBean.taoke_cookie, url, adzoneid, siteid, out out_log);
                if (alimamaClick != null)
                {
                    return(alimamaClick.short_url);
                }
                else
                {
                    if (out_log.Contains("\"wait\""))
                    {
                        if (n < 10)
                        {
                            n = n + 10;
                            LogUtil.log_call(cmsForm, "申请过快,休息60秒:");
                            Thread.Sleep(60000);
                            goto apply_click;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (out_log.Contains("callLocation") || out_log.Contains("gen url item not found on call"))
                    {
                        //LogUtil.log_call(cmsForm, "[该链接转化失败。]");
                    }
                    else
                    {
                        if (n < 3)
                        {
                            n++;
                            LogUtil.log_call(cmsForm, "检测登录状态:");
                            AppUtil.alimama_login(cmsForm);
                            Thread.Sleep(1000);
                            goto apply_click;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #2
0
        public static void alimama_login(CmsForm cmsForm)
        {
            int n = 0;

            while (n < 10)
            {
                if (!AlimamaUtil.check_login(cmsForm.appBean.taoke_cookie) &&
                    Process.GetProcessesByName(Constants.alimama_login_exe_name).Length <= 0)
                {
                    LogUtil.log_call(cmsForm, "阿里妈妈登录过期。正在开始重新登录");
                    if (cmsForm.checkBoxAutoLogin.Checked)
                    {
                        AlimamaLogin.login(cmsForm, 1);
                    }
                    else
                    {
                        LogUtil.log_call(cmsForm, "没有开启阿里妈妈自动登录,无法完成登录");
                        return;
                    }
                }
                else if (AlimamaUtil.check_login(cmsForm.appBean.taoke_cookie))
                {
                    LogUtil.log_call(cmsForm, "阿里妈妈登录正常");
                    return;
                }
                else if (Process.GetProcessesByName(Constants.alimama_login_exe_name).Length > 0)
                {
                    LogUtil.log_call(cmsForm, "登录窗口正在运行中");
                    Thread.Sleep(3000);
                }
                n++;
            }
        }
Beispiel #3
0
        public static void updAliPid(object cmsFormobj)
        {
            Object[]   obj        = ((Object[])cmsFormobj);
            CmsForm    cmsForm    = ((CmsForm)obj[0]);
            int        zone_id    = ((int)obj[1]);
            AdzoneBean adzoneBean = AlimamaUtil.query_AdzoneBean("29", cmsForm.appBean.taoke_cookie);

            cmsForm.adzoneBean        = adzoneBean;
            cmsForm.appBean.member_id = adzoneBean.memberid;
            CmsUtil.view_cms_call(cmsForm, zone_id);
        }
Beispiel #4
0
        public static string apply_taoke_url_item(CmsForm cmsForm, ContentItem contentItem, UrlItem urlItem, string num_iid, string pid, ref int click_status, bool apply_jihua, int url_type)
        {
            string out_log;

            if (string.IsNullOrEmpty(pid))
            {
                LogUtil.log_call(cmsForm, "pid没有配置,无法完成转换连接");
                return(null);
            }
            ArrayList taoke_goods_list = AlimamaUtil.query_taoke_goods_list("https://item.taobao.com/item.htm?id=" + num_iid, cmsForm.appBean.taoke_cookie, out out_log);

            if (out_log.Contains("\"wait\""))
            {
                int n = 0;
                while (n < 2)
                {
                    taoke_goods_list = AlimamaUtil.query_taoke_goods_list("https://item.taobao.com/item.htm?id=" + num_iid, cmsForm.appBean.taoke_cookie, out out_log);
                    if (out_log.Contains("\"wait\""))
                    {
                        n++;
                        LogUtil.log_call(cmsForm, "申请过快,休息30秒:");
                        Thread.Sleep(30000);
                    }
                }
            }
            TaokeItem taokeItem = null;

            //LogUtil.log_call(cmsForm, "1:" + num_iid);
            if ((taoke_goods_list != null) && (taoke_goods_list.Count != 0))
            {
                //LogUtil.log_call(cmsForm, "2:");
                taokeItem             = new TaokeItem();
                taokeItem.num_iid     = num_iid;
                taokeItem.user_num_id = ((GoodsItem2)taoke_goods_list[0]).user_num_id;
                taokeItem.title       = ((GoodsItem2)taoke_goods_list[0]).title;
                taokeItem.tkRate      = ((GoodsItem2)taoke_goods_list[0]).tkRate;

                taokeItem.price       = ((GoodsItem2)taoke_goods_list[0]).zkPrice;
                taokeItem.userType    = "" + ((GoodsItem2)taoke_goods_list[0]).userType;
                taokeItem.user_num_id = ((GoodsItem2)taoke_goods_list[0]).user_num_id;

                taokeItem.tkMktStatus = ((GoodsItem2)taoke_goods_list[0]).tkMktStatus;
                taokeItem.eventRate   = ((GoodsItem2)taoke_goods_list[0]).eventRate;

                urlItem.taokeItem = taokeItem;
                int status = 0;
                AppUtil.apply_taoke_url_item(cmsForm, contentItem, taokeItem, ref status, pid, ref click_status, apply_jihua, url_type);
                if (!string.IsNullOrEmpty(taokeItem.short_url))
                {
                    return(taokeItem.short_url);
                }
            }
            return(null);
        }
Beispiel #5
0
        internal static void put_alimama_cookie_url(object obj)
        {
            CmsForm cmsForm = (CmsForm)obj;

            try
            {
                LogUtil.log_call(cmsForm, "开始跟踪");
                while (cmsForm.appBean.alimama_cookie_put_url_status)
                {
                    if (!AlimamaUtil.check_login(cmsForm.appBean.taoke_cookie) &&
                        Process.GetProcessesByName(Constants.alimama_login_exe_name).Length <= 0)
                    {
                        LogUtil.log_call(cmsForm, "阿里妈妈登录过期。正在开始重新登录");
                        if (cmsForm.checkBoxAutoLogin.Checked)
                        {
                            AlimamaLogin.login(cmsForm, 1);
                        }
                        else
                        {
                            LogUtil.log_call(cmsForm, "没有开启阿里妈妈自动登录,无法完成登录");
                        }
                    }
                    else if (AlimamaUtil.check_login(cmsForm.appBean.taoke_cookie))
                    {
                        LogUtil.log_call(cmsForm, "阿里妈妈登录正常");
                        string put_url = cmsForm.textBoxAlimamaCookieUrl.Text;
                        put_url = "http://" + Constants.api_url + "/zhushou/pid/create";
                        String user_key = cmsForm.appBean.user_token;

                        string create_pid = cmsForm.textBoxCreatePid.Text;

                        if (!String.IsNullOrEmpty(put_url) && !String.IsNullOrEmpty(create_pid))
                        {
                            StringUtil.login(cmsForm.httpService, put_url, "key=alimama_cookie_" + cmsForm.textBoxAlimamaAcc.Text.Trim() + "&content=" + cmsForm.appBean.taoke_cookie + "&member_token=" + user_key + "&pid=" + create_pid);
                        }
                    }
                    else if (Process.GetProcessesByName(Constants.alimama_login_exe_name).Length > 0)
                    {
                        LogUtil.log_call(cmsForm, "登录窗口正在运行中");
                        Thread.Sleep(3000);
                    }

                    Thread.Sleep(100000);
                }
                LogUtil.log_call(cmsForm, "停止批量转化");
            }
            catch (Exception exception)
            {
                //LogUtil.log_call(cmsForm, "[checkAutoLogin]出错!" + exception.ToString());
            }
        }
Beispiel #6
0
        public static string method_307(CmsForm cmsForm, string content)
        {
            string string96;

            try
            {
                CouponBean couponBean = new CouponBean();
                SendUtil.method_308(cmsForm, content, couponBean);
                if (!"".Equals(couponBean.uland_url))
                {
                    if (!SendUtil.method_138(cmsForm, couponBean.uland_url))
                    {
                        string    str        = StringUtil.subString(couponBean.uland_url, 0, "activityId=", "&");
                        string    str1       = StringUtil.subString(couponBean.uland_url, 0, "itemId=", "&");
                        string    out_log    = "";
                        ArrayList arrayLists = AlimamaUtil.smethod_17(str1, "1", out out_log);
                        if ((arrayLists == null ? false : arrayLists.Count != 0))
                        {
                            GoodsItem item = (GoodsItem)arrayLists[0];
                            string    str2 = "优惠券:http://shop.m.taobao.com/shop/coupon.htm?activityId={activityId}&sellerId={sellerId}<BR>下单:http://item.taobao.com/item.htm?id={itemId}";
                            str2    = str2.Replace("{activityId}", str).Replace("{sellerId}", item.num_iid).Replace("{itemId}", str1);
                            content = couponBean.content.Replace("{couponItemUrl}", str2);
                        }
                        else
                        {
                            LogUtil.log_call(cmsForm, "2合1链接出错!");
                            string96 = null;
                            return(string96);
                        }
                    }
                    else
                    {
                        string96 = content;
                        return(string96);
                    }
                }
                string96 = content;
            }
            catch (Exception exception)
            {
                LogUtil.log_call(cmsForm, string.Concat("[parseCouponItemContentUrl]出错:", exception.ToString()));
                string96 = null;
            }
            return(string96);
        }
Beispiel #7
0
 public static string get_kouling(CmsForm cmsForm, string uland_url, string pic, string text, string ext)
 {
     if (!cmsForm.radioButtonsetting_app_ben.Checked)
     {
         string koulingHaopintui = KoulingUtil.get_kouling_haopintui(cmsForm, uland_url, pic, text, ext);
         if (string.IsNullOrEmpty(koulingHaopintui))
         {
             string      str      = StringUtil.subString(uland_url, 0, "activityId=", "&");
             string      str1     = StringUtil.subString(uland_url, 0, "itemId=", "&");
             string      str2     = StringUtil.subString(uland_url, 0, "pid=", "&");
             string      str3     = StringUtil.subString(uland_url, 0, "dx=", "&");
             string      str4     = "";
             KoulingBean _kouling = AlimamaUtil.get_kouling(str, str1, str2, str3, out str4);
             if (_kouling != null)
             {
                 return(_kouling.password);
             }
         }
         return(koulingHaopintui);
     }
     if (string.IsNullOrEmpty(cmsForm.textBox_setting_appId.Text.Trim()) || string.IsNullOrEmpty(cmsForm.textBox_setting_appKey.Text.Trim()))
     {
         string      str5        = StringUtil.subString(uland_url, 0, "activityId=", "&");
         string      str6        = StringUtil.subString(uland_url, 0, "itemId=", "&");
         string      str7        = StringUtil.subString(uland_url, 0, "pid=", "&");
         string      str8        = StringUtil.subString(uland_url, 0, "dx=", "&");
         string      str9        = "";
         KoulingBean koulingBean = AlimamaUtil.get_kouling(str5, str6, str7, str8, out str9);
         if (koulingBean != null)
         {
             return(koulingBean.password);
         }
     }
     else
     {
         string _kouling1 = KoulingUtil.get_kouling(cmsForm.textBox_setting_appId.Text.Trim(), cmsForm.textBox_setting_appKey.Text.Trim(), uland_url, pic, text, ext);
         if (!string.IsNullOrEmpty(_kouling1))
         {
             return(StringUtil.subString(_kouling1, 0, "<model>", "</model>"));
         }
     }
     return(null);
 }
Beispiel #8
0
        public static void binding_income(CmsForm cmsForm)
        {
            string out_log = "";

            if (cmsForm.appBean == null ||
                string.IsNullOrEmpty(cmsForm.appBean.taoke_cookie))
            {
                return;
            }
            AlimamaBean alimamaBean = AlimamaUtil.get_AlimamaBean(cmsForm.appBean.taoke_cookie, out out_log);

            //LogUtil.log_call(cmsForm, cmsForm.appBean.taoke_cookie);
            //LogUtil.log_call(cmsForm, out_log);
            if (alimamaBean != null)
            {
                string      member_id        = cmsForm.appBean.member_id;
                HttpService httpservice      = cmsForm.httpService;
                long        user_id          = cmsForm.appBean.user_id;
                string      app_id           = cmsForm.appBean.cms_app_id;
                String      user_key         = cmsForm.appBean.user_key;
                String      user_name        = cmsForm.appBean.user_name;
                String      user_binding_url = Constants.binding_income_url;
                string      datastr          = String.Concat(
                    "user_id=" + user_id
                    , "&user_key=" + user_key
                    , "&user_token="
                    , "&app_id=" + app_id
                    , "&alimama_id=" + member_id
                    , "&curMonthTotal=" + alimamaBean.curMonthTotal
                    , "&lastMonthTotal=" + alimamaBean.lastMonthTotal
                    , "&yesterdayTotal=" + alimamaBean.yesterdayTotal

                    );
                String body = httpservice.post_http(user_binding_url, datastr, null);
                //LogUtil.log_call(cmsForm, body);
            }
        }
Beispiel #9
0
    public static CouponItem get_coupon(string coupon_url, String num_iid, String pid, out string money)
    {
        money = "";
        CouponItem class2 = null;

        if (!(coupon_url.Contains("coupon") && coupon_url.Contains("taobao.com")))
        {
            coupon_url = get_redirect_url(coupon_url, coupon_url);
        }
        coupon_url = HttpUtility.UrlDecode(coupon_url);
        coupon_url = coupon_url.Replace("seller_id=", "sellerId=").Replace("activity_id=", "activityId=");
        string seller_id   = StringUtil.subString(coupon_url, 0, "sellerId=", "&");
        string activity_id = StringUtil.subString(coupon_url, 0, "activityId=", "&");

        if (!string.IsNullOrEmpty(seller_id) &&
            !string.IsNullOrEmpty(activity_id) &&
            !string.IsNullOrEmpty(num_iid) &&
            !string.IsNullOrEmpty(pid))
        {
            class2 = new CouponItem();
            string out_log;
            string ctoken = AlimamaUtil.smethod_61(activity_id, num_iid, pid, "1", out out_log);
            string str1   = AlimamaUtil.smethod_62(ctoken, activity_id, num_iid, pid, "1", out out_log, out money);
            try
            {
                class2.money     = (int)double.Parse(money);
                class2.leftCount = 100000;
            }
            catch
            {
                class2.money = 0;
            }
            return(class2);
        }

        string    str3    = "http://shop.m.taobao.com/shop/coupon.htm?seller_id={seller_id}&activity_id={activity_id}";
        string    address = str3.Replace("{seller_id}", seller_id).Replace("{activity_id}", activity_id);
        WebClient client  = new WebClient();

        client.Headers.Add("user-agent", "Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10");
        byte[] buffer = client.DownloadData(address);
        string str5   = "";
        string str6   = client.ResponseHeaders["Content-Encoding"];

        if ("gzip".Equals(str6))
        {
            str5 = GzipUtil.zip_to_string(buffer, Encoding.UTF8);
        }
        else
        {
            str5 = Encoding.UTF8.GetString(buffer);
        }
        class2 = new CouponItem();
        if (!str5.Contains("该优惠券不存在或者已经过期"))
        {
            int index  = str5.IndexOf("元优惠券");
            int length = 1;
            while (regex_0.IsMatch(str5.Substring(index - length, length)))
            {
                length++;
            }
            length--;
            try
            {
                class2.money = int.Parse(str5.Substring(index - length, length));
            }
            catch
            {
                class2.money = 0;
            }
            try
            {
                class2.leftCount = int.Parse(StringUtil.subString(str5, 0, "<span class=\"rest\">", "</span>"));
            }
            catch
            {
                class2.leftCount = 0;
            }
            try
            {
                class2.receiveCount = int.Parse(StringUtil.subString(str5, 0, "<span class=\"count\">", "</span>"));
            }
            catch
            {
                class2.receiveCount = 0;
            }
            class2.endTime = StringUtil.subString(str5, 0, "<dd>有效期:", "</dd>");
        }
        return(class2);
    }
Beispiel #10
0
        public static void log_login(CmsForm cmsForm, int login_status_int, string cookie, int zoneId)
        {
            try
            {
                cmsForm.appBean.alimama_login_status = true;
                FormUtil.set_formWindowState(cmsForm, FormWindowState.Normal);
                if (login_status_int == Constants.FORM_MSG_TYPE_LOGINED)
                {
                    cmsForm.appBean.alimama_login_status = true;
                    cmsForm.appBean.taoke_cookie         = cookie;
                    bool check_login = AlimamaUtil.check_login(cookie);
                    LogUtil.log_call(cmsForm, "阿里妈妈登录完成,返回状态:【" + (check_login ? "登录成功" : "登录失败") + "】!");
                    new Thread(new ParameterizedThreadStart(AlimamaAdUtil.updAliPid)).Start(new Object[] { cmsForm, zoneId });
                    if (check_login)
                    {
                        ConfigUtil.save_taoke_cookie(cmsForm);
                    }

                    if (cmsForm.thread_online != null)
                    {
                        try
                        {
                            cmsForm.thread_online.Abort();
                            cmsForm.thread_online = null;
                        }
                        catch
                        {
                        }
                    }
                    cmsForm.thread_online = new Thread(new ParameterizedThreadStart(AlimamaUtil.online));
                    cmsForm.thread_online.IsBackground = true;
                    cmsForm.thread_online.Start(cookie);

                    //BindingUtil.isBinding_call(cmsForm);
                }
                else if (login_status_int == Constants.FORM_MSG_TYPE_NOTOPEN)
                {
                    cmsForm.appBean.alimama_login_status = false;
                    LogUtil.log_call(cmsForm, "网页无法打开!");
                    if (cmsForm.checkBoxAutoLogin.Checked)
                    {
                        AlimamaLogin.login(cmsForm, zoneId);
                    }
                }
                else if (login_status_int == Constants.FORM_MSG_TYPE_CHKTMOUT)
                {
                    cmsForm.appBean.alimama_login_status = false;
                    LogUtil.log_call(cmsForm, "检查登录成功页面超过8秒!");
                    if (cmsForm.checkBoxAutoLogin.Checked)
                    {
                        AlimamaLogin.login(cmsForm, zoneId);
                    }
                }
                else if (login_status_int == Constants.FORM_MSG_TYPE_CLOSENOTLOGINED)
                {
                    cmsForm.appBean.alimama_login_status = false;
                    LogUtil.log_call(cmsForm, "登录窗口被手动关闭,并且没有登录成功!");
                }
            }
            catch (Exception exception)
            {
                LogUtil.log_call(cmsForm, "[processFormMsg]出错," + exception.ToString());
            }
        }
Beispiel #11
0
        public static string zhuan_pid(CmsForm cmsForm, string content)
        {
            string    string81;
            ArrayList arrayLists;
            bool      flag;

            try
            {
                int num = 0;
                while (!AlimamaUtil.check_login(cmsForm.appBean.taoke_cookie))
                {
                    //if (this.bool_28)
                    //{
                    //    LogUtil.log_call(cmsForm, "阿里妈妈显示请求频繁,等待30秒再试!");
                    //    Thread.Sleep(30000);
                    //}
                    //else
                    if (num >= 30)
                    {
                        LogUtil.log_call(cmsForm, "登录阿里妈妈失败!");
                        string81 = "notlogin";
                        return(string81);
                    }
                    else
                    {
                        num++;
                        //this.method_8(true);
                        AlimamaLogin.login(cmsForm, 0);
                        Thread.Sleep(20000);
                    }
                }
                //content = ᝛.ᜀ(content);
                //content = ᝛.ᜂ(content);
                string str = SendUtil.method_307(cmsForm, content);
                if (str != null)
                {
                    content = str;
                    //this.string_80 = ᜸.ᜄ(content.Replace("<", " <").Replace(">", "> ")).Replace("&nbsp;", " ");
                    //this.string_81 = content;
                    //this.string_49 = this.string_81;
                    //this.arrayList_5 = new ArrayList();
                    //this.bool_34 = false;
                    //this.string_83 = "";
                    int num1 = 0;
                    arrayLists = null;
                    while (true)
                    {
                        //ArrayList arrayLists1 = this.method_324(this.string_80);
                        //arrayLists = arrayLists1;
                        //if (arrayLists1 != null)
                        //{
                        //    goto Label1;
                        //}
                        //if (num1 >= 3)
                        //{
                        //    break;
                        //}
                        //LogUtil.log_call(cmsForm, string.Concat("PID转换第【", num1 + 1, "】次失败,正在重试!"));
                        //Thread.Sleep(1000);
                        num1++;
                    }
                    LogUtil.log_call(cmsForm, "PID转换失败【3】次,跳过!");
                    string81 = null;
                }
                else
                {
                    string81 = null;
                }
            }
            catch (Exception exception)
            {
                LogUtil.log_call(cmsForm, string.Concat("[changeFollowSndPid]出错:", exception.ToString()));
                string81 = null;
            }
            return(string81);

Label1:
            //flag = (this.float_1 <= this.float_4 ? true : "".Equals(this.string_70));
            //if (flag)
            //{
            //    this.int_26 = this.method_325(arrayLists);
            //    this.string_81 = this.string_81.Replace("¥", "$");
            //    GClass30 gClass30 = null;
            //    this.bool_5 = false;
            //    if ((this.bool_3 ? false : !this.bool_6))
            //    {
            //        this.string_81 = this.method_317(arrayLists);
            //    }
            //    else
            //    {
            //        gClass30 = this.method_140(this.string_81);
            //        if (this.bool_6)
            //        {
            //            this.method_311(gClass30, arrayLists, this.int_26);
            //        }
            //        else if (!this.bool_5)
            //        {
            //            this.string_81 = this.method_317(arrayLists);
            //        }
            //        else
            //        {
            //            this.string_81 = gClass30.string_1.Replace("{couponItemUrl}", string.Concat("【领券下单地址】", this.method_315(gClass30)));
            //            if ((this.bool_32 || !this.bool_4 ? false : this.int_26 == 4))
            //            {
            //                this.string_81 = string.Concat(this.string_81, "<BR>复制这条消息,", gClass30.᜞_0.ᜀ, ",打开【手机淘宝】即可领券并下单");
            //            }
            //        }
            //    }
            //    string81 = this.string_81;
            //    return string81;
            //}
            //else
            //{
            //    string81 = "lowestcms";
            //    return string81;
            //}
            return("");
        }
Beispiel #12
0
        public static void apply_taoke_url_item(CmsForm cmsForm, ContentItem contentItem, TaokeItem taokeItem, ref int status, string pid, ref int click_status, bool apply_jihua, int url_type)
        {
            int qunfa_coupon     = 0;
            int qunfa_commission = 0;

            try
            {
                qunfa_coupon     = int.Parse(cmsForm.textBox_qunfa_coupon.Text.Trim());
                qunfa_commission = int.Parse(cmsForm.textBox_qunfa_commission.Text.Trim());
            }
            catch (Exception)
            {}

            //LogUtil.log_call(cmsForm, "taokeItem.num_iid:" + taokeItem.num_iid);
            if (!string.IsNullOrEmpty(taokeItem.num_iid))
            {
                string out_log = "";
                int    n       = 0;
                if (apply_jihua)
                {
                    //LogUtil.log_call(cmsForm, "开始计划的检测:");
campaign:
                    ArrayList goods_campaign_list = AlimamaUtil.query_campaign_list(cmsForm.appBean.taoke_cookie, taokeItem.num_iid, out out_log);
                    CampaignItem1 campaignItem_current       = null; //最高计划
                    CampaignItem1 campaignItem_current_auto  = null; //最高自动计划
                    CampaignItem1 campaignItem_current_apply = null; //已经申请的计划
                    if (goods_campaign_list != null && goods_campaign_list.Count > 0)
                    {
                        foreach (CampaignItem1 campaignItem1 in goods_campaign_list)
                        {
                            if (campaignItem1.commissionRate >= taokeItem.tkRate &&
                                (campaignItem_current == null ||
                                 campaignItem_current.commissionRate < campaignItem1.commissionRate))
                            {
                                campaignItem_current = campaignItem1;
                            }
                            if (campaignItem1.commissionRate >= taokeItem.tkRate &&
                                campaignItem1.manualAudit == "0" &&
                                (campaignItem_current_auto == null ||
                                 campaignItem_current_auto.commissionRate < campaignItem1.commissionRate))
                            {
                                campaignItem_current_auto = campaignItem1;
                            }
                            if (campaignItem1.Exist == "true")
                            {
                                campaignItem_current_apply = campaignItem1;
                            }
                        }
                    }
                    else
                    {
                        if (out_log.Contains("\"wait\""))
                        {
                            if (n < 10)
                            {
                                n = n + 10;
                                LogUtil.log_call(cmsForm, "申请过快,休息30秒:");
                                Thread.Sleep(60000);
                                goto campaign;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else if (out_log.Contains("\"ok\":true"))
                        {
                        }
                        else
                        {
                            if (n < 3)
                            {
                                n++;
                                LogUtil.log_call(cmsForm, "检测登录状态:");
                                AppUtil.alimama_login(cmsForm);
                                Thread.Sleep(3000);
                                goto campaign;
                            }
                            else
                            {
                                //return;
                            }
                        }
                    }

                    out_log = "";
                    n       = 0;
apply_campaign:
                    if (campaignItem_current_auto != null)
                    {
                        if (campaignItem_current_auto.Exist == "true")
                        {
                            //LogUtil.log_call(cmsForm, "定向计划【" + campaignItem_current_auto.CampaignName + "】已经申请过。本次跳过重复申请");
                        }
                        else
                        {
                            LogUtil.log_call(cmsForm, "开始申请定向计划【" + campaignItem_current_auto.CampaignName + "】");
                            AlimamaUtil.apply_campaign(cmsForm, campaignItem_current_auto.CampaignID
                                                       , campaignItem_current_auto.ShopKeeperID, Constants.applyreason_pre, cmsForm.appBean.applyreason, cmsForm.appBean.taoke_cookie, out out_log, "");
                            if (out_log.Contains("\"wait\""))
                            {
                                if (n < 10)
                                {
                                    n = n + 10;
                                    LogUtil.log_call(cmsForm, "申请过快,休息30秒:");
                                    Thread.Sleep(60000);
                                    goto apply_campaign;
                                }
                                else
                                {
                                    //return;
                                }
                            }
                        }
                    }
                    else if (campaignItem_current != null)
                    {
                        if (campaignItem_current.Exist == "true")
                        {
                            //LogUtil.log_call(cmsForm, "定向计划【" + campaignItem_current.CampaignName + "】已经申请过。本次跳过重复申请");
                        }
                        else
                        {
                            LogUtil.log_call(cmsForm, "开始申请定向计划【" + campaignItem_current.CampaignName + "】");
                            AlimamaUtil.apply_campaign(cmsForm, campaignItem_current.CampaignID
                                                       , campaignItem_current.ShopKeeperID, Constants.applyreason_pre, cmsForm.appBean.applyreason, cmsForm.appBean.taoke_cookie, out out_log, "");
                            if (out_log.Contains("\"wait\""))
                            {
                                if (n < 10)
                                {
                                    n = n + 10;
                                    LogUtil.log_call(cmsForm, "申请过快,休息30秒:");
                                    Thread.Sleep(60000);
                                    goto apply_campaign;
                                }
                                else
                                {
                                    //return;
                                }
                            }
                        }
                    }

                    out_log = "";
                    n       = 0;
apply_event:
                    GoodsItem2 goodsItem2 = AlimamaUtil.query_taoke_item_event(cmsForm.appBean.taoke_cookie, taokeItem.num_iid, out out_log);
                    url_type = 0;
                    if (goodsItem2 != null &&
                        taokeItem.tkRate < goodsItem2.eventRate &&
                        (campaignItem_current_auto == null ||
                         campaignItem_current_auto.commissionRate < goodsItem2.eventRate))
                    {
                        url_type = 1;
                    }
                    else
                    {
                        if (out_log.Contains("\"wait\""))
                        {
                            if (n < 10)
                            {
                                n = n + 10;
                                LogUtil.log_call(cmsForm, "申请过快,休息30秒:");
                                Thread.Sleep(60000);
                                goto apply_event;
                            }
                            else
                            {
                                //return;
                            }
                        }
                    }

                    double commission_rate = 0;
                    if (url_type == 1)
                    {
                        LogUtil.log_call(cmsForm, "通过鹊桥计划转换链接:佣金比例【" + goodsItem2.eventRate + "%】");
                        commission_rate = goodsItem2.eventRate;
                        contentItem.dx  = 0;
                    }
                    else
                    {
                        contentItem.dx = 1;
                        if (campaignItem_current_auto != null)
                        {
                            LogUtil.log_call(cmsForm, "通过定向计划转换链接:佣金比例【" + campaignItem_current_auto.commissionRate + "%】");
                            commission_rate     = campaignItem_current_auto.commissionRate;
                            taokeItem.auto_Rate = campaignItem_current_auto.commissionRate;
                        }
                        else
                        {
                            if (campaignItem_current != null)
                            {
                                LogUtil.log_call(cmsForm, "通过通用计划转换链接:佣金比例【" + taokeItem.tkRate + "%】 定向计划【" + campaignItem_current.CampaignName + "】审核通过后,会自动走高佣金【" + campaignItem_current.commissionRate + "%】");
                                commission_rate = taokeItem.tkRate;
                            }
                            else
                            {
                                if (campaignItem_current_apply != null)
                                {
                                    AlimamaUtil.exitCampaign(taokeItem.user_num_id, campaignItem_current_apply.CampaignID, cmsForm.appBean.taoke_cookie, out out_log);
                                    if (!string.IsNullOrEmpty(out_log))
                                    {
                                        LogUtil.log_call(cmsForm, out_log);
                                    }
                                }
                                LogUtil.log_call(cmsForm, "通过通用计划转换链接:佣金比例【" + taokeItem.tkRate + "%】");
                                commission_rate = taokeItem.tkRate;
                            }
                        }
                    }


                    //LogUtil.log_call(cmsForm, "【commission_rate:" + commission_rate + "】");
                    if (qunfa_commission > commission_rate)
                    {
                        //LogUtil.log_call(cmsForm, "佣金比例小于设置最低佣金比例,转换失败");
                        click_status = 2;
                        //return;
                    }
                    contentItem.url_type = url_type;
                }

                out_log = "";
                n       = 0;
apply_click:
                string[] pid_list = Regex.Split(pid, "_", RegexOptions.IgnoreCase);
                string   adzoneid = "";
                string   siteid   = "";
                if (pid_list.Length > 3)
                {
                    siteid   = pid_list[2];
                    adzoneid = pid_list[3];
                }
                AlimamaClick alimamaClick = AlimamaUtil.query_taoke_click(cmsForm.appBean.taoke_cookie, taokeItem.num_iid, adzoneid, siteid, url_type, out out_log);
                if (alimamaClick != null)
                {
                    taokeItem.click_url = alimamaClick.url;
                    taokeItem.short_url = alimamaClick.short_url;
                    if (taokeItem.tkMktStatus == 1 &&
                        !String.IsNullOrEmpty(alimamaClick.coupon_short_url) &&
                        alimamaClick.coupon_short_url.Contains("http"))
                    {
                        taokeItem.click_url = alimamaClick.coupon_url;
                        taokeItem.short_url = alimamaClick.coupon_short_url;
                    }
                }
                else
                {
                    if (out_log.Contains("\"wait\""))
                    {
                        if (n < 10)
                        {
                            n = n + 10;
                            LogUtil.log_call(cmsForm, "申请过快,休息30秒:");
                            Thread.Sleep(60000);
                            goto apply_click;
                        }
                        else
                        {
                            //return;
                        }
                    }
                    else if (out_log.Contains("callLocation") || out_log.Contains("gen url item not found on call"))
                    {
                        //LogUtil.log_call(cmsForm, "[该商品已经下架或者退出了淘客推广。]");
                    }
                    else
                    {
                        //LogUtil.log_call(cmsForm,"[转化失败的原因:]"+out_log);
                    }
                }
            }
        }