コード例 #1
0
        public virtual async Task <GetAdvertAccountForEditOutput> GetAccountForEdit(NullableIdDto <long> input)
        {
            GetAdvertAccountForEditOutput accountDto;

            if (input.Id.HasValue) //Editing existing store?
            {
                var account = await _advertAccountManager.GetByIdAsync(input.Id.Value);

                accountDto          = ObjectMapper.Map <GetAdvertAccountForEditOutput>(account);
                accountDto.IsAuthed = account.IsAuth();
            }
            else
            {
                accountDto = new GetAdvertAccountForEditOutput();
            }

            return(accountDto);
        }
コード例 #2
0
        /// <summary>
        /// 回传物流信息
        /// </summary>
        /// <param name="shipment"></param>
        /// <returns></returns>
        public async Task <bool> UploadOrderTrackingAsync(Shipment shipment)
        {
            if (!shipment.Order.AdvertAccountId.HasValue)
            {
                return(false);
            }

            if (!shipment.LogisticsId.HasValue)
            {
                return(false);
            }

            var account = await _advertAccountManager.GetByIdAsync(Convert.ToInt32(shipment.Order.AdvertAccountId.Value));

            if (account == null)
            {
                return(false);
            }

            if (account.IsAuthExpires())
            {
                await RefreshAccessTokenAsync(account);
            }

            var postUrl = OrderUpdateAddress() + GetRequestPara(account);

            if (shipment == null)
            {
                return(false);
            }

            using (var client = new HttpClient())
            {
                var logistics = await _logisticsManager.GetByIdAsync(shipment.LogisticsId.Value);

                var content = new FormUrlEncodedContent(new Dictionary <string, string>()
                {
                    { "account_id", account.ThirdpartyId },
                    { "ecommerce_order_id", shipment.OrderNumber },
                    { "delivery_tracking_number", shipment.LogisticsNumber },
                    { "express_company", GetFxShipEnum(logistics.Memo) },
                    { "ecommerce_order_status", "ORDER_DELIVERING" }
                });

                var response = client.PostAsync(postUrl, content).Result;

                var responseString = response.Content.ReadAsStringAsync().Result;
            }

            return(true);
        }