科创券优化

This commit is contained in:
zhoupengwei 2022-05-17 12:31:47 +08:00
parent 797681d76c
commit 3540209b26
7 changed files with 73 additions and 47 deletions

View File

@ -59,10 +59,10 @@ var ArticleCtr = Ctr{
finishTime := that.Req.FormValue("finishtime") finishTime := that.Req.FormValue("finishtime")
if startTime != "" { if startTime != "" {
data["release_date[>=]"] = startTime data["release_time[>=]"] = startTime
} }
if finishTime != "" { if finishTime != "" {
data["release_date[<=]"] = finishTime data["release_time[<=]"] = finishTime
} }
dispatchName := that.Req.FormValue("dispatch_name") dispatchName := that.Req.FormValue("dispatch_name")

View File

@ -160,6 +160,12 @@ var CompanyCtr = Ctr{
that.Display(3, "请求参数异常") that.Display(3, "请求参数异常")
return return
} }
//验证码
err := auth(that, phone, company_name, name)
if err != nil {
that.Display(3, err.Error())
return
}
//营业执照路径 //营业执照路径
business_license := that.Req.FormValue("business_license") business_license := that.Req.FormValue("business_license")
if business_license == "" { if business_license == "" {
@ -194,7 +200,7 @@ var CompanyCtr = Ctr{
"coupon_id": 1, "coupon_id": 1,
"code_no": "SN" + time.Now().Format("20060102150405") + getSn(), "code_no": "SN" + time.Now().Format("20060102150405") + getSn(),
"effective_start_time[#]": "NOW()", "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, "source_type": 2,
"status": 0, "status": 0,
"admin_id": user.GetCeilInt("admin_id"), "admin_id": user.GetCeilInt("admin_id"),
@ -205,7 +211,6 @@ var CompanyCtr = Ctr{
if couponCount == 0 { if couponCount == 0 {
that.Db.Insert("coupon_user", data) that.Db.Insert("coupon_user", data)
} }
that.Display(0, "认证成功") that.Display(0, "认证成功")
}, },
//上传营业执照 //上传营业执照

View File

@ -42,6 +42,17 @@ var CouponCtr = Ctr{
data.Put("coupon_user.status", status) 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}) count := that.Db.Count("coupon_user", Map{"AND": data})
res := that.Db.Page(page, pageSize).PageSelect("coupon_user", 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_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.coupon_amount,coupon.coupon_type,coupon.name,"+
"coupon.description", "coupon.description",
Map{"AND": data, specMap,
"ORDER": "coupon_user.create_time DESC"}) )
that.Display(0, Map{"total": count, "data": res}) that.Display(0, Map{"total": count, "data": res})
}, },
} }

View File

@ -870,6 +870,10 @@ var DeclareCtr = Ctr{
id := v.GetCeilInt("declare_id") id := v.GetCeilInt("declare_id")
article := that.Db.Get("article", "id,title,description,department_id,click_num+click_num_base AS click_num,"+ 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}) "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}) declare := that.Db.Get("declare", "*", Map{"id": id})
//查询是否已关注 //查询是否已关注

View File

@ -162,13 +162,17 @@ var VipOrderCtr = Ctr{
"coupon_id": 1, "coupon_id": 1,
"code_no": "SN" + time.Now().Format("20060102150405") + getSn(), "code_no": "SN" + time.Now().Format("20060102150405") + getSn(),
"effective_start_time[#]": "NOW()", "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, "source_type": 1,
"status": 0, "status": 0,
"admin_id": user.GetCeilInt("admin_id"), "admin_id": user.GetCeilInt("admin_id"),
"create_time[#]": "NOW()", "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) that.Db.Insert("coupon_user", data2)
} }
return return

View File

@ -39,6 +39,44 @@ var Wechath5 = Ctr{
} }
userId := 0 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() { defer func() {
//有sn就关联业务员 //有sn就关联业务员
@ -72,7 +110,7 @@ var Wechath5 = Ctr{
"coupon_id": 1, "coupon_id": 1,
"code_no": "SN" + time.Now().Format("20060102150405") + getSn(), "code_no": "SN" + time.Now().Format("20060102150405") + getSn(),
"effective_start_time[#]": "NOW()", "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, "source_type": 3,
"status": 0, "status": 0,
"admin_id": user.GetCeilInt("admin_id"), "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}}) wechat := that.Db.Get("wechat", "*", Map{"AND": Map{"openid": userInfo.OpenID, "del_flag": 0}})
if wechat != nil { if wechat != nil {

View File

@ -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, "你已经绑定了其他商户") that.Display(5, "你已经绑定了其他商户")
return 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()"}, that.Db.Update("salesman", Map{"login_time[#]": "now()", "modify_time[#]": "now()"},
Map{"id": salesman.GetCeilInt("id")}) Map{"id": salesman.GetCeilInt("id")})