Ejemplo n.º 1
0
        /// <summary>
        /// 修改帐号
        /// Api.ashx?act=updatezh&zh=b帐号&status=已申请&ids=114964887,115371546,115365386
        /// </summary>
        /// <param name="con"></param>
        /// <returns></returns>
        private ApiResult UpdateZh(HttpContext con)
        {
            BLL.plans bllplans = new BLL.plans();
            DataSet   ds       = new DataSet();
            ApiResult res      = new ApiResult();

            try
            {
                string ids    = GetRequest(con, "ids");
                string zh     = GetRequest(con, "zh");
                string status = GetRequest(con, "status");
                ids = "," + ids + ",";
                int total = 0;
                var list  = bllplans.GetList(1, int.MaxValue, ref total, m => ids.Contains("," + m.campaignId + ","), m => m.id, false);

                foreach (var model in list)
                {
                    if (status == "已通过")
                    {
                        model.zhanghaos_ok += "#" + zh;
                        model.zhanghaos_ok  = model.zhanghaos_ok.Trim('#');
                        List <string> tmplist = new List <string>();
                        if (!string.IsNullOrEmpty(model.zhanghaos_doing))
                        {
                            tmplist = new List <string>(model.zhanghaos_doing.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries));
                        }
                        model.zhanghaos_doing = string.Join("#", tmplist.Where(i => i != zh));
                        model.lastOkTime      = DateTime.Now;
                    }
                    else if (status == "已申请")
                    {
                        model.zhanghaos_doing += "#" + zh;
                        model.zhanghaos_doing  = model.zhanghaos_doing.Trim('#');
                        List <string> tmplist = new List <string>();
                        if (!string.IsNullOrEmpty(model.zhanghaos_ok))
                        {
                            tmplist = new List <string>(model.zhanghaos_ok.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries));
                        }
                        model.zhanghaos_ok = string.Join("#", tmplist.Where(i => i != zh));
                    }
                    else if (status == "作废")
                    {
                        model.ifok = "作废";
                    }
                    bllplans.Update(model);
                }

                res.message = "";
                res.success = true;
            }
            catch (Exception e)
            {
                res.success = false;
                res.message = "操作失败," + e.Message;
            }

            return(res);
        }
Ejemplo n.º 2
0
        private ApiResult DealLink(dynamic json)
        {
            ApiResult res = new ApiResult();

            try
            {
                BLL.plans bllPlans = new BLL.plans();
                rootDto <Model.Api.message> dto = JsonConvert.DeserializeObject <rootDto <Model.Api.message> >(json.ToString());
                DateTime      dtNow             = DateTime.Now;
                DateTime      dtToDay           = DateTime.Parse(dtNow.ToString("yyyy-MM-dd"));
                string        strMsg            = dto.Data.msg;
                string[]      strArr            = strMsg.Split(new string[] { "http" }, StringSplitOptions.None);
                List <string> aLink             = new List <string>();
                for (int i = 0; i < strArr.Length; i++)
                {
                    if (i == 0 && string.IsNullOrEmpty(strArr[0]))
                    {
                        continue;
                    }
                    string strItem = strArr[i];
                    int    index   = PageFunc.getIndex(strItem);
                    string strLink = string.Format("http{0}", strItem.Substring(0, index));
                    if (strLink.IndexOf("uland.taobao.com") != -1)
                    {
                    }
                    else if (strLink.IndexOf("detail.tmall.com") != -1)
                    {
                        string itemId     = PageFunc.GetQueryString("id", strLink);
                        string strContent = HttpHelper.HttpGet("http://g5.vipdamai.net/hcapi.ashx?gid=" + itemId);
                        hcRoot hc         = JsonConvert.DeserializeObject <hcRoot>(strContent);
                        if (hc.error == "0")
                        {
                            if (hc.data != null)
                            {
                                int total = 0;
                                var list  = bllPlans.GetList(1, int.MaxValue, ref total, p => p.userNumberId == hc.data.seller_id && EntityFunctions.CreateDateTime(p.zctime.Value.Year, p.zctime.Value.Month, p.zctime.Value.Day, 0, 0, 0) == dtToDay, p => p.id);

                                if (total > 0)
                                {
                                    foreach (var item in list)
                                    {
                                        item.item_id   = hc.data.num_iid;
                                        item.goodsname = hc.data.title;
                                        item.shopname  = hc.data.shop_title;
                                        if (!string.IsNullOrEmpty(hc.data.coupon_info))
                                        {
                                            string couponPrice = hc.data.coupon_info.Substring(hc.data.coupon_info.IndexOf("减") + 1).Replace("元", "");

                                            item.coupon_price = couponPrice;
                                            item.PayMoney     = decimal.Parse(hc.data.zk_final_price) - decimal.Parse(couponPrice);
                                        }
                                        else
                                        {
                                            item.PayMoney = decimal.Parse(hc.data.zk_final_price);
                                        }
                                        bllPlans.Update(item);
                                    }
                                }
                                else
                                {
                                    var item = new Model.plans();
                                    item.item_id   = itemId;
                                    item.goodsname = hc.data.title;
                                    item.shopname  = hc.data.shop_title;
                                    item.pic       = hc.data.pict_url;
                                    item.zctime    = dtNow;
                                    //item.coupon_url = hc.data.coupon_click_url;
                                    item.userNumberId = hc.data.seller_id;
                                    item.ifok         = "待补充";
                                    bllPlans.Add(item);
                                }
                            }
                        }
                    }
                    else if (strLink.IndexOf("pub.alimama.com") != -1)
                    {
                        string userNumberId = PageFunc.GetQueryString("userNumberId", strLink);

                        var model = bllPlans.GetModel(p => p.userNumberId == userNumberId && EntityFunctions.CreateDateTime(p.zctime.Value.Year, p.zctime.Value.Month, p.zctime.Value.Day, 0, 0, 0) == dtToDay);
                        if (model != null)
                        {
                            model.planname = "默认计划名";
                            model.planlink = strLink;
                            model.ifok     = "正常";
                            bllPlans.Update(model);
                        }
                        else
                        {
                            model              = new Model.plans();
                            model.planname     = "默认计划名";
                            model.userNumberId = userNumberId;
                            model.planlink     = strLink;
                            model.zctime       = dtNow;
                            model.ifok         = "正常";
                            bllPlans.Add(model);
                        }
                    }
                }

                res.message = "";
                res.success = true;
            }
            catch (Exception e)
            {
                res.success = false;
                res.message = "请求失败" + e.Message;
                LogHelper.Error(res.message, e);
            }
            return(res);
        }