From 3540209b263a636f862835d12902d62660807336 Mon Sep 17 00:00:00 2001 From: zhoupengwei Date: Tue, 17 May 2022 12:31:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=91=E5=88=9B=E5=88=B8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/app/article.go | 4 +- example/app/company.go | 9 ++++- example/app/coupon.go | 15 ++++++- example/app/declare.go | 4 ++ example/app/vip_order.go | 8 +++- example/app/wechath5.go | 76 ++++++++++++++++++------------------ example/provider/salesman.go | 4 +- 7 files changed, 73 insertions(+), 47 deletions(-) diff --git a/example/app/article.go b/example/app/article.go index 795b2ce..3819d76 100644 --- a/example/app/article.go +++ b/example/app/article.go @@ -59,10 +59,10 @@ var ArticleCtr = Ctr{ finishTime := that.Req.FormValue("finishtime") if startTime != "" { - data["release_date[>=]"] = startTime + data["release_time[>=]"] = startTime } if finishTime != "" { - data["release_date[<=]"] = finishTime + data["release_time[<=]"] = finishTime } dispatchName := that.Req.FormValue("dispatch_name") diff --git a/example/app/company.go b/example/app/company.go index a8c218e..a4f47c0 100644 --- a/example/app/company.go +++ b/example/app/company.go @@ -160,6 +160,12 @@ var CompanyCtr = Ctr{ that.Display(3, "请求参数异常") return } + //验证码 + err := auth(that, phone, company_name, name) + if err != nil { + that.Display(3, err.Error()) + return + } //营业执照路径 business_license := that.Req.FormValue("business_license") if business_license == "" { @@ -194,7 +200,7 @@ var CompanyCtr = Ctr{ "coupon_id": 1, "code_no": "SN" + time.Now().Format("20060102150405") + getSn(), "effective_start_time[#]": "NOW()", - "effective_end_time": "2022-10-01 23:59:59", + "effective_end_time": time.Now().AddDate(0, 6, 0).Format("2006-01-02 15:04:05"), "source_type": 2, "status": 0, "admin_id": user.GetCeilInt("admin_id"), @@ -205,7 +211,6 @@ var CompanyCtr = Ctr{ if couponCount == 0 { that.Db.Insert("coupon_user", data) } - that.Display(0, "认证成功") }, //上传营业执照 diff --git a/example/app/coupon.go b/example/app/coupon.go index c8cb2c3..ab7ffff 100644 --- a/example/app/coupon.go +++ b/example/app/coupon.go @@ -42,6 +42,17 @@ var CouponCtr = Ctr{ data.Put("coupon_user.status", status) } + specMap := Map{"AND": data} + if status == 0 { + specMap.Put("ORDER", "coupon_user.status ASC,coupon_user.effective_end_time ASC,coupon_user.create_time DESC") + } + if status == 1 { + specMap.Put("ORDER", "coupon_user.use_time DESC") + } + if status == 2 { + specMap.Put("ORDER", "coupon_user.effective_end_time DESC") + } + count := that.Db.Count("coupon_user", Map{"AND": data}) res := that.Db.Page(page, pageSize).PageSelect("coupon_user", @@ -49,8 +60,8 @@ var CouponCtr = Ctr{ "coupon_user.code_no,coupon_user.effective_start_time,coupon_user.effective_end_time,coupon_user.status,"+ "coupon.coupon_amount,coupon.coupon_type,coupon.name,"+ "coupon.description", - Map{"AND": data, - "ORDER": "coupon_user.create_time DESC"}) + specMap, + ) that.Display(0, Map{"total": count, "data": res}) }, } diff --git a/example/app/declare.go b/example/app/declare.go index 5b520fa..cd8e90d 100644 --- a/example/app/declare.go +++ b/example/app/declare.go @@ -870,6 +870,10 @@ var DeclareCtr = Ctr{ id := v.GetCeilInt("declare_id") article := that.Db.Get("article", "id,title,description,department_id,click_num+click_num_base AS click_num,"+ "favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,declare_id,declare_id,declare_id", Map{"declare_id": id}) + if article == nil { + that.Display(4, "没有查到article数据") + return + } declare := that.Db.Get("declare", "*", Map{"id": id}) //查询是否已关注 diff --git a/example/app/vip_order.go b/example/app/vip_order.go index 769794d..76e3ae8 100644 --- a/example/app/vip_order.go +++ b/example/app/vip_order.go @@ -162,13 +162,17 @@ var VipOrderCtr = Ctr{ "coupon_id": 1, "code_no": "SN" + time.Now().Format("20060102150405") + getSn(), "effective_start_time[#]": "NOW()", - "effective_end_time": "2022-10-01 23:59:59", + "effective_end_time": time.Now().AddDate(0, 6, 0).Format("2006-01-02 15:04:05"), "source_type": 1, "status": 0, "admin_id": user.GetCeilInt("admin_id"), "create_time[#]": "NOW()", } - for n := 0; n < 10; n++ { + for n := 0; n < 5; n++ { + that.Db.Insert("coupon_user", data2) + } + data2["effective_end_time"] = time.Now().AddDate(1, 0, 0).Format("2006-01-02 15:04:05") + for n := 0; n < 5; n++ { that.Db.Insert("coupon_user", data2) } return diff --git a/example/app/wechath5.go b/example/app/wechath5.go index 958011b..d0dd58d 100644 --- a/example/app/wechath5.go +++ b/example/app/wechath5.go @@ -39,6 +39,44 @@ var Wechath5 = Ctr{ } userId := 0 + + //这个defer放到上面,防止出现用户第一次登陆的时候出现不返回company和salesman的情况 + //如果有则直接返回用户信息到微信小程序里 + defer func() { + if userId != 0 { + user := that.Db.Get("user", "*", Map{"id": userId}) + if user == nil { + that.Display(4, "获取个人信息失败") + return + } + delete(user, "password") + company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")}) + + //消除company没有创建的影响 + if company == nil { + companyId := that.Db.Insert("company", Map{ + "user_id": user["id"], + "provider_id": user["provider_id"], + "salesman_id": user["salesman_id"], + "create_time[#]": "now()", + "modify_time[#]": "now()", + "del_flag": 0, + }) + user["company_id"] = companyId + that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")}) + company = that.Db.Get("company", "*", 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")}) + + user["company"] = company + user["salesman"] = salesman + user["provider"] = provider + + that.Display(0, user) + } + }() + defer func() { //有sn就关联业务员 @@ -72,7 +110,7 @@ var Wechath5 = Ctr{ "coupon_id": 1, "code_no": "SN" + time.Now().Format("20060102150405") + getSn(), "effective_start_time[#]": "NOW()", - "effective_end_time": "2022-10-01 23:59:59", + "effective_end_time": time.Now().AddDate(0, 6, 0).Format("2006-01-02 15:04:05"), "source_type": 3, "status": 0, "admin_id": user.GetCeilInt("admin_id"), @@ -122,42 +160,6 @@ var Wechath5 = Ctr{ }() - //如果有则直接返回用户信息到微信小程序里 - defer func() { - if userId != 0 { - user := that.Db.Get("user", "*", Map{"id": userId}) - if user == nil { - that.Display(4, "获取个人信息失败") - return - } - delete(user, "password") - company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")}) - - //消除company没有创建的影响 - if company == nil { - companyId := that.Db.Insert("company", Map{ - "user_id": user["id"], - "provider_id": user["provider_id"], - "salesman_id": user["salesman_id"], - "create_time[#]": "now()", - "modify_time[#]": "now()", - "del_flag": 0, - }) - user["company_id"] = companyId - that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")}) - company = that.Db.Get("company", "*", 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")}) - - user["company"] = company - user["salesman"] = salesman - user["provider"] = provider - - that.Display(0, user) - } - }() - wechat := that.Db.Get("wechat", "*", Map{"AND": Map{"openid": userInfo.OpenID, "del_flag": 0}}) if wechat != nil { diff --git a/example/provider/salesman.go b/example/provider/salesman.go index 68f5ce0..1cc4ec6 100644 --- a/example/provider/salesman.go +++ b/example/provider/salesman.go @@ -126,12 +126,12 @@ var Salesman = Ctr{ } //有用户直接返回 - if wechat.GetCeilInt("salesman_id") != 0 && wechat.GetCeilInt64("salesman_id") != salesman.GetInt64("id") { + if wechat.GetCeilInt("salesman_id") != 0 && wechat.GetCeilInt64("salesman_id") != salesman.GetCeilInt64("id") { that.Display(5, "你已经绑定了其他商户") return } - that.Db.Update("wechat", Map{"salesman_id": salesman.GetCeilInt64("id")}, Map{"id": wechat.GetInt64("id")}) + that.Db.Update("wechat", Map{"salesman_id": salesman.GetCeilInt64("id")}, Map{"id": wechat.GetCeilInt64("id")}) that.Db.Update("salesman", Map{"login_time[#]": "now()", "modify_time[#]": "now()"}, Map{"id": salesman.GetCeilInt("id")})