示例#1
0
        /// <summary>
        /// 取消/退款
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="orderType"></param>
        /// <param name="remark"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public bool Cancel(string orderId, OrderType orderType, string remark, out string error)
        {
            var list            = QueryList(b => b.OutOrderId == orderId && b.Status == Status.已确认 && b.OrderType == orderType);
            var instance        = new Account.TransactionBusiness <PayTransManage>();
            var accountInstance = new Account.AccountBusiness <PayTransManage>();
            List <Account.Transaction> trans = new List <Account.Transaction>();

            foreach (var item in list)
            {
                if (!item.MakeTrans)
                {
                    continue;
                }
                var account            = accountInstance.GetAccountId(item.UserId, item.AccountType, item.TransactionType);
                var operateType        = item.OperateType == Account.OperateType.收入 ? Account.OperateType.支出 : Account.OperateType.收入;
                Account.Transaction ts = new Account.Transaction()
                {
                    AccountId = account, Amount = item.Amount, OperateType = operateType, TradeType = item.TradeTypeCancel, OutOrderId = item.OutOrderId, Remark = remark
                };
                trans.Add(ts);
            }
            bool a = instance.SubmitTransaction(out error, false, trans.ToArray());//提交流水

            if (!a)
            {
                error = "退款时发生错误:" + error;
                return(false);
            }
            ParameCollection c = new ParameCollection();

            c["Status"] = Status.已退款;
            Update(b => b.OutOrderId == orderId && b.OrderType == orderType && b.Status == Status.已提交, c);
            return(true);
        }
示例#2
0
        public List <Account.Transaction> GetConfirmTrans(List <PayTrans> payTrans)
        {
            List <Account.Transaction> trans = new List <Account.Transaction>();
            var accountInstance = new Account.AccountBusiness <PayTransManage>();

            foreach (var item in payTrans)
            {
                if (!item.MakeTrans)
                {
                    continue;
                }
                var account            = accountInstance.GetAccountId(item.UserId, item.AccountType, item.TransactionType);
                Account.Transaction ts = new Account.Transaction()
                {
                    AccountId = account, Amount = item.Amount, OperateType = item.OperateType, TradeType = item.TradeType, OutOrderId = item.OutOrderId, Remark = item.Remark, TransactionType = (int)item.TransactionType
                };
                trans.Add(ts);
            }
            return(trans);
        }