static void addRefund() { // la documentación de la API está mal, devuelve un objeto Refund en vez de Transaction Paymill.ApiKey = Properties.Settings.Default.ApiKey; Paymill.ApiUrl = Properties.Settings.Default.ApiUrl; RefundService refundService = Paymill.GetService <RefundService>(); Refund refund = new Refund(); refund.Amount = 500; refund.Description = "Prueba desde API c#"; refund.Transaction = new Transaction() { Id = "tran_a7c93a1e5b431b52c0f0" }; Refund newRefund = refundService.AddRefund(refund); Console.WriteLine("RefundID:" + newRefund.Id); Console.Read(); }
public static void UpdateSiteTotal(string nick, string session, DateTime now, SiteTotalService taoDal) { RefundService refDal = new RefundService(); TaoBaoGoodsOrderService tbgoDal = new TaoBaoGoodsOrderService(); List <RefundInfo> refundList = (List <RefundInfo>)TaoBaoAPI.GetRefundInfoList(now.AddDays(-2), now, nick, session, "SUCCESS"); //所有有订单的用户 TopSiteTotalInfo stinfo = taoDal.GetOrderTotalPay(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick); //所有表名(添加过统计代码到网页的) List <string> tableList = taoDal.GetTableName(); string tablename = GetTableName(nick); List <string> mytablelist = tableList.Where(o => o == tablename).ToList(); TopSiteTotalInfo addup = new TopSiteTotalInfo(); addup.SiteNick = nick; addup.SiteTotalDate = now.ToString("yyyyMMdd"); //给询单数赋值 addup.AskOrder = new TalkRecodService().GetCustomerList(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick).Count; //有添加统计代码 if (mytablelist.Count > 0) { //有订单 if (stinfo != null) { addup.SiteOrderCount = stinfo.SiteOrderCount; addup.SiteOrderPay = stinfo.SiteOrderPay; addup.PostFee = stinfo.PostFee; addup.SiteBuyCustomTotal = stinfo.SiteBuyCustomTotal; addup.SiteSecondBuy = taoDal.GetSecondBuyTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick); } TopSiteTotalInfo puvinfo = taoDal.GetPvUvTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), tablename); addup.SiteUVCount = puvinfo.SiteUVCount; addup.SitePVCount = puvinfo.SitePVCount; addup.ZhiTongFlow = taoDal.GetZhiTongTotal(now, now.AddDays(1), tablename); addup.SiteZuanZhan = taoDal.GetZuanZhanTotal(now, now.AddDays(1), tablename); addup.SiteUVBack = taoDal.GetBackTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), tablename); } else { //有订单 if (stinfo != null) { addup.SiteOrderCount = stinfo.SiteOrderCount; addup.SiteOrderPay = stinfo.SiteOrderPay; addup.PostFee = stinfo.PostFee; addup.SiteBuyCustomTotal = stinfo.SiteBuyCustomTotal; addup.SiteSecondBuy = taoDal.GetSecondBuyTotal(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick); } } IList <string> tidList = taoDal.GetOrderIds(DateTime.Parse(now.ToShortDateString()), DateTime.Parse(now.AddDays(1).ToShortDateString()), nick); if (tidList.Count > 0) { addup.GoodsCount = taoDal.GetGoodsCount(tidList); } List <RefundInfo> hadReList = refDal.GetAllRefund(nick, now.AddDays(-2), now); //退款情况 List <RefundInfo> trefundList = refundList.Where(o => o.modified.ToShortDateString() == now.ToShortDateString()).ToList(); if (trefundList.Count > 0) { int rorderCount = 0; decimal rpay = 0; foreach (RefundInfo refund in new List <RefundInfo>(trefundList)) { if (!tidList.Contains(refund.tid)) { GoodsOrderInfo roinfo = tbgoDal.GetGoodsOrderInfo(refund.tid); if (roinfo == null) { continue; } else { if (hadReList.Where(o => o.tid == refund.tid).ToList().Count > 0) { continue; } if (roinfo.pay_time != DateTime.Parse("1990-1-1")) { refund.OrderTime = roinfo.pay_time; } else { refund.OrderTime = roinfo.created; } refund.seller_nick = nick; refDal.AddRefund(refund); //需要查询这一天有多少订单 RefundInfo newrefund = refDal.GetRefundTotal(nick, DateTime.Parse(refund.OrderTime.ToShortDateString()), DateTime.Parse(refund.OrderTime.ToShortDateString()).AddDays(1)); taoDal.UpdateGoodsOrderInfo(nick, refund.OrderTime.ToString("yyyyMMdd"), newrefund.total_fee, newrefund.num); } continue; } rorderCount++; rpay += (refund.total_fee - refund.payment); } addup.RefundOrderCount = rorderCount; addup.RefundMoney = rpay; } taoDal.AddOrUp(addup); }