/// <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)); }
public List <RequestModel> GetActivityData(int rows, int page, string cateId, string keyword, bool myActivity, string sort, out int total, string column = "", bool isForward = false, string isFee = "") { //DateTime start = DateTime.Now; StringBuilder sbWhere = new StringBuilder(); string orderBy = "";//默认排序 switch (sort) { case "activity_tstatus": orderBy = " TStatus DESC"; break; case "activity_start_time": orderBy = " ActivityStartDate DESC"; break; case "activity_signcount ": orderBy = " SignUpCount DESC"; break; case "activity_sort": //综合排序 orderBy = " SignUpCount DESC, ActivityStartDate DESC"; break; case "activity_createDate": orderBy = " CreateDate DESC "; break; default: orderBy = ""; break; } total = 0; string currUserId = ""; if (myActivity) { currUserId = bll.GetCurrUserID(); if (string.IsNullOrEmpty(currUserId)) { currUserId = "-1"; } } BLLJIMP.Model.ActivityConfig activityConfig = new ActivityConfig(); activityConfig = bllJuActivity.Get <BLLJIMP.Model.ActivityConfig>(string.Format(" WebsiteOwner='{0}'", bllJuActivity.WebsiteOwner)); if (activityConfig == null) { activityConfig = new ActivityConfig(); } bool showStopEndDateData = false; bool showHide = true; if (activityConfig.IsShowHideActivity == 1) { showStopEndDateData = true; showHide = false; } var juActivityData = bllJuActivity.QueryJuActivityData(null, out total, null, null, null, isFee, keyword, page, rows, currUserId, null, "Activity", bll.WebsiteOwner, null, cateId, null, null, null, null, null, false, orderBy, false, showHide, false, null, null, showStopEndDateData, column, isForward); //DateTime dataend = DateTime.Now; //sbWhere.AppendFormat(" ArticleType='Activity' AND IsDelete=0 AND WebsiteOwner='{0}'", bll.WebsiteOwner); //if (!string.IsNullOrEmpty(cateId) && cateId != "0" && !cateId.Contains(",")) //{ // cateId = new ZentCloud.BLLJIMP.BLLArticleCategory().GetCateAndChildIds(int.Parse(cateId));//获取下面的子分类 // if (string.IsNullOrEmpty(cateId)) cateId = "-1"; // sbWhere.AppendFormat(" AND ( CategoryId in ({0}) OR RootCateId IN ({0}))", cateId); //} //else if (!string.IsNullOrEmpty(cateId) && cateId.Contains(",")) //{ // cateId = "'" + cateId.Replace(",", "','") + "'"; // sbWhere.AppendFormat(" AND CategoryId in ({0}) ", cateId); //} //if (!string.IsNullOrEmpty(keyword)) //{ // sbWhere.AppendFormat(" And (ActivityName like'%{0}%' Or ActivityAddress like'%{0}%')", keyword); //} //if (myActivity) //{ // sbWhere.AppendFormat(" And SignUpActivityID in(select ActivityID from ZCJ_ActivityDataInfo where UserId='{0}')", bll.GetCurrUserID()); //} //sbWhere.Append(" AND IsSys = 0 "); List <RequestModel> data = new List <RequestModel>(); //total = bll.GetCount<JuActivityInfo>(sbWhere.ToString()); //var juActivityData = bll.GetLit<JuActivityInfo>(rows, page, sbWhere.ToString(), orderBy); foreach (JuActivityInfo p in juActivityData) { CrowdFundItem itemModel = bllJuActivity.Get <CrowdFundItem>(string.Format(" WebsiteOwner='{0}' AND CrowdFundID={1} order by ItemId asc ", bll.WebsiteOwner, p.JuActivityID)); RequestModel requestModel = new RequestModel(); requestModel.activity_id = p.JuActivityID; requestModel.activity_name = p.ActivityName; if (p.ActivityStartDate != null) { requestModel.activity_start_time = bll.GetTimeStamp((DateTime)p.ActivityStartDate); } if (p.ActivityEndDate != null) { requestModel.activity_end_time = bll.GetTimeStamp((DateTime)p.ActivityEndDate); } requestModel.activity_address = p.ActivityAddress; requestModel.category_name = p.CategoryName; requestModel.activity_img_url = bll.GetImgUrl(p.ThumbnailsPath); requestModel.activity_pv = p.PV; requestModel.activity_signcount = p.SignUpCount; requestModel.activity_score = p.ActivityIntegral; if (!string.IsNullOrEmpty(p.Tags)) { requestModel.activity_tags = p.Tags.Split(',').Take(5).ToList(); } requestModel.activity_status = p.ActivityStatus; if (itemModel != null) { requestModel.activity_price = itemModel.Amount; } data.Add(requestModel); } //DateTime dataStructure = DateTime.Now; //data.Add(new RequestModel { // activity_address = start.ToString("yyyy-MM-dd hh:mm:ss.fff"), // activity_img_url = dataend.ToString("yyyy-MM-dd hh:mm:ss.fff"), // activity_name = dataStructure.ToString("yyyy-MM-dd hh:mm:ss.fff") //}); return(data); }
/// <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)); } }