示例#1
0
        /// <summary>
        /// 提交订单
        /// </summary>
        /// <typeparam name="TMain"></typeparam>
        /// <param name="order"></param>
        /// <param name="orderDetail"></param>
        /// <returns></returns>
        public static bool SubmitOrder <TMain>(TMain order, List <IOrderDetail> orderDetail)
            where TMain : IProductOrder, new()
        {
            DBExtend helper = dbHelper;

            order.OrderId = MakeOrderId();//生成订单号
            decimal orderAmount   = 0;
            decimal orderIntegral = 0;

            orderDetail.ForEach(b => {
                b.OrderId      = order.OrderId;
                orderAmount   += b.Price * b.Num;
                orderIntegral += b.Integral * b.Num;
            });

            //if (UseFreight)
            //{
            //    decimal freightAmount = 0;
            //    double freight1, freight2;
            //    Freight.FreightAction<TType>.CalculateFreight(orderDetail, order.AreaId, supplier, out freight1, out freight2);
            //    freightAmount = order.DeliverType == Freight.DeliverType.物流 ? (decimal)freight1 : (decimal)freight2;
            //    order.FreightAmount = freightAmount;
            //}
            order.OriginalAmount = orderAmount;
            order.Integral       = orderIntegral;
            OrderAction <TType> .SubmitOrder <TMain>(order);

            //详细
            helper.BatchInsert <IOrderDetail>(orderDetail);
            return(true);
        }