Selaa lähdekoodia

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/services into dev

zjxpcyc 6 vuotta sitten
vanhempi
commit
f0a310ae75
3 muutettua tiedostoa jossa 35 lisäystä ja 10 poistoa
  1. 4
    2
      controllers/statistics/goods.go
  2. 12
    3
      models/statistics/goods.go
  3. 19
    5
      service/statistics/goods.go

+ 4
- 2
controllers/statistics/goods.go Näytä tiedosto

88
 	usertype := c.GetString("usertype")
88
 	usertype := c.GetString("usertype")
89
 	begindate := c.GetString("begindate")
89
 	begindate := c.GetString("begindate")
90
 	enddate := c.GetString("enddate")
90
 	enddate := c.GetString("enddate")
91
+	paytype := c.GetString("paytype")
91
 
92
 
92
 	if caseids == "" {
93
 	if caseids == "" {
93
 		cases := c.Context.Get("cases").([]model.SysUserCase)
94
 		cases := c.Context.Get("cases").([]model.SysUserCase)
94
 		caseids = c.GetCaseIDs(cases)
95
 		caseids = c.GetCaseIDs(cases)
95
 	}
96
 	}
96
-	goodsList, err := c.serv.GetGoodsOrdersStatistics(status, usertype, caseids, begindate, enddate, page, pagesize)
97
+	goodsList, err := c.serv.GetGoodsOrdersStatistics(status, usertype, caseids, begindate, enddate, paytype, page, pagesize)
97
 	if err != nil {
98
 	if err != nil {
98
 		c.ResponseError(err)
99
 		c.ResponseError(err)
99
 	}
100
 	}
108
 	usertype := c.GetString("usertype")
109
 	usertype := c.GetString("usertype")
109
 	begindate := c.GetString("begindate")
110
 	begindate := c.GetString("begindate")
110
 	enddate := c.GetString("enddate")
111
 	enddate := c.GetString("enddate")
112
+	paytype := c.GetString("paytype")
111
 
113
 
112
 	if caseids == "" {
114
 	if caseids == "" {
113
 		cases := c.Context.Get("cases").([]model.SysUserCase)
115
 		cases := c.Context.Get("cases").([]model.SysUserCase)
114
 		caseids = c.GetCaseIDs(cases)
116
 		caseids = c.GetCaseIDs(cases)
115
 	}
117
 	}
116
-	list, err := c.serv.GetGoodsOrdersStatisticsExcel(status, usertype, caseids, begindate, enddate)
118
+	list, err := c.serv.GetGoodsOrdersStatisticsExcel(status, usertype, caseids, begindate, enddate, paytype)
117
 	if err != nil {
119
 	if err != nil {
118
 		c.ResponseError(err)
120
 		c.ResponseError(err)
119
 	}
121
 	}

+ 12
- 3
models/statistics/goods.go Näytä tiedosto

122
 	Name          string
122
 	Name          string
123
 	Remark        string
123
 	Remark        string
124
 	AreaIconWhite string
124
 	AreaIconWhite string
125
+	PayType       string
126
+	PayTypeStr    string
125
 	Details       []model.TaGoodsOrdersDetail
127
 	Details       []model.TaGoodsOrdersDetail
126
 }
128
 }
127
 
129
 
128
 // GetGoodsOrderStatistics 获取商品订单
130
 // GetGoodsOrderStatistics 获取商品订单
129
-func (m *StatisticsDAO) GetGoodsOrderStatistics(status, usertype, caseids, begindate, enddate string, page, pageSize int) ([]GoodsOrdersStatistics, error) {
131
+func (m *StatisticsDAO) GetGoodsOrderStatistics(status, usertype, caseids, begindate, enddate, paytype string, page, pageSize int) ([]GoodsOrdersStatistics, error) {
130
 	var orders []GoodsOrdersStatistics
132
 	var orders []GoodsOrdersStatistics
131
 	sql := `SELECT
133
 	sql := `SELECT
132
 						a.orders_id,
134
 						a.orders_id,
150
 							END
152
 							END
151
 						) AS NAME,
153
 						) AS NAME,
152
 						b.phone,
154
 						b.phone,
153
-						a.remark
155
+						a.remark,
156
+						a.pay_type
154
 					FROM
157
 					FROM
155
 						ta_goods_orders a
158
 						ta_goods_orders a
156
 					INNER JOIN ta_customer b ON a.user_id = b.customer_id
159
 					INNER JOIN ta_customer b ON a.user_id = b.customer_id
162
 	if usertype != "" {
165
 	if usertype != "" {
163
 		sql = sql + ` and a.user_type='` + usertype + `'`
166
 		sql = sql + ` and a.user_type='` + usertype + `'`
164
 	}
167
 	}
168
+	if paytype != "" {
169
+		sql = sql + ` and a.pay_type='` + paytype + `'`
170
+	}
165
 	if begindate != "" {
171
 	if begindate != "" {
166
 		sql = sql + ` and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '` + begindate + `'`
172
 		sql = sql + ` and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '` + begindate + `'`
167
 	}
173
 	}
195
 }
201
 }
196
 
202
 
197
 // GetGoodsOrderStatisticsCount 获取商品订单Count
203
 // GetGoodsOrderStatisticsCount 获取商品订单Count
198
-func (m *StatisticsDAO) GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate string) ([]GoodsOrdersStatistics, error) {
204
+func (m *StatisticsDAO) GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate, paytype string) ([]GoodsOrdersStatistics, error) {
199
 	var orders []GoodsOrdersStatistics
205
 	var orders []GoodsOrdersStatistics
200
 	sql := `SELECT
206
 	sql := `SELECT
201
 						a.orders_id,
207
 						a.orders_id,
229
 	if usertype != "" {
235
 	if usertype != "" {
230
 		sql = sql + ` and a.user_type='` + usertype + `'`
236
 		sql = sql + ` and a.user_type='` + usertype + `'`
231
 	}
237
 	}
238
+	if paytype != "" {
239
+		sql = sql + ` and a.pay_type='` + paytype + `'`
240
+	}
232
 	if begindate != "" {
241
 	if begindate != "" {
233
 		sql = sql + ` and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '` + begindate + `'`
242
 		sql = sql + ` and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '` + begindate + `'`
234
 	}
243
 	}

+ 19
- 5
service/statistics/goods.go Näytä tiedosto

2
 
2
 
3
 import (
3
 import (
4
 	"errors"
4
 	"errors"
5
+	"spaceofcheng/services/models"
5
 	"spaceofcheng/services/models/statistics"
6
 	"spaceofcheng/services/models/statistics"
6
 	"spaceofcheng/services/service"
7
 	"spaceofcheng/services/service"
7
 	"spaceofcheng/services/utils"
8
 	"spaceofcheng/services/utils"
50
 }
51
 }
51
 
52
 
52
 // GetGoodsOrdersStatistics 获取商品订单统计信息
53
 // GetGoodsOrdersStatistics 获取商品订单统计信息
53
-func (s *StatisticsServ) GetGoodsOrdersStatistics(status, usertype, caseids, begindate, enddate string, page, pageSize int) (map[string]interface{}, error) {
54
+func (s *StatisticsServ) GetGoodsOrdersStatistics(status, usertype, caseids, begindate, enddate, paytype string, page, pageSize int) (map[string]interface{}, error) {
54
 	if pageSize == 0 {
55
 	if pageSize == 0 {
55
 		pageSize = service.PAGENUM
56
 		pageSize = service.PAGENUM
56
 	}
57
 	}
62
 		return nil, errors.New("请先选择案场信息")
63
 		return nil, errors.New("请先选择案场信息")
63
 	}
64
 	}
64
 
65
 
65
-	list, err := s.dao.GetGoodsOrderStatistics(status, usertype, caseids, begindate, enddate, page, pageSize)
66
+	list, err := s.dao.GetGoodsOrderStatistics(status, usertype, caseids, begindate, enddate, paytype, page, pageSize)
66
 	if err != nil {
67
 	if err != nil {
67
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
68
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
68
 		return nil, errors.New("获取商品订单统计数据失败")
69
 		return nil, errors.New("获取商品订单统计数据失败")
69
 	}
70
 	}
70
-	all, err := s.dao.GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate)
71
+	for a := 0; a < len(list); a++ {
72
+		switch list[a].PayType {
73
+		case models.CONSUME_INNER:
74
+			list[a].PayTypeStr = "案场"
75
+		case models.CONSUME_COUPON:
76
+			list[a].PayTypeStr = "优惠券"
77
+		case models.CONSUME_COINCHG:
78
+			list[a].PayTypeStr = "城币"
79
+		case models.CONSUME_POINTS:
80
+			list[a].PayTypeStr = "积分"
81
+		}
82
+
83
+	}
84
+	all, err := s.dao.GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, paytype, enddate)
71
 	if err != nil {
85
 	if err != nil {
72
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
86
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
73
 		return nil, errors.New("获取商品订单统计数据失败")
87
 		return nil, errors.New("获取商品订单统计数据失败")
82
 }
96
 }
83
 
97
 
84
 // GetGoodsOrdersStatisticsExcel 商品订单导出
98
 // GetGoodsOrdersStatisticsExcel 商品订单导出
85
-func (s *StatisticsServ) GetGoodsOrdersStatisticsExcel(status, usertype, caseids, begindate, enddate string) ([]statistics.GoodsOrdersStatistics, error) {
99
+func (s *StatisticsServ) GetGoodsOrdersStatisticsExcel(status, usertype, caseids, begindate, enddate, paytype string) ([]statistics.GoodsOrdersStatistics, error) {
86
 	if caseids == "" {
100
 	if caseids == "" {
87
 		return nil, errors.New("请先选择案场信息")
101
 		return nil, errors.New("请先选择案场信息")
88
 	}
102
 	}
89
 
103
 
90
-	all, err := s.dao.GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate)
104
+	all, err := s.dao.GetGoodsOrderStatisticsCount(status, usertype, caseids, begindate, enddate, paytype)
91
 	if err != nil {
105
 	if err != nil {
92
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
106
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
93
 		return nil, errors.New("获取商品订单统计数据失败")
107
 		return nil, errors.New("获取商品订单统计数据失败")