初步版本修正

This commit is contained in:
hoteas
2022-05-05 00:29:30 +08:00
parent ce8059b0a0
commit f0d4efd8fc
20 changed files with 511 additions and 52 deletions
+24 -2
View File
@@ -9,7 +9,29 @@ var ArticleCtr = Ctr{
"getdispatchs": func(that *Context) {
res := that.Db.Select("article", "dispatch_name", Map{"del_flag": 0, "GROUP": "dispatch_name"})
//判断类型
tp := that.Req.FormValue("type")
//判断类型
data := Map{"del_flag": 0}
if tp == "notify" {
data["notify_id[!]"] = nil
}
if tp == "policy" {
data["policy_id[!]"] = nil
}
if tp == "declare" {
data["declare_id[!]"] = nil
}
if len(data) > 1 {
data = Map{"AND": data, "GROUP": "dispatch_name"}
} else {
data["GROUP"] = "dispatch_name"
}
res := that.Db.Select("article", "dispatch_name", data)
that.Display(0, res)
},
@@ -69,7 +91,7 @@ var ArticleCtr = Ctr{
count := that.Db.Count("article", data)
res := that.Db.Page(page, pageSize).PageSelect("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,policy_id,declare_id,notify_id", data)
"favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,policy_id,declare_id,notify_id,dispatch_name,policy_level", data)
for _, v := range res {
if v.GetCeilInt("notify_id") > 0 {
+7
View File
@@ -11,6 +11,13 @@ var CompanyCtr = Ctr{
"search": func(that *Context) {
keywords := that.Req.FormValue("keywords")
if keywords == "" {
keywords = that.Req.FormValue("company_name")
}
if keywords == "" {
keywords = that.Req.FormValue("name")
}
if len(keywords) < 2 {
that.Display(0, Slice{})
return
+7 -7
View File
@@ -388,15 +388,15 @@ var DeclareCtr = Ctr{
res = append(res, article)
}
minMoney := float64(0)
maxMoney := float64(0)
minMoney := 0
maxMoney := 0
for _, v := range res {
if v.GetMap("declare") != nil {
if v.GetMap("declare").GetFloat64("money_scope_min") < minMoney {
minMoney = v.GetMap("declare").GetFloat64("money_scope_min")
if v.GetMap("declare").GetInt("money_scope_min") < minMoney {
minMoney = v.GetMap("declare").GetInt("money_scope_min")
}
if v.GetMap("declare").GetFloat64("money_scope_max") > maxMoney {
maxMoney = v.GetMap("declare").GetFloat64("money_scope_max")
if v.GetMap("declare").GetInt("money_scope_max") > maxMoney {
maxMoney = v.GetMap("declare").GetInt("money_scope_max")
}
}
}
@@ -465,7 +465,7 @@ var DeclareCtr = Ctr{
count := that.Db.Count("article", data)
res := that.Db.Page(page, pageSize).PageSelect("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", data)
"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,dispatch_name,policy_level", data)
for _, v := range res {
//if v.GetCeilInt("declare_id")>0{
+1
View File
@@ -23,6 +23,7 @@ var Project = Proj{
"sms": Sms,
"tag": TagCtr,
"user": UserCtr,
"vip_order": VipOrderCtr,
"websocket": WebsocketCtr,
"wechath5": Wechath5,
"wechatmini": Wechath5,
+11 -2
View File
@@ -24,7 +24,7 @@ var MattersCtr = Ctr{
return
}
salesman := that.Db.Get("salesman", "*", Map{"AND": Map{"sn": sn, "del_flag": 0}})
salesman := that.Db.Get("salesman", "id,provider_id,name,nickname", Map{"AND": Map{"sn": sn, "del_flag": 0}})
if salesman == nil {
that.Display(4, "找不到服务商")
return
@@ -41,8 +41,17 @@ var MattersCtr = Ctr{
"modify_time[#]": "now()",
"del_flag": 0,
})
res := that.Db.Get("matters", "*", Map{"id": re})
if res == nil {
that.Display(4, "找不到事项")
return
}
that.Display(0, re)
res["salesman"] = that.Db.Get("salesman", "name,id", Map{"id": res.GetCeilInt64("salesman_id")})
res["provider"] = that.Db.Get("provider", "name,id", Map{"id": res.GetCeilInt64("provider_id")})
that.Display(0, res)
},
"info": func(that *Context) {
if that.Session("user_id").Data == nil {
+1 -1
View File
@@ -92,7 +92,7 @@ var NotifyCtr = Ctr{
count := that.Db.Count("article", data)
res := that.Db.Page(page, pageSize).PageSelect("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,policy_id,declare_id,notify_id", data)
"favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,policy_id,declare_id,notify_id,dispatch_name,policy_level", data)
for _, v := range res {
if v.GetCeilInt("notify_id") > 0 {
+1 -1
View File
@@ -24,7 +24,7 @@ var OrderCtr = Ctr{
err := auth(that, phone, companyName)
if err != nil {
that.Display(3, err)
that.Display(3, err.Error())
return
}
+1 -1
View File
@@ -93,7 +93,7 @@ var PolicyCtr = Ctr{
count := that.Db.Count("article", data)
res := that.Db.Page(page, pageSize).PageSelect("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,policy_id,declare_id,policy_id", data)
"favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,policy_id,declare_id,policy_id,dispatch_name,policy_level", data)
for _, v := range res {
//if v.GetCeilInt("policy_id")>0{
+3 -1
View File
@@ -36,7 +36,9 @@ var SearchRecordCtr = Ctr{
}
if len(data) > 1 {
data = Map{"AND": data, "ORDER": "create_time DESC"}
data = Map{"AND": data}
} else {
data["ORDER"] = "create_time DESC"
}
count := that.Db.Count("search_record", data)
+1 -1
View File
@@ -20,7 +20,7 @@ var UserCtr = Ctr{
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").ToCeilInt()})
if user == nil {
that.Display(4, "获取个人信息失败")
that.Display(2, "获取个人信息失败")
return
}
+132 -4
View File
@@ -2,6 +2,10 @@ package app
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"code.hoteas.com/golang/hotime/dri/wechat"
"fmt"
"time"
)
var VipOrderCtr = Ctr{
@@ -19,12 +23,136 @@ var VipOrderCtr = Ctr{
return
}
err := auth(that, phone, companyName)
if err != nil {
that.Display(3, err)
that.Db.Delete("vip_order", Map{"AND": Map{"user_id": that.Session("user_id").Data, "status": 0}})
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").Data})
if user == nil {
that.Display(2, "找不到此用户")
return
}
//that.Display(0, Map{"total": count, "data": res})
wc := that.Db.Get("wechat", "openid", Map{"AND": Map{"appid": that.Config.GetString("wechatAppID"), "user_id": that.Session("user_id").Data}})
if wc == nil {
that.Display(2, "没有获取微信个人信息")
return
}
err := auth(that, phone, companyName)
if err != nil {
that.Display(3, err.Error())
return
}
data := Map{
"sn": "SN" + time.Now().Format("20060102150405") + getSn(),
//"name":"1年VIP会员",
"amount": 72000, //720元
"user_id": user.GetCeilInt64("id"),
"company_id": user.GetCeilInt("company_id"),
"expiration_time": time.Now().Add(365 * 24 * time.Hour).Format("2006-01-02 15:04:05"),
"create_time[#]": "now()",
"modify_time[#]": "now()",
"del_flag": 0,
"status": 0,
}
tp := "购买"
if user.GetString("expiration_time") != "" {
data["old_expiration_time"] = user.GetString("expiration_time")
t, e := time.Parse("2006-01-02 15:04:05", user.GetString("expiration_time"))
fmt.Println(e, "时间创建失败")
if t.Unix() >= time.Now().Unix() {
tp = "续订"
data["expiration_time"] = t.Add(365 * 24 * time.Hour).Format("2006-01-02 15:04:05")
}
}
if user.GetCeilInt("provider_id") != 0 {
data["provider_id"] = user.GetCeilInt("provider_id")
data["amount"] = 36000
//tp=tp
}
data["amount"] = 1
if user.GetCeilInt("salesman_id") != 0 {
data["salesman_id"] = user.GetCeilInt("salesman_id")
}
data["name"] = tp + "1年VIP会员"
jsParams, e := wechat.WxPay.GetJsOrder(data.GetCeilInt64("amount"), that.Config.GetString("wechatAppID"), wc.GetString("openid"), data.GetString("name"), data.GetString("sn"), that.Config.GetString("wechatAppNotifyUrl"))
if e != nil {
fmt.Println(e)
that.Display(4, e)
return
}
re := that.Db.Insert("vip_order", data)
fmt.Println(re)
that.Display(0, jsParams)
},
"callback": func(that *Context) {
data, e := wechat.WxPay.CallbackJsOrder(that.Req)
if e != nil {
fmt.Println(e)
//that.Display(4,e)
fmt.Println("返回数据错误", e)
return
}
sn := data.OutTradeNo
amount := int64(data.Amount.Total)
state := data.TradeState
//state:="SUCCESS"
//data := Map{"ces": "das"}
//sn := that.Req.FormValue("sn")
//amount := ObjToCeilInt64(that.Req.FormValue("amount"))
if state != "SUCCESS" {
fmt.Println("购买返回失败", data)
return
}
vipOrder := that.Db.Get("vip_order", "*", Map{"sn": sn})
if vipOrder == nil {
fmt.Println("找不到订单", vipOrder, data)
return
}
user := that.Db.Get("user", "*", Map{"id": vipOrder.GetCeilInt("user_id")})
if user == nil {
fmt.Println("找不到用户", vipOrder, data)
return
}
if vipOrder.GetCeilInt64("amount") != amount {
fmt.Println("金额不符", user, vipOrder, amount, data)
return
}
that.Db.Update("vip_order", Map{"status": 1}, Map{"id": vipOrder.GetCeilInt("id")})
idata := Map{"expiration_time": time.Now().Add(365 * 24 * time.Hour).Format("2006-01-02 15:04:05")}
if user.GetString("expiration_time") != "" {
t, e := time.Parse("2006-01-02 15:04:05", user.GetString("expiration_time"))
fmt.Println(e, "时间创建失败")
if t.Unix() >= time.Now().Unix() {
idata["expiration_time"] = t.Add(365 * 24 * time.Hour).Format("2006-01-02 15:04:05")
}
}
re := that.Db.Update("user", idata, Map{"id": user.GetCeilInt("id")})
if re == 0 {
fmt.Println("购买失败", user, vipOrder, re, data)
return
}
fmt.Println("成功购买", user, vipOrder, re, data)
return
},
}
+26
View File
@@ -38,7 +38,31 @@ var Wechath5 = Ctr{
}
userId := 0
defer func() {
//有sn就关联业务员
parentId := ObjToInt(that.Req.FormValue("parent_id"))
if parentId == 0 {
return
}
if userId == 0 || userId == parentId {
return
}
puser := that.Db.Get("user", "`index`,id", Map{"id": parentId})
if puser == nil {
return
}
user := that.Db.Get("user", "parent_id", Map{"id": userId})
if user.GetCeilInt("parent_id") != 0 {
return
}
index1 := puser.GetString("index")
if index1 == "," {
index1 = index1 + ObjToStr(parentId) + ","
}
that.Db.Update("user", Map{"parent_id": parentId, "index": index1 + ObjToStr(userId) + ","}, Map{"id": userId})
}()
//最后验证服务商是否绑定
defer func() {
//有sn就关联业务员
@@ -131,6 +155,7 @@ var Wechath5 = Ctr{
user := Map{
"nickname": wechatInfo.GetString("nickname"),
"avatar": wechatInfo.GetString("avatar"),
"index": ",",
"create_time[#]": "now()",
"modify_time[#]": "now()",
"login_time[#]": "now()",
@@ -160,6 +185,7 @@ var Wechath5 = Ctr{
user := Map{
"nickname": wechatInfo.GetString("nickname"),
"avatar": wechatInfo.GetString("avatar"),
"index": ",",
"create_time[#]": "now()",
"modify_time[#]": "now()",
"login_time[#]": "now()",
+1
View File
@@ -52,6 +52,7 @@
"smsLogin": "【政策通】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
"tpt": "tpt",
"wechatAppID": "wxdcc8d6360661a179",
"wechatAppNotifyUrl": "https://zcth5.kct.cn/app/vip_order/callback",
"wechatAppSecret": "4d793683ca915264663a9c9a33530c3c",
"wechatMiniAppID": "wx1c795e883b5b54c4",
"wechatMiniAppSecret": "d2bec12d1fa4d8b5714ccbed1c0671e4",
+113
View File
@@ -0,0 +1,113 @@
package provider
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
)
var DeclareCtr = Ctr{
"info": func(that *Context) {
id := ObjToInt(that.Req.FormValue("id"))
if id == 0 {
that.Display(3, "请求参数异常")
return
}
res := that.Db.Get("declare", "*", Map{"id": id})
if res == nil {
that.Display(4, "找不到通知公告")
return
}
res["click_num"] = res.GetCeilInt64("click_num") + res.GetCeilInt64("click_num_base") + 1
delete(res, "click_num_base")
res["favorite_num"] = res.GetCeilInt64("favorite_num") + res.GetCeilInt64("favorite_num_base")
delete(res, "favorite_num_base")
article := that.Db.Get("article", "*", Map{"id": res.GetCeilInt64("article_id")})
if article != nil {
article["click_num"] = article.GetCeilInt64("click_num") + article.GetCeilInt64("click_num_base") + 1
delete(article, "click_num_base")
article["favorite_num"] = article.GetCeilInt64("favorite_num") + article.GetCeilInt64("favorite_num_base")
delete(article, "favorite_num_base")
}
res["article"] = article
//浏览量加1
that.Db.Update("declare", Map{"click_num[#]": "click_num+1"}, Map{"id": id})
//浏览量加1
that.Db.Update("article", Map{"click_num[#]": "click_num+1"}, Map{"id": res.GetCeilInt64("article_id")})
//查询是否已关注
if that.Session("user_id").Data != nil {
favorite := that.Db.Get("favorite", "user_id,declare_id", Map{"AND": Map{"declare_id": id, "user_id": that.Session("user_id").ToCeilInt(), "del_flag": 0}})
res["favorite"] = favorite
}
that.Display(0, res)
},
//用户微信公众号或者小程序登录
"search": func(that *Context) {
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 20
}
data := Map{"del_flag": 0, "declare_id[!]": nil}
keywords := that.Req.FormValue("keywords")
if keywords != "" {
data["OR"] = Map{"title[~]": keywords, "description[~]": keywords, "content[~]": keywords}
}
startTime := that.Req.FormValue("starttime")
finishTime := that.Req.FormValue("finishtime")
if startTime != "" {
data["release_date[>=]"] = startTime
}
if finishTime != "" {
data["release_date[<=]"] = finishTime
}
dispatchName := that.Req.FormValue("dispatch_name")
if dispatchName != "" {
data["dispatch_name"] = dispatchName
}
if len(data) > 1 {
data = Map{"AND": data, "ORDER": "release_time DESC"}
}
count := that.Db.Count("article", data)
res := that.Db.Page(page, pageSize).PageSelect("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,dispatch_name,policy_level", data)
for _, v := range res {
//if v.GetCeilInt("declare_id")>0{
// v["declare"]=that.Db.Get("declare","id,tag",Map{"id":v.GetCeilInt("declare_id")})
//}
//if v.GetCeilInt("declare_id")>0{
// v["declare"]=that.Db.Get("declare","tag",Map{"id":v.GetCeilInt("declare_id")})
//}
if v.GetCeilInt("declare_id") > 0 {
v["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,status", Map{"id": v.GetCeilInt("declare_id")})
}
}
that.Display(0, Map{"total": count, "data": res})
},
}
+2
View File
@@ -9,10 +9,12 @@ import (
// Project 管理端项目
var Project = Proj{
"company": CompanyCtr,
"declare": DeclareCtr,
"matters": MattersCtr,
"order": OrderCtr,
"salesman": Salesman,
"sms": Sms,
"tag": TagCtr,
"user": UserCtr,
"wechat": Wechat,
}
+2 -2
View File
@@ -96,9 +96,9 @@ var MattersCtr = Ctr{
for _, v := range res {
if v.GetCeilInt64("user_id") != 0 {
v["user"] = that.Db.Get("user", "id,name,nickname,company_id", Map{"user_id": v.GetCeilInt64("user_id")})
v["user"] = that.Db.Get("user", "id,avatar,name,nickname,company_id", Map{"id": v.GetCeilInt64("user_id")})
if v.GetMap("user") != nil && v.GetMap("user").GetCeilInt64("company_id") != 0 {
v["company"] = that.Db.Get("company", "id,name", Map{"company_id": v.GetMap("user").GetCeilInt64("company_id")})
v["company"] = that.Db.Get("company", "id,name", Map{"id": v.GetMap("user").GetCeilInt64("company_id")})
}
}
}
+20 -8
View File
@@ -18,17 +18,23 @@ var OrderCtr = Ctr{
that.Display(3, "请求参数异常")
return
}
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
if salesman == nil {
that.Display(2, "登录错误")
return
}
res := that.Db.Get("order", "*", Map{"id": id})
res := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "provider_id": salesman.GetCeilInt64("provider_id")}})
if res == nil {
that.Display(4, "找不到对应订单")
return
}
if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
that.Display(4, "不是你的订单")
return
}
//if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
// that.Display(4, "不是你的订单")
// return
//}
if res.GetCeilInt("user_id") > 0 {
res["user"] = that.Db.Get("user", "name,nickname,avatar", Map{"id": res.GetCeilInt("user_id")})
@@ -59,7 +65,7 @@ var OrderCtr = Ctr{
return
}
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "salesman_id": that.Session("salesman_id").Data}})
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "provider_id": salesman.GetCeilInt64("provider_id")}})
if order == nil {
that.Display(4, "不是属于你的订单")
return
@@ -129,7 +135,7 @@ var OrderCtr = Ctr{
data["declare_id"] = declareId
}
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "salesman_id": that.Session("salesman_id").Data}})
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "provider_id": salesman.GetCeilInt64("provider_id")}})
if order == nil {
that.Display(4, "不是属于你的订单")
return
@@ -178,7 +184,13 @@ var OrderCtr = Ctr{
pageSize = 20
}
data := Map{"del_flag": 0, "salesman_id": that.Session("salesman_id").Data}
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
if salesman == nil {
that.Display(2, "登录错误")
return
}
data := Map{"del_flag": 0, "provider_id": salesman.GetCeilInt64("provider_id")}
keywords := that.Req.FormValue("keywords")
if keywords != "" {
data["OR"] = Map{"sn[~]": keywords, "name[~]": keywords}
+83
View File
@@ -0,0 +1,83 @@
package provider
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
)
var TagCtr = Ctr{
"create": func(that *Context) {
if that.Session("user_id").Data == nil {
that.Display(2, "没有登录")
return
}
name := that.Req.FormValue("name")
oldTag := that.Db.Get("tag", "id", Map{"name": name})
if oldTag != nil {
that.Display(4, "此标签已存在")
return
}
re := that.Db.Insert("tag", Map{
"user_id": that.Session("user_id").Data,
"name": name,
"remark": "用户上传",
"create_time[#]": "now()",
"modify_time[#]": "now()",
"state": 1, //先置为异常状态,等待审核通过
"del_flag": 0,
})
if re == 0 {
that.Display(4, "添加失败")
return
}
that.Display(0, "添加成功")
return
},
//用户微信公众号或者小程序登录
"search": func(that *Context) {
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 40
}
data := Map{"del_flag": 0, "state": 0}
keywords := that.Req.FormValue("keywords")
if keywords != "" {
data["OR"] = Map{"name[~]": keywords, "remark[~]": keywords}
}
startTime := that.Req.FormValue("starttime")
finishTime := that.Req.FormValue("finishtime")
if startTime != "" {
data["modify_time[>=]"] = startTime
}
if finishTime != "" {
data["modify_time[<=]"] = finishTime
}
if len(data) > 1 {
data = Map{"AND": data}
}
count := that.Db.Count("tag", data)
res := that.Db.Page(page, pageSize).PageSelect("tag", "id,name,remark", data)
that.Display(0, Map{"total": count, "data": res})
},
}
+7 -2
View File
@@ -3,6 +3,7 @@ package provider
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"time"
)
var UserCtr = Ctr{
@@ -124,12 +125,16 @@ var UserCtr = Ctr{
if tp == 2 {
data["certification_flag"] = 1
data["expiration_time[<]"] = "now()"
data["OR"] = Map{"expiration_time": nil, "expiration_time[#]": "now()"}
}
if tp == 3 {
data["certification_flag"] = 1
data["expiration_time[>]"] = "now()"
data["expiration_time[>]"] = time.Now().Format("2006-01-02 15:04:05")
}
if len(data) > 1 {
data = Map{"AND": data, "ORDER": "modify_time DESC"}
}
count := that.Db.Count("user", data)