Beispiel #1
0
        /// <summary>
        /// 快递信息
        /// </summary>
        /// <param name="orderId">订单Id</param>
        public ActionResult ExpressInfo(long orderId)
        {
            var order = OrderApplication.GetOrder(orderId);

            if (order == null)
            {
                throw new HimallException("错误的订单编号");
            }
            if (order.ShopBranchId > 0)
            {
                var sbdata = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                if (sbdata != null)
                {
                    ViewBag.StoreLat = sbdata.Latitude;
                    ViewBag.Storelng = sbdata.Longitude;
                }
            }
            else
            {
                var shopshiper = ShopShippersApplication.GetDefaultSendGoodsShipper(order.ShopId);
                if (shopshiper != null)
                {
                    ViewBag.StoreLat = shopshiper.Latitude;
                    ViewBag.Storelng = shopshiper.Longitude;
                }
            }
            return(View(order));
        }
        public object PostReply(OrderRefundReplyModel reply)
        {
            CheckUserLogin();

            if (reply == null)
            {
                return(ErrorResult("参数不能为空"));
            }

            var shopAddress = ShopShippersApplication.GetDefaultSendGoodsShipper(CurrentShop.Id);

            if (shopAddress == null)
            {
                return(ErrorResult("未设置默认发/退货地址"));
            }

            switch (reply.AuditStatus)
            {
            case OrderRefundInfo.OrderRefundAuditStatus.UnAudit:
                if (string.IsNullOrWhiteSpace(reply.SellerRemark))
                {
                    return(ErrorResult("请填写拒绝理由"));
                }
                break;
            }

            var refund = Application.RefundApplication.GetOrderRefund(reply.RefundId);

            if (refund == null || refund.ShopId != CurrentShop.Id)
            {
                return(ErrorResult("无效的售后申请编号"));
            }

            if (refund.SellerAuditStatus == OrderRefundInfo.OrderRefundAuditStatus.WaitReceiving && reply.AuditStatus != OrderRefundInfo.OrderRefundAuditStatus.UnAudit)
            {
                RefundApplication.SellerConfirmRefundGood(reply.RefundId, CurrentUser.UserName, reply.SellerRemark);
            }
            else
            {
                RefundApplication.SellerDealRefund(reply.RefundId, reply.AuditStatus, reply.SellerRemark, CurrentUser.UserName);
            }

            return(SuccessResult("操作成功"));
        }
        /// <summary>
        /// 查看订单物流
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public object GetLogisticsData(string expressCompanyName, string shipOrderNumber, long orderid)
        {
            var order = OrderApplication.GetOrder(orderid);

            if (order != null && order.DeliveryType == DeliveryType.CityExpress)
            {
                float StoreLat = 0, Storelng = 0;
                if (order.ShopBranchId > 0)
                {
                    var sbdata = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    if (sbdata != null)
                    {
                        StoreLat = sbdata.Latitude;
                        Storelng = sbdata.Longitude;
                    }
                }
                else
                {
                    var shopshiper = ShopShippersApplication.GetDefaultSendGoodsShipper(order.ShopId);
                    if (shopshiper != null && shopshiper.Latitude.HasValue && shopshiper.Longitude.HasValue)
                    {
                        StoreLat = shopshiper.Latitude.Value;
                        Storelng = shopshiper.Longitude.Value;
                    }
                }
                return(new
                {
                    success = true,
                    deliveryType = DeliveryType.CityExpress.GetHashCode(),
                    userLat = order.ReceiveLatitude,
                    userLng = order.ReceiveLongitude,
                    storeLat = StoreLat,
                    Storelng = Storelng,
                    shipOrderNumber = order.ShipOrderNumber,
                });
            }
            else
            {
                var expressData = Application.OrderApplication.GetExpressData(expressCompanyName, shipOrderNumber);
                if (expressData != null)
                {
                    if (expressData.Success)
                    {
                        expressData.ExpressDataItems = expressData.ExpressDataItems.OrderByDescending(item => item.Time);//按时间逆序排列
                    }
                    var json = new
                    {
                        success = expressData.Success,
                        msg     = expressData.Message,
                        data    = expressData.ExpressDataItems.Select(item => new
                        {
                            time    = item.Time.ToString("yyyy-MM-dd HH:mm:ss"),
                            content = item.Content
                        })
                    };
                    return(json);
                }
                else
                {
                    var json = new
                    {
                        success = false,
                        msg     = "无物流信息"
                    };
                    return(json);
                }
            }
        }
Beispiel #4
0
        public object GetExpressInfo(long orderId)
        {
            CheckUserLogin();
            OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(orderId, CurrentUser.Id);

            if (order.DeliveryType == DeliveryType.CityExpress)
            {
                float StoreLat = 0, Storelng = 0;
                if (order == null)
                {
                    throw new HimallException("错误的订单编号");
                }
                if (order.ShopBranchId > 0)
                {
                    var sbdata = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    if (sbdata != null)
                    {
                        StoreLat = sbdata.Latitude;
                        Storelng = sbdata.Longitude;
                    }
                }
                else
                {
                    var shopshiper = ShopShippersApplication.GetDefaultSendGoodsShipper(order.ShopId);
                    if (shopshiper != null && shopshiper.Latitude.HasValue && shopshiper.Longitude.HasValue)
                    {
                        StoreLat = shopshiper.Latitude.Value;
                        Storelng = shopshiper.Longitude.Value;
                    }
                }
                return(new
                {
                    success = true,
                    ExpressNum = order.ShipOrderNumber,
                    ExpressCompanyName = order.ExpressCompanyName,
                    deliveryType = DeliveryType.CityExpress.GetHashCode(),
                    userLat = order.ReceiveLatitude,
                    userLng = order.ReceiveLongitude,
                    storeLat = StoreLat,
                    Storelng = Storelng,
                });
            }
            else
            {
                var expressData = ServiceProvider.Instance <IExpressService> .Create.GetExpressData(order.ExpressCompanyName, order.ShipOrderNumber);

                if (expressData.Success)
                {
                    expressData.ExpressDataItems = expressData.ExpressDataItems.OrderByDescending(item => item.Time);//按时间逆序排列
                }
                var json = new
                {
                    success = expressData.Success,
                    msg     = expressData.Message,
                    data    = expressData.ExpressDataItems.Select(item => new
                    {
                        time    = item.Time.ToString("yyyy-MM-dd HH:mm:ss"),
                        content = item.Content
                    })
                };
                return(new
                {
                    success = true,
                    ExpressNum = order.ShipOrderNumber,
                    ExpressCompanyName = order.ExpressCompanyName,
                    Comment = json
                });
            }
        }
        private string SendDaDaExpress(long orderId, long shopid, bool isQueryOrder)
        {
            //Log.Error("达达发货ShopOrder-01:orderId:" + orderId);
            var order = OrderApplication.GetOrder(orderId);

            if (order == null || order.ShopId != shopid || order.ShopBranchId > 0 || order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery)
            {
                throw new HimallApiException("错误的订单编号");
            }
            var dadaconfig = CityExpressConfigApplication.GetDaDaCityExpressConfig(shopid);

            if (!dadaconfig.IsEnable)
            {
                throw new HimallApiException("未开启同城合作物流");
            }
            //Log.Error("达达发货ShopOrder-02:OrderStatus:" + order.OrderStatus + "--ReceiveLatitude:" + order.ReceiveLatitude + "--ReceiveLongitude:" + order.ReceiveLongitude + "--RegionId:" + order.RegionId);
            if (order.ReceiveLatitude <= 0 || order.ReceiveLongitude <= 0)
            {
                throw new HimallApiException("未获取到客户收货地址坐标信息,无法使用该配送方式");
            }
            var shopsend = ShopShippersApplication.GetDefaultSendGoodsShipper(shopid);

            if (shopsend == null || shopsend.Latitude <= 0 || shopsend.Longitude <= 0)
            {
                throw new HimallApiException("店铺没有发货地址或发货地址没有坐标信息,无法发单,请前往后台进行设置");
            }
            //Log.Error("达达发货ShopOrder-03:Latitude:" + shopsend.Latitude + "--Longitude:" + shopsend.Longitude);
            string cityCode  = "";
            var    _adregion = RegionApplication.GetRegion(order.RegionId);
            var    _city     = GetCity(_adregion);

            try
            {
                string cityJson = ExpressDaDaHelper.cityCodeList(shopid);
                var    cityObj  = JsonConvert.DeserializeObject(cityJson) as JObject;
                JArray citylist = (JArray)cityObj["result"];
                foreach (JToken item in citylist)
                {
                    if (_city.ShortName == item["cityName"].ToString())
                    {
                        cityCode = item["cityCode"].ToString();
                        break;
                    }
                }
            }
            catch
            {
            }
            //达达不支持的城市
            if (cityCode == "")
            {
                throw new HimallApiException("配送范围超区,无法配送");
            }
            string callback = CurrentUrlHelper.CurrentUrl() + "/pay/dadaOrderNotify/";

            bool isreaddorder = (order.DadaStatus == DadaStatus.Cancel.GetHashCode());

            if (isQueryOrder)
            {
                isreaddorder = false;
            }

            //Log.Error(DateTime.Now + "ShopOrder-0:callback:" + callback + "|shopid:" + shopid + "|source_id:" + dadaconfig.source_id + "|orderId:" + order.Id + "|cityCode:" + cityCode + "|isreaddorder:" + isreaddorder);
            string json = ExpressDaDaHelper.addOrder(shopid, dadaconfig.source_id, order.Id.ToString()
                                                     , cityCode, (double)order.TotalAmount, 0, ExpressDaDaHelper.DateTimeToUnixTimestamp(DateTime.Now.AddMinutes(15))
                                                     , order.ShipTo, order.Address, order.ReceiveLatitude, order.ReceiveLongitude
                                                     , callback, order.CellPhone, order.CellPhone, isQueryDeliverFee: isQueryOrder
                                                     , isReAddOrder: isreaddorder);

            //Log.Error(DateTime.Now + "达达发货ShopOrder-1:json:" + json);
            return(json);
        }