/// <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); }
/// <summary> /// 添加高佣金计划 /// Api.ashx?act=upplans&json={"item_id":"12345","goodsname":"产品名","shopname":"店铺名","PayMoney":50.2,"planname":"playName","planlink":"playLink","campaignId":"23","userNumberId":"232","shopkeeperId":"12321","zctime":"2020-07-07T17:28:21.1393121+08:00","zhanghaos":"a","ifok":"有效"} /// </summary> /// <param name="con"></param> /// <returns></returns> private ApiResult UpPlans(HttpContext con) { BLL.plans bllplans = new BLL.plans(); ApiResult res = new ApiResult(); try { string strJsonInfo = GetRequest(con, "json"); //strJsonInfo = "{\"item_id\":\"12345\",\"goodsname\":\"产品名\",\"shopname\":\"店铺名\",\"PayMoney\":50.2,\"planname\":\"playName\",\"planlink\":\"playLink\",\"campaignId\":\"23\",\"userNumberId\":\"232\",\"shopkeeperId\":\"12321\",\"zctime\":\"2020-07-07T17:28:21.1393121+08:00\",\"zhanghaos\":\"a\",\"ifok\":\"有效\"}"; Model.plans model = new Model.plans(); model = Newtonsoft.Json.JsonConvert.DeserializeObject <Model.plans>(strJsonInfo); bllplans.Add(model); res.message = ""; res.success = true; } catch (Exception e) { res.success = false; res.message = "添加失败" + e.Message; } return(res); }
/// <summary> /// 获取高佣计划 /// Api.ashx?act=getplans&dt=1590940800 /// </summary> /// <param name="con"></param> /// <returns></returns> private ApiResult GetPlans(HttpContext con) { BLL.plans bllplans = new BLL.plans(); ApiResult res = new ApiResult(); try { string strGetOk = GetRequest(con, "getok"); string strDt = GetRequest(con, "dt"); DateTime dt = DateTimeHelper.GetTime(strDt); int total = 0; List <Model.plansInfo> listRes = new List <Model.plansInfo>(); List <Model.plans> list = new List <Model.plans>(); if (string.IsNullOrEmpty(strGetOk)) { list = bllplans.GetList(1, int.MaxValue, ref total, m => m.zctime >= dt && m.ifok == "正常", m => m.id, false); } else { list = bllplans.GetList(1, int.MaxValue, ref total, m => m.zctime >= dt && m.zhanghaos_ok != "" && m.ifok == "正常", m => m.lastOkTime, false); } foreach (var item in list) { listRes.Add(new Model.plansInfo { id = item.id, item_id = item.item_id, goodsname = item.item_id, shopname = item.shopname, PayMoney = item.PayMoney, planname = item.planname, planlink = item.planlink, campaignId = item.campaignId, userNumberId = item.userNumberId, shopkeeperId = item.shopkeeperId, zctime = item.zctime, zhanghaos_ok = item.zhanghaos_ok, ifok = item.ifok, coupon_url = item.coupon_url, coupon_price = item.coupon_price, commission_dx = item.commission_dx, commission_MKT = item.commission_MKT, pic = item.pic, intro = item.intro, tdRatio = item.tdRatio, tdCoupon = item.tdCoupon, tdCouponPrice = item.tdCouponPrice, detectionTime = item.detectionTime }); } string json = Newtonsoft.Json.JsonConvert.SerializeObject(listRes); res.message = json; res.success = true; } catch (Exception e) { res.success = false; res.message = "操作失败" + e.Message; } return(res); }
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); }