Esempio n. 1
0
 public string InsertOrderReturnMaster(OrderReturnMaster q)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"insert into order_return_master(return_id,order_id,vendor_id,return_status,return_note,return_createdate,return_updatedate,return_ipfrom) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}') ;", q.return_id,q.order_id,q.vendor_id,q.return_status,q.return_note,CommonFunction.GetPHPTime(DateTime.Now.ToString()),CommonFunction.GetPHPTime(DateTime.Now.ToString()),q.return_ipfrom);
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("OrderReturnMasterDao.InsertOrderReturnMaster-->" + ex.Message + sql.ToString(), ex);
     }
 }
Esempio n. 2
0
        public string OrderReturn(OrderReturnMasterQuery query)
        { 
            string josn = "";
            List<OrderDetailQuery> orm = new List<OrderDetailQuery>();
            List<OrderDetail> od = new List<OrderDetail>();
            Serial s = new Serial();//流水號
            Serial s1 = new Serial();//流水號
            OrderReturnMaster m = new OrderReturnMaster();
            StringBuilder sb = new StringBuilder();
            ArrayList arrList = new ArrayList();
            string r_id="";
           uint slave=0;
            try
            {
                orm = _orderReturnMaster.GetOrderreturn(query);
                if (orm.Count == 0)
                {//1.判斷detail_id選中的個數,沒有則退出;  查詢該訂單詳細數據,取出需要的字段;
                    return josn = "{success:true,msg:2}";//
                }
                uint a = 1;
                foreach (var item in orm)
                {//同一出貨商的商品放在同一陣列中,成立獨立的退貨單                   
                    if (slave != item.Slave_Id)
                    { //    (1)區分出貨商order_slave.slave_id相同的添加到同一個退貨單中.
                        s =_serial.GetSerialById(45);//獲取退貨流水號
                        s.Serial_Value=s.Serial_Value+ a;
                        m.return_id = uint.Parse(s.Serial_Value.ToString());
                        r_id += m.return_id.ToString() + ",";
                        m.order_id = item.Order_Id;
                        m.vendor_id = item.Vendor_Id;
                        m.return_status = 0;
                        m.return_note = query.return_note;
                        m.return_ipfrom = query.return_ipfrom;
                        //新增退貨單信息
                        arrList.Add(_orderReturnMaster.InsertOrderReturnMaster(m));
                        arrList.Add(_serial.Update(45));//流水號+1
                        slave = item.Slave_Id;
                        //修改訂單的付款狀態
                        arrList.Add(_orderReturnMaster.UpdOrderMaster(item.Order_Id, "5"));
                        //新增訂單狀態變更記錄
                        s1 = _serial.GetSerialById(29);//獲取訂單主檔狀態流水號
                        s1.Serial_Value = s1.Serial_Value + a;
                        arrList.Add(_orderReturnMaster.InsertOrderMasterStatus(s1.Serial_Value, item.Order_Id, "91", "miaoshu"));
                        arrList.Add(_serial.Update(29));//流水號+1
                        a++;
                    }
                    //變更相關訂單細項商品狀態,并新增退貨單細項.判斷是否是組合商品并修改商品狀態.
                    arrList.Add(_orderReturnMaster.InsertOrderReturnDetail(s.Serial_Value.ToString(), item.Detail_Id.ToString()));

                    if (item.item_mode == 1)
                    {//變更組合商品內所有商品狀態,獲取時候是否獲取到整個組合商品
                        od = _orderReturnMaster.Getdetail(item.Slave_Id.ToString(), item.Parent_Id.ToString());
                        foreach (var item1 in od)
                        {
                            arrList.Add(_orderReturnMaster.UpdOrderDetail(item1.Detail_Id.ToString()));
                        }
                    }
                    else 
                    {//不是組合商品就只修改該商品的狀態
                        arrList.Add(_orderReturnMaster.UpdOrderDetail(item.Detail_Id.ToString()));
                    }
                }                
                //10000以上代表拋轉過資料,需重拋轉
                if (_orderReturnMaster.GetExportFlag(m.order_id.ToString())>0)
                {
                    arrList.Add(_orderReturnMaster.UpdExportFlag(m.order_id.ToString()));
                }
                r_id = r_id.Substring(0, r_id.Length - 1);
                //執行sql語句
                if ( _mySqlDao.ExcuteSqlsThrowException(arrList))
                {
                    josn = "{success:true,msg:0,return_id:'"+r_id+"'}";
                }
                else
                {
                    josn = "{success:true,msg:1}";
                }                
                return josn;
            }
            catch (Exception ex)
            {
                throw new Exception("OrderReturnMasterMgr.OrderReturn-->" + ex.Message, ex);
            }
        }