|
@@ -7,6 +7,7 @@ import (
|
7
|
7
|
"spaceofcheng/services/models/model"
|
8
|
8
|
"spaceofcheng/services/service/vipcard"
|
9
|
9
|
"time"
|
|
10
|
+ "spaceofcheng/services/utils"
|
10
|
11
|
)
|
11
|
12
|
|
12
|
13
|
// CaseController 信息
|
|
@@ -107,3 +108,71 @@ func (c *VipcardController) GetVipByCode() {
|
107
|
108
|
}
|
108
|
109
|
c.ResponseJSON(vipChild)
|
109
|
110
|
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+// GetVipListExcel 导出VIP 列表
|
|
114
|
+func (c *VipcardController) GetVipListExcel(){
|
|
115
|
+
|
|
116
|
+ caseids := c.GetString("caseid")
|
|
117
|
+ if caseids == "" {
|
|
118
|
+ cases := c.Context.Get("cases").([]model.SysUserCase)
|
|
119
|
+ caseids = c.GetCaseIDs(cases)
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ cardNo := c.GetString("cardNo")
|
|
123
|
+ sellerName := c.GetString("sellerName")
|
|
124
|
+ userName := c.GetString("userName")
|
|
125
|
+
|
|
126
|
+ list, err := c.dao.GetVipChildExcel(caseids, cardNo, sellerName, userName)
|
|
127
|
+ if err != nil {
|
|
128
|
+ c.ResponseError(err)
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ excel, err := utils.NewTinyXLSXEngine()
|
|
132
|
+ if err != nil {
|
|
133
|
+ utils.LogError("初始化Excel服务失败: " + err.Error())
|
|
134
|
+ c.ResponseError(errors.New("初始化Excel服务失败"))
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ // 创建表头
|
|
138
|
+ excel.SetCell(excel.InsertRow(), []string{
|
|
139
|
+ "卡号",
|
|
140
|
+ "价格",
|
|
141
|
+ "状态",
|
|
142
|
+ "销售",
|
|
143
|
+ "案场",
|
|
144
|
+ "用户",
|
|
145
|
+ "激活时间",
|
|
146
|
+ "创建时间",
|
|
147
|
+ })
|
|
148
|
+
|
|
149
|
+ // 遍历数据
|
|
150
|
+ for _, item := range list {
|
|
151
|
+ row := excel.InsertRow()
|
|
152
|
+ createDateToString := item.CreateDate.Format("2006-01-02 15:04:05")
|
|
153
|
+ activeDateToString := item.ActiveDate.Format("2006-01-02 15:04:05")
|
|
154
|
+ statusToString := ""
|
|
155
|
+ if item.Status == 1 {
|
|
156
|
+ statusToString = "已激活"
|
|
157
|
+ }else{
|
|
158
|
+ statusToString = "未激活"
|
|
159
|
+ }
|
|
160
|
+
|
|
161
|
+ excel.SetCell(row, []string{
|
|
162
|
+ item.VipCardChildCode,
|
|
163
|
+ item.Amount,
|
|
164
|
+ statusToString,
|
|
165
|
+ item.SalesName,
|
|
166
|
+ item.CaseName,
|
|
167
|
+ item.CustomerName,
|
|
168
|
+ activeDateToString,
|
|
169
|
+ createDateToString,
|
|
170
|
+ })
|
|
171
|
+ }
|
|
172
|
+ c.SaveToExcel("VIP卡列表.xlsx", excel)
|
|
173
|
+
|
|
174
|
+}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|