Просмотр исходного кода

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

wangfei 6 лет назад
Родитель
Сommit
d2f9af2520
2 измененных файлов: 24 добавлений и 23 удалений
  1. 4
    0
      service/goods/orders.go
  2. 20
    23
      tests/goodsorder_test.go

+ 4
- 0
service/goods/orders.go Просмотреть файл

@@ -209,6 +209,10 @@ func (s *GoodsServ) ConfirmOrder(ordersID string) error {
209 209
 		return utils.LogError("获取订单失败", err)
210 210
 	}
211 211
 
212
+	if orders.Status != models.STATUS_READY {
213
+		return errors.New("没有订单信息")
214
+	}
215
+
212 216
 	// 如果是内部人员
213 217
 	if orders.PayType == models.CONSUME_INNER {
214 218
 		// 查找禁用名单

+ 20
- 23
tests/goodsorder_test.go Просмотреть файл

@@ -40,34 +40,31 @@ func TestPreGoodsOrder(t *testing.T) {
40 40
 			// 业务返回判断
41 41
 			So(result.Code, ShouldEqual, http.StatusOK)
42 42
 			So(result.Result, ShouldNotBeEmpty)
43
-		})
44
-	})
45
-}
46 43
 
47
-func TestConfirmOrders(t *testing.T) {
48
-	orderID := "cc84338e-488e-463b-a33e-7dc7f2cd10b6"
44
+			orderID := result.Result.(map[string]interface{})["OrdersId"].(string)
49 45
 
50
-	Convey("下单确认", t, func() {
51
-		result := &controllers.JSONMessage{}
52
-		api := "/api/wechat/MQ/order/goods/" + orderID
46
+			Convey("下单确认", func() {
47
+				result := &controllers.JSONMessage{}
48
+				api := "/api/wechat/MQ/order/goods/" + orderID
53 49
 
54
-		token := &utils.JWTToken{
55
-			Guest:   false,
56
-			ID:      "oMOpz0kgTrasoAA3G70R7phomn1g", // openid
57
-			Expire:  time.Now().Local().Add(24 * 30 * time.Hour),
58
-			BatchNo: "",
59
-		}
50
+				token := &utils.JWTToken{
51
+					Guest:   false,
52
+					ID:      "oMOpz0kgTrasoAA3G70R7phomn1g", // openid
53
+					Expire:  time.Now().Local().Add(24 * 30 * time.Hour),
54
+					BatchNo: "",
55
+				}
60 56
 
61
-		code, _, err := NewRequestMock().
62
-			AddToken(token.ToMap()).
63
-			AddWechatUA().
64
-			Request(http.MethodPut, api, nil, result)
57
+				code, _, err := NewRequestMock().
58
+					AddToken(token.ToMap()).
59
+					AddWechatUA().
60
+					Request(http.MethodPut, api, nil, result)
65 61
 
66
-		So(code, ShouldEqual, http.StatusOK)
67
-		So(err, ShouldBeNil)
62
+				So(code, ShouldEqual, http.StatusOK)
63
+				So(err, ShouldBeNil)
68 64
 
69
-		// 业务返回判断
70
-		So(result.Code, ShouldEqual, http.StatusOK)
65
+				// 业务返回判断
66
+				So(result.Code, ShouldEqual, http.StatusOK)
67
+			})
68
+		})
71 69
 	})
72
-
73 70
 }