Esempio n. 1
0
        public JsonResult Create(AccountType obj)
        {
            try
            {
                if (IsCreateOk(obj.AccountName, obj.Platform))
                {
                    return(Json(new { errorMsg = "此账号已存在!" }));
                }

                if (obj.Platform == "SMT")
                {
                    if (!string.IsNullOrEmpty(obj.ApiToken) && obj.ApiToken.Trim().Length > 0)
                    {
                        obj.ApiToken = AliUtil.GetToken(obj.ApiToken.Trim());
                    }
                }
                NSession.SaveOrUpdate(obj);
                NSession.Flush();
            }
            catch (Exception ee)
            {
                return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
            }
            return(Json(new { IsSuccess = true }));
        }
Esempio n. 2
0
 public JsonResult GetAliLoginUrl()
 {
     try
     {
         return(Json(new { IsSuccess = true, Result = AliUtil.GetAuthUrl() }));
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
 }
        public JsonResult Create(string code)
        {
            AliShop     shop = AliUtil.GetRefreshToken(code);
            AliShopType obj  = new AliShopType();

            obj.ShopTitle     = shop.resource_owner;
            obj.RefershToken  = DateTime.Now;
            obj.RefreshToken  = shop.refresh_token;
            obj.AccessToken   = shop.access_token;
            obj.Manager       = shop.aliId;
            obj.BeginOn       = DateTime.Now;
            obj.EndOn         = DateTime.Now;
            obj.Status        = 1;
            obj.TokenUpdateOn = DateTime.Now;
            base.Save <AliShopType>(obj);
            return(Json(new { IsSuccess = true }));
        }
Esempio n. 4
0
        public JsonResult Syn(int s)
        {
            if (s == 0)
            {
                IList <AliShopType> list     = GetAll <AliShopType>();
                List <CountryType>  countrys = GetAll <CountryType>().ToList <CountryType>();
                foreach (AliShopType shop in list)
                {
                    if (!string.IsNullOrEmpty(shop.RefreshToken))
                    {
                        if (!string.IsNullOrEmpty(shop.AccessToken))
                        {
                            TimeSpan ts = (DateTime.Now - shop.TokenUpdateOn);
                            if (ts.TotalHours > 8)
                            {
                                shop.AccessToken   = AliUtil.GetAccessToken(shop.RefreshToken);
                                shop.TokenUpdateOn = DateTime.Now;
                                Update <AliShopType>(shop);
                            }

                            int page = 1; AliOrderListType aliOrderList = null;
                            do
                            {
                                aliOrderList = AliUtil.findOrderListQuery(shop.AccessToken, page, AliOrderStatus.WAIT_SELLER_SEND_GOODS);

                                foreach (OrderList foo in aliOrderList.orderList)
                                {
                                    AliexpressEF.API.AliOrderType o     = AliUtil.findOrderById(shop.AccessToken, foo.orderId);
                                    Domain.AliOrderType           order = new Domain.AliOrderType
                                    {
                                        OrderNo      = foo.orderId,
                                        Status       = "等待您发货",
                                        HasPrint     = 0,
                                        HasMerger    = 0,
                                        CurrencyCode = foo.payAmount.currencyCode,
                                        Amount       = foo.payAmount.amount,

                                        BuyerId    = o.buyerInfo.loginId,
                                        BuyerName  = o.buyerSignerFullname,
                                        BuyerEmail = o.buyerInfo.email,

                                        RecipientCity     = o.receiptAddress.city,
                                        RecipientName     = o.receiptAddress.contactPerson,
                                        RecipientPhone    = o.receiptAddress.phoneCountry + "-" + o.receiptAddress.phoneArea + "-" + o.receiptAddress.phoneNumber,
                                        RecipientPostCode = o.receiptAddress.zip,
                                        RecipientStreet   = o.receiptAddress.detailAddress + " " + o.receiptAddress.address2,
                                        RecipientProvince = o.receiptAddress.province,
                                        RecipientCountry  = o.receiptAddress.country,
                                        RecipientTel      = o.receiptAddress.mobileNo,

                                        GenerateOn = AliUtil.GetAliDate(o.gmtCreate),
                                        SendOn     = DateTime.Now,

                                        ShopId       = shop.Id,
                                        ShopTitle    = shop.ShopTitle,
                                        UId          = shop.UId,
                                        LogisticType = foo.productList[0].logisticsServiceName
                                    };
                                    CountryType country =
                                        countrys.Find(
                                            p => p.CountryCode.ToUpper() == o.receiptAddress.country.ToUpper());
                                    if (country != null)
                                    {
                                        order.RecipientCountry = country.ECountry;
                                    }
                                    base.Save <Domain.AliOrderType>(order);
                                    foreach (ProductList fo in foo.productList)
                                    {
                                        order.OrderNote += fo.memo;
                                        AliOrderProductType product = new AliOrderProductType();
                                        product.SKU     = fo.skuCode;
                                        product.ItemId  = fo.productId;
                                        product.Qty     = fo.productCount;
                                        product.Title   = fo.productName;
                                        product.Price   = fo.productUnitPrice.amount;
                                        product.OId     = order.Id;
                                        product.ImgUrl  = fo.productImgUrl;
                                        product.ItemUrl = fo.productSnapUrl;
                                        base.Save <Domain.AliOrderProductType>(product);
                                    }
                                    base.Update <Domain.AliOrderType>(order);
                                }
                                page++;
                            } while (aliOrderList.totalItem > (page - 1) * 50);
                        }
                    }
                }
            }
            return(Json(new { IsSuccess = true }));
        }
 public JsonResult GetAuthUrl()
 {
     return(Json(new { IsSuccess = true, Result = AliUtil.GetAuthUrl() }));
 }