浏览代码

加入购买方式

胡轶钦 6 年前
父节点
当前提交
f52c926ef0
共有 3 个文件被更改,包括 35 次插入10 次删除
  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 查看文件

@@ -88,12 +88,13 @@ func (c *StatisticsController) GetGoodsOrdersStatistics() {
88 88
 	usertype := c.GetString("usertype")
89 89
 	begindate := c.GetString("begindate")
90 90
 	enddate := c.GetString("enddate")
91
+	paytype := c.GetString("paytype")
91 92
 
92 93
 	if caseids == "" {
93 94
 		cases := c.Context.Get("cases").([]model.SysUserCase)
94 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 98
 	if err != nil {
98 99
 		c.ResponseError(err)
99 100
 	}
@@ -108,12 +109,13 @@ func (c *StatisticsController) GetGoodsOrdersStatisticsExcel() {
108 109
 	usertype := c.GetString("usertype")
109 110
 	begindate := c.GetString("begindate")
110 111
 	enddate := c.GetString("enddate")
112
+	paytype := c.GetString("paytype")
111 113
 
112 114
 	if caseids == "" {
113 115
 		cases := c.Context.Get("cases").([]model.SysUserCase)
114 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 119
 	if err != nil {
118 120
 		c.ResponseError(err)
119 121
 	}

+ 12
- 3
models/statistics/goods.go 查看文件

@@ -122,11 +122,13 @@ type GoodsOrdersStatistics struct {
122 122
 	Name          string
123 123
 	Remark        string
124 124
 	AreaIconWhite string
125
+	PayType       string
126
+	PayTypeStr    string
125 127
 	Details       []model.TaGoodsOrdersDetail
126 128
 }
127 129
 
128 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 132
 	var orders []GoodsOrdersStatistics
131 133
 	sql := `SELECT
132 134
 						a.orders_id,
@@ -150,7 +152,8 @@ func (m *StatisticsDAO) GetGoodsOrderStatistics(status, usertype, caseids, begin
150 152
 							END
151 153
 						) AS NAME,
152 154
 						b.phone,
153
-						a.remark
155
+						a.remark,
156
+						a.pay_type
154 157
 					FROM
155 158
 						ta_goods_orders a
156 159
 					INNER JOIN ta_customer b ON a.user_id = b.customer_id
@@ -162,6 +165,9 @@ func (m *StatisticsDAO) GetGoodsOrderStatistics(status, usertype, caseids, begin
162 165
 	if usertype != "" {
163 166
 		sql = sql + ` and a.user_type='` + usertype + `'`
164 167
 	}
168
+	if paytype != "" {
169
+		sql = sql + ` and a.pay_type='` + paytype + `'`
170
+	}
165 171
 	if begindate != "" {
166 172
 		sql = sql + ` and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '` + begindate + `'`
167 173
 	}
@@ -195,7 +201,7 @@ func (m *StatisticsDAO) GetGoodsOrderDetailByOrderId(ordersid string) ([]model.T
195 201
 }
196 202
 
197 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 205
 	var orders []GoodsOrdersStatistics
200 206
 	sql := `SELECT
201 207
 						a.orders_id,
@@ -229,6 +235,9 @@ func (m *StatisticsDAO) GetGoodsOrderStatisticsCount(status, usertype, caseids,
229 235
 	if usertype != "" {
230 236
 		sql = sql + ` and a.user_type='` + usertype + `'`
231 237
 	}
238
+	if paytype != "" {
239
+		sql = sql + ` and a.pay_type='` + paytype + `'`
240
+	}
232 241
 	if begindate != "" {
233 242
 		sql = sql + ` and DATE_FORMAT(a.create_date, '%Y-%m-%d') >= '` + begindate + `'`
234 243
 	}

+ 19
- 5
service/statistics/goods.go 查看文件

@@ -2,6 +2,7 @@ package statistics
2 2
 
3 3
 import (
4 4
 	"errors"
5
+	"spaceofcheng/services/models"
5 6
 	"spaceofcheng/services/models/statistics"
6 7
 	"spaceofcheng/services/service"
7 8
 	"spaceofcheng/services/utils"
@@ -50,7 +51,7 @@ func (s *StatisticsServ) GetGoodsStatisticsExcel(caseids, typeid, name string) (
50 51
 }
51 52
 
52 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 55
 	if pageSize == 0 {
55 56
 		pageSize = service.PAGENUM
56 57
 	}
@@ -62,12 +63,25 @@ func (s *StatisticsServ) GetGoodsOrdersStatistics(status, usertype, caseids, beg
62 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 67
 	if err != nil {
67 68
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
68 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 85
 	if err != nil {
72 86
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
73 87
 		return nil, errors.New("获取商品订单统计数据失败")
@@ -82,12 +96,12 @@ func (s *StatisticsServ) GetGoodsOrdersStatistics(status, usertype, caseids, beg
82 96
 }
83 97
 
84 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 100
 	if caseids == "" {
87 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 105
 	if err != nil {
92 106
 		utils.LogError("获取商品订单统计数据失败: " + err.Error())
93 107
 		return nil, errors.New("获取商品订单统计数据失败")