/// <summary> /// 获取推送类型 /// </summary> /// <returns></returns> public static string GetWXType(string sendType, string userID, string orderID) { string res = string.Empty; decimal num = 0; string orderInfo = string.Empty; string orderOut = String.Empty; Hi.Model.DIS_OrderOut outModel = null; Hi.Model.DIS_OrderReturn returnModel = null; List <Hi.Model.DIS_Logistics> list_log = null; Hi.Model.DIS_Logistics log = null; Hi.BLL.DIS_Logistics bll_log = new Hi.BLL.DIS_Logistics(); Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(userID)); if (user == null || string.IsNullOrEmpty(user.OpenID)) { return(""); } Hi.Model.DIS_Order order = new Hi.BLL.DIS_Order().GetModel(int.Parse(orderID)); if (order == null) { return(""); } List <Hi.Model.DIS_OrderDetail> orderList = new Hi.BLL.DIS_OrderDetail().GetList("", " orderID=" + int.Parse(orderID), ""); if (orderList == null || orderList.Count == 0) { return(""); } foreach (Hi.Model.DIS_OrderDetail detail in orderList) { Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID); if (goodsInfo != null) { Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID); orderInfo += " " + goods.GoodsName + "*" + detail.GoodsNum; } num += detail.GoodsNum; } Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(order.AddrID); if (addr != null) { if (addr.Phone != "") { orderOut += addr.Principal + ":" + addr.Phone + " "; } else { orderOut += addr.Principal + ":" + addr.Tel + " "; } } List <Hi.Model.DIS_OrderOut> orderout = new Hi.BLL.DIS_OrderOut().GetList("", " orderID=" + int.Parse(orderID), ""); if (orderout != null && orderout.Count != 0) { foreach (Hi.Model.DIS_OrderOut detail in orderout) { list_log = bll_log.GetList("", "OrderOutID = " + detail.ID + " and isnull(dr,0) == 0", ""); if (list_log != null && list_log.Count >= 0) { log = list_log[0]; //orderOut += log.ExpressPerson + ":" + log.ExpressTel + " "; } outModel = detail; } } List <Hi.Model.DIS_OrderReturn> returnlist = new Hi.BLL.DIS_OrderReturn().GetList("", " orderID=" + int.Parse(orderID), ""); if (returnlist != null && returnlist.Count != 0) { foreach (Hi.Model.DIS_OrderReturn detail in returnlist) { returnModel = detail; } } //string sqlstr = string.Format("select * from dis_order where receiptno like ('%{0}%') and dr=0", ReceiptNo); switch (sendType) { case "1": //下单通知 StringBuilder strSql = new StringBuilder(); strSql.Append("{\"type\":\"ORDERADD\",\"openid\":\""); strSql.Append(user.OpenID); strSql.Append("\",\"msg\":[{\"title\":\"尊敬的"); strSql.Append(user.TrueName); strSql.Append(",您好\",\"orderno\":\""); strSql.Append(order.ReceiptNo); strSql.Append("\",\"orderamount\":\""); strSql.Append(order.TotalAmount.ToString("N")); strSql.Append("元\",\"extra1\":\"状态:待付款\",\"extra2\":\"数量:"); strSql.Append(num.ToString("0.00")); strSql.Append("\",\"remark\":\""); strSql.Append(order.Remark); strSql.Append("\"}]}"); res = strSql.ToString(); break; case "2": //订单支付通知 StringBuilder str = new StringBuilder(); str.Append("{\"type\":\"ORDERPAY\",\"openid\":\""); str.Append(user.OpenID); str.Append("\",\"msg\":[{\"title\":\"尊敬的"); str.Append(user.TrueName); str.Append(",您好\",\"orderpay\":\""); str.Append(order.TotalAmount.ToString("N")); str.Append("元\",\"orderinfo\":\""); str.Append(orderInfo); str.Append("\",\"receiveinfo\":\""); str.Append(orderOut); str.Append("\",\"orderno\":\""); str.Append(order.ReceiptNo); str.Append("\",\"remark\":\""); str.Append("\"}]}"); res = str.ToString(); break; case "3": //42、签收提醒 StringBuilder SIGN = new StringBuilder(); SIGN.Append("{\"type\":\"SIGN\",\"openid\":\""); SIGN.Append(user.OpenID); SIGN.Append("\",\"msg\":[{\"title\":\"您好,您的订单"); SIGN.Append(order.ReceiptNo); SIGN.Append("已签收\",\"orderno\":\""); SIGN.Append(order.ReceiptNo); SIGN.Append("\",\"qianshouren\":\""); SIGN.Append(outModel.SignUser); SIGN.Append("\",\"qianshoushijian\":\""); SIGN.Append(outModel.SignDate); SIGN.Append("\",\"remark\":\""); SIGN.Append(order.Remark); SIGN.Append("\"}]}"); res = SIGN.ToString(); break; case "4": //退货申请 StringBuilder RETGOODS = new StringBuilder(); RETGOODS.Append("{\"type\":\"RETGOODS\",\"openid\":\""); RETGOODS.Append(user.OpenID); RETGOODS.Append("\",\"msg\":[{\"title\":\"买家申请退货"); RETGOODS.Append("\",\"orderno\":\""); RETGOODS.Append(order.ReceiptNo); RETGOODS.Append("\",\"shangpinxinxi\":\""); RETGOODS.Append(orderInfo); RETGOODS.Append("\",\"orderjine\":\""); RETGOODS.Append(order.TotalAmount.ToString("N")); RETGOODS.Append("元\",\"remark\":\""); RETGOODS.Append(order.Remark); RETGOODS.Append("\"}]}"); res = RETGOODS.ToString(); break; case "41": //代人下单通知 StringBuilder ORDERADD = new StringBuilder(); ORDERADD.Append("{\"type\":\"ORDERADD\",\"openid\":\""); ORDERADD.Append(user.OpenID); ORDERADD.Append("\",\"msg\":[{\"title\":\"尊敬的"); ORDERADD.Append(user.TrueName); ORDERADD.Append(",您好\",\"orderno\":\""); ORDERADD.Append(order.ReceiptNo); ORDERADD.Append("\",\"orderamount\":\""); ORDERADD.Append(order.TotalAmount.ToString("N")); ORDERADD.Append("元\",\"extra1\":\"状态:待付款\",\"extra2\":\"数量:"); ORDERADD.Append(num.ToString()); ORDERADD.Append("\",\"remark\":\""); ORDERADD.Append(order.Remark); ORDERADD.Append("\"}]}"); res = ORDERADD.ToString(); break; case "42": //订单审批 StringBuilder sql = new StringBuilder(); sql.Append("{\"type\":\"ORDERSTATUS\",\"openid\":\""); sql.Append(user.OpenID); sql.Append("\",\"msg\":[{\"title\":\"尊敬的"); sql.Append(user.TrueName); sql.Append(",您好\",\"orderno\":\""); sql.Append(order.ReceiptNo); if (order.OState.ToString() == "-1") { sql.Append("\",\"orderstatus\":\"订单退回\",\"remark\":\""); } else { sql.Append("\",\"orderstatus\":\"待发货、审批通过\",\"remark\":\""); } sql.Append(order.Remark); sql.Append("\"}]}"); res = sql.ToString(); break; case "43": //订单发货 StringBuilder sqlSend = new StringBuilder(); sqlSend.Append("{\"type\":\"ORDERSEND\",\"openid\":\""); sqlSend.Append(user.OpenID); sqlSend.Append("\",\"msg\":[{\"title\":\"尊敬的"); sqlSend.Append(user.TrueName); sqlSend.Append(",您好\",\"orderno\":\""); sqlSend.Append(order.ReceiptNo); sqlSend.Append("\",\"wuliuname\":\""); sqlSend.Append(log.ComPName); sqlSend.Append("\",\"wuliucode\":\""); sqlSend.Append(log.LogisticsNo); sqlSend.Append("\",\"remark\":\""); sqlSend.Append(outModel.Remark); sqlSend.Append("\"}]}"); res = sqlSend.ToString(); break; case "44": //6、退货审核 StringBuilder RETAUDIT = new StringBuilder(); RETAUDIT.Append("{\"type\":\"RETAUDIT\",\"openid\":\""); RETAUDIT.Append(user.OpenID); RETAUDIT.Append("\",\"msg\":[{\"title\":\"您好,您的退货审核"); if (returnModel.ReturnState == -1) { RETAUDIT.Append("已退回"); } else { RETAUDIT.Append("已审核"); } RETAUDIT.Append("\",\"shenhejieguo\":\""); if (returnModel.ReturnState == -1) { RETAUDIT.Append("已退回"); } else { RETAUDIT.Append("已审核"); } RETAUDIT.Append("\",\"shangpinxinxi\":\""); RETAUDIT.Append(orderInfo); RETAUDIT.Append("\",\"tuihuojine\":\""); RETAUDIT.Append(order.PayedAmount.ToString("N")); RETAUDIT.Append("元\",\"shenheshuoming\":\""); RETAUDIT.Append(returnModel.AuditRemark); RETAUDIT.Append("\",\"shenheshijian\":\""); RETAUDIT.Append(returnModel.AuditDate); RETAUDIT.Append("\",\"orderno\":\""); RETAUDIT.Append(order.ReceiptNo); RETAUDIT.Append("\",\"remark\":\""); RETAUDIT.Append("\"}]}"); res = RETAUDIT.ToString(); break; case "45": //5、退款 StringBuilder REFUND = new StringBuilder(); REFUND.Append("{\"type\":\"REFUND\",\"openid\":\""); REFUND.Append(user.OpenID); REFUND.Append("\",\"msg\":[{\"title\":\"您好,您的订单"); REFUND.Append(order.ReceiptNo); REFUND.Append(",已退款。\",\"reason\":\""); REFUND.Append(returnModel.ReturnContent); REFUND.Append("\",\"refund\":\""); REFUND.Append(order.PayedAmount.ToString("N")); REFUND.Append("元\",\"orderno\":\""); REFUND.Append(order.ReceiptNo); REFUND.Append("\",\"remark\":\""); REFUND.Append("\"}]}"); res = REFUND.ToString(); break; } return(res); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.DIS_Logistics model) { return(dal.Update(model)); }
/// <summary> /// 应收应付账款订单列表 /// </summary> /// <param name="JSon"></param> /// <returns></returns> public DIS_Order.ResultOrderList GetDisAccountInfo(string JSon) { try { string strWhere = " and Ostate in (2,4,5) and PayState in (0,1)"; #region JSon取值 string userID = string.Empty; string disID = string.Empty; string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1 string getType = string.Empty; //方向 string rows = string.Empty; string sortType = string.Empty; string sort = string.Empty; string orderType = string.Empty;//单据类型 1:订单 2:账单 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" && JInfo["CriticalOrderID"].ToString() != "" && JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" && JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "" && JInfo["orderType"].ToString() != "") { userID = JInfo["UserID"].ToString(); disID = JInfo["ResellerID"].ToString(); strWhere += " and DisID='" + disID + "' and ISNULL(dr,0)=0"; criticalOrderID = JInfo["CriticalOrderID"].ToString(); getType = JInfo["GetType"].ToString(); rows = JInfo["Rows"].ToString(); sortType = JInfo["SortType"].ToString(); sort = JInfo["Sort"].ToString(); orderType = JInfo["orderType"].ToString(); } else { return(new DIS_Order.ResultOrderList() { Result = "F", Description = "参数异常" }); } if (orderType == "1")//订单 { strWhere += " and ISNULL(dr,0)=0 and OState != 0 and Otype!=9"; } else//账单 { strWhere += " and ISNULL(dr,0)=0 and OState != 0 and Otype=9"; } JsonData JMsg = JInfo["Search"]; if (JMsg.Count > 0) { if (JMsg["OrderID"].ToString() != "") { strWhere += " and ReceiptNo like '" + JMsg["OrderID"].ToString() + "%'"; } if (JMsg["BeginDate"].ToString() != "") { strWhere += " and CreateDate >= '" + Convert.ToDateTime(JMsg["BeginDate"].ToString()) + "'"; } if (JMsg["EndDate"].ToString() != "") { strWhere += " and CreateDate < " + Convert.ToDateTime(JInfo["EndDate"].ToString()).AddDays(1) + "'"; } //根据出库单编号 锁定 订单ID if (JMsg["ExpressNo"].ToString() != "") { //strWhere += " and ReceiptNo like '" + JMsg["ExpressNo"].ToString() + "%'"; List <Hi.Model.DIS_OrderOut> orderOut = new Hi.BLL.DIS_OrderOut().GetList("", " ExpressNo like '%" + JMsg["ExpressNo"].ToString() + "%'", ""); if (orderOut.Count == 0) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "参数异常" } } ; strWhere += " and ID in ( 0"; strWhere = orderOut.Aggregate(strWhere, (current, aout) => current + ("," + aout.OrderID)); strWhere += " )"; } } #endregion #region 模拟分页 string tabName = " [dbo].[DIS_Order]"; //表名 string strsql = string.Empty; //搜索sql sortType = "ID"; strsql = new Common().PageSqlString(criticalOrderID, "ID", tabName, sortType, sort, strWhere, getType, rows); if (strsql == "") { return new DIS_Order.ResultOrderList() { Result = "F", Description = "基础数据异常" } } ; #endregion #region 赋值 string SKUName = string.Empty; List <DIS_Order.Order> OrderList = new List <DIS_Order.Order>(); DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql); if (ds.Tables.Count == 0) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "没有更多数据" } } ; DataTable orderList = ds.Tables[0]; if (orderList != null) { if (orderList.Rows.Count == 0) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "没有更多数据" } } ; foreach (DataRow row in orderList.Rows) { DIS_Order.Order order = new DIS_Order.Order(); Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(int.Parse(row["ID"].ToString())); order.OrderID = orderModel.ID.ToString(); order.CompID = orderModel.CompID.ToString(); Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(orderModel.CompID); if (comp == null || comp.IsEnabled == 0 || comp.dr == 1) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "企业异常" } } ; order.CompName = comp.CompName; order.State = Common.GetDisOrderType(orderModel.OState, orderModel.PayState, orderModel.Otype, orderModel.ReturnState); order.OState = orderModel.OState.ToString(); order.AddType = orderModel.AddType.ToString(); order.Otype = orderModel.Otype.ToString(); order.PayState = orderModel.PayState.ToString(); order.ReturnState = orderModel.ReturnState.ToString(); order.DisID = orderModel.DisID.ToString(); Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(orderModel.DisID); if (dis == null || dis.IsEnabled == 0 || dis.dr == 1) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "经销信息商异常" } } ; order.DisName = dis.DisName; order.DisUserID = orderModel.DisUserID.ToString(); Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(userID)); if (user == null || user.IsEnabled == 0 || user.dr == 1) { return new DIS_Order.ResultOrderList() { Result = "F", Description = "经销商用户信息异常" } } ; order.DisUserName = user.TrueName; order.AddrID = orderModel.AddrID.ToString(); order.ReceiptNo = orderModel.ReceiptNo; order.ArriveDate = orderModel.ArriveDate.ToString(); if (!string.IsNullOrEmpty(orderModel.AddrID.ToString())) { Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(orderModel.AddrID); if (addr != null) { order.Zip = addr.Zip; } } order.Address = orderModel.Address; order.Contact = orderModel.Principal; order.Phone = orderModel.Phone; order.TotalAmount = orderModel.TotalAmount.ToString("0.00"); order.AuditTotalAmount = orderModel.AuditAmount.ToString("0.00"); order.PayedAmount = orderModel.PayedAmount.ToString("0.00"); order.CreateUserID = orderModel.CreateUserID.ToString(); order.CreateDate = orderModel.CreateDate.ToString(); order.ReturnMoneyDate = orderModel.ReturnMoneyDate.ToString(); order.ReturnMoneyUser = orderModel.ReturnMoneyUser.ToString(); order.ReturnMoneyUserId = orderModel.ReturnMoneyUserId.ToString(); List <Hi.Model.DIS_OrderOut> outList = new Hi.BLL.DIS_OrderOut().GetList("", " OrderID='" + orderModel.ID + "' and CompID='" + orderModel.CompID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (outList.Count != 0) { Hi.Model.DIS_OrderOut orderOut = new Hi.Model.DIS_OrderOut(); foreach (Hi.Model.DIS_OrderOut Out in outList) { orderOut = Out; } order.SendID = orderOut.ID.ToString(); order.SendDate = orderOut.SendDate.ToString(); //根据发货单取对应的物流信息 List <Hi.Model.DIS_Logistics> list_log = new Hi.BLL.DIS_Logistics().GetList("", "OrderOutID = " + orderOut.ID + " and isnull(dr,0) = 0", ""); //一个发货单只有一条物流信息,所以list_log里也只有一条数据 Hi.Model.DIS_Logistics model_log = list_log[0]; order.Express = Convert.ToString(model_log.ComPName); order.ExpressNo = Convert.ToString(model_log.LogisticsNo); //order.ExpressPerson = Convert.ToString(orderOut.ExpressPerson); //order.ExpressTel = Convert.ToString(orderOut.ExpressTel); //order.ExpressBao =Convert.ToString(orderOut.ExpressBao); order.PostFee = orderModel.PostFee.ToString("0.00"); order.ActionUser = Convert.ToString(orderOut.ActionUser); order.SendRemark = Convert.ToString(orderOut.Remark); order.IsAudit = Convert.ToString(orderOut.IsAudit); order.AuditUserID = Convert.ToString(orderOut.AuditUserID); order.AuditDate = Convert.ToString(orderOut.AuditDate); order.AuditRemark = orderOut.AuditRemark == null ? "" : orderOut.AuditRemark.ToString(); order.SignDate = Convert.ToString(orderOut.SignDate); order.IsSign = Convert.ToString(orderOut.IsSign); order.SignUserId = Convert.ToString(orderOut.SignUserId); order.SignUser = Convert.ToString(orderOut.SignUser); order.SignRemark = Convert.ToString(orderOut.SignRemark); } order.SendRemark = Convert.ToString(orderModel.Remark); //todo:不知道的排序 //order.SortIndex = orderModel.SortIndex.ToString(); order.IsDel = Convert.ToString(orderModel.dr); //明细 List <DIS_Order.OrderDetail> orderDetail = new List <DIS_Order.OrderDetail>(); List <Hi.Model.DIS_OrderDetail> detailList = new Hi.BLL.DIS_OrderDetail().GetList("", " OrderID='" + orderModel.ID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (detailList == null) //|| detailList.Count==0 没有明细的单 PC可以新建 { return new DIS_Order.ResultOrderList() { Result = "F", Description = "订单明细异常" } } ; List <Hi.Model.BD_GoodsAttrs> list_attrs = null; foreach (Hi.Model.DIS_OrderDetail detail in detailList) { DIS_Order.OrderDetail ordetail = new DIS_Order.OrderDetail(); ordetail.SKUID = detail.GoodsinfoID.ToString(); //通过GoodsInfoID找到GoodsID Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID); if (goodsInfo == null) { //if (goodsInfo == null || goodsInfo.IsEnabled == false || goodsInfo.dr == 1) return new DIS_Order.ResultOrderList() { Result = "F", Description = "SKU信息异常" } } ; ordetail.ProductID = goodsInfo.GoodsID.ToString(); //通过GoodsID找到GoodsName Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID); if (goods == null) { //if (goods == null || goods.IsEnabled == 0 || goods.dr == 1) return new DIS_Order.ResultOrderList() { Result = "F", Description = "商品异常" } } ; ordetail.ProductName = goods.GoodsName; SKUName += goods.GoodsName; list_attrs = new Hi.BLL.BD_GoodsAttrs().GetList("AttrsName", "GoodsID = " + goodsInfo.GoodsID + " and CompID = " + comp.ID + " and ISNULL(dr,0) = 0", ""); if (list_attrs != null && list_attrs.Count != 0) { foreach (Hi.Model.BD_GoodsAttrs attr in list_attrs) { SKUName += attr.AttrsName; } } ordetail.SKUName = SKUName; //todo:描述是什么 ordetail.ValueInfo = goodsInfo.ValueInfo; ordetail.SalePrice = detail.Price.ToString("0.00"); ordetail.TinkerPrice = detail.AuditAmount.ToString("0.00"); ordetail.Num = detail.GoodsNum.ToString("0.00"); ordetail.Remark = detail.Remark; List <DIS_Order.Pic> Pic = new List <DIS_Order.Pic>(); if (goods.Pic.ToString() != "" && goods.Pic.ToString() != "X") { DIS_Order.Pic pic = new DIS_Order.Pic(); pic.ProductID = goodsInfo.GoodsID.ToString(); pic.IsDeafult = "1"; pic.PicUrl = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" + goods.Pic; Pic.Add(pic); } ordetail.ProductPicUrlList = Pic; orderDetail.Add(ordetail); } order.OrderDetailList = orderDetail; OrderList.Add(order); } } else { return(new DIS_Order.ResultOrderList() { Result = "F", Description = "没有更多数据" }); } #endregion return(new DIS_Order.ResultOrderList() { Result = "T", Description = "获取成功", OrderList = OrderList }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetDisAccountInfo:" + JSon); return(new DIS_Order.ResultOrderList() { Result = "F", Description = "参数异常" }); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.DIS_Logistics model) { return(dal.Add(model)); }