This repository has been archived by the owner on Sep 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrderDetailForYWY.aspx.cs
472 lines (453 loc) · 18.7 KB
/
OrderDetailForYWY.aspx.cs
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
using System;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WXShare
{
public partial class OrderDetailForYWY : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// 不是微信内置浏览器
if (!WXManage.IsWXBrowser(Request))
{
Response.Redirect("/RequireWX.aspx?url=" + Request.Url);
return;
}
if (Session["phone"] == null || Session["iden"].ToString() != "2")
{
Response.Redirect("/UserIndex.aspx");
return;
}
if (Request.QueryString["oid"] == null)
{
Response.Clear();
Response.Redirect("/OrdersForYWY.aspx");
return;
}
// 获取订单信息
var oid = Request.QueryString["oid"];
var order = DataBase.Order.GetByID(new Objects.Order()
{
id = oid
});
inputName.Value = order.name;
inputPhone.Value = order.phone;
inputLocation.Value = order.location;
inputLocationDetail.Value = order.locationDetail;
inputStatus.Value = new DataBase.Status()
.Get(
new Objects.Status()
{
id = order.status.ToString()
}
)
.view;
// 获取活动优惠
var activity = DataBase.Activity.Get(new Objects.Activity() { id = order.youHuiLaiYuan.ToString() });
inputYouHui.Attributes["data-t"] = activity.template.ToString();
inputYouHui.Attributes["data-a"] = activity.templateAddition;
if (activity.template == 1)
{
var addition = activity.templateAddition.Split(',');
inputYouHui.Value = "满" + addition[0] + "减" + addition[1];
}
else if (activity.template == 2)
{
var addition = activity.templateAddition.Split(',');
inputYouHui.Value = "满" + addition[0] + "赠送" + addition[1];
}
HideOthers(order.status);
// 派单完成
if (order.status == 0)
{
// 获取涂刷类型
var brushType = new DataBase.BrushType().Gets();
typeSelect.Items.Clear();
typeSelect.Items.Add(new ListItem("选择涂刷类型", "0"));
foreach (var type in brushType)
{
if (type.id == "0")
{
continue;
}
typeSelect.Items.Add(new ListItem(type.view, type.id));
}
// 获取涂刷需求
string demandHtml =
"<label class=\"weui-cell weui-check__label\" for=\"#id#\">" +
" <div class=\"weui-cell__hd\">" +
" <input type=\"checkbox\" class=\"weui-check\" name=\"select_#id#\" id=\"#id#\">" +
" <i class=\"weui-icon-checked\"></i>" +
" </div>" +
" <div class=\"weui-cell__bd\">" +
" <p>#content#</p>" +
" </div>" +
"</label>";
var brushDemand = new DataBase.BrushDemand().Gets();
demandList.InnerHtml = "";
foreach (var demand in brushDemand)
{
if (demand.id == "0")
{
continue;
}
demandList.InnerHtml += demandHtml
.Replace("#id#", demand.id)
.Replace("#content#", demand.view);
}
}
// 订单取消
else if (order.status == 1)
{
requiredHint.InnerHtml = "";
requiredHint.Style["display"] = "none";
}
// 预约基检
else if (order.status == 2)
{
// 获取房屋用途
var housePurpose = new DataBase.HousePurpose().Gets();
housePurposeSelect.Items.Clear();
housePurposeSelect.Items.Add(new ListItem("选择房屋用途", "0"));
foreach (var purpose in housePurpose)
{
if (purpose.id == "0")
{
continue;
}
housePurposeSelect.Items.Add(new ListItem(purpose.view, purpose.id));
}
// 获取房屋类型
var houseType = new DataBase.HouseType().Gets();
houseTypeSelect.Items.Clear();
houseTypeSelect.Items.Add(new ListItem("选择房屋类型", "0"));
foreach (var type in houseType)
{
if (type.id == "0")
{
continue;
}
houseTypeSelect.Items.Add(new ListItem(type.view, type.id));
}
// 获取房屋结构
var houseStructure = new DataBase.HouseStructure().Gets();
houseStructureSelect.Items.Clear();
houseStructureSelect.Items.Add(new ListItem("选择房屋结构", "0"));
foreach (var structure in houseStructure)
{
if (structure.id == "0")
{
continue;
}
houseStructureSelect.Items.Add(new ListItem(structure.view, structure.id));
}
// 判断基检是否已经开始
if (order.comCheckTime == DateTime.Parse("2017-01-01 00:00:00"))
{
// 未开始
start.Style["display"] = "";
status_2.InnerHtml = "";
inputStatus.Value += " - " + order.comCheckOrderTime.ToString("yyyy-MM-dd HH:mm:ss");
}
else
{
// 正在基检
finish.Style["display"] = "";
inputStatus.Value = "正在基检 - " + order.comCheckTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
// 基检完成
else if (order.status == 3)
{
//
}
// 签约成功
else if(order.status == 5)
{
//
}
// 签约失败、其他
else
{
requiredHint.InnerHtml = "";
requiredHint.Style["display"] = "none";
}
if (order.status > 0)
{
// 显示预约的内容
inputBrushType.Value = new DataBase.BrushType().Get(new Objects.BrushType() { id = order.brushType.ToString() }).view;
inputBrushDemand.Value = "";
foreach (var dem in order.brushDemand.Split(','))
{
inputBrushDemand.Value += new DataBase.BrushDemand().Get(new Objects.BrushDemand() { id = dem }).view + ",";
}
inputBrushDemand.Value = inputBrushDemand.Value.Substring(0, inputBrushDemand.Value.Length - 1);
}
if (order.status > 2)
{
// 显示基检内容
inputHousePurpose.Value = new DataBase.HousePurpose().Get(new Objects.HousePurpose() { id = order.housePurpose.ToString() }).view;
inputHouseType.Value = new DataBase.HouseType().Get(new Objects.HouseType() { id = order.houseType.ToString() }).view;
inputHouseStructure.Value = new DataBase.HouseStructure().Get(new Objects.HouseStructure() { id = order.houseStructure.ToString() }).view;
inputMianJiSubmitted.Value = order.mianJi.ToString();
inputNeiQiangSubmitted.Value = order.neiQiang.ToString();
inputYiShuQiSubmitted.Value = order.yiShuQi.ToString();
inputWaiQiangSubmitted.Value = order.waiQiang.ToString();
inputYangTaiSubmitted.Value = order.yangTai.ToString();
inputMuQiSubmitted.Value = order.muQi.ToString();
inputTieYiSubmitted.Value = order.tieYi.ToString();
}
if (order.status > 3)
{
inputWorkOrderDateSubmitted.Value = order.workOrderDate.ToString("yyyy-MM-dd");
inputWorkCompleteOrderDateSubmitted.Value = order.workCompleteOrderDate.ToString("yyyy-MM-dd");
inputContractNumberSubmitted.Value = order.contractNumber;
}
// 收款完成+ 不含合同退单
if(order.status > 5 && order.status != 7)
{
var sum = order.smSum + order.mmSum + order.workSum;
if(activity.template == 1)
{
if(sum >= int.Parse(activity.templateAddition.Split(',')[0]))
{
sum -= int.Parse(activity.templateAddition.Split(',')[1]);
}
}
cashRec.Value = sum.ToString("0.0");
}
inputMMSumSubmitted.Value = order.mmSum.ToString("0.0");
inputSMSumSubmitted.Value = order.smSum.ToString("0.0");
inputWorkSumSubmitted.Value = order.workSum.ToString("0.0");
}
protected void saveBtn_Click(Object sender, EventArgs e)
{
var brushType = Request.Form["typeSelect"];
if (brushType == "0")
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('请选择涂刷类型')", true);
return;
}
var brushDemand = "";
foreach (var key in Request.Form.AllKeys)
{
if (Regex.IsMatch(key, "^select_\\d?$"))
{
brushDemand += key.Split('_')[1] + ",";
}
}
if (brushDemand == "")
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('请选择涂刷需求')", true);
return;
}
else
{
// 删除最后一个逗号
brushDemand = brushDemand.Substring(0, brushDemand.Length - 1);
}
var comOrderTime = DateTime.Parse(Request.Form["comOrderTime"].Replace("T", " "));
if (!DataBase.Order.CommissionerOrderToCustomer(
new Objects.Order()
{
id = Request.QueryString["oid"],
brushType = int.Parse(brushType),
brushDemand = brushDemand,
comOrderTime = comOrderTime,
comCheckOrderTime = comOrderTime
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('保存失败,服务器错误')", true);
return;
}
Response.Redirect(Request.Url.ToString());
}
protected void cancelBtn_Click(Object sender, EventArgs e)
{
var oid = Request.QueryString["oid"];
var cancelReason = Request.Form["cancelReason"];
if (!DataBase.Order.CancelOrder(
new Objects.Order()
{
id = oid,
canceledReason = cancelReason
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('取消订单失败,服务器错误')", true);
return;
}
Response.Redirect(Request.Url.ToString());
}
protected void startCheck_Click(Object sender, EventArgs e)
{
if (!DataBase.Order.CommissionerCheck(new Objects.Order()
{
id = Request.QueryString["oid"],
comCheckTime = DateTime.Now
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('无法开始基检,系统错误');", true);
return;
}
Response.Redirect(Request.Url.ToString());
}
protected void finishCheck_Click(Object sender, EventArgs e)
{
if (!DataBase.Order.CommissionerCheckComplete(new Objects.Order()
{
id = Request.QueryString["oid"],
housePurpose = int.Parse(Request.Form["housePurposeSelect"]),
houseType = int.Parse(Request.Form["houseTypeSelect"]),
houseStructure = int.Parse(Request.Form["houseStructureSelect"]),
mianJi = int.Parse(Request.Form["inputMianji"]),
neiQiang = int.Parse(Request.Form["inputNeiQiang"]),
yiShuQi = int.Parse(Request.Form["inputYiShuQi"]),
waiQiang = int.Parse(Request.Form["inputWaiQiang"]),
yangTai = int.Parse(Request.Form["inputYangTai"]),
muQi = int.Parse(Request.Form["inputMuQi"]),
tieYi = int.Parse(Request.Form["inputTieYi"])
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('无法完成基检,系统错误')", true);
return;
}
Response.Redirect(Request.Url.ToString());
}
protected void orderFailed_Click(Object sender, EventArgs e)
{
var reason = Request.Form["orderFailedReason"];
if (!DataBase.Order.SignFailed(new Objects.Order()
{
id = Request.QueryString["oid"],
signFailedReason = reason
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('无法完成操作,系统错误')", true);
return;
}
Response.Redirect(Request.Url.ToString());
}
protected void signOrder_Click(Object sender, EventArgs e)
{
var workOrderDate = DateTime.Parse(Request.Form["workOrderDate"].Replace('T', ' '));
var timeLimitOrder = int.Parse(Request.Form["timeLimitOrder"]);
var workCompleteOrderDate = workOrderDate.AddDays(timeLimitOrder);
var contractNumber = Request.Form["contractNumber"];
if (!DataBase.Order.SignTheOrder(new Objects.Order()
{
id = Request.QueryString["oid"],
workOrderDate = workOrderDate,
timeLimitOrder = timeLimitOrder,
workCompleteOrderDate = workCompleteOrderDate,
contractNumber = contractNumber
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('无法完成签约,系统错误')", true);
return;
};
Response.Redirect(Request.Url.ToString());
}
protected void HideOthers(int show)
{
if (show != 0)
{
status_0.InnerHtml = "";
status_0.Style["display"] = "none";
statusBtn_0.InnerHtml = "";
statusBtn_0.Style["display"] = "none";
}
if (show != 2)
{
status_2.InnerHtml = "";
status_2.Style["display"] = "none";
statusBtn_2.InnerHtml = "";
statusBtn_2.Style["display"] = "none";
}
if (show != 3)
{
status_3.InnerHtml = "";
status_3.Style["display"] = "none";
statusBtn_3.InnerHtml = "";
statusBtn_3.Style["display"] = "none";
}
if(show != 4)
{
status_4.InnerHtml = "";
status_4.Style["display"] = "none";
statusBtn_4.InnerHtml = "";
statusBtn_4.Style["display"] = "none";
}
}
protected void cash_Click(object sender, EventArgs e)
{
var mmSum = float.Parse(Request.Form["inputMMSum"]);
var smSum = float.Parse(Request.Form["inputSMSum"]);
var workSum = float.Parse(Request.Form["inputWorkSum"]);
if(!DataBase.Order.Cashed(new Objects.Order()
{
id = Request.QueryString["oid"],
mmSum = mmSum,
smSum = smSum,
workSum = workSum
}))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('无法完成收款,系统错误')", true);
return;
}
var admins = DataBase.User.Gets("5");
foreach(var admin in admins)
{
var openID = DataBase.User.GetOpenID(admin);
if(openID != "")
{
WXManage.SendMessage(openID, "一个订单收款完成,前往派工:http://debug.ocrosoft.com/OrderDetail.aspx?oid=" + Request.QueryString["oid"]);
}
}
Response.Redirect(Request.Url.ToString());
}
protected void refuse_Click(object sender, EventArgs e)
{
var reason = Request.Form["refuseReason"];
var order = new Objects.Order()
{
id = Request.QueryString["oid"]
};
order = DataBase.Order.GetByID(order);
order.refuseReason = reason;
if(!DataBase.Order.RefuseOrder(order))
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "alert('无法完成退单,系统错误')", true);
return;
}
// 给管理员发送消息
var admins = DataBase.User.Gets("5");
foreach(var admin in admins)
{
var openID = DataBase.User.GetOpenID(admin);
if(!string.IsNullOrEmpty(openID))
{
WXManage.SendMessage(openID, "一个订单被退单");
}
}
// 已经派工也给施工队发送提醒
if(order.status>=8)
{
var team = new Objects.Team()
{
id = order.constructionTeam
};
team = DataBase.Team.GetWithMembers(team);
foreach(var member in team.members)
{
var openID = DataBase.User.GetOpenID(member);
if (!string.IsNullOrEmpty(openID))
{
WXManage.SendMessage(openID, "一个订单被退单");
}
}
}
Response.Redirect(Request.Url.ToString());
}
}
}