Example #1
0
        public ActionResult GetDetail(long id)
        {
            Product_MY product = ProductMyService.GetInfo(id);

            if (product != null)
            {
                var redpack = UtilityService.GetRedPack(product.PPrice.Value, product.CouponMoney.Value, 10);
                return(Json(new
                {
                    code = 0,
                    result = new
                    {
                        id = product.ID,
                        name = product.PTitle,
                        img = product.PImgUrls.Split('|')[0],
                        price = product.PPrice - product.CouponMoney - redpack,
                        coupon = product.CouponMoney,
                        redpack = redpack,
                        sales = product.PSales,
                        key = product.CouponCommand
                    }
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { code = 1, result = new { } }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
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));
        }
Example #3
0
        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());
        }