Beispiel #1
0
        public void ExportToExcel(HttpContext context)
        {
            RefundApplyQuery refundApplyQuery = new RefundApplyQuery();

            refundApplyQuery.OrderId      = Globals.UrlDecode(context.Request["OrderId"]);
            refundApplyQuery.HandleStatus = base.GetIntParam(context, "HandleStatus", true);
            refundApplyQuery.RefundIds    = context.Request["Ids"].ToNullString();
            refundApplyQuery.SortBy       = "ApplyForTime";
            refundApplyQuery.SortOrder    = SortAction.Desc;
            IList <RefundModel> refundApplysNoPage = OrderHelper.GetRefundApplysNoPage(refundApplyQuery);
            StringBuilder       stringBuilder      = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>售后编号</th>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>申请时间</th>");
            stringBuilder.Append("<th>匹配门店</th>");
            stringBuilder.Append("<th>处理状态</th>");
            stringBuilder.Append("<th>退款原因</th>");
            stringBuilder.Append("<th>退款金额</th>");
            stringBuilder.Append("<th>处理时间</th>");
            stringBuilder.Append("<th>退款途径</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (RefundModel item in refundApplysNoPage)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ApplyForTime, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD((item.StoreId.HasValue && item.StoreId.Value > 0) ? DepotHelper.GetStoreNameByStoreId(item.StoreId.Value) : "平台店", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.HandleStatus, 0), true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundReason, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundAmount, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.GetDealTime, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.RefundType, 0), true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "RefundApplys" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            if (context.Request["flag"] == "GetFinishedVerificationRecord")
            {
                int storeId   = base.CurrentManager.StoreId;
                int managerId = 0;
                if (base.CurrentManager.RoleId == -3)
                {
                    managerId = base.CurrentManager.ManagerId;
                }
                string     keyword    = context.Request["keyword"].ToNullString();
                Pagination pagination = new Pagination();
                int        num        = context.Request["PageIndex"].ToInt(0);
                if (num < 1)
                {
                    num = 1;
                }
                int num2 = context.Request["PageSize"].ToInt(0);
                if (num2 < 1)
                {
                    num2 = 10;
                }
                pagination.PageIndex = num;
                pagination.PageSize  = num2;
                pagination.SortOrder = SortAction.Desc;
                pagination.SortBy    = "VerificationDate";
                DbQueryResult finishedVerificationRecord = OrderHelper.GetFinishedVerificationRecord(pagination, storeId, keyword, managerId);
                string        s = JsonConvert.SerializeObject(new
                {
                    Result = new
                    {
                        RecordCount = finishedVerificationRecord.TotalRecords,
                        List        = from d in finishedVerificationRecord.Data.AsEnumerable()
                                      select new
                        {
                            OrderId          = d.Field <string>("OrderId"),
                            ProductName      = d.Field <string>("ItemDescription"),
                            ThumbnailsUrl    = Globals.FullPath(d.Field <string>("ThumbnailsUrl")),
                            Price            = d.Field <decimal>("ItemAdjustedPrice").F2ToString("f2"),
                            num              = d.Field <int>("num"),
                            UserName         = d.Field <string>("UserName"),
                            VerificationDate = d.Field <DateTime>("VerificationDate").ToString("yyyy-MM-dd HH:mm:ss")
                        }
                    }
                });
                context.Response.Write(s);
                context.Response.End();
            }
            DateTime value;

            if (context.Request["flag"] == "CheckVerification")
            {
                int    storeId2             = base.CurrentManager.StoreId;
                string verificationPassword = context.Request["VerificationItems"];
                OrderVerificationItemInfo verificationInfoByPassword = OrderHelper.GetVerificationInfoByPassword(verificationPassword);
                if (verificationInfoByPassword == null)
                {
                    context.Response.Write(this.GetErrorJosn(801, "该核销码无效,请重新输入"));
                    return;
                }
                if (verificationInfoByPassword.StoreId != storeId2)
                {
                    context.Response.Write(this.GetErrorJosn(802, "非本门店核销码,请买家核对信息"));
                    return;
                }
                if (verificationInfoByPassword.VerificationStatus == 1)
                {
                    HttpResponse response = context.Response;
                    value = verificationInfoByPassword.VerificationDate.Value;
                    response.Write(this.GetErrorJosn(801, "该核销码 于" + value.ToString("yyyy-MM-dd HH:mm:ss") + "已核销"));
                    return;
                }
                if (verificationInfoByPassword.VerificationStatus == 3)
                {
                    context.Response.Write(this.GetErrorJosn(801, "核销码已过期,无法核销"));
                    return;
                }
                if (verificationInfoByPassword.VerificationStatus == 5)
                {
                    context.Response.Write(this.GetErrorJosn(801, "此核销码已进行售后,无法核销"));
                    return;
                }
                if (verificationInfoByPassword.VerificationStatus == 4)
                {
                    context.Response.Write(this.GetErrorJosn(801, "此核销码正在进行售后,无法核销"));
                    return;
                }
                string s2 = JsonConvert.SerializeObject(new
                {
                    Result = new
                    {
                        Success = new
                        {
                            Status = true,
                            Msg    = "核销码可用"
                        }
                    }
                });
                context.Response.Write(s2);
                context.Response.End();
            }
            decimal num3 = default(decimal);

            if (context.Request["flag"] == "OrderVerification")
            {
                int      storeId3 = base.CurrentManager.StoreId;
                string   text     = context.Request["VerificationItems"];
                string[] array    = text.Split(',');
                DateTime now      = DateTime.Now;
                string   text2    = "";
                OrderVerificationItemInfo orderVerificationItemInfo = null;
                for (int i = 0; i < array.Length; i++)
                {
                    if (!string.IsNullOrEmpty(array[i]))
                    {
                        OrderVerificationItemInfo verificationInfoByPassword2 = OrderHelper.GetVerificationInfoByPassword(array[i]);
                        if (i == 0)
                        {
                            orderVerificationItemInfo = verificationInfoByPassword2;
                            orderVerificationItemInfo.VerificationDate = DateTime.Now;
                        }
                        if (verificationInfoByPassword2 == null)
                        {
                            context.Response.Write(this.GetErrorJosn(801, "该核销码无效,请重新输入"));
                            return;
                        }
                        if (verificationInfoByPassword2.StoreId != storeId3)
                        {
                            context.Response.Write(this.GetErrorJosn(802, "非本门店核销码,请买家核对信息"));
                            return;
                        }
                        if (verificationInfoByPassword2.VerificationStatus == 1)
                        {
                            HttpResponse response2 = context.Response;
                            value = verificationInfoByPassword2.VerificationDate.Value;
                            response2.Write(this.GetErrorJosn(801, "该核销码 于" + value.ToString("yyyy-MM-dd HH:mm:ss") + "已核销"));
                            return;
                        }
                        if (verificationInfoByPassword2.VerificationStatus == 3)
                        {
                            context.Response.Write(this.GetErrorJosn(801, "核销码已过期,无法核销"));
                            return;
                        }
                        if (verificationInfoByPassword2.VerificationStatus == 5)
                        {
                            context.Response.Write(this.GetErrorJosn(801, "此核销码已进行售后,无法核销"));
                            return;
                        }
                        if (verificationInfoByPassword2.VerificationStatus == 4)
                        {
                            context.Response.Write(this.GetErrorJosn(801, "此核销码正在进行售后,无法核销"));
                            return;
                        }
                        verificationInfoByPassword2.VerificationStatus = 1;
                        verificationInfoByPassword2.VerificationDate   = now;
                        verificationInfoByPassword2.ManagerId          = base.CurrentManager.ManagerId;
                        verificationInfoByPassword2.UserName           = base.CurrentManager.UserName;
                        OrderHelper.UpdateVerificationItem(verificationInfoByPassword2);
                        text2 = verificationInfoByPassword2.OrderId;
                    }
                    WXAppletFormDataInfo wxFormData = WeChartAppletHelper.GetWxFormData(WXAppletEvent.ServiceProductValid, text2);
                    if (wxFormData != null)
                    {
                        wxFormData.EventValue += now.ToString("yyyyMMddHHmmss");
                        new WeChatAppletDao().Update(wxFormData, null);
                    }
                }
                OrderInfo serviceProductOrderInfo = OrderHelper.GetServiceProductOrderInfo(text2);
                if (serviceProductOrderInfo != null)
                {
                    num3 = serviceProductOrderInfo.GetTotal(false) / (decimal)serviceProductOrderInfo.GetBuyQuantity() * (decimal)array.Length;
                    MemberInfo user        = Users.GetUser(serviceProductOrderInfo.UserId);
                    string     storeName   = "";
                    string     productName = "";
                    if (serviceProductOrderInfo.StoreId > 0)
                    {
                        storeName = DepotHelper.GetStoreNameByStoreId(serviceProductOrderInfo.StoreId);
                    }
                    if (serviceProductOrderInfo.LineItems != null && serviceProductOrderInfo.LineItems.Count > 0)
                    {
                        productName = serviceProductOrderInfo.LineItems.Values.FirstOrDefault().ItemDescription;
                    }
                    Messenger.ServiceOrderValidSuccess(orderVerificationItemInfo, user, serviceProductOrderInfo, productName, storeName, text, num3);
                    if (OrderHelper.IsVerificationFinished(text2) && serviceProductOrderInfo.ItemStatus == OrderItemStatus.Nomarl)
                    {
                        serviceProductOrderInfo.OrderStatus = OrderStatus.Finished;
                        serviceProductOrderInfo.FinishDate  = DateTime.Now;
                        TradeHelper.UpdateOrderInfo(serviceProductOrderInfo);
                    }
                }
                string s3 = JsonConvert.SerializeObject(new
                {
                    Result = new
                    {
                        Status           = "SUCCESS",
                        VerificationDate = now.ToString("yyyy-MM-dd HH:mm:ss")
                    }
                });
                context.Response.Write(s3);
                context.Response.End();
            }
        }