Example #1
0
        /// <summary>
        /// 获取宝贝属性,商品名等
        /// </summary>
        /// <param name="TradeOrderCode"></param>
        /// <param name="tradeOrderStock"></param>
        private void AddDetail(string TradeOrderCode, TradeOrderStock tradeOrderStock)
        {
            View_TradeStock tradeStock = View_TradeStockService.GetView_TradeStock(q => q.TradeOrderCode == TradeOrderCode).FirstOrDefault();

            if (tradeStock != null)
            {
                //宝贝性质
                tradeOrderStock.itemType = tradeStock.ItemType;
                //商品类别
                tradeOrderStock.orderType = tradeStock.OrderType;
                //商品名
                tradeOrderStock.itemName = tradeStock.ItemName;
            }
        }
Example #2
0
        /// <summary>
        /// 将订单信息展示到GridControl界面
        /// </summary>
        /// <param name="gc">展示界面</param>
        /// <param name="orderList">展示订单列表</param>
        private void LoadTradeOrder(GridControl gc, GridView view, List <TradeOrderStock> tradeOrderList, List <TradeOrder> orderList)
        {
            DataSet      dataSet = new DataSet();
            MemoryStream stream  = new MemoryStream(Resources.OrderSpiltSchema);

            try
            {
                dataSet.ReadXmlSchema(stream);
            }
            finally
            {
                stream.Close();
            }

            #region dataSet赋值
            if (orderList != null)
            {
                foreach (TradeOrder tradeOrder in orderList)
                {
                    TradeOrderStock tradeOrderStock = new TradeOrderStock();
                    tradeOrderStock.order = tradeOrder;
                    DataRow orderRow = dataSet.Tables["OrderList"].NewRow();

                    InitOrderRow(orderRow, tradeOrderStock);//将一条订单信息赋值到一行上面去
                    dataSet.Tables["OrderList"].Rows.Add(orderRow);
                }
            }
            if (tradeOrderList != null)
            {
                foreach (TradeOrderStock order in tradeOrderList)
                {
                    DataRow orderRow = dataSet.Tables["OrderList"].NewRow();
                    InitOrderRow(orderRow, order);//将一条订单信息赋值到一行上面去
                    dataSet.Tables["OrderList"].Rows.Add(orderRow);
                }
            }
            #endregion


            gc.DataSource = dataSet.Tables["OrderList"];
            view.BestFitColumns();
            gc.ForceInitialize();
        }
Example #3
0
        /// <summary>
        /// 将一条订单相关信息展示到一行上面去
        /// </summary>
        /// <param name="orderRow">展示行</param>
        /// <param name="orderCur">展示订单</param>
        private void InitOrderRow(DataRow orderRow, TradeOrderStock tradeOrderStock)
        {
            TradeOrder orderCur = tradeOrderStock.order;

            orderRow["num"]                 = orderCur.num;
            orderRow["CustomTid"]           = orderCur.CustomTid;
            orderRow["sku_properties_name"] = orderCur.sku_properties_name;
            orderRow["price"]               = orderCur.price;
            orderRow["OrderType"]           = orderCur.OrderType;
            orderRow["orderTotalFee"]       = orderCur.total_fee;
            orderRow["TradeOrderCode"]      = orderCur.TradeOrderCode;
            orderRow["adjust_fee"]          = orderCur.adjust_fee;
            orderRow["payment"]             = orderCur.payment;
            orderRow["ItemType"]            = tradeOrderStock.itemType;
            orderRow["ItemName"]            = tradeOrderStock.itemName;
            orderRow["iid"]                 = orderCur.iid;
            if (CombineFlag == combineStyle.ConbineTradeFlg)
            {
                orderRow["tid"] = trade.tid;
            }
        }
Example #4
0
        /// <summary>
        /// 交易合并成一个交易
        /// </summary>
        private void ConbinePrintFlg()
        {
            /*再次确认收货人姓名、地址,省市区是否一直等信息*/
            if (DialogResult.Cancel == XtraMessageBox.Show(Alading.Properties.Resources.CheckTidData,
                                                           Alading.Properties.Resources.Imformation, MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
            {
                combine.Enabled = true;
                return;
            }

            foreach (string custom in customTidList)
            {
                tradeList.AddRange(TradeService.GetTrade(q => q.CustomTid == custom));
                parentTradeOrderList.AddRange(TradeOrderService.GetTradeOrder(q => q.CustomTid == custom));
            }/*foreach*/

            //通过outer_id  GroupBy
            List <IGrouping <string, Alading.Entity.TradeOrder> > groupOrderList = new List <IGrouping <string, Alading.Entity.TradeOrder> >();

            groupOrderList = parentTradeOrderList.GroupBy(q => q.iid).ToList();

            //生成combine_code
            string combine_code = Guid.NewGuid().ToString();

            #region /*查找相同的订单 并把相同的订单合单*/
            foreach (IGrouping <string, Alading.Entity.TradeOrder> orderList in groupOrderList)
            {
                //在对sku_properties_name分类
                List <IGrouping <string, Alading.Entity.TradeOrder> > groupList = orderList.GroupBy(q => q.sku_properties_name).ToList();

                /*存在至少有两个相同的订单*/
                if (groupList.Count() < orderList.Count())
                {
                    foreach (IGrouping <string, Alading.Entity.TradeOrder> listOrder in groupList)
                    {
                        /*找到了相同的订单*/
                        if (listOrder.Count() > 1)
                        {
                            /*订单合并处理*/
                            TradeOrderStock tradeOrderStock = new TradeOrderStock();
                            int             num             = 0;

                            foreach (Alading.Entity.TradeOrder order in listOrder)
                            {
                                tradeOrderStock.order = order;

                                //购买量汇总
                                num += order.num;

                                //adjust_fee汇总
                                tradeOrderStock.order.adjust_fee += order.adjust_fee;

                                //discount_fee汇总
                                tradeOrderStock.order.discount_fee += order.discount_fee;
                            }/*if*/

                            AddDetail(listOrder.First().TradeOrderCode, tradeOrderStock);
                            //num 汇总
                            tradeOrderStock.order.num = num;

                            //total_fee汇总
                            tradeOrderStock.order.total_fee = tradeOrderStock.order.num * tradeOrderStock.order.price + tradeOrderStock.order.adjust_fee;

                            //payment汇总
                            tradeOrderStock.order.payment = tradeOrderStock.order.discount_fee + tradeOrderStock.order.total_fee;

                            //customtid赋值
                            tradeOrderStock.order.CustomTid = combine_code;

                            //添加订单
                            tradeOrderList.Add(tradeOrderStock);
                        }    /*if*/
                        else /*没有和其他订单相同属性的单个订单*/
                        {
                            TradeOrderStock tradeOrderStock = new TradeOrderStock();
                            tradeOrderStock.order = listOrder.First();
                            //添加宝贝名等信息
                            AddDetail(listOrder.First().TradeOrderCode, tradeOrderStock);
                            //CustomTid
                            tradeOrderStock.order.CustomTid = combine_code;
                            tradeOrderList.Add(tradeOrderStock);
                        }
                    } /*foreach*/
                }     /*if*/
                else
                {
                    //单个订单
                    foreach (Alading.Entity.TradeOrder order in orderList)
                    {
                        TradeOrderStock tradeOrderStock = new TradeOrderStock();
                        tradeOrderStock.order = order;

                        //添加宝贝名等信息
                        AddDetail(order.TradeOrderCode, tradeOrderStock);
                        //CustomTid
                        tradeOrderStock.order.CustomTid = combine_code;

                        //total_fee汇总
                        tradeOrderStock.order.total_fee = tradeOrderStock.order.num * tradeOrderStock.order.price + tradeOrderStock.order.adjust_fee;

                        //payment汇总
                        tradeOrderStock.order.payment = tradeOrderStock.order.discount_fee + tradeOrderStock.order.total_fee;
                        tradeOrderList.Add(tradeOrderStock);
                    }
                }
            }/*foreach*/
            #endregion

            //邮费
            double realPostFee = 0.0;
            double payment     = 0.0;
            double total_fee   = 0.0;
            /*修改子交易信息*/
            for (int i = 0; i < tradeList.Count; i++)
            {
                if (realPostFee < tradeList[i].post_fee)
                {
                    realPostFee = tradeList[i].post_fee;
                }

                //修改本地状态
                tradeList[i].LocalStatus = LocalTradeStatus.CombineTrade;
                //添加combinecode
                tradeList[i].CombineCode = combine_code;
            }/*foreach*/

            /*父交易*/
            FatherTrade = TradeService.GetTrade(q => q.CustomTid == customTidList[0]).FirstOrDefault();
            /*父订单(虚拟订单)*/
            /*修改父交易相关信息*/

            foreach (TradeOrderStock tradeOrderStock in tradeOrderList)
            {
                payment   += tradeOrderStock.order.payment;
                total_fee += tradeOrderStock.order.total_fee;
            }
            FatherTrade.payment     = payment + realPostFee;
            FatherTrade.total_fee   = total_fee;
            FatherTrade.post_fee    = realPostFee;
            FatherTrade.CombineCode = combine_code;
            FatherTrade.tid         = Guid.NewGuid().ToString();
            FatherTrade.IsCombined  = true;
            FatherTrade.IsSelected  = false;
            /*将combine_code赋给父交易的 CustomTid*/
            FatherTrade.CustomTid   = combine_code;
            FatherTrade.LocalStatus = LocalTradeStatus.HasNotSummit;
            /*显示数据*/
            LoadTradeOrder(gcCombineTrade, gvCombineOrder, tradeOrderList, null);
            LoadTextEdit(FatherTrade);
            XtraMessageBox.Show(Alading.Properties.Resources.ConbineSuccess, Alading.Properties.Resources.Imformation);
            //合并不能用
            combine.Enabled = false;
        }