Parcourir la source

判断推荐码是否正确

胡轶钦 il y a 6 ans
Parent
révision
9fa0e368f2

+ 10
- 0
controllers/customerremark/customerremark.go Voir le fichier

@@ -55,6 +55,16 @@ func (c *CustomerRemarkController) AddRemark() {
55 55
 	c.ResponseJSON(newRemark)
56 56
 }
57 57
 
58
+func (c *CustomerRemarkController) IsExist() {
59
+	recommendCode := c.GetString(":recommendCode")
60
+	num, err := c.dao.IsExist(recommendCode)
61
+	if err != nil {
62
+		c.ResponseError(err)
63
+	}
64
+	c.ResponseJSON(num)
65
+
66
+}
67
+
58 68
 func (c *CustomerRemarkController) SearchCustomer() {
59 69
 	salesId := c.GetString(":salesId")
60 70
 	customerInfo := c.GetString(":customerInfo")

+ 8
- 0
models/customerremark/customerremark.go Voir le fichier

@@ -128,3 +128,11 @@ FROM
128 128
 	return len(customerReceive), err
129 129
 
130 130
 }
131
+
132
+func (m *CustomerRemarkDAO) IsExist(recommendCode string) (int, error) {
133
+	var user []model.SysUser
134
+	sql := `select * from sys_user where recommend_code = '` + recommendCode + `' 
135
+	and status > ` + strconv.Itoa(models.STATUS_DEL)
136
+	err := m.db.Sql(sql).Find(&user)
137
+	return len(user), err
138
+}

+ 5
- 4
routers/wechat.go Voir le fichier

@@ -95,15 +95,16 @@ func getWechatRoutes(prefix string) beego.LinkNamespace {
95 95
 		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
96 96
 
97 97
 		// 抢购
98
-		beego.NSRouter("/flashbuy/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
99
-		beego.NSRouter("/flashbuy/:customerId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
100
-		beego.NSRouter("/flashbuy/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
98
+		beego.NSRouter("/flashbuy/flash/:flashBuyId", &flashbuy.FlashBuyController{}, "get:GetFlashBuyById"),
99
+		beego.NSRouter("/flashbuy/customer/:customerId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyByCustomerId"),
100
+		beego.NSRouter("/flashbuy/customerFlash/:customerFlashBuyId", &flashbuy.FlashBuyController{}, "get:GetCustomerFlashBuyId"),
101 101
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
102 102
 
103 103
 		// 客户备注
104 104
 		beego.NSRouter("/customerremark/record/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerReceiveRecord"),
105 105
 		beego.NSRouter("/customerremark/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerRemarkList"),
106
-		beego.NSRouter("/customerremark/:salesId/:customerInfo", &customerremark.CustomerRemarkController{}, "get:SearchCustomer"),
106
+		beego.NSRouter("/customerremark/search/:salesId/:customerInfo", &customerremark.CustomerRemarkController{}, "get:SearchCustomer"),
107 107
 		beego.NSRouter("/customerremark", &customerremark.CustomerRemarkController{}, "post:AddRemark"),
108
+		beego.NSRouter("/customerremark/exist/:recommendCode", &customerremark.CustomerRemarkController{}, "get:IsExist"),
108 109
 	)
109 110
 }

+ 8
- 0
service/customerremark/customerremark.go Voir le fichier

@@ -80,3 +80,11 @@ func (s *CustomerRemarkServ) SearchCustomer(customerInfo, salesId string) (*mode
80 80
 	}
81 81
 	return &customer, nil
82 82
 }
83
+func (s *CustomerRemarkServ) IsExist(recommendCode string) (int, error) {
84
+	num, err := s.dao.IsExist(recommendCode)
85
+	if err != nil {
86
+		utils.LogError("获取推荐人失败: " + err.Error())
87
+		return 0, errors.New("获取推荐人失败")
88
+	}
89
+	return num, nil
90
+}

+ 1
- 1
service/events/giveCard.go Voir le fichier

@@ -56,7 +56,7 @@ var giveCard = func(e tinyevent.Event) error {
56 56
 		case ActGiveCoupon:
57 57
 			res := make(map[string]interface{})
58 58
 			if err := json.Unmarshal([]byte(act.ResourceDesc), &res); err != nil {
59
-				utils.LogError("解析优惠券赠送规则失败: " + err.Error())
59
+				utils.LogError("解析体验卡赠送规则失败: " + err.Error())
60 60
 				continue
61 61
 			}
62 62