public Tuple<bool, string> OrderRefundOpe(string type, Dictionary<string, string> dicPar, Func<string, string, string, string, string> _func) { //Init string id = dicPar["RefundID"]; string orderID = dicPar["OrderID"]; string state = string.Empty; //DAL AdminOrderDAL orderDal = new AdminOrderDAL(); //Result bool flag = false; string strMsg = string.Empty; switch (type) { case "success": //成功 state = "7"; string refundState = "1"; //同意申请 string orderNum = dicPar["OrderNum"]; string refundPrice = dicPar["RefundPrice"]; string totalPrice = dicPar["TotalPrice"]; float fPriceNa = float.Parse(refundPrice) * 100; float fPriceNb = float.Parse(totalPrice) * 100; try { //微信退款接口 strMsg = _func(string.Empty, orderNum, fPriceNb.ToString(), fPriceNa.ToString()); dynamic resultDnm = JsonConvert.DeserializeObject<dynamic>(strMsg); //本地数据库 if (resultDnm.result_code == "SUCCESS") { flag = orderDal.OrderRefundOpe(orderID, state, id, refundState); } else { flag = false; strMsg = "数据操作失败!请重新操作!"; } } catch (Exception e) { strMsg = e.Message; flag = false; } break; case "refused": //失败 state = "3"; refundState = "2"; //拒绝申请 flag = orderDal.OrderRefundOpe(orderID, state, id, refundState); strMsg = flag ? "拒绝退款请求成功!" : "拒绝退款请求失败!请重新操作!"; break; default: break; } return new Tuple<bool, string>(flag, strMsg); }
/// <summary> /// 填写快递单号实现业务逻辑方法 /// </summary> /// <param name="orderNum"></param> /// <param name="expCode"></param> /// <param name="expNum"></param> /// <param name="expType"></param> /// <returns></returns> public bool WriteExpressOpe(string orderNum, string expCode, string expNum, string expType) { //Result bool flag = false; //DAL WX_ZZSCOrderExpressDAL dal = new WX_ZZSCOrderExpressDAL(); //Query WX_ZZSCOrderExpressInfo info = dal.Query<WX_ZZSCOrderExpressInfo>(" OrderNum = @OrderNum ", new { OrderNum = orderNum }).FirstOrDefault(); if (info != null) { info.ExpressCode = expCode; info.ExpressNum = expNum; info.ExpressType = expType; info.State = 1; //已发货 info.Flag = 1; //已生效 info.NowState = 1; //已发货 List<string> listSql = new List<string>(); List<object> listPar = new List<object>(); //Update listSql.Add(dal.UpdateSQL()); listPar.Add(info); //填写快递单号后:BeOrder + Order表更新状态 AdminOrderDAL adminDal = new AdminOrderDAL(); listSql.Add(adminDal.OrderLogisticsStateOpeSQL()); listPar.Add(new { OrderNum = info.OrderNum, LogisticsState = 1 }); flag = dal.ExecuteTran(listSql, listPar); } return flag; }
/// <summary> /// 查询订单列表 /// </summary> /// <returns></returns> public IEnumerable<dynamic> Main_QuerySaleslist(int state, string startdate, string enddate, int index, int size) { //Init bool isPay = state > 4; //是否付完款 bool isLogistics = state >= 30; //是否具有物流信息 int orderState = isLogistics ? 3 : state; //订单状态 int logisticsState = state - 30; //物流状态 string tblName = isPay ? "scorder" : "beorder"; //Init SQL WHERE string sql = "1=1"; if (state != -1) { sql += string.Format(" AND {0}.OrderState=@State", tblName); } if (isLogistics) { sql += string.Format(" AND {0}.LogisticsState=@LogisticsState ", tblName); } if (!string.IsNullOrEmpty(startdate) && !string.IsNullOrEmpty(enddate)) { sql += string.Format(" AND {0}.OpeDate BETWEEN @startdate AND @enddate", tblName); } sql += string.Format(" Order by {0}.OpeDate", tblName); //Result IEnumerable<dynamic> result = null; //Operator switch (orderState) { case -1: //全部订单 //调用 result = new AdminOrderDAL().Query_AllOrder(index, size, sql, new { State = orderState, LogisticsState = logisticsState, startdate = startdate, enddate = enddate }); break; case 1: //未付款 result = new AdminOrderDAL().Query_BeOrder(index, size, sql, new { State = orderState, LogisticsState = logisticsState, startdate = startdate, enddate = enddate }); break; case 4: //已关闭 result = new AdminOrderDAL().Query_BeOrder(index, size, sql, new { State = orderState, LogisticsState = logisticsState, startdate = startdate, enddate = enddate }); break; default: //其余:为已付款订单 result = new AdminOrderDAL().Query_Order(index, size, sql, new { State = orderState, LogisticsState = logisticsState, startdate = startdate, enddate = enddate }); break; } return result; }