コード例 #1
0
 public JsonResult Delete(long id)
 {
     ShopShippersApplication.Delete(CurShopId, id);
     return(Json(new Result {
         success = true
     }));
 }
コード例 #2
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));
        }
コード例 #3
0
 public JsonResult SetDefaultVerification(long id)
 {
     ShopShippersApplication.SetDefaultVerificationShipper(CurShopId, id);
     return(Json(new Result {
         success = true
     }));
 }
コード例 #4
0
        public JsonResult DealRefund(long refundId, int auditStatus, string sellerRemark)
        {
            Result result            = new Result();
            var    refundauditstatus = (Entities.OrderRefundInfo.OrderRefundAuditStatus)auditStatus;

            switch (refundauditstatus)
            {
            case Entities.OrderRefundInfo.OrderRefundAuditStatus.UnAudit:
                if (string.IsNullOrWhiteSpace(sellerRemark))
                {
                    throw new HimallException("请填写拒绝理由");
                }
                break;
            }
            var refund = RefundApplication.GetOrderRefund(refundId);

            if (refund != null && refund.IsReturn == true && auditStatus == 2)
            {
                var shopget = ShopShippersApplication.GetDefaultGetGoodsShipper(refund.ShopId);
                if (shopget == null)
                {
                    throw new HimallException("需要先设置好退货地址再进行操作,立即前往设置!");
                }
            }
            _iRefundService.SellerDealRefund(refundId, refundauditstatus, sellerRemark, CurrentSellerManager.UserName);
            result.success = true;
            return(Json(result));
        }
コード例 #5
0
        /// <summary>
        /// 进入立即购买提交页面
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        /// <param name="GroupActionId">拼团活动编号</param>
        /// <param name="GroupId">拼团编号</param>
        public ActionResult Submit(string skuIds, string counts, int islimit = 0, long shippingAddressId = 0, string couponIds = "")
        {
            var coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var result  = OrderApplication.GetMobileSubmit(UserId, skuIds, counts, shippingAddressId, coupons);

            ViewBag.InvoiceContext   = result.InvoiceContext;
            ViewBag.InvoiceTitle     = result.InvoiceTitle;
            ViewBag.skuIds           = skuIds;
            ViewBag.counts           = counts;
            ViewBag.IsCashOnDelivery = result.IsCashOnDelivery;
            ViewBag.address          = null == result.Address || result.Address.NeedUpdate ? null : result.Address;
            ViewBag.ConfirmModel     = result;
            ViewBag.Islimit          = islimit == 1 ? true : false;

            var orderTag = Guid.NewGuid().ToString("N");

            ViewBag.OrderTag    = orderTag;
            Session["OrderTag"] = orderTag;

            InitOrderSubmitModel(result);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion

            #region TDO:ZYF 3.2注释是否提供发票
            //bool ProvideInvoice = false;
            //if (result.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;
            ViewBag.productType         = result.ProductType;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (result.ProductType == 1)
            {
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new HimallException("该虚拟商品已过期,不支持下单");
                }
                if (result.products != null && result.products.Count > 0)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            ViewBag.ShipperAddress  = shipperAddress;
            ViewBag.ShipperTelPhone = shipperTelPhone;
            return(View());
        }
コード例 #6
0
        public JsonResult List(int page, int rows)
        {
            var result = ShopShippersApplication.GetShopShippers(CurrentSellerManager.ShopId);
            DataGridModel <ShopShipper> model = new DataGridModel <ShopShipper>
            {
                rows  = result,
                total = result.Count
            };

            return(Json(model, true));
        }
コード例 #7
0
ファイル: OrderController.cs プロジェクト: redpanda321/Mall
        /// <summary>
        /// 点击立即购买调用的GET方法,但是重定向到了Submit页面
        /// </summary>
        /// <param name="skuIds">多个库存Id</param>
        /// <param name="counts">每个库存对应的数据量</param>
        /// <param name="regionId">客户收货地区的id</param>
        /// <param name="collpids">组合购Id集合</param>
        /// <returns>订单提交页面的数据</returns>
        public ActionResult SubmitByProductId(string skuIds, string counts, long?regionId, string collpids = null, string CouponIds = "", sbyte productType = 0, long productId = 0)
        {
            //Logo
            ViewBag.Logo = SiteSettings.Logo; //获取Logo
                                              //设置会员信息
            ViewBag.Member = CurrentUser;
            var coupons     = CouponApplication.ConvertUsedCoupon(CouponIds);
            var submitModel = OrderApplication.SubmitByProductId(UserId, skuIds, counts, regionId, collpids, coupons, productType);

            ViewBag.IsCashOnDelivery = submitModel.IsCashOnDelivery;
            ViewBag.IsLimitBuy       = submitModel.IsLimitBuy;

            InitOrderSubmitModel(submitModel);
            #region 是否开启门店授权
            ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            #endregion
            #region 是否提供发票
            //bool ProvideInvoice = false;
            //if (submitModel.products != null)
            //    ProvideInvoice = ShopApplication.HasProvideInvoice(submitModel.products.Select(p => p.shopId).ToList());
            //ViewBag.ProvideInvoice = ProvideInvoice;
            #endregion

            bool canIntegralPerMoney = true, canCapital = true;
            CanDeductible(out canIntegralPerMoney, out canCapital);
            ViewBag.CanIntegralPerMoney = canIntegralPerMoney;
            ViewBag.CanCapital          = canCapital;

            ViewBag.Keyword = SiteSettings.Keyword;
            if (productType == 1 && productId > 0)
            {
                submitModel.VirtualProductItemInfos = ProductManagerApplication.GetVirtualProductItemInfoByProductId(productId);
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(productId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new MallException("该虚拟商品已过期,不支持下单");
                }
            }
            submitModel.ProductType = productType;
            if (productType == 1 && submitModel.products != null && submitModel.products.Count > 0)
            {
                var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(submitModel.products.FirstOrDefault().shopId);
                if (verificationShipper != null)
                {
                    ViewBag.ShipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                    ViewBag.ShipperTelPhone = verificationShipper.TelPhone;
                }
            }
            return(View("Submit", submitModel));
        }
コード例 #8
0
        public ActionResult Add(long id = 0)
        {
            int    sceneid   = 0;
            string ticketstr = "";
            var    settings  = SiteSettingApplication.SiteSettings;

            try
            {
                if (!string.IsNullOrWhiteSpace(settings.WeixinAppId) && !string.IsNullOrWhiteSpace(settings.WeixinAppSecret))
                {
                    string token = AccessTokenContainer.TryGetToken(settings.WeixinAppId, settings.WeixinAppSecret);
                    if (string.IsNullOrWhiteSpace(token))
                    {
                        token = AccessTokenContainer.TryGetToken(settings.WeixinAppId, settings.WeixinAppSecret, true);
                    }

                    SceneModel scene = new SceneModel(QR_SCENE_Type.ShopShipper)
                    {
                        //Object = CurrentUser.Id.ToString()
                    };
                    SceneHelper helper = new SceneHelper();
                    sceneid = helper.SetModel(scene);
                    var ticket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 300, sceneid);
                    ticketstr = ticket.ticket;
                }
            }
            catch {
                Log.Error("设置退货地址出错:微信配置错误,无法获取到微信凭证");
            }
            ViewBag.ticket  = ticketstr;
            ViewBag.Sceneid = sceneid;
            ShopShipper data = new ShopShipper
            {
                ShopId = CurShopId
            };

            if (id > 0)
            {
                data = ShopShippersApplication.GetShopShipper(CurShopId, id);
                if (data == null)
                {
                    throw new HimallException("错误的参数");
                }
            }
            return(View(data));
        }
コード例 #9
0
 public JsonResult Save(ShopShipper model)
 {
     if (model.RegionId <= 0)
     {
         ModelState.AddModelError("Latitude", "请选择发货地区");
     }
     if (!model.Latitude.HasValue || !model.Longitude.HasValue)
     {
         ModelState.AddModelError("Latitude", "请定位发货地址");
     }
     if (ModelState.IsValid)
     {
         bool isadd = false;
         if (model.Id == 0)
         {
             isadd = true;
         }
         model.ShopId = CurShopId;
         if (isadd)
         {
             ShopShippersApplication.Add(CurShopId, model);
         }
         else
         {
             var curdata = ShopShippersApplication.GetShopShipper(CurShopId, model.Id);
             if (curdata == null)
             {
                 throw new HimallException("错误参数");
             }
             UpdateModel(curdata);
             ShopShippersApplication.Update(CurShopId, curdata);
         }
         return(Json(new Result()
         {
             success = true, msg = "保存发收货地址成功"
         }));
     }
     else
     {
         return(Json(new Result()
         {
             success = false, msg = "数据参数错误"
         }));
     }
 }
コード例 #10
0
        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("操作成功"));
        }
コード例 #11
0
 public object GetShopGetAddress(long shopId, long shopBranchId = 0)
 {
     if (shopBranchId <= 0)
     {
         var data = ShopShippersApplication.GetDefaultGetGoodsShipper(shopId);
         if (data == null)
         {
             data = new DTO.ShopShipper()
             {
             };
         }
         else
         {
             data.RegionStr = RegionApplication.GetFullName(data.RegionId);
         }
         var model = new
         {
             success     = true,
             Region      = data.RegionStr,
             Address     = data.Address,
             Phone       = data.TelPhone,
             ShipperName = data.ShipperName
         };
         return(model);
     }
     else
     {
         var    data      = ShopBranchApplication.GetShopBranchById(shopBranchId);
         string redionstr = "";
         if (data != null)
         {
             redionstr = RegionApplication.GetFullName(data.AddressId);
         }
         var model = new
         {
             success     = true,
             Region      = redionstr,
             Address     = data.AddressDetail,
             Phone       = data.ContactPhone,
             ShipperName = data.ContactUser
         };
         return(model);
     }
 }
コード例 #12
0
 public JsonResult GetShopGetAddress(long shopId, long shopBranchId = 0)
 {
     if (shopBranchId <= 0)
     {
         var data = ShopShippersApplication.GetDefaultGetGoodsShipper(shopId);
         if (data == null)
         {
             data = new DTO.ShopShipper()
             {
             };
         }
         else
         {
             data.RegionStr = RegionApplication.GetFullName(data.RegionId);
         }
         var model = new
         {
             Region      = string.IsNullOrEmpty(data.RegionStr) ? "" : data.RegionStr,
             Address     = string.IsNullOrEmpty(data.Address) ? "" : data.Address,
             Phone       = string.IsNullOrEmpty(data.TelPhone) ? "" : data.TelPhone,
             ShipperName = string.IsNullOrEmpty(data.ShipperName) ? "" : data.ShipperName
         };
         return(Json <dynamic>(true, data: model));
     }
     else
     {
         var    data      = ShopBranchApplication.GetShopBranchById(shopBranchId);
         string redionstr = "";
         if (data != null)
         {
             redionstr = RegionApplication.GetFullName(data.AddressId);
         }
         var model = new
         {
             Region      = redionstr,
             Address     = data == null ? "" : data.AddressDetail,
             Phone       = data == null ? "" : data.ContactPhone,
             ShipperName = data == null ? "" : data.ContactUser
         };
         return(Json <dynamic>(true, data: model));
     }
 }
コード例 #13
0
        /// <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);
                }
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        /// <summary>
        /// 订单详细信息页面
        /// </summary>
        /// <param name="id">订单Id</param>
        public ActionResult Detail(long id)
        {
            OrderDetailView view = OrderApplication.Detail(id, UserId, PlatformType, Request.Url.Host);

            ViewBag.Detail          = view.Detail;
            ViewBag.Bonus           = view.Bonus;
            ViewBag.ShareHref       = view.ShareHref;
            ViewBag.IsRefundTimeOut = view.IsRefundTimeOut;
            ViewBag.Logo            = SiteSettings.Logo;
            view.Order.FightGroupOrderJoinStatus = view.FightGroupJoinStatus;
            view.Order.FightGroupCanRefund       = view.FightGroupCanRefund;

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(view.Order.ShopId);

            ViewBag.CustomerServices = customerServices;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            #region 门店信息
            if (view.Order.ShopBranchId > 0)
            {
                var shopBranchInfo = ShopBranchApplication.GetShopBranchById(view.Order.ShopBranchId);
                ViewBag.ShopBranchInfo = shopBranchInfo;
                if (view.Order.OrderType == OrderInfo.OrderTypes.Virtual && shopBranchInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(shopBranchInfo.AddressId) + " " + shopBranchInfo.AddressDetail;
                    shipperTelPhone = shopBranchInfo.ContactPhone;
                }
            }
            else
            {
                if (view.Order.OrderType == OrderInfo.OrderTypes.Virtual)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(view.Order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            ViewBag.isCanRefundOrder = OrderApplication.CanRefund(view.Order);
            #region 虚拟订单信息
            if (view.Order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = view.Detail.OrderItems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    ViewBag.virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        view.Order.Id
                    });
                    orderVerificationCodes.ForEach(a =>
                    {
                        a.QRCode = GetQRCode(a.VerificationCode);
                    });
                    ViewBag.orderVerificationCodes = orderVerificationCodes;
                    ViewBag.virtualOrderItemInfos  = OrderApplication.GetVirtualOrderItemInfosByOrderId(view.Order.Id);
                }
            }
            #endregion
            //发票信息
            ViewBag.OrderInvoiceInfo = OrderApplication.GetOrderInvoiceInfo(view.Order.Id);
            //统一显示支付方式名称
            view.Order.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(view.Order.PaymentTypeGateway) ?? view.Order.PaymentTypeName;
            ViewBag.ShipperAddress     = shipperAddress;
            ViewBag.ShipperTelPhone    = shipperTelPhone;
            return(View(view.Order));
        }
コード例 #16
0
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(id, CurrentUser.Id);

            var    orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var    bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var    orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var    bonusmodel         = bonusService.GetGrantByUserOrder(id, CurrentUser.Id);
            bool   hasBonus           = bonusmodel != null ? true : false;
            string shareHref          = "";
            string shareTitle         = "";
            string shareDetail        = "";
            string shareImg           = "";

            if (hasBonus)
            {
                shareHref = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/shopbonus/index/" + bonusService.GetGrantIdByOrderId(id);
                var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId);
                shareTitle  = bonus.ShareTitle;
                shareDetail = bonus.ShareDetail;
                shareImg    = HimallIO.GetRomoteImagePath(bonus.ShareImg);
            }
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(order.ShopId);

            var shop        = ShopApplication.GetShop(order.ShopId);
            var orderItems  = OrderApplication.GetOrderItemsByOrderId(order.Id);
            var products    = ProductManagerApplication.GetProducts(orderItems.Select(p => p.ProductId));
            var refunds     = OrderApplication.GetOrderRefundsByOrder(order.Id);        //获取订单商品项数据
            var orderDetail = new
            {
                ShopId     = shop.Id,
                ShopName   = shop.ShopName,
                OrderItems = orderItems.Select(item =>
                {
                    var product  = products.FirstOrDefault(p => p.Id == item.ProductId);
                    var typeInfo = TypeApplication.GetType(product.TypeId);

                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (product != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
                    }
                    var itemrefund   = refunds.FirstOrDefault(d => d.OrderItemId == item.Id && d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                    int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus);
                    itemrefstate     = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                    var IsCanRefund  = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id);
                    return(new
                    {
                        ItemId = item.Id,
                        ProductId = item.ProductId,
                        ProductName = item.ProductName,
                        Count = item.Quantity,
                        Price = item.SalePrice,
                        ProductImage = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = IsCanRefund,
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                        OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id),
                        RefundStats = itemrefstate
                    });
                })
            };
            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            var _ordrefobj = orderRefundService.GetOrderRefundByOrderId(order.Id) ?? new OrderRefundInfo {
                Id = 0
            };

            if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
            {
                _ordrefobj = new OrderRefundInfo {
                    Id = 0
                };
            }
            int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus);

            ordrefstate = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate);

            var hasAppendComment = ServiceProvider.Instance <ICommentService> .Create.HasAppendComment(orderItems.FirstOrDefault().Id);

            var orderModel = new
            {
                Id                 = order.Id,
                OrderType          = order.OrderType,
                OrderTypeName      = order.OrderType.ToDescription(),
                Status             = order.OrderStatus.ToDescription(),
                JoinStatus         = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                ShipTo             = order.ShipTo,
                Phone              = order.CellPhone,
                Address            = order.RegionFullName + " " + order.Address,
                HasExpressStatus   = !string.IsNullOrWhiteSpace(order.ShipOrderNumber),
                ExpressCompanyName = order.ExpressCompanyName,
                Freight            = order.Freight,
                Tax                = order.Tax,
                IntegralDiscount   = order.IntegralDiscount,
                RealTotalAmount    = order.OrderTotalAmount,
                CapitalAmount      = order.CapitalAmount,
                RefundTotalAmount  = order.RefundTotalAmount,
                ProductTotalAmount = order.ProductTotalAmount,
                OrderPayAmount     = order.OrderPayAmount,//订单需要第三方支付的金额
                PaymentTypeName    = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeDesc    = order.PaymentTypeDesc,
                OrderDate          = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName           = order.ShopName,
                VShopId            = vshop == null ? 0 : vshop.Id,
                commentCount       = OrderApplication.GetOrderCommentCount(order.Id),
                ShopId             = order.ShopId,
                orderStatus        = (int)order.OrderStatus,
                //Invoice = order.InvoiceType.ToDescription(),
                //InvoiceValue = (int)order.InvoiceType,
                //InvoiceContext = order.InvoiceContext,
                //InvoiceTitle = order.InvoiceTitle,
                //InvoiceCode = order.InvoiceCode,
                PaymentType         = order.PaymentType.ToDescription(),
                PaymentTypeValue    = (int)order.PaymentType,
                FullDiscount        = order.FullDiscount,
                DiscountAmount      = order.DiscountAmount,
                OrderRemarks        = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                HasBonus            = hasBonus,
                ShareHref           = shareHref,
                ShareTitle          = shareTitle,
                ShareDetail         = shareDetail,
                ShareImg            = shareImg,
                IsCanRefund         = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, ordrefstate, null),
                RefundStats         = ordrefstate,
                OrderRefundId       = _ordrefobj.Id > 0 ? _ordrefobj.Id : 0,
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                HasAppendComment    = hasAppendComment,
                SelfTake            = order.DeliveryType == Himall.CommonModel.DeliveryType.SelfTake ? 1 : 0,
                OrderInvoice        = OrderApplication.GetOrderInvoiceInfo(order.Id)
            };

            #region 门店配送信息
            Himall.DTO.ShopBranch storeInfo = null;
            if (order.ShopBranchId > 0)
            {
                storeInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }
            #endregion
            #region 虚拟订单信息
            VirtualProductInfo virtualProductInfo = null;
            int            validityType = 0; string startDate = string.Empty, endDate = string.Empty;
            List <dynamic> orderVerificationCodes = null;
            List <dynamic> virtualOrderItemInfos  = null;
            bool           isCanRefundVirtual     = false;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = orderItems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    if (virtualProductInfo != null)
                    {
                        validityType = virtualProductInfo.ValidityType ? 1 : 0;
                        if (validityType == 1)
                        {
                            startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd");
                            endDate   = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd");
                        }
                    }
                    var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    });
                    orderVerificationCodes = codes.Select(p =>
                    {
                        return(new
                        {
                            VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "),
                            Status = p.Status,
                            StatusText = p.Status.ToDescription(),
                            QRCode = GetQRCode(p.VerificationCode)
                        });
                    }).ToList <dynamic>();

                    var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                    virtualOrderItemInfos = virtualItems.Select(p =>
                    {
                        return(new
                        {
                            VirtualProductItemName = p.VirtualProductItemName,
                            Content = ReplaceImage(p.Content, p.VirtualProductItemType),
                            VirtualProductItemType = p.VirtualProductItemType
                        });
                    }).ToList <dynamic>();
                }
            }
            if (order.OrderStatus == Himall.Entities.OrderInfo.OrderOperateStatus.WaitVerification)
            {
                if (virtualProductInfo != null)
                {
                    if (virtualProductInfo.SupportRefundType == 2)
                    {
                        isCanRefundVirtual = true;
                    }
                    else if (virtualProductInfo.SupportRefundType == 1)
                    {
                        if (virtualProductInfo.EndDate.Value > DateTime.Now)
                        {
                            isCanRefundVirtual = true;
                        }
                    }
                    else if (virtualProductInfo.SupportRefundType == 3)
                    {
                        isCanRefundVirtual = false;
                    }

                    if (isCanRefundVirtual)
                    {
                        long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                        if (num > 0)
                        {
                            isCanRefundVirtual = true;
                        }
                        else
                        {
                            isCanRefundVirtual = false;
                        }
                    }
                }
            }
            #endregion
            #region 虚拟订单核销地址信息
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (order.ShopBranchId > 0 && storeInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(storeInfo.AddressId) + " " + storeInfo.AddressDetail;
                    shipperTelPhone = storeInfo.ContactPhone;
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            return(new
            {
                success = true,
                Order = orderModel,
                OrderItem = orderDetail.OrderItems,
                StoreInfo = storeInfo,
                CustomerServices = customerServices,
                ValidityType = validityType,
                StartDate = startDate,
                EndDate = endDate,
                OrderVerificationCodes = orderVerificationCodes,
                VirtualOrderItemInfos = virtualOrderItemInfos,
                IsCanRefundVirtual = isCanRefundVirtual,
                ShipperAddress = shipperAddress,
                ShipperTelPhone = shipperTelPhone
            });
        }
コード例 #17
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
                });
            }
        }
コード例 #18
0
        public ActionResult Detail(long id)
        {
            var order      = _iOrderService.GetOrder(id, CurrentUser.Id);//限制到用户
            var orderItems = _iOrderService.GetOrderItemsByOrderId(order.Id);
            //补充商品货号
            var proids      = orderItems.Select(d => d.ProductId);
            var procodelist = ProductManagerApplication.GetProductByIds(proids).Select(d => new { d.Id, d.ProductCode, d.FreightTemplateId }).ToList();

            foreach (var item in orderItems)
            {
                var _tmp = procodelist.Find(d => d.Id == item.ProductId);
                if (_tmp != null)
                {
                    item.ProductCode = _tmp.ProductCode;
                    item.FreightId   = _tmp.FreightTemplateId;
                }
            }
            var service = ServiceApplication.Create <Mall.IServices.IProductService>();
            //  string RegionIdPath = regionService.GetRegionPath(order.RegionId);
            var freightProductGroup = orderItems.GroupBy(a => a.FreightId);

            if (order.DeliveryType != CommonModel.DeliveryType.SelfTake)
            {
                var regionService = ServiceApplication.Create <Mall.IServices.IRegionService>();
                var region        = regionService.GetRegion(order.RegionId);
                int cityId        = 0;
                if (region != null)
                {
                    cityId = region.Id;
                }
                //foreach (var f in freightProductGroup)
                //{
                //    var productIds = f.Select(a => a.ProductId);
                //    var counts = f.Select(a => Convert.ToInt32(a.Quantity));
                //    decimal freight = service.GetFreight(productIds, counts, cityId);

                //    foreach (var item in f)
                //    {
                //        item.Freight = freight;
                //    }
                //}
            }

            ViewBag.freightProductGroup = freightProductGroup;

            ViewBag.Coupon = 0;
            var coupon = _iCouponService.GetCouponRecordInfo(order.UserId, order.Id);
            var bonus  = _iShopBonusService.GetUsedPrice(order.Id, order.UserId);

            if (coupon != null)
            {
                ViewBag.Coupon = CouponApplication.GetCouponInfo(coupon.CouponId).Price;
            }
            else if (bonus > 0)
            {
                ViewBag.Coupon = bonus;
            }

            if (order.OrderType == Entities.OrderInfo.OrderTypes.FightGroup)
            {
                var fgord = _iFightGroupService.GetFightGroupOrderStatusByOrderId(order.Id);
                order.FightGroupOrderJoinStatus = fgord.GetJoinStatus;
                order.FightGroupCanRefund       = fgord.CanRefund;
            }
            //使用OrderListModel
            //   AutoMapper.Mapper.CreateMap<OrderInfo, OrderListModel>();
            // AutoMapper.Mapper.CreateMap<OrderItemInfo, OrderItemListModel>();
            var orderModel = order.Map <OrderListModel>();

            orderModel.OrderItemList = orderItems.Map <IEnumerable <OrderItemListModel> >();
            if (order.ShopBranchId > 0)
            {//补充数据
                var branch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                if (branch != null)
                {
                    orderModel.ShopBranchName         = branch.ShopBranchName;
                    orderModel.ShopBranchAddress      = branch.AddressFullName;
                    orderModel.ShopBranchContactPhone = branch.ContactPhone;
                }
            }
            if (order.FightGroupOrderJoinStatus.HasValue)
            {
                orderModel.FightGroupJoinStatus = order.FightGroupOrderJoinStatus.Value;
            }
            orderModel.UserRemark = order.OrderRemarks;
            ViewBag.Keyword       = SiteSettings.Keyword;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            #region 虚拟订单
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                orderModel.OrderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                {
                    order.Id
                });
                orderModel.OrderVerificationCodes.ForEach(a =>
                {
                    a.QRCode = GetQRCode(a.VerificationCode);
                });
                orderModel.VirtualOrderItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                if (order.ShopBranchId > 0)//门店订单取门店地址
                {
                    var shopBranch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    if (shopBranch != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(shopBranch.AddressId) + " " + shopBranch.AddressDetail;
                        shipperTelPhone = shopBranch.ContactPhone;
                    }
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            ViewBag.ShipperAddress  = shipperAddress;
            ViewBag.ShipperTelPhone = shipperTelPhone;
            #endregion
            orderModel.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName;
            //发票信息
            orderModel.OrderInvoice = OrderApplication.GetOrderInvoiceInfo(order.Id);
            return(View(orderModel));
        }
コード例 #19
0
        public object GetOrderDetail(long orderId)
        {
            CheckUserLogin();
            var orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var order              = orderService.GetOrder(orderId, CurrentUser.Id);
            var orderitems         = orderService.GetOrderItemsByOrderId(order.Id);
            var orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var productService     = ServiceProvider.Instance <IProductService> .Create;
            var coupon             = ServiceProvider.Instance <ICouponService> .Create.GetCouponRecordInfo(order.UserId, order.Id);

            string  couponName  = "";
            decimal couponAmout = 0;

            if (coupon != null)
            {
                var c = CouponApplication.GetCouponInfo(coupon.CouponId);
                couponName  = c.CouponName;
                couponAmout = c.Price;
            }

            //订单信息是否正常
            if (order == null)
            {
                throw new MallException("订单号不存在!");
            }
            dynamic expressTrace = new ExpandoObject();

            //取订单物流信息
            if (!string.IsNullOrWhiteSpace(order.ShipOrderNumber))
            {
                var expressData = ServiceProvider.Instance <IExpressService> .Create.GetExpressData(order.ExpressCompanyName, order.ShipOrderNumber);

                if (expressData.Success)
                {
                    expressData.ExpressDataItems = expressData.ExpressDataItems.OrderByDescending(item => item.Time);//按时间逆序排列
                    expressTrace.traces          = expressData.ExpressDataItems.Select(item => new
                    {
                        acceptTime    = item.Time.ToString("yyyy-MM-dd HH:mm:ss"),
                        acceptStation = item.Content
                    });
                }
            }
            var orderRefunds     = OrderApplication.GetOrderRefunds(orderitems.Select(p => p.Id));
            var isCanOrderReturn = OrderApplication.CanRefund(order);
            //获取订单商品项数据
            var orderDetail = new
            {
                ShopId = order.ShopId,
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                OrderItems          = orderitems.Select(item =>
                {
                    var productinfo            = productService.GetProduct(item.ProductId);
                    Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(productinfo.TypeId);
                    string colorAlias          = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias           = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias        = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    var itemStatusText         = "";
                    var itemrefund             = orderRefunds.Where(or => or.OrderItemId == item.Id).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                    int?itemrefstate           = (itemrefund == null ? 0 : (int?)itemrefund.SellerAuditStatus);
                    itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                    if (itemrefund != null)
                    {     //默认为商家处理进度
                        if (itemrefstate == 4)
                        { //商家拒绝,可以再发起申请
                            itemStatusText = "";
                        }
                        else
                        {
                            itemStatusText = "售后处理中";
                        }
                    }
                    if (itemrefstate > 4)
                    {//如果商家已经处理完,则显示平台处理进度
                        if (itemrefstate == 7)
                        {
                            itemStatusText = "退款成功";
                        }
                    }
                    if (productinfo != null)
                    {
                        colorAlias   = (!string.IsNullOrWhiteSpace(productinfo.ColorAlias)) ? productinfo.ColorAlias : colorAlias;//如果商品有自定义规格名称,则用
                        sizeAlias    = (!string.IsNullOrWhiteSpace(productinfo.SizeAlias)) ? productinfo.SizeAlias : sizeAlias;
                        versionAlias = (!string.IsNullOrWhiteSpace(productinfo.VersionAlias)) ? productinfo.VersionAlias : versionAlias;
                    }

                    long activeId   = 0;
                    int activetype  = 0;
                    var limitbuyser = ServiceProvider.Instance <ILimitTimeBuyService> .Create;
                    var limitBuy    = limitbuyser.GetLimitTimeMarketItemByProductId(item.ProductId);
                    if (limitBuy != null)
                    {
                        //salePrice = limitBuy.MinPrice;
                        activeId   = limitBuy.Id;
                        activetype = 1;
                    }
                    else
                    {
                        #region 限时购预热
                        var FlashSale       = limitbuyser.IsFlashSaleDoesNotStarted(item.ProductId);
                        var FlashSaleConfig = limitbuyser.GetConfig();

                        if (FlashSale != null)
                        {
                            TimeSpan flashSaleTime = DateTime.Parse(FlashSale.BeginDate) - DateTime.Now; //开始时间还剩多久
                            TimeSpan preheatTime   = new TimeSpan(FlashSaleConfig.Preheat, 0, 0);        //预热时间是多久
                            if (preheatTime >= flashSaleTime)                                            //预热大于开始
                            {
                                if (!FlashSaleConfig.IsNormalPurchase)
                                {
                                    activeId   = FlashSale.Id;
                                    activetype = 1;
                                }
                            }
                        }
                        #endregion
                    }

                    return(new
                    {
                        Status = itemrefstate,
                        StatusText = itemStatusText,
                        Id = item.Id,
                        SkuId = item.SkuId,
                        ProductId = item.ProductId,
                        Name = item.ProductName,
                        Amount = item.Quantity,
                        Price = item.SalePrice,
                        //ProductImage = "http://" + Url.Request.RequestUri.Host + productService.GetProduct(item.ProductId).GetImage(ProductInfo.ImageSize.Size_100),
                        Image = Core.MallIO.GetRomoteProductSizeImage(productService.GetProduct(item.ProductId).RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id),
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        SkuText = colorAlias + ":" + item.Color + ";" + sizeAlias + ":" + item.Size + ";" + versionAlias + ":" + item.Version,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                        ActiveId = activeId,    //活动Id
                        ActiveType = activetype //活动类型(1代表限购,2代表团购,3代表商品预售,4代表限购预售,5代表团购预售)
                    });
                })
            };

            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            #region 门店信息
            var branchInfo = new ShopBranch();
            if (order.ShopBranchId > 0)
            {
                branchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }
            else
            {
                branchInfo = null;
            }
            #endregion

            #region 虚拟订单信息
            VirtualProductInfo virtualProductInfo = null;
            int            validityType = 0; string startDate = string.Empty, endDate = string.Empty;
            List <dynamic> orderVerificationCodes = null;
            List <dynamic> virtualOrderItemInfos  = null;
            bool           isCanRefundVirtual     = false;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = orderitems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    if (virtualProductInfo != null)
                    {
                        validityType = virtualProductInfo.ValidityType ? 1 : 0;
                        if (validityType == 1)
                        {
                            startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd");
                            endDate   = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd");
                        }
                    }
                    var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    });
                    orderVerificationCodes = codes.Select(p =>
                    {
                        return(new
                        {
                            VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "),
                            Status = p.Status,
                            StatusText = p.Status.ToDescription(),
                            QRCode = GetQRCode(p.VerificationCode)
                        });
                    }).ToList <dynamic>();

                    var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                    virtualOrderItemInfos = virtualItems.Select(p =>
                    {
                        return(new
                        {
                            VirtualProductItemName = p.VirtualProductItemName,
                            Content = ReplaceImage(p.Content, p.VirtualProductItemType),
                            VirtualProductItemType = p.VirtualProductItemType
                        });
                    }).ToList <dynamic>();
                }
            }
            if (order.OrderStatus == Mall.Entities.OrderInfo.OrderOperateStatus.WaitVerification)
            {
                if (virtualProductInfo != null)
                {
                    if (virtualProductInfo.SupportRefundType == 2)
                    {
                        isCanRefundVirtual = true;
                    }
                    else if (virtualProductInfo.SupportRefundType == 1)
                    {
                        if (virtualProductInfo.EndDate.Value > DateTime.Now)
                        {
                            isCanRefundVirtual = true;
                        }
                    }
                    else if (virtualProductInfo.SupportRefundType == 3)
                    {
                        isCanRefundVirtual = false;
                    }

                    if (isCanRefundVirtual)
                    {
                        long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                        if (num > 0)
                        {
                            isCanRefundVirtual = true;
                        }
                        else
                        {
                            isCanRefundVirtual = false;
                        }
                    }
                }
            }
            #endregion
            #region 虚拟订单核销地址信息
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (order.ShopBranchId > 0 && branchInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(branchInfo.AddressId) + " " + branchInfo.AddressDetail;
                    shipperTelPhone = branchInfo.ContactPhone;
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            var bonusmodel = ServiceProvider.Instance <IShopBonusService> .Create.GetGrantByUserOrder(orderId, CurrentUser.Id);

            bool   hasBonus    = bonusmodel != null ? true : false;
            string shareHref   = "";
            string shareTitle  = "";
            string shareDetail = "";
            string shareImg    = "";
            if (hasBonus)
            {
                shareHref = "/m-weixin/ShopBonus/Index/" + ServiceProvider.Instance <IShopBonusService> .Create.GetGrantIdByOrderId(orderId);

                var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId);
                shareTitle  = bonus.ShareTitle;
                shareDetail = bonus.ShareDetail;
                shareImg    = MallIO.GetRomoteImagePath(bonus.ShareImg);
            }
            var orderModel = new
            {
                OrderId             = order.Id,
                Status              = (int)order.OrderStatus,
                StatusText          = order.OrderStatus.ToDescription(),
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                OrderTotal          = order.OrderTotalAmount,
                CapitalAmount       = order.CapitalAmount,
                OrderAmount         = order.ProductTotalAmount,
                DeductionPoints     = 0,
                DeductionMoney      = order.IntegralDiscount,
                //CouponAmount = couponAmout.ToString("F2"),//优惠劵金额
                CouponAmount                = order.DiscountAmount, //优惠劵金额
                CouponName                  = couponName,           //优惠劵名称
                RefundAmount                = order.RefundTotalAmount,
                Tax                         = order.Tax,
                AdjustedFreight             = order.Freight,
                OrderDate                   = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ItemStatus                  = 0,
                ItemStatusText              = "",
                ShipTo                      = order.ShipTo,
                ShipToDate                  = order.ShippingDate.HasValue ? order.ShippingDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                Cellphone                   = order.CellPhone,
                Address                     = order.DeliveryType == CommonModel.DeliveryType.SelfTake && branchInfo != null ? branchInfo.AddressFullName : (order.RegionFullName + " " + order.Address),
                FreightFreePromotionName    = string.Empty,
                ReducedPromotionName        = string.Empty,
                ReducedPromotionAmount      = order.FullDiscount,
                SentTimesPointPromotionName = string.Empty,
                CanBackReturn               = !string.IsNullOrWhiteSpace(order.PaymentTypeGateway),
                CanCashierReturn            = false,
                PaymentType                 = order.PaymentType.ToDescription(),
                OrderPayAmount              = order.OrderPayAmount,//订单需要第三方支付的金额
                PaymentTypeName             = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeDesc             = order.PaymentTypeDesc,
                Remark                      = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                //InvoiceTitle = order.InvoiceTitle,
                //Invoice = order.InvoiceType.ToDescription(),
                //InvoiceValue = (int)order.InvoiceType,
                //InvoiceContext = order.InvoiceContext,
                //InvoiceCode = order.InvoiceCode,
                ModeName               = order.DeliveryType.ToDescription(),
                LogisticsData          = expressTrace,
                TakeCode               = order.PickupCode,
                LineItems              = orderDetail.OrderItems,
                IsCanRefund            = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, null, null),
                IsSelfTake             = order.DeliveryType == Mall.CommonModel.DeliveryType.SelfTake ? 1 : 0,
                BranchInfo             = branchInfo,
                DeliveryType           = (int)order.DeliveryType,
                OrderInvoice           = OrderApplication.GetOrderInvoiceInfo(order.Id),
                ValidityType           = validityType,
                StartDate              = startDate,
                EndDate                = endDate,
                OrderVerificationCodes = orderVerificationCodes,
                VirtualOrderItemInfos  = virtualOrderItemInfos,
                IsCanRefundVirtual     = isCanRefundVirtual,
                ShipperAddress         = shipperAddress,
                ShipperTelPhone        = shipperTelPhone,
                OrderType              = order.OrderType,
                JoinStatus             = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                HasBonus               = hasBonus,
                ShareHref              = shareHref,
                ShareTitle             = shareTitle,
                ShareDetail            = shareDetail,
                ShareImg               = shareImg,
                ShopName               = order.ShopName
            };

            return(Json(orderModel));
        }
コード例 #20
0
ファイル: OrderController.cs プロジェクト: redpanda321/Mall
        /// <summary>
        /// 获取立即购买提交页面的数据
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        object GetSubmitModelById(string skuId, int count, long shippingAddressId = 0, IEnumerable <string[]> CouponIdsStr = null, bool isStore = false, sbyte productType = 0, long shopBranchId = 0)
        {
            CheckUserLogin();
            dynamic d          = new System.Dynamic.ExpandoObject();
            var     siteconfig = SiteSettingApplication.SiteSettings;

            var     result = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, CouponIdsStr, shopBranchId);
            dynamic add    = new System.Dynamic.ExpandoObject();

            if (result.Address != null)
            {
                add = new
                {
                    ShippingId     = result.Address.Id,
                    ShipTo         = result.Address.ShipTo,
                    CellPhone      = result.Address.Phone,
                    FullRegionName = result.Address.RegionFullName,
                    FullAddress    = result.Address.RegionFullName + " " + result.Address.Address + " " + result.Address.AddressDetail,
                    Address        = result.Address.Address,
                    RegionId       = result.Address.RegionId
                };
            }
            else
            {
                add = null;
            }
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            if (isStore)
            {
                if (productType == 0)
                {
                    throw new MallException("门店订单暂时不允许立即购买");
                }
                //门店订单
                Mall.DTO.ShopBranch storeInfo = Application.ShopBranchApplication.GetShopBranchById(shopBranchId);
                if (storeInfo == null)
                {
                    throw new MallException("获取门店信息失败,不可提交非门店商品");
                }
                d.shopBranchId   = shopBranchId;
                d.shopBranchInfo = storeInfo;
                if (storeInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(storeInfo.AddressId) + storeInfo.AddressDetail;
                    shipperTelPhone = storeInfo.ContactPhone;
                }
            }
            d.ProductType = productType;
            if (result.ProductType == 1)
            {
                d.VirtualProductItemInfos = ProductManagerApplication.GetVirtualProductItemInfoByProductId(result.ProductId);
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new MallException("该虚拟商品已过期,不支持下单");
                }
                if (result.products != null && result.products.Count > 0 && !isStore)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);//虚拟订单支持立即购买所以商家只有一个
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            d.shipperAddress  = shipperAddress;
            d.shipperTelPhone = shipperTelPhone;
            bool canIntegralPerMoney = true, canCapital = true;

            CanDeductible(out canIntegralPerMoney, out canCapital);
            d.InvoiceContext            = result.InvoiceContext;
            d.InvoiceTitle              = result.InvoiceTitle;
            d.cellPhone                 = result.cellPhone;
            d.email                     = result.email;
            d.vatInvoice                = result.vatInvoice;
            d.invoiceName               = result.invoiceName; //默认抬头(普通、电子)
            d.invoiceCode               = result.invoiceCode; //默认税号(普通、电子)
            d.products                  = result.products;
            d.TotalAmount               = result.totalAmount;
            d.Freight                   = result.Freight;
            d.orderAmount               = result.orderAmount;
            d.IsCashOnDelivery          = result.IsCashOnDelivery;
            d.IsOpenStore               = siteconfig.IsOpenStore;
            d.Address                   = add;
            d.integralPerMoney          = result.integralPerMoney;
            d.userIntegralMaxDeductible = result.userIntegralMaxDeductible;
            d.integralPerMoneyRate      = result.integralPerMoneyRate;
            d.userIntegralMaxRate       = siteconfig.IntegralDeductibleRate;
            d.userIntegrals             = result.userIntegrals;
            d.TotalMemberIntegral       = result.memberIntegralInfo.AvailableIntegrals;
            d.canIntegralPerMoney       = canIntegralPerMoney;
            d.canCapital                = canCapital;
            d.capitalAmount             = result.capitalAmount;

            return(Json(d));
        }
コード例 #21
0
ファイル: OrderController.cs プロジェクト: redpanda321/Mall
        public ActionResult Detail(long id)
        {
            var order = _iOrderService.GetOrder(id);

            if (order == null)
            {
                throw new MallException("错误的订单信息");
            }
            if (order.OrderType == Entities.OrderInfo.OrderTypes.FightGroup)
            {
                var fgord = _iFightGroupService.GetFightGroupOrderStatusByOrderId(order.Id);
                order.FightGroupOrderJoinStatus = fgord.GetJoinStatus;
                order.FightGroupCanRefund       = fgord.CanRefund;
            }
            var orderItems = _iOrderService.GetOrderItemsByOrderId(order.Id);
            //处理平台佣金
            var orderRefunds = RefundApplication.GetOrderRefundList(id);

            foreach (var item in orderItems)
            {
                var refund = orderRefunds.Where(e => e.OrderItemId == item.Id).Sum(e => e.ReturnPlatCommission);
                item.PlatCommission = Math.Round(item.CommisRate * (item.RealTotalPrice - item.FullDiscount - item.CouponDiscount), 2);
                if (refund > 0)
                {
                    item.PlatCommission = item.PlatCommission - refund;
                }
                item.PlatCommission = (item.PlatCommission < 0) ? 0 : item.PlatCommission;
            }
            ViewBag.OrderItems = orderItems;
            ViewBag.Logs       = _iOrderService.GetOrderLogs(order.Id);
            ViewBag.Coupon     = 0;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            #region 门店信息
            if (order.ShopBranchId > 0)
            {
                var shopBranchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                if (shopBranchInfo != null)
                {
                    ViewBag.ShopBranchInfo = shopBranchInfo;
                    if (order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.Finish)
                    {
                        ViewBag.ShopBranchContactUser = shopBranchInfo.UserName;
                    }
                    if (order.OrderType == OrderInfo.OrderTypes.Virtual)
                    {
                        shipperAddress  = RegionApplication.GetFullName(shopBranchInfo.AddressId) + " " + shopBranchInfo.AddressDetail;
                        shipperTelPhone = shopBranchInfo.ContactPhone;
                    }
                }
            }
            #endregion
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                ViewBag.VirtualOrderItemInfos      = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                ViewBag.OrderVerificationCodeInfos = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                {
                    order.Id
                });
                if (order.ShopBranchId == 0)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            ViewBag.ShipperAddress  = shipperAddress;
            ViewBag.ShipperTelPhone = shipperTelPhone;
            //发票信息
            ViewBag.OrderInvoiceInfo = OrderApplication.GetOrderInvoiceInfo(order.Id);
            //统一显示支付方式名称
            order.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName;
            return(View(order));
        }
コード例 #22
0
        /// <summary>
        /// 获取立即购买提交页面的数据
        /// </summary>
        /// <param name="skuIds">库存ID集合</param>
        /// <param name="counts">库存ID对应的数量</param>
        public object GetSubmitModel(string skuId, int count, long shippingAddressId = 0, string couponIds = "")
        {
            CheckUserLogin();
            var     coupons = CouponApplication.ConvertUsedCoupon(couponIds);
            var     result  = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, coupons);
            dynamic d       = SuccessResult();

            if (result.Address != null && !result.Address.NeedUpdate)
            {
                var addDetail = result.Address.AddressDetail ?? "";
                var add       = new
                {
                    Id       = result.Address.Id,
                    ShipTo   = result.Address.ShipTo,
                    Phone    = result.Address.Phone,
                    Address  = result.Address.RegionFullName + " " + result.Address.Address + " " + addDetail,
                    RegionId = result.Address.RegionId
                };
                d.Address = add;
            }
            else
            {
                d.Address = null;
            }

            bool canIntegralPerMoney = true, canCapital = true;

            CanDeductible(out canIntegralPerMoney, out canCapital);

            d.canIntegralPerMoney = canIntegralPerMoney;
            d.canCapital          = canCapital;
            //发票信息
            d.InvoiceContext   = result.InvoiceContext; //发票类容
            d.InvoiceTitle     = result.InvoiceTitle;   //发票抬头
            d.cellPhone        = result.cellPhone;      //默认收票人手机
            d.email            = result.email;          //默认收票人邮箱
            d.vatInvoice       = result.vatInvoice;     //默认增值税发票
            d.invoiceName      = result.invoiceName;    //默认抬头(普通、电子)
            d.invoiceCode      = result.invoiceCode;    //默认税号(普通、电子)
            d.products         = result.products;
            d.capitalAmount    = result.capitalAmount;
            d.TotalAmount      = result.totalAmount;
            d.Freight          = result.Freight;
            d.orderAmount      = result.orderAmount;
            d.IsCashOnDelivery = result.IsCashOnDelivery;
            d.IsOpenStore      = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore;
            d.ProvideInvoice   = ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList());

            d.integralPerMoney          = result.integralPerMoney;
            d.userIntegralMaxDeductible = result.userIntegralMaxDeductible;
            d.integralPerMoneyRate      = result.integralPerMoneyRate;
            d.userIntegralMaxRate       = SiteSettingApplication.SiteSettings.IntegralDeductibleRate;
            d.userIntegrals             = result.userIntegrals;
            d.TotalMemberIntegral       = result.memberIntegralInfo.AvailableIntegrals;
            d.productType = result.ProductType;
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;

            if (result.ProductType == 1)
            {
                var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId);
                if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value)
                {
                    throw new HimallException("该虚拟商品已过期,不支持下单");
                }
                if (result.products != null && result.products.Count > 0)
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);//虚拟订单支持立即购买所以商家只有一个
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            d.shipperAddress  = shipperAddress;
            d.shipperTelPhone = shipperTelPhone;
            return(d);
        }