Esempio n. 1
0
 public JsonResult SuNingDelete(string ids)//删除lazada订单
 {
     try
     {
         string[] Ids = ids.Split(',');
         for (int j = 0; j < Ids.Length; j++)
         {
             int            id       = Convert.ToInt32(Ids[j]);
             T_HtSuNing     delModel = db.T_HtSuNing.Find(id);
             T_HtSuNingItem item     = db.T_HtSuNingItem.FirstOrDefault(s => s.PorderID.Equals(delModel.OrderNumber));
             if (item != null)
             {
                 db.T_HtSuNingItem.Remove(item);
             }
             db.T_HtSuNing.Remove(delModel);
         }
         db.SaveChanges();
         return(Json(new { State = "Success" }));
     }
     catch (Exception ex)
     {
         return(Json(new { State = "Faile", Message = ex.Message }));
     }
 }
Esempio n. 2
0
        public JsonResult UpToGY(string ids)//上传到旺店通
        {
            using (TransactionScope sc = new TransactionScope())
            {
                string shibai = "0";
                try
                {
                    var aa = "";

                    string[] Ids = ids.Split(',');
                    for (int j = 0; j < Ids.Length; j++)
                    {
                        Dictionary <string, string> dic = new Dictionary <string, string>();
                        int        id         = Convert.ToInt32(Ids[j]);
                        T_HtSuNing ordermodel = db.T_HtSuNing.SingleOrDefault(a => a.ID == id);
                        if (ordermodel.Istijiao == 1)
                        {
                            return(Json(new { State = "Faile", Message = "" + ordermodel.OrderNumber + "已提交到旺店通,不能重复提交" }, JsonRequestBehavior.AllowGet));
                        }


                        string ShopName = "";

                        ShopName = "3011";

                        string tid = ordermodel.OrderNumber;
                        //int trade_status = 10;
                        //int pay_status = 2;
                        //int delivery_term = 1;
                        DateTime trade_time    = DateTime.Parse(ordermodel.CreateTime.ToString());
                        DateTime pay_time      = DateTime.Parse(ordermodel.CreateTime.ToString());
                        string   buyer_nick    = ordermodel.CustomerName;
                        string   receiver_name = ordermodel.CustomerName;

                        string receiver_province = ordermodel.Province;
                        string receiver_city     = ordermodel.City;
                        string receiver_district = ordermodel.Area;
                        string receiver_address  = ordermodel.Address;
                        string receiver_mobile   = ordermodel.Telephone;

                        // int logistics_type = -1;
                        string  seller_memo = ordermodel.CustomerRemarks;
                        decimal paid        = 0.00m;

                        List <T_HtSuNingItem> orderItems = db.T_HtSuNingItem.Where(a => a.PorderID == tid).ToList();
                        string order_list = "";

                        for (int i = 0; i < orderItems.Count; i++)
                        {
                            decimal num       = decimal.Parse(orderItems[i].num.ToString());
                            decimal UnitPrice = decimal.Parse(orderItems[i].UnitPrice.ToString());
                            paid += num * UnitPrice;

                            string goods_no = orderItems[i].ProductCode;
                            string spec_no  = orderItems[i].ProductCode;
                            //    string Guid = System.Guid.NewGuid().ToString();
                            T_WDTGoods cofig      = db.T_WDTGoods.SingleOrDefault(s => s.goods_no == goods_no);
                            string     goods_name = "";
                            if (cofig != null)
                            {
                                goods_name = cofig.goods_name;
                            }
                            string oid = Guid.NewGuid().ToString();
                            if (order_list == "")
                            {
                                order_list += "{" +
                                              "\"oid\": \"" + oid + "\"," +
                                              "\"num\": \"" + num + "\"," +
                                              "\"price\": \"" + UnitPrice + "\"," +
                                              "\"status\": \"40\"," +
                                              "\"refund_status\": \"0\"," +
                                              "\"adjust_amount\": \"0\"," +
                                              "\"discount\": \"0\"," +
                                              "\"share_discount\": \"0\"," +
                                              "\"goods_id\": \"" + goods_no + "\"," +
                                              "\"goods_no\": \"" + goods_no + "\"," +
                                              "\"spec_no\": \"" + goods_no + "\"," +
                                              "\"goods_name\": \"" + goods_name + "\"," +
                                              "\"cid\": \"\"" +
                                              "}";
                            }
                            else
                            {
                                order_list += ",{" +
                                              "\"oid\": \"" + oid + "\"," +
                                              "\"num\": \"" + num + "\"," +
                                              "\"price\": \"" + UnitPrice + "\"," +
                                              "\"status\": \"40\"," +
                                              "\"refund_status\": \"0\"," +
                                              "\"adjust_amount\": \"0\"," +
                                              "\"discount\": \"0\"," +
                                              "\"share_discount\": \"0\"," +
                                              "\"goods_id\": \"" + goods_no + "\"," +
                                              "\"goods_no\": \"" + goods_no + "\"," +
                                              "\"spec_no\": \"" + goods_no + "\"," +
                                              "\"goods_name\": \"" + goods_name + "\"," +
                                              "\"cid\": \"\"" +
                                              "}";
                            }
                        }

                        //旺店通
                        dic.Remove("shop_no");
                        dic.Add("shop_no", ShopName);

                        string cmd = "[{" +
                                     "\"tid\": \"" + tid + "\"," +
                                     "\"trade_status\": \"30\"," +
                                     "\"pay_status\": \"2\"," +
                                     "\"delivery_term\": \"1\"," +
                                     "\"trade_time\": \"" + trade_time + "\"," +
                                     "\"pay_time\": \"" + pay_time + "\"," +
                                     "\"buyer_nick\": \"" + buyer_nick + "\"," +
                                     "\"buyer_email\": \"\"," +
                                     "\"receiver_name\": \"" + receiver_name + "\"," +
                                     "\"receiver_province\": \"" + receiver_province + "\"," +
                                     "\"receiver_city\": \"" + receiver_city + "\"," +
                                     "\"receiver_district\": \"" + receiver_district + "\"," +
                                     "\"receiver_address\": \"" + receiver_address + "\"," +
                                     "\"receiver_mobile\": \"" + receiver_mobile + "\"," +
                                     "\"receiver_zip\": \"\"," +
                                     "\"logistics_type\": \"-1\"," +
                                     "\"buyer_message\": \"\"," +
                                     "\"seller_memo\": \"" + seller_memo + "\"," +
                                     "\"post_amount\": \"0\"," +
                                     "\"cod_amount\": \"0\"," +
                                     "\"ext_cod_fee\": \"0\"," +
                                     "\"paid\": \"" + paid + "\"," +
                                     "\"order_list\": [" + order_list + "]}]";
                        dic.Remove("trade_list");
                        dic.Remove("sid");
                        dic.Remove("appkey");
                        dic.Remove("timestamp");
                        dic.Add("trade_list", cmd);
                        dic.Add("sid", "hhs2");
                        dic.Add("appkey", "hhs2-ot");
                        dic.Add("timestamp", GetTimeStamp());

                        aa = CreateParam(dic, true);


                        string ret = Post("http://api.wangdian.cn/openapi2/trade_push.php", aa);


                        JsonData jsonData = null;
                        jsonData = JsonMapper.ToObject(ret);
                        string sd = jsonData[0].ToString();
                        if (sd == "0")
                        {
                            int sdz = int.Parse(jsonData[2].ToString());
                            if (sdz > 0)
                            {
                                T_HtSuNing model = db.T_HtSuNing.Single(a => a.ID == id);
                                model.Istijiao = 1;
                                db.SaveChanges();
                            }
                            else
                            {
                                shibai += tid + ",";
                            }
                        }
                        else
                        {
                            shibai += tid + ",";
                        }
                    }
                    sc.Complete();
                    if (shibai != "0")
                    {
                        return(Json(new { State = "Faile", Message = "" + shibai + "提交旺店通失败,请与技术人员联系" }, JsonRequestBehavior.AllowGet));
                    }

                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }