public bool AddOrder(ClientOrder order) { if (order.Detials.Any(x => x.Amount < 1) || order.Detials.Any(y => y.Price <= 0)) { return(false); } try { OrderBase createOrder = new OrderBase(); createOrder.AccountId = order.AccountId; createOrder.Address = order.Address; createOrder.Creater = order.Creater; createOrder.OrderId = GetOrderSerialnumber(); createOrder.State = OrderState.Normal; createOrder.SubmitTime = DateTime.Now; createOrder.TotalMoney = order.Detials.Sum(x => x.Amount * x.Price); transactionHelper.BeginTransaction(); foreach (var item in order.Detials) { OrderDetialBase detial = new OrderDetialBase(); detial.Amount = item.Amount; detial.GoodId = item.CommodityId; detial.OrderId = createOrder.OrderId; detial.price = item.Price; _databaseInstance.Insert(detial, OrderTable); } _databaseInstance.Insert(createOrder, OrderDetialTable); return(transactionHelper.CommitAndReturn(true)); } catch { return(false); } }
public int Save(PrePay prePay) { if (prePay.PrePayId != 0) { prePay.UpdateTime = DateTime.Now; return(_databaseInstance.Update(prePay, "PrePays")); } else { prePay.UpdateTime = prePay.SubmitTime; prePay.PrePayId = _databaseInstance.Insert(prePay, "PrePays"); return(prePay.PrePayId); } }
protected override void OnExecute(DateTime date) { var start = new DateTime(date.Year, date.Month, 1); var end = new DateTime(date.AddMonths(1).Year, date.AddMonths(1).Month, 1); // 1, pay, 4 doneprepay, 3, cancel, 6, canceldoneprepay var sql = string.Format( @"select 0 ShopMonthReportId, convert(varchar(50), DatePart(yyyy, submittime)) + '-' + convert(varchar(50), DatePart(mm, submittime)) as month, accountId, accountName, sum(amount) dealamount from deallogs where (state <> {0}) and submittime >= @start and submittime < @end group by accountName, convert(varchar(50), DatePart(yyyy, submittime)) + '-' + convert(varchar(50), DatePart(mm, submittime)), accountId", DealLogStates.Normal_); var parameters = new { start = start, end = end, }; var reports = DatabaseInstance.Query <AccountMonth>(sql, parameters).ToList(); reports.ForEach(x => x.Month = start.Date.ToString("yyyy-MM")); DatabaseInstance.ExecuteNonQuery("delete ReportAccountMonth where month = '" + start.Date.ToString("yyyy-MM") + "'", null); foreach (var report in reports) { DatabaseInstance.Insert(report, "ReportAccountMonth"); } }
public void Create(SystemDealLog item) { lock (SiteAccount.Locker) { //if (!_databaseInstance.InTransaction) // throw new Exception("SystemDealLog have to run in transaction"); //_databaseInstance.ExecuteNonQuery("update siteaccounts set amount = amount + @amount", // new { amount = item.Amount }); //var siteAccount = _databaseInstance.Query<SiteAccount>("select * from siteaccounts", null).FirstOrDefault(); //if (siteAccount == null) // throw new Exception("siteaccounts table changed, please check it"); //item.SiteAmount = siteAccount.Amount ; item.SystemDealLogId = _databaseInstance.Insert(item, TableName); } }
protected override void OnExecute(DateTime date) { DateTime start = date.Date; DateTime end = date.Date.AddDays(1); string sql = string.Format( @"select 0 as SystemDealLogByUserId, userId, @start as SubmitDate, sum(amount) as SumAmount, avg(amount) as AvgAmount, count(*) as [Count], DealType from systemdeallogs where state = 1 and submittime >= @start and submittime < @end group by userid, dealtype "); List <SystemDealLogByUser> reports = DatabaseInstance.Query <SystemDealLogByUser>(sql, new { start, end }).ToList(); DatabaseInstance.ExecuteNonQuery( "delete ReportSystemDealLogByUser where submitdate = @start", new { start }); foreach (SystemDealLogByUser report in reports) { DatabaseInstance.Insert(report, "ReportSystemDealLogByUser"); } }
protected override void OnExecute(DateTime date) { var start = date.Date; var end = date.Date.AddDays(1); // 1, pay, 4 doneprepay, 3, cancel, 6, canceldoneprepay var sql = string.Format( @"select 0 AccountDealsReportId, AccountId, isnull((select sum(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 1 and t1.submittime >= @start and t1.submittime < @end), 0.0) as PayAmount, isnull((select count(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 1 and t1.submittime >= @start and t1.submittime < @end), 0.0) as PayCount, isnull((select sum(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 4 and t1.submittime >= @start and t1.submittime < @end), 0.0) as DonePrepayAmount, isnull((select count(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 4 and t1.submittime >= @start and t1.submittime < @end), 0.0) as DonePrepayCount, isnull((select sum(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 2 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelAmount, isnull((select count(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 2 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelCount, isnull((select sum(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 6 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelDonePrepayAmount, isnull((select count(t1.amount) from deallogs t1 where t1.AccountId = t.AccountId and t1.state <> {0} and t1.dealtype = 6 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelDonePrepayCount, isnull((select count(*) from deallogs t1 where t1.AccountId = t.AccountId and t1.state = {0} and t1.submittime >= @start and t1.submittime < @end), 0) as UnPayCount, accountName from deallogs t where (state <> {0}) and submittime >= @start and submittime < @end group by accountName, AccountId", DealLogStates.Normal_); var parameters = new { start = start, end = end, }; var reports = DatabaseInstance.Query <AccountDeal>(sql, parameters).ToList(); reports.ForEach(x => x.SubmitDate = start); DatabaseInstance.ExecuteNonQuery("delete ReportAccountDeals where submitdate = @submitdate", new { submitdate = start }); foreach (var report in reports) { DatabaseInstance.Insert(report, "ReportAccountDeals"); } }
private List <AccountUser> GetAccounts() { List <AccountUser> accountUsers = new List <AccountUser>(); var reportSetting = _databaseInstance.Query <ReportSetting>("select * from reportsettings where reportType='smsbirthdate'", null). FirstOrDefault() ?? new ReportSetting() { ReportType = "smsbirthdate", Value = DateTime.Now.Date.AddDays(-1).ToString("yyyy-MM-dd") }; var lastTime = DateTime.Parse(reportSetting.Value); if (reportSetting.ReportSettingId == 0) { reportSetting.ReportSettingId = _databaseInstance.Insert(reportSetting, "reportsettings"); } if (lastTime.Date < DateTime.Now.Date) { var now = DateTime.Now; var sql = @"select * from users where state = 1 and birthdate is not null and DatePart(mm, birthdate) = @month and DatePart(dd, birthdate) = @day "; var parameters = new { month = now.Month, day = now.Day, }; var users = _databaseInstance.Query <AccountUser>(sql, parameters).ToList(); reportSetting.Value = now.ToString("yyyy-MM-dd"); _databaseInstance.Update(reportSetting, "reportsettings"); return(users); } return(accountUsers); }
public int Insert(UserAddress item) { return(_databaseInstance.Insert(item, TableName)); }
public void Create(Log item) { item.LogId = _databaseInstance.Insert(item, TableName); }
public int Insert(Models.OrangeKeyAndopenID item) { return(_databaseInstance.Insert(item, TableName)); }
public void Create(Account item) { item.AccountId = _databaseInstance.Insert(item, TableName); }
public void Create(AdmissionTicket item) { item.id = _databaseInstance.Insert(item, TableName); }
public int Insert(Models.Commodity item) { return(_databaseInstance.Insert(item, TableName)); }
public void Create(UserCoupons item) { item.id = _databaseInstance.Insert(item, TableName); }
public void Create(Models.RechargingLog item) { item.RechargingLogId = _databaseInstance.Insert(item, TableName); }
public void Execute() { _instance.BeginTransaction(); // state preview month data var reportSetting = _instance.Query <ReportSetting>("select * from reportsettings where reportType='shopDeals'", null).FirstOrDefault() ?? new ReportSetting() { ReportType = "shopDeals", Value = "2009-1-1" }; var lastTime = DateTime.Parse(reportSetting.Value); while (lastTime.Date < DateTime.Now.Date) { var start = lastTime.Date; var end = lastTime.Date.AddDays(1); // 1, pay, 4 doneprepay, 3, cancel, 6, canceldoneprepay var sql = string.Format( @"select 0 ShopDealsReportId, ShopId, isnull((select sum(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 1 and t1.submittime >= @start and t1.submittime < @end), 0.0) as PayAmount, isnull((select count(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 1 and t1.submittime >= @start and t1.submittime < @end), 0.0) as PayCount, isnull((select sum(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 4 and t1.submittime >= @start and t1.submittime < @end), 0.0) as DonePrepayAmount, isnull((select count(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 4 and t1.submittime >= @start and t1.submittime < @end), 0.0) as DonePrepayCount, isnull((select sum(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 2 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelAmount, isnull((select count(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 2 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelCount, isnull((select sum(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 6 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelDonePrepayAmount, isnull((select count(t1.amount) from deallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = 6 and t1.submittime >= @start and t1.submittime < @end), 0.0) as CancelDonePrepayCount, isnull((select count(*) from deallogs t1 where t1.shopId = t.shopId and t1.state = {0} and t1.submittime >= @start and t1.submittime < @end), 0) as UnPayCount, isnull((select sum(t1.amount) from shopdeallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = {1} and t1.submittime >= @start and t1.submittime < @end), 0.0) as ShopDealLogDoneAmount, isnull((select sum(t1.amount) from shopdeallogs t1 where t1.shopId = t.shopId and t1.state <> {0} and t1.dealtype = {2} and t1.submittime >= @start and t1.submittime < @end), 0.0) as ShopDealLogChargeAmount, name shopName from shops t group by Name, ShopId", DealLogStates.Normal_, CashDealLogTypes.ShopDealLogDone, CashDealLogTypes.ShopDealLogCharging); var parameters = new { start = start, end = end, }; var reports = _instance.Query <ShopDeal>(sql, parameters).ToList(); reports.ForEach(x => x.SubmitDate = start); _instance.ExecuteNonQuery("delete ReportShopDeals where submitdate = @submitdate", new { submitdate = start }); foreach (var report in reports) { _instance.Insert(report, "ReportShopDeals"); } lastTime = (DateTime.Now.Date < end) ? DateTime.Now.Date : end; reportSetting.Value = lastTime.ToString("yyyy-MM-dd"); if (reportSetting.ReportSettingId == 0) { reportSetting.ReportSettingId = _instance.Insert(reportSetting, "reportsettings"); } else { _instance.Update(reportSetting, "reportsettings"); } } _instance.Commit(); }
public void Create(RollbackShopDealLog item) { item.RollbackShopDealLogId = _databaseInstance.Insert(item, TableName); }
public void Create(TemporaryTokenKey item) { item.TemporaryTokenKeyId = _databaseInstance.Insert(item, TableName); }
public void Create(PointRebateLog item) { item.PointRebateLogId = _databaseInstance.Insert(item, TableName); }
public int Insert(Order item) { return(_databaseInstance.Insert(item, TableName)); }
public int Insert(ShoppingCart item) { return(_databaseInstance.Insert(item, TableName)); }
public void Create(Sms item) { item.SmsId = _databaseInstance.Insert(item, TableName); }
public void Create(PrintTicket item) { item.PrintTicketId = _databaseInstance.Insert(item, TableName); }
public void Insert(TicketOff item) { item.id = _databaseInstance.Insert(item, TableName); }
public int Insert(Models.Fz_Messages item) { return(_databaseInstance.Insert(item, TableName)); }
public void Insert(PostToken item) { item.id = _databaseInstance.Insert(item, TableName); }
protected void Page_Load(object sender, EventArgs e) { WxPayAPI.Log.Info(this.GetType().ToString(), "--异步回调处理开始--"); Dictionary <string, string> data = GetRequestPost(); string notify_id = Request.Form["notify_id"]; //获取notify_id string sign = Request.Form["sign"]; //获取sign string SerialNo = Request.Form["out_trade_no"]; string TradeNo = Request.Form["trade_no"]; string price = Request.Form["buyer_pay_amount"]; string trade_status = Request.Form["trade_status"]; string gmt_payment = Request.Form["notify_time"]; WxPayAPI.Log.Info("Form:", AlipaySignature.GetSignContent(data)); if (notify_id == null || notify_id == "") { WxPayAPI.Log.Info("", "参数错误"); return; } Notify aliNotify = new Notify(); if (aliNotify.GetResponseTxt(notify_id) != "true") { WxPayAPI.Log.Info("", "参数错误"); return; } WxPayAPI.Log.Info("订单号:", SerialNo); bool flag = aliNotify.GetSignVeryfy(data, sign); //AlipaySignature.RSACheckV1(sPara, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, "RSA", false); // bool checkSign = AlipaySignature.RSACheckV2(data, AlipayConfig.ALIPAY_PUBLIC_KEY); if (flag) { WxPayAPI.Log.Info("", "验签成功"); _database = new Database("ecard"); using (var _databaseInstance = new DatabaseInstance(_database)) { var sql = "select * from fz_Orders where orderNo=@orderNo"; var item = new QueryObject <Ecard.Models.Order>(_databaseInstance, sql, new { orderNo = SerialNo }).FirstOrDefault(); if (item != null) { if (item.payState == Ecard.Models.PayStates.non_payment && item.orderState == Ecard.Models.OrderStates.awaitPay) { WxPayAPI.Log.Info("payAmount", item.payAmount.ToString()); WxPayAPI.Log.Info("price", price); decimal amount = 0; decimal.TryParse(price, out amount); WxPayAPI.Log.Info("amount", amount.ToString()); if (item.payAmount == amount) { WxPayAPI.Log.Info("金额", "成功"); _databaseInstance.BeginTransaction(); item.payState = Ecard.Models.PayStates.paid; item.orderState = Ecard.Models.OrderStates.paid; item.payType = PayTypes.Alipay; item.submitTime = DateTime.Now; _databaseInstance.Update(item, "fz_Orders"); var sql2 = "select * from fz_Accounts where accountId=@accountId"; var item2 = new QueryObject <Ecard.Models.Account>(_databaseInstance, sql2, new { accountId = item.userId }).FirstOrDefault(); if (item2 != null) { if (!string.IsNullOrWhiteSpace(item2.openID)) { var message = new Fz_Messages(); message.accountId = item2.accountId; message.openId = item2.openID; message.state = MessagesState.staySend; message.submitTime = DateTime.Now; message.keyword1 = item.orderNo; message.keyword2 = "已付款"; message.msgType = MsgType.orderState; _databaseInstance.Insert(message, "Fz_Messages"); } } _databaseInstance.Commit(); } } } } WxPayAPI.Log.Info("交易", "成功"); //交易成功 Response.Write("success"); } else { WxPayAPI.Log.Info("", "验签失败"); } }
public int Insert(Models.fz_OperationAmountLogs item) { return(_databaseInstance.Insert(item, TableName)); }
public int Insert(RecommendLog item) { return(_databaseInstance.Insert(item, TableName)); }
public int Insert(Specification item) { return(_databaseInstance.Insert(item, TableName)); }