zjxpcyc 6 years ago
parent
commit
db8ad043de

+ 1
- 1
conf/db.conf View File

15
 username     = spaceofcheng
15
 username     = spaceofcheng
16
 
16
 
17
 ; 密码
17
 ; 密码
18
-password     = c;a|vK)Xv/=L@c[6Fx,v[ITD5;WpR}+Y
18
+password     = spaceofcheng
19
 
19
 
20
 ; 数据库名或者schema
20
 ; 数据库名或者schema
21
 database     = spaceofcheng
21
 database     = spaceofcheng

+ 1
- 1
conf/log.conf View File

1
 [common]
1
 [common]
2
-filename="E:\\GoProjects\\src\\spaceofcheng\\services\\log\\common.log"
2
+filename="E:\\GoProject\\src\\spaceofcheng\\services\\log\\common.log"
3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
4
 level="debug"
4
 level="debug"

+ 8
- 0
controllers/customer/customer.go View File

4
 	"errors"
4
 	"errors"
5
 	"net/http"
5
 	"net/http"
6
 	"spaceofcheng/services/controllers"
6
 	"spaceofcheng/services/controllers"
7
+	"spaceofcheng/services/models"
7
 	"spaceofcheng/services/models/model"
8
 	"spaceofcheng/services/models/model"
8
 	"spaceofcheng/services/service/customer"
9
 	"spaceofcheng/services/service/customer"
9
 	"spaceofcheng/services/utils"
10
 	"spaceofcheng/services/utils"
72
 		c.ResponseError(errors.New("获取用户信息失败, 请重试"))
73
 		c.ResponseError(errors.New("获取用户信息失败, 请重试"))
73
 	}
74
 	}
74
 
75
 
76
+	if cust.MapUser != "" && cust.BelongCaseStatus != models.STATUS_NORMAL {
77
+		c.ResponseError(
78
+			errors.New("案场状态异常!"),
79
+			http.StatusMethodNotAllowed,
80
+		)
81
+	}
82
+
75
 	c.ResponseJSON(map[string]interface{}{
83
 	c.ResponseJSON(map[string]interface{}{
76
 		"customer": cust,
84
 		"customer": cust,
77
 	})
85
 	})

+ 22
- 5
controllers/goods/order.go View File

4
 	"encoding/json"
4
 	"encoding/json"
5
 	"errors"
5
 	"errors"
6
 	"net/http"
6
 	"net/http"
7
-	"spaceofcheng/services/models"
7
+	"spaceofcheng/services/models/goods"
8
 	"spaceofcheng/services/models/model"
8
 	"spaceofcheng/services/models/model"
9
 	"spaceofcheng/services/utils"
9
 	"spaceofcheng/services/utils"
10
 	"strconv"
10
 	"strconv"
183
 				order.UserName,
183
 				order.UserName,
184
 				strconv.Itoa(good.Number),
184
 				strconv.Itoa(good.Number),
185
 				good.Price,
185
 				good.Price,
186
-				strconv.Itoa(good.Number),
187
 			})
186
 			})
188
 
187
 
189
 			price, err := strconv.ParseFloat(good.Price, 64)
188
 			price, err := strconv.ParseFloat(good.Price, 64)
199
 
198
 
200
 			excel.SetCell(row, strconv.FormatFloat(charge, 'f', -1, 64))
199
 			excel.SetCell(row, strconv.FormatFloat(charge, 'f', -1, 64))
201
 
200
 
202
-			status := "未完成"
203
-			if order.Status == models.STATUS_NORMAL {
204
-				status = "已完成"
201
+			status := "已完成"
202
+			switch order.MakeStatus {
203
+			case goods.MAKESTATUS_NOTSTARTED:
204
+				status = "制作中"
205
+				break
206
+			case goods.MAKESTATUS_DOING:
207
+				status = "制作中"
208
+				break
209
+			case goods.MAKESTATUS_CANCEL:
210
+				status = "已取消"
211
+				break
205
 			}
212
 			}
206
 			excel.SetCell(row, status)
213
 			excel.SetCell(row, status)
207
 			excel.SetCell(row, order.CreateDate.Format("2006-01-02 15:04:05"))
214
 			excel.SetCell(row, order.CreateDate.Format("2006-01-02 15:04:05"))
262
 	}
269
 	}
263
 	c.ResponseJSON("操作成功!")
270
 	c.ResponseJSON("操作成功!")
264
 }
271
 }
272
+
273
+// UpdateOrdersIntimidate 更新订单打单状态
274
+func (c *GoodsController) UpdateOrdersIntimidate() {
275
+	id := c.GetString(":id")
276
+	err := c.serv.UpdateOrdersIntimidate(id)
277
+	if err != nil {
278
+		c.ResponseError(err)
279
+	}
280
+	c.ResponseJSON("操作成功!")
281
+}

+ 8
- 2
controllers/statistics/goods.go View File

132
 		"订单状态",
132
 		"订单状态",
133
 		"商品",
133
 		"商品",
134
 		"数量",
134
 		"数量",
135
-		"金额",
135
+		"单价",
136
 		"桌位",
136
 		"桌位",
137
 		"下单人",
137
 		"下单人",
138
 		"电话",
138
 		"电话",
139
 	})
139
 	})
140
 
140
 
141
 	for _, item := range list {
141
 	for _, item := range list {
142
-		row := excel.InsertRow()
143
 		usertype := ""
142
 		usertype := ""
144
 		switch item.UserType {
143
 		switch item.UserType {
145
 		case "customer":
144
 		case "customer":
160
 			orderStatus = "已取消"
159
 			orderStatus = "已取消"
161
 		}
160
 		}
162
 		for _, detail := range item.Details {
161
 		for _, detail := range item.Details {
162
+			row := excel.InsertRow()
163
 			name := detail.GoodsName
163
 			name := detail.GoodsName
164
 			if detail.SpecName != "" {
164
 			if detail.SpecName != "" {
165
 				name = name + "(" + detail.SpecName + ")"
165
 				name = name + "(" + detail.SpecName + ")"
166
 			}
166
 			}
167
+			// price, err := strconv.ParseFloat(detail.Price, 64)
168
+			// if err != nil {
169
+			// 	c.ResponseError(errors.New("金额类型不正确!"))
170
+			// }
171
+			// amount := price * float64(detail.Number)
167
 			excel.SetCell(row, []string{
172
 			excel.SetCell(row, []string{
168
 				item.OrdersNo,
173
 				item.OrdersNo,
169
 				item.CaseName,
174
 				item.CaseName,
172
 				orderStatus,
177
 				orderStatus,
173
 				name,
178
 				name,
174
 				strconv.Itoa(detail.Number),
179
 				strconv.Itoa(detail.Number),
180
+				detail.Price,
175
 				item.AreaName + item.TableNo,
181
 				item.AreaName + item.TableNo,
176
 				item.CustomerName,
182
 				item.CustomerName,
177
 				item.Phone,
183
 				item.Phone,

+ 118
- 0
log/common.log View File

1
+<<<<<<< HEAD
2
+=======
3
+2018/09/21 00:04:05 [E] 用户没有设置默认案场
4
+2018/09/21 00:04:05 [E] 用户没有设置默认案场
5
+2018/09/21 00:04:05 [E] 用户没有设置默认案场
6
+2018/09/21 00:04:14 [E] 用户没有设置默认案场
7
+2018/09/21 00:04:17 [E] 用户没有设置默认案场
8
+2018/09/21 00:04:19 [E] 用户没有设置默认案场
9
+2018/09/21 00:05:17 [E] 用户没有设置默认案场
10
+2018/09/21 00:05:26 [E] 用户没有设置默认案场
11
+2018/09/21 00:05:26 [E] 用户没有设置默认案场
12
+2018/09/21 00:30:14 [E] 用户没有设置默认案场
13
+2018/09/21 00:30:14 [E] 用户没有设置默认案场
14
+2018/09/21 00:30:37 [E] 用户没有设置默认案场
15
+2018/09/21 00:30:45 [E] 用户没有设置默认案场
16
+2018/09/21 00:30:46 [E] 用户没有设置默认案场
17
+2018/09/21 00:32:11 [E] 用户没有设置默认案场
18
+2018/09/21 00:36:16 [E] 用户没有设置默认案场
19
+2018/09/21 00:36:16 [E] 用户没有设置默认案场
20
+2018/09/21 00:36:16 [E] 用户没有设置默认案场
21
+2018/09/21 00:36:39 [E] 用户没有设置默认案场
22
+2018/09/21 00:36:45 [E] 用户没有设置默认案场
23
+2018/09/21 00:36:49 [E] 用户没有设置默认案场
24
+2018/09/21 00:36:58 [E] 用户没有设置默认案场
25
+2018/09/21 00:37:04 [E] 用户没有设置默认案场
26
+2018/09/21 00:37:36 [E] 用户没有设置默认案场
27
+2018/09/21 00:37:36 [E] 用户没有设置默认案场
28
+2018/09/21 00:37:38 [E] 用户没有设置默认案场
29
+2018/09/21 00:37:40 [E] 用户没有设置默认案场
30
+2018/09/21 00:37:43 [E] 用户没有设置默认案场
31
+2018/09/21 00:37:53 [E] 用户没有设置默认案场
32
+2018/09/21 00:38:05 [E] 用户没有设置默认案场
33
+2018/09/21 00:38:08 [E] 用户没有设置默认案场
34
+2018/09/21 00:38:12 [E] 用户没有设置默认案场
35
+2018/09/21 00:38:15 [E] 用户没有设置默认案场
36
+2018/09/21 00:38:49 [E] 用户没有设置默认案场
37
+2018/09/21 00:38:51 [E] 用户没有设置默认案场
38
+2018/09/21 00:38:53 [E] 用户没有设置默认案场
39
+2018/09/21 00:38:53 [E] 用户没有设置默认案场
40
+2018/09/21 00:38:55 [E] 用户没有设置默认案场
41
+2018/09/21 00:38:56 [E] 用户没有设置默认案场
42
+2018/09/21 00:38:59 [E] 用户没有设置默认案场
43
+2018/09/21 00:39:02 [E] 用户没有设置默认案场
44
+2018/09/21 00:39:12 [E] 用户没有设置默认案场
45
+2018/09/21 00:39:24 [E] 用户没有设置默认案场
46
+2018/09/21 00:45:56 [E] 用户没有设置默认案场
47
+2018/09/21 00:45:56 [E] 用户没有设置默认案场
48
+2018/09/21 00:46:37 [E] 用户没有设置默认案场
49
+2018/09/21 00:46:37 [E] 用户没有设置默认案场
50
+2018/09/21 00:47:06 [E] 用户没有设置默认案场
51
+2018/09/21 00:47:06 [E] 用户没有设置默认案场
52
+2018/09/21 00:47:47 [E] 用户没有设置默认案场
53
+2018/09/21 00:47:47 [E] 用户没有设置默认案场
54
+2018/09/21 00:48:12 [E] 用户没有设置默认案场
55
+2018/09/21 00:49:04 [E] 用户没有设置默认案场
56
+2018/09/21 00:53:33 [E] 用户没有设置默认案场
57
+2018/09/21 00:53:33 [E] 用户没有设置默认案场
58
+2018/09/21 00:53:51 [E] 用户没有设置默认案场
59
+2018/09/21 00:53:52 [E] 用户没有设置默认案场
60
+2018/09/21 00:53:52 [E] 用户没有设置默认案场
61
+2018/09/21 00:53:56 [E] 用户没有设置默认案场
62
+2018/09/21 00:53:58 [E] 用户没有设置默认案场
63
+2018/09/21 00:54:12 [E] 用户没有设置默认案场
64
+2018/09/21 00:54:12 [E] 用户没有设置默认案场
65
+2018/09/21 01:01:20 [E] 用户没有设置默认案场
66
+2018/09/21 01:03:52 [E] 用户没有设置默认案场
67
+2018/09/21 01:03:52 [E] 用户没有设置默认案场
68
+2018/09/21 01:04:06 [E] 用户没有设置默认案场
69
+2018/09/21 01:42:44 [E] 用户没有设置默认案场
70
+2018/09/21 01:44:00 [E] 用户没有设置默认案场
71
+2018/09/21 01:44:00 [E] 用户没有设置默认案场
72
+2018/09/21 01:44:05 [E] 用户没有设置默认案场
73
+2018/09/21 01:44:08 [E] 用户没有设置默认案场
74
+2018/09/21 01:44:08 [E] 用户没有设置默认案场
75
+2018/09/21 01:44:10 [E] 用户没有设置默认案场
76
+2018/09/21 01:44:19 [E] 用户没有设置默认案场
77
+2018/09/21 01:45:42 [E] 用户没有设置默认案场
78
+2018/09/21 01:45:45 [E] 用户没有设置默认案场
79
+2018/09/21 01:47:37 [E] 用户没有设置默认案场
80
+2018/09/21 01:47:37 [E] 用户没有设置默认案场
81
+2018/09/21 02:10:32 [E] 用户没有设置默认案场
82
+2018/09/21 02:10:32 [E] 用户没有设置默认案场
83
+2018/09/21 02:10:36 [E] 用户没有设置默认案场
84
+2018/09/21 02:10:37 [E] 用户没有设置默认案场
85
+2018/09/21 02:10:37 [E] 用户没有设置默认案场
86
+2018/09/21 02:10:38 [E] 用户没有设置默认案场
87
+2018/09/21 02:10:41 [E] 用户没有设置默认案场
88
+2018/09/21 02:10:53 [E] 用户没有设置默认案场
89
+2018/09/21 02:11:07 [E] 用户没有设置默认案场
90
+2018/09/21 02:11:08 [E] 用户没有设置默认案场
91
+2018/09/21 02:11:12 [E] 用户没有设置默认案场
92
+2018/09/21 02:11:12 [E] 用户没有设置默认案场
93
+2018/09/21 02:11:29 [E] 用户没有设置默认案场
94
+2018/09/21 02:11:31 [E] 用户没有设置默认案场
95
+2018/09/21 02:11:43 [E] 用户没有设置默认案场
96
+2018/09/21 02:11:53 [E] 用户没有设置默认案场
97
+2018/09/21 02:11:57 [E] 用户没有设置默认案场
98
+2018/09/21 02:11:57 [E] 用户没有设置默认案场
99
+2018/09/21 02:12:12 [E] 用户没有设置默认案场
100
+2018/09/21 02:12:39 [E] 用户没有设置默认案场
101
+2018/09/21 02:12:40 [E] 用户没有设置默认案场
102
+2018/09/21 02:12:40 [E] 用户没有设置默认案场
103
+2018/09/21 02:12:40 [E] 用户没有设置默认案场
104
+2018/09/21 02:12:43 [E] 用户没有设置默认案场
105
+2018/09/21 02:12:47 [E] 用户没有设置默认案场
106
+2018/09/21 02:13:47 [E] 用户没有设置默认案场
107
+2018/09/21 02:13:47 [E] 用户没有设置默认案场
108
+2018/09/21 02:14:10 [E] 用户没有设置默认案场
109
+2018/09/21 02:14:17 [E] 用户没有设置默认案场
110
+2018/09/21 02:14:19 [E] 用户没有设置默认案场
111
+2018/09/21 02:14:20 [E] 用户没有设置默认案场
112
+2018/09/21 02:14:58 [E] 用户没有设置默认案场
113
+2018/09/21 02:15:01 [E] 用户没有设置默认案场
114
+2018/09/21 02:15:02 [E] 用户没有设置默认案场
115
+2018/09/21 02:15:03 [E] 用户没有设置默认案场
116
+2018/09/21 02:15:03 [E] 用户没有设置默认案场
117
+2018/09/21 02:15:03 [E] 用户没有设置默认案场
118
+>>>>>>> 443c1728ef51dbf0d939a5f62ed7e34f0f6708a8

+ 9
- 3
models/cases/cases.go View File

59
 
59
 
60
 // GetCaseByID 根据ID获取案场信息
60
 // GetCaseByID 根据ID获取案场信息
61
 func (m *CaseDAO) GetCaseByID(caseid string) (*model.SysCase, error) {
61
 func (m *CaseDAO) GetCaseByID(caseid string) (*model.SysCase, error) {
62
-	cs := new(model.SysCase)
63
-	_, err := m.db.Where("status>?", models.STATUS_DEL).And("case_id=?", caseid).Get(cs)
64
-	return cs, err
62
+	var cases []model.SysCase
63
+	err := m.db.Where("status>?", models.STATUS_DEL).And("case_id=?", caseid).Find(&cases)
64
+	if err != nil {
65
+		return nil, err
66
+	}
67
+	if len(cases) > 0 {
68
+		return &cases[0], nil
69
+	}
70
+	return nil, err
65
 }
71
 }
66
 
72
 
67
 // AddCase 新增案场信息
73
 // AddCase 新增案场信息

+ 1
- 0
models/customer/types.go View File

12
 	Points              int
12
 	Points              int
13
 	MapUser             string
13
 	MapUser             string
14
 	BelongCaseId        string
14
 	BelongCaseId        string
15
+	BelongCaseStatus    int
15
 }
16
 }

+ 20
- 2
models/goods/orders.go View File

15
 const (
15
 const (
16
 	USERTPE_SALES     = "sales"
16
 	USERTPE_SALES     = "sales"
17
 	USERTYPE_CUSTOMER = "customer"
17
 	USERTYPE_CUSTOMER = "customer"
18
+
19
+	INTIMIDATE_NO  = 0
20
+	INTIMIDATE_YES = 1
18
 )
21
 )
19
 
22
 
20
 // GetOrdersByCases 获取案场订单列表
23
 // GetOrdersByCases 获取案场订单列表
44
 	order.Status = models.STATUS_NORMAL
47
 	order.Status = models.STATUS_NORMAL
45
 	order.IsPay = models.BOOL_TRUE // 默认已支付
48
 	order.IsPay = models.BOOL_TRUE // 默认已支付
46
 	order.CouponAmount = "0"
49
 	order.CouponAmount = "0"
50
+	order.IsIntimidate = INTIMIDATE_NO
47
 
51
 
48
 	// 当前订单号的随机方式 = 时间 + 个人ID
52
 	// 当前订单号的随机方式 = 时间 + 个人ID
49
 	ordersno := "G-" + time.Now().Local().Format("20060102150405") + "-" + strings.Join(utils.GUIID2IntString(order.UserId), "")
53
 	ordersno := "G-" + time.Now().Local().Format("20060102150405") + "-" + strings.Join(utils.GUIID2IntString(order.UserId), "")
56
 	return nil
60
 	return nil
57
 }
61
 }
58
 
62
 
63
+// UpdateOrdersIntimidate 更新订单已打单
64
+func (m *GoodsDAO) UpdateOrdersIntimidate(id string) error {
65
+	var orders = model.TaGoodsOrders{
66
+		OrdersId:     id,
67
+		IsIntimidate: INTIMIDATE_YES,
68
+	}
69
+	var cols = []string{
70
+		"spec_name",
71
+		"case_id",
72
+	}
73
+	_, err := m.db.Cols(cols...).Where("orders_id=?", orders.OrdersId).Update(orders)
74
+	return err
75
+}
76
+
59
 // SaveOrdersDetail 保存订单明细
77
 // SaveOrdersDetail 保存订单明细
60
 func (m *GoodsDAO) SaveOrdersDetail(list []model.TaGoodsOrdersDetail, ordersID string) error {
78
 func (m *GoodsDAO) SaveOrdersDetail(list []model.TaGoodsOrdersDetail, ordersID string) error {
61
 	for inx := range list {
79
 	for inx := range list {
222
 	sql := `select a.*, c.case_name from ta_goods_orders a 
240
 	sql := `select a.*, c.case_name from ta_goods_orders a 
223
 	inner join sys_case c on a.case_id=c.case_id
241
 	inner join sys_case c on a.case_id=c.case_id
224
 	where a.user_id='` + custID +
242
 	where a.user_id='` + custID +
225
-		`' and c.status=` + strconv.Itoa(models.STATUS_NORMAL) + ` and a.status=` + strconv.Itoa(models.STATUS_NORMAL)
243
+		`' and a.status=` + strconv.Itoa(models.STATUS_NORMAL)
226
 	sql += ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
244
 	sql += ` order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
227
 	err := m.db.Sql(sql).Find(&orderList)
245
 	err := m.db.Sql(sql).Find(&orderList)
228
 	if err != nil {
246
 	if err != nil {
244
 	sql := `select a.*, c.case_name from ta_goods_orders a 
262
 	sql := `select a.*, c.case_name from ta_goods_orders a 
245
 	inner join sys_case c on a.case_id=c.case_id
263
 	inner join sys_case c on a.case_id=c.case_id
246
 	where a.user_id='` + custID +
264
 	where a.user_id='` + custID +
247
-		`' and c.status=` + strconv.Itoa(models.STATUS_NORMAL) + ` and a.status=` + strconv.Itoa(models.STATUS_NORMAL)
265
+		`' and a.status=` + strconv.Itoa(models.STATUS_NORMAL)
248
 	err := m.db.Sql(sql).Find(&orderList)
266
 	err := m.db.Sql(sql).Find(&orderList)
249
 	if err != nil {
267
 	if err != nil {
250
 		return 0, err
268
 		return 0, err

+ 1
- 0
models/model/ta_goods_orders.go View File

27
 	IsPay        int    `xorm:"TINYINT(1)"`
27
 	IsPay        int    `xorm:"TINYINT(1)"`
28
 	ActualAmount string `xorm:"DECIMAL(8,2)"`
28
 	ActualAmount string `xorm:"DECIMAL(8,2)"`
29
 	CouponAmount string `xorm:"DECIMAL(8,2)"`
29
 	CouponAmount string `xorm:"DECIMAL(8,2)"`
30
+	IsIntimidate int    `xorm:"SMALLINT(6)"`
30
 }
31
 }

+ 8
- 3
models/statistics/goods.go View File

167
 		return nil, err
167
 		return nil, err
168
 	}
168
 	}
169
 	for inx, item := range orders {
169
 	for inx, item := range orders {
170
-		var details []model.TaGoodsOrdersDetail
171
-		err := m.db.Where("orders_id=?", item.OrdersId).Find(&details)
170
+		details, err := m.GetGoodsOrderDetailByOrderId(item.OrdersId)
172
 		if err != nil {
171
 		if err != nil {
173
 			return nil, err
172
 			return nil, err
174
 		}
173
 		}
177
 	return orders, err
176
 	return orders, err
178
 }
177
 }
179
 
178
 
179
+// GetGoodsOrderDetailByOrderId 获取商品详情
180
+func (m *StatisticsDAO) GetGoodsOrderDetailByOrderId(ordersid string) ([]model.TaGoodsOrdersDetail, error) {
181
+	var details []model.TaGoodsOrdersDetail
182
+	err := m.db.Where("orders_id=?", ordersid).Find(&details)
183
+	return details, err
184
+}
185
+
180
 // GetGoodsOrderStatisticsCount 获取商品订单Count
186
 // GetGoodsOrderStatisticsCount 获取商品订单Count
181
 func (m *StatisticsDAO) GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate string) ([]GoodsOrdersStatistics, error) {
187
 func (m *StatisticsDAO) GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate string) ([]GoodsOrdersStatistics, error) {
182
 	var orders []GoodsOrdersStatistics
188
 	var orders []GoodsOrdersStatistics
213
 	if status != "" {
219
 	if status != "" {
214
 		sql = sql + ` and a.make_status='` + status + `'`
220
 		sql = sql + ` and a.make_status='` + status + `'`
215
 	}
221
 	}
216
-
217
 	err := m.db.Sql(sql).Find(&orders)
222
 	err := m.db.Sql(sql).Find(&orders)
218
 	return orders, err
223
 	return orders, err
219
 }
224
 }

+ 1
- 0
routers/common.go View File

247
 
247
 
248
 		beego.NSRouter("/order/goods/finish/:id", &goods.GoodsController{}, "put:FinishMake"),
248
 		beego.NSRouter("/order/goods/finish/:id", &goods.GoodsController{}, "put:FinishMake"),
249
 		beego.NSRouter("/order/goods/cancel/:id", &goods.GoodsController{}, "put:CancelMake"),
249
 		beego.NSRouter("/order/goods/cancel/:id", &goods.GoodsController{}, "put:CancelMake"),
250
+		beego.NSRouter("/order/goods/intimidate/:id", &goods.GoodsController{}, "put:UpdateOrdersIntimidate"),
250
 
251
 
251
 		// 优惠券
252
 		// 优惠券
252
 		beego.NSRouter("/coupon", &coupon.CouponController{}, "get:ListByCase"),
253
 		beego.NSRouter("/coupon", &coupon.CouponController{}, "get:ListByCase"),

+ 22
- 4
service/coupon/coupon.go View File

544
 		return errors.New("log-error-该优惠券已被领取!")
544
 		return errors.New("log-error-该优惠券已被领取!")
545
 	}
545
 	}
546
 
546
 
547
+	// 计算卡券有效期
548
+	startDate := coupon.StartDate
549
+	endDate := coupon.EndDate
550
+	if coupon.ValidDays > 0 {
551
+		startDate = time.Now().Local()
552
+		hs := int64(coupon.ValidDays * 24)
553
+		endDate = time.Now().Local().Add(time.Hour * time.Duration(hs))
554
+	}
555
+
547
 	// 领取
556
 	// 领取
548
 	var customerCoupon = model.TaCustomerCoupon{
557
 	var customerCoupon = model.TaCustomerCoupon{
549
 		CouponId:           coupon.CouponId,
558
 		CouponId:           coupon.CouponId,
551
 		CustomerId:         customer.CustomerId,
560
 		CustomerId:         customer.CustomerId,
552
 		SalesId:            saler.UserId,
561
 		SalesId:            saler.UserId,
553
 		SalesName:          saler.UserName,
562
 		SalesName:          saler.UserName,
554
-		StartDate:          coupon.StartDate,
555
-		EndDate:            coupon.EndDate,
563
+		StartDate:          startDate,
564
+		EndDate:            endDate,
556
 		CaseId:             coupon.CaseId,
565
 		CaseId:             coupon.CaseId,
557
 		OrgId:              coupon.OrgId,
566
 		OrgId:              coupon.OrgId,
558
 		SerialCode:         serialcode,
567
 		SerialCode:         serialcode,
611
 		return errors.New("log-error-您已领取过该优惠券!")
620
 		return errors.New("log-error-您已领取过该优惠券!")
612
 	}
621
 	}
613
 
622
 
623
+	// 计算卡券有效期
624
+	startDate := coupon.StartDate
625
+	endDate := coupon.EndDate
626
+	if coupon.ValidDays > 0 {
627
+		startDate = time.Now().Local()
628
+		hs := int64(coupon.ValidDays * 24)
629
+		endDate = time.Now().Local().Add(time.Hour * time.Duration(hs))
630
+	}
631
+
614
 	// 领取
632
 	// 领取
615
 	var customerCoupon = model.TaCustomerCoupon{
633
 	var customerCoupon = model.TaCustomerCoupon{
616
 		CouponId:           coupon.CouponId,
634
 		CouponId:           coupon.CouponId,
617
 		CustomerCouponName: coupon.CouponName,
635
 		CustomerCouponName: coupon.CouponName,
618
 		CustomerId:         customer.CustomerId,
636
 		CustomerId:         customer.CustomerId,
619
-		StartDate:          coupon.StartDate,
620
-		EndDate:            coupon.EndDate,
637
+		StartDate:          startDate,
638
+		EndDate:            endDate,
621
 		CaseId:             coupon.CaseId,
639
 		CaseId:             coupon.CaseId,
622
 		OrgId:              coupon.OrgId,
640
 		OrgId:              coupon.OrgId,
623
 		ReceivingType:      models.RECEIVEING_TYPE_CHANNEL,
641
 		ReceivingType:      models.RECEIVEING_TYPE_CHANNEL,

+ 1
- 1
service/course/order.go View File

107
 		var isdy = false
107
 		var isdy = false
108
 		if coupon.IsAll == 1 {
108
 		if coupon.IsAll == 1 {
109
 			isdy = true
109
 			isdy = true
110
-			couseOrder.CouponAmount = couseOrder.Price
110
+			couseOrder.CouponAmount = coupon.Price
111
 		} else {
111
 		} else {
112
 			for _, target := range coupon.Targets {
112
 			for _, target := range coupon.Targets {
113
 				if target.TargetId == course.CourseId {
113
 				if target.TargetId == course.CourseId {

+ 1
- 0
service/customer/customer.go View File

74
 			return nil, err
74
 			return nil, err
75
 		}
75
 		}
76
 		cust.BelongCaseId = caseinfo.CaseId
76
 		cust.BelongCaseId = caseinfo.CaseId
77
+		cust.BelongCaseStatus = caseinfo.Status
77
 	}
78
 	}
78
 
79
 
79
 	return cust, nil
80
 	return cust, nil

+ 10
- 0
service/goods/orders.go View File

545
 	err := s.dao.UpdateOrdersMake(orders)
545
 	err := s.dao.UpdateOrdersMake(orders)
546
 	return err
546
 	return err
547
 }
547
 }
548
+
549
+// UpdateOrdersIntimidate 更新订单打单
550
+func (s *GoodsServ) UpdateOrdersIntimidate(id string) error {
551
+	err := s.dao.UpdateOrdersIntimidate(id)
552
+	if err != nil {
553
+		utils.LogError("更新失败:", err)
554
+		return err
555
+	}
556
+	return nil
557
+}

+ 7
- 1
service/statistics/goods.go View File

92
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
92
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
93
 		return nil, errors.New("获取商品订单统计数据失败")
93
 		return nil, errors.New("获取商品订单统计数据失败")
94
 	}
94
 	}
95
-
95
+	for inx, item := range all {
96
+		details, err := s.dao.GetGoodsOrderDetailByOrderId(item.OrdersId)
97
+		if err != nil {
98
+			return nil, err
99
+		}
100
+		all[inx].Details = details
101
+	}
96
 	return all, nil
102
 	return all, nil
97
 }
103
 }

+ 1
- 1
service/verify/verify.go View File

86
 		return nil, errors.New("获取课程列表失败")
86
 		return nil, errors.New("获取课程列表失败")
87
 	}
87
 	}
88
 	if len(customerDetail) == 0 {
88
 	if len(customerDetail) == 0 {
89
-		return nil, errors.New("今日无可核销课程")
89
+		return nil, nil
90
 	}
90
 	}
91
 	customerID := customerDetail[0].CustomerId
91
 	customerID := customerDetail[0].CustomerId
92
 	total, err := s.dao.GetCustomerCourseListByTelCount(tel, caseids)
92
 	total, err := s.dao.GetCustomerCourseListByTelCount(tel, caseids)