public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd)
        {
            if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null)
            {
                throw new HimallException("支付密码不对,请重新输入!");
            }
            CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);
            decimal     num         = amount;
            decimal?    balance     = capitalInfo.Balance;

            if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue))
            {
                throw new HimallException("提现金额不能超出可用金额!");
            }
            ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo()
            {
                ApplyAmount = amount,
                ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm,
                ApplyTime   = DateTime.Now,
                MemId       = base.CurrentUser.Id,
                OpenId      = openid,
                NickName    = nickname
            };

            ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo);
            return(Json(new { success = true }));
        }
        public void RefuseApplyWithDraw(long id, ApplyWithDrawInfo.ApplyWithDrawStatus status, string opuser, string remark)
        {
            decimal?          nullable;
            ApplyWithDrawInfo applyWithDrawInfo = context.ApplyWithDrawInfo.FirstOrDefault((ApplyWithDrawInfo e) => e.Id == id);

            applyWithDrawInfo.ApplyStatus = status;
            applyWithDrawInfo.OpUser      = opuser;
            applyWithDrawInfo.Remark      = remark;
            applyWithDrawInfo.ConfirmTime = new DateTime?(DateTime.Now);
            CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == applyWithDrawInfo.MemId);
            decimal?    balance     = capitalInfo.Balance;

            capitalInfo.Balance = new decimal?(balance.Value + applyWithDrawInfo.ApplyAmount);
            CapitalInfo capitalInfo1 = capitalInfo;
            decimal?    freezeAmount = capitalInfo.FreezeAmount;
            decimal     applyAmount  = applyWithDrawInfo.ApplyAmount;

            if (freezeAmount.HasValue)
            {
                nullable = new decimal?(freezeAmount.GetValueOrDefault() - applyAmount);
            }
            else
            {
                nullable = null;
            }
            capitalInfo1.FreezeAmount = nullable;
            context.SaveChanges();
        }
Beispiel #3
0
        public object GetCapital()
        {
            CheckUserLogin();
            var capital         = MemberCapitalApplication.GetCapitalInfo(CurrentUser.Id);
            var sitesetting     = SiteSettingApplication.SiteSettings;
            var redPacketAmount = 0M;

            if (capital != null)
            {
                //redPacketAmount = capital.Mall_CapitalDetail.Where(e => e.SourceType == Mall.Model.CapitalDetailInfo.CapitalDetailType.RedPacket).Sum(e => e.Amount);
                redPacketAmount = MemberCapitalApplication.GetSumRedPacket(capital.Id);
            }
            else
            {
                capital = new CapitalInfo();
            }
            bool canWithDraw = MemberApplication.CanWithdraw(CurrentUser.Id);

            return(Json(new
            {
                success = true,
                Balance = capital?.Balance ?? 0,
                RedPacketAmount = redPacketAmount,
                PresentAmount = capital?.PresentAmount ?? 0,
                ChargeAmount = capital?.ChargeAmount ?? 0,
                WithDrawMinimum = sitesetting.WithDrawMinimum,
                WithDrawMaximum = sitesetting.WithDrawMaximum,
                canWithDraw = canWithDraw,
                isOpen = sitesetting.IsOpenRechargePresent,
                rule = RechargePresentRuleApplication.GetRules()
            }));
        }
Beispiel #4
0
        public ActionMessage editEmloyee(int id, CapitalInfo _capital)
        {
            ActionMessage ret = new ActionMessage();

            if (_capital.CapitalName.Trim() == string.Empty)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error";
                ret.err.msgString = "Chưa nhập tên";
            }
            else
            {
                SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    {
                        try
                        {
                            CapitalDataLayer.GetInstance().UpdateCapital(connection, _capital);
                            ret.isSuccess = true;
                        }
                        catch (Exception ex)
                        {
                            ret.isSuccess     = false;
                            ret.err.msgCode   = "Internal Error";
                            ret.err.msgString = ex.ToString();
                        }
                    }
                }
            }
            return(ret);
        }
Beispiel #5
0
        public ActionResult Index()
        {
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            CapitalInfo           capitalInfo          = memberCapitalService.GetCapitalInfo(base.CurrentUser.Id);

            return(View(capitalInfo));
        }
Beispiel #6
0
        public ActionMessage createCapital(CapitalInfo _capital)
        {
            ActionMessage ret = new ActionMessage();

            if (_capital.CapitalName.Trim() == string.Empty)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error";
                ret.err.msgString = "Chưa nhập tên";
            }
            //else if (_department.SourceID == -1)
            //{
            //}
            else
            {
                SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        CapitalDataLayer.GetInstance().InsertCapital(connection, _capital);
                        ret.isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        ret.isSuccess     = false;
                        ret.err.msgCode   = "Internal Error";
                        ret.err.msgString = ex.ToString();
                    }
                }
            }
            return(ret);
        }
        public ActionResult ApplyWithDraw()
        {
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();
            //if (string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) || string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret))
            //{
            //    throw new HimallException("未配置公众号参数");
            //}
            ////string str = "";//AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false);
            //SceneModel sceneModel = new SceneModel(QR_SCENE_Type.WithDraw)
            //{
            //    Object = base.CurrentSellerManager.Id.ToString()
            //};
            int num = 0;//(new SceneHelper()).SetModel(sceneModel, 600);

            //CreateQrCodeResult createQrCodeResult = QrCodeApi.Create(str, 300, num, 10000);
            ViewBag.ticket  = "";//createQrCodeResult.ticket;
            ViewBag.Sceneid = num;
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            CapitalInfo           capitalInfo          = memberCapitalService.GetCapitalInfoByManagerId(base.CurrentSellerManager.Id);

            if (capitalInfo == null)
            {
                ViewBag.ApplyWithMoney = 0;
            }
            else
            {
                dynamic viewBag = base.ViewBag;
                decimal?balance = capitalInfo.Balance;
                viewBag.ApplyWithMoney = balance.Value;
            }
            base.ViewBag.IsSetPwd = (string.IsNullOrWhiteSpace(base.CurrentSellerManager.Password) ? false : true);
            return(View());
        }
        public JsonResult AddStatisticsMoneyLog(int TradingType, decimal TradingPrice, string OrderNum, int PayType, string TypeID)
        {
            IStatisticsMoneyService isms = ServiceHelper.Create <IStatisticsMoneyService>();
            decimal         moneybynow   = isms.GetMoneyByUidType(base.CurrentSellerManager.Id, 2);
            StatisticsMoney entity       = new StatisticsMoney
            {
                UserId       = base.CurrentSellerManager.Id,
                UserName     = base.CurrentSellerManager.UserName,
                UserType     = 2,
                TradingTime  = DateTime.Now,
                TradingType  = TradingType,
                TradingPrice = TradingPrice,
                OrderNum     = OrderNum,
                PayType      = PayType,
                Balance      = moneybynow + TradingPrice,
                BalanceAble  = moneybynow + TradingPrice
            };

            isms.Add(entity);
            CapitalInfo cinfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfoByManagerId(base.CurrentSellerManager.Id);

            if (cinfo != null)
            {
                cinfo.Balance += TradingPrice;
                ServiceHelper.Create <IMemberCapitalService>().UpdateCapitalAmount(cinfo.Id, 0, cinfo.Balance, 0, 0, base.CurrentSellerManager.Id);
            }
            return(Json(new { Successful = true }));
        }
Beispiel #9
0
        public ActionResult Index()
        {
            if (base.Request.Url.AbsolutePath.EndsWith("/Capital/Index", StringComparison.OrdinalIgnoreCase) || base.Request.Url.AbsolutePath.EndsWith("/Capital", StringComparison.OrdinalIgnoreCase))
            {
                return(this.Redirect(base.Url.RouteUrl("PayRoute") + "?area=mobile&platform=" + base.PlatformType.ToString() + "&controller=Capital&action=Index"));
            }
            CapitalInfo capitalInfo = this._iMemberCapitalService.GetCapitalInfo(base.CurrentUser.Id);
            decimal     num         = 0M;

            if (capitalInfo != null)
            {
                num = (from e in capitalInfo.Himall_CapitalDetail
                       where e.SourceType == CapitalDetailInfo.CapitalDetailType.RedPacket
                       select e).Sum <CapitalDetailInfo>((Func <CapitalDetailInfo, decimal>)(e => e.Amount));
                ((dynamic)base.ViewBag).CapitalDetails = (from e in capitalInfo.Himall_CapitalDetail
                                                          orderby e.CreateTime descending
                                                          select e).Take <CapitalDetailInfo>(15);
            }
            ((dynamic)base.ViewBag).RedPacketAmount = num;
            ((dynamic)base.ViewBag).IsSetPwd        = !string.IsNullOrWhiteSpace(base.CurrentUser.PayPwd);
            SiteSettingsInfo siteSettings = this._iSiteSettingService.GetSiteSettings();

            ((dynamic)base.ViewBag).WithDrawMinimum = siteSettings.WithDrawMinimum;
            ((dynamic)base.ViewBag).WithDrawMaximum = siteSettings.WithDrawMaximum;
            return(base.View(capitalInfo));
        }
        /*	public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd)   //仅仅支持微信支付
         *      {
         *              if (ServiceHelper.Create<IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null)
         *              {
         *                      throw new HimallException("支付密码不对,请重新输入!");
         *              }
         *              CapitalInfo capitalInfo = ServiceHelper.Create<IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);
         *              decimal num = amount;
         *              decimal? balance = capitalInfo.Balance;
         *              if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue))
         *              {
         *                      throw new HimallException("提现金额不能超出可用金额!");
         *              }
         *              ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo()
         *              {
         *                      ApplyAmount = amount,
         *                      ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm,
         *                      ApplyTime = DateTime.Now,
         *                      MemId = base.CurrentUser.Id,
         *                      OpenId = openid,
         *                      NickName = nickname
         *              };
         *              ServiceHelper.Create<IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo);
         *              return Json(new { success = true });
         *      }*/

        public JsonResult ApplyWithDrawSubmit(string withdrawtype, string myaccount, string nickname, decimal amount, string pwd)   //扩展版本(提现方式、账号、人名)
        {
            //if (withdrawtype == null)
            //    return Json(new { success = true });

            if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null)
            {
                // throw new HimallException("支付密码不对,请重新输入!");
                return(Json(new { success = false, msg = "Payment pwd error,please try again!" }));
            }
            CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);
            decimal     num         = amount;
            decimal?    balance     = capitalInfo.Balance;

            if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue))
            {
                throw new HimallException("withdraw amount exceed Balance!");
            }
            ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo()
            {
                ApplyAmount  = amount,
                ApplyStatus  = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm,
                ApplyTime    = DateTime.Now,
                MemId        = base.CurrentUser.Id,
                AccountId    = 0,
                WithdrawType = withdrawtype,
                Myaccount    = myaccount,
                NickName     = nickname,
            };

            ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo);
            return(base.Json(new { success = true }));
        }
Beispiel #11
0
        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 void AddCapitalInfo(CapitalInfo cinfo)
 {
     if (cinfo == null)
     {
         return;
     }
     context.CapitalInfo.Add(cinfo);
     context.SaveChanges();
 }
        /// <summary>
        /// 充值成功
        /// </summary>
        /// <param name="chargeDetailId"></param>
        public void ChargeSuccess(long chargeDetailId)
        {
            var chargeDetail = this.Context.ChargeDetailInfo.FirstOrDefault(p => p.Id == chargeDetailId);

            if (chargeDetail == null)
            {
                return;
            }

            chargeDetail.ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.ChargeSuccess;

            var capital = this.Context.CapitalInfo.FirstOrDefault(p => p.MemId == chargeDetail.MemId);

            if (capital == null)
            {
                CapitalInfo newCapital = new CapitalInfo()
                {
                    Balance              = 0,
                    ChargeAmount         = 0,
                    MemId                = chargeDetail.MemId,
                    Himall_CapitalDetail = new List <CapitalDetailInfo> {
                        new CapitalDetailInfo {
                            Id         = CreateCode(CapitalDetailInfo.CapitalDetailType.ChargeAmount),
                            Amount     = chargeDetail.ChargeAmount,
                            CreateTime = DateTime.Now,
                            SourceType = CapitalDetailInfo.CapitalDetailType.ChargeAmount,
                            SourceData = chargeDetailId.ToString()
                        }
                    }
                };
                this.Context.CapitalInfo.Add(newCapital);
            }
            else
            {
                var capitalDetail = this.Context.CapitalDetailInfo.FirstOrDefault(e => e.SourceData == chargeDetailId.ToString() && e.SourceType == CapitalDetailInfo.CapitalDetailType.ChargeAmount);
                if (capitalDetail != null)//已经处理过直接返回
                {
                    return;
                }
                this.Context.CapitalDetailInfo.Add(new CapitalDetailInfo()
                {
                    Id         = CreateCode(CapitalDetailInfo.CapitalDetailType.ChargeAmount),
                    Amount     = chargeDetail.ChargeAmount,
                    CreateTime = DateTime.Now,
                    SourceType = CapitalDetailInfo.CapitalDetailType.ChargeAmount,
                    SourceData = chargeDetailId.ToString(),
                    CapitalID  = capital.Id
                });
            }

            this.Context.SaveChanges();

            var sql = "UPDATE Himall_Capital SET Balance=Balance+@p1,ChargeAmount=ChargeAmount+@p1 WHERE MemId=@p0";

            this.Context.Database.ExecuteSqlCommand(sql, capital.MemId, chargeDetail.ChargeAmount);
        }
Beispiel #14
0
        public CapitalInfo getCapitalbyId(int _ID)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                List <CapitalInfo> ListDepartment = CapitalDataLayer.GetInstance().GetAllCapitalbyID(connection, _ID);
                CapitalInfo        findCapital    = ListDepartment.First();
                return(findCapital);
            }
        }
        private void InitCapital(long memberId)
        {
            CapitalInfo newCapital = new CapitalInfo()
            {
                Balance      = 0,
                ChargeAmount = 0,
                MemId        = memberId,
                FreezeAmount = 0
            };

            DbFactory.Default.Add(newCapital);
        }
Beispiel #16
0
        public void UpdateCapital(SqlConnection connection, CapitalInfo _capital)
        {
            using (var command = new SqlCommand("UPDATE tbl_Capital \n" +
                                                "SET CapitalName = @CapitalName  \n" +
                                                "WHERE (CapitalID = @CapitalID)", connection))
            {
                AddSqlParameter(command, "@CapitalID", _capital.CapitalID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@CapitalName", _capital.CapitalName, System.Data.SqlDbType.NVarChar);
                WriteLogExecutingCommand(command);

                command.ExecuteScalar();
            }
        }
Beispiel #17
0
        public int InsertCapital(SqlConnection connection, CapitalInfo _capital)
        {
            int lastestInserted = 0;

            using (var command = new SqlCommand("Insert into [dbo].[tbl_Capital] (CapitalName)" +
                                                "VALUES(@CapitalName)  ", connection))
            {
                AddSqlParameter(command, "@CapitalName", _capital.CapitalName, System.Data.SqlDbType.NVarChar);
                WriteLogExecutingCommand(command);
                command.ExecuteScalar();
            }

            return(lastestInserted);
        }
        public ActionResult ApplyWithDraw()
        {
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();

            if (string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) || string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret))
            {
                throw new HimallException("Can not Set WeiXin AppId");
            }
            string     str        = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, true);
            SceneModel sceneModel = new SceneModel(QR_SCENE_Type.WithDraw)
            {
                Object = base.CurrentUser.Id.ToString()
            };
            int num = (new SceneHelper()).SetModel(sceneModel, 600);
            CreateQrCodeResult createQrCodeResult = QrCodeApi.Create(str, 300, num, 10000);

            ViewBag.ticket  = createQrCodeResult.ticket;
            ViewBag.Sceneid = num;
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            CapitalInfo           capitalInfo          = memberCapitalService.GetCapitalInfo(base.CurrentUser.Id);

            if (capitalInfo == null)
            {
                ViewBag.ApplyWithMoney = 0;
            }
            else
            {
                dynamic viewBag = base.ViewBag;
                decimal?balance = capitalInfo.Balance;
                ViewBag.ApplyWithMoney = balance.Value;
            }
            string membersId = this.CurrentUser.UserName;
            IEnumerable <WithDrawInfo> WithDraws = ServiceHelper.Create <IWithDrawService>().GetWithDrawByMembersId(membersId);//因为UserName值唯一,所以没有登录账号ID去获取信息

            String[] Array = new String[WithDraws.Count()];
            int      i     = 0;

            foreach (var item in WithDraws)
            {
                Array[i] = item.WithdrawType + "【" + item.AccountNumber + "," + item.Name + "】";
                i++;
            }
            ViewBag.List = Array;
            ViewBag.Num  = Array.Length;


            base.ViewBag.IsSetPwd = (string.IsNullOrWhiteSpace(base.CurrentUser.PayPwd) ? false : true);
            return(View());
        }
Beispiel #19
0
        public JsonResult ApplyWithDrawSubmit(string nickname, decimal amount, string pwd)
        {
            if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null)
            {
                throw new HimallException("支付密码不对,请重新输入!");
            }
            CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);
            decimal     num         = amount;
            decimal?    balance     = capitalInfo.Balance;

            if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue))
            {
                throw new HimallException("提现金额不能超出可用金额!");
            }
            string cookie = WebHelper.GetCookie("Himall-User_OpenId");
            string empty  = string.Empty;

            if (string.IsNullOrWhiteSpace(cookie))
            {
                throw new HimallException("数据异常,OpenId不能为空!");
            }
            cookie = SecureHelper.AESDecrypt(cookie, "Mobile");
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();

            if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret))
            {
                //string str = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false);
                string str = CommonApi.GetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret).access_token;
                //
                WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(str, cookie);
                if (userInfo != null)
                {
                    empty = userInfo.nickname;
                }
            }
            ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo()
            {
                ApplyAmount = amount,
                ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm,
                ApplyTime   = DateTime.Now,
                MemId       = base.CurrentUser.Id,
                OpenId      = cookie,
                NickName    = empty
            };

            ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo);
            return(Json(new { success = true }));
        }
Beispiel #20
0
        public ActionMessage Post([FromBody] CapitalInfo _capital)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = CapitalServices.GetInstance().createCapital(_capital);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "001";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Beispiel #21
0
        public ActionMessage Put(int id, [FromBody] CapitalInfo _capital)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                CapitalServices.GetInstance().editEmloyee(id, _capital);
                ret.isSuccess = true;
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "001";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Beispiel #22
0
        // GET: Mobile/Capital
        public ActionResult Index()
        {
            CapitalIndexChargeModel result = new CapitalIndexChargeModel();

            //判断是否需要跳转到支付地址
            if (this.Request.Url.AbsolutePath.EndsWith("/Capital/Index", StringComparison.OrdinalIgnoreCase) || this.Request.Url.AbsolutePath.EndsWith("/Capital", StringComparison.OrdinalIgnoreCase))
            {
                return(Redirect(Url.RouteUrl("PayRoute") + "?area=mobile&platform=" + this.PlatformType.ToString() + "&controller=Capital&action=Index"));
            }

            var model           = MemberCapitalApplication.GetCapitalInfo(CurrentUser.Id);
            var redPacketAmount = 0M;

            if (model != null)
            {
                //redPacketAmount = model.Himall_CapitalDetail.Where(e => e.SourceType == Model.CapitalDetailInfo.CapitalDetailType.RedPacket).Sum(e => e.Amount);
                redPacketAmount       = MemberCapitalApplication.GetSumRedPacket(model.Id);
                result.CapitalDetails = MemberCapitalApplication.GetTopCapitalDetailList(model.Id, 15);
            }
            else
            {
                model = new CapitalInfo
                {
                    Balance       = 0,
                    ChargeAmount  = 0,
                    FreezeAmount  = 0,
                    MemId         = CurrentUser.Id,
                    PresentAmount = 0
                };
            }
            result.UserCaptialInfo         = model;
            result.IsEnableRechargePresent = SiteSettings.IsOpenRechargePresent;
            if (result.IsEnableRechargePresent)
            {
                result.RechargePresentRules = RechargePresentRuleApplication.GetRules();
            }

            result.RedPacketAmount = redPacketAmount;
            result.IsSetPwd        = string.IsNullOrWhiteSpace(CurrentUser.PayPwd) ? false : true;
            var siteSetting = SiteSettingApplication.SiteSettings;

            result.WithDrawMinimum = siteSetting.WithDrawMinimum;
            result.WithDrawMaximum = siteSetting.WithDrawMaximum;
            result.CanWithDraw     = MemberApplication.CanWithdraw(CurrentUser.Id);
            return(View(result));
        }
        public ActionResult CapitalCharge()
        {
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            CapitalInfo           capitalInfo          = memberCapitalService.GetCapitalInfoByManagerId(base.CurrentSellerManager.Id);

            if (capitalInfo == null)
            {
                capitalInfo = new CapitalInfo()
                {
                    MemId        = 0,
                    Balance      = 0,
                    FreezeAmount = 0,
                    ChargeAmount = 0,
                    ManageId     = base.CurrentSellerManager.Id
                };
                memberCapitalService.AddCapitalInfo(capitalInfo);
            }
            return(View(capitalInfo));
        }
Beispiel #24
0
        public List <CapitalInfo> GetByName(SqlConnection connection, string name)
        {
            var result = new List <CapitalInfo>();

            using (var command = new SqlCommand("Select * " +
                                                " from tbl_Capital  where  CapitalName like '%" + name + "%'  and isused = 1 order by CapitalID ", connection))
            {
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new CapitalInfo();
                        info.CapitalID   = GetDbReaderValue <int>(reader["CapitalID"]);
                        info.CapitalName = GetDbReaderValue <string>(reader["CapitalName"]);
                        result.Add(info);
                    }
                }
                return(result);
            }
        }
Beispiel #25
0
        public decimal getMyMoney(long uid, int userType)
        {
            CapitalInfo SMInfo = (
                from a in context.CapitalInfo

                where a.ManageId == uid

                select a).FirstOrDefault();
            decimal aa;

            if (SMInfo != null)
            {
                aa = decimal.Parse(SMInfo.Balance.ToString());
            }
            else
            {
                aa = 0;
            }
            return(aa);
        }
Beispiel #26
0
        public List <CapitalInfo> GetAllCapitalbyID(SqlConnection connection, int id)
        {
            var result = new List <CapitalInfo>();

            using (var command = new SqlCommand("Select * " +
                                                " from tbl_Capital  where  CapitalID = @CapitalID  AND isused = 1 order by CapitalID ", connection))
            {
                AddSqlParameter(command, "@CapitalID", id, System.Data.SqlDbType.Int);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new CapitalInfo();
                        info.CapitalID   = GetDbReaderValue <int>(reader["CapitalID"]);
                        info.CapitalName = GetDbReaderValue <string>(reader["CapitalName"]);
                        result.Add(info);
                    }
                }
                return(result);
            }
        }
Beispiel #27
0
        public ActionResult Center()
        {
            decimal num;
            IQueryable <OrderInfo> topOrders  = ServiceHelper.Create <IOrderService>().GetTopOrders(2147483647, base.CurrentUser.Id);
            OrderQuery             orderQuery = new OrderQuery()
            {
                Status    = new OrderInfo.OrderOperateStatus?(OrderInfo.OrderOperateStatus.Finish),
                UserId    = new long?(base.CurrentUser.Id),
                PageSize  = 2147483647,
                PageNo    = 1,
                Commented = new bool?(false)
            };
            OrderQuery orderQuery1 = orderQuery;

            ViewBag.WaitingForComments = ServiceHelper.Create <IOrderService>().GetOrders <OrderInfo>(orderQuery1, null).Total;
            UserMemberInfo member = ServiceHelper.Create <IMemberService>().GetMember(base.CurrentUser.Id);

            ViewBag.AllOrders = topOrders.Count();
            base.ViewBag.WaitingForRecieve = topOrders.Count((OrderInfo item) => (int)item.OrderStatus == 3);
            base.ViewBag.WaitingForPay     = topOrders.Count((OrderInfo item) => (int)item.OrderStatus == 1);
            CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id);

            if (capitalInfo == null)
            {
                ViewBag.Capital = 0;
            }
            else
            {
                dynamic viewBag = base.ViewBag;
                num             = (capitalInfo.Balance.HasValue ? capitalInfo.Balance.Value : new decimal(0));
                viewBag.Capital = num;
            }
            int num1 = ServiceHelper.Create <ICouponService>().GetAllUserCoupon(base.CurrentUser.Id).Count();

            num1 = num1 + ServiceHelper.Create <IShopBonusService>().GetCanUseDetailByUserId(base.CurrentUser.Id).Count();
            ViewBag.GradeName      = base.CurrentUser.MemberGradeName;
            ViewBag.CouponsCount   = num1;
            ViewBag.CollectionShop = ServiceHelper.Create <IVShopService>().GetUserConcernVShops(base.CurrentUser.Id, 1, 2147483647).Count();
            return(View(member));
        }
        public ActionResult ApplyWithDraw()
        {
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();

            if (string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) || string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret))
            {
                throw new HimallException("未配置公众号参数");
            }

            //string str = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false);
            string str = CommonApi.GetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret).access_token;
            //
            SceneModel sceneModel = new SceneModel(QR_SCENE_Type.WithDraw)
            {
                Object = base.CurrentUser.Id.ToString()
            };
            int num = (new SceneHelper()).SetModel(sceneModel, 600);

            //CreateQrCodeResult createQrCodeResult = Senparc.Weixin.MP.AdvancedAPIs.QrCodeApi.Create(str, 300, num, 10000);
            CreateQrCodeResult createQrCodeResult = Senparc.Weixin.MP.AdvancedAPIs.QrCodeApi.Create(str, 300, num, Senparc.Weixin.MP.QrCode_ActionName.QR_SCENE);

            ViewBag.ticket  = createQrCodeResult.ticket;
            ViewBag.Sceneid = num;
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            CapitalInfo           capitalInfo          = memberCapitalService.GetCapitalInfo(base.CurrentUser.Id);

            if (capitalInfo == null)
            {
                ViewBag.ApplyWithMoney = 0;
            }
            else
            {
                dynamic viewBag = base.ViewBag;
                decimal?balance = capitalInfo.Balance;
                viewBag.ApplyWithMoney = balance.Value;
            }
            base.ViewBag.IsSetPwd = (string.IsNullOrWhiteSpace(base.CurrentUser.PayPwd) ? false : true);
            return(View());
        }
        public void AddWithDrawApply(ApplyWithDrawInfo model)
        {
            decimal?nullable;

            context.ApplyWithDrawInfo.Add(model);
            CapitalInfo capitalInfo  = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == model.MemId);
            CapitalInfo capitalInfo1 = capitalInfo;
            decimal?    balance      = capitalInfo1.Balance;
            decimal     applyAmount  = model.ApplyAmount;

            if (balance.HasValue)
            {
                nullable = new decimal?(balance.GetValueOrDefault() - applyAmount);
            }
            else
            {
                nullable = null;
            }
            capitalInfo1.Balance     = nullable;
            capitalInfo.FreezeAmount = new decimal?((capitalInfo.FreezeAmount.HasValue ? capitalInfo.FreezeAmount.Value + model.ApplyAmount : model.ApplyAmount));
            context.SaveChanges();
        }
Beispiel #30
0
        public ActionResult Index()
        {
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();
            CapitalInfo           capitalInfo          = memberCapitalService.GetCapitalInfo(base.CurrentUser.Id);
            decimal num = new decimal(0);

            if (capitalInfo != null)
            {
                num = (
                    from e in capitalInfo.Himall_CapitalDetail
                    where e.SourceType == CapitalDetailInfo.CapitalDetailType.RedPacket
                    select e).Sum <CapitalDetailInfo>((CapitalDetailInfo e) => e.Amount);
                dynamic viewBag = base.ViewBag;
                ICollection <CapitalDetailInfo> himallCapitalDetail = capitalInfo.Himall_CapitalDetail;
                viewBag.CapitalDetails = (
                    from e in himallCapitalDetail
                    orderby e.CreateTime descending
                    select e).Take(15);
            }
            ViewBag.RedPacketAmount = num;
            base.ViewBag.IsSetPwd   = (string.IsNullOrWhiteSpace(base.CurrentUser.PayPwd) ? false : true);
            return(View(capitalInfo));
        }