コード例 #1
0
ファイル: ServiceSaleOutController.cs プロジェクト: 17/YunPos
        public ActionResult Out(string obj)
        {
            BaseResult br = new BaseResult();

            try
            {
                Hashtable   param = JSON.Deserialize <Hashtable>(obj);
                ParamVessel p     = new ParamVessel();
                p.Add("head", null, HandleType.ReturnMsg);
                p.Add("body", null, HandleType.ReturnMsg);
                p.Add("ShoppingInfo", null, HandleType.Remove);
                param = param.Trim(p);
                Td_Sale_Out_Head head = JSON.ConvertToType <Td_Sale_Out_Head>(param["head"]);
                head.id_gys = GetLoginInfo <long>("id_supplier");//int.Parse(param["id_supplier"].ToString());
                List <Td_Sale_Out_Body> body         = JSON.ConvertToType <List <Td_Sale_Out_Body> >(param["body"]);
                ShoppingInfo            shoppinginfo = JSON.ConvertToType <ShoppingInfo>(param["ShoppingInfo"]);
                Ts_Sale_Order_Log       ts           = new Ts_Sale_Order_Log();//日志

                //单号 赋值
                if (head.id_cgs <= 0)
                {
                    br.Success = false;
                    br.Message.Add("未知采购商,请刷新后再试!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (head.dh_order.IsEmpty())
                {
                    br.Success = false;
                    br.Message.Add("订单号丢失,请刷新后再试!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (head.id_gys <= 0)
                {
                    br.Success = false;
                    br.Message.Add("未知供应商,请刷新后再试!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (body.Count < 1)
                {
                    br.Success = false;
                    br.Message.Add("<h5>参数错误</h5>");
                    br.Message.Add("没有可保存的商品!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                int xh = 1;
                foreach (var item in body)
                {
                    if (item != null)
                    {
                        if (item.id_sku < 1)
                        {
                            br.Success = false;
                            br.Message.Add("<h5>参数错误</h5>");
                            br.Message.Add(String.Format("[代码:303],第{0}行数据中商品id有误!", xh));
                            br.Level = ErrorLevel.Warning;
                            return(Json(br));
                        }
                        if (item.sl <= 0m)
                        {
                            br.Success = false;
                            br.Message.Add("<h5>参数错误</h5>");
                            br.Message.Add(String.Format("[代码:303],第{0}行数据中商品数量有误!", xh));
                            br.Level = ErrorLevel.Warning;
                            return(Json(br));
                        }
                        //if (item.zhl <= 0m)
                        //{
                        //    br.Success = false;
                        //    br.Message.Add("<h5>参数错误</h5>");
                        //    br.Message.Add(String.Format("[代码:303],第{0}行数据中包装数有误!", xh));
                        //    br.Level = ErrorLevel.Warning;
                        //    return Json(br);
                        //}
                        xh++;
                    }
                }
                br = BusinessFactory.Utilety.GetNextDH(head, typeof(Td_Sale_Out_Head));

                if (!br.Success)
                {
                    return(Json(br));
                }
                ts.id             = BusinessFactory.Utilety.GetNextKey(typeof(Ts_Sale_Order_Log));
                ts.id_user        = GetLoginInfo <long>("id_user");
                ts.id_user_master = GetLoginInfo <long>("id_user_master");
                ts.flag_type      = 4;
                head.id_create    = GetLoginInfo <long>("id_user");
                head.id_edit      = GetLoginInfo <long>("id_user");
                head.flag_state   = CySoft.Model.Flags.OrderFlag.WaitDelivery;
                param.Clear();
                param.Add("head", head);
                param.Add("body", body);
                param.Add("Ts", ts);
                param.Add("id_user_master", GetLoginInfo <long>("id_user_master"));
                param.Add("ShoppingInfo", shoppinginfo);
                br = BusinessFactory.ShippingRecord.Add(param);

                return(Json(br));
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public override BaseResult Add(dynamic entity)
        {
            BaseResult              br             = new BaseResult();
            Hashtable               param          = (Hashtable)entity;
            Hashtable               param0         = new Hashtable();
            OrderFlag               new_flag_state = CySoft.Model.Flags.OrderFlag.WaitDelivery;
            Td_Sale_Out_Head        head           = (Td_Sale_Out_Head)param["head"];
            List <Td_Sale_Out_Body> body           = (List <Td_Sale_Out_Body>)param["body"];
            Ts_Sale_Order_Log       ts             = (Ts_Sale_Order_Log)param["Ts"];
            ShoppingInfo            shopping       = (ShoppingInfo)param["ShoppingInfo"];
            short xh       = 1;
            int   dj_digit = 2;
            int   je_digit = 2;

            foreach (Td_Sale_Out_Body item in body)
            {
                xh               = xh++;
                item.dh          = head.dh;                    //设置单号
                item.xh          = xh;
                item.sl          = item.sl.Digit(dj_digit);    //数量
                item.sl_ck       = item.sl_ck.Digit(dj_digit);
                item.sl_fh       = item.sl_fh.Digit(dj_digit); //折扣
                head.sl_sum      = +item.sl;
                head.flag_delete = 0;
                head.rq_fh       = DateTime.Now;
                xh++;
            }
            Ts_Param_Business item0 = new Ts_Param_Business();

            param0["id_user_master"] = param["id_user_master"];
            IList <Ts_Param_Business> list = DAL.QueryList <Ts_Param_Business>(typeof(Ts_Param_Business), param0);

            list = list.Where(m => m.bm.IndexOf("ywlc") != -1 && m.val != "0" && m.bm.IndexOf("order_ywlc_cwsh") == -1).ToList();
            if (list.Where(m => m.bm == "order_ywlc_cksh").Count() > 0)
            {
                item0.bm = "order_ywlc_cksh";
            }
            else if (list.Where(m => m.bm == "order_ywlc_fhqr").Count() > 0)
            {
                item0.bm = "order_ywlc_fhqr";
            }

            switch (item0.bm)
            {
            case "order_ywlc_cksh":
                if (list.Where(m => m.bm != "order_ywlc_cksh").Count() > 0)
                {
                    if (list.Where(m => m.bm != "order_ywlc_cksh").First().bm == "order_ywlc_shqr")
                    {
                        new_flag_state = OrderFlag.Delivered;
                    }
                    else
                    {
                        new_flag_state = OrderFlag.WaitDelivery;
                    }
                }
                else
                {
                    if (list.Count == 0)
                    {
                        new_flag_state = OrderFlag.WaitDelivery;
                    }
                    else
                    {
                        new_flag_state = OrderFlag.Receipted;
                    }
                }
                break;

            case "order_ywlc_fhqr":
                if (list.Where(m => m.bm != "order_ywlc_fhqr").Count() == 0)
                {
                    new_flag_state = OrderFlag.Receipted;
                }
                else
                {
                    new_flag_state = OrderFlag.Delivered;
                }
                break;

            case "order_ywlc_shqr":
                new_flag_state = OrderFlag.Delivered;
                break;

            default:
                new_flag_state = OrderFlag.Receipted;
                break;
            }
            head.flag_state = new_flag_state;
            DAL.AddRange(body);
            DAL.Add(head);
            param.Clear();
            param["dh_order"] = head.dh_order;
            param["dh"]       = head.dh;
            int flag = Td_Sale_Out_BodyDAL.UpdateBody(typeof(Td_Sale_Out_Body), param);

            if (item0.bm == "order_ywlc_fhqr")
            {
                param.Clear();
                param["dh"] = head.dh;
                param["new_company_logistics"] = shopping.company_logistics;
                param["new_no_logistics"]      = shopping.no_logistics;
                param["new_rq_fh_logistics"]   = shopping.rq_fh;
                param["new_id_fh"]             = head.id_create;
                DAL.UpdatePart(typeof(Td_Sale_Out_Head), param);
                param.Clear();
                param["dh"]       = head.dh;
                param["dh_order"] = head.dh_order;
                Td_Sale_Out_BodyDAL.UpdatefhCrossingck(typeof(Td_Sale_Out_Body), param);
            }
            else if (list.Where(m => m.bm != "order_ywlc_cksh").Count() == 0)
            {
                param["dh"] = head.dh;
                param.Clear();
                param["new_company_logistics"] = shopping.company_logistics;
                param["new_no_logistics"]      = shopping.no_logistics;
                param["new_rq_fh_logistics"]   = shopping.rq_fh;
                param["new_id_fh"]             = head.id_create;
                DAL.UpdatePart(typeof(Td_Sale_Out_Head), param);
                param.Clear();
                param["dh"]       = head.dh;
                param["dh_order"] = head.dh_order;
                Td_Sale_Out_BodyDAL.Updatefh(typeof(Td_Sale_Out_Body), param);
            }
            else if (list.Where(m => m.bm != "order_ywlc_cksh").First().bm == "order_ywlc_shqr")
            {
                param["dh"] = head.dh;
                param.Clear();
                param["new_company_logistics"] = shopping.company_logistics;
                param["new_no_logistics"]      = shopping.no_logistics;
                param["new_rq_fh_logistics"]   = shopping.rq_fh;
                param["new_id_fh"]             = head.id_create;
                DAL.UpdatePart(typeof(Td_Sale_Out_Head), param);
                param.Clear();
                param["dh"]       = head.dh;
                param["dh_order"] = head.dh_order;
                Td_Sale_Out_BodyDAL.Updatefh(typeof(Td_Sale_Out_Body), param);
            }

            #region 跳入分单批量插入出库单

            var Fd = new GoodsSkuFdBLL();
            Fd.DAL = DAL;
            var rs = Fd.Query_Sale_Order_Head(head.dh_order);
            if (rs.flag_fd != 1)
            {
                //检查当前单号是否存在上级单号
                var Order_Fd = Fd.Query_Sale_Order_Fd(head.dh_order);
                //存在上级订单
                if (Order_Fd != null)
                {
                    Fd.SaleOut_Out_Fd(head.dh_order, head.dh);
                }
            }

            #endregion

            ts.dh      = head.dh_order;
            ts.content = "订单已通过出库审核";
            DAL.Add(ts);
            br.Success = true;
            br.Data    = head;
            br.Message.Add(String.Format("新增出库单。信息:单号:{0}", head.dh));
            return(br);
        }
コード例 #3
0
        public ActionResult OutList(string obj)
        {
            BaseResult br = new BaseResult();

            try
            {
                if (!string.IsNullOrEmpty(obj) && obj != "[]")
                {
                    Hashtable               param        = new Hashtable();
                    List <Hashtable>        paramList    = JSON.Deserialize <List <Hashtable> >(obj);
                    List <Td_Sale_Out_Body> body         = new List <Td_Sale_Out_Body>();
                    List <Td_Sale_Out_Body> bodyQuery    = new List <Td_Sale_Out_Body>();
                    Ts_Sale_Order_Log       ts           = new Ts_Sale_Order_Log();//日志
                    ShoppingInfo            shoppinginfo = new ShoppingInfo();
                    if (shoppinginfo != null)
                    {
                        if (shoppinginfo.company_logistics == "")
                        {
                            shoppinginfo.company_logistics = "暂无";
                        }
                        if (shoppinginfo.no_logistics == "")
                        {
                            shoppinginfo.no_logistics = "暂无";
                        }
                        if (shoppinginfo.rq_fh == "")
                        {
                            shoppinginfo.rq_fh = DateTime.Now.ToString();
                        }
                    }
                    long gys            = GetLoginInfo <long>("id_supplier");
                    long id_user        = GetLoginInfo <long>("id_user");
                    long id_user_master = GetLoginInfo <long>("id_user_master");
                    foreach (Hashtable item in paramList)
                    {
                        Td_Sale_Out_Head head = new Td_Sale_Out_Head();
                        head.dh_order = item["dh_order"].ToString();
                        head.id_cgs   = Convert.ToInt32(item["id_cgs"]);
                        head.id_gys   = gys;
                        param.Clear();
                        param["id_gys"] = gys;
                        param["sort"]   = "sl_ck";
                        param["dir"]    = "desc";
                        param.Add("dh", head.dh_order);
                        br = BusinessFactory.Order.GetAll(param);
                        if (br.Data != null)
                        {
                            body.Clear();
                            body      = JSON.Deserialize <List <Td_Sale_Out_Body> >(JSON.Serialize(br.Data));
                            bodyQuery = JSON.Deserialize <List <Td_Sale_Out_Body> >(JSON.Serialize(br.Data));
                            if (head.id_cgs > 0 && !head.dh_order.IsEmpty() && head.id_gys > 0 || body.Count > 0)
                            {
                                int index = 0;
                                foreach (Td_Sale_Out_Body bq in bodyQuery)
                                {
                                    bq.dh_order = bq.dh;
                                    bq.dh       = "";
                                    bq.xh_order = Convert.ToInt16(index++);
                                    bq.sl       = bq.sl - bq.sl_ck;
                                }
                                //for (int i = 0; i < bodyQuery.Count; i++)
                                //{
                                //    //if (bodyQuery[i].sl - bodyQuery[i].sl_ck <= 0)
                                //    //{
                                //    //    bodyQuery.RemoveAt(i);
                                //    //}
                                //    //else
                                //    //{
                                //    //    bodyQuery[i].dh_order = bodyQuery[i].dh;
                                //    //    bodyQuery[i].dh = "";
                                //    //    bodyQuery[i].xh_order = Convert.ToInt16(i++);
                                //    //    bodyQuery[i].sl = bodyQuery[i].sl - bodyQuery[i].sl_ck;
                                //    //    index++;
                                //    //}
                                //    bodyQuery[i].dh_order = bodyQuery[i].dh;
                                //    bodyQuery[i].dh = "";
                                //    bodyQuery[i].xh_order = Convert.ToInt16(i++);
                                //    bodyQuery[i].sl = bodyQuery[i].sl - bodyQuery[i].sl_ck;
                                //}
                                br = BusinessFactory.Utilety.GetNextDH(head, typeof(Td_Sale_Out_Head));
                                if (br.Success)
                                {
                                    ts.id             = BusinessFactory.Utilety.GetNextKey(typeof(Ts_Sale_Order_Log));
                                    ts.id_user        = id_user;
                                    ts.id_user_master = id_user_master;
                                    ts.flag_type      = 4;
                                    head.id_create    = id_user;
                                    head.id_edit      = id_user;
                                    param.Clear();
                                    param.Add("head", head);
                                    param.Add("body", bodyQuery);
                                    param.Add("ShoppingInfo", shoppinginfo);
                                    param.Add("Ts", ts);
                                    param.Add("id_user_master", id_user_master);

                                    br = BusinessFactory.ShippingRecord.Add(param);
                                }
                            }
                        }
                    }
                }
                else
                {
                    br.Success = false;
                    br.Message.Add("无可出库的订单!");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                return(Json(br));
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }