/// <summary>
        /// 充值
        /// </summary>
        /// <param name="userCode"></param>
        /// <param name="order"></param>
        /// <param name="payType"></param>
        /// <returns></returns>
        public financialStatements getDataRechargeRecord(string userCode, string typeCode, UseWallet useWallet, string storeCode, decimal?ratio, string payType)
        {
            ICouponService       _couponService      = new CouponService();
            IRechargeTypeService rt                  = new RechargeTypeService();
            IProductInfoService  _productInfoService = new ProductInfoService();
            ICouponTypeService   _couponTypeService  = new CouponTypeService();
            IUseWalletService    _useWalletService   = new UseWalletService();
            IUserStoreService    _userStoreService   = new UserStoreService();
            IStoreService        _storeService       = new StoreService();
            IUserInfo            _userService        = new UserInfo();
            var rechargetype = rt.GetRechargeTypeByCode(typeCode);
            var uw           = _useWalletService.GetUseWalletCountMoney(userCode);

            if (string.IsNullOrEmpty(storeCode))
            {
                var us = _userStoreService.GetUserStorebyUserCode(userCode);
                storeCode = us.MembershipCardStore;
            }
            var s = _storeService.GetStore(storeCode);
            var u = _userService.GetUserByCode(userCode);
            financialStatements fs = new financialStatements();

            fs.Code           = Guid.NewGuid().ToString();
            fs.CreateTime     = DateTime.Now;
            fs.UserPhone      = u?.Phone;
            fs.UserCreateTime = u?.CreateTime;
            fs.StoreName      = s?.StoreName;
            fs.ProductionType = "体验服务";
            fs.Cstname        = "普通销售";
            fs.ProductionCode = rechargetype?.RechargeTypeCode;
            fs.ProductionName = rechargetype?.RechargeTypeName;
            fs.Iquantity      = 1;
            fs.Itaxunitprice  = useWallet?.AccountPrincipal;
            fs.Isum           = useWallet?.AccountPrincipal;
            fs.CpersonName    = "业务员";
            fs.PayType        = payType;
            fs.AmountOfIncome = useWallet?.AccountPrincipal;
            fs.DonationAmount = useWallet?.DonationAmount;
            fs.CouponUseCode  = "";
            fs.CouponUseMoney = 0;
            fs.UseWalletMoney = uw?.TotalAmount + useWallet?.AccountPrincipal + useWallet?.DonationAmount;

            if (ratio != null)
            {
                fs.Ratio = Math.Round(100 - Convert.ToDouble(ratio) * 100, 2).ToString() + '%';
            }

            fs.UseWalletMoney1           = fs?.UseWalletMoney;
            fs.UseWalletAccountPrincipal = uw?.AccountPrincipal + useWallet?.AccountPrincipal;

            fs.ProductInfoRate = "0";
            return(fs);
        }
Esempio n. 2
0
        public bool Recharge(string typeCode, string userCode, decimal?money = 0, string storeCode = "")
        {
            IRechargeTypeService         s  = new RechargeTypeService();
            IRecordsOfConsumptionService cs = new RecordsOfConsumptionService();
            IUseWalletService            us = new UseWalletService();
            IFinancialStatementsService  _financialStatementsService = new FinancialStatementService();
            var     type           = s.GetRechargeTypeByCode(typeCode);
            var     explain        = "";
            decimal?donationAmount = 0;
            decimal?ratio          = 0;

            if (money > 0 && type == null)
            {
                typeCode = "0";
                ratio    = 0;
                explain  = "充值类型:任意金额,本金:" + money;
            }
            else
            {
                donationAmount = type.DonationAmount;
                money          = type.Money;
                ratio          = donationAmount / (money + donationAmount);
                explain        = "充值类型" + type.RechargeTypeName + ",本金:" + money + ",赠送:+" + donationAmount;
            }
            UseWallet wallet = new UseWallet()
            {
                WalletCode        = Guid.NewGuid().ToString(),
                UserCode          = userCode,
                AccountPrincipal  = money,
                DonationAmount    = donationAmount,
                Ratio             = decimal.Round(decimal.Parse(ratio.ToString()), 4).ToString(),
                Status            = true,
                Sort              = 1,
                IsMissionGiveaway = false
            };

            using (var scope2 = new TransactionScope())//创建事务
            {
                var fs = _financialStatementsService.getDataRechargeRecord(userCode, typeCode, wallet, storeCode, ratio, "微信");
                LogHelper.WriteLog("报表表数据更新完成");
                _financialStatementsService.Insert(fs);
                //钱包
                us.InsertUseWallet(wallet);
                //消费记录
                cs.InsertRecore(typeCode, userCode, decimal.Parse(money.ToString()), explain, null, null, null);
                scope2.Complete();
            }
            //充值
            //InsertRechargeRecord(record);
            return(true);
        }
Esempio n. 3
0
        //获取充值页面数据
        public RechargePage GetRechargePage(string userCode)
        {
            RechargePage      rechargePage = new RechargePage();
            IList <UseWallet> list         = GetUseWallet(userCode);
            var totalMoney     = list.Sum(p => p.DonationAmount + p.AccountPrincipal);
            var pechargeMoney  = list.Sum(p => p.AccountPrincipal);
            var donationAmount = list.Sum(p => p.DonationAmount);

            rechargePage.TotalMoney     = totalMoney;
            rechargePage.PechargeMoney  = pechargeMoney;
            rechargePage.DonationAmount = donationAmount;
            IRechargeTypeService _service = new RechargeTypeService();

            rechargePage.RechargeTypeList = _service.GetRechargeTypeList();
            return(rechargePage);
        }