public void ProcessRequest(HttpContext context) { string categoryId = context.Request["category_id"]; if (string.IsNullOrEmpty(categoryId)) { resp.errmsg = "category_id 为必填项,请检查"; resp.errcode = 1; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" WebsiteOwner='{0}' AND AutoID={1}", bllMall.WebsiteOwner, categoryId)); if (category == null) { resp.errmsg = "没有找到商城分类"; resp.errcode = 1; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } RequestModel requestModel = new RequestModel(); requestModel.category_name = category.CategoryName; requestModel.category_img_url = category.CategoryImg; requestModel.category_description = category.Description; requestModel.category_parent_id = category.PreID; requestModel.type = category.Type; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(requestModel)); }
public void ProcessRequest(HttpContext context) { string data = context.Request["data"]; RequestModel requestModel; try { requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]); } catch (Exception) { resp.errcode = -1; resp.errmsg = "json格式错误,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (string.IsNullOrEmpty(requestModel.category_name)) { resp.errmsg = "category_name 为必填项,请检查"; resp.errcode = 1; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } WXMallCategory model = new WXMallCategory(); model.CategoryName = requestModel.category_name; model.CategoryImg = requestModel.category_img_url; model.Description = requestModel.category_description; model.PreID = requestModel.category_parent_id; model.WebsiteOwner = bllMall.WebsiteOwner; if (string.IsNullOrEmpty(requestModel.type) || requestModel.type.ToLower().ToString() == "mall") { model.Type = "Mall"; } else { model.Type = requestModel.type; } if ((!string.IsNullOrEmpty(model.CategoryName)) && model.CategoryName.Length > 20) { model.CategoryName = model.CategoryName.Substring(0, 20); } if ((!string.IsNullOrEmpty(model.Description)) && model.Description.Length > 30) { model.Description = model.Description.Substring(0, 30); } if (bllMall.Add(model)) { resp.errcode = 0; resp.errmsg = "ok"; resp.isSuccess = true; } else { resp.errcode = 1; resp.errmsg = "添加分类出错"; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
protected void Page_Load(object sender, EventArgs e) { config = bllWebSite.GetCompanyWebsiteConfig(); if (config == null) { config = new CompanyWebsite_Config(); config.WebsiteTitle = "膏方专家预约平台"; config.WebsiteDescription = "膏方专家预约平台"; } if (string.IsNullOrEmpty(Request["id"])) { Response.Write("id 参数必传"); Response.End(); } model = bllMall.GetProduct(Request["id"]); if (model == null) { Response.Write("id 参数错误"); Response.End(); } config.WebsiteTitle = string.Format("中医专家-{0}-膏方预约平台已开通!", model.PName); if (model.IsOnSale == "0") { config.WebsiteTitle = string.Format("中医专家-{0}-膏方预约平台即将开通!", model.PName); } StringBuilder sbWhere = new StringBuilder(); sbWhere.AppendFormat(" WebsiteOwner='{0}' And TableName ='ZCJ_WXMallOrderInfo' Order by Sort DESC", bllMall.WebsiteOwner); fieldList = bllMall.GetList <TableFieldMapping>(sbWhere.ToString()); categoryList = bllMall.GetCategoryList().Where(p => p.PreID == 0).Where(p => p.Type == "BookingDoctorFuYou").ToList(); if (!string.IsNullOrEmpty(model.CategoryId)) { categoryId = model.CategoryId; WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" AutoID={0}", model.CategoryId)); if (category != null) { if (category.PreID > 0) { categoryId = bllMall.Get <WXMallCategory>(string.Format(" AutoID={0}", category.PreID)).AutoID.ToString(); } } } }
/// <summary> /// 添加预约 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddOrder(HttpContext context) { try { string id = context.Request["id"]; //多个医生id string[] ids = new string[] { }; //多个医生id if (!string.IsNullOrEmpty(id)) { id = id.TrimStart(',').TrimEnd(','); ids = id.Split(','); } if (ids.Length >= 1)//检查是否可以预约 { foreach (var item in ids) { WXMallProductInfo productInfoCheck = bllMall.GetProduct(item); if (productInfoCheck != null) { if (productInfoCheck.Stock <= 0) { apiResp.msg = string.Format("专家{0}的预约已满", productInfoCheck.PName); return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } } } } WXMallProductInfo productInfo = new WXMallProductInfo(); WXMallOrderInfo orderInfo = bllMall.ConvertRequestToModel <WXMallOrderInfo>(new WXMallOrderInfo()); if (string.IsNullOrEmpty(orderInfo.Consignee)) { apiResp.msg = "请填写姓名"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (string.IsNullOrEmpty(orderInfo.Ex1)) { apiResp.msg = "请填写年龄"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (string.IsNullOrEmpty(orderInfo.Ex2)) { apiResp.msg = "请选择性别"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (string.IsNullOrEmpty(orderInfo.Phone)) { apiResp.msg = "请填写手机号"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (!Common.MyRegex.PhoneNumLogicJudge(orderInfo.Phone)) { apiResp.msg = "请输入正确手机号"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } StringBuilder sbWhere = new StringBuilder(); sbWhere.AppendFormat(" WebsiteOwner='{0}' And TableName ='ZCJ_WXMallOrderInfo' Order by Sort DESC", bllMall.WebsiteOwner); var fieldList = bllMall.GetList <TableFieldMapping>(sbWhere.ToString()); if (fieldList != null && fieldList.Count > 0) { Type type = orderInfo.GetType(); fieldList = fieldList.Where(p => p.FieldIsNull == 0).ToList(); foreach (var field in fieldList) { System.Reflection.PropertyInfo propertyInfo = type.GetProperty(field.Field); //获取指定名称的属性 var value = propertyInfo.GetValue(orderInfo, null); //获取属性值 if (value == null || string.IsNullOrEmpty(value.ToString())) { switch (field.FieldType) { case "text": apiResp.msg = "请填写 " + field.MappingName; break; case "combox": //下拉框 apiResp.msg = "请选择 " + field.MappingName; break; case "checkbox": //下拉框 apiResp.msg = "请选择 " + field.MappingName; break; default: break; } return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } } } orderInfo.OrderID = bllMall.GetGUID(BLLJIMP.TransacType.AddMallOrder); orderInfo.WebsiteOwner = bllMall.WebsiteOwner; orderInfo.InsertDate = DateTime.Now; orderInfo.OrderUserID = "defualt"; orderInfo.Status = "未确认"; if (bllMall.IsLogin) { orderInfo.OrderUserID = bllUser.GetCurrUserID(); } if (!string.IsNullOrEmpty(orderInfo.Ex6))//科系 { //推荐 int categoryId; if (int.TryParse(orderInfo.Ex6, out categoryId)) { WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" AutoId={0}", categoryId)); if (category != null) { orderInfo.Ex6 = category.CategoryName; } } } else { //正常预约 if (ids.Length == 1) { productInfo = bllMall.GetProduct(ids[0]); if (productInfo != null) { if (!string.IsNullOrEmpty(productInfo.CategoryId)) { WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" AutoId={0}", productInfo.CategoryId)); if (category != null) { orderInfo.Ex6 = category.CategoryName; } } } } } if (!string.IsNullOrEmpty(orderInfo.Ex5))//医生 名字或多个Id { orderInfo.Ex5 = orderInfo.Ex5.TrimStart(',').TrimEnd(','); string names = ""; foreach (var item in orderInfo.Ex5.Split(',')) { int pId; if (int.TryParse(item, out pId)) { productInfo = bllMall.GetProduct(pId.ToString()); if (productInfo != null) { names += productInfo.PName + ","; if (productInfo.Stock <= 0) { apiResp.msg = string.Format("专家{0}的预约已满", productInfo.PName); return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } } } } if (orderInfo.Ex5.Split(',').Length >= 1 && (!string.IsNullOrEmpty(names))) { orderInfo.Ex5 = names.TrimEnd(','); } } ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); if (!bllMall.Add(orderInfo, tran)) { apiResp.msg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (ids.Length > 0) { if (bllMall.Update(productInfo, string.Format("Stock-=1,SaleCount+=1"), string.Format("PID in({0})", id)) < ids.Length) { tran.Rollback(); apiResp.msg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } } tran.Commit(); apiResp.status = true; bllWeixin.SendTemplateMessageToKefu("有新的预约", string.Format("姓名:{0}\\n手机:{1}", orderInfo.Consignee, orderInfo.Phone)); } catch (Exception ex) { apiResp.msg = ex.Message; } return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }