wangfei 6 jaren geleden
bovenliggende
commit
55438672d2
5 gewijzigde bestanden met toevoegingen van 24 en 11 verwijderingen
  1. 1
    0
      log/common.log
  2. 14
    5
      models/goods/orders.go
  3. 8
    1
      models/goods/types.go
  4. 0
    4
      models/verify/verify.go
  5. 1
    1
      service/verify/verify.go

+ 1
- 0
log/common.log Bestand weergeven

@@ -268,3 +268,4 @@
268 268
 2018/09/06 19:58:18 [E] 下单转换JSON失败: json: cannot unmarshal number into Go struct field TaGoodsOrders.Amount of type string
269 269
 2018/09/06 19:59:58 [E] 下单转换JSON失败: json: cannot unmarshal number into Go struct field TaGoodsOrders.Amount of type string
270 270
 2018/09/06 20:00:48 [E] 下单转换JSON失败: json: cannot unmarshal number into Go struct field TaGoodsOrders.Amount of type string
271
+2018/09/06 20:03:48 [E] 下单转换JSON失败: json: cannot unmarshal number into Go struct field TaGoodsOrders.Amount of type string

+ 14
- 5
models/goods/orders.go Bestand weergeven

@@ -162,17 +162,26 @@ func (m *GoodsDAO) GetOrdersByCaseID(caseID, userType string, makeStatus []strin
162 162
 	}
163 163
 
164 164
 	for i, o := range orderList {
165
-		var details []model.TaGoodsOrdersDetail
166
-		if err := m.db.Where("orders_id=?", o.OrdersId).Find(&details); err != nil {
165
+		details, err := m.GetOrderDetailByOrder(o.OrdersId)
166
+		if err != nil {
167 167
 			return nil, 0, err
168 168
 		}
169
-
170 169
 		orderList[i].Goods = details
171 170
 	}
172 171
 
173 172
 	return orderList, cnt, nil
174 173
 }
175 174
 
175
+// GetOrderDetailByOrder 获取商品明细
176
+func (m *GoodsDAO) GetOrderDetailByOrder(orderid string) ([]DetailWithType, error) {
177
+	var details []DetailWithType
178
+	sql := `select a.*,b.type_id,c.type_name from ta_goods_orders_detail a inner join ta_goods b on a.goods_id=b.goods_id inner join td_goods_type c on b.type_id=c.type_id where a.orders_id=?`
179
+	if err := m.db.Sql(sql, orderid).Find(&details); err != nil {
180
+		return nil, err
181
+	}
182
+	return details, nil
183
+}
184
+
176 185
 // GetOrdersByRecord 根据
177 186
 func (m *GoodsDAO) GetOrdersByRecord(recordid string) ([]OrdersWithGoods, error) {
178 187
 	var orderList []OrdersWithGoods
@@ -183,8 +192,8 @@ func (m *GoodsDAO) GetOrdersByRecord(recordid string) ([]OrdersWithGoods, error)
183 192
 		return nil, err
184 193
 	}
185 194
 	for i, o := range orderList {
186
-		var details []model.TaGoodsOrdersDetail
187
-		if err := m.db.Where("orders_id=?", o.OrdersId).Find(&details); err != nil {
195
+		details, err := m.GetOrderDetailByOrder(o.OrdersId)
196
+		if err != nil {
188 197
 			return nil, err
189 198
 		}
190 199
 		orderList[i].Goods = details

+ 8
- 1
models/goods/types.go Bestand weergeven

@@ -31,8 +31,15 @@ type GoodsWithPrice struct {
31 31
 	model.TaGoodsSpec `xorm:"extends"`
32 32
 }
33 33
 
34
+// DetailWithType 含类型的明细
35
+type DetailWithType struct {
36
+	model.TaGoodsOrdersDetail `xorm:"extends"`
37
+	TypeId                    string
38
+	TypeName                  string
39
+}
40
+
34 41
 // OrdersWithGoods 订单列表
35 42
 type OrdersWithGoods struct {
36 43
 	model.TaGoodsOrders `xorm:"extends"`
37
-	Goods               []model.TaGoodsOrdersDetail
44
+	Goods               []DetailWithType
38 45
 }

+ 0
- 4
models/verify/verify.go Bestand weergeven

@@ -28,11 +28,7 @@ type MyCourse struct {
28 28
 	CourseName                   string
29 29
 	DetailName                   string
30 30
 	LocationName                 string
31
-<<<<<<< HEAD
32
-	CostomerId                   string
33
-=======
34 31
 	CustomerId                   string
35
->>>>>>> 802c15c146846cf0ddc7fc7e0273f2683cea90f4
36 32
 }
37 33
 
38 34
 func (m *VerifyDAO) GetCustomerCourseDetailById(id string) (*model.TaCustomerCourseDetail, error) {

+ 1
- 1
service/verify/verify.go Bestand weergeven

@@ -80,7 +80,7 @@ func (s *VerifyServ) GetCustomerCourseDetailByTel(tel, caseid string, page, page
80 80
 		utils.LogError("获取列表失败: " + err.Error())
81 81
 		return nil, errors.New("获取列表失败")
82 82
 	}
83
-	customerId := customerDetail[0].
83
+	customerId := customerDetail[0].CustomerId
84 84
 	total, err := s.dao.GetCustomerCourseListByTelCount(tel, caseid)
85 85
 	if err != nil {
86 86
 		utils.LogError("获取列表失败: " + err.Error())