From 797681d76c726c61f3c8ce26db0e048994b45630 Mon Sep 17 00:00:00 2001 From: zhoupengwei Date: Fri, 13 May 2022 18:43:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BBsource=5Ftype=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=88=E5=88=B8=E7=9A=84=E6=9D=A5=E6=BA=90=EF=BC=9A1-vip?= =?UTF-8?q?=E8=8E=B7=E5=BE=97,2-=E8=AE=A4=E8=AF=81=E8=8E=B7=E5=BE=97,3-?= =?UTF-8?q?=E6=8B=89=E6=96=B0=E8=8E=B7=E5=BE=97=EF=BC=89=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E6=9D=A5=E5=88=A4=E6=96=AD=E5=88=B8=E7=9A=84=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=EF=BC=8C=20userinfo=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=BB=9F=E4=B8=80=E7=A4=BE=E4=BC=9A=E4=BF=A1?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81=E5=92=8C=E8=90=A5=E4=B8=9A=E6=89=A7?= =?UTF-8?q?=E7=85=A7=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/app/company.go | 23 ++++++++++------------- example/app/user.go | 2 +- example/app/vip_order.go | 4 +--- example/app/wechath5.go | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/example/app/company.go b/example/app/company.go index 1b9f03b..a8c218e 100644 --- a/example/app/company.go +++ b/example/app/company.go @@ -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, "认证成功") }, diff --git a/example/app/user.go b/example/app/user.go index 0358952..4c695ab 100644 --- a/example/app/user.go +++ b/example/app/user.go @@ -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")}) diff --git a/example/app/vip_order.go b/example/app/vip_order.go index 000a772..769794d 100644 --- a/example/app/vip_order.go +++ b/example/app/vip_order.go @@ -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 diff --git a/example/app/wechath5.go b/example/app/wechath5.go index 31b4d8f..958011b 100644 --- a/example/app/wechath5.go +++ b/example/app/wechath5.go @@ -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) + } }() //最后验证服务商是否绑定