Esempio n. 1
0
        public bool Insert(BankRechargeRecord obj)
        {
            bool result = false;
            try
            {
                SqlParameter[] parameters = new SqlParameter[]{
                    new SqlParameter("@OrderSeq",obj.OrderSeq),
                    new SqlParameter("@PayTransactionID",obj.PayTransactionID),
                    new SqlParameter("@OrderDate",obj.OrderDate),
                    new SqlParameter("@CurType",obj.CurType),
                    new SqlParameter("@OrderAmount",obj.OrderAmount),
                    new SqlParameter("@ProductAmount",obj.ProductAmount),
                    new SqlParameter("@AttachAmount",obj.AttachAmount),
                    new SqlParameter("@OrderDesc",obj.OrderDesc),
                    new SqlParameter("@TargetAccount",obj.TargetAccount),
                    new SqlParameter("@Status",obj.Status),
                    new SqlParameter("@ReqTime",obj.ReqTime),
                    new SqlParameter("@PayTime",obj.PayTime),
                    new SqlParameter("@UptranSeq",obj.UptranSeq),
                    new SqlParameter("@TranDate",obj.TranDate),
                    new SqlParameter("@Sign",obj.Sign),
                    new SqlParameter("@ReturnCode",obj.ReturnCode),
                    new SqlParameter("@ReturnDesc",obj.ReturnDesc)
                };

                SqlCommand cmd = new SqlCommand(Insert_Sql);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddRange(parameters);

                result = DBUtility.Execute(cmd, DBUtility.BestToneCenterConStr);
            }
            catch { }

            return result;
        }
Esempio n. 2
0
        public BankRechargeRecord QueryByOrderTransacntionID(String transactionid)
        {
            BankRechargeRecord obj = null;

            try
            {
                String where = String.Format(" where PayTransactionID = '{0}'", transactionid);
                IList <BankRechargeRecord> list = QueryByWhere(where);
                if (list != null && list.Count > 0)
                {
                    obj = list[0];
                }
            }
            catch (Exception ex) { throw ex; }

            return(obj);
        }
Esempio n. 3
0
        public BankRechargeRecord QueryByOrderSeq(String orderSeq)
        {
            BankRechargeRecord obj = null;

            try
            {
                String where = String.Format(" where OrderSeq = '{0}'", orderSeq);
                IList <BankRechargeRecord> list = QueryByWhere(where);
                if (list != null && list.Count > 0)
                {
                    obj = list[0];
                }
            }
            catch (Exception ex) { throw ex; }

            return(obj);
        }
Esempio n. 4
0
        private IList <BankRechargeRecord> QueryByWhere(String where)
        {
            IList <BankRechargeRecord> list = null;

            String     sql = Select_Sql.Insert(Select_Sql.Length, where);
            SqlCommand cmd = new SqlCommand(sql);

            cmd.CommandType = CommandType.Text;

            DataSet ds = DBUtility.FillData(cmd, DBUtility.BestToneCenterConStr);

            if (ds != null && ds.Tables[0] != null)
            {
                list = new List <BankRechargeRecord>();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    BankRechargeRecord entity = new BankRechargeRecord();
                    entity.ID               = Convert.ToInt64(row["ID"]);
                    entity.OrderSeq         = row["OrderSeq"].ToString();
                    entity.PayTransactionID = row["PayTransactionID"].ToString();
                    entity.OrderDate        = row["OrderDate"].ToString();
                    entity.CurType          = row["CurType"].ToString();
                    entity.OrderAmount      = Convert.ToInt64(row["OrderAmount"]);
                    entity.ProductAmount    = Convert.ToInt64(row["ProductAmount"]);
                    entity.AttachAmount     = Convert.ToInt64(row["AttachAmount"]);
                    entity.OrderDesc        = row["OrderDesc"].ToString();
                    entity.TargetAccount    = row["TargetAccount"].ToString();
                    entity.Status           = Convert.ToInt32(row["Status"]);
                    entity.ReqTime          = Convert.ToDateTime(row["ReqTime"]);
                    entity.PayTime          = Convert.ToDateTime(row["PayTime"]);
                    entity.UptranSeq        = row["UptranSeq"].ToString();
                    entity.TranDate         = row["TranDate"].ToString();
                    entity.Sign             = row["Sign"].ToString();
                    entity.ReturnCode       = row["ReturnCode"].ToString();
                    entity.ReturnDesc       = row["ReturnDesc"].ToString();

                    list.Add(entity);
                }
            }

            return(list);
        }
Esempio n. 5
0
        public bool Update(BankRechargeRecord obj)
        {
            bool result = false;

            try
            {
                SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@ID", obj.ID),
                    new SqlParameter("@OrderSeq", obj.OrderSeq),
                    new SqlParameter("@PayTransactionID", obj.PayTransactionID),
                    new SqlParameter("@OrderDate", obj.OrderDate),
                    new SqlParameter("@CurType", obj.CurType),
                    new SqlParameter("@OrderAmount", obj.OrderAmount),
                    new SqlParameter("@ProductAmount", obj.ProductAmount),
                    new SqlParameter("@AttachAmount", obj.AttachAmount),
                    new SqlParameter("@OrderDesc", obj.OrderDesc),
                    new SqlParameter("@TargetAccount", obj.TargetAccount),
                    new SqlParameter("@Status", obj.Status),
                    new SqlParameter("@ReqTime", obj.ReqTime),
                    new SqlParameter("@PayTime", obj.PayTime),
                    new SqlParameter("@UptranSeq", obj.UptranSeq),
                    new SqlParameter("@TranDate", obj.TranDate),
                    new SqlParameter("@Sign", obj.Sign),
                    new SqlParameter("@ReturnCode", obj.ReturnCode),
                    new SqlParameter("@ReturnDesc", obj.ReturnDesc)
                };

                SqlCommand cmd = new SqlCommand(Update_Sql);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddRange(parameters);

                result = DBUtility.Execute(cmd, DBUtility.BestToneCenterConStr);
            }
            catch { }

            return(result);
        }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                String custid = Request["hiddenCustID"];
                String spid = Request["hiddenSPID"];
                String InvoiceType = Request["InvoiceType"];
                String InvoiceTitle = Request["InvoiceTitle"];
                String InvoiceContent = Request["InvoiceContent"];
                String ContactPerson = Request["ContactPerson"];
                String ContactPhone = Request["ContactPhone"];
                String Address = Request["Address"];
                String Zip = Request["Zip"];
                String Mem = Request["Mem"];
                String NeedInvoice = Request["NeedInvoice"];

                long balance = Convert.ToInt64(Convert.ToDouble(Request["TranAmount"]) * 100);
                DateTime reqTime = DateTime.Now;

                //查询账户信息
                BesttoneAccountDAO _besttoneAccount_dao = new BesttoneAccountDAO();
                BesttoneAccount account_entity = _besttoneAccount_dao.QueryByCustID(custid);
                if (account_entity == null)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "账户信息异常", this.Context);
                    return;
                }

                #region 账户充值金额上限校验

                long OnceRechargeLimit = BesttoneAccountConstDefinition.DefaultInstance.AccountRechargeLimitedOne;              //单笔充值金额上限
                long RechargeAmountLimit = BesttoneAccountConstDefinition.DefaultInstance.AccountRechargeLimitedDay;            //账户单日充值额度上限
                long CurrentAmountLimit = BesttoneAccountConstDefinition.DefaultInstance.AccountBalanceLimited;                 //账户余额上限
                if (OnceRechargeLimit > 0)
                {
                    //检测用户单笔充值金额是否超限(10000元)
                    if (balance > OnceRechargeLimit)
                    {
                        result = 100003;
                        ErrMsg = String.Format("单笔充值金额最多不能超过{0}元", BesttoneAccountHelper.ConvertAmountToYuan(OnceRechargeLimit));
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "充值金额超过上限", this.Context);
                        return;
                    }
                }
                if (RechargeAmountLimit > 0)
                {
                    //检测用户当日充值是否超限(当日充值金额不能超过50000元)
                    long hadRechargeAmount = _rechargeOrder_dao.QueryCurrentRechargeAmount(account_entity.BestPayAccount);
                    if ((hadRechargeAmount + balance) > RechargeAmountLimit)
                    {
                        result = 100001;
                        ErrMsg = String.Format("您今日累计充值金额:{0}元,本次充值将超过您的当日累计充值限额:{1}元,请改日再进行充值操作!",
                            BesttoneAccountHelper.ConvertAmountToYuan(hadRechargeAmount), BesttoneAccountHelper.ConvertAmountToYuan(RechargeAmountLimit));
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "充值金额超过上限", this.Context);
                        return;
                    }
                }

                if (CurrentAmountLimit > 0)
                {
                    long accountBalance = 0;
                    //检测用户帐户余额(个人账户余额不能超过100000元)
                    result = BesttoneAccountHelper.QueryAccountBalance(account_entity.BestPayAccount, out accountBalance, out ErrMsg);
                    if (result != 0)
                    {
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "账户信息异常", this.Context);
                        return;
                    }

                    if ((accountBalance + balance) > CurrentAmountLimit)
                    {
                        result = 100002;
                        ErrMsg = String.Format("您的账户余额为:{0}元,本次充值将超过您的账户余额上限:{1}元,请消费后再进行充值操作!",
                            BesttoneAccountHelper.ConvertAmountToYuan(accountBalance), BesttoneAccountHelper.ConvertAmountToYuan(CurrentAmountLimit));
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "充值金额超过上限", this.Context);
                        return;
                    }
                }

                #endregion

                bool Result = false;

                #region 生成订单信息

                /***************************************************************************/
                String orderSeq = BesttoneAccountHelper.CreateOrderSeq();                   //订单号
                String transactionID = BesttoneAccountHelper.CreateTransactionID();         //流水号
                // 在发起网银扣款请求,主表状态为1,扣款子表状态为0
                //初始化充值订单
                //2013-04-13 add -start
                if (String.IsNullOrEmpty(NeedInvoice))
                {
                    NeedInvoice = "0";
                }
                //2013-04-13 add -end
                RechargeOrder _recharge_order = new RechargeOrder(orderSeq, transactionID, reqTime.ToString("yyyyMMdd"), "RMB",
                    balance, balance, 0, "网银充值", custid, account_entity.BestPayAccount, "0", spid, reqTime, new DateTime(1900, 1, 1),
                    new DateTime(1900, 1, 1), 1, 0, "", "", "", NeedInvoice);  //2013-04-13 add NeedInvoice 字段

                //初始化网银扣款流水记录
                BankRechargeRecord _bankRecharge_record = new BankRechargeRecord(orderSeq, transactionID, reqTime.ToString("yyyyMMdd"), "RMB",
                    balance, balance, 0, "网银充值", account_entity.BestPayAccount, 0, reqTime, new DateTime(1900, 1, 1), "", "", "", "", "");

                Result = _rechargeOrder_dao.Insert(_recharge_order);
                if (!Result)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败1", this.Context);
                    return;
                }

                //如果需要开发票 -- 插入发票表  2013-04-14 add-start
                if ("1".Equals(NeedInvoice))
                {
                    System.Text.StringBuilder datalog = new System.Text.StringBuilder();
                    //Result = _rechargeOrder_dao.InsertInvoice(orderSeq, InvoiceType, "", InvoiceTitle, ContactPerson, ContactPhone, Address, Zip, Mem, out datalog);
                    if ("0".Equals("InvoiceType"))
                    {
                        InvoiceTitle = "个人";
                    }
                    if (String.IsNullOrEmpty(InvoiceTitle))
                    {
                        InvoiceTitle = "个人";
                    }
                    if (String.IsNullOrEmpty(InvoiceContent))
                    {
                        InvoiceContent = "日用品";
                    }
                    Result = _rechargeOrder_dao.InsertInvoice(orderSeq, InvoiceType, InvoiceContent, InvoiceTitle, ContactPerson, ContactPhone, Address, Zip, Mem,"9", out datalog);  // "9" 代表需要开票
                    if (!Result)
                    {
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败-发票生成失败", this.Context);
                        return;
                    }
                }
                //2013-04-14 add-end

                Result = _bankRechargeRecord_dao.Insert(_bankRecharge_record);
                if (!Result)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败2", this.Context);
                    return;
                }
                /***************************************************************************/

                #endregion

                this._ORDERSEQ = orderSeq;
                this._ORDERREQTRANSEQ = transactionID;
                this._ORDERDATE = reqTime.ToString("yyyyMMddHHmmss");
                this._ORDERAMOUNT = balance.ToString();
                this._PRODUCTAMOUNT = balance.ToString();

                //MAC签名
                String mac = String.Format("MERCHANTID={0}&ORDERSEQ={1}&ORDERDATE={2}&ORDERAMOUNT={3}", this.MERCHANTID, this._ORDERSEQ, this._ORDERDATE, this._ORDERAMOUNT);
                mac = BesttoneAccountHelper.MACSign(mac);

                this._MAC = mac;
            }
            catch (Exception ex)
            {
                CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败", this.Context);
                return;
            }
        }
    }
Esempio n. 7
0
        private IList<BankRechargeRecord> QueryByWhere(String where)
        {
            IList<BankRechargeRecord> list = null;

            String sql = Select_Sql.Insert(Select_Sql.Length, where);
            SqlCommand cmd = new SqlCommand(sql);
            cmd.CommandType = CommandType.Text;

            DataSet ds = DBUtility.FillData(cmd, DBUtility.BestToneCenterConStr);
            if (ds != null && ds.Tables[0] != null)
            {
                list = new List<BankRechargeRecord>();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    BankRechargeRecord entity = new BankRechargeRecord();
                    entity.ID = Convert.ToInt64(row["ID"]);
                    entity.OrderSeq = row["OrderSeq"].ToString();
                    entity.PayTransactionID = row["PayTransactionID"].ToString();
                    entity.OrderDate = row["OrderDate"].ToString();
                    entity.CurType = row["CurType"].ToString();
                    entity.OrderAmount = Convert.ToInt64(row["OrderAmount"]);
                    entity.ProductAmount = Convert.ToInt64(row["ProductAmount"]);
                    entity.AttachAmount = Convert.ToInt64(row["AttachAmount"]);
                    entity.OrderDesc = row["OrderDesc"].ToString();
                    entity.TargetAccount = row["TargetAccount"].ToString();
                    entity.Status = Convert.ToInt32(row["Status"]);
                    entity.ReqTime = Convert.ToDateTime(row["ReqTime"]);
                    entity.PayTime = Convert.ToDateTime(row["PayTime"]);
                    entity.UptranSeq = row["UptranSeq"].ToString();
                    entity.TranDate = row["TranDate"].ToString();
                    entity.Sign = row["Sign"].ToString();
                    entity.ReturnCode = row["ReturnCode"].ToString();
                    entity.ReturnDesc = row["ReturnDesc"].ToString();

                    list.Add(entity);
                }
            }

            return list;
        }