username@email.com
2024-12-31 7dad3e5ef9896edc58a04c7b52e2978c33396d7a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**  
* OrderProgressRate.aspx.cs
*
* 功 能: 订单进度
* 类 名: OrderProgressRate
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013-5-21 9:48        吴崎均    初版
*
*
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using CY.BLL.Sys;
using System.Text;
using CY.BLL.EC;
using CY.Infrastructure.Common;
 
namespace CY.WebForm.Pages.business
{
    /// <summary>
    /// 订单进度
    /// </summary>
    public partial class OrderProgressRate : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack || IsCallback)
            {
                return;
 
            }
            else ;
            string id = Request["id"];
            string typeidStr = Request["typeid"];
            if (string.IsNullOrEmpty(Request["orderId"]) || string.IsNullOrEmpty(id) || string.IsNullOrEmpty(typeidStr))
            {
                return;
            }
 
            try
            {
                int? orderId = MyConvert.ConvertToInt32(id);
                int? typeId = MyConvert.ConvertToInt32(typeidStr);
                if (!orderId.HasValue || !typeId.HasValue) return; else ;
                Sys_DictionaryBLL _sys_DictionaryBLL = new Sys_DictionaryBLL();
                IEnumerable<Sys_Dictionary> types = _sys_DictionaryBLL.GetDataByType("EC_订单状态");
                StringBuilder builder = new StringBuilder();
 
                foreach (Sys_Dictionary item in types)
                {
                    if (0 >= item.MeanValue) continue; else ;//已终止与中断不要
                    //if (0 < typeId.Value && 6 == item.MeanValue) continue; else ;
                    builder.Append(",{");
                    builder.Append(string.Format("id:{0},name:'{1}'", item.MeanValue, 1 == item.MeanValue ? "已下单" : item.Name));
                    builder.Append("}");
                }
                builder.Remove(0, 1);//去掉第一个逗号 
                builder.Insert(0, "[");
                builder.Append("]");
                Request.RequestContext.RouteData.DataTokens.Add("operates", builder.ToString());
 
 
                EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
                IList<EC_OrderOperate> orderOperates = _eC_OrderBasicBLL.SelectOrderOperates(orderId.Value) as IList<EC_OrderOperate>;
 
                if (null == orderOperates || 0 == orderOperates.Count)
                {
                    Request.RequestContext.RouteData.DataTokens.Add("dooperates", builder.ToString());
                    return;
                }
                else ;
 
                EC_OrderOperate lastOperate = orderOperates.OrderBy(p => p.LastUpdateTime).Last();
                if (lastOperate.OperateType != 0&&lastOperate.OperateType != -2)
                {
                    orderOperates = orderOperates.Where(p => (p.OperateType != 0) && (p.OperateType != -2)).ToList<EC_OrderOperate>();
                }
 
                IEnumerable<IGrouping<int?, EC_OrderOperate>> groupOperate = orderOperates.GroupBy(o => o.OperateType);
                builder = new StringBuilder();
                string operateName = null;
                foreach (IGrouping<int?, EC_OrderOperate> group in groupOperate)
                {
                    EC_OrderOperate item = null;
                    if (group.Count() > 1)
                        item = group.OrderBy(obj => obj.LastUpdateTime).Last();//最后一个操作(最后操作时间最大的那个)
                    else
                        item = group.First();//仅有一个取第一个
 
                    builder.Append(",{");
                 
                     Sys_Dictionary [] findResult = types.Where(t => t.MeanValue == item.OperateType).ToArray();
                     operateName = findResult.Length > 0 ? findResult[0].Name : "";
                     builder.Append(string.Format("id:{0},operator:'{1}',dotime:'{2}',name:'{3}'", item.OperateType, item.Operator, item.LastUpdateTime.Value.ToString(UtilConst.DATETIMEFORMAT), operateName));
                    builder.Append("}");
                }
 
 
                builder.Remove(0, 1);//去掉第一个逗号 
                builder.Insert(0, "[");
                builder.Append("]");
 
                Request.RequestContext.RouteData.DataTokens.Add("dooperates", builder.ToString());
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                Response.Write("<script>alert('数据获取失败!');</script>");
                Response.End();
            }
 
 
        }
    }
}