コード例 #1
0
        public ActionResult Detail(long id, bool isjson = false)
        {
            Product_MY product = ProductMyService.GetInfo(id);

            if (string.IsNullOrWhiteSpace(product.CouponCommand))
            {
                ITopClient           client = new DefaultTopClient(ConfigService.TaoBaoApiUrl, "24526506", "5a9e071dacf3f6f925eccce6f7b99602", "json");
                TbkTpwdCreateRequest req    = new TbkTpwdCreateRequest();
                req.UserId = "98776048";
                req.Text   = product.PTitle;
                req.Url    = product.CouponLink;
                req.Logo   = product.PImgUrls.Replace("300x300", "100x100");
                req.Ext    = "{\"test\":\"testv\"}";
                TbkTpwdCreateResponse rsp = client.Execute(req);
                JObject obj = JObject.Parse(rsp.Body);
                if (obj["tbk_tpwd_create_response"] != null &&
                    obj["tbk_tpwd_create_response"]["data"] != null &&
                    obj["tbk_tpwd_create_response"]["data"]["model"] != null)
                {
                    product.CouponCommand = obj["tbk_tpwd_create_response"]["data"]["model"].ToString();
                    ProductMyService.Update(product);
                    if (isjson)
                    {
                        return(Json(new { key = product.CouponCommand }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    ErrorLog.WriteTextLog("", rsp.Body, DateTime.Now);
                    if (isjson)
                    {
                        return(Json(new { key = "" }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            else if (isjson)
            {
                return(Json(new { key = product.CouponCommand }, JsonRequestBehavior.AllowGet));
            }
            return(View(product));
        }
コード例 #2
0
ファイル: ProductController.cs プロジェクト: jilter/project
        public ActionResult Code(long id)
        {
            Product_MY product = ProductMyService.GetInfo(id);
            string     imgSrc  = "";

            if (product != null)
            {
                if (string.IsNullOrWhiteSpace(product.Remark))
                {
                    imgSrc = CodeHelper.CombinImage(product.PImgUrls.Split('|')[0], product.ID, product.PTitle, product.PPrice.Value, product.CouponMoney.Value, product.PSales.Value);
                    if (!string.IsNullOrWhiteSpace(imgSrc))
                    {
                        product.Remark = imgSrc;
                        ProductMyService.Update(product);
                    }
                }
                else
                {
                    imgSrc = product.Remark;
                }
            }
            ViewBag.Src = imgSrc;
            return(View());
        }