示例#1
0
        /// <summary>
        /// 收货
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="receiveTime">收货时间</param>
        /// <param name="ip">ip</param>
        public static void ReceiveOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, DateTime receiveTime, string ip)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Received);//将订单状态设为收货状态

            //订单商品列表
            List <OrderProductInfo> orderProductList = GetOrderProductList(orderInfo.Oid);

            //发放收货积分
            Credits.SendReceiveOrderCredits(ref partUserInfo, orderInfo, orderProductList, receiveTime);

            //发放单品促销活动支付积分和优惠劵
            foreach (OrderProductInfo orderProductInfo in orderProductList)
            {
                if (orderProductInfo.Type == 0)
                {
                    if (orderProductInfo.PayCredits > 0)
                    {
                        Credits.SendSinglePromotionCredits(ref partUserInfo, orderInfo, orderProductInfo.PayCredits, receiveTime);
                    }
                    if (orderProductInfo.CouponTypeId > 0)
                    {
                        Coupons.SendSinglePromotionCoupon(partUserInfo, orderProductInfo.CouponTypeId, orderInfo, ip);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 后台生成优惠劵
        /// </summary>
        /// <param name="o">参数对象</param>
        private static void AdminGenerateCoupon(object o)
        {
            object[] parms = (object[])o;

            int      couponTypeId = (int)parms[0];
            int      storeId      = (int)parms[1];
            int      money        = (int)parms[2];
            int      count        = (int)parms[3];
            int      sendUid      = (int)parms[4];
            DateTime sendTime     = (DateTime)parms[5];
            string   sendIP       = (string)parms[6];

            for (int i = 0; i < count; i++)
            {
                CouponInfo couponInfo = new CouponInfo();

                couponInfo.CouponSN     = Coupons.GenerateCouponSN();
                couponInfo.Uid          = 0;
                couponInfo.CouponTypeId = couponTypeId;
                couponInfo.StoreId      = storeId;
                couponInfo.Oid          = 0;
                couponInfo.UseTime      = new DateTime(1900, 1, 1);
                couponInfo.UseIP        = "";
                couponInfo.Money        = money;
                couponInfo.ActivateTime = new DateTime(1900, 1, 1);
                couponInfo.ActivateIP   = "";
                couponInfo.CreateUid    = sendUid;
                couponInfo.CreateOid    = 0;
                couponInfo.CreateTime   = sendTime;
                couponInfo.CreateIP     = sendIP;

                AdminCoupons.CreateCoupon(couponInfo);
            }
        }
示例#3
0
        /// <summary>
        /// 发放单品促销活动优惠劵
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="ip">ip</param>
        public static void SendSinglePromotionCoupon(PartUserInfo partUserInfo, int couponTypeId, OrderInfo orderInfo, string ip)
        {
            CouponTypeInfo couponTypeInfo = GetCouponTypeById(couponTypeId);

            if (couponTypeInfo == null || couponTypeInfo.State == 0 || couponTypeInfo.UserRankLower > partUserInfo.UserRid || couponTypeInfo.OrderAmountLower > orderInfo.OrderAmount)
            {
                return;
            }

            CouponInfo couponInfo = new CouponInfo();

            couponInfo.CouponSN     = Coupons.GenerateCouponSN();
            couponInfo.Uid          = partUserInfo.Uid;
            couponInfo.CouponTypeId = couponTypeId;
            couponInfo.StoreId      = couponTypeInfo.StoreId;
            couponInfo.Oid          = 0;
            couponInfo.UseTime      = new DateTime(1900, 1, 1);
            couponInfo.UseIP        = "";
            couponInfo.Money        = couponTypeInfo.Money;
            couponInfo.ActivateTime = couponInfo.CreateTime = DateTime.Now;
            couponInfo.ActivateIP   = couponInfo.CreateIP = ip;
            couponInfo.CreateUid    = 0;
            couponInfo.CreateOid    = orderInfo.Oid;

            CreateCoupon(couponInfo);
        }
示例#4
0
        /// <summary>
        /// 后台批量生成优惠劵
        /// </summary>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="storeId">店铺id</param>
        /// <param name="money">优惠劵金额</param>
        /// <param name="count">数量</param>
        /// <param name="sendUid">发放人id</param>
        /// <param name="sendTime">发放时间</param>
        /// <param name="sendIP">发放ip</param>
        public static void AdminBatchGenerateCoupon(int couponTypeId, int storeId, int money, int count, int sendUid, DateTime sendTime, string sendIP)
        {
            if (count > 100)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(AdminGenerateCoupon), new object[7] {
                    couponTypeId, storeId, money, count, sendUid, sendTime, sendIP
                });
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    CouponInfo couponInfo = new CouponInfo();

                    couponInfo.CouponSN     = Coupons.GenerateCouponSN();
                    couponInfo.Uid          = 0;
                    couponInfo.CouponTypeId = couponTypeId;
                    couponInfo.StoreId      = storeId;
                    couponInfo.Oid          = 0;
                    couponInfo.UseTime      = new DateTime(1900, 1, 1);
                    couponInfo.UseIP        = "";
                    couponInfo.Money        = money;
                    couponInfo.ActivateTime = new DateTime(1900, 1, 1);
                    couponInfo.ActivateIP   = "";
                    couponInfo.CreateUid    = sendUid;
                    couponInfo.CreateOid    = 0;
                    couponInfo.CreateTime   = sendTime;
                    couponInfo.CreateIP     = sendIP;

                    CreateCoupon(couponInfo);
                }
            }
        }
示例#5
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="operatorId">操作人id</param>
        /// <param name="cancelTime">取消时间</param>
        public static void CancelOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int operatorId, DateTime cancelTime)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Cancelled);//将订单状态设为取消状态

            if (orderInfo.CouponMoney > 0)//退回用户使用的优惠劵
                Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);

            if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, cancelTime);

            Products.IncreaseProductStockNumber(GetOrderProductList(orderInfo.Oid));//增加商品库存数量
        }
示例#6
0
        /// <summary>
        /// 完成订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="completeTime">完成时间</param>
        /// <param name="ip">ip</param>
        public static void CompleteOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, DateTime completeTime, string ip)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Completed);//将订单状态设为完成状态

            //订单商品列表
            List<OrderProductInfo> orderProductList = GetOrderProductList(orderInfo.Oid);

            //发放完成订单积分
            Credits.SendCompleteOrderCredits(ref partUserInfo, orderInfo, orderProductList, completeTime);

            //发放单品促销活动支付积分和优惠劵
            foreach (OrderProductInfo orderProductInfo in orderProductList)
            {
                if (orderProductInfo.Type == 0)
                {
                    if (orderProductInfo.PayCredits > 0)
                        Credits.SendSinglePromotionCredits(ref partUserInfo, orderInfo, orderProductInfo.PayCredits, completeTime);
                    if (orderProductInfo.CouponTypeId > 0)
                        Coupons.SendSinglePromotionCoupon(partUserInfo, orderProductInfo.CouponTypeId, orderInfo, ip);
                }
            }
        }
示例#7
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="storeInfo">店铺信息</param>
        /// <param name="orderProductList">订单商品列表</param>
        /// <param name="singlePromotionList">单品促销活动列表</param>
        /// <param name="fullShipAddressInfo">配送地址</param>
        /// <param name="payMode">支付方式(0代表货到付款,1代表在线支付)</param>
        /// <param name="payCreditCount">支付积分数</param>
        /// <param name="couponList">优惠劵列表</param>
        /// <param name="fullCut">满减</param>
        /// <param name="buyerRemark">买家备注</param>
        /// <param name="bestTime">最佳配送时间</param>
        /// <param name="ip">ip地址</param>
        /// <returns>订单信息</returns>
        public static OrderInfo CreateOrder(PartUserInfo partUserInfo, StoreInfo storeInfo, List <OrderProductInfo> orderProductList, List <SinglePromotionInfo> singlePromotionList, FullShipAddressInfo fullShipAddressInfo, int payMode, ref int payCreditCount, List <CouponInfo> couponList, int fullCut, string buyerRemark, DateTime bestTime, string ip)
        {
            DateTime nowTime = DateTime.Now;

            OrderInfo orderInfo = new OrderInfo();

            orderInfo.OSN = GenerateOSN(storeInfo.StoreId, partUserInfo.Uid, fullShipAddressInfo.RegionId, nowTime);;
            orderInfo.Uid = partUserInfo.Uid;

            orderInfo.Weight        = Carts.SumOrderProductWeight(orderProductList);
            orderInfo.ProductAmount = Carts.SumOrderProductAmount(orderProductList);
            orderInfo.FullCut       = fullCut;
            orderInfo.ShipFee       = GetShipFee(fullShipAddressInfo.ProvinceId, fullShipAddressInfo.CityId, orderProductList);
            orderInfo.OrderAmount   = orderInfo.ProductAmount - orderInfo.FullCut + orderInfo.ShipFee;

            decimal payCreditMoney = Credits.PayCreditsToMoney(payCreditCount);

            if (orderInfo.OrderAmount >= payCreditMoney)
            {
                orderInfo.PayCreditCount = payCreditCount;
                orderInfo.PayCreditMoney = payCreditMoney;
                payCreditCount           = 0;
            }
            else
            {
                int orderPayCredits = Credits.MoneyToPayCredits(orderInfo.OrderAmount);
                orderInfo.PayCreditCount = orderPayCredits;
                orderInfo.PayCreditMoney = orderInfo.OrderAmount;
                payCreditCount           = payCreditCount - orderPayCredits;
            }

            orderInfo.CouponMoney = Coupons.SumCouponMoney(couponList);

            orderInfo.SurplusMoney = orderInfo.OrderAmount - orderInfo.PayCreditMoney - orderInfo.CouponMoney;
            if (orderInfo.SurplusMoney < 0)
            {
                orderInfo.SurplusMoney = 0;
            }

            orderInfo.OrderState = (orderInfo.SurplusMoney <= 0 || payMode == 0) ? (int)OrderState.Confirming : (int)OrderState.WaitPaying;

            orderInfo.IsReview      = 0;
            orderInfo.AddTime       = nowTime;
            orderInfo.StoreId       = storeInfo.StoreId;
            orderInfo.StoreName     = storeInfo.Name;
            orderInfo.PaySystemName = payMode == 0 ? "cod" : "";
            orderInfo.PayFriendName = payMode == 0 ? "货到付款" : "";
            orderInfo.PayMode       = payMode;

            orderInfo.RegionId  = fullShipAddressInfo.RegionId;
            orderInfo.Consignee = fullShipAddressInfo.Consignee;
            orderInfo.Mobile    = fullShipAddressInfo.Mobile;
            orderInfo.Phone     = fullShipAddressInfo.Phone;
            orderInfo.Email     = fullShipAddressInfo.Email;
            orderInfo.ZipCode   = fullShipAddressInfo.ZipCode;
            orderInfo.Address   = fullShipAddressInfo.Address;
            orderInfo.BestTime  = bestTime;

            orderInfo.BuyerRemark = buyerRemark;
            orderInfo.IP          = ip;

            try
            {
                //添加订单
                int oid = _iorderstrategy.CreateOrder(orderInfo, Carts.IsPersistOrderProduct, orderProductList);
                if (oid > 0)
                {
                    orderInfo.Oid = oid;

                    //减少商品库存数量
                    Products.DecreaseProductStockNumber(orderProductList);
                    //更新限购库存
                    if (singlePromotionList.Count > 0)
                    {
                        Promotions.UpdateSinglePromotionStock(singlePromotionList);
                    }
                    //使用支付积分
                    Credits.PayOrder(ref partUserInfo, orderInfo, orderInfo.PayCreditCount, nowTime);
                    //使用优惠劵
                    foreach (CouponInfo couponInfo in couponList)
                    {
                        if (couponInfo.Uid > 0)
                        {
                            Coupons.UseCoupon(couponInfo.CouponId, oid, nowTime, ip);
                        }
                        else
                        {
                            Coupons.ActivateAndUseCoupon(couponInfo.CouponId, partUserInfo.Uid, oid, nowTime, ip);
                        }
                    }

                    return(orderInfo);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(null);
        }
示例#8
0
        /// <summary>
        /// 退货
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="operatorId">操作人id</param>
        /// <param name="returnTime">退货时间</param>
        public static void ReturnOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int operatorId, DateTime returnTime)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Returned); //将订单状态设为退货状态

            if (orderInfo.OrderState == (int)OrderState.Sended)   //用户收货时退货
            {
                if (orderInfo.CouponMoney > 0)                    //退回用户使用的优惠劵
                {
                    Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);
                }

                if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                {
                    Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, returnTime);
                }

                if (orderInfo.PaySN.Length > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                {
                    OrderRefunds.ApplyRefund(new OrderRefundInfo
                    {
                        StoreId       = orderInfo.StoreId,
                        StoreName     = orderInfo.StoreName,
                        Oid           = orderInfo.Oid,
                        OSN           = orderInfo.OSN,
                        Uid           = orderInfo.Uid,
                        State         = 0,
                        ApplyTime     = returnTime,
                        PayMoney      = orderInfo.SurplusMoney,
                        RefundMoney   = orderInfo.SurplusMoney,
                        PaySN         = orderInfo.PaySN,
                        PaySystemName = orderInfo.PaySystemName,
                        PayFriendName = orderInfo.PayFriendName
                    });
                }
            }
            else if (orderInfo.OrderState == (int)OrderState.Completed) //订单完成后退货
            {
                if (orderInfo.CouponMoney > 0)                          //退回用户使用的优惠劵
                {
                    Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);
                }

                if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                {
                    Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, returnTime);
                }

                //应退金钱
                decimal returnMoney = orderInfo.SurplusMoney;

                //订单发放的积分
                DataTable sendCredits      = Credits.GetUserOrderSendCredits(orderInfo.Oid);
                int       payCreditAmount  = TypeHelper.ObjectToInt(sendCredits.Rows[0]["paycreditamount"]);
                int       rankCreditAmount = TypeHelper.ObjectToInt(sendCredits.Rows[0]["rankcreditamount"]);
                //判断用户当前积分是否足够退回,如果不足够就将差额核算成金钱并在应退金钱中减去
                if (partUserInfo.PayCredits < payCreditAmount)
                {
                    returnMoney     = returnMoney - Credits.PayCreditsToMoney(payCreditAmount - partUserInfo.PayCredits);
                    payCreditAmount = partUserInfo.PayCredits;
                }
                //收回订单发放的积分
                Credits.ReturnUserOrderSendCredits(ref partUserInfo, orderInfo, payCreditAmount, rankCreditAmount, operatorId, returnTime);

                StringBuilder couponIdList = new StringBuilder();
                //订单发放的优惠劵列表
                List <CouponInfo> couponList = Coupons.GetUserOrderSendCouponList(orderInfo.Oid);
                //判断优惠劵是否已经被使用,如果已经使用就在应退金钱中减去优惠劵金额
                foreach (CouponInfo couponInfo in couponList)
                {
                    if (couponInfo.Oid > 0)
                    {
                        returnMoney = returnMoney - couponInfo.Money;
                    }
                    else
                    {
                        couponIdList.AppendFormat("{0},", couponInfo.CouponId);
                    }
                }
                //收回订单发放的优惠劵
                if (couponIdList.Length > 0)
                {
                    Coupons.DeleteCouponById(couponIdList.Remove(couponIdList.Length - 1, 1).ToString());
                }

                if (returnMoney > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                {
                    OrderRefunds.ApplyRefund(new OrderRefundInfo
                    {
                        StoreId       = orderInfo.StoreId,
                        StoreName     = orderInfo.StoreName,
                        Oid           = orderInfo.Oid,
                        OSN           = orderInfo.OSN,
                        Uid           = orderInfo.Uid,
                        State         = 0,
                        ApplyTime     = returnTime,
                        PayMoney      = orderInfo.SurplusMoney,
                        RefundMoney   = returnMoney,
                        PaySN         = orderInfo.PaySN,
                        PaySystemName = orderInfo.PaySystemName,
                        PayFriendName = orderInfo.PayFriendName
                    });
                }
            }

            Products.IncreaseProductStockNumber(GetOrderProductList(orderInfo.Oid));//增加商品库存数量
        }
示例#9
0
文件: Orders.cs 项目: xiaoshihr/CMall
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="storeInfo">店铺信息</param>
        /// <param name="orderProductList">订单商品列表</param>
        /// <param name="singlePromotionList">单品促销活动列表</param>
        /// <param name="fullShipAddressInfo">配送地址</param>
        /// <param name="payPluginInfo">支付方式</param>
        /// <param name="payCreditCount">支付积分数</param>
        /// <param name="couponList">优惠劵列表</param>
        /// <param name="fullCut">满减</param>
        /// <param name="buyerRemark">买家备注</param>
        /// <param name="bestTime">最佳配送时间</param>
        /// <param name="ip">ip地址</param>
        /// <returns>订单信息</returns>
        public static OrderInfo CreateOrder(PartUserInfo partUserInfo, StoreInfo storeInfo, List <OrderProductInfo> orderProductList, List <SinglePromotionInfo> singlePromotionList, FullShipAddressInfo fullShipAddressInfo, PluginInfo payPluginInfo, ref int payCreditCount, List <CouponInfo> couponList, int fullCut, string buyerRemark, DateTime bestTime, string ip)
        {
            DateTime   nowTime   = DateTime.Now;
            IPayPlugin payPlugin = (IPayPlugin)payPluginInfo.Instance;

            OrderInfo orderInfo = new OrderInfo();

            orderInfo.OSN = GenerateOSN(storeInfo.StoreId, partUserInfo.Uid, fullShipAddressInfo.RegionId, nowTime);;
            orderInfo.Uid = partUserInfo.Uid;

            orderInfo.Weight        = Carts.SumOrderProductWeight(orderProductList);
            orderInfo.ProductAmount = Carts.SumOrderProductAmount(orderProductList);
            //折扣
            //折扣
            decimal disc = 1.00m;

            if (partUserInfo.UserLevel == 1)
            {
                disc = 0.95m;
                orderInfo.Discount      = orderInfo.ProductAmount - (orderInfo.ProductAmount * disc);
                orderInfo.ProductAmount = orderInfo.ProductAmount - orderInfo.Discount;
            }
            if (partUserInfo.UserLevel == 2)
            {
                disc = 0.9m;
                orderInfo.Discount      = orderInfo.ProductAmount - (orderInfo.ProductAmount * disc);
                orderInfo.ProductAmount = orderInfo.ProductAmount - orderInfo.Discount;
            }
            if (partUserInfo.UserLevel == 3)
            {
                disc = 0.85m;
                orderInfo.Discount      = orderInfo.ProductAmount - (orderInfo.ProductAmount * disc);
                orderInfo.ProductAmount = orderInfo.ProductAmount - orderInfo.Discount;
            }
            orderInfo.FullCut     = fullCut;
            orderInfo.ShipFee     = GetShipFee(fullShipAddressInfo.ProvinceId, fullShipAddressInfo.CityId, orderProductList);
            orderInfo.PayFee      = payPlugin.GetPayFee(orderInfo.ProductAmount - orderInfo.FullCut, nowTime, partUserInfo);
            orderInfo.OrderAmount = orderInfo.ProductAmount - orderInfo.FullCut + orderInfo.ShipFee + orderInfo.PayFee;
            //折扣
            //折扣
            //decimal disc = 1.00m;
            //if (partUserInfo.UserLevel == 1)
            //{
            //    disc = 0.95m;
            //    orderInfo.Discount = orderInfo.OrderAmount * disc;
            //    orderInfo.OrderAmount = orderInfo.OrderAmount - orderInfo.Discount;
            //}
            //if (partUserInfo.UserLevel == 2)
            //{
            //    disc = 0.9m;
            //    orderInfo.Discount = orderInfo.OrderAmount * disc;
            //    orderInfo.OrderAmount = orderInfo.OrderAmount - orderInfo.Discount;
            //}
            //if (partUserInfo.UserLevel == 3)
            //{
            //    disc = 0.85m;
            //    orderInfo.Discount = orderInfo.OrderAmount * disc;
            //    orderInfo.OrderAmount = orderInfo.OrderAmount - orderInfo.Discount;
            //}
            decimal payCreditMoney = Credits.PayCreditsToMoney(payCreditCount);

            if (orderInfo.OrderAmount >= payCreditMoney)
            {
                orderInfo.PayCreditCount = payCreditCount;
                orderInfo.PayCreditMoney = payCreditMoney;
                payCreditCount           = 0;
            }
            else
            {
                int orderPayCredits = Credits.MoneyToPayCredits(orderInfo.OrderAmount);
                orderInfo.PayCreditCount = orderPayCredits;
                orderInfo.PayCreditMoney = orderInfo.OrderAmount;
                payCreditCount           = payCreditCount - orderPayCredits;
            }

            orderInfo.CouponMoney  = Coupons.SumCouponMoney(couponList);
            orderInfo.SurplusMoney = orderInfo.OrderAmount - orderInfo.PayCreditMoney - orderInfo.CouponMoney;



            orderInfo.OrderState = (orderInfo.SurplusMoney <= 0 || payPlugin.PayMode == 0) ? (int)OrderState.Confirming : (int)OrderState.WaitPaying;

            orderInfo.ParentId      = 0;
            orderInfo.IsReview      = 0;
            orderInfo.AddTime       = nowTime;
            orderInfo.StoreId       = storeInfo.StoreId;
            orderInfo.StoreName     = storeInfo.Name;
            orderInfo.PaySystemName = payPluginInfo.SystemName;
            orderInfo.PayFriendName = payPluginInfo.FriendlyName;
            orderInfo.PayMode       = payPlugin.PayMode;

            orderInfo.RegionId  = fullShipAddressInfo.RegionId;
            orderInfo.Consignee = fullShipAddressInfo.Consignee;
            orderInfo.Mobile    = fullShipAddressInfo.Mobile;
            orderInfo.Phone     = fullShipAddressInfo.Phone;
            orderInfo.Email     = fullShipAddressInfo.Email;
            orderInfo.ZipCode   = fullShipAddressInfo.ZipCode;
            orderInfo.Address   = fullShipAddressInfo.Address;
            orderInfo.BestTime  = bestTime;

            orderInfo.BuyerRemark = buyerRemark;
            orderInfo.IP          = ip;

            try
            {
                //添加订单
                int oid = _iorderstrategy.CreateOrder(orderInfo, Carts.IsPersistOrderProduct, orderProductList);
                //int oid = _iorderstrategy.CreateOrder(orderInfo, false, orderProductList);
                if (oid > 0)
                {
                    orderInfo.Oid = oid;

                    //减少商品库存数量
                    Products.DecreaseProductStockNumber(orderProductList);
                    //更新限购库存
                    if (singlePromotionList.Count > 0)
                    {
                        Promotions.UpdateSinglePromotionStock(singlePromotionList);
                    }
                    //使用支付积分
                    Credits.PayOrder(ref partUserInfo, orderInfo, orderInfo.PayCreditCount, nowTime);
                    //使用优惠劵
                    foreach (CouponInfo couponInfo in couponList)
                    {
                        if (couponInfo.Uid > 0)
                        {
                            Coupons.UseCoupon(couponInfo.CouponId, oid, nowTime, ip);
                        }
                        else
                        {
                            Coupons.ActivateAndUseCoupon(couponInfo.CouponId, partUserInfo.Uid, oid, nowTime, ip);
                        }
                    }

                    return(orderInfo);
                }
            }
            catch (Exception ex)
            {
                //throw ex;
                BMALog.Instance.Write(ex.ToString());
            }

            return(null);
        }
示例#10
0
        /// <summary>
        /// 生成商品的促销信息
        /// </summary>
        /// <param name="singlePromotionInfo">单品促销活动</param>
        /// <param name="buySendPromotionList">买送促销活动列表</param>
        /// <param name="fullSendPromotionInfo">满赠促销活动</param>
        /// <param name="fullCutPromotionInfo">满减促销活动</param>
        /// <returns></returns>
        public static string GeneratePromotionMsg(SinglePromotionInfo singlePromotionInfo, List <BuySendPromotionInfo> buySendPromotionList, FullSendPromotionInfo fullSendPromotionInfo, FullCutPromotionInfo fullCutPromotionInfo)
        {
            StringBuilder promotionMsg = new StringBuilder();

            //单品促销
            if (singlePromotionInfo != null)
            {
                //折扣类别
                switch (singlePromotionInfo.DiscountType)
                {
                case 0:    //折扣
                    promotionMsg.AppendFormat("折扣:{0}折<br/>", singlePromotionInfo.DiscountValue);
                    break;

                case 1:    //直降
                    promotionMsg.AppendFormat("直降:{0}元<br/>", singlePromotionInfo.DiscountValue);
                    break;

                case 2:    //折后价
                    promotionMsg.AppendFormat("折后价:{0}元<br/>", singlePromotionInfo.DiscountValue);
                    break;
                }

                //积分
                if (singlePromotionInfo.PayCredits > 0)
                {
                    promotionMsg.AppendFormat("赠送{0}:{1}<br/>", Credits.PayCreditName, singlePromotionInfo.PayCredits);
                }

                //优惠劵
                if (singlePromotionInfo.CouponTypeId > 0)
                {
                    CouponTypeInfo couponTypeInfo = Coupons.GetCouponTypeById(singlePromotionInfo.CouponTypeId);
                    if (couponTypeInfo != null)
                    {
                        promotionMsg.AppendFormat("赠送优惠劵:{0}<br/>", couponTypeInfo.Name);
                    }
                }
            }
            //买送促销
            if (buySendPromotionList != null && buySendPromotionList.Count > 0)
            {
                promotionMsg.Append("买送促销:");
                foreach (BuySendPromotionInfo buySendPromotionInfo in buySendPromotionList)
                {
                    promotionMsg.AppendFormat("买{0}送{1},", buySendPromotionInfo.BuyCount, buySendPromotionInfo.SendCount);
                }
                promotionMsg.Remove(promotionMsg.Length - 1, 1);
                promotionMsg.Append("<br/>");
            }
            //满赠促销
            if (fullSendPromotionInfo != null)
            {
                promotionMsg.Append("满赠促销:");
                promotionMsg.AppendFormat("满{0}元加{1}元<br/>", fullSendPromotionInfo.LimitMoney, fullSendPromotionInfo.AddMoney);
            }
            //满减促销
            if (fullCutPromotionInfo != null)
            {
                promotionMsg.Append("满减促销:");
                promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney1, fullCutPromotionInfo.CutMoney1);
                if (fullCutPromotionInfo.LimitMoney2 > 0 && fullCutPromotionInfo.CutMoney2 > 0)
                {
                    promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney2, fullCutPromotionInfo.CutMoney2);
                }
                if (fullCutPromotionInfo.LimitMoney3 > 0 && fullCutPromotionInfo.CutMoney3 > 0)
                {
                    promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney3, fullCutPromotionInfo.CutMoney3);
                }
                promotionMsg.Remove(promotionMsg.Length - 1, 1);
                promotionMsg.Append("<br/>");
            }

            return(promotionMsg.Length > 0 ? promotionMsg.Remove(promotionMsg.Length - 5, 5).ToString() : "");
        }