public ActionResult OrderDetail(string ordernum) { VIEW_TG_order order = new VIEW_TG_order() { orderNum = CommonMethod.GetOrderNum(), trade_type = "ONLINE", orderTime = DateTime.Now, ThingNum = CommonMethod.GetCode(18) }; ViewBag.ReturnUrl = Request["returnurl"]; ViewBag.TYPE = "Update"; if (string.IsNullOrEmpty(ordernum)) { ViewBag.TYPE = "Add"; var list = sys_userlogin.LoadListBy(su => su.LOGIN_ID == OperateContext.Current.UsrId).Select(su => su.SLSORG_CD); ViewBag.MEMBERS = DataSelect.ToListViewModel(VIEW_YX_weiUser.ToListViewModel(userB.GetListBy(u => list.Contains(u.TREE_NODE_ID) && u.isfenxiao != 0, u => u.userRelname))); ViewBag.COMPANYS = DataSelect.ToListViewModel(VIEW_MST_SUPPLIER.ToListViewModel(supplierB.GetListBy(u => list.Contains(u.TREE_NODE_ID) && u.SYNCOPERATION != "D", u => u.SUPPLIER_ID))); } var model = orderB.Get(o => o.orderNum == ordernum); if (model != null) { order = VIEW_TG_order.ToViewModel(model); ViewBag.Things = VIEW_TG_Thing.ToListViewModel(thingB.GetListBy(t => t.orderNum == ordernum, t => t.createTim, false)); } return(View(order)); }
public ActionResult Add(VIEW_TG_order model) { bool status = false; if (!ModelState.IsValid) { return(this.JsonFormat(ModelState, status, "ERROR")); } if (model.total_fee <= 0) { return(this.JsonFormat("SYSERROR", status, "订单的金额不正确")); } try { var user = userB.Get(u => u.userNum == model.UserId); if (user != null) { model.userName = user.userRelname; model.userOpenId = user.openid; model.UserTel = user.userTel; } var supplierid = TypeParser.ToInt32(model.remark3); var company = supplierB.Get(u => u.SUPPLIER_ID == supplierid); if (company != null) { model.remark2 = company.SUPPLIER_NAME; model.UserAddress = company.ADDRESS; } List <VIEW_TG_Thing> things = new List <VIEW_TG_Thing>(); string[] productID = Request.Form.GetValues("productID"); string[] productName = Request.Form.GetValues("productName"); string[] productCount = Request.Form.GetValues("productCount"); string[] productPrice = Request.Form.GetValues("productPrice"); string[] productMoney = Request.Form.GetValues("productMoney"); if (productID != null) { for (int i = 0; i < productID.Length; i++) { VIEW_TG_Thing item = new VIEW_TG_Thing(); item.orderNum = model.orderNum; item.ispay = model.ispay; item.ThingNum = model.ThingNum; item.UserId = model.UserId; item.openId = model.userOpenId; item.productId = productID[i]; item.remark1 = productName[i]; item.productCount = TypeParser.ToInt32(productCount[i]); item.productPrice = TypeParser.ToDecimal(productPrice[i]); item.productMoney = TypeParser.ToDecimal(productMoney[i]); item.createTim = DateTime.Now; things.Add(item); } } model.ispay = 0; model.ssh_status = 0; model.orderTime = DateTime.Now; model.SYNCFLAG = "N"; model.SYNCOPERATION = "A"; model.SYNCVERSION = DateTime.Now; model.VERSION = 1; orderB.Add(VIEW_TG_order.ToEntity(model)); foreach (var item in things) { thingB.Add(VIEW_TG_Thing.ToEntity(item)); } status = true; } catch (Exception e) { return(this.JsonFormat(status, status, SysOperate.Add)); } return(this.JsonFormat("/Admin/Order/OrderDetail?ordernum=" + model.orderNum, status, SysOperate.Add.ToMessage(status), status)); }