private void add() { string planLink = txtplan_link.Text.Trim(); string camId = ""; Regex reg = new Regex("campaignId=(.+)&?"); Match match = reg.Match(planLink); camId = match.Groups[1].Value; var model = bllplans.GetModel(p => p.planlink.ToLower() == planLink || p.campaignId == camId); if (model != null) { PageFunc.AjaxAlert(this.Page, "计划链接已存在!"); return; } modelplans = new Model.plans(); modelplans.item_id = txtitem_id.Text.Trim(); modelplans.goodsname = txtgoodsname.Text.Trim(); modelplans.pic = txtitem_pic.Value.Trim(); modelplans.planname = txtplan_name.Text.Trim(); modelplans.campaignId = txtcampaignId.Text.Trim(); modelplans.planlink = txtplan_link.Text.Trim(); modelplans.coupon_url = txtquan_link.Text.Trim(); modelplans.commission_dx = txtcommission_dx.Text.Trim(); modelplans.commission_MKT = txtcommission_MKT.Text.Trim(); modelplans.ifok = "正常"; modelplans.zctime = DateTime.Now; decimal paymoney = 0m; decimal.TryParse(txtPayMoney.Text.Trim(), out paymoney); modelplans.PayMoney = paymoney; bllplans.Add(modelplans); Response.Write(PageFunc.ShowMsgJumpE("添加成功!", "plansList.aspx")); }
/// <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); }
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); }