public void ProcessRequest(HttpContext context) { try { string id = context.Request["id"]; string give = context.Request["give"]; //是否是领卡页 string websiteOwner = bll.WebsiteOwner; StoredValueCardRecord record = bll.GetByKey <StoredValueCardRecord>("AutoId", id, websiteOwner: websiteOwner); StoredValueCard card = bll.GetByKey <StoredValueCard>("AutoId", record.CardId.ToString(), websiteOwner: websiteOwner); UserInfo fromUser = bllUser.GetUserInfo(record.UserId, websiteOwner); UserInfo toUser = null; if (!string.IsNullOrWhiteSpace(record.ToUserId)) { toUser = bllUser.GetUserInfo(record.ToUserId, websiteOwner); } int useStatus = bll.GetUseStatus(card, record, CurrentUserInfo, fromUser, toUser, give == "1"); apiResp.result = new{ id = record.AutoId, card_id = record.CardId, card_number = record.CardNumber, name = card.Name, amount = card.Amount, bg_img = card.BgImage, create_date = record.CreateDate.ToString("yyyy/MM/dd HH:mm:ss"), valid_to = !record.ValidTo.HasValue ? "" : record.ValidTo.Value.ToString("yyyy/MM/dd HH:mm:ss"), use_date = !record.UseDate.HasValue ? "" : record.UseDate.Value.ToString("yyyy/MM/dd HH:mm:ss"), cur_user_id = CurrentUserInfo.AutoID, user_id = fromUser == null ? 0 : fromUser.AutoID, user_nickname = fromUser == null ? "" : bllUser.GetUserDispalyName(fromUser), user_avatar = fromUser == null ? "" : bllUser.GetUserDispalyAvatar(fromUser), touser_id = toUser == null ? 0 : toUser.AutoID, touser_nickname = toUser == null ? "" : bllUser.GetUserDispalyName(toUser), touser_avatar = toUser == null ? "" : bllUser.GetUserDispalyAvatar(toUser), touser_phone = toUser == null ? "" : toUser.Phone, status = record.Status, use_status = useStatus, canuse_amount = bllMall.GetStoreValueCardCanUseAmount(record.AutoId.ToString(), fromUser.UserID) }; apiResp.msg = "前台查询储值卡详情"; apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; bll.ContextResponse(context, apiResp); } catch (Exception ex) { apiResp.result = ex.ToString(); bll.ContextResponse(context, apiResp); } }
/// <summary> /// 新建储值卡 /// </summary> /// <param name="name"></param> /// <param name="amount"></param> /// <param name="maxCount"></param> /// <param name="validTo"></param> /// <param name="bgImg"></param> /// <param name="websiteOwner"></param> /// <param name="createUserId"></param> /// <returns></returns> public bool AddCard(string name, decimal amount, int maxCount, DateTime?validTo, string bgImg, string websiteOwner, string createUserId) { StoredValueCard card = new StoredValueCard(); card.Name = name; card.Amount = amount; card.MaxCount = maxCount; if (validTo.HasValue) { card.ValidTo = validTo; } card.BgImage = bgImg; card.WebsiteOwner = websiteOwner; card.CreateUserId = createUserId; card.CreateDate = DateTime.Now; card.ModifyUserId = createUserId; card.ModifyDate = card.CreateDate; return(Add(card)); }
/// <summary> /// 修改储值卡 /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="amount"></param> /// <param name="maxCount"></param> /// <param name="validTo"></param> /// <param name="bgImg"></param> /// <param name="websiteOwner"></param> /// <param name="createUserId"></param> /// <param name="msg"></param> /// <returns></returns> public bool UpdateCard(string id, string name, decimal amount, int maxCount, DateTime?validTo, string bgImg, string createUserId, string websiteOwner, out string msg) { msg = ""; StoredValueCard card = GetByKey <StoredValueCard>("AutoId", id, websiteOwner: websiteOwner); if (card == null) { msg = "储值卡未找到"; return(false); } card.Name = name; if (card.Amount != amount) { if (GetCountByKey <StoredValueCardRecord>("CardId", id, websiteOwner: websiteOwner) > 0) { msg = "储值卡存在发放记录,禁止修改金额"; return(false); } card.Amount = amount; } card.MaxCount = maxCount; if (validTo.HasValue) { card.ValidTo = validTo; } else if (card.ValidTo.HasValue) { card.ValidTo = null; } card.BgImage = bgImg; card.ModifyUserId = createUserId; card.ModifyDate = DateTime.Now; if (!Update(card)) { msg = "修改储值卡失败"; return(false); } return(true); }
public void ProcessRequest(HttpContext context) { int rows = Convert.ToInt32(context.Request["rows"]); int page = Convert.ToInt32(context.Request["page"]); string status = context.Request["status"]; string card_id = context.Request["card_id"]; string websiteOwner = bll.WebsiteOwner; int total = bll.GetRecordCount(card_id, websiteOwner, status, null); List <StoredValueCardRecord> list = new List <StoredValueCardRecord>(); if (total > 0) { list = bll.GetRecordList(rows, page, card_id, websiteOwner, status, null); } List <dynamic> rList = new List <dynamic>(); if (list.Count > 0) { StoredValueCard card = bll.GetColByKey <StoredValueCard>("AutoId", card_id, "AutoId,Name,BgImage", websiteOwner: websiteOwner); foreach (StoredValueCardRecord item in list) { UserInfo user = bllUser.GetUserInfo(item.UserId, websiteOwner); UserInfo toUser = null; if (!string.IsNullOrWhiteSpace(item.ToUserId)) { toUser = bllUser.GetUserInfo(item.ToUserId, websiteOwner); } int useStatus = bll.GetUseStatusByAdmin(item); rList.Add(new { id = item.AutoId, card_id = item.CardId, card_number = item.CardNumber, name = card.Name, bg_img = card.BgImage, create_date = item.CreateDate.ToString("yyyy/MM/dd HH:mm:ss"), valid_to = !item.ValidTo.HasValue ? "" : item.ValidTo.Value.ToString("yyyy/MM/dd HH:mm:ss"), use_date = !item.UseDate.HasValue ? "" : item.UseDate.Value.ToString("yyyy/MM/dd HH:mm:ss"), user_id = user == null ? 0 : user.AutoID, user_userId = item.UserId, user_nickname = user == null ? "" : bllUser.GetUserDispalyName(user), user_avatar = user == null ? "" : bllUser.GetUserDispalyAvatar(user), user_phone = user == null ? "" : user.Phone, touser_id = toUser == null ? 0 : toUser.AutoID, touser_userId = item.ToUserId, touser_nickname = toUser == null ? "" : bllUser.GetUserDispalyName(toUser), touser_avatar = toUser == null ? "" : bllUser.GetUserDispalyAvatar(toUser), touser_phone = toUser == null ? "" : toUser.Phone, status = item.Status, use_status = useStatus, amount = item.Amount, canuse_amount = string.IsNullOrEmpty(item.ToUserId) ? bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), item.UserId) : bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), item.UserId) }); } } apiResp.msg = "查询储值卡发放列表"; apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.result = new { totalcount = total, list = rList }; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { try { int rows = Convert.ToInt32(context.Request["rows"]); int page = Convert.ToInt32(context.Request["page"]); string status = context.Request["status"]; //0未使用 1已使用 2已转赠 3已过期 string websiteOwner = bll.WebsiteOwner; string curUserId = CurrentUserInfo.UserID; int total = bll.GetRecordCount(null, websiteOwner, status, curUserId); List <StoredValueCardRecord> list = new List <StoredValueCardRecord>(); if (total > 0) { list = bll.GetRecordList(rows, page, null, websiteOwner, status, curUserId); } List <dynamic> rList = new List <dynamic>(); List <UserInfo> uList = new List <UserInfo>(); if (list.Count > 0) { foreach (StoredValueCardRecord item in list) { StoredValueCard card = bll.GetColByKey <StoredValueCard>("AutoId", item.CardId.ToString(), "AutoId,Name,BgImage", websiteOwner: websiteOwner); UserInfo user = uList.FirstOrDefault(p => p.UserID == item.UserId); if (user == null) { user = bll.GetColByKey <UserInfo>("UserID", item.UserId, "AutoID", websiteOwner: websiteOwner); uList.Add(user); } if (user == null) { continue; } UserInfo toUser = null; if (!string.IsNullOrWhiteSpace(item.ToUserId)) { toUser = uList.FirstOrDefault(p => p.UserID == item.ToUserId); if (toUser == null) { toUser = bll.GetColByKey <UserInfo>("UserID", item.ToUserId, "AutoID", websiteOwner: websiteOwner); uList.Add(toUser); } } if (toUser == null) { continue; } int useStatus = bll.GetUseStatus(card, item, CurrentUserInfo, user, toUser, false); rList.Add(new { id = item.AutoId, card_id = item.CardId, card_number = item.CardNumber, amount = item.Amount, name = card.Name, bg_img = card.BgImage, valid_to = !item.ValidTo.HasValue ? "" : item.ValidTo.Value.ToString("yyyy/MM/dd HH:mm:ss"), status = item.Status, use_status = useStatus, canuse_amount = string.IsNullOrEmpty(item.ToUserId) ? bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), CurrentUserInfo.UserID) : bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), item.UserId) }); } } apiResp.msg = "前台查询储值卡发放列表"; apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.result = new { totalcount = total, list = rList }; bll.ContextResponse(context, apiResp); } catch (Exception ex) { apiResp.msg = ex.ToString(); context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } }
public void ProcessRequest(HttpContext context) { StringBuilder sbWhere = new StringBuilder(); sbWhere.AppendFormat(" WebsiteOwner= '{0}' And IsNull(IsMain,0)=0", bllMall.WebsiteOwner); string fromDate = context.Request["from_date"]; //开始日期 string toDate = context.Request["to_date"]; //结束日期 string status = context.Request["status"]; //订单状态 string orderIds = context.Request["oids"]; //订单号 string userAutoIds = context.Request["user_aids"]; //用户自动编号 string userTags = context.Request["user_tags"]; //用户标签 string isYuYueOrder = context.Request["is_yuyue"]; //是否是会议室预约和资源预约订单 string supplierUserId = context.Request["supplier_userid"]; //供应商账号 //订单类型 //0 商城订单 //1 礼品订单 //2 团购订单 //3 无 //4 活动订单 //5 会议室预订 //6 导师预约 string orderType = context.Request["order_type"]; if (!string.IsNullOrEmpty(orderType)) { if (orderType == "5") { sbWhere.AppendFormat(" And ArticleCategoryType='MeetingRoom'"); } else if (orderType == "6") { sbWhere.AppendFormat(" And ArticleCategoryType='BookingTutor'"); } else { sbWhere.AppendFormat(" And OrderType={0}", orderType); } } if (!string.IsNullOrEmpty(fromDate)) { sbWhere.AppendFormat(" And InsertDate>='{0}'", fromDate); } if (!string.IsNullOrEmpty(toDate)) { sbWhere.AppendFormat(" And InsertDate<='{0}'", toDate); } if (orderType == "2" && !string.IsNullOrEmpty(status)) { status = ConvertGroupbuyStatus(status); sbWhere.AppendFormat(" And GroupBuyStatus in({0})", status); } if (orderType == "2") { sbWhere.AppendFormat(" And PaymentStatus=1 ", status); } if ((!string.IsNullOrEmpty(status)) && (status != "退款退货") && orderType != "2") { status = "'" + status.Replace(",", "','") + "'"; sbWhere.AppendFormat(" And Status in({0})", status); } if (status == "退款退货") { sbWhere.AppendFormat(" And IsRefund=1 "); } if (!string.IsNullOrEmpty(orderIds)) { orderIds = "'" + orderIds.Replace(",", "','") + "'"; sbWhere.AppendFormat(" And OrderID in({0}) ", orderIds); } if (bllUser.IsSupplier(currentUserInfo)) { sbWhere.AppendFormat(" And SupplierUserId ='{0}' ", currentUserInfo.UserID); } if ((!string.IsNullOrEmpty(userAutoIds)) || (!string.IsNullOrEmpty(userTags))) { string userIds = ""; if (!string.IsNullOrEmpty(userAutoIds)) { foreach (var userAutoId in userAutoIds.Split(',')) { var userInfo = bllUser.GetUserInfoByAutoID(int.Parse(userAutoId)); if (userInfo != null) { userIds += string.Format("'{0}',", userInfo.UserID); } } } if (!string.IsNullOrEmpty(userTags)) { foreach (string tag in userTags.Split(',')) { List <UserInfo> userList = bllUser.GetList <UserInfo>(string.Format(" Websiteowner='{0}' And TagName like '%{1}%'", bllUser.WebsiteOwner, tag)); foreach (var userInfo in userList) { userIds += string.Format("'{0}',", userInfo.UserID); } } } userIds = userIds.TrimEnd(','); sbWhere.AppendFormat(" And OrderUserId in({0}) ", userIds); } if (!string.IsNullOrEmpty(supplierUserId)) { if (supplierUserId == "none") { sbWhere.AppendFormat(" And (SupplierUserId='' Or SupplierUserId IS NULL)", ""); } else { sbWhere.AppendFormat(" And SupplierUserId ='{0}' ", supplierUserId); } } sbWhere.AppendFormat(" Order by InsertDate Desc "); List <WXMallOrderInfo> orderList = bllMall.GetList <WXMallOrderInfo>(sbWhere.ToString()); //sbExport.Append("会员ID\t"); DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); dt1.Columns.Add("会员ID"); dt1.Columns.Add("线上卡号"); dt1.Columns.Add("OpenId"); dt1.Columns.Add("订单时间"); dt1.Columns.Add("父订单编号"); dt1.Columns.Add("订单号"); dt1.Columns.Add("订单状态"); dt1.Columns.Add("商品编号"); dt1.Columns.Add("商品编码"); dt1.Columns.Add("商品名称"); if (!string.IsNullOrEmpty(isYuYueOrder)) { dt1.Columns.Add("预约时间"); } dt1.Columns.Add("商品原价"); dt1.Columns.Add("商品均摊价格"); dt1.Columns.Add("商品单价"); dt1.Columns.Add("商品规格"); dt1.Columns.Add("商品条码"); dt1.Columns.Add("商品数量"); dt1.Columns.Add("商品总金额"); dt1.Columns.Add("运费"); dt1.Columns.Add("实付金额"); dt1.Columns.Add("收货人姓名"); dt1.Columns.Add("电话"); dt1.Columns.Add("收货地址"); dt1.Columns.Add("留言"); dt1.Columns.Add("支付状态"); dt1.Columns.Add("基础价"); dt1.Columns.Add("使用积分"); dt1.Columns.Add("使用余额"); dt1.Columns.Add("优惠券名称"); dt1.Columns.Add("优惠券ID"); dt1.Columns.Add("退款"); dt1.Columns.Add("主订单号"); dt1.Columns.Add("商户名称"); dt1.Columns.Add("商家备注"); dt1.Columns.Add("快递公司"); dt1.Columns.Add("快递单号"); dt2.Columns.Add("订单时间"); dt2.Columns.Add("订单号"); dt2.Columns.Add("订单状态"); dt2.Columns.Add("商品编号"); dt2.Columns.Add("商品名称"); dt2.Columns.Add("商品规格"); dt2.Columns.Add("商品数量"); dt2.Columns.Add("实付金额"); dt2.Columns.Add("收货人姓名"); dt2.Columns.Add("电话"); dt2.Columns.Add("收货地址"); dt2.Columns.Add("支付状态"); dt2.Columns.Add("退款"); dt2.Columns.Add("主订单号"); dt2.Columns.Add("商户名称"); dt2.Columns.Add("商家备注"); dt2.Columns.Add("快递公司"); dt2.Columns.Add("快递单号"); for (int i = 0; i < orderList.Count; i++) { var userInfo = bllUser.GetUserInfo(orderList[i].OrderUserID); if (userInfo == null) { userInfo = new UserInfo(); } string cardId = string.Empty; string cardName = string.Empty; if (!string.IsNullOrEmpty(orderList[i].MyCouponCardId)) { switch (orderList[i].CouponType) { case 0: MyCardCoupons myCardModel = bllCardcoupon.GetMyCardCoupon(Convert.ToInt32(orderList[i].MyCouponCardId)); if (myCardModel != null) { CardCoupons coupns = bllCardcoupon.GetCardCoupon(myCardModel.CardId); cardId = coupns.CardId.ToString(); cardName = coupns.Name; } break; case 1: int cardIdInt = Convert.ToInt32(orderList[i].MyCouponCardId); StoredValueCardRecord storedCard = bllStoredValueCard.GetStoredValueCardRecord(cardIdInt); if (storedCard != null) { StoredValueCard cardModel = bllStoredValueCard.GetStoredValueCard(storedCard.CardId); cardId = cardModel.AutoId.ToString(); cardName = cardModel.Name; } break; default: break; } } foreach (var item in bllMall.GetOrderDetailsList(orderList[i].OrderID)) { if (orderList[i].IsRefund == 1 && string.IsNullOrEmpty(item.RefundStatus) && status == "退款退货") { continue; } DataRow newRow = dt1.NewRow(); DataRow newRow1 = dt2.NewRow(); newRow["会员ID"] = userInfo.AutoID.ToString(); newRow["OpenId"] = userInfo.WXOpenId; newRow["订单时间"] = orderList[i].InsertDate.ToString(); newRow1["订单时间"] = orderList[i].InsertDate.ToString(); WXMallProductInfo product = bllMall.GetProduct(item.PID); switch (orderList[i].OrderType) { case 0: newRow["父订单编号"] = ""; break; case 1: newRow["父订单编号"] = orderList[i].ParentOrderId; break; case 2: newRow["父订单编号"] = orderList[i].GroupBuyParentOrderId; break; default: break; } newRow["订单号"] = orderList[i].OrderID; newRow1["订单号"] = orderList[i].OrderID; newRow["订单状态"] = orderList[i].Status; newRow1["订单状态"] = orderList[i].Status; newRow["商品编号"] = product == null ? "" : product.PID; newRow1["商品编号"] = product == null ? "" : product.PID; newRow["商品编码"] = product == null ? "" : product.ProductCode; newRow["商品名称"] = product == null ? item.SkuShowProp : product.PName; newRow1["商品名称"] = product == null ? item.SkuShowProp : product.PName; if (!string.IsNullOrEmpty(isYuYueOrder)) { if (isYuYueOrder == "MeetingRoom") { if (!string.IsNullOrEmpty(product.RelationProductId)) { newRow["预约时间"] = item.StartDate.ToString("yyyy-MM-dd HH:mm") + "-" + item.EndDate.ToString("HH:mm"); } else { newRow["预约时间"] = ""; } } else { newRow["预约时间"] = item.StartDate.ToString("yyyy-MM-dd HH:mm") + "-" + item.EndDate.ToString("HH:mm"); } } newRow["商品原价"] = product.PreviousPrice; newRow["商品均摊价格"] = item.PaymentFt; newRow["商品单价"] = item.OrderPrice; if (item.SkuId.HasValue) { newRow["商品规格"] = item.SkuShowProp; newRow1["商品规格"] = item.SkuShowProp; newRow["商品条码"] = item.SkuId; } else { newRow["商品规格"] = ""; newRow1["商品规格"] = ""; newRow["商品条码"] = ""; } newRow["商品数量"] = item.TotalCount; newRow1["商品数量"] = item.TotalCount; newRow["商品总金额"] = item.TotalCount * item.OrderPrice; newRow["运费"] = orderList[i].Transport_Fee; newRow["实付金额"] = orderList[i].TotalAmount; newRow1["实付金额"] = orderList[i].TotalAmount; newRow["收货人姓名"] = orderList[i].Consignee; newRow1["收货人姓名"] = orderList[i].Consignee; newRow["电话"] = orderList[i].Phone; newRow1["电话"] = orderList[i].Phone; newRow["收货地址"] = orderList[i].ReceiverProvince + orderList[i].ReceiverCity + orderList[i].ReceiverDist + orderList[i].Address; newRow1["收货地址"] = orderList[i].ReceiverProvince + orderList[i].ReceiverCity + orderList[i].ReceiverDist + orderList[i].Address; newRow["留言"] = orderList[i].OrderMemo; newRow["支付状态"] = ConvertPaymentStatus(orderList[i].PaymentStatus); newRow1["支付状态"] = ConvertPaymentStatus(orderList[i].PaymentStatus); newRow["基础价"] = item.BasePrice; newRow["使用积分"] = orderList[i].UseScore; newRow["使用余额"] = orderList[i].UseAmount; newRow["优惠券名称"] = cardName; newRow["优惠券ID"] = cardId; newRow["退款"] = ConvertRefundStatus(item.RefundStatus); newRow1["退款"] = ConvertRefundStatus(item.RefundStatus); newRow["主订单号"] = orderList[i].ParentOrderId; newRow1["主订单号"] = orderList[i].ParentOrderId; newRow["商户名称"] = orderList[i].SupplierName; newRow1["商户名称"] = orderList[i].SupplierName; newRow["商家备注"] = orderList[i].Ex21; newRow1["商家备注"] = orderList[i].Ex21; newRow["快递公司"] = orderList[i].ExpressCompanyName; newRow1["快递公司"] = orderList[i].ExpressCompanyName; newRow["快递单号"] = orderList[i].ExpressNumber; newRow1["快递单号"] = orderList[i].ExpressNumber; newRow["线上卡号"] = userInfo.Ex2; dt1.Rows.Add(newRow); dt2.Rows.Add(newRow1); } //if (orderList[i].OrderType == 2)//团购订单 //{ // foreach (var item in bllMall.GetList<WXMallOrderInfo>(string.Format(" GroupBuyParentOrderId='{0}' And PaymentStatus=1", orderList[i].OrderID))) // { // foreach (var detail in bllMall.GetOrderDetailsList(item.OrderID)) // { // DataRow nowRow1 = dt1.NewRow(); // DataRow nowRow2 = dt2.NewRow(); // WXMallProductInfo product = bllMall.GetProduct(detail.PID); // nowRow1["订单时间"] = item.InsertDate.ToString(); // nowRow2["订单时间"] = item.InsertDate.ToString(); // nowRow1["父订单编号"] = item.GroupBuyParentOrderId; // nowRow1["订单号"] = item.OrderID; // nowRow2["订单号"] = item.OrderID; // nowRow1["订单状态"] = item.Status; // nowRow2["订单状态"] = item.Status; // nowRow1["商品编号"] = product == null ? "" : product.PID; // nowRow2["商品编号"] = product == null ? "" : product.PID; // nowRow1["商品编码"] = product == null ? "" : product.ProductCode; // nowRow1["商品名称"] = product == null ? "" : product.PName; // nowRow2["商品名称"] = product == null ? "" : product.PName; // nowRow1["商品原价"] = product.PreviousPrice; // nowRow1["商品均摊价格"] = detail.PaymentFt; // nowRow1["商品单价"] = detail.OrderPrice; // if (detail.SkuId.HasValue) // { // nowRow1["商品规格"] = detail.SkuShowProp; // nowRow2["商品规格"] = detail.SkuShowProp; // nowRow1["商品条码"] = detail.SkuId; // } // else // { // nowRow1["商品规格"] = ""; // nowRow2["商品规格"] = ""; // nowRow1["商品条码"] = ""; // } // nowRow1["商品数量"] = detail.TotalCount; // nowRow2["商品数量"] = detail.TotalCount; // nowRow1["商品总金额"] = detail.TotalCount * detail.OrderPrice; // nowRow1["运费"] = item.Transport_Fee; // nowRow1["实付金额"] = item.TotalAmount; // nowRow2["实付金额"] = item.TotalAmount; // nowRow1["收货人姓名"] = item.Consignee; // nowRow2["收货人姓名"] = item.Consignee; // nowRow1["电话"] = item.Phone; // nowRow2["电话"] = item.Phone; // nowRow1["收货地址"] = item.ReceiverProvince + item.ReceiverCity + item.ReceiverDist + item.Address; // nowRow2["收货地址"] = item.ReceiverProvince + item.ReceiverCity + item.ReceiverDist + item.Address; // nowRow1["留言"] = item.OrderMemo; // nowRow1["支付状态"] = ConvertPaymentStatus(item.PaymentStatus); // nowRow2["支付状态"] = ConvertPaymentStatus(item.PaymentStatus); // nowRow1["基础价"] =detail.BasePrice; // nowRow1["使用积分"] = orderList[i].UseScore; // nowRow1["使用余额"] = orderList[i].UseAmount; // nowRow1["优惠券名称"] = cardName; // nowRow1["优惠券ID"] = cardId; // nowRow1["退款"] =ConvertRefundStatus(detail.RefundStatus); // nowRow2["退款"] = ConvertRefundStatus(detail.RefundStatus); // dt1.Rows.Add(nowRow1); // dt2.Rows.Add(nowRow2); // } // } //} } dt1.TableName = "订单列表"; dt2.TableName = "精简订单列表"; DataTable[] dt3 = { dt1, dt2 }; DataLoadTool.ExportDataTable(dt3, string.Format("{0}_data.xls", DateTime.Now.ToString())); }
/// <summary> /// 前台发放的储值卡可用状态 /// </summary> /// <param name="card">储值卡主卡</param> /// <param name="record">发放的储值卡</param> /// <param name="curUser">当前登录用户</param> /// <param name="fromUser">发放用户</param> /// <param name="toUser">转赠用户</param> /// <param name="isGive">是否转赠</param> /// <returns> /// 可用状态 /// 0可用 /// 1已使用 /// 2已过期 /// 10待接收转赠 (接口判断查看人构造) /// 11已转赠 (接口判断查看人构造) /// 12已转赠他人(接口判断查看人构造) /// 9已停用 (接口判断查看人构造) /// 99非法状态 (未知) /// </returns> public int GetUseStatus(StoredValueCard card, StoredValueCardRecord record, UserInfo curUser, UserInfo fromUser, UserInfo toUser, bool isGive) { BLLMall bllMall = new BLLMall(); int useStatus = 99; //正常 if (card.Status == 1) { useStatus = 9; //已停用 } else if (record.Status == 0) { if (curUser.AutoID == fromUser.AutoID) { useStatus = 0; //已转赠 } else if (isGive) { useStatus = 10; //待接收转赠 } } else if (record.Status == 1) { if (curUser.AutoID == toUser.AutoID) { useStatus = 0; //正常 } else if (curUser.AutoID == fromUser.AutoID) { useStatus = 11; //已转赠 } else { useStatus = 12; //已转赠它人 } } else if (record.Status == 9) { if (curUser.AutoID == fromUser.AutoID && toUser != null) { useStatus = 11; //已转赠 } else { useStatus = 1; //已使用 } // 储值卡有余额还可转赠 decimal canUseAmount = string.IsNullOrEmpty(record.ToUserId) ? bllMall.GetStoreValueCardCanUseAmount(record.AutoId.ToString(), record.UserId) : bllMall.GetStoreValueCardCanUseAmount(record.AutoId.ToString(), record.UserId); if (canUseAmount > 0) { useStatus = 0; if (isGive) { useStatus = 10; } } // 储值卡有余额还可转赠 } if (useStatus == 0 && record.ValidTo.HasValue && record.ValidTo.Value < DateTime.Now) { useStatus = 2; } return(useStatus); }
/// <summary> /// 储值卡发放 /// </summary> /// <param name="userIds"></param> /// <param name="cardId"></param> /// <param name="websiteOwner"></param> /// <param name="msg"></param> /// <param name="authority">域名加端口</param> /// <returns></returns> public bool SendRecord(string card_id, string type, string user_ids, string tags, string websiteOwner, string createUserId, out string msg, string authority) { msg = ""; if (type == "2" && string.IsNullOrWhiteSpace(tags)) { msg = "请选择接受储值卡的用户标签组"; return(false); } else if (type == "1" && string.IsNullOrWhiteSpace(user_ids)) { msg = "请选择接受储值卡的用户"; return(false); } StoredValueCard card = GetByKey <StoredValueCard>("AutoId", card_id, websiteOwner: websiteOwner); if (card == null) { msg = "储值卡不存在"; return(false); } if (card.Status != 0) { msg = "储值卡已停用"; return(false); } DateTime curDate = DateTime.Now; string dateString = curDate.ToString("yyyyMMdd"); if (card.ValidType == 0 && card.ValidTo.HasValue && card.ValidTo.Value < curDate) { msg = string.Format("储值卡已过有效期"); return(false); } List <string> userIdList = new List <string>(); if (type == "2") { StringBuilder sbWhere = new StringBuilder(); sbWhere.AppendFormat(" WebSiteOwner='{0}' And ( 1=2 ", websiteOwner); foreach (var tag in tags.Split(',')) { sbWhere.AppendFormat(" Or ',' + TagName + ',' Like '%,{0},%' ", tag); } sbWhere.AppendFormat(" )"); List <UserInfo> userList = GetColList <UserInfo>(int.MaxValue, 1, sbWhere.ToString(), "AutoID,UserID"); if (userList.Count > 0) { userIdList = userList.Select(p => p.UserID).Distinct().ToList(); } } else if (type == "1") { userIdList = user_ids.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).Distinct().ToList(); } if (userIdList.Count == 0) { msg = "接受卡券的用户未找到"; return(false); } int cCount = userIdList.Count - (card.MaxCount - card.SendCount); if (cCount > 0) { msg = string.Format("储值卡可发放数量不足,少{0}张", cCount); return(false); } int startNum = 0; StoredValueCardRecord oldRecord = Get <StoredValueCardRecord>(string.Format("{0}{1}", GetRecordWhereString(card.AutoId.ToString(), websiteOwner, null, null), " Order By AutoId Desc")); if (oldRecord != null) { startNum = Convert.ToInt32(oldRecord.CardNumber.Substring(16)); } StoredValueCardRecord baseRecord = new StoredValueCardRecord(); baseRecord.CardId = card.AutoId; baseRecord.WebsiteOwner = websiteOwner; baseRecord.CreateUserId = createUserId; baseRecord.CreateDate = curDate; if (card.ValidType == 0) { baseRecord.ValidTo = card.ValidTo; } else if (card.ValidType == 1 && card.ValidDay.HasValue) { baseRecord.ValidTo = curDate.AddDays(card.ValidDay.Value); } baseRecord.Amount = card.Amount; Random ran = new Random(); string cardString = card_id.PadLeft(3, '0'); if (card_id.Length > 3) { cardString = cardString.Substring(card_id.Length - 3); } List <StoredValueCardRecord> sendRecordList = new List <StoredValueCardRecord>(); List <UserInfo> usList = new List <UserInfo>(); for (int i = 0; i < userIdList.Count; i++) { UserInfo cru = usList.FirstOrDefault(p => p.UserID == userIdList[i]); if (cru == null) { cru = GetColByKey <UserInfo>("UserID", userIdList[i], "AutoID,UserID,WXOpenId,WebsiteOwner", websiteOwner: websiteOwner); if (cru == null) { continue; } usList.Add(cru); } else { usList.Add(cru); } startNum++; StoredValueCardRecord rRecord = (StoredValueCardRecord)baseRecord.Clone(); rRecord.UserId = userIdList[i]; string numString = startNum.ToString(); string ranString = ran.Next(99).ToString(); rRecord.CardNumber = "No." + dateString + cardString + ranString.PadLeft(2, '0') + numString.PadLeft(3, '0'); sendRecordList.Add(rRecord); } if (sendRecordList.Count == 0) { msg = "接收用户未找到"; return(false); } BLLWeixin bllWeixin = new BLLWeixin(); int suCount = 0; string redicturl = string.Format("http://{0}/App/SVCard/Wap/List.aspx", authority); for (int i = 0; i < sendRecordList.Count; i++) { if (Add(sendRecordList[i])) { suCount++; string content = string.Format("{0}\\n金额:{1}", card.Name, card.Amount); if (sendRecordList[i].ValidTo.HasValue) { content += string.Format("\\n有效期:{0}", sendRecordList[i].ValidTo.Value.ToString("yyyy-MM-dd HH:mm")); } bllWeixin.SendTemplateMessageNotifyComm(usList[i], "您收到一张储值卡", content, redicturl); } } if (Update(card, string.Format("SendCount=SendCount+{0}", suCount), string.Format("AutoId={0} And WebsiteOwner='{1}'", card.AutoId, websiteOwner)) <= 0) { if (suCount < sendRecordList.Count) { msg = "发送成功" + suCount + "张,但更新发放数量出错"; } else { msg = "发送成功,但更新发放数量出错"; } return(true); } if (suCount < sendRecordList.Count) { msg = "发送成功" + suCount + "张"; } else { msg = "发放储值卡成功"; } return(true); }