public JsonResult SavePayPwd(string oldPwd, string pwd) { var hasPayPwd = MemberApplication.HasPayPwd(CurrentUser.Id); if (hasPayPwd && string.IsNullOrEmpty(oldPwd)) { return(Json(new { success = false, msg = "请输入旧支付密码" })); } if (string.IsNullOrWhiteSpace(pwd)) { return(Json(new { success = false, msg = "请输入新支付密码" })); } if (hasPayPwd) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, oldPwd); if (!success) { return(Json(new { success = false, msg = "旧支付密码错误" })); } } _iMemberCapitalService.SetPayPwd(CurrentUser.Id, pwd); return(Json(new { success = true, msg = "设置成功" })); }
protected override object ChangePayPwdByOldPassword(string oldPassword, string password) { CheckUserLogin(); var _iMemberCapitalService = ServiceProvider.Instance <IMemberCapitalService> .Create; var hasPayPwd = MemberApplication.HasPayPassword(CurrentUser.Id); if (hasPayPwd && string.IsNullOrEmpty(oldPassword)) { return(Json(new { success = false, msg = "请输入旧支付密码" })); } if (string.IsNullOrWhiteSpace(password)) { return(Json(new { success = false, msg = "请输入新支付密码" })); } if (hasPayPwd) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, oldPassword); if (!success) { return(Json(new { success = false, msg = "旧支付密码错误" })); } } _iMemberCapitalService.SetPayPwd(CurrentUser.Id, password); return(Json(new { success = true, msg = "设置成功" })); }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { if (!MemberApplication.VerificationPayPwd(base.CurrentUser.Id, pwd)) { throw new HimallException("支付密码不对,请重新输入!"); } if (!((applyType != UserWithdrawType.ALiPay.GetHashCode()) || base.CurrentSiteSetting.Withdraw_AlipayEnable)) { throw new HimallException("不支持支付宝提现方式!"); } CapitalInfo capitalInfo = this._iMemberCapitalService.GetCapitalInfo(base.CurrentUser.Id); if (amount > capitalInfo.Balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0M) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid) && (applyType == UserWithdrawType.WeiChat.GetHashCode())) { openid = WebHelper.GetCookie("Himall-User_OpenId"); } if (string.IsNullOrWhiteSpace(nickname) && (applyType == UserWithdrawType.ALiPay.GetHashCode())) { throw new HimallException("数据异常,真实姓名不可为空!"); } if (!string.IsNullOrWhiteSpace(openid) && (applyType == UserWithdrawType.WeiChat.GetHashCode())) { openid = SecureHelper.AESDecrypt(openid, "Mobile"); SiteSettingsInfo siteSettings = this._iSiteSettingService.GetSiteSettings(); if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false), openid); if (userInfo != null) { nickname = userInfo.nickname; } } } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } ApplyWithDrawInfo model = new ApplyWithDrawInfo { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = new UserWithdrawType?((UserWithdrawType)applyType) }; this._iMemberCapitalService.AddWithDrawApply(model); return(base.Json(new { success = true })); }
public object PostSubmitFightGroupOrder(OrderSubmitFightGroupOrderModel value) { CheckUserLogin(); if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd)) { var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd); if (!flag) { return(Json(ErrorResult <dynamic>("预存款支付密码错误!"))); } } string skuIds = value.skuId; long counts = value.count; long recieveAddressId = value.recieveAddressId; long activeId = value.GroupActionId; long groupId = value.GroupId; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; string invoiceCode = value.invoiceCode; decimal capitalAmount = value.CapitalAmount; string orderRemarks = "";//value.orderRemarks;//订单备注 List <FightGroupOrderJoinStatus> seastatus = new List <FightGroupOrderJoinStatus>(); seastatus.Add(FightGroupOrderJoinStatus.Ongoing); seastatus.Add(FightGroupOrderJoinStatus.JoinSuccess); var groupData = ServiceProvider.Instance <IFightGroupService> .Create.GetActive(activeId, false, false); if (counts > groupData.LimitQuantity) { return(Json(ErrorResult <dynamic>(string.Format("每人限购数量:{0}!", groupData.LimitQuantity)))); } try { var model = OrderApplication.GetGroupOrder(CurrentUser.Id, skuIds, counts.ToString(), recieveAddressId, invoiceType, invoiceTitle, invoiceCode, invoiceContext, activeId, PlatformType.WeiXinSmallProg, groupId, isCashOnDelivery, orderRemarks, capitalAmount); CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提 model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray(); var ret = OrderApplication.OrderSubmit(model); AddVshopBuyNumber(ret.OrderIds);//添加微店购买数量 return(Json(new { OrderIds = ret.OrderIds, RealTotalIsZero = ret.OrderTotal == 0 })); } catch (MallException he) { return(Json(ErrorResult <dynamic>(he.Message))); } catch (Exception ex) { return(Json(ErrorResult <dynamic>("提交订单异常" + ex.Message))); } }
public object CheckPayPwd(PostSetPayPwdModel papa) { CheckUserLogin(); bool result = false; if (papa != null && !string.IsNullOrWhiteSpace(papa.pwd)) { result = MemberApplication.VerificationPayPwd(CurrentUser.Id, papa.pwd); } return(Json(ApiResult(result, data: result))); }
/// <summary> /// 判断支付密码是否正确 /// </summary> public object VerificationPayPwd(PaymentVerificationPayPwdModel papa) { CheckUserLogin(); bool result = false; if (papa != null && !string.IsNullOrWhiteSpace(papa.pwd)) { result = MemberApplication.VerificationPayPwd(CurrentUser.Id, papa.pwd); } return(new { success = result }); }
public JsonResult ApplyWithDrawSubmit(string nickname, decimal amount, string pwd) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } var capitalInfo = _iMemberCapitalService.GetCapitalInfo(CurrentUser.Id); if (amount > capitalInfo.Balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } var openid = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER_OpenID); string strNick = string.Empty; if (!string.IsNullOrWhiteSpace(openid)) { openid = Core.Helper.SecureHelper.AESDecrypt(openid, "Mobile"); var siteSetting = _iSiteSettingService.GetSiteSettings(); if (!(string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))) { string token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, openid); if (userinfo != null) { strNick = userinfo.nickname; } } } else { throw new HimallException("数据异常,OpenId不能为空!"); } ApplyWithDrawInfo model = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = strNick }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
public object SubmitOrder(SmallProgSubmitOrderModel value) { CheckUserLogin(); if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd)) { var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd); if (!flag) { return(Json(ErrorResult <dynamic>("预存款支付密码错误"))); } } if (value.fromPage == WXSmallProgFromPageType.SignBuy) { //立即购买(限时购) OrderSubmitOrderModel orderModel = new OrderSubmitOrderModel(); orderModel.counts = value.buyAmount.ToString(); orderModel.couponIds = value.couponCode; orderModel.integral = (int)value.deductionPoints; orderModel.recieveAddressId = value.shippingId; orderModel.skuIds = value.productSku; orderModel.orderRemarks = value.remark; orderModel.formId = value.formId; orderModel.isCashOnDelivery = false; //货到付款 orderModel.invoiceType = 0; //发票类型 orderModel.jsonOrderShops = value.jsonOrderShops; orderModel.isStore = value.isStore; orderModel.ProductType = value.ProductType; orderModel.VirtualProductItems = value.VirtualProductItems; orderModel.Capital = value.CapitalAmount; //提交 return(SubmitOrderById(orderModel)); } else if (value.fromPage == WXSmallProgFromPageType.Cart) { //购物车 OrderSubmitOrderByCartModel cartModel = new OrderSubmitOrderByCartModel(); cartModel.couponIds = value.couponCode; cartModel.integral = (int)value.deductionPoints; cartModel.recieveAddressId = value.shippingId; cartModel.cartItemIds = value.cartItemIds; // cartModel.formId = value.formId; cartModel.isCashOnDelivery = false; //货到付款 cartModel.invoiceType = 0; //发票类型 cartModel.jsonOrderShops = value.jsonOrderShops; cartModel.Capital = value.CapitalAmount; cartModel.isStore = value.isStore; return(SubmitOrderByCart(cartModel)); } return(Json(ErrorResult <dynamic>("提交来源异常"))); }
/// <summary> /// 下单 /// </summary> /// <param name="id">返回缓存预约单标识</param> /// <param name="order">预约单数据实体</param> /// <returns>下单结果</returns> public static Himall.Web.App_Code.Common.SubmitOrderResult SubmitOrder(OrderCreateModel order, out string id, string payPwd = "") { id = ""; if (((order.Capital > 0) && !string.IsNullOrEmpty(payPwd)) && !MemberApplication.VerificationPayPwd(order.CurrentUser.Id, payPwd)) { return(SubmitOrderResult.ErrorPassword); } if (order == null) { return(Common.SubmitOrderResult.NoData); } else if (order.SkuIds == null || order.SkuIds.Count() == 0 || string.IsNullOrEmpty(order.SkuIds.ElementAt(0))) { return(SubmitOrderResult.NoSkuId); } if (!_locker.Keys.Contains(order.SkuIds.ElementAt(0))) { return(SubmitOrderResult.NoLimit); } string skuid = order.SkuIds.ElementAt(0); lock (_locker[skuid])//锁库存 { int sellcount = int.Parse(Cache.Get(LIMIT_COUNT_TAG + skuid).ToString()); int total = int.Parse(Cache.Get(LIMIT_TOTAL_TAG + skuid).ToString()); int buy = order.Counts.ElementAt(0); if (sellcount + buy > total)//判断是否超卖 { return(SubmitOrderResult.SoldOut); } sellcount = sellcount + buy; Cache.Insert(LIMIT_COUNT_TAG + skuid, sellcount); //更新库存 OrderIdentity myorder = new OrderIdentity(); //给预约单加标识 myorder.Id = Guid.NewGuid().ToString(); myorder.Order = order; myorder.State = OrderState.Untreated; myorder.Message = "预约单正在处理"; id = myorder.Id; AddOrder(myorder); Cache.Send(LIMIT_LIST_TAG + skuid, myorder);//发消息后台处理 return(SubmitOrderResult.Success); } }
public object PostSubmitFightGroupOrder(OrderSubmitFightGroupOrderModel value) { this.CheckUserLogin(); if (value.CapitalAmount > new Decimal(0) && !string.IsNullOrEmpty(value.PayPwd) && !MemberApplication.VerificationPayPwd(this.CurrentUser.Id, value.PayPwd)) { return((object)this.Json(new { Success = "false", Msg = "预付款支付密码错误" })); } string skuId = value.skuId; long count = value.count; long recieveAddressId = value.recieveAddressId; long groupActionId = value.GroupActionId; long groupId = value.GroupId; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; string invoiceCode = value.invoiceCode; string orderRemarks = ""; List <FightGroupOrderJoinStatus> list = new List <FightGroupOrderJoinStatus>() { FightGroupOrderJoinStatus.Ongoing, FightGroupOrderJoinStatus.JoinSuccess }; FightGroupActiveInfo active = Instance <IFightGroupService> .Create.GetActive(groupActionId, false, false, true); long num = count; int? limitQuantity = active.LimitQuantity; if ((num <= (long)limitQuantity.GetValueOrDefault() ? 0 : (limitQuantity.HasValue ? 1 : 0)) != 0) { return((object)this.Json(new { Success = "false", Msg = string.Format("每人限购数量:{0}!", (object)active.LimitQuantity) })); } try { OrderCreateModel groupOrder = OrderApplication.GetGroupOrder(this.CurrentUser.Id, skuId, count.ToString(), recieveAddressId, invoiceType, invoiceTitle, invoiceCode, invoiceContext, groupActionId, PlatformType.Android, groupId, isCashOnDelivery, orderRemarks, new Decimal(0)); OrderShop[] orderShopArray = JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); groupOrder.OrderShops = orderShopArray; groupOrder.OrderRemarks = (IEnumerable <string>)Enumerable.ToArray <string>(Enumerable.Select <OrderShop, string>((IEnumerable <OrderShop>)orderShopArray, (Func <OrderShop, string>)(p => p.Remark))); OrderReturnModel orderReturnModel = OrderApplication.OrderSubmit(groupOrder, ""); this.AddVshopBuyNumber((IEnumerable <long>)orderReturnModel.OrderIds); return((object)this.Json(new { Success = "true", OrderIds = orderReturnModel.OrderIds })); } catch (HimallException ex) { return((object)this.Json(new { Success = "false", Msg = ex.Message })); } catch (Exception ex) { return((object)this.Json(new { Success = "false", Msg = "提交订单异常" })); } }
public object PostSubmitOrderByCart(OrderSubmitOrderByCartModel value) { this.CheckUserLogin(); if (value.CapitalAmount > new Decimal(0) && !string.IsNullOrEmpty(value.PayPwd) && !MemberApplication.VerificationPayPwd(this.CurrentUser.Id, value.PayPwd)) { return((object)this.Json(new { Success = "false", Msg = "预付款支付密码错误" })); } string cartItemIds = value.cartItemIds; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; OrderCreateModel model = new OrderCreateModel(); IOrderService create = Instance <IOrderService> .Create; model.PlatformType = PlatformType.Android; model.CurrentUser = this.CurrentUser; model.ReceiveAddressId = recieveAddressId; model.Integral = integral; model.Capital = value.CapitalAmount; model.IsCashOnDelivery = isCashOnDelivery; model.Invoice = (InvoiceType)invoiceType; model.InvoiceContext = invoiceContext; model.InvoiceTitle = invoiceTitle; model.InvoiceCode = value.invoiceCode; OrderShop[] orderShopArray = JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); model.OrderShops = orderShopArray; model.OrderRemarks = (IEnumerable <string>)Enumerable.ToArray <string>(Enumerable.Select <OrderShop, string>((IEnumerable <OrderShop>)orderShopArray, (Func <OrderShop, string>)(p => p.Remark))); try { long[] numArray = Enumerable.ToArray <long>(Enumerable.Select <string, long>(Enumerable.Where <string>((IEnumerable <string>)cartItemIds.Split(','), (Func <string, bool>)(d => !string.IsNullOrWhiteSpace(d))), (Func <string, long>)(item => long.Parse(item)))); IQueryable <ShoppingCartItem> cartItems = CartApplication.GetCartItems((IEnumerable <long>)numArray); model.SkuIds = (IEnumerable <string>)Enumerable.ToList <string>((IEnumerable <string>)Queryable.Select <ShoppingCartItem, string>(cartItems, (Expression <Func <ShoppingCartItem, string> >)(e => e.SkuId))); model.Counts = (IEnumerable <int>)Enumerable.ToList <int>((IEnumerable <int>)Queryable.Select <ShoppingCartItem, int>(cartItems, (Expression <Func <ShoppingCartItem, int> >)(e => e.Quantity))); model.CartItemIds = numArray; model.CouponIdsStr = OrderHelper.ConvertUsedCoupon(couponIds); List <OrderInfo> order = create.CreateOrder(model); IEnumerable <long> enumerable = (IEnumerable <long>)Enumerable.ToArray <long>(Enumerable.Select <OrderInfo, long>((IEnumerable <OrderInfo>)order, (Func <OrderInfo, long>)(item => item.Id))); Decimal num = Enumerable.Sum <OrderInfo>((IEnumerable <OrderInfo>)order, (Func <OrderInfo, Decimal>)(item => item.OrderTotalAmount)); string str = "false"; if (num == new Decimal(0)) { str = "true"; } return((object)this.Json(new { Success = "true", OrderIds = enumerable, RealTotalIsZero = str })); } catch (HimallException ex) { return((object)this.Json(new { Success = "false", Msg = ex.Message })); } catch (Exception ex) { return((object)this.Json(new { Success = "false", Msg = "提交订单异常" })); } }
public object PostSubmitOrder(OrderSubmitOrderModel value) { this.CheckUserLogin(); if (value.CapitalAmount > new Decimal(0) && !string.IsNullOrEmpty(value.PayPwd) && !MemberApplication.VerificationPayPwd(this.CurrentUser.Id, value.PayPwd)) { return((object)this.Json(new { Success = "false", Msg = "预付款支付密码错误" })); } string skuIds = value.skuIds; string counts = value.counts; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; string str = string.Empty; OrderCreateModel model = new OrderCreateModel(); IOrderService create1 = Instance <IOrderService> .Create; IProductService create2 = Instance <IProductService> .Create; IEnumerable <string> source = Enumerable.Select <string, string>((IEnumerable <string>)skuIds.Split(','), (Func <string, string>)(item => item.ToString())); IEnumerable <int> enumerable = Enumerable.Select <string, int>((IEnumerable <string>)counts.Split(','), (Func <string, int>)(item => int.Parse(item))); model.CouponIdsStr = OrderHelper.ConvertUsedCoupon(couponIds); model.PlatformType = PlatformType.Android; model.CurrentUser = this.CurrentUser; model.ReceiveAddressId = recieveAddressId; model.SkuIds = source; model.Counts = enumerable; model.Integral = integral; model.Capital = value.CapitalAmount; model.IsCashOnDelivery = isCashOnDelivery; model.Invoice = (InvoiceType)invoiceType; model.InvoiceContext = invoiceContext; model.InvoiceTitle = invoiceTitle; model.InvoiceCode = value.invoiceCode; OrderShop[] orderShopArray = JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); model.OrderShops = orderShopArray; model.OrderRemarks = (IEnumerable <string>)Enumerable.ToArray <string>(Enumerable.Select <OrderShop, string>((IEnumerable <OrderShop>)orderShopArray, (Func <OrderShop, string>)(p => p.Remark))); model.IsShopbranchOrder = true; try { if (Enumerable.Count <string>(source) == 1) { string skuId = Enumerable.ElementAt <string>(source, 0); if (!string.IsNullOrWhiteSpace(skuId)) { bool flag = Instance <ILimitTimeBuyService> .Create.IsLimitTimeMarketItem(create2.GetSku(skuId).ProductId); model.IslimitBuy = flag; } } List <OrderInfo> order = create1.CreateOrder(model); IEnumerable <long> orderIds = (IEnumerable <long>)Enumerable.ToArray <long>(Enumerable.Select <OrderInfo, long>((IEnumerable <OrderInfo>)order, (Func <OrderInfo, long>)(item => item.Id))); Decimal num = Enumerable.Sum <OrderInfo>((IEnumerable <OrderInfo>)order, (Func <OrderInfo, Decimal>)(item => item.OrderTotalAmount)); this.AddVshopBuyNumber(orderIds); return((object)this.Json(new { Success = "true", OrderIds = orderIds, RealTotalIsZero = num == new Decimal(0) })); } catch (HimallException ex) { return((object)this.Json(new { Success = "false", Msg = ex.Message })); } catch (Exception ex) { return((object)this.Json(new { Success = "false", Msg = "提交订单异常" })); } }
/// <summary> /// 判断预存款支付密码 /// </summary> /// <param name="pwd"></param> /// <returns></returns> public JsonResult ValidPayPwd(string pwd) { var ret = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); return(Json <dynamic>(success: ret, msg: "密码错误")); }
/// <summary> /// 提现申请 /// </summary> /// <param name="apply"></param> public static void ApplyWithdraw(DistributionApplyWithdraw apply) { if (!MemberApplication.VerificationPayPwd(apply.MemberId, apply.Password)) { throw new MallException("交易密码错误"); } if (apply.Amount > SiteSettingApplication.SiteSettings.DistributorWithdrawMaxLimit) { throw new MallException("超过最大提现额限"); } if (apply.Amount < SiteSettingApplication.SiteSettings.DistributorWithdrawMinLimit) { throw new MallException("小于最低提现额限"); } var distributor = Service.GetDistributor(apply.MemberId); if (apply.Amount > distributor.Balance) { throw new MallException("超过最多提现金额"); } var settings = SiteSettingApplication.SiteSettings; if (apply.Type == DistributionWithdrawType.Alipay) { if (!settings.DistributorWithdrawTypes.ToLower().Contains("alipay")) { throw new MallException("暂不支持支付宝提现"); } if (string.IsNullOrEmpty(apply.WithdrawAccount)) { throw new MallException("支付宝账户不可为空"); } if (string.IsNullOrEmpty(apply.WithdrawName)) { throw new MallException("真实姓名不可为空"); } } else if (apply.Type == DistributionWithdrawType.WeChat) { if (!settings.DistributorWithdrawTypes.ToLower().Contains("wechat")) { throw new MallException("暂不支持微信提现"); } if (string.IsNullOrEmpty(apply.WithdrawAccount)) { throw new MallException("尚未绑定微信,请先绑定微信账户"); } } var info = new DistributionWithdrawInfo { Amount = apply.Amount, WithdrawType = apply.Type, MemberId = apply.MemberId, WithdrawAccount = apply.WithdrawAccount, WithdrawName = apply.WithdrawName }; Service.ApplyWithdraw(info); //发送消息 var member = MemberApplication.GetMember(apply.MemberId); var message = new MessageWithDrawInfo(); message.UserName = member != null ? member.UserName : ""; message.Amount = info.Amount; message.ApplyType = info.WithdrawType.GetHashCode(); message.ApplyTime = info.ApplyTime; message.Remark = info.Remark; message.SiteName = SiteSettingApplication.SiteSettings.SiteName; Task.Factory.StartNew(() => MessageApplication.SendMessageOnDistributionMemberWithDrawApply(apply.MemberId, message)); //预付款提现,自动审核 if (info.WithdrawType == DistributionWithdrawType.Capital) { AuditingWithdraw(info.Id, "System", "预存款提现,自动审核"); } }
public object PostSubmitOrderByCart(OrderSubmitOrderByCartModel value) { CheckUserLogin(); if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd)) { var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd); if (!flag) { throw new MallApiException("预存款支付密码错误"); } } string cartItemIds = value.cartItemIds; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; IEnumerable<long> orderIds; CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject<OrderShop[]>(value.jsonOrderShops); OrderPostModel model = new OrderPostModel(); model.CurrentUser = CurrentUser; model.PlatformType = PlatformType.Android.GetHashCode(); model.IsShopbranchOrder = true; model.RecieveAddressId = recieveAddressId; model.Integral = integral; model.Capital = value.CapitalAmount; model.IsCashOnDelivery = isCashOnDelivery; //model.InvoiceType = invoiceType; //model.InvoiceContext = invoiceContext; //model.InvoiceTitle = invoiceTitle; //model.InvoiceCode = value.invoiceCode; model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提 model.CartItemIds = cartItemIds; model.IsShopbranchOrder = true; if (model.OrderShops == null || model.OrderShops.Count() < 1) { throw new MallApiException("订单信息错误"); } try { var cartItemIdsArr = cartItemIds.Split(',').Where(d => !string.IsNullOrWhiteSpace(d)).Select(item => long.Parse(item)).ToArray(); //根据购物车项补充sku数据 var cartItems = CartApplication.GetCartItems(cartItemIdsArr); List<OrderSku> skus = new List<OrderSku>(); foreach (var _item in cartItems) { OrderSku _tmp = new OrderSku(); _tmp.SkuId = _item.SkuId; _tmp.Count = _item.Quantity; skus.Add(_tmp); } model.CouponIds = couponIds; model.OrderShops[0].OrderSkus = skus.ToArray(); var result = OrderApplication.SubmitOrder(model, value.PayPwd); orderIds = result.OrderIds; decimal orderTotals = result.OrderTotal; var _result = new { success = true, OrderIds = orderIds, RealTotalIsZero = orderTotals == 0 }; return _result; } catch (MallException he) { return ErrorResult(he.Message); } catch (Exception ex) { return ErrorResult("提交订单异常"); } }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } if (applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !SiteSettings.Withdraw_AlipayEnable) { throw new HimallException("不支持支付宝提现方式!"); } var balance = MemberCapitalApplication.GetBalanceByUserId(UserId); if (amount > balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid) && applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { openid = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER_OpenID); } if (string.IsNullOrWhiteSpace(nickname) && applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { throw new HimallException("数据异常,真实姓名不可为空!"); } if (!string.IsNullOrWhiteSpace(openid) && applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { openid = Core.Helper.SecureHelper.AESDecrypt(openid, "Mobile"); var siteSetting = SiteSettingApplication.SiteSettings; if (!(string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))) { string token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, openid); if (userinfo != null) { nickname = userinfo.nickname; } } } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } Himall.Entities.ApplyWithDrawInfo model = new Himall.Entities.ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = (CommonModel.UserWithdrawType)applyType }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
public object PostSubmitOrder(OrderSubmitOrderModel value) { CheckUserLogin(); if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd)) { var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd); if (!flag) { throw new MallApiException("预存款支付密码错误"); } } string skuIds = value.skuIds; string counts = value.counts; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; //end string orderRemarks = string.Empty;//value.orderRemarks;//订单备注 OrderCreateModel model = new OrderCreateModel(); var orderService = ServiceProvider.Instance<IOrderService>.Create; var productService = ServiceProvider.Instance<IProductService>.Create; var skuIdArr = skuIds.Split(',').Select(item => item.ToString()); var countArr = counts.Split(',').Select(item => int.Parse(item)); model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds); IEnumerable<long> orderIds; model.PlatformType = PlatformType.Android; model.CurrentUser = CurrentUser; model.ReceiveAddressId = recieveAddressId; model.SkuIds = skuIdArr; model.Counts = countArr; model.Integral = integral; model.Capital = value.CapitalAmount; model.IsCashOnDelivery = isCashOnDelivery; model.Invoice = (InvoiceType)invoiceType; model.InvoiceContext = invoiceContext; model.InvoiceTitle = invoiceTitle; model.InvoiceCode = value.invoiceCode; CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject<OrderShop[]>(value.jsonOrderShops); CommonModel.VirtualProductItem[] VirtualProductItems = Newtonsoft.Json.JsonConvert.DeserializeObject<VirtualProductItem[]>(value.VirtualProductItems); model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提 model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray(); //end model.IsShopbranchOrder = true; model.IsVirtual = value.ProductType == 1; if (model.IsVirtual && skuIdArr.Count() > 0) { var skuInfo = ProductManagerApplication.GetSKU(skuIdArr.FirstOrDefault()); if (skuInfo != null) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(skuInfo.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { return ErrorResult("该虚拟商品已过期,不支持下单"); } } } try { //处理限时购 if (skuIdArr.Count() == 1) { var skuid = skuIdArr.ElementAt(0); if (!string.IsNullOrWhiteSpace(skuid)) { var sku = productService.GetSku(skuid); bool isltmbuy = ServiceProvider.Instance<ILimitTimeBuyService>.Create.IsLimitTimeMarketItem(sku.ProductId); model.IslimitBuy = isltmbuy;//标识为限时购计算价格按限时购价格核算 } } var orders = orderService.CreateOrder(model); orderIds = orders.Select(item => item.Id).ToArray(); decimal orderTotals = orders.Sum(item => item.OrderTotalAmount); //orderIds = orderService.CreateOrder(CurrentUser.Id, skuIdArr, countArr, recieveAddressId, PlatformType); AddVshopBuyNumber(orderIds);//添加微店购买数量 #region 处理虚拟订单项 if (value.ProductType == 1 && VirtualProductItems != null && VirtualProductItems.Count() > 0) { var orderId = orderIds.FirstOrDefault(); if (orderId > 0) { var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault(); if (orderItemInfo != null) { var list = VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项 list.ForEach(a => { a.OrderId = orderId; a.OrderItemId = orderItemInfo.Id; if (a.VirtualProductItemType == (sbyte)ProductInfo.VirtualProductItemType.Picture) { a.Content = MoveImages(a.Content, CurrentUser.Id); } }); if (list.Count > 0) { OrderApplication.AddVirtualOrderItemInfo(list); } } } } #endregion var _result = new { success = true, OrderIds = orderIds, RealTotalIsZero = orderTotals == 0 }; return _result; } catch (MallException he) { return ErrorResult(he.Message); } catch (Exception ex) { return ErrorResult("提交订单异常"); } }
/// <summary> /// 判断预存款支付密码 /// </summary> /// <param name="pwd"></param> /// <returns></returns> public JsonResult ValidPayPwd(string pwd) { var ret = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); return(Json(new { success = ret, msg = "密码错误" })); }
public object PostApplyWithDraw(MemberCapitalApplyWithDrawModel para) { CheckUserLogin(); if (para == null) { para = new MemberCapitalApplyWithDrawModel(); } var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, para.pwd); var sitesetting = SiteSettingApplication.SiteSettings; if (para.applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !sitesetting.Withdraw_AlipayEnable) { return(Json(ErrorResult <bool>("不支持支付宝提现方式"))); } if (!success) { return(Json(ErrorResult <bool>("支付密码不对,请重新输入"))); } var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); if (para.amount > balance) { return(Json(ErrorResult <bool>("提现金额不能超出可用金额!"))); } if (para.amount <= 0) { return(Json(ErrorResult <bool>("提现金额不能小于等于0!"))); } if (string.IsNullOrWhiteSpace(para.openId) && para.applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, PLUGIN_OAUTH_WEIXIN); if (mo != null && !string.IsNullOrWhiteSpace(mo.OpenId)) { para.openId = mo.OpenId; } } if (string.IsNullOrWhiteSpace(para.nickname) && para.applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { return(Json(ErrorResult <bool>("数据异常,真实姓名不可为空!"))); } if (!string.IsNullOrWhiteSpace(para.openId) && para.applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { //para.openid = Core.Helper.SecureHelper.AESDecrypt(para.openid, "Mobile"); if (!string.IsNullOrWhiteSpace(sitesetting.WeixinAppletId) && !string.IsNullOrWhiteSpace(sitesetting.WeixinAppletSecret)) { string token = AccessTokenContainer.TryGetAccessToken(sitesetting.WeixinAppletId, sitesetting.WeixinAppletSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, para.openId); if (userinfo != null) { para.nickname = userinfo.nickname; } } } if (string.IsNullOrWhiteSpace(para.openId)) { return(Json(ErrorResult <bool>("数据异常,OpenId或收款账号不可为空!"))); } Mall.Entities.ApplyWithdrawInfo model = new Mall.Entities.ApplyWithdrawInfo() { ApplyAmount = para.amount, ApplyStatus = Mall.Entities.ApplyWithdrawInfo.ApplyWithdrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = para.openId, NickName = para.nickname, ApplyType = (CommonModel.UserWithdrawType)para.applyType }; MemberCapitalApplication.AddWithDrawApply(model); return(Json(true)); }
/// <summary> /// 购物车方式提交的订单 /// </summary> /// <param name="value">数据</param> public object PostSubmitOrderByCart(OrderSubmitOrderByCartModel value) { CheckUserLogin(); if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd)) { var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd); if (!flag) { return(ErrorResult("预存款支付密码错误")); } } string cartItemIds = value.cartItemIds; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; decimal capitalAmount = value.CapitalAmount; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; string invoiceCode = value.invoiceCode; OrderCreateModel model = new OrderCreateModel(); var orderService = ServiceProvider.Instance <IOrderService> .Create; IEnumerable <long> orderIds; model.PlatformType = PlatformType.Android; model.CurrentUser = CurrentUser; model.ReceiveAddressId = recieveAddressId; model.Integral = integral; model.Capital = capitalAmount;//预存款 model.IsCashOnDelivery = isCashOnDelivery; model.Invoice = (InvoiceType)invoiceType; model.InvoiceContext = invoiceContext; model.InvoiceTitle = invoiceTitle; model.InvoiceCode = invoiceCode; //end CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提 model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray(); try { var cartItemIdsArr = cartItemIds.Split(',').Select(item => long.Parse(item)).ToArray(); //根据购物车项补充sku数据 var cartItems = CartApplication.GetCartItems(cartItemIdsArr); model.SkuIds = cartItems.Select(e => e.SkuId).ToList(); model.Counts = cartItems.Select(e => e.Quantity).ToList(); model.CartItemIds = cartItemIdsArr; model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds); var orders = orderService.CreateOrder(model); orderIds = orders.Select(item => item.Id).ToArray(); decimal orderTotals = orders.Where(d => d.PaymentType != Entities.OrderInfo.PaymentTypes.CashOnDelivery).Sum(item => item.OrderTotalAmount); return(new { success = true, OrderIds = orderIds, RealTotalIsZero = orderTotals == 0 }); } catch (HimallException he) { return(ErrorResult(he.Message)); } catch (Exception ex) { return(ErrorResult("提交订单异常")); } }