-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_ording.go
113 lines (102 loc) · 3.06 KB
/
order_ording.go
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
/**
* Copyright 2014 @ z3q.net.
* name :
* author : jarryliu
* date : 2014-02-05 21:53
* description :
* history :
*/
package partner
import (
"go2o/src/app/cache"
"go2o/src/core/domain/interface/enum"
"go2o/src/core/domain/interface/shopping"
"go2o/src/core/service/dps"
"go2o/src/x/echox"
"html/template"
"strconv"
)
func (this *orderC) setShop(ctx *echox.Context,
partnerId int, order *shopping.ValueOrder) error {
shopDr := cache.GetShopDropList(partnerId, -1)
isNoShop := len(shopDr) == 0
d := ctx.NewData()
d.Map = map[string]interface{}{
"shopDr": template.HTML(shopDr),
"noShop": isNoShop,
"orderNo": order.OrderNo,
}
return ctx.RenderOK("order.setup_setshop.html", d)
}
// 设置门店(POST)
func (this *orderC) SetShop(ctx *echox.Context) error {
partnerId := getPartnerId(ctx)
r := ctx.HttpRequest()
if r.Method == "POST" {
r.ParseForm()
shopId, err := strconv.Atoi(r.FormValue("shopId"))
if err == nil {
orderNo := r.FormValue("order_no")
err = dps.ShoppingService.SetDeliverShop(partnerId,
orderNo, shopId)
dps.ShoppingService.ConfirmOrder(partnerId, orderNo)
}
if err != nil {
return ctx.StringOK("{result:false,message:'" + err.Error() + "'}")
}
return ctx.StringOK("{result:true}")
}
return nil
}
func (this *orderC) setState(ctx *echox.Context,
partnerId int, order *shopping.ValueOrder) error {
var descript string
var button string
switch order.Status {
case enum.ORDER_COMPLETED:
descript = `<span style="color:green">订单已经完成!</span>`
case enum.ORDER_CANCEL:
descript = `<span style="color:red">订单已经取消!</span>`
case enum.ORDER_WAIT_CONFIRM:
descript = "确认订单无误后,点击按钮进行下一步.."
button = `<span class="ui-button w80 small-button">
<span class="button-inner">
<span class="button-txt">确认订单</span>
<input id="btn2"/>
</span>
</span>`
case enum.ORDER_WAIT_DELIVERY:
button = `<span class="ui-button w80 small-button">
<span class="button-inner">
<span class="button-txt">开始配送</span>
<input id="btn2"/>
</span>
</span>`
case enum.ORDER_WAIT_RECEIVE:
button = `<span class="ui-button w80 small-button">
<span class="button-inner">
<span class="button-txt">确认收货</span>
<input id="btn2"/>
</span>
</span>`
case enum.ORDER_RECEIVED:
if order.IsPaid == 0 {
descript = `<span style="color:red">订单尚未付款,如果已经付款,请人工手动付款!</span>`
} else {
descript = "如果已收货,点击按钮完成订单"
button = `<span class="ui-button w80 small-button">
<span class="button-inner">
<span class="button-txt">完成订单</span>
<input id="btn2"/>
</span>
</span>`
}
}
d := ctx.NewData()
d.Map = map[string]interface{}{
"button": template.HTML(button),
"descript": template.HTML(descript),
"order_no": order.OrderNo,
}
return ctx.RenderOK("order.setup_setstate.html", d)
}