Browse Source

判断推荐码是否正确

胡轶钦 6 years ago
parent
commit
9fa0e368f2

+ 10
- 0
controllers/customerremark/customerremark.go View File

55
 	c.ResponseJSON(newRemark)
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
 func (c *CustomerRemarkController) SearchCustomer() {
68
 func (c *CustomerRemarkController) SearchCustomer() {
59
 	salesId := c.GetString(":salesId")
69
 	salesId := c.GetString(":salesId")
60
 	customerInfo := c.GetString(":customerInfo")
70
 	customerInfo := c.GetString(":customerInfo")

+ 8
- 0
models/customerremark/customerremark.go View File

128
 	return len(customerReceive), err
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 View File

95
 		beego.NSRouter("/user/luckdraw/record/:id", &luckdraw.LuckDrawController{}, "get:GetRecordByID"),
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
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
101
 		beego.NSRouter("/flashbuy/:id", &flashbuy.FlashBuyController{}, "post:FlashBuy"),
102
 
102
 
103
 		// 客户备注
103
 		// 客户备注
104
 		beego.NSRouter("/customerremark/record/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerReceiveRecord"),
104
 		beego.NSRouter("/customerremark/record/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerReceiveRecord"),
105
 		beego.NSRouter("/customerremark/:salesId/:customerId", &customerremark.CustomerRemarkController{}, "get:GetCustomerRemarkList"),
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
 		beego.NSRouter("/customerremark", &customerremark.CustomerRemarkController{}, "post:AddRemark"),
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 View File

80
 	}
80
 	}
81
 	return &customer, nil
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 View File

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