Exemple #1
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();
        }
Exemple #2
0
 /// <summary>
 /// 用于向 PayLog EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToPayLog(PayLog payLog)
 {
     base.AddObject("PayLog", payLog);
 }
Exemple #3
0
        private void SavePayLog(ViewModel.PaymentViewModel model)
        {
            var paylog = new PayLog();
            paylog.OrderId = model.OrderModel.OrderId;
            //paylog.TransactionId = model.OrderModel.TradeNo;
            paylog.UserId = model.OrderModel.UserId;
            paylog.PayWay = (int)PayWay.UnionPay;
            paylog.PayMoney = model.OrderModel.Total;
            paylog.PayUrl = "";
            paylog.BackUrl = model.BackCallbackUrl;
            paylog.PayResult = "前往支付";
            paylog.CreateTime = DateTime.Now;

            _uow.PayLogService.Add(paylog);
            _uow.Commit();
        }
Exemple #4
0
 /// <summary>
 /// 创建新的 PayLog 对象。
 /// </summary>
 /// <param name="payId">PayId 属性的初始值。</param>
 /// <param name="orderId">OrderId 属性的初始值。</param>
 /// <param name="userId">UserId 属性的初始值。</param>
 /// <param name="payWay">PayWay 属性的初始值。</param>
 /// <param name="payMoney">PayMoney 属性的初始值。</param>
 /// <param name="createTime">CreateTime 属性的初始值。</param>
 public static PayLog CreatePayLog(global::System.Int32 payId, global::System.Guid orderId, global::System.Int64 userId, global::System.Int32 payWay, global::System.Decimal payMoney, global::System.DateTime createTime)
 {
     PayLog payLog = new PayLog();
     payLog.PayId = payId;
     payLog.OrderId = orderId;
     payLog.UserId = userId;
     payLog.PayWay = payWay;
     payLog.PayMoney = payMoney;
     payLog.CreateTime = createTime;
     return payLog;
 }