/// <summary> /// 数据赋值 /// </summary> /// <param name="result"></param> /// <param name="trade"></param> private void TradeRefundCopydata(TradeRefund ob, TradeRefund traderefund) { ob.refund_id = traderefund.refund_id; ob.tid = traderefund.tid; ob.oid = traderefund.oid; ob.alipay_no = traderefund.alipay_no; ob.total_fee = traderefund.total_fee; ob.buyer_nick = traderefund.buyer_nick; ob.seller_nick = traderefund.seller_nick; ob.created = traderefund.created; ob.modified = traderefund.modified; ob.order_status = traderefund.order_status; ob.status = traderefund.status; ob.good_status = traderefund.good_status; ob.has_good_return = traderefund.has_good_return; ob.refund_fee = traderefund.refund_fee; ob.payment = traderefund.payment; ob.reason = traderefund.reason; ob.desc = traderefund.desc; ob.iid = traderefund.iid; ob.title = traderefund.title; ob.price = traderefund.price; ob.num = traderefund.num; ob.good_return_time = traderefund.good_return_time; ob.company_name = traderefund.company_name; ob.sid = traderefund.sid; ob.address = traderefund.address; ob.shipping_type = traderefund.shipping_type; ob.refund_remind_timeout = traderefund.refund_remind_timeout; ob.LocalPrivyC = traderefund.LocalPrivyC; ob.IsRecieved = traderefund.IsRecieved; }
public ReturnType RemoveTradeRefund(string traderefundCode) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*List<TradeRefund> list = alading.TradeRefund.Where(p => p.TradeRefundID == traderefundID).ToList();*/ List <TradeRefund> list = alading.TradeRefund.Where(p => p.refund_id == traderefundCode).ToList(); if (list.Count == 0) { return(ReturnType.NotExisted); } else { TradeRefund sy = list.First(); alading.DeleteObject(sy); alading.SaveChanges(); return(ReturnType.Success); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
public ReturnType UpdateTradeRefund(List <TradeRefund> tradeRefundList) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { foreach (TradeRefund tradeRefund in tradeRefundList) { TradeRefund result = alading.TradeRefund.Where(p => p.refund_id == tradeRefund.refund_id).FirstOrDefault(); if (result == null) { return(ReturnType.NotExisted); } TradeRefundCopydata(result, tradeRefund); } alading.SaveChanges(); return(ReturnType.Success); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType AddTradeRefund(TradeRefund traderefund) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { alading.AddToTradeRefund(traderefund); if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.PropertyExisted); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
/// <summary> /// 获取退货单的详细信息并保存到数据库 /// </summary> /// <param name="tradeRefundList"></param> /// <param name="refundIDList"></param> public void GetNewRefundDetail(string session, List <Alading.Entity.TradeRefund> tradeRefundList, List <string> refundIDList) { //存放数据库中不存在的退货详细信息 List <Alading.Entity.TradeRefund> newRefundList = new List <Alading.Entity.TradeRefund>(); List <Alading.Entity.TradeRefund> oldRefundList = TradeRefundService.GetTradeRefund(refundIDList); foreach (Alading.Entity.TradeRefund tradeRefund in tradeRefundList) { Alading.Entity.TradeRefund oldRefund = oldRefundList.Find(c => c.refund_id == tradeRefund.refund_id); if (oldRefund != null)//数据库中已存在此数据 { continue; } else//不存在则取淘宝网获取 { TradeRsp tradeRsp = TopService.RefundGet(session, tradeRefund.refund_id); /*未获取到数据*/ if (tradeRsp == null) { continue; } oldRefund = new TradeRefund(); oldRefund.modified = tradeRefund.modified; oldRefund.order_status = tradeRefund.order_status; TradeRefundCopyData(oldRefund, tradeRsp.Refund); newRefundList.Add(oldRefund); } } TradeRefundService.AddTradeRefund(newRefundList); }
public ReturnType UpdateTradeRefund(List <TradeRefund> tradeRefundList, List <StockProduct> stockProductList, List <StockHouseProduct> houseProList , List <StockInOut> stockInOutList, List <StockDetail> stockDetailList, PayCharge payCharge, List <string> refundIdList , List <string> outerSkuIdList, List <string> outerIdList) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*更新TradeRefund*/ var refundResult = alading.TradeRefund.Where(BuildWhereInExpression <TradeRefund, string>(v => v.refund_id, refundIdList)); if (refundResult == null) { return(ReturnType.NotExisted); } foreach (TradeRefund tradeRefund in tradeRefundList)//需要更新的新数据 { TradeRefund oldRefund = refundResult.Where(c => c.refund_id == tradeRefund.refund_id).FirstOrDefault(); //TradeRefundCopydata(oldRefund, tradeRefund); oldRefund.IsRecieved = tradeRefund.IsRecieved; oldRefund.LocalPrivyC = tradeRefund.LocalPrivyC; } /*更新StockProduct 和 StockItem*/ var stockProductResult = alading.StockProduct.Where(BuildWhereInExpression <StockProduct, string>(v => v.SkuOuterID, outerSkuIdList)); var stockItemResult = alading.StockItem.Where(BuildWhereInExpression <StockItem, string>(v => v.OuterID, outerIdList)); if (stockProductResult == null || stockItemResult == null) { return(ReturnType.NotExisted); } foreach (StockProduct stockProduct in stockProductList) { //获取StockProduct的原始数据 StockProduct oldStockProduct = stockProductResult.Where(c => c.SkuOuterID == stockProduct.SkuOuterID).FirstOrDefault(); //获取StockItem的原始数据 StockItem oldStockItem = stockItemResult.Where(c => c.OuterID == stockProduct.OuterID).FirstOrDefault(); if (oldStockProduct != null && oldStockItem != null) { //获取StockProduct的相关原始数据的商品数量 oldStockProduct.SkuQuantity = oldStockProduct.SkuQuantity + stockProduct.SkuQuantity; //获取oldStockItem的相关原始数据的商品数量 oldStockItem.TotalQuantity = oldStockItem.TotalQuantity + stockProduct.SkuQuantity; } else { return(ReturnType.NotExisted); } } /*添加或更新StockHouseProduct*/ var stockHouseProResult = alading.StockHouseProduct.Where(BuildWhereInExpression <StockHouseProduct, string>(v => v.SkuOuterID, outerSkuIdList)); foreach (StockHouseProduct stockHousePro in houseProList) { StockHouseProduct oldPro = stockHouseProResult.Where(c => c.SkuOuterID == stockHousePro.SkuOuterID && c.HouseCode == stockHousePro.HouseCode && c.LayoutCode == stockHousePro.LayoutCode).FirstOrDefault(); if (oldPro != null) { oldPro.Num += stockHousePro.Num; } else { stockHousePro.HouseProductCode = Guid.NewGuid().ToString(); alading.AddToStockHouseProduct(stockHousePro); } } /*添加StockInOut*/ foreach (StockInOut stockInOut in stockInOutList) { alading.AddToStockInOut(stockInOut); } /*添加StockDetail*/ foreach (StockDetail stockDetail in stockDetailList) { alading.AddToStockDetail(stockDetail); } alading.AddToPayCharge(payCharge); alading.SaveChanges(); return(ReturnType.Success); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType UpdateTradeRefund(string traderefundCode, TradeRefund traderefund) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*var result = alading.TradeRefund.Where(p => p.TradeRefundID == traderefundID).ToList();*/ var result = alading.TradeRefund.Where(p => p.refund_id == traderefundCode).ToList(); if (result.Count == 0) { return(ReturnType.NotExisted); } TradeRefund ob = result.First(); ob.refund_id = traderefund.refund_id; ob.tid = traderefund.tid; ob.oid = traderefund.oid; ob.alipay_no = traderefund.alipay_no; ob.total_fee = traderefund.total_fee; ob.buyer_nick = traderefund.buyer_nick; ob.seller_nick = traderefund.seller_nick; ob.created = traderefund.created; ob.modified = traderefund.modified; ob.order_status = traderefund.order_status; ob.status = traderefund.status; ob.good_status = traderefund.good_status; ob.has_good_return = traderefund.has_good_return; ob.refund_fee = traderefund.refund_fee; ob.payment = traderefund.payment; ob.reason = traderefund.reason; ob.desc = traderefund.desc; ob.iid = traderefund.iid; ob.title = traderefund.title; ob.price = traderefund.price; ob.num = traderefund.num; ob.good_return_time = traderefund.good_return_time; ob.company_name = traderefund.company_name; ob.sid = traderefund.sid; ob.address = traderefund.address; ob.shipping_type = traderefund.shipping_type; ob.refund_remind_timeout = traderefund.refund_remind_timeout; ob.LocalPrivyC = traderefund.LocalPrivyC; ob.IsRecieved = traderefund.IsRecieved; if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.OthersError); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
public ReturnType UpdateTradeRefund(TradeRefund traderefund) { throw new NotImplementedException(); //try //{ // using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) // { // /*TradeRefund result = alading.TradeRefund.Where(p => p.TradeRefundID == traderefund.TradeRefundID).FirstOrDefault();*/ // TradeRefund result = alading.TradeRefund.Where(p => p.refund_id == traderefund.refund_id).FirstOrDefault(); // if (result == null) // { // return ReturnType.NotExisted; // } // #region Using Attach() Function Update,Default USE; // alading.Attach(result); // alading.ApplyPropertyChanges("TradeRefund", traderefund); // #endregion // #region Using All Items Replace To Update ,Default UnUse // /* // result.refund_id = traderefund.refund_id; // result.tid = traderefund.tid; // result.oid = traderefund.oid; // result.alipay_no = traderefund.alipay_no; // result.total_fee = traderefund.total_fee; // result.buyer_nick = traderefund.buyer_nick; // result.seller_nick = traderefund.seller_nick; // result.created = traderefund.created; // result.modified = traderefund.modified; // result.order_status = traderefund.order_status; // result.status = traderefund.status; // result.good_status = traderefund.good_status; // result.has_good_return = traderefund.has_good_return; // result.refund_fee = traderefund.refund_fee; // result.payment = traderefund.payment; // result.reason = traderefund.reason; // result.desc = traderefund.desc; // result.iid = traderefund.iid; // result.title = traderefund.title; // result.price = traderefund.price; // result.num = traderefund.num; // result.good_return_time = traderefund.good_return_time; // result.company_name = traderefund.company_name; // result.sid = traderefund.sid; // result.address = traderefund.address; // result.shipping_type = traderefund.shipping_type; // result.refund_remind_timeout = traderefund.refund_remind_timeout; // result.LocalPrivyC = traderefund.LocalPrivyC; // result.IsRecieved = traderefund.IsRecieved; // */ // #endregion // if (alading.SaveChanges() == 1) // { // return ReturnType.Success; // } // } //} //catch (SqlException sex) //{ // return ReturnType.ConnFailed; //} //catch (Exception ex) //{ // return ReturnType.OthersError; //} }
public static ReturnType UpdateTradeRefund(string traderefundCode, TradeRefund traderefund) { return(DataProviderClass.Instance().UpdateTradeRefund(traderefundCode, traderefund)); }
public static ReturnType AddTradeRefund(TradeRefund traderefund) { return(DataProviderClass.Instance().AddTradeRefund(traderefund)); }
/// <summary> /// 保存操作 /// </summary> public bool SaveRefund() { //出入库时间 if (string.IsNullOrEmpty(dateEditInTime.Text)) { XtraMessageBox.Show("请填写入库日期", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); dateEditInTime.Focus(); return(false); } //业务员及编号 if (string.IsNullOrEmpty(pceOperator.Text)) { XtraMessageBox.Show("请填写业务员", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); pceOperator.Focus(); return(false); } //用于存放需要退货入库的订单的退款单号 List <string> refundIDList = new List <string>(); //用于存放oid,以通过View_RefundTradeStock获取sku_outerID List <string> oidList = new List <string>(); //存放修要修改库存的sku_outer_id List <string> outerSkuIdList = new List <string>(); //存放修要修改库存的outer_id List <string> outerIdList = new List <string>(); //用于存放需要更新的StockProduct数据 List <StockProduct> stockProductList = new List <StockProduct>(); //用于存放要保存到数据库的StockHouseProduct List <Alading.Entity.StockHouseProduct> stockHouseProList = new List <StockHouseProduct>(); //存放StockDetail List <Alading.Entity.StockDetail> stockDetailList = new List <Alading.Entity.StockDetail>(); //入库单编号 string inOutCode = string.Empty; if (!string.IsNullOrEmpty(textEditInOutCode.Text)) { inOutCode = textEditInOutCode.Text.Trim(); if (inoutHelper.ExistInOutCode(inOutCode)) { XtraMessageBox.Show("此单号已存在", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textEditInOutCode.Focus(); return(false); } } else { inOutCode = Guid.NewGuid().ToString(); } for (int index = 0; index < gvReturnInProduct.RowCount; index++) { DataRow dataRow = gvReturnInProduct.GetDataRow(index); if (dataRow["Select"].ToString() == true.ToString()) { if (dataRow["HouseName"] == null || string.IsNullOrEmpty(dataRow["HouseName"].ToString())) { XtraMessageBox.Show("需要选择仓库", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (dataRow["LayoutName"] == null || string.IsNullOrEmpty(dataRow["LayoutName"].ToString())) { XtraMessageBox.Show("需要选择库位", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } refundIDList.Add(dataRow["refund_id"].ToString()); oidList.Add(dataRow["oid"].ToString()); #region 保存StockProduct信息 outerSkuIdList.Add(dataRow["outer_sku_id"].ToString()); outerIdList.Add(dataRow["OuterID"].ToString()); StockProduct newStockPro = new StockProduct(); newStockPro.SkuOuterID = dataRow["outer_sku_id"].ToString(); newStockPro.OuterID = dataRow["OuterID"].ToString(); //入库数量 if (string.IsNullOrEmpty(dataRow["Count"].ToString())) { newStockPro.SkuQuantity = 0; } else { newStockPro.SkuQuantity = int.Parse(dataRow["Count"].ToString()); } stockProductList.Add(newStockPro); #endregion #region 添加或更新StockHouseProduct StockHouseProduct stockHousePro = new StockHouseProduct(); stockHousePro.HouseCode = dataRow["HouseCode"] == null ? string.Empty : dataRow["HouseCode"].ToString(); stockHousePro.LayoutCode = dataRow["LayoutCode"] == null ? string.Empty : dataRow["LayoutCode"].ToString(); stockHousePro.SkuOuterID = newStockPro.SkuOuterID; stockHousePro.Num = newStockPro.SkuQuantity; stockHousePro.HouseName = dataRow["HouseName"].ToString(); stockHousePro.LayoutName = dataRow["LayoutName"].ToString(); stockHouseProList.Add(stockHousePro); #endregion #region 保存StockDetail Alading.Entity.StockDetail stockDetail = new StockDetail(); stockDetail.StockDetailCode = Guid.NewGuid().ToString(); stockDetail.ProductSkuOuterId = dataRow["outer_sku_id"].ToString(); stockDetail.InOutCode = inOutCode; //仓库编号 if (dataRow["HouseCode"] == null) { stockDetail.StockHouseCode = string.Empty; } else { stockDetail.StockHouseCode = dataRow["HouseCode"].ToString(); } //库位编号 if (dataRow["LayoutCode"] == null) { stockDetail.StockLayOutCode = string.Empty; } else { stockDetail.StockLayOutCode = dataRow["LayoutCode"].ToString(); } //商品价格price stockDetail.Price = float.Parse(dataRow["price"].ToString()); stockDetail.Quantity = int.Parse(dataRow["Count"].ToString()); stockDetail.DetailType = (int)InOutType.SelledReturnIn; stockDetail.DetailRemark = string.Empty; stockDetail.Tax = string.Empty; stockDetail.TotalFee = dataRow["payment"] == null?0:float.Parse(dataRow["payment"].ToString()); stockDetail.DurabilityDate = DateTime.Parse(DateTime.Now.ToShortDateString()); stockDetailList.Add(stockDetail); #endregion } } if (refundIDList.Count == 0) { XtraMessageBox.Show("请先勾选数据", "系统提示", MessageBoxButtons.OK , MessageBoxIcon.Information); return(false); } /*销售退货时间,仓库,库位要求必须填写*/ #region 将要更新的数据保存到oldRefundList List <Alading.Entity.TradeRefund> oldRefundList = TradeRefundService.GetTradeRefund(refundIDList); //用于保存等待更新到数据库表TradeRefund的数据 List <Alading.Entity.TradeRefund> refundUpdateList = new List <Alading.Entity.TradeRefund>(); //修改StockRefund中的IsRecieved 和 LocalPrivyC的状态 foreach (string refundId in refundIDList) { Alading.Entity.TradeRefund refund = new TradeRefund(); refund.refund_id = refundId; //记录当前库管是否收到从买家发回的货物 refund.IsRecieved = true; //经办人 refund.LocalPrivyC = pceOperator.Text; refundUpdateList.Add(refund); } #endregion #region 更新StockInOut string InOutTime = dateEditInTime.Text; //用于存放StockInOut List <Alading.Entity.StockInOut> stockInOutList = new List <Alading.Entity.StockInOut>(); //添加到StockInOut Alading.Entity.StockInOut stockInOut = new Alading.Entity.StockInOut(); stockInOut.InOutCode = inOutCode; //进出库单编号 stockInOut.InOutTime = DateTime.Parse(InOutTime); //进出库时间 stockInOut.OperatorName = pceOperator.Text == null ? string.Empty : pceOperator.Text; stockInOut.OperatorCode = pceOperator.Tag.ToString(); stockInOut.InOutType = (int)InOutType.SelledReturnIn; //oid赋值 stockInOut.TradeOrderCode = string.Empty;; stockInOut.DiscountFee = 0; //保存应付应收金额 if (string.IsNullOrEmpty(textEditTotalFee.EditValue.ToString())) { stockInOut.DueFee = 0; } else { stockInOut.DueFee = float.Parse(textEditTotalFee.EditValue.ToString()); } stockInOut.InOutStatus = (int)InOutStatus.AllRefund; stockInOut.IsSettled = true; stockInOut.PayType = 0;//付款方式 stockInOut.PayThisTime = string.IsNullOrEmpty(textEditTotalFee.EditValue.ToString()) ? 0 : float.Parse(textEditTotalFee.EditValue.ToString()); stockInOut.PayTerm = 0; stockInOut.IncomeTime = DateTime.Parse(DateTime.Now.ToShortDateString());; stockInOut.AmountTax = 0; stockInOut.FreightCompany = string.Empty; stockInOut.FreightCode = string.Empty; stockInOutList.Add(stockInOut); #endregion #region 添加PayCharge PayCharge payCharge = new PayCharge(); payCharge.PayChargeCode = Guid.NewGuid().ToString(); payCharge.PayChargeType = 0; payCharge.InOutCode = inOutCode; payCharge.PayerCode = string.Empty; payCharge.PayerName = string.Empty; payCharge.ChargerCode = string.Empty; payCharge.ChargerName = string.Empty; payCharge.OperateTime = DateTime.Parse(dateEditInTime.Text); payCharge.OperatorCode = pceOperator.Tag.ToString(); payCharge.OperatorName = pceOperator.Text; payCharge.PayChargeRemark = string.Empty; if (!string.IsNullOrEmpty(textEditTotalFee.Text)) { payCharge.TotalFee = double.Parse(textEditTotalFee.EditValue.ToString()); } else { payCharge.TotalFee = 0.0; } payCharge.NeedToPay = 0.0; payCharge.AmountTax = 0.0; payCharge.PayThisTime = payCharge.TotalFee; payCharge.DiscountFee = 0.0; payCharge.IncomeDay = 0; payCharge.IncomeTime = DateTime.MinValue; #endregion //更新Refund StockProduct StockItem StockInOut StockDetail TradeRefundService.UpdateTradeRefund(refundUpdateList, stockProductList, stockHouseProList, stockInOutList, stockDetailList , payCharge, refundIDList, outerSkuIdList, outerIdList); return(true); }