Example #1
0
        public object PostSubmitFightGroupOrder(OrderSubmitFightGroupOrderModel value)
        {
            CheckUserLogin();
            if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd))
            {
                var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd);
                if (!flag)
                {
                    return(Json(ErrorResult <dynamic>("预存款支付密码错误!")));
                }
            }
            string skuIds           = value.skuId;
            long   counts           = value.count;
            long   recieveAddressId = value.recieveAddressId;
            long   activeId         = value.GroupActionId;
            long   groupId          = value.GroupId;

            bool   isCashOnDelivery = value.isCashOnDelivery;
            int    invoiceType      = value.invoiceType;
            string invoiceTitle     = value.invoiceTitle;
            string invoiceContext   = value.invoiceContext;
            string invoiceCode      = value.invoiceCode;

            decimal capitalAmount = value.CapitalAmount;

            string orderRemarks = "";//value.orderRemarks;//订单备注
            List <FightGroupOrderJoinStatus> seastatus = new List <FightGroupOrderJoinStatus>();

            seastatus.Add(FightGroupOrderJoinStatus.Ongoing);
            seastatus.Add(FightGroupOrderJoinStatus.JoinSuccess);
            var groupData = ServiceProvider.Instance <IFightGroupService> .Create.GetActive(activeId, false, false);

            if (counts > groupData.LimitQuantity)
            {
                return(Json(ErrorResult <dynamic>(string.Format("每人限购数量:{0}!", groupData.LimitQuantity))));
            }
            try
            {
                var model = OrderApplication.GetGroupOrder(CurrentUser.Id, skuIds, counts.ToString(), recieveAddressId, invoiceType, invoiceTitle, invoiceCode, invoiceContext, activeId, PlatformType.WeiXinSmallProg, groupId, isCashOnDelivery, orderRemarks, capitalAmount);
                CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops);
                model.OrderShops   = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提
                model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray();
                var ret = OrderApplication.OrderSubmit(model);
                AddVshopBuyNumber(ret.OrderIds);//添加微店购买数量
                return(Json(new { OrderIds = ret.OrderIds, RealTotalIsZero = ret.OrderTotal == 0 }));
            }
            catch (MallException he)
            {
                return(Json(ErrorResult <dynamic>(he.Message)));
            }
            catch (Exception ex)
            {
                return(Json(ErrorResult <dynamic>("提交订单异常" + ex.Message)));
            }
        }
Example #2
0
        /// <summary>
        /// 拼团订单提交
        /// </summary>
        /// <param name="value">表单数据</param>
        /// <returns></returns>
        public object PostSubmitFightGroupOrder(OrderSubmitFightGroupOrderModel value)
        {
            CheckUserLogin();
            string skuIds           = value.skuId;
            long   counts           = value.count;
            long   recieveAddressId = value.recieveAddressId;
            long   activeId         = value.GroupActionId;
            long   groupId          = value.GroupId;

            bool   isCashOnDelivery = value.isCashOnDelivery;
            int    invoiceType      = value.invoiceType;
            string invoiceTitle     = value.invoiceTitle;
            string invoiceContext   = value.invoiceContext;

            string orderRemarks = "";//value.orderRemarks;//订单备注
            List <FightGroupOrderJoinStatus> seastatus = new List <FightGroupOrderJoinStatus>();

            seastatus.Add(FightGroupOrderJoinStatus.Ongoing);
            seastatus.Add(FightGroupOrderJoinStatus.JoinSuccess);
            var groupData = ServiceProvider.Instance <IFightGroupService> .Create.GetActive(activeId, false, false);

            if (counts > groupData.LimitQuantity)
            {
                return(Json(new { Success = "false", Msg = string.Format("每人限购数量:{0}!", groupData.LimitQuantity) }));
            }
            if (groupId > 0)   //非开团,判断人数限制
            {
                var orderData = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderByGroupId(seastatus, groupId);

                if (orderData != null && groupData.LimitedNumber <= orderData.Count)
                {
                    return(Json(new { Success = "false", Msg = "该团参加人数已满!" }));
                }
            }

            try
            {
                var model = OrderApplication.GetGroupOrder(CurrentUser.Id, skuIds, counts.ToString(), recieveAddressId, invoiceType, invoiceTitle, invoiceContext, activeId, PlatformType.Android, groupId, isCashOnDelivery, orderRemarks);
                CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops);
                model.OrderShops   = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提
                model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray();
                var orderIds = OrderApplication.OrderSubmit(model);
                AddVshopBuyNumber(orderIds);//添加微店购买数量
                return(Json(new { Success = "true", OrderIds = orderIds }));
            }
            catch (HimallException he)
            {
                return(Json(new { Success = "false", Msg = he.Message }));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = "false", Msg = "提交订单异常" }));
            }
        }
        public object PostSubmitFightGroupOrder(OrderSubmitFightGroupOrderModel value)
        {
            this.CheckUserLogin();
            if (value.CapitalAmount > new Decimal(0) && !string.IsNullOrEmpty(value.PayPwd) && !MemberApplication.VerificationPayPwd(this.CurrentUser.Id, value.PayPwd))
            {
                return((object)this.Json(new
                {
                    Success = "false",
                    Msg = "预付款支付密码错误"
                }));
            }
            string skuId            = value.skuId;
            long   count            = value.count;
            long   recieveAddressId = value.recieveAddressId;
            long   groupActionId    = value.GroupActionId;
            long   groupId          = value.GroupId;
            bool   isCashOnDelivery = value.isCashOnDelivery;
            int    invoiceType      = value.invoiceType;
            string invoiceTitle     = value.invoiceTitle;
            string invoiceContext   = value.invoiceContext;
            string invoiceCode      = value.invoiceCode;
            string orderRemarks     = "";
            List <FightGroupOrderJoinStatus> list = new List <FightGroupOrderJoinStatus>()
            {
                FightGroupOrderJoinStatus.Ongoing,
                FightGroupOrderJoinStatus.JoinSuccess
            };
            FightGroupActiveInfo active = Instance <IFightGroupService> .Create.GetActive(groupActionId, false, false, true);

            long num           = count;
            int? limitQuantity = active.LimitQuantity;

            if ((num <= (long)limitQuantity.GetValueOrDefault() ? 0 : (limitQuantity.HasValue ? 1 : 0)) != 0)
            {
                return((object)this.Json(new
                {
                    Success = "false",
                    Msg = string.Format("每人限购数量:{0}!", (object)active.LimitQuantity)
                }));
            }
            try
            {
                OrderCreateModel groupOrder     = OrderApplication.GetGroupOrder(this.CurrentUser.Id, skuId, count.ToString(), recieveAddressId, invoiceType, invoiceTitle, invoiceCode, invoiceContext, groupActionId, PlatformType.Android, groupId, isCashOnDelivery, orderRemarks, new Decimal(0));
                OrderShop[]      orderShopArray = JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops);
                groupOrder.OrderShops   = orderShopArray;
                groupOrder.OrderRemarks = (IEnumerable <string>)Enumerable.ToArray <string>(Enumerable.Select <OrderShop, string>((IEnumerable <OrderShop>)orderShopArray, (Func <OrderShop, string>)(p => p.Remark)));
                OrderReturnModel orderReturnModel = OrderApplication.OrderSubmit(groupOrder, "");
                this.AddVshopBuyNumber((IEnumerable <long>)orderReturnModel.OrderIds);
                return((object)this.Json(new
                {
                    Success = "true",
                    OrderIds = orderReturnModel.OrderIds
                }));
            }
            catch (HimallException ex)
            {
                return((object)this.Json(new
                {
                    Success = "false",
                    Msg = ex.Message
                }));
            }
            catch (Exception ex)
            {
                return((object)this.Json(new
                {
                    Success = "false",
                    Msg = "提交订单异常"
                }));
            }
        }