//使用本地账户支付 public static int dhOrdersuc(string number, string dhorderid, double getpE) { int res = 0; SqlTransaction tran = null; SqlConnection conn = null; using (conn = DBHelper.SqlCon()) { conn.Open(); tran = conn.BeginTransaction(); if (getpE > 0) { //修改会员账户 增加E int r = DBHelper.ExecuteNonQuery(tran, "update memberinfo set pointEin=pointEin+" + getpE + " where number='" + number + "'"); if (r == 0) { tran.Rollback(); } } else { tran.Rollback(); } string ddremark = "USDT兌換創世幣E:" + getpE; //插入对账单 if (getpE > 0) { int c = D_AccountDAL.AddAccount("E", number, getpE, D_AccountSftype.MemberType, D_AccountKmtype.AccountTransfer, DirectionEnum.AccountsIncreased, ddremark, tran); if (c == 0) { tran.Rollback(); } } //修改订单状态 int rr = DBHelper.ExecuteNonQuery(tran, "update dhlist set issuc=1 ,remark=remark+' 兌換成功' where dhorderid='" + dhorderid + "' "); if (rr == 1) { tran.Commit(); res = 1; } else { tran.Rollback(); } } return(res); }
/// <summary> /// 填写退货退款单 ——ds2012——tianfeng /// </summary> /// <param name="DocID">订单号</param> /// <param name="StoreID">店编号</param> /// <returns></returns> public static Boolean UPtInventoryDoc(string DocID, string StoreID, int flag, double money, string reason, Boolean bol, string opbh, string opip, int qishu) { SqlParameter[] parameter = { new SqlParameter("@DocID", SqlDbType.VarChar, 20), new SqlParameter("@StoreID", SqlDbType.VarChar, 20), new SqlParameter("@Flag", SqlDbType.Int), new SqlParameter("@Charged", SqlDbType.Money, 20), new SqlParameter("@Reason", SqlDbType.VarChar, 250), new SqlParameter("@error", SqlDbType.VarChar, 20) }; parameter[0].Value = DocID; parameter[1].Value = StoreID; parameter[2].Value = flag; parameter[3].Value = money; parameter[4].Value = reason; parameter[5].Direction = ParameterDirection.Output; double totalFmoney = GetInventoryTotalMoney(DocID); using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { try { //修改 double Fmoney = GetInventoryMoney(tran, DocID); string huidan = "HK" + Model.Other.MYDateTime.ToYYMMDDHHmmssString(); //判断汇单号是否存在:true存在,false不存在 bool isExist = RemittancesDAL.isMemberExistsHuiDan(huidan); while (isExist) { huidan = "HK" + Model.Other.MYDateTime.ToYYMMDDHHmmssString(); isExist = RemittancesDAL.isMemberExistsHuiDan(huidan); } if (bol) { AddOrderDataDAL.AddDataTORemittances(tran, huidan, StoreID, (Fmoney * (-1)), DocID, opip, opbh, qishu); DBHelper.ExecuteNonQuery(tran, "update storeinfo set totalaccountmoney=totalaccountmoney - @money where storeid=@storeid", new SqlParameter[2] { new SqlParameter("@money", Fmoney), new SqlParameter("@storeid", StoreID) }, CommandType.Text); D_AccountDAL.AddStoreAccount(StoreID, Fmoney, D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnCharge, DirectionEnum.AccountReduced, "返回上次店铺退货单款" + DocID, tran); DBHelper.ExecuteNonQuery(tran, "UPtInventoryDoc", parameter, CommandType.StoredProcedure); AddOrderDataDAL.AddDataTORemittances(tran, "", StoreID, totalFmoney, DocID, opip, opbh, qishu); DBHelper.ExecuteNonQuery(tran, "update storeinfo set totalaccountmoney=totalaccountmoney + @money where storeid=@storeid", new SqlParameter[2] { new SqlParameter("@money", totalFmoney), new SqlParameter("@storeid", StoreID) }, CommandType.Text); D_AccountDAL.AddStoreAccount(StoreID, totalFmoney, D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnRebate, DirectionEnum.AccountsIncreased, "店铺退货单退款" + DocID, tran); AddOrderDataDAL.AddDataTORemittances(tran, huidan, StoreID, (money * (-1)), DocID, opip, opbh, qishu); DBHelper.ExecuteNonQuery(tran, "update storeinfo set totalaccountmoney=totalaccountmoney - @money where storeid=@storeid", new SqlParameter[2] { new SqlParameter("@money", money), new SqlParameter("@storeid", StoreID) }, CommandType.Text); D_AccountDAL.AddStoreAccount(StoreID, money, D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnCharge, DirectionEnum.AccountReduced, "店铺退货单扣款" + DocID, tran); } else { //添加 DBHelper.ExecuteNonQuery(tran, "UPtInventoryDoc", parameter, CommandType.StoredProcedure); AddOrderDataDAL.AddDataTORemittances(tran, huidan, StoreID, totalFmoney, DocID, opip, opbh, qishu); DBHelper.ExecuteNonQuery(tran, "update storeinfo set totalaccountmoney=totalaccountmoney + @money where storeid=@storeid", new SqlParameter[2] { new SqlParameter("@money", totalFmoney), new SqlParameter("@storeid", StoreID) }, CommandType.Text); D_AccountDAL.AddStoreAccount(StoreID, totalFmoney, D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnRebate, DirectionEnum.AccountsIncreased, "店铺退货单退款" + DocID, tran); AddOrderDataDAL.AddDataTORemittances(tran, huidan, StoreID, (money * (-1)), DocID, opip, opbh, qishu); DBHelper.ExecuteNonQuery(tran, "update storeinfo set totalaccountmoney=totalaccountmoney - @money where storeid=@storeid", new SqlParameter[2] { new SqlParameter("@money", money), new SqlParameter("@storeid", StoreID) }, CommandType.Text); D_AccountDAL.AddStoreAccount(StoreID, money, D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnRebate, DirectionEnum.AccountReduced, "店铺退货单扣款" + DocID, tran); } tran.Commit(); } catch (Exception ex1) { tran.Rollback(); return(false); } finally { conn.Close(); } } } return(int.Parse(parameter[5].Value.ToString()) == 0 ? true : false); }
public static int payOrderEcoin(string number, string orderid, double neede, string remark) { int res = 0; if (neede > 0) { try { int maxexpt = ConfigDAL.GetMaxExpectNum(); //判断订单是否支付 未激活 int ckorder = Convert.ToInt32(DBHelper.ExecuteScalar("select isnull(count(0),0) from memberorder where orderid='" + orderid + "' and DefrayState=1 and isactive =0 ")); if (ckorder == 1) { //判断E币是否足够支付 double blac = Convert.ToDouble(DBHelper.ExecuteScalar("select pointEin -pointEout from memberinfo where number='" + number + "'")); if (neede > blac) { return(-1); //余额不足 } // 扣除对应 E币 SqlTransaction tran = null; SqlConnection conn = null; using (conn = DBHelper.SqlCon()) { conn.Open(); tran = conn.BeginTransaction(); int r1 = DBHelper.ExecuteNonQuery(tran, "update memberinfo set pointEout=pointEout+" + neede + " where number='" + number + "'"); if (r1 == 0) { tran.Rollback(); } int c = D_AccountDAL.AddAccount("E", number, neede, D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, remark, tran); if (c == 0) { tran.Rollback(); } //更新订单 激活业绩 //修改订单状态 int rr = DBHelper.ExecuteNonQuery(tran, "update memberorder set isactive=1 ,activeExpectNum=" + maxexpt + " ,remark=remark+',会员支付E币激活' where orderid='" + orderid + "' "); double ttpv = Convert.ToDouble(DBHelper.ExecuteScalar(tran, "select isnull(sum(totalpv),0) from memberorder where number='" + number + "' and DefrayState=1 and isactive=1 and ordertype in(23,24) ", CommandType.Text)); int lv = 1; switch (ttpv) { case 50: lv = 2; break; case 100: lv = 3; break; case 500: lv = 4; break; case 1000: lv = 5; break; case 3000: lv = 6; break; case 10000: lv = 7; break; } //修改会员账户 int r = DBHelper.ExecuteNonQuery(tran, "update memberinfo set levelint=" + lv + " where number='" + number + "' "); DBHelper.ExecuteNonQuery(tran, "update memberinfobalance" + maxexpt + " set level =" + lv + " where number='" + number + "' "); if (r == 0) { tran.Rollback(); } double cupv = Convert.ToDouble(DBHelper.ExecuteScalar(tran, "select totalpv from memberorder where orderid='" + orderid + "' and DefrayState=1 and isactive=1 ", CommandType.Text)); if (cupv > 0) { //计算业绩 SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Number", number), new SqlParameter("@CurrentOneMark", cupv), new SqlParameter("@ExpectNum", maxexpt) }; DBHelper.ExecuteNonQuery(tran, "js_addnew_PV", sp, CommandType.StoredProcedure); } if (rr == 1) { tran.Commit(); res = 1; } else { tran.Rollback(); } } } } catch (Exception) { res = -2; } } return(res); }
//使用本地账户支付 public static int PayOrder(string number, string orderid, double aneed, double bneed, double cneed, double eneed, int lv, string remark) { int res = 0; try { //判断订单 int ispay = Convert.ToInt32(DBHelper.ExecuteScalar("select DefrayState from memberorder where orderid='" + orderid + "'")); if (ispay > 0) { return(1); } else { int maxexpt = ConfigDAL.GetMaxExpectNum(); SqlTransaction tran = null; SqlConnection conn = null; using (conn = DBHelper.SqlCon()) { conn.Open(); tran = conn.BeginTransaction(); if (aneed > 0 || bneed > 0 || cneed > 0) { //修改会员账户 int r1 = DBHelper.ExecuteNonQuery(tran, "update memberinfo set pointAout=pointAOut+" + aneed + " ,pointBout=pointBout+" + bneed + ", ,pointCout=pointCout+" + cneed + " where number='" + number + "'"); //更新销毁字段 DBHelper.ExecuteNonQuery(tran, "update CoinPlant set CoinDestroy=CoinDestroy+" + aneed + " where CoinIndex='CoinA' ;update CoinPlant set CoinDestroy=CoinDestroy+" + bneed + " where CoinIndex='CoinB' ;update CoinPlant set CoinDestroy=CoinDestroy+" + cneed + " where CoinIndex='CoinC' ; "); if (r1 == 0) { tran.Rollback(); } } string ddremark = "支付订单:"; //插入对账单 if (aneed > 0) { ddremark += "A币支付 " + aneed; int c = D_AccountDAL.AddAccount("A", number, aneed, D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "购买矿机支付", tran); if (c == 0) { tran.Rollback(); } } if (bneed > 0) { ddremark += " B币支付 " + bneed; int c = D_AccountDAL.AddAccount("B", number, bneed, D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "购买矿机支付,订单号" + orderid, tran); if (c == 0) { tran.Rollback(); } } if (cneed > 0) { ddremark += " C币支付 " + cneed; int c = D_AccountDAL.AddAccount("C", number, cneed, D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "购买矿机支付,订单号" + orderid, tran); if (c == 0) { tran.Rollback(); } } int rr = 0; //修改订单状态 rr = DBHelper.ExecuteNonQuery(tran, "update memberorder set DefrayState=1 ,PayExpectNum=" + maxexpt + " ,remark='" + remark + "' where orderid='" + orderid + "' "); double ttpv = Convert.ToDouble(DBHelper.ExecuteScalar(tran, "select isnull(sum(totalpv),0) from memberorder where orderid='" + orderid + "' ", CommandType.Text)); if (ttpv == 0) { DBHelper.ExecuteNonQuery(tran, "update memberinfo set levelint=1 where number='" + number + "' ; update memberinfobalance1 set level=1 where number='" + number + "' "); DBHelper.ExecuteNonQuery(tran, "update memberorder set DefrayState=1 ,PayExpectNum=" + maxexpt + " ,remark='" + remark + "',isactive=1,activeExpectNum=" + maxexpt + " where orderid='" + orderid + "' "); } if (rr == 1) { tran.Commit(); res = 1; } else { tran.Rollback(); } } } } catch (Exception ee) { return(res); } return(res); }