Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tenantID"></param>
        /// <param name="userID"></param>
        /// <param name="oStatus">用户指定的状态</param>
        /// <param name="paidAmount">支付金额</param>
        /// <param name="bankID">银行</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool Pay(Guid tenantID, Guid userID, EAP.Logic.Z10.OrderStatus oStatus, decimal paidAmount, long?bankID)
        {
            int orderSts = Z10Order.OrderStatus ?? 0;

            if ((orderSts & (int)EAP.Logic.Z10.OrderStatus.Paid) == (int)EAP.Logic.Z10.OrderStatus.Paid ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Finished) == (int)EAP.Logic.Z10.OrderStatus.Finished ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Archived) == (int)EAP.Logic.Z10.OrderStatus.Archived)
            {
                throw new Exception("已经支付的订单,已经结束的订单和已经存档的订单不能支付。");
            }

            Zippy.Data.IDalProvider db = Zippy.Data.StaticDB.DB;

            Z10Order xorder = new Z10Order();

            xorder.OrderID = Z10Order.OrderID;
            xorder.FeePaid = Z10Order.FeePaid + paidAmount;

            if (oStatus == OrderStatus.Paid)
            {
                xorder.OrderStatus = orderSts & ~(int)OrderStatus.PaidSome;
                xorder.OrderStatus = (xorder.OrderStatus ?? 0) | (int)oStatus;
            }
            else
            {
                //throw new Exception(orderSts.ToString() + "  -- " + oStatus + " -- " + ((Z10Order.OrderStatus ?? 0) | (int)oStatus));
                xorder.OrderStatus = orderSts | (int)oStatus;
            }

            db.Update(xorder);

            Z01Beetle.Entity.Z01FinancialFlow dflow = new Z01Beetle.Entity.Z01FinancialFlow();

            dflow.FlowID   = null;
            dflow.OrderID  = Z10Order.OrderID;
            dflow.Amount   = paidAmount;
            dflow.Creator  = userID;
            dflow.TenantID = tenantID;
            dflow.BankID   = bankID;
            dflow.Currency = Z10Order.Currency;
            db.Insert(dflow);


            //string sqlUpdateStatus = "update Z10Order set OrderStatus=OrderStatus|@paid where OrderID=@orderid ";
            //Zippy.Data.StaticDB.DB.ExecuteNonQuery(sqlUpdateStatus,
            //    Zippy.Data.StaticDB.DB.CreateParameter("paid", (int)EAP.Logic.Z10.OrderStatus.Paid),
            //    Zippy.Data.StaticDB.DB.CreateParameter("orderid", Z10Order.OrderID ?? 0));


            return(true);
        }
Ejemplo n.º 2
0
Archivo: Order.cs Proyecto: honj51/EAP
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tenantID"></param>
        /// <param name="userID"></param>
        /// <param name="oStatus">用户指定的状态</param>
        /// <param name="paidAmount">支付金额</param>
        /// <param name="bankID">银行</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool Pay(Guid tenantID, Guid userID, EAP.Logic.Z10.OrderStatus oStatus, decimal paidAmount, long? bankID)
        {
            int orderSts = Z10Order.OrderStatus ?? 0;
            if ((orderSts & (int)EAP.Logic.Z10.OrderStatus.Paid) == (int)EAP.Logic.Z10.OrderStatus.Paid ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Finished) == (int)EAP.Logic.Z10.OrderStatus.Finished ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Archived) == (int)EAP.Logic.Z10.OrderStatus.Archived)
            {
                throw new Exception("已经支付的订单,已经结束的订单和已经存档的订单不能支付。");
            }

            Zippy.Data.IDalProvider db = Zippy.Data.StaticDB.DB;

            Z10Order xorder = new Z10Order();
            xorder.OrderID = Z10Order.OrderID;
            xorder.FeePaid = Z10Order.FeePaid + paidAmount;

            if (oStatus == OrderStatus.Paid)
            {
                xorder.OrderStatus = orderSts & ~(int)OrderStatus.PaidSome;
                xorder.OrderStatus = (xorder.OrderStatus ?? 0) | (int)oStatus;
            }
            else
            {
                //throw new Exception(orderSts.ToString() + "  -- " + oStatus + " -- " + ((Z10Order.OrderStatus ?? 0) | (int)oStatus));
                xorder.OrderStatus = orderSts | (int)oStatus;
            }

            db.Update(xorder);

            Z01Beetle.Entity.Z01FinancialFlow dflow = new Z01Beetle.Entity.Z01FinancialFlow();

            dflow.FlowID = null;
            dflow.OrderID = Z10Order.OrderID;
            dflow.Amount = paidAmount;
            dflow.Creator = userID;
            dflow.TenantID = tenantID;
            dflow.BankID = bankID;
            dflow.Currency = Z10Order.Currency;
            db.Insert(dflow);

            //string sqlUpdateStatus = "update Z10Order set OrderStatus=OrderStatus|@paid where OrderID=@orderid ";
            //Zippy.Data.StaticDB.DB.ExecuteNonQuery(sqlUpdateStatus,
            //    Zippy.Data.StaticDB.DB.CreateParameter("paid", (int)EAP.Logic.Z10.OrderStatus.Paid),
            //    Zippy.Data.StaticDB.DB.CreateParameter("orderid", Z10Order.OrderID ?? 0));

            return true;
        }