初步版本修正
This commit is contained in:
+24
-2
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -23,6 +23,7 @@ var Project = Proj{
|
||||
"sms": Sms,
|
||||
"tag": TagCtr,
|
||||
"user": UserCtr,
|
||||
"vip_order": VipOrderCtr,
|
||||
"websocket": WebsocketCtr,
|
||||
"wechath5": Wechath5,
|
||||
"wechatmini": Wechath5,
|
||||
|
||||
+11
-2
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
@@ -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
@@ -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
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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()",
|
||||
|
||||
Reference in New Issue
Block a user