Ejemplo n.º 1
0
        /// <summary>
        /// 发送文本
        /// </summary>
        /// <param name="shareData">The share data.</param>
        /// <param name="wins">The wins.</param>
        private void SendText(List <weChatShareTextModel> shareData, List <WindowInfo> wins, bool isImageText, GoodsModel goods)
        {
            bool isLogin = true;

            foreach (var item in shareData)
            {
                try
                {
                    Tuple <string, string> resultTuple = TaobaoHelper.GetGaoYongToken(goods.goodsDetailUrl, goods.goodsId, item.tpwd, MyUserInfo.GetTbToken(), MyUserInfo.cookies, out isLogin);
                    if (resultTuple != null)
                    {
                        if (!isLogin)
                        {
                            hotForm.isTaskRuning = true;
                            isStartTask          = false;
                            hotForm.SendNotify();
                            System.Threading.Thread.Sleep(5000);
                            break;
                        }
                        item.status = 0;
                        if (item.text.Contains("[二合一淘口令]"))
                        {
                            item.text = item.text.Replace("[二合一淘口令]", resultTuple.Item1);
                        }
                        else
                        {
                            item.text += "复制这条信息,打开『手机淘宝』" + resultTuple.Item1 + "领券下单即可抢购宝贝";
                        }

                        if (item.text.Contains("[短链接]"))
                        {
                            item.text = item.text.Replace("[短链接]", resultTuple.Item2);
                        }
                        LogicHotTao.Instance(MyUserInfo.currentUserId).UpdateUserShareTextStatus(item.id, item.text, resultTuple.Item1);
                    }
                    else
                    {
                        bool flag = LogicHotTao.Instance(MyUserInfo.currentUserId).BuildTpwd(MyUserInfo.currentUserId, MyUserInfo.LoginToken, goods, item, appkey, appsecret);
                        if (!flag)
                        {
                            continue;
                        }
                    }

                    if (!isStartTask || MyUserInfo.currentUserId == 0)
                    {
                        break;
                    }

                    ClipboardObjectData(item.text);
                    //如果当前微信已经发送,则结束本循环
                    if (textResult.Contains(item.title))
                    {
                        continue;
                    }
                    wins = WinApi.GetAllDesktopWindows();
                    if (wins == null || wins.Count() == 0)
                    {
                        continue;
                    }

                    bool b = wins.Exists(win => { return(win.szWindowName == item.title); });
                    if (b)
                    {
                        var win = wins.Find(w => { return(w.szWindowName == item.title); });
                        //设置微信为输入焦点

                        //复制粘贴发送
                        WinApi.SendData(win.hWnd, win.winType == 1);

                        SleepImage(0.5m);

                        if (!textResult.Contains(item.title))
                        {
                            textResult.Add(item.title);
                        }

                        if (isImageText)
                        {
                            UpdateShareTextStatus(item.id);//更新修改状态
                        }
                    }
                    else
                    {
                        SendNotify(item.title);//通知
                    }
                }
                catch (Exception ex)
                {
                    //通知
                    SendNotify(item.title);

                    if (!textResult.Contains(item.title))
                    {
                        textResult.Add(item.title);
                    }

                    //添加错误日志
                    AddErrorLog(item, 1);
                    if (isImageText)
                    {
                        UpdateShareTextStatus(item.id);//更新修改状态
                    }
                    log.Error(ex);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 申请高佣
        /// </summary>
        /// <param name="goodsDetailUrl">商品详情地址</param>
        public void ApplyPlan(string goodsId, string goodsName)
        {
            if (lw == null)
            {
                logRuningList.Add(new LogRuningModel()
                {
                    goodsid   = goodsId,
                    goodsName = goodsName,
                    title     = goodsId,
                    content   = goodsName,
                    logTime   = DateTime.Now,
                    logType   = LogTypeOpts.申请高佣,
                    isError   = true,
                    remark    = "您还没登录阿里妈妈,请登录后重试!"
                });
                return;
            }
            ThreadHandle(() =>
            {
                LogRuningModel logData = new LogRuningModel()
                {
                    goodsid   = goodsId,
                    goodsName = goodsName,
                    title     = goodsId,
                    content   = goodsName,
                    logTime   = DateTime.Now,
                    logType   = LogTypeOpts.申请高佣,
                };
                try
                {
                    MyUserInfo.cookies = lw.GetCurrentCookies();
                    //获取更多定向计划数据
                    string url = string.Format("http://pub.alimama.com/pubauc/getCommonCampaignByItemId.json?itemId={0}&t={1}&_tb_token_={2}&pvid=", goodsId, getClientMsgId(), MyUserInfo.GetTbToken());
                    CookieContainer cookiesContainer = new CookieContainer();
                    cookiesContainer.Add(MyUserInfo.cookies);
                    string content = BaseRequestService.HttpGet(url, cookiesContainer);
                    TaobaoCommonCampaignItemsModel items = JsonConvert.DeserializeObject <TaobaoCommonCampaignItemsModel>(content);
                    if (items != null && items.ok && items.data != null && items.data.Count > 0)
                    {
                        var data = items.data.FindAll(i =>
                        {
                            return(i.manualAudit == 0);
                        });
                        var listData = data.OrderByDescending(r => r.commissionRate).ToList();

                        TaobaoCommonItem item = listData[0];
                        if (item != null)
                        {
                            if (!item.Exist)
                            {
                                string applyUrl = "http://pub.alimama.com/pubauc/applyForCommonCampaign.json";
                                Dictionary <string, string> formFields = new Dictionary <string, string>();
                                formFields["campId"]      = item.CampaignID;
                                formFields["keeperid"]    = item.ShopKeeperID;
                                formFields["applyreason"] = "您好,淘客人多,请于通过!";
                                formFields["_tb_token_"]  = MyUserInfo.GetTbToken();
                                formFields["t"]           = getClientMsgId().ToString();
                                formFields["pvid"]        = "";
                                string res = BaseRequestService.HttpPost(applyUrl, formFields, cookiesContainer);
                                log.Info(res);
                                TaobaoCommonCampaignItemsModel _items = JsonConvert.DeserializeObject <TaobaoCommonCampaignItemsModel>(res);
                                if (_items != null)
                                {
                                    if (_items.ok)
                                    {
                                        logData.isError = false;
                                        logData.remark  = "[" + goodsId + "]" + "自动申请佣金成功,佣金:" + item.commissionRate + " %";
                                    }
                                    else
                                    {
                                        logData.isError = true;
                                        logData.remark  = "[" + goodsId + "]" + _items.info.message;
                                    }
                                }
                            }
                            else
                            {
                                logData.isError = false;
                                logData.remark  = "[" + goodsId + "]" + "已经申请过了";
                            }
                        }
                        else
                        {
                            logData.isError = false;
                            logData.remark  = "[" + goodsId + "]" + "没找到定向佣金";
                        }
                    }
                    else
                    {
                        logData.isError = false;
                        logData.remark  = "[" + goodsId + "]" + "没找到定向佣金";
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                    logData.isError = true;
                    logData.remark  = "[" + goodsId + "]" + "一瞬间,风起人涌,交通拥堵,请稍后重试!";
                }
                logRuningList.Add(logData);
            });
        }