forked from golang/hotime
初步版本修正
This commit is contained in:
parent
62ba00270a
commit
53f24c033c
@ -2,9 +2,10 @@ package wechat
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"github.com/go-pay/gopay"
|
"github.com/go-pay/gopay"
|
||||||
"github.com/go-pay/gopay/pkg/xlog"
|
|
||||||
"github.com/go-pay/gopay/wechat/v3"
|
"github.com/go-pay/gopay/wechat/v3"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,6 +14,8 @@ import (
|
|||||||
type wxpay struct {
|
type wxpay struct {
|
||||||
client *wechat.ClientV3
|
client *wechat.ClientV3
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
apiV3Key string
|
||||||
|
MchId string
|
||||||
}
|
}
|
||||||
|
|
||||||
var WxPay = wxpay{}
|
var WxPay = wxpay{}
|
||||||
@ -21,17 +24,21 @@ var WxPay = wxpay{}
|
|||||||
func (that *wxpay) Init(MchId, SerialNo, APIv3Key, PrivateKey string) {
|
func (that *wxpay) Init(MchId, SerialNo, APIv3Key, PrivateKey string) {
|
||||||
client, err := wechat.NewClientV3(MchId, SerialNo, APIv3Key, PrivateKey)
|
client, err := wechat.NewClientV3(MchId, SerialNo, APIv3Key, PrivateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
xlog.Error(err)
|
//xlog.Error(err)
|
||||||
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
that.client = client
|
that.client = client
|
||||||
|
that.apiV3Key = APIv3Key
|
||||||
|
that.MchId = MchId
|
||||||
// 设置微信平台API证书和序列号(如开启自动验签,请忽略此步骤)
|
// 设置微信平台API证书和序列号(如开启自动验签,请忽略此步骤)
|
||||||
//client.SetPlatformCert([]byte(""), "")
|
//client.SetPlatformCert([]byte(""), "")
|
||||||
that.ctx = context.Background()
|
that.ctx = context.Background()
|
||||||
// 启用自动同步返回验签,并定时更新微信平台API证书(开启自动验签时,无需单独设置微信平台API证书和序列号)
|
// 启用自动同步返回验签,并定时更新微信平台API证书(开启自动验签时,无需单独设置微信平台API证书和序列号)
|
||||||
err = client.AutoVerifySign()
|
err = client.AutoVerifySign()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
xlog.Error(err)
|
//xlog.Error(err)
|
||||||
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,38 +47,78 @@ func (that *wxpay) Init(MchId, SerialNo, APIv3Key, PrivateKey string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetUserInfo 获取用户信息
|
// GetUserInfo 获取用户信息
|
||||||
func (that *wxpay) GetJsOrder(money int64, appid, name, tradeNo, notifyUrl string) (jsApiParams *wechat.JSAPIPayParams, err error) {
|
func (that *wxpay) GetJsOrder(money int64, appid, openid, name, tradeNo, notifyUrl string) (jsApiParams *wechat.JSAPIPayParams, err error) {
|
||||||
|
fmt.Println("dasdas", money, appid, name, tradeNo, notifyUrl)
|
||||||
PrepayId, err := that.getPrepayId(money, name, tradeNo, notifyUrl)
|
PrepayId, err := that.getPrepayId(money, appid, that.MchId, openid, name, tradeNo, notifyUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//小程序
|
//小程序
|
||||||
jsapi, err := that.client.PaySignOfJSAPI(appid, PrepayId)
|
jsapi, err := that.client.PaySignOfJSAPI(appid, PrepayId)
|
||||||
return jsapi, err
|
return jsapi, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserInfo 获取用户信息
|
func (that *wxpay) CallbackJsOrder(req *http.Request) (*wechat.V3DecryptResult, error) {
|
||||||
func (that *wxpay) GetMiniOrder(money int64, appid, name, tradeNo, notifyUrl string) (jsApiParams *wechat.AppletParams, err error) {
|
|
||||||
|
|
||||||
PrepayId, err := that.getPrepayId(money, name, tradeNo, notifyUrl)
|
notifyReq, err := wechat.V3ParseNotify(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//xlog.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//小程序
|
// wxPublicKey 通过 client.WxPublicKey() 获取
|
||||||
applet, err := that.client.PaySignOfApplet(appid, PrepayId)
|
err = notifyReq.VerifySignByPK(that.client.WxPublicKey())
|
||||||
|
if err != nil {
|
||||||
|
//xlog.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return applet, err
|
// ========异步通知敏感信息解密========
|
||||||
|
// 普通支付通知解密
|
||||||
|
result, err := notifyReq.DecryptCipherText(that.apiV3Key)
|
||||||
|
|
||||||
|
//that.client.V3TransactionQueryOrder(that.ctx,result.BankType,result.OR)
|
||||||
|
|
||||||
|
return result, err
|
||||||
|
|
||||||
|
// 合单支付通知解密
|
||||||
|
//result, err := notifyReq.DecryptCombineCipherText(apiV3Key)
|
||||||
|
//// 退款通知解密
|
||||||
|
//result, err := notifyReq.DecryptRefundCipherText(apiV3Key)
|
||||||
|
|
||||||
|
// ========异步通知应答========
|
||||||
|
// 退款通知http应答码为200且返回状态码为SUCCESS才会当做商户接收成功,否则会重试。
|
||||||
|
// 注意:重试过多会导致微信支付端积压过多通知而堵塞,影响其他正常通知。
|
||||||
|
|
||||||
|
// 此写法是 gin 框架返回微信的写法
|
||||||
|
//c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"})
|
||||||
|
//
|
||||||
|
//// 此写法是 echo 框架返回微信的写法
|
||||||
|
//return c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (that *wxpay) getPrepayId(money int64, name, tradeNo, notifyUrl string) (prepayid string, err error) {
|
// GetUserInfo 获取用户信息
|
||||||
|
//func (that *wxpay) GetMiniOrder(money int64,appid,name,tradeNo,notifyUrl string) (jsApiParams *wechat.AppletParams,err error){
|
||||||
|
//
|
||||||
|
// PrepayId,err:=that.getPrepayId(money,name,tradeNo,notifyUrl)
|
||||||
|
// if err!=nil{
|
||||||
|
// return nil,err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //小程序
|
||||||
|
// applet, err := that.client.PaySignOfApplet(appid,PrepayId)
|
||||||
|
//
|
||||||
|
// return applet,err
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (that *wxpay) getPrepayId(money int64, appid, mchid, openid, name, tradeNo, notifyUrl string) (prepayid string, err error) {
|
||||||
expire := time.Now().Add(10 * time.Minute).Format(time.RFC3339)
|
expire := time.Now().Add(10 * time.Minute).Format(time.RFC3339)
|
||||||
// 初始化 BodyMap
|
// 初始化 BodyMap
|
||||||
bm := make(gopay.BodyMap)
|
bm := make(gopay.BodyMap)
|
||||||
bm.Set("sp_appid", "sp_appid").
|
bm.Set("appid", appid).
|
||||||
Set("sp_mchid", "sp_mchid").
|
Set("mchid", mchid).
|
||||||
Set("sub_mchid", "sub_mchid").
|
//Set("sub_mchid", "sub_mchid").
|
||||||
Set("description", name).
|
Set("description", name).
|
||||||
Set("out_trade_no", tradeNo).
|
Set("out_trade_no", tradeNo).
|
||||||
Set("time_expire", expire).
|
Set("time_expire", expire).
|
||||||
@ -81,13 +128,14 @@ func (that *wxpay) getPrepayId(money int64, name, tradeNo, notifyUrl string) (pr
|
|||||||
Set("currency", "CNY")
|
Set("currency", "CNY")
|
||||||
}).
|
}).
|
||||||
SetBodyMap("payer", func(bm gopay.BodyMap) {
|
SetBodyMap("payer", func(bm gopay.BodyMap) {
|
||||||
bm.Set("sp_openid", "asdas")
|
bm.Set("openid", openid)
|
||||||
})
|
})
|
||||||
//ctx:=context.Context()
|
//ctx:=context.Context()
|
||||||
|
|
||||||
wxRsp, err := that.client.V3TransactionJsapi(that.ctx, bm)
|
wxRsp, err := that.client.V3TransactionJsapi(that.ctx, bm)
|
||||||
|
fmt.Println("获取PrepayId", wxRsp, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
xlog.Error(err)
|
//xlog.Error(err)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return wxRsp.Response.PrepayId, nil
|
return wxRsp.Response.PrepayId, nil
|
||||||
|
@ -9,7 +9,29 @@ var ArticleCtr = Ctr{
|
|||||||
|
|
||||||
"getdispatchs": func(that *Context) {
|
"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)
|
that.Display(0, res)
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -69,7 +91,7 @@ var ArticleCtr = Ctr{
|
|||||||
count := that.Db.Count("article", data)
|
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,"+
|
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 {
|
for _, v := range res {
|
||||||
|
|
||||||
if v.GetCeilInt("notify_id") > 0 {
|
if v.GetCeilInt("notify_id") > 0 {
|
||||||
|
@ -11,6 +11,13 @@ var CompanyCtr = Ctr{
|
|||||||
|
|
||||||
"search": func(that *Context) {
|
"search": func(that *Context) {
|
||||||
keywords := that.Req.FormValue("keywords")
|
keywords := that.Req.FormValue("keywords")
|
||||||
|
if keywords == "" {
|
||||||
|
keywords = that.Req.FormValue("company_name")
|
||||||
|
}
|
||||||
|
if keywords == "" {
|
||||||
|
keywords = that.Req.FormValue("name")
|
||||||
|
}
|
||||||
|
|
||||||
if len(keywords) < 2 {
|
if len(keywords) < 2 {
|
||||||
that.Display(0, Slice{})
|
that.Display(0, Slice{})
|
||||||
return
|
return
|
||||||
|
@ -388,15 +388,15 @@ var DeclareCtr = Ctr{
|
|||||||
|
|
||||||
res = append(res, article)
|
res = append(res, article)
|
||||||
}
|
}
|
||||||
minMoney := float64(0)
|
minMoney := 0
|
||||||
maxMoney := float64(0)
|
maxMoney := 0
|
||||||
for _, v := range res {
|
for _, v := range res {
|
||||||
if v.GetMap("declare") != nil {
|
if v.GetMap("declare") != nil {
|
||||||
if v.GetMap("declare").GetFloat64("money_scope_min") < minMoney {
|
if v.GetMap("declare").GetInt("money_scope_min") < minMoney {
|
||||||
minMoney = v.GetMap("declare").GetFloat64("money_scope_min")
|
minMoney = v.GetMap("declare").GetInt("money_scope_min")
|
||||||
}
|
}
|
||||||
if v.GetMap("declare").GetFloat64("money_scope_max") > maxMoney {
|
if v.GetMap("declare").GetInt("money_scope_max") > maxMoney {
|
||||||
maxMoney = v.GetMap("declare").GetFloat64("money_scope_max")
|
maxMoney = v.GetMap("declare").GetInt("money_scope_max")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ var DeclareCtr = Ctr{
|
|||||||
count := that.Db.Count("article", data)
|
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,"+
|
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 {
|
for _, v := range res {
|
||||||
|
|
||||||
//if v.GetCeilInt("declare_id")>0{
|
//if v.GetCeilInt("declare_id")>0{
|
||||||
|
@ -23,6 +23,7 @@ var Project = Proj{
|
|||||||
"sms": Sms,
|
"sms": Sms,
|
||||||
"tag": TagCtr,
|
"tag": TagCtr,
|
||||||
"user": UserCtr,
|
"user": UserCtr,
|
||||||
|
"vip_order": VipOrderCtr,
|
||||||
"websocket": WebsocketCtr,
|
"websocket": WebsocketCtr,
|
||||||
"wechath5": Wechath5,
|
"wechath5": Wechath5,
|
||||||
"wechatmini": Wechath5,
|
"wechatmini": Wechath5,
|
||||||
|
@ -24,7 +24,7 @@ var MattersCtr = Ctr{
|
|||||||
return
|
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 {
|
if salesman == nil {
|
||||||
that.Display(4, "找不到服务商")
|
that.Display(4, "找不到服务商")
|
||||||
return
|
return
|
||||||
@ -41,8 +41,17 @@ var MattersCtr = Ctr{
|
|||||||
"modify_time[#]": "now()",
|
"modify_time[#]": "now()",
|
||||||
"del_flag": 0,
|
"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) {
|
"info": func(that *Context) {
|
||||||
if that.Session("user_id").Data == nil {
|
if that.Session("user_id").Data == nil {
|
||||||
|
@ -92,7 +92,7 @@ var NotifyCtr = Ctr{
|
|||||||
count := that.Db.Count("article", data)
|
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,"+
|
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 {
|
for _, v := range res {
|
||||||
|
|
||||||
if v.GetCeilInt("notify_id") > 0 {
|
if v.GetCeilInt("notify_id") > 0 {
|
||||||
|
@ -24,7 +24,7 @@ var OrderCtr = Ctr{
|
|||||||
|
|
||||||
err := auth(that, phone, companyName)
|
err := auth(that, phone, companyName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
that.Display(3, err)
|
that.Display(3, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ var PolicyCtr = Ctr{
|
|||||||
count := that.Db.Count("article", data)
|
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,"+
|
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 {
|
for _, v := range res {
|
||||||
|
|
||||||
//if v.GetCeilInt("policy_id")>0{
|
//if v.GetCeilInt("policy_id")>0{
|
||||||
|
@ -36,7 +36,9 @@ var SearchRecordCtr = Ctr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(data) > 1 {
|
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)
|
count := that.Db.Count("search_record", data)
|
||||||
|
@ -20,7 +20,7 @@ var UserCtr = Ctr{
|
|||||||
|
|
||||||
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").ToCeilInt()})
|
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").ToCeilInt()})
|
||||||
if user == nil {
|
if user == nil {
|
||||||
that.Display(4, "获取个人信息失败")
|
that.Display(2, "获取个人信息失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
. "code.hoteas.com/golang/hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
|
"code.hoteas.com/golang/hotime/dri/wechat"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VipOrderCtr = Ctr{
|
var VipOrderCtr = Ctr{
|
||||||
@ -19,12 +23,136 @@ var VipOrderCtr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := auth(that, phone, companyName)
|
that.Db.Delete("vip_order", Map{"AND": Map{"user_id": that.Session("user_id").Data, "status": 0}})
|
||||||
if err != nil {
|
|
||||||
that.Display(3, err)
|
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").Data})
|
||||||
|
if user == nil {
|
||||||
|
that.Display(2, "找不到此用户")
|
||||||
return
|
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
|
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() {
|
defer func() {
|
||||||
//有sn就关联业务员
|
//有sn就关联业务员
|
||||||
@ -131,6 +155,7 @@ var Wechath5 = Ctr{
|
|||||||
user := Map{
|
user := Map{
|
||||||
"nickname": wechatInfo.GetString("nickname"),
|
"nickname": wechatInfo.GetString("nickname"),
|
||||||
"avatar": wechatInfo.GetString("avatar"),
|
"avatar": wechatInfo.GetString("avatar"),
|
||||||
|
"index": ",",
|
||||||
"create_time[#]": "now()",
|
"create_time[#]": "now()",
|
||||||
"modify_time[#]": "now()",
|
"modify_time[#]": "now()",
|
||||||
"login_time[#]": "now()",
|
"login_time[#]": "now()",
|
||||||
@ -160,6 +185,7 @@ var Wechath5 = Ctr{
|
|||||||
user := Map{
|
user := Map{
|
||||||
"nickname": wechatInfo.GetString("nickname"),
|
"nickname": wechatInfo.GetString("nickname"),
|
||||||
"avatar": wechatInfo.GetString("avatar"),
|
"avatar": wechatInfo.GetString("avatar"),
|
||||||
|
"index": ",",
|
||||||
"create_time[#]": "now()",
|
"create_time[#]": "now()",
|
||||||
"modify_time[#]": "now()",
|
"modify_time[#]": "now()",
|
||||||
"login_time[#]": "now()",
|
"login_time[#]": "now()",
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
"smsLogin": "【政策通】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
"smsLogin": "【政策通】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
||||||
"tpt": "tpt",
|
"tpt": "tpt",
|
||||||
"wechatAppID": "wxdcc8d6360661a179",
|
"wechatAppID": "wxdcc8d6360661a179",
|
||||||
|
"wechatAppNotifyUrl": "https://zcth5.kct.cn/app/vip_order/callback",
|
||||||
"wechatAppSecret": "4d793683ca915264663a9c9a33530c3c",
|
"wechatAppSecret": "4d793683ca915264663a9c9a33530c3c",
|
||||||
"wechatMiniAppID": "wx1c795e883b5b54c4",
|
"wechatMiniAppID": "wx1c795e883b5b54c4",
|
||||||
"wechatMiniAppSecret": "d2bec12d1fa4d8b5714ccbed1c0671e4",
|
"wechatMiniAppSecret": "d2bec12d1fa4d8b5714ccbed1c0671e4",
|
||||||
|
113
example/provider/declare.go
Normal file
113
example/provider/declare.go
Normal 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})
|
||||||
|
},
|
||||||
|
}
|
@ -9,10 +9,12 @@ import (
|
|||||||
// Project 管理端项目
|
// Project 管理端项目
|
||||||
var Project = Proj{
|
var Project = Proj{
|
||||||
"company": CompanyCtr,
|
"company": CompanyCtr,
|
||||||
|
"declare": DeclareCtr,
|
||||||
"matters": MattersCtr,
|
"matters": MattersCtr,
|
||||||
"order": OrderCtr,
|
"order": OrderCtr,
|
||||||
"salesman": Salesman,
|
"salesman": Salesman,
|
||||||
"sms": Sms,
|
"sms": Sms,
|
||||||
|
"tag": TagCtr,
|
||||||
"user": UserCtr,
|
"user": UserCtr,
|
||||||
"wechat": Wechat,
|
"wechat": Wechat,
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,9 @@ var MattersCtr = Ctr{
|
|||||||
|
|
||||||
for _, v := range res {
|
for _, v := range res {
|
||||||
if v.GetCeilInt64("user_id") != 0 {
|
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 {
|
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")})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,23 @@ var OrderCtr = Ctr{
|
|||||||
that.Display(3, "请求参数异常")
|
that.Display(3, "请求参数异常")
|
||||||
return
|
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 {
|
if res == nil {
|
||||||
that.Display(4, "找不到对应订单")
|
that.Display(4, "找不到对应订单")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
|
|
||||||
that.Display(4, "不是你的订单")
|
//if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
|
||||||
return
|
// that.Display(4, "不是你的订单")
|
||||||
}
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
if res.GetCeilInt("user_id") > 0 {
|
if res.GetCeilInt("user_id") > 0 {
|
||||||
res["user"] = that.Db.Get("user", "name,nickname,avatar", Map{"id": res.GetCeilInt("user_id")})
|
res["user"] = that.Db.Get("user", "name,nickname,avatar", Map{"id": res.GetCeilInt("user_id")})
|
||||||
@ -59,7 +65,7 @@ var OrderCtr = Ctr{
|
|||||||
return
|
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 {
|
if order == nil {
|
||||||
that.Display(4, "不是属于你的订单")
|
that.Display(4, "不是属于你的订单")
|
||||||
return
|
return
|
||||||
@ -129,7 +135,7 @@ var OrderCtr = Ctr{
|
|||||||
data["declare_id"] = declareId
|
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 {
|
if order == nil {
|
||||||
that.Display(4, "不是属于你的订单")
|
that.Display(4, "不是属于你的订单")
|
||||||
return
|
return
|
||||||
@ -178,7 +184,13 @@ var OrderCtr = Ctr{
|
|||||||
pageSize = 20
|
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")
|
keywords := that.Req.FormValue("keywords")
|
||||||
if keywords != "" {
|
if keywords != "" {
|
||||||
data["OR"] = Map{"sn[~]": keywords, "name[~]": keywords}
|
data["OR"] = Map{"sn[~]": keywords, "name[~]": keywords}
|
||||||
|
83
example/provider/tag.go
Normal file
83
example/provider/tag.go
Normal 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})
|
||||||
|
},
|
||||||
|
}
|
@ -3,6 +3,7 @@ package provider
|
|||||||
import (
|
import (
|
||||||
. "code.hoteas.com/golang/hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
. "code.hoteas.com/golang/hotime/common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var UserCtr = Ctr{
|
var UserCtr = Ctr{
|
||||||
@ -124,12 +125,16 @@ var UserCtr = Ctr{
|
|||||||
|
|
||||||
if tp == 2 {
|
if tp == 2 {
|
||||||
data["certification_flag"] = 1
|
data["certification_flag"] = 1
|
||||||
data["expiration_time[<]"] = "now()"
|
data["OR"] = Map{"expiration_time": nil, "expiration_time[#]": "now()"}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tp == 3 {
|
if tp == 3 {
|
||||||
data["certification_flag"] = 1
|
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)
|
count := that.Db.Count("user", data)
|
||||||
|
Loading…
Reference in New Issue
Block a user