Exemple #1
0
 public static bool EnsureRefund(string orderId, string Operator, string adminRemark, int refundType, bool accept)
 {
     RefundDao dao = new RefundDao();
     RefundInfo byOrderId = dao.GetByOrderId(orderId);
     byOrderId.Operator = Operator;
     byOrderId.AdminRemark = adminRemark;
     byOrderId.HandleTime = DateTime.Now;
     byOrderId.HandleStatus = accept ? RefundInfo.Handlestatus.Refunded : RefundInfo.Handlestatus.Refused;
     byOrderId.OrderId = orderId;
     OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId);
     using (TransactionScope scope = new TransactionScope())
     {
         OrderHelper.SetOrderState(orderId, accept ? OrderStatus.Refunded : OrderStatus.BuyerAlreadyPaid);
         dao.UpdateByOrderId(byOrderId);
         if (orderInfo.GroupBuyId > 0)
         {
             GroupBuyHelper.RefreshGroupFinishBuyState(orderInfo.GroupBuyId);
         }
         scope.Complete();
     }
     return true;
 }
Exemple #2
0
 private bool SetGroupBuyFailed(int groupBuyId)
 {
     IDataReader reader;
     StringBuilder builder = new StringBuilder();
     builder.Append("update Hishop_Orders set OrderStatus = 6 where GroupBuyId = @GroupBuyId and OrderStatus = 2;");
     builder.AppendFormat("update Hishop_Orders set OrderStatus = 4,CloseReason='{0}' where GroupBuyId = @GroupBuyId and OrderStatus = 1;", "团购失败,自动关闭");
     builder.Append("UPDATE Hishop_GroupBuy SET Status = 5,SoldCount = 0 WHERE GroupBuyId = @GroupBuyId AND (select Count(1) from Hishop_Orders where GroupBuyId = @GroupBuyId and OrderStatus = 6) >0;");
     builder.Append("UPDATE Hishop_GroupBuy SET Status = 4,SoldCount = 0 WHERE GroupBuyId = @GroupBuyId AND (select Count(1) from Hishop_Orders where GroupBuyId = @GroupBuyId and OrderStatus = 6) =0;");
     builder.Append("  select OrderId,TelPhone,CellPhone,ShippingRegion+[Address] as [Address],ShipTo from Hishop_Orders where GroupBuyId = @GroupBuyId and OrderStatus = 6; ");
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
     using (reader = this.database.ExecuteReader(sqlStringCommand))
     {
         RefundInfo refundInfo = new RefundInfo();
         RefundDao dao = new RefundDao();
         while (reader.Read())
         {
             refundInfo.OrderId = reader["OrderId"].ToString();
             refundInfo.RefundRemark = "团购失败,申请退款";
             refundInfo.ApplyForTime = DateTime.Now;
             refundInfo.HandleStatus = RefundInfo.Handlestatus.Applied;
             dao.AddRefund(refundInfo);
         }
     }
     builder.Clear();
     builder.Append("select c.SkuId,c.Quantity from Hishop_GroupBuy a left join Hishop_Orders b on a.GroupBuyId = b.GroupBuyId left join Hishop_OrderItems c on b.OrderId = c.OrderId left join Hishop_SKUs d on c.SkuId = d.SkuId where a.GroupBuyId =@GroupBuyId and b.OrderStatus = 6");
     sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
     Dictionary<string, int> source = new Dictionary<string, int>();
     using (reader = this.database.ExecuteReader(sqlStringCommand))
     {
         while (reader.Read())
         {
             Dictionary<string, int> dictionary2;
             string str2;
             string key = reader.GetString(0);
             if (!source.ContainsKey(key))
             {
                 source[key] = 0;
             }
             (dictionary2 = source)[str2 = key] = dictionary2[str2] + reader.GetInt32(1);
         }
     }
     builder.Clear();
     for (int i = 0; i < source.Count; i++)
     {
         builder.AppendFormat("update Hishop_SKUs set Stock=Stock+{1} where SKUId = '{0}';", source.ElementAt<KeyValuePair<string, int>>(i).Key, source.ElementAt<KeyValuePair<string, int>>(i).Value);
     }
     this.database.ExecuteNonQuery(CommandType.Text, builder.ToString());
     return true;
 }