/// <summary> /// 获取众筹订单详情 /// </summary> /// <returns></returns> private string Get(HttpContext context) { string recordID = context.Request["order_id"]; CrowdFundRecord crowdFundRecord = bll.Get <CrowdFundRecord>(string.Format(" RecordID={0}", recordID)); CrowdFundInfo crowdFundInfo = bll.Get <CrowdFundInfo>(string.Format(" CrowdFundID={0}", crowdFundRecord.CrowdFundID)); var item = bll.Get <CrowdFundItem>(string.Format("ItemId={0}", crowdFundRecord.ItemId)); var data = new { receiver_name = crowdFundRecord.Name, receiver_phone = crowdFundRecord.Phone, receiver_address = crowdFundRecord.ReceiveAddress, crowdfund_img_url = bll.GetImgUrl(crowdFundInfo.CoverImage), crowdfund_title = crowdFundInfo.Title, order_amount = crowdFundRecord.Amount, order_id = crowdFundRecord.RecordID, order_status = crowdFundRecord.OrderStatus, crowdfund_originator = crowdFundInfo.Originator, order_time = crowdFundRecord.InsertDate != null?bll.GetTimeStamp((DateTime)crowdFundRecord.InsertDate) : 0, order_pay_time = crowdFundRecord.PayTime != null?bll.GetTimeStamp((DateTime)crowdFundRecord.PayTime) : 0, order_delivery_time = crowdFundRecord.DeliveryTime != null?bll.GetTimeStamp((DateTime)crowdFundRecord.DeliveryTime) : 0, express_company_name = crowdFundRecord.ExpressCompanyName, express_number = crowdFundRecord.ExpressNumber, express_company_code = crowdFundRecord.ExpressCompanyCode, item_productname = item.ProductName }; return(ZentCloud.Common.JSONHelper.ObjectToJson(data)); }
/// <summary> /// 编辑 /// </summary> /// <param name="context"></param> /// <returns></returns> private string EditCrowdFundInfo(HttpContext context) { CrowdFundInfo requestModel = bllBase.ConvertRequestToModel <CrowdFundInfo>(new CrowdFundInfo()); if (bllBase.Update(requestModel)) { resp.Status = 1; resp.Msg = "修改成功"; } return(Common.JSONHelper.ObjectToJson(resp)); }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["id"])) { Response.End(); } model = bllBase.Get <CrowdFundInfo>(string.Format(" AutoID={0}", Request["id"])); if (model == null) { Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { id = Request["id"]; if (!string.IsNullOrEmpty(Request["id"])) { actionStr = "编辑"; currAction = "edit"; model = bllBase.Get <CrowdFundInfo>(string.Format("WebSiteOwner='{0}' And AutoID={1}", bllBase.WebsiteOwner, id)); if (model == null) { Response.End(); } else { } } }
/// <summary> /// 添加 /// </summary> /// <param name="context"></param> /// <returns></returns> private string AddCrowdFundInfo(HttpContext context) { CrowdFundInfo model = bllBase.ConvertRequestToModel <CrowdFundInfo>(new CrowdFundInfo()); model.WebSiteOwner = bllBase.WebsiteOwner; if (bllBase.Add(model)) { resp.Status = 1; resp.Msg = "添加成功"; } else { resp.Status = 0; resp.Msg = "添加失败"; } outoff: return(Common.JSONHelper.ObjectToJson(resp)); }
/// <summary> /// 众筹订单列表 /// </summary> /// <returns></returns> private string List(HttpContext context) { int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; int pageSize = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10; System.Text.StringBuilder sbWhere = new System.Text.StringBuilder(string.Format(" WebSiteOwner='{0}'", bll.WebsiteOwner)); string status = context.Request["order_status"]; if (!string.IsNullOrEmpty(status)) { sbWhere.AppendFormat(" And OrderStatus ='{0}'", status); } int totalCount = bll.GetCount <CrowdFundRecord>(sbWhere.ToString()); var sourceData = bll.GetLit <CrowdFundRecord>(pageSize, pageIndex, sbWhere.ToString()); List <OrderListModel> list = new List <OrderListModel>(); foreach (var item in sourceData) { CrowdFundInfo crowdFundInfo = bll.Get <CrowdFundInfo>(string.Format(" CrowdFundID={0}", item.CrowdFundID)); if (crowdFundInfo == null) { resp.errcode = 1; resp.errmsg = "不存在订单"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } OrderListModel order = new OrderListModel(); order.order_id = item.RecordID; order.order_amount = item.Amount; order.order_status = item.OrderStatus; order.crowdfund_title = crowdFundInfo.Title; order.crowdfund_img_url = crowdFundInfo.CoverImage; order.crowdfund_originator = crowdFundInfo.Originator; order.receiver_name = item.Name; order.order_time = bll.GetTimeStamp(item.InsertDate); list.Add(order); } var data = new { totalcount = totalCount, //数量 list = list, //列表 }; return(ZentCloud.Common.JSONHelper.ObjectToJson(data)); }
/// <summary> /// 订单列表 /// </summary> /// <param name="context"></param> /// <returns></returns> private string List(HttpContext context) { int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; int pageSize = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10; string status = context.Request["order_status"]; System.Text.StringBuilder sbWhere = new System.Text.StringBuilder(string.Format(" WebSiteOwner='{0}' AND UserID='{1}'", bll.WebsiteOwner, currentUserInfo.UserID)); if (!string.IsNullOrEmpty(status)) { sbWhere.AppendFormat(" And OrderStatus ='{0}'", status); } int totalCount = bll.GetCount <CrowdFundRecord>(sbWhere.ToString()); var sourceData = bll.GetLit <CrowdFundRecord>(pageSize, pageIndex, sbWhere.ToString()); List <OrderListModel> list = new List <OrderListModel>(); foreach (var item in sourceData) { CrowdFundInfo crowdFundInfo = bll.Get <CrowdFundInfo>(string.Format(" CrowdFundID={0}", item.CrowdFundID)); OrderListModel order = new OrderListModel(); order.order_id = item.RecordID; order.order_amount = item.Amount; order.order_status = item.OrderStatus; order.crowdfund_title = crowdFundInfo.Title; order.crowdfund_img_url = bll.GetImgUrl(crowdFundInfo.CoverImage); order.crowdfund_originator = crowdFundInfo.Originator; order.expree_company_name = item.ExpressCompanyName; order.express_company_code = item.ExpressCompanyCode; order.express_number = item.ExpressNumber; list.Add(order); } var data = new { totalcount = totalCount, //数量 list = list, //列表 }; return(ZentCloud.Common.JSONHelper.ObjectToJson(data)); }
/// <summary> /// 更新 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Update(HttpContext context) { RequestModel requestModel; try { requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]); } catch (Exception) { resp.errcode = -1; resp.errmsg = "json格式错误,请检查"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } //检查必填项 if (string.IsNullOrEmpty(requestModel.crowdfund_title)) { resp.errcode = 1; resp.errmsg = "crowdfund_title 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(requestModel.crowdfund_img_url)) { resp.errcode = 1; resp.errmsg = "crowdfund_img_url 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.crowdfund_amount <= 0) { resp.errcode = 1; resp.errmsg = "crowdfund_amount 参数须大于0"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(requestModel.crowdfund_intro)) { resp.errcode = 1; resp.errmsg = "crowdfund_intro 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.crowdfund_stoptime <= 0) { resp.errcode = 1; resp.errmsg = "crowdfund_stoptime 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.item_list == null || requestModel.item_list.Count == 0) { resp.errcode = -1; resp.errmsg = "item_list 元素个数需大于0"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); try { CrowdFundInfo crowdFundInfo = bll.Get <CrowdFundInfo>(string.Format(" CrowdFundID={0} And WebSiteOwner='{1}'", requestModel.crowdfund_id, bll.WebsiteOwner)); if (crowdFundInfo == null) { resp.errcode = 1; resp.errmsg = "众筹活动不存在"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } var itemList = bll.GetList <CrowdFundItem>(string.Format(" CrowdFundID={0}", crowdFundInfo.CrowdFundID)); var delItemIdList = new List <int>(); if (itemList.Count != requestModel.item_list.Where(p => p.item_id > 0).Count()) { //有删除的item 检查是否可以删除 var delItemList = from req in itemList where !(from old in requestModel.item_list select old.item_id).Contains(req.ItemId) select req; if (delItemList.Count() > 0) { foreach (var item in delItemList) { if (bll.GetCount <CrowdFundRecord>(string.Format(" ItemId={0}", item.ItemId)) > 0) { resp.errcode = 1; resp.errmsg = string.Format("{0}已经有下单记录,不能删除。", item.ProductName); return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } delItemIdList.Add(item.ItemId); } } } crowdFundInfo.Type = requestModel.crowdfund_type; crowdFundInfo.Title = requestModel.crowdfund_title; crowdFundInfo.CoverImage = requestModel.crowdfund_img_url; crowdFundInfo.FinancAmount = requestModel.crowdfund_amount; crowdFundInfo.Introduction = requestModel.crowdfund_intro; crowdFundInfo.Originator = requestModel.crowdfund_originator; crowdFundInfo.StopTime = bll.GetTime(requestModel.crowdfund_stoptime); if (!bll.Update(crowdFundInfo, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } foreach (var item in requestModel.item_list) { CrowdFundItem model; if (item.item_id == 0) { model = new CrowdFundItem(); model.Amount = item.item_amount; model.CrowdFundID = crowdFundInfo.CrowdFundID; model.Description = item.item_desc; model.ItemId = int.Parse(bll.GetGUID(BLLJIMP.TransacType.CommAdd)); model.WebsiteOwner = bll.WebsiteOwner; model.ProductName = item.item_productname; if (!bll.Add(model, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } else { model = bll.Get <CrowdFundItem>(string.Format(" ItemId={0} And WebSiteOwner='{1}'", item.item_id, bll.WebsiteOwner)); if (model == null) { tran.Rollback(); resp.errcode = 1; resp.errmsg = " item 不存在"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } model.Amount = item.item_amount; model.Description = item.item_desc; model.ProductName = item.item_productname; if (!bll.Update(model, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } } tran.Commit(); if (delItemIdList.Count > 0) { foreach (var itemId in delItemIdList) { if (bll.Delete(new CrowdFundItem(), string.Format(" ItemId={0}", itemId)) <= 0) { resp.errcode = 1; resp.errmsg = "删除旧选项失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } } resp.errmsg = "ok"; } catch (Exception ex) { tran.Rollback(); resp.errcode = -1; resp.errmsg = ex.Message; } return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
/// <summary> /// 添加 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Add(HttpContext context) { RequestModel requestModel; try { requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]); } catch (Exception) { resp.errcode = -1; resp.errmsg = "json格式错误,请检查"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } //检查必填项 if (string.IsNullOrEmpty(requestModel.crowdfund_title)) { resp.errcode = 1; resp.errmsg = "crowdfund_title 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.crowdfund_stoptime <= 0) { resp.errcode = 1; resp.errmsg = "crowdfund_stoptime 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(requestModel.crowdfund_img_url)) { resp.errcode = 1; resp.errmsg = "crowdfund_img_url 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.crowdfund_amount <= 0) { resp.errcode = 1; resp.errmsg = "crowdfund_amount 参数须大于0"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.crowdfund_stoptime <= 0) { resp.errcode = 1; resp.errmsg = "crowdfund_stoptime 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(requestModel.crowdfund_intro)) { resp.errcode = 1; resp.errmsg = "crowdfund_intro 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(requestModel.crowdfund_originator)) { resp.errcode = 1; resp.errmsg = "crowdfund_originator 参数必填"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (requestModel.item_list == null || requestModel.item_list.Count == 0) { resp.errcode = -1; resp.errmsg = "item_list 元素个数需大于0"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); try { CrowdFundInfo crowdFundInfo = new CrowdFundInfo(); crowdFundInfo.CrowdFundID = int.Parse(bll.GetGUID(BLLJIMP.TransacType.CommAdd)); crowdFundInfo.Type = requestModel.crowdfund_type; crowdFundInfo.Title = requestModel.crowdfund_title; crowdFundInfo.CoverImage = requestModel.crowdfund_img_url; crowdFundInfo.FinancAmount = requestModel.crowdfund_amount; crowdFundInfo.Introduction = requestModel.crowdfund_intro; crowdFundInfo.WebSiteOwner = bll.WebsiteOwner; crowdFundInfo.StopTime = bll.GetTime(requestModel.crowdfund_stoptime); crowdFundInfo.Originator = requestModel.crowdfund_originator; crowdFundInfo.Status = 1; if (!bll.Add(crowdFundInfo, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } foreach (var item in requestModel.item_list) { CrowdFundItem model = new CrowdFundItem(); model.Amount = item.item_amount; model.CrowdFundID = crowdFundInfo.CrowdFundID; model.Description = item.item_desc; model.ItemId = int.Parse(bll.GetGUID(BLLJIMP.TransacType.CommAdd)); model.WebsiteOwner = bll.WebsiteOwner; model.ProductName = item.item_productname; if (!bll.Add(model, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "操作失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } tran.Commit(); resp.errmsg = "ok"; } catch (Exception ex) { tran.Rollback(); resp.errcode = -1; resp.errmsg = ex.Message; } return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
/// <summary> /// 下单 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Add(HttpContext context) { RequestModel requestModel; try { requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]); CrowdFundItem itemInfo = bll.Get <CrowdFundItem>(string.Format(" ItemId={0} And Websiteowner='{1}' And CrowdFundID={2}", requestModel.crowdfund_item_id, bll.WebsiteOwner, requestModel.crowdfund_id)); if (itemInfo == null) { resp.errcode = 1; resp.errmsg = " crowdfund_item_id,crowdfund_id 不存在,请检查"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } CrowdFundRecord model = new CrowdFundRecord(); model.UserID = currentUserInfo.UserID; model.Amount = itemInfo.Amount; model.CrowdFundID = itemInfo.CrowdFundID; model.InsertDate = DateTime.Now; model.ItemId = itemInfo.ItemId; model.Name = requestModel.receiver_name; model.Phone = requestModel.receiver_phone; model.ReceiveAddress = requestModel.receiver_address; model.RecordID = int.Parse(bll.GetGUID(BLLJIMP.TransacType.CommAdd)); model.WebsiteOwner = bll.WebsiteOwner; model.CrowdFundID = itemInfo.CrowdFundID; model.OrderStatus = "待付款"; model.BuyerMemo = requestModel.buyer_memo; CrowdFundInfo crowdFundInfo = bll.Get <CrowdFundInfo>(string.Format(" CrowdFundID={0} ", requestModel.crowdfund_id)); if (crowdFundInfo == null) { resp.errcode = 1; resp.errmsg = " 众筹不存在"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (crowdFundInfo.Status == 0) { resp.errcode = 1; resp.errmsg = " 众筹已停止"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (DateTime.Now >= crowdFundInfo.StopTime) { resp.errcode = 1; resp.errmsg = " 众筹已到截止时间"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } //检查必填项 if (string.IsNullOrEmpty(model.Name)) { resp.errcode = 1; resp.errmsg = " 收货人姓名不能为空"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(model.Phone)) { resp.errcode = 1; resp.errmsg = " 收货人电话不能为空"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (string.IsNullOrEmpty(model.ReceiveAddress)) { resp.errcode = 1; resp.errmsg = " 收货地址不能为空"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (!bll.Add(model)) { resp.errcode = 1; resp.errmsg = "下单失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } return(ZentCloud.Common.JSONHelper.ObjectToJson(new { errcode = 0, errmsg = "ok", order_id = model.RecordID })); } catch (Exception ex) { resp.errcode = 1; resp.errmsg = "JSON格式错误,请检查。错误信息:" + ex.Message; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } }