添source_type字段(券的来源:1-vip获得,2-认证获得,3-拉新获得),用来判断券的来源,

userinfo接口返回企业统一社会信用代码和营业执照路径
This commit is contained in:
zhoupengwei 2022-05-13 18:43:35 +08:00
parent 0ec83f9a95
commit 797681d76c
4 changed files with 32 additions and 17 deletions

View File

@ -137,8 +137,8 @@ var CompanyCtr = Ctr{
}
//统一社会信用代码
code := that.Req.FormValue("social_code")
if code == "" {
social_code := that.Req.FormValue("social_code")
if social_code == "" {
that.Display(3, "请求参数异常")
return
}
@ -162,10 +162,10 @@ var CompanyCtr = Ctr{
}
//营业执照路径
business_license := that.Req.FormValue("business_license")
//if business_license == ""{
// that.Display(3, "请求参数异常")
// return
//}
if business_license == "" {
that.Display(3, "请求参数异常")
return
}
user_id := that.Session("user_id").Data
user := that.Db.Get("user", "*", Map{"id": user_id})
if user == nil {
@ -186,7 +186,7 @@ var CompanyCtr = Ctr{
that.Db.Update("user", Map{"name": name, "phone": phone, "authentication_flag": authentication_flag}, Map{"id": user_id})
that.Db.Update("company", Map{"code": code, "name": company_name, "phone": phone, "business_license": business_license, "modify_time[#]": "now()"}, Map{"id": id})
that.Db.Update("company", Map{"social_code": social_code, "name": company_name, "phone": phone, "business_license": business_license, "modify_time[#]": "now()"}, Map{"id": id})
//赠送一张券
data := Map{
@ -195,19 +195,16 @@ var CompanyCtr = Ctr{
"code_no": "SN" + time.Now().Format("20060102150405") + getSn(),
"effective_start_time[#]": "NOW()",
"effective_end_time": "2022-10-01 23:59:59",
"source_type": 2,
"status": 0,
"admin_id": user.GetCeilInt("admin_id"),
"create_time[#]": "NOW()",
}
//先判断是否领取过
couponCount := that.Db.Count("coupon_user", Map{"user_id": user_id})
//先判断是否领取过 source_type=2 是通过认证赠送的券
couponCount := that.Db.Count("coupon_user", Map{"AND": Map{"user_id": user_id, "source_type": 2}})
if couponCount == 0 {
that.Db.Insert("coupon_user", data)
}
//不为0但是是10的倍数说明是vip也应该给一张
if couponCount != 0 && couponCount%10 == 0 {
that.Db.Insert("coupon_user", data)
}
that.Display(0, "认证成功")
},

View File

@ -37,7 +37,7 @@ var UserCtr = Ctr{
delete(user, "password")
company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")})
company := that.Db.Get("company", "id,name,social_code,business_license", Map{"id": user.GetCeilInt("company_id")})
salesman := that.Db.Get("salesman", "id,name", Map{"id": user.GetCeilInt("salesman_id")})
provider := that.Db.Get("provider", "id,name", Map{"id": user.GetCeilInt("provider_id")})

View File

@ -163,15 +163,13 @@ var VipOrderCtr = Ctr{
"code_no": "SN" + time.Now().Format("20060102150405") + getSn(),
"effective_start_time[#]": "NOW()",
"effective_end_time": "2022-10-01 23:59:59",
"source_type": 1,
"status": 0,
"admin_id": user.GetCeilInt("admin_id"),
"create_time[#]": "NOW()",
}
for n := 0; n < 10; n++ {
that.Db.Insert("coupon_user", data2)
//fmt.Println(that.Db.LastQuery)
//fmt.Println(that.Db.LastData)
//fmt.Println(that.Db.LastErr)
}
return

View File

@ -4,6 +4,7 @@ import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"code.hoteas.com/golang/hotime/dri/wechat"
"time"
)
var Wechath5 = Ctr{
@ -63,6 +64,25 @@ var Wechath5 = Ctr{
//2022/5/11 zpw 添加字段用户关联parenid的时间 join_parent_time
that.Db.Update("user", Map{"parent_id": parentId, "index": index1 + ObjToStr(userId) + ",", "join_parent_time[#]": "NOW()"}, Map{"id": userId})
//在这里做判断 能否通过分享领券
//如果通过邀请获得的券超过了三张则不再赠送
//赠送一张券
data := Map{
"user_id": parentId,
"coupon_id": 1,
"code_no": "SN" + time.Now().Format("20060102150405") + getSn(),
"effective_start_time[#]": "NOW()",
"effective_end_time": "2022-10-01 23:59:59",
"source_type": 3,
"status": 0,
"admin_id": user.GetCeilInt("admin_id"),
"create_time[#]": "NOW()",
}
//先判断是否领取过 source_type=3 是通过拉新赠送的券
couponCount := that.Db.Count("coupon_user", Map{"AND": Map{"user_id": parentId, "source_type": 3}})
if couponCount < 3 {
that.Db.Insert("coupon_user", data)
}
}()
//最后验证服务商是否绑定