示例#1
0
        public ActionResult ChangeUserGoldNum(int userId, int cashMoney)
        {
            try
            {
                var operId = (Session[SessionConstants.CURRENTOPERATOR] as _operator).oper_id;

                account_record model = new account_record();
                model.user_id         = userId;
                model.acc_type        = AccountConstants.GOLD;
                model.cons_type       = ConType.INCOME;
                model.acc_record_type = AccRecordType.RECHARGE;
                model.cons_value      = cashMoney;
                model.acc_balance     = 0;
                model.oper_id         = operId;
                model.acc_remark      = "后台充值";

                bool result = _userManager.InsertAccountRecord(model);

                return(Json(new AjaxResultObject {
                    code = AjaxResultObject.OK, message = "充值成功"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new AjaxResultObject {
                    code = AjaxResultObject.ERROR, message = "失败,请联系管理员"
                }));
            }
        }
示例#2
0
        public static bool SyncPayOrder(this MyDbContext db, PayOrderBag payOrderBag)
        {
            System.Object locker = new System.Object();

            lock (locker)
            {   // 同步代码块
                var old = ("SELECT  PayStateID FROM pay_order where PO_ID='" + payOrderBag.PayOrder.PO_ID + "'").ExecuteReader(Setting.ConnectionString);
                if (old.Any() &&
                    (old[0][0] == PayStateEnum.Failed.ToString() ||
                     old[0][0] == PayStateEnum.Finished.ToString()))
                {//同步检查是否 已完成
                    return(false);
                }


                if (payOrderBag.IsSuccessful)
                {
                    //写记录
                    var payerLog = new account_record()
                    {
                        AccountRecordID   = payOrderBag.PayOrder.PO_ID + "-" + payOrderBag.Payer.Account.AccountID,
                        AccountID         = payOrderBag.Payer.Account.AccountID,
                        Amount            = payOrderBag.PayOrder.PayNum,
                        Type              = "支出",
                        Time              = DateTime.Now,
                        AfterPayedBalance = payOrderBag.Payer.Account.Balance,
                        ServiceCharge     = 0,
                        Reason            = "订单[" + payOrderBag.PayOrder.PO_ID + "]产生的支出" + payOrderBag.PayOrder.PayNum / 100.0 + "元",
                        PO_ID             = payOrderBag.PayOrder.PO_ID
                    };
                    var receiverLog = new account_record()
                    {
                        AccountRecordID   = payOrderBag.PayOrder.PO_ID + "-" + payOrderBag.Receiver.Account.AccountID,
                        AccountID         = payOrderBag.Receiver.Account.AccountID,
                        Amount            = payOrderBag.PayOrder.PayNum,
                        Type              = "收入",
                        Time              = DateTime.Now,
                        AfterPayedBalance = payOrderBag.Receiver.Account.Balance,
                        ServiceCharge     = 0,
                        Reason            = "订单[" + payOrderBag.PayOrder.PO_ID + "]产生的收入" + payOrderBag.PayOrder.PayNum / 100.0 + "元",
                        PO_ID             = payOrderBag.PayOrder.PO_ID
                    };

                    //改为已完成
                    payOrderBag.PayOrder.PayStateID = PayStateEnum.Finished.ToString();
                    db.account_record.Add(payerLog);
                    db.account_record.Add(receiverLog);
                    db.account.AddOrUpdate(payOrderBag.Payer.Account);
                    db.account.AddOrUpdate(payOrderBag.Receiver.Account);
                    db.pay_order.AddOrUpdate(payOrderBag.PayOrder);
                    return(db.SaveChanges() > 0);
                }
                db.account.AddOrUpdate(payOrderBag.Payer.Account);
                db.account.AddOrUpdate(payOrderBag.Receiver.Account);
                db.pay_order.AddOrUpdate(payOrderBag.PayOrder);
                return(db.SaveChanges() > 0);
            }
        }
示例#3
0
 private object ToBonusRecordViewModel(account_record b)
 {
     return(new
     {
         user_name = b.user.user_name,
         user_phone = b.user.user_phone,
         acc_type = AccountConstants.ToString(b.acc_type),
         bonus_money = b.cons_value,
         bonus_time = b.acc_record_time.ToString("yyyy-MM-dd HH:mm:ss"),
         bonus_remark = b.acc_remark,
         acc_balance = b.acc_balance
     });
 }
示例#4
0
        public bool AddDeleteMoney(int[] userIds, int addOrDelete, string money, int accountType)
        {
            for (int i = 0; i < userIds.Length; i++)
            {
                int userId = userIds[i];
                //获取对象
                user_account userAccount = this._userManager.GetUserAccount(userId);
                var          operId      = (Session[SessionConstants.CURRENTOPERATOR] as _operator).oper_id;
                if (userAccount == null)
                {
                    continue;
                }
                account_record accountRecord = new account_record();
                accountRecord.user_id    = userAccount.user_id;
                accountRecord.cons_value = int.Parse(money);
                accountRecord.oper_id    = operId;
                accountRecord.acc_remark = "系统手工操作";
                //判断是增加还是删除
                //addOrDelete增加是1   减是-1
                if (addOrDelete == 1)
                {
                    accountRecord.acc_record_type = AccRecordType.SYS_ADD;
                    accountRecord.cons_type       = ConType.INCOME;
                    //金钻账户增加
                    if (accountType == AccountConstants.GOLD)
                    {
                        accountRecord.acc_type    = AccountConstants.GOLD;
                        accountRecord.acc_balance = userAccount.account1_balance + int.Parse(money);

                        this._userManager.InsertAccountRecord(accountRecord);
                    }
                    //银钻账户增加
                    if (accountType == AccountConstants.SILVER)
                    {
                        accountRecord.acc_type    = AccountConstants.SILVER;
                        accountRecord.acc_balance = userAccount.account2_balance + int.Parse(money);

                        this._userManager.InsertAccountRecord(accountRecord);
                    }
                    //蓝钻账户增加
                    if (accountType == AccountConstants.BLUE)
                    {
                        accountRecord.acc_type    = AccountConstants.BLUE;
                        accountRecord.acc_balance = userAccount.account3_balance + int.Parse(money);

                        this._userManager.InsertAccountRecord(accountRecord);
                    }
                    continue;
                }
                if (addOrDelete == -1)
                {
                    accountRecord.acc_record_type = AccRecordType.SYS_DELETE;
                    accountRecord.cons_type       = ConType.EXPEND;
                    //金钻账户减少
                    if (accountType == AccountConstants.GOLD)
                    {
                        accountRecord.acc_type    = AccountConstants.GOLD;
                        accountRecord.acc_balance = userAccount.account1_balance - int.Parse(money);

                        this._userManager.InsertAccountRecord(accountRecord);
                    }
                    //银钻账户减少
                    if (accountType == AccountConstants.SILVER)
                    {
                        accountRecord.acc_type    = AccountConstants.SILVER;
                        accountRecord.acc_balance = userAccount.account2_balance - int.Parse(money);

                        this._userManager.InsertAccountRecord(accountRecord);
                    }
                    //蓝钻账户减少
                    if (accountType == AccountConstants.BLUE)
                    {
                        accountRecord.acc_type    = AccountConstants.BLUE;
                        accountRecord.acc_balance = userAccount.account3_balance - int.Parse(money);

                        this._userManager.InsertAccountRecord(accountRecord);
                    }
                    continue;
                }
            }
            return(true);
        }