Example #1
0
 //加载小票信息
 private void LoadPosInfo()
 {
     try
     {
         var source = new cPos.Admin.Service.InoutService().GetInoutInfoById(loggingSessionInfo, this.Request.QueryString["order_id"]);
         order_no.Text         = source.order_no ?? "";
         order_date.Text       = source.order_date ?? "";
         status_desc.Text      = source.status_desc ?? "";
         create_unit_name.Text = source.create_unit_name ?? "";
         pos_name.Text         = source.pos_id ?? "";
         tital_qty.Text        = source.total_qty.ToString();
         dicount_rate.Text     = source.discount_rate.ToString();
         total_amoount.Text    = source.total_amount.ToString();
         keep_the_change.Text  = source.keep_the_change.ToString();
         wiping_zero.Text      = source.wiping_zero.ToString();
         vip_no.Text           = source.vip_no ?? "";
         pos_name.Text         = source.sales_user;
         //cretae_user_name.Text = source.create_user_name ?? "";
         //send_user_name.Text = source.send_user_name ?? "";
         //accepet_user_name.Text = source.accpect_user_name ?? "";
         //create_time.Text = source.create_time ?? "";
         //send_time.Text = source.send_time ?? "";
         //accpect_time.Text = source.accpect_time ?? "";
         approve_user_name.Text = source.approve_user_name ?? "";
         approve_time.Text      = source.approve_time ?? "";
         remark.Text            = source.remark ?? "";
         this.InoutDetailInfos  = source.InoutDetailList;
     }
     catch (Exception ex)
     {
         PageLog.Current.Write(ex);
         this.InfoBox.ShowPopError("加载数据出错!");
     }
 }
Example #2
0
        /// <summary>
        /// 批量保存调整单
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="inoutInfoList">调整单集合</param>
        /// <returns></returns>
        public bool SetAJInfoList(LoggingSessionInfo loggingSessionInfo, IList <InoutInfo> inoutInfoList)
        {
            MSSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).BeginTransaction();
            string strError = string.Empty;

            try
            {
                bool bReturn = false;

                foreach (InoutInfo inoutInfo in inoutInfoList)
                {
                    //新建
                    bReturn = SetAJInfo(loggingSessionInfo, false, inoutInfo, out strError);
                    if (!bReturn)
                    {
                        break;
                    }
                    //审批
                    if (new cBillService().CanApproveBill(loggingSessionInfo, "", inoutInfo.order_id))
                    {
                        bReturn = new InoutService().SetInoutOrderStatus(loggingSessionInfo, inoutInfo.order_id, BillActionType.Approve, out strError);
                        if (!bReturn)
                        {
                            break;
                        }
                    }
                    //影响库存
                    bReturn = new StockBalanceService().SetStockBalance(loggingSessionInfo, inoutInfo.order_id);
                    if (!bReturn)
                    {
                        break;
                    }
                }
                MSSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).CommitTransaction();
                return(true);
            }
            catch (Exception ex) {
                MSSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).RollBackTransaction();
                throw (ex);
            }
        }
Example #3
0
        /// <summary>
        /// 调整单查询
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="order_no">单据号</param>
        /// <param name="status">状态</param>
        /// <param name="unit_id">单位</param>
        /// <param name="warehouse_id">仓库</param>
        /// <param name="order_date_begin">开始日期(yyyy-MM-dd)</param>
        /// <param name="order_date_end">结束日期(yyyy-MM-dd)</param>
        /// <param name="order_reason_type_id">类型2</param>
        /// <param name="ref_order_no">上级单号</param>
        /// <param name="data_from_id">来源</param>
        /// <param name="maxRowCount">当前页数量</param>
        /// <param name="startRowIndex">开始数量</param>
        /// <returns></returns>
        public InoutInfo SearchAJInfo(LoggingSessionInfo loggingSessionInfo
                                      , string order_no
                                      , string status
                                      , string unit_id
                                      , string warehouse_id
                                      , string order_date_begin
                                      , string order_date_end
                                      , string order_reason_type_id
                                      , string ref_order_no
                                      , string data_from_id
                                      , int maxRowCount
                                      , int startRowIndex
                                      )
        {
            try
            {
                InoutInfo       inoutInfo       = new InoutInfo();
                OrderSearchInfo orderSearchInfo = new OrderSearchInfo();
                orderSearchInfo.order_no         = order_no;
                orderSearchInfo.status           = status;
                orderSearchInfo.unit_id          = unit_id;
                orderSearchInfo.warehouse_id     = warehouse_id;
                orderSearchInfo.order_date_begin = order_date_begin;
                orderSearchInfo.order_date_end   = order_date_end;
                orderSearchInfo.order_reason_id  = order_reason_type_id;
                orderSearchInfo.ref_order_no     = ref_order_no;
                orderSearchInfo.data_from_id     = data_from_id;
                orderSearchInfo.StartRow         = startRowIndex;
                orderSearchInfo.EndRow           = startRowIndex + maxRowCount;

                orderSearchInfo.order_type_id = "5F11A199E3CD42DE9CAE70442FC3D991";
                InoutService inoutService = new InoutService();
                inoutInfo = inoutService.SearchInoutInfo(loggingSessionInfo, orderSearchInfo);

                return(inoutInfo);
            }
            catch (Exception ex) {
                throw (ex);
            }
        }
Example #4
0
        /// <summary>
        /// Mobile CCOrder保存
        /// </summary>
        /// <param name="orders">models</param>
        /// <param name="IsTrans">是否批处理</param>
        /// <returns>Hashtable:
        ///  status(成功:true, 失败:false)
        ///  error(错误描述)
        /// </returns>
        public Hashtable SaveMobileCCOrderList(bool IsTrans, IList <CCInfo> orders, string userId)
        {
            Hashtable ht = new Hashtable();

            ht["status"] = false;
            try
            {
                string                        error              = string.Empty;
                SkuService                    skuService         = new SkuService();
                ItemService                   itemService        = new ItemService();
                InoutService                  inoutService       = new InoutService();
                StockBalanceOrderService      stockService       = new StockBalanceOrderService();
                UnitService                   unitService        = new UnitService();
                cPos.Model.LoggingSessionInfo loggingSessionInfo = new cPos.Model.LoggingSessionInfo();
                loggingSessionInfo.CurrentUser         = new cPos.Model.User.UserInfo();
                loggingSessionInfo.CurrentUser.User_Id = userId;

                if (IsTrans)
                {
                    MSSqlMapper.Instance().BeginTransaction();
                }

                // 处理SKU
                bool exsitBarcode          = false;
                cPos.Model.SkuInfo skuInfo = null;
                foreach (var order in orders)
                {
                    order.order_type_id = "5F11A199E3CD42DE9CAE70442FC3D991"; // AJ
                    var unitInfo = unitService.GetUnitById(loggingSessionInfo, order.unit_id);
                    order.customer_id = unitInfo.customer_id;

                    if (order.CCDetailInfoList == null)
                    {
                        continue;
                    }
                    foreach (var orderDetail in order.CCDetailInfoList)
                    {
                        exsitBarcode = skuService.CheckBarcode(orderDetail.barcode, null);
                        if (!exsitBarcode)
                        {
                            cPos.Model.ItemInfo itemInfo = new cPos.Model.ItemInfo();
                            itemInfo.SkuList = new List <cPos.Model.SkuInfo>();
                            cPos.Model.SkuInfo newSkuInfo = new cPos.Model.SkuInfo();
                            newSkuInfo.sku_id           = orderDetail.sku_id;
                            newSkuInfo.barcode          = orderDetail.barcode;
                            newSkuInfo.status           = "1";
                            newSkuInfo.create_user_id   = orderDetail.create_user_id;
                            newSkuInfo.create_time      = orderDetail.create_time;
                            newSkuInfo.modify_user_id   = orderDetail.modify_user_id;
                            newSkuInfo.modify_time      = orderDetail.modify_time;
                            newSkuInfo.prop_1_detail_id = orderDetail.sku_prop_1_name;
                            newSkuInfo.prop_2_detail_id = orderDetail.sku_prop_2_name;
                            newSkuInfo.prop_3_detail_id = orderDetail.sku_prop_3_name;
                            newSkuInfo.prop_4_detail_id = orderDetail.sku_prop_4_name;
                            newSkuInfo.prop_5_detail_id = orderDetail.sku_prop_5_name;

                            // 商品
                            var itemListObj             = itemService.GetItemByCode(orderDetail.item_code);
                            cPos.Model.ItemInfo itemObj = new cPos.Model.ItemInfo();
                            if (itemListObj != null && itemListObj.Count > 0)
                            {
                                itemObj            = itemListObj[0];
                                newSkuInfo.item_id = itemObj.Item_Id;

                                if (itemObj.SkuList == null)
                                {
                                    itemObj.SkuList = new List <cPos.Model.SkuInfo>();
                                }
                                itemObj.SkuList.Add(newSkuInfo);
                                skuService.SetSkuInfo(itemObj, out error);
                            }
                            else
                            {
                                itemObj = new cPos.Model.ItemInfo();
                                itemObj.Item_Category_Id = "10e1e76ced9b45e1ac722d3e8b193419";
                                itemObj.Item_Id          = NewGUID();
                                itemObj.Item_Code        = orderDetail.item_code;
                                itemObj.Item_Name        = orderDetail.item_name;
                                itemObj.ifgifts          = 0;
                                itemObj.ifoften          = 0;
                                itemObj.ifservice        = 0;
                                itemObj.isGB             = 1;
                                itemObj.data_from        = "1";

                                // 价格
                                var skuPriceService  = new SkuPriceService();
                                var skuUnitPriceInfo = new cPos.Model.SkuUnitPriceInfo();
                                skuUnitPriceInfo.SkuUnitPriceInfoList = new List <cPos.Model.SkuUnitPriceInfo>();
                                if (orderDetail.enter_price != null &&
                                    orderDetail.enter_price.Trim().Length > 0)
                                {
                                    cPos.Model.SkuUnitPriceInfo unitPriceInfo = new cPos.Model.SkuUnitPriceInfo();
                                    unitPriceInfo.item_price_type_id = "12EDF2F0C5BE4FB2B4FE3ECE870FF723";
                                    unitPriceInfo.price             = Decimal.Parse(orderDetail.enter_price.Trim());
                                    unitPriceInfo.sku_unit_price_id = NewGuid();
                                    unitPriceInfo.sku_id            = orderDetail.sku_id;
                                    unitPriceInfo.unit_id           = order.unit_id;
                                    unitPriceInfo.status            = "1";
                                    unitPriceInfo.start_date        = "1900-01-01";
                                    unitPriceInfo.end_date          = "9999-12-31";
                                    unitPriceInfo.create_user_id    = userId;
                                    unitPriceInfo.create_time       = GetNow();
                                    skuUnitPriceInfo.SkuUnitPriceInfoList.Add(unitPriceInfo);
                                }
                                if (orderDetail.sales_price != null &&
                                    orderDetail.sales_price.Trim().Length > 0)
                                {
                                    cPos.Model.SkuUnitPriceInfo unitPriceInfo = new cPos.Model.SkuUnitPriceInfo();
                                    unitPriceInfo.item_price_type_id = "75412168A16C4D2296B92CA0E596A188";
                                    unitPriceInfo.price             = Decimal.Parse(orderDetail.sales_price.Trim());
                                    unitPriceInfo.sku_unit_price_id = NewGuid();
                                    unitPriceInfo.sku_id            = orderDetail.sku_id;
                                    unitPriceInfo.unit_id           = order.unit_id;
                                    unitPriceInfo.status            = "1";
                                    unitPriceInfo.start_date        = "1900-01-01";
                                    unitPriceInfo.end_date          = "9999-12-31";
                                    unitPriceInfo.create_user_id    = userId;
                                    unitPriceInfo.create_time       = GetNow();
                                    skuUnitPriceInfo.SkuUnitPriceInfoList.Add(unitPriceInfo);
                                }
                                skuPriceService.InsertOrUpdateSkuUnitPrice(false, skuUnitPriceInfo);

                                itemObj.SkuList    = new List <cPos.Model.SkuInfo>();
                                newSkuInfo.item_id = itemObj.Item_Id;
                                itemObj.SkuList.Add(newSkuInfo);

                                itemService.SetItemInfo(false, loggingSessionInfo, itemObj, out error);
                                orderDetail.sku_id = newSkuInfo.sku_id;
                            }
                        }
                        else
                        {
                            skuInfo            = skuService.GetSkuByBarcode(orderDetail.barcode);
                            orderDetail.sku_id = skuInfo.sku_id;
                        }
                    }
                }

                // 处理Order
                foreach (var order in orders)
                {
                    if (!CheckIsEndMobileCCOrder(order))
                    {
                        MSSqlMapper.Instance().Insert("CC.InsertAndUpdateMobileCCOrder", order);
                    }

                    // 获取仓库
                    var       warehouseObj = (new UnitService()).GetDefaultWarehouse(order.unit_id);
                    string    warehouseId  = warehouseObj == null ? "" : warehouseObj.warehouse_id;
                    Hashtable htStockId    = new Hashtable();
                    string    tmpStockId;

                    // 保存库存
                    foreach (var orderDetail in order.CCDetailInfoList)
                    {
                        cPos.Model.StockBalanceInfo stockInfo = new cPos.Model.StockBalanceInfo();

                        htStockId["unit_id"]      = order.unit_id;
                        htStockId["warehouse_id"] = warehouseId;
                        htStockId["sku_id"]       = orderDetail.sku_id;
                        tmpStockId = stockService.GetStockBalanceIdBySkuId(htStockId);
                        if (tmpStockId == null || tmpStockId.Trim().Length == 0)
                        {
                            tmpStockId = NewGUID();
                        }

                        stockInfo.stock_balance_id   = tmpStockId;
                        stockInfo.unit_id            = order.unit_id;
                        stockInfo.warehouse_id       = warehouseId;
                        stockInfo.sku_id             = orderDetail.sku_id;
                        stockInfo.begin_qty          = orderDetail.end_qty;
                        stockInfo.end_qty            = orderDetail.end_qty;
                        stockInfo.price              = orderDetail.enter_price == null ? 0 : Convert.ToDecimal(orderDetail.enter_price);
                        stockInfo.item_label_type_id = "522B623A30C243F2853AA34CD01B510B";
                        stockInfo.status             = "1";
                        stockInfo.create_time        = GetNow();
                        stockInfo.create_user_id     = order.create_user_id;

                        stockService.SaveStockBalance(stockInfo);
                    }
                }

                if (IsTrans)
                {
                    MSSqlMapper.Instance().CommitTransaction();
                }
                ht["status"] = true;
            }
            catch (Exception ex)
            {
                if (IsTrans)
                {
                    MSSqlMapper.Instance().RollBackTransaction();
                }
                throw (ex);
            }
            return(ht);
        }