Esempio n. 1
0
 /// <summary>
 /// 创建新的 AccountLog 对象。
 /// </summary>
 /// <param name="logId">LogId 属性的初始值。</param>
 /// <param name="userId">UserId 属性的初始值。</param>
 /// <param name="orderId">OrderId 属性的初始值。</param>
 /// <param name="amount">Amount 属性的初始值。</param>
 /// <param name="accountWay">AccountWay 属性的初始值。</param>
 /// <param name="ip">Ip 属性的初始值。</param>
 public static AccountLog CreateAccountLog(global::System.Int32 logId, global::System.Int64 userId, global::System.Guid orderId, global::System.Decimal amount, global::System.Int32 accountWay, global::System.String ip)
 {
     AccountLog accountLog = new AccountLog();
     accountLog.LogId = logId;
     accountLog.UserId = userId;
     accountLog.OrderId = orderId;
     accountLog.Amount = amount;
     accountLog.AccountWay = accountWay;
     accountLog.Ip = ip;
     return accountLog;
 }
Esempio n. 2
0
        /// <summary>
        /// 支付成功的后续操作
        /// </summary>
        private void OnAfterPay(Order order,SrvResponse resp)
        {   
            var paylog = new PayLog();
            paylog.OrderId = order.OrderId;
            paylog.TransactionId = resp.Fields["qid"];
            paylog.UserId = order.UserId;
            paylog.PayWay = (int)PayWay.UnionPay;
            paylog.PayMoney = order.Total;
            paylog.PayUrl = resp.OrigPostString;
            paylog.BackUrl = Request.RawUrl;
            paylog.CreateTime = DateTime.Now;
            paylog.PayResult = "支付成功";
            //如果支付失败
            if (resp.ResponseCode != SrvResponse.RESP_SUCCESS)
                paylog.PayResult = "支付失败";
            else { 
                //账户操作
                var acc = _uow.AccountService.Get(t => t.UserId == order.UserId);
                if (acc == null)
                {
                    acc = new Account() { 
                        UserId = order.UserId,
                        Amount = 0,
                        IsStop = false,
                        CreateTime = DateTime.Now,
                        FrozenAmount = 0
                    };
                    //新增账户
                    _uow.AccountService.Add(acc);
                }
                //账户日志--充值
                var acclog = new AccountLog();
                acclog.UserId = order.UserId;
                acclog.OrderId = order.OrderId;
                acclog.Amount = order.Total;
                acclog.AccountWay = (int)AccountWay.In;
                acclog.Ip = Request.UserHostAddress;
                acclog.CreateTime = DateTime.Now;
                acclog.PayWay = (int)PayWay.UnionPay;
                _uow.AccountLogService.Add(acclog);
                //充值
                acc.Amount += order.Total;
                //账户日志--扣款
                var acclog2 = new AccountLog();
                acclog2.UserId = order.UserId;
                acclog2.OrderId = order.OrderId;
                acclog2.Amount = order.Total;
                acclog2.AccountWay = (int)AccountWay.Out;
                acclog2.Ip = Request.UserHostAddress;
                acclog2.CreateTime = DateTime.Now;
                acclog2.PayWay = (int)PayWay.UnionPay;
                _uow.AccountLogService.Add(acclog2);
                //修改账户余额
                acc.Amount -= order.Total;
                acc.UpdateTime = DateTime.Now;
                //写支付日志
                _uow.PayLogService.Add(paylog);
                //修改订单状态
                order.Status = (int)OrderState.Paid;
                order.UpdateTime = DateTime.Now;
                order.PayTime = DateTime.Now;

            }
            _uow.Commit();
        }
Esempio n. 3
0
 /// <summary>
 /// 用于向 AccountLog EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToAccountLog(AccountLog accountLog)
 {
     base.AddObject("AccountLog", accountLog);
 }