调优
This commit is contained in:
parent
fe31335cf5
commit
62ba00270a
@ -64,3 +64,16 @@ func (that *h5Program) GetSignUrl(signUrl string) (*js.Config, error) {
|
||||
|
||||
return cfg1, nil
|
||||
}
|
||||
|
||||
// GetSignUrl js url签名
|
||||
//func (that *h5Program) GetJsPay(signUrl string) (*js.Config, error) {
|
||||
// //
|
||||
// //js := that.OfficialAccount().GetJs()
|
||||
// //
|
||||
// //cfg1, e := js.GetConfig(signUrl)
|
||||
// //if e != nil {
|
||||
// // return nil, e
|
||||
// //}
|
||||
//
|
||||
// return cfg1, nil
|
||||
//}
|
||||
|
94
dri/wechat/pay.go
Normal file
94
dri/wechat/pay.go
Normal file
@ -0,0 +1,94 @@
|
||||
package wechat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-pay/gopay"
|
||||
"github.com/go-pay/gopay/pkg/xlog"
|
||||
"github.com/go-pay/gopay/wechat/v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
//基于此文档开发
|
||||
//https://github.com/silenceper/wechat/blob/v2/doc/api/officialaccount.md
|
||||
type wxpay struct {
|
||||
client *wechat.ClientV3
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
var WxPay = wxpay{}
|
||||
|
||||
// Init 初始化
|
||||
func (that *wxpay) Init(MchId, SerialNo, APIv3Key, PrivateKey string) {
|
||||
client, err := wechat.NewClientV3(MchId, SerialNo, APIv3Key, PrivateKey)
|
||||
if err != nil {
|
||||
xlog.Error(err)
|
||||
return
|
||||
}
|
||||
that.client = client
|
||||
// 设置微信平台API证书和序列号(如开启自动验签,请忽略此步骤)
|
||||
//client.SetPlatformCert([]byte(""), "")
|
||||
that.ctx = context.Background()
|
||||
// 启用自动同步返回验签,并定时更新微信平台API证书(开启自动验签时,无需单独设置微信平台API证书和序列号)
|
||||
err = client.AutoVerifySign()
|
||||
if err != nil {
|
||||
xlog.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 打开Debug开关,输出日志,默认是关闭的
|
||||
client.DebugSwitch = gopay.DebugOn
|
||||
}
|
||||
|
||||
// GetUserInfo 获取用户信息
|
||||
func (that *wxpay) GetJsOrder(money int64, appid, name, tradeNo, notifyUrl string) (jsApiParams *wechat.JSAPIPayParams, err error) {
|
||||
|
||||
PrepayId, err := that.getPrepayId(money, name, tradeNo, notifyUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//小程序
|
||||
jsapi, err := that.client.PaySignOfJSAPI(appid, PrepayId)
|
||||
return jsapi, err
|
||||
}
|
||||
|
||||
// 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, name, tradeNo, notifyUrl string) (prepayid string, err error) {
|
||||
expire := time.Now().Add(10 * time.Minute).Format(time.RFC3339)
|
||||
// 初始化 BodyMap
|
||||
bm := make(gopay.BodyMap)
|
||||
bm.Set("sp_appid", "sp_appid").
|
||||
Set("sp_mchid", "sp_mchid").
|
||||
Set("sub_mchid", "sub_mchid").
|
||||
Set("description", name).
|
||||
Set("out_trade_no", tradeNo).
|
||||
Set("time_expire", expire).
|
||||
Set("notify_url", notifyUrl).
|
||||
SetBodyMap("amount", func(bm gopay.BodyMap) {
|
||||
bm.Set("total", money).
|
||||
Set("currency", "CNY")
|
||||
}).
|
||||
SetBodyMap("payer", func(bm gopay.BodyMap) {
|
||||
bm.Set("sp_openid", "asdas")
|
||||
})
|
||||
//ctx:=context.Context()
|
||||
|
||||
wxRsp, err := that.client.V3TransactionJsapi(that.ctx, bm)
|
||||
if err != nil {
|
||||
xlog.Error(err)
|
||||
return "", err
|
||||
}
|
||||
return wxRsp.Response.PrepayId, nil
|
||||
}
|
@ -4,6 +4,7 @@ import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paixuArr []Map
|
||||
@ -12,7 +13,8 @@ func (x paixuArr) Len() int {
|
||||
return len(x)
|
||||
}
|
||||
func (x paixuArr) Less(i, j int) bool {
|
||||
return x[i].GetCeilInt64("count") < x[j].GetCeilInt64("count")
|
||||
|
||||
return x[i].GetCeilInt64("count") > x[j].GetCeilInt64("count")
|
||||
}
|
||||
func (x paixuArr) Swap(i, j int) {
|
||||
x[i], x[j] = x[j], x[i]
|
||||
@ -67,7 +69,7 @@ var DeclareCtr = Ctr{
|
||||
//政策匹配
|
||||
"match": func(that *Context) {
|
||||
|
||||
if that.Session("user_id").Data != nil {
|
||||
if that.Session("user_id").Data == nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
@ -83,6 +85,18 @@ var DeclareCtr = Ctr{
|
||||
that.Display(3, "参数错误")
|
||||
return
|
||||
}
|
||||
qu := that.Req.FormValue("register_address")
|
||||
qus := strings.Split(qu, "/")
|
||||
|
||||
for _, v := range qus {
|
||||
if v != "" {
|
||||
qu = v
|
||||
}
|
||||
}
|
||||
|
||||
if !strings.Contains(qu, "区") && !strings.Contains(qu, "县") {
|
||||
qu = "没有此项数据随意填充的"
|
||||
}
|
||||
|
||||
company := that.Db.Get("company", "*", Map{"user_id": that.Session("user_id").Data})
|
||||
delete(company, "id")
|
||||
@ -125,7 +139,7 @@ var DeclareCtr = Ctr{
|
||||
//标签分析
|
||||
if tags != nil {
|
||||
for _, v := range tags {
|
||||
dtag := that.Db.Select("declare_tag", "id,declare_id", Map{"tag_id": v})
|
||||
dtag := that.Db.Select("declare_tag", Map{"[><]`declare`": "declare_tag.declare_id=declare.id"}, "declare_tag.declare_id", Map{"AND": Map{"OR": Map{"declare.policy_level": Slice{"省", "市"}, "declare.dispatch_department[~]": qu}, "declare_tag.tag_id": v}})
|
||||
for _, v1 := range dtag {
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
declares[v1.GetCeilInt64("declare_id")] = v1
|
||||
@ -137,7 +151,7 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
|
||||
//企业规模分析
|
||||
dtag := that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "company_scale[<=]": ObjToInt(that.Req.FormValue("company_scale"))}})
|
||||
dtag := that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "company_scale[<=]": ObjToInt(that.Req.FormValue("company_scale"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -150,7 +164,7 @@ var DeclareCtr = Ctr{
|
||||
//是否是有效期内的科技型中小企业称号:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("smes_flag")) > 0 {
|
||||
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "smes_flag": ObjToInt(that.Req.FormValue("smes_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "smes_flag": ObjToInt(that.Req.FormValue("smes_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -164,7 +178,7 @@ var DeclareCtr = Ctr{
|
||||
//是否是有效期内的高新区技术企业称号:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("htzte_flag")) > 0 {
|
||||
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "htzte_flag": ObjToInt(that.Req.FormValue("htzte_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "htzte_flag": ObjToInt(that.Req.FormValue("htzte_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -179,11 +193,14 @@ var DeclareCtr = Ctr{
|
||||
flagslice := Slice{}
|
||||
if flags != nil {
|
||||
for _, v := range flags {
|
||||
if v == "0" {
|
||||
continue
|
||||
}
|
||||
flagslice = append(flagslice, v)
|
||||
}
|
||||
|
||||
}
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "engineering_center_flag": flagslice}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "engineering_center_flag": flagslice}})
|
||||
|
||||
for _, v1 := range dtag {
|
||||
|
||||
@ -199,11 +216,14 @@ var DeclareCtr = Ctr{
|
||||
flagslice = Slice{}
|
||||
if flags != nil {
|
||||
for _, v := range flags {
|
||||
if v == "0" {
|
||||
continue
|
||||
}
|
||||
flagslice = append(flagslice, v)
|
||||
}
|
||||
|
||||
}
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "engineering_laboratory_flag": flagslice}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "engineering_laboratory_flag": flagslice}})
|
||||
|
||||
for _, v1 := range dtag {
|
||||
|
||||
@ -219,11 +239,14 @@ var DeclareCtr = Ctr{
|
||||
flagslice = Slice{}
|
||||
if flags != nil {
|
||||
for _, v := range flags {
|
||||
if v == "0" {
|
||||
continue
|
||||
}
|
||||
flagslice = append(flagslice, v)
|
||||
}
|
||||
|
||||
}
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "key_laboratory_flag": flagslice}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "key_laboratory_flag": flagslice}})
|
||||
for _, v1 := range dtag {
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
declares[v1.GetCeilInt64("declare_id")] = v1
|
||||
@ -237,11 +260,14 @@ var DeclareCtr = Ctr{
|
||||
flagslice = Slice{}
|
||||
if flags != nil {
|
||||
for _, v := range flags {
|
||||
if v == "0" {
|
||||
continue
|
||||
}
|
||||
flagslice = append(flagslice, v)
|
||||
}
|
||||
|
||||
}
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "industrial_design_center_flag": flagslice}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "industrial_design_center_flag": flagslice}})
|
||||
for _, v1 := range dtag {
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
declares[v1.GetCeilInt64("declare_id")] = v1
|
||||
@ -265,7 +291,7 @@ var DeclareCtr = Ctr{
|
||||
|
||||
//有无授权发明专利:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("invention_patent_flag")) > 0 {
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "invention_patent_flag": ObjToInt(that.Req.FormValue("invention_patent_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "invention_patent_flag": ObjToInt(that.Req.FormValue("invention_patent_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -278,7 +304,7 @@ var DeclareCtr = Ctr{
|
||||
|
||||
//有无国际科技合作:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("international_cooperation_flag")) > 0 {
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "international_cooperation_flag": ObjToInt(that.Req.FormValue("international_cooperation_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "international_cooperation_flag": ObjToInt(that.Req.FormValue("international_cooperation_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -290,7 +316,7 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
//上年度有无固定资产投入:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("investment_fixed_assets_flag")) > 0 {
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "investment_fixed_assets_flag": ObjToInt(that.Req.FormValue("investment_fixed_assets_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "investment_fixed_assets_flag": ObjToInt(that.Req.FormValue("investment_fixed_assets_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -301,7 +327,7 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
}
|
||||
//高层次人才情况:0-否,1-3个及以上博士-1,2-1个及以上博士-2,3-知名企业中高管1个及以上
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "high_level_talents_flag": ObjToInt(that.Req.FormValue("high_level_talents_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "high_level_talents_flag": ObjToInt(that.Req.FormValue("high_level_talents_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -312,7 +338,7 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
//企业股东或成员是否有国内外高校或科研院在编、全职人员:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("shareholders_flag")) > 0 {
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "shareholders_flag": ObjToInt(that.Req.FormValue("shareholders_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "shareholders_flag": ObjToInt(that.Req.FormValue("shareholders_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -324,7 +350,7 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
//企业有无从外地引进博士学历人才:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("nonlocal_dr_flag")) > 0 {
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "nonlocal_dr_flag": ObjToInt(that.Req.FormValue("nonlocal_dr_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "nonlocal_dr_flag": ObjToInt(that.Req.FormValue("nonlocal_dr_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -336,7 +362,7 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
//上年度是否有贷款/融资或未来有贷款/融资计划:0-否,1-是
|
||||
if ObjToInt(that.Req.FormValue("loan_flag")) > 0 {
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "loan_flag": ObjToInt(that.Req.FormValue("loan_flag"))}})
|
||||
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "loan_flag": ObjToInt(that.Req.FormValue("loan_flag"))}})
|
||||
for _, v1 := range dtag {
|
||||
|
||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||
@ -353,15 +379,46 @@ var DeclareCtr = Ctr{
|
||||
}
|
||||
//获取到排序后的数据
|
||||
sort.Sort(px)
|
||||
res := Slice{}
|
||||
var res []Map
|
||||
for _, v := range px {
|
||||
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})
|
||||
article["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,tag,status", Map{"id": id})
|
||||
article["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,status", Map{"id": id})
|
||||
|
||||
res = append(res, article)
|
||||
}
|
||||
minMoney := float64(0)
|
||||
maxMoney := float64(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").GetFloat64("money_scope_max") > maxMoney {
|
||||
maxMoney = v.GetMap("declare").GetFloat64("money_scope_max")
|
||||
}
|
||||
}
|
||||
}
|
||||
seData := Map{
|
||||
"user_id": that.Session("user_id").Data,
|
||||
"search_company_name": companyName,
|
||||
"policy_match_count": len(res),
|
||||
"json_data": ObjToStr(company),
|
||||
"create_time[#]": "now()",
|
||||
"modify_time[#]": "now()",
|
||||
"del_flag": 0,
|
||||
}
|
||||
if maxMoney != minMoney {
|
||||
seData["money_scope"] = ObjToStr(minMoney) + "-" + ObjToStr(maxMoney) + "万元"
|
||||
} else if maxMoney == 0 {
|
||||
seData["money_scope"] = ""
|
||||
} else {
|
||||
seData["money_scope"] = ObjToStr(maxMoney) + "万元"
|
||||
}
|
||||
|
||||
//匹配记录存储
|
||||
that.Db.Insert("search_record", seData)
|
||||
|
||||
that.Display(0, res)
|
||||
|
||||
|
@ -205,7 +205,7 @@ var FavoriteCtr = Ctr{
|
||||
}
|
||||
|
||||
if len(data) > 1 {
|
||||
data = Map{"AND": data}
|
||||
data = Map{"AND": data, "ORDER": "modify_time DESC"}
|
||||
}
|
||||
|
||||
count := that.Db.Count("favorite", data)
|
||||
@ -217,11 +217,11 @@ var FavoriteCtr = Ctr{
|
||||
v["policy"] = that.Db.Get("policy", "id,tag", Map{"id": v.GetCeilInt64("policy_id")})
|
||||
}
|
||||
if v.GetCeilInt64("declare_id") != 0 {
|
||||
v["declare"] = that.Db.Get("declare", "id,money_scope_min,money_scope_max,tag,status", Map{"id": v.GetCeilInt64("policy_id")})
|
||||
v["declare"] = that.Db.Get("declare", "id,money_scope_min,money_scope_max,status", Map{"id": v.GetCeilInt64("declare_id")})
|
||||
}
|
||||
|
||||
if v.GetCeilInt64("notify_id") != 0 {
|
||||
v["notify"] = that.Db.Get("notify", "id,tag", Map{"id": v.GetCeilInt64("policy_id")})
|
||||
v["notify"] = that.Db.Get("notify", "id,tag", Map{"id": v.GetCeilInt64("notify_id")})
|
||||
}
|
||||
|
||||
if v.GetCeilInt64("article_id") != 0 {
|
||||
@ -231,7 +231,7 @@ var FavoriteCtr = Ctr{
|
||||
|
||||
if v.GetCeilInt64("provider_id") != 0 {
|
||||
v["provider"] = that.Db.Get("provider", "id,name,level,discount,avatar,title,description,"+
|
||||
"click_num_base+click_num AS click_num,handle_num_base+handle_num AS handle_num,favorite_num_base+favorite_num AS favorite_num,modify_time", Map{"id": v.GetCeilInt64("policy_id")})
|
||||
"click_num_base+click_num AS click_num,handle_num_base+handle_num AS handle_num,favorite_num_base+favorite_num AS favorite_num,modify_time", Map{"id": v.GetCeilInt64("provider_id")})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ var Project = Proj{
|
||||
"order": OrderCtr,
|
||||
"policy": PolicyCtr,
|
||||
"provider": ProviderCtr,
|
||||
"search_record": SearchRecordCtr,
|
||||
"sms": Sms,
|
||||
"tag": TagCtr,
|
||||
"user": UserCtr,
|
||||
|
@ -133,7 +133,7 @@ var MattersCtr = Ctr{
|
||||
}
|
||||
|
||||
if tp != "" {
|
||||
data["type"] = ObjToInt("tp")
|
||||
data["type"] = ObjToInt(tp)
|
||||
}
|
||||
|
||||
startTime := that.Req.FormValue("starttime")
|
||||
@ -147,7 +147,7 @@ var MattersCtr = Ctr{
|
||||
}
|
||||
|
||||
if len(data) > 1 {
|
||||
data = Map{"AND": data}
|
||||
data = Map{"AND": data, "ORDER": "modify_time DESC"}
|
||||
}
|
||||
|
||||
count := that.Db.Count("matters", data)
|
||||
|
@ -32,13 +32,6 @@ var OrderCtr = Ctr{
|
||||
|
||||
tp := that.Req.FormValue("type")
|
||||
|
||||
//是否以前已经创建了该服务商的订单,如果创建了则直接跳转到订单详情中去
|
||||
oldOrder := that.Db.Get("order", "id", Map{"AND": Map{"provider_id": providerId, "user_id": that.Session("user_id").Data, "del_flag": 0, "status": 0}})
|
||||
if oldOrder != nil {
|
||||
that.Display(0, oldOrder.GetCeilInt64("id"))
|
||||
return
|
||||
}
|
||||
|
||||
//新建流程
|
||||
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").Data})
|
||||
|
||||
@ -59,6 +52,25 @@ var OrderCtr = Ctr{
|
||||
return
|
||||
}
|
||||
|
||||
//是否以前已经创建了该服务商的订单,如果创建了则直接跳转到订单详情中去
|
||||
oldOrder := that.Db.Get("order", "id", Map{"AND": Map{"provider_id": providerId, "user_id": that.Session("user_id").Data, "del_flag": 0, "status": 0}})
|
||||
if oldOrder != nil {
|
||||
orderRecord := Map{
|
||||
"order_id": oldOrder.GetCeilInt64("id"),
|
||||
"user_id": user.GetCeilInt64("id"),
|
||||
"remarks": user.GetString("nickname") + "向“" + provider.GetString("name") + "”服务商再次发起了订单请求",
|
||||
"create_time[#]": "now()",
|
||||
"modify_time[#]": "now()",
|
||||
"del_flag": 0,
|
||||
}
|
||||
|
||||
orderRecord["id"] = that.Db.Insert("order_record", orderRecord)
|
||||
that.Db.Update("order", Map{"order_record_id": orderRecord.GetCeilInt64("id"), "modify_time[#]": "now()"}, Map{"id": oldOrder.GetCeilInt64("id")})
|
||||
|
||||
that.Display(0, oldOrder.GetCeilInt64("id"))
|
||||
return
|
||||
}
|
||||
|
||||
data := Map{
|
||||
"name": "购买“" + provider.GetString("title") + "”服务",
|
||||
"sn": "SN" + time.Now().Format("20060102150405") + getSn(),
|
||||
@ -97,7 +109,7 @@ var OrderCtr = Ctr{
|
||||
"del_flag": 0,
|
||||
}
|
||||
|
||||
orderRecord["id"] = that.Db.Insert("order_record", data)
|
||||
orderRecord["id"] = that.Db.Insert("order_record", orderRecord)
|
||||
|
||||
if orderRecord.GetCeilInt64("id") == 0 {
|
||||
that.Display(4, "无法生成订单记录!")
|
||||
@ -121,14 +133,14 @@ var OrderCtr = Ctr{
|
||||
return
|
||||
}
|
||||
|
||||
res := that.Db.Get("order", "*", Map{"id": id})
|
||||
res := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "user_id": that.Session("user_id").Data}})
|
||||
|
||||
if res == nil {
|
||||
that.Display(4, "找不到对应订单")
|
||||
return
|
||||
}
|
||||
if res.GetCeilInt("provider_id") > 0 {
|
||||
res["provider"] = that.Db.Get("provider", "name,title", Map{"id": res.GetCeilInt("provider_id")})
|
||||
res["provider"] = that.Db.Get("provider", "name,title,phone", Map{"id": res.GetCeilInt("provider_id")})
|
||||
}
|
||||
|
||||
res["order_record"] = that.Db.Select("order_record", "remarks,modify_time", Map{"order_id": res.GetCeilInt("id"), "ORDER": "modify_time DESC"})
|
||||
@ -154,7 +166,7 @@ var OrderCtr = Ctr{
|
||||
pageSize = 20
|
||||
}
|
||||
|
||||
data := Map{"del_flag": 0}
|
||||
data := Map{"del_flag": 0, "user_id": that.Session("user_id").Data}
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
if keywords != "" {
|
||||
data["OR"] = Map{"sn[~]": keywords, "company_name[~]": keywords, "name[~]": keywords}
|
||||
@ -171,7 +183,7 @@ var OrderCtr = Ctr{
|
||||
}
|
||||
|
||||
if len(data) > 1 {
|
||||
data = Map{"AND": data}
|
||||
data = Map{"AND": data, "ORDER": "modify_time DESC"}
|
||||
}
|
||||
|
||||
count := that.Db.Count("order", data)
|
||||
|
@ -79,7 +79,7 @@ var ProviderCtr = Ctr{
|
||||
}
|
||||
|
||||
if len(data) > 1 {
|
||||
data = Map{"AND": data}
|
||||
data = Map{"AND": data, "ORDER": "id DESC"}
|
||||
}
|
||||
|
||||
count := that.Db.Count("provider", data)
|
||||
|
49
example/app/search_record.go
Normal file
49
example/app/search_record.go
Normal file
@ -0,0 +1,49 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var SearchRecordCtr = Ctr{
|
||||
|
||||
"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}
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
if keywords != "" {
|
||||
data["search_company_name[~]"] = keywords
|
||||
}
|
||||
|
||||
startTime := that.Req.FormValue("starttime")
|
||||
finishTime := that.Req.FormValue("finishtime")
|
||||
|
||||
if startTime != "" {
|
||||
data["create_time[>=]"] = startTime
|
||||
}
|
||||
if finishTime != "" {
|
||||
data["create_time[<=]"] = finishTime
|
||||
}
|
||||
|
||||
if len(data) > 1 {
|
||||
data = Map{"AND": data, "ORDER": "create_time DESC"}
|
||||
}
|
||||
|
||||
count := that.Db.Count("search_record", data)
|
||||
|
||||
res := that.Db.Page(page, pageSize).PageSelect("search_record", "id,search_company_name,policy_match_count,money_scope,create_time", data)
|
||||
|
||||
that.Display(0, Map{"total": count, "data": res})
|
||||
|
||||
},
|
||||
}
|
30
example/app/vip_order.go
Normal file
30
example/app/vip_order.go
Normal file
@ -0,0 +1,30 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
)
|
||||
|
||||
var VipOrderCtr = Ctr{
|
||||
//创建V订单
|
||||
"create": func(that *Context) {
|
||||
if that.Session("user_id").Data == nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
phone := that.Req.FormValue("phone")
|
||||
companyName := that.Req.FormValue("company_name")
|
||||
if len(phone) != 11 || len(companyName) < 4 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
err := auth(that, phone, companyName)
|
||||
if err != nil {
|
||||
that.Display(3, err)
|
||||
return
|
||||
}
|
||||
|
||||
//that.Display(0, Map{"total": count, "data": res})
|
||||
},
|
||||
}
|
@ -55,5 +55,9 @@
|
||||
"wechatAppSecret": "4d793683ca915264663a9c9a33530c3c",
|
||||
"wechatMiniAppID": "wx1c795e883b5b54c4",
|
||||
"wechatMiniAppSecret": "d2bec12d1fa4d8b5714ccbed1c0671e4",
|
||||
"wechatPayMApiV3Key": "dh33tyagd1623623GDYGGDhe1d9dh171",
|
||||
"wechatPayMCHID": "1624888906",
|
||||
"wechatPayPrivateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC1vs3i/4sozxsK\noiS2S95rl+csLXQDugg23bcAVzXr7ZeTM/h81sCwraQDMnAJ/V3n7LxFAZeaFwLb\nyrkQ3lv4IEtWVgjVUkjkhvKGWcAp16Q/grOpxWmmn+VlW5ZGwQQ4DL4sC6BeEyxu\nUdtZ7UVc9lqsQX01R0oiegItJGPMMXNgeLFDEeoAwyIQcL0VG2bND7qrEVeQkLTj\nFm9ZkSb0LySPkSgqxMlSpiX1MS+wWWIHpq91CvdVHNowaGFA7ajU3RztbFAuxdpl\ng9RIocbrY1QwGXouQTEOUI2KZaES9rAa2lD6oWom4mRYiQ1oNO12XlUTcKsr84P5\nTq50dOYFAgMBAAECggEAQUns/mncnOlhhn1fANnaaf5kvlsJvTj8MHGPhyDNLxbo\nB6p4zqf7Cr0mGTvqQbxyGpnRvFxpEKLJlRmLSAMJOOapCbfYboGjy+yqfRcK0D02\nNNaIIinX3VK9fp7bKkm2cUgqnPoEPydWI79mNDTnYRDi29Se3R/iAuafl4XmD/js\nOKWG5tlXEatZ+gDbhnug4hp3xEGm4pbTS1HedV7HgYiKpxAT9uc/YmiHelZUUqlG\nwa1Nda2J88pzCSZX6TsRyY9UF/sjorxSNZGfj+5waeYMccj0Cx4uEQYgBv5tm+I+\nFTRgo/riM5gT9oRTnuNuzUrNwUNLyUsldvdQdlheNQKBgQDqwhrW52q3xClFLXR4\nHu9cTPt/p96MYE+xBllO/M9VFcG/hT++9R9l26+o26Lu+iIF5euDQiYSyURniGim\nWfV0I2q8HufhPLJBamvxRPI0V8LHwbY7c6HKnRR3eDAWAVYIcmsV4RLS67bsgtnr\nCgaFUDHXnpPKjxp1b4M5K3GqxwKBgQDGMLgAQn0a3nZwquPD4D+6tjy5xTxDX4Op\nULHBQheX0lBAR9Kcurzy4ca+T5xsyHd6SPwQxobRPei/3TBmc18J1T3nxJkTbEEP\nqy8k7MOWW2es3ou4CRL5lVKPx4YDWb5iT7X3Ue55JjPFAoj6FBOHxdvRQnDYsLFy\nSuSHPc280wKBgQCqfvCZNZcnAbtrd3jIKMd0hKB/dP7HesdF7TN9j1RRGi0NmIvU\ndxgnlOa9v05VO6rsF7D1MlyOdkhM3SAL+PewMmy5VcTYq4lWwyDEKGuzoi1fgIuG\nIBPYID8WCV77DFtcZSTqzf0q3HCM0vfLoQtdVQHt9Ein60ivE579LVUvTwKBgFid\nefgrwnJcG8serb5sKzKZvyc1CE/7igwPl5sYqSHqGJXVR1dqq4dR6iI3yHJfZASa\nU5JQogE21DXNeZGlbk4gOZDCt8sWcTTHTsoMzxsQfZeu3fwImqJb4NGG3eXrn5On\nnm4aBS3IJgelrYdbqKvhjPrQ4VISFxVKZUoPGUmfAoGARZbtbyl3s8cAExWe9dK6\nyWdkA3M2wR4n623W13rTQDc3D7p/hmlgB2x8it88m+580326G4qgwdUbG93EW1WQ\nahbkkcmdxzHgPVJdsyx22fR0TkeT1gjMpoSh4k3HOsbZE4EvlI459yE9fTSLBq2A\nFzGjYRpBTlRyrsSEhyVg4G0=\n-----END PRIVATE KEY-----",
|
||||
"wechatPaySerialNo": "7A92D2D26D212D6BF934BDB10D547274807C3DDB",
|
||||
"wxFilePath": "wxfile/2006/01/02/"
|
||||
}
|
@ -26,6 +26,11 @@ func main() {
|
||||
wechat.H5Program.Init(appIns.Config.GetString("wechatAppID"), appIns.Config.GetString("wechatAppSecret"))
|
||||
//初始化小程序配置
|
||||
wechat.MiniProgram.Init(appIns.Config.GetString("wechatMiniAppID"), appIns.Config.GetString("wechatMiniAppSecret"))
|
||||
//初始化小程序及公众号支付配置
|
||||
wechat.WxPay.Init(appIns.Config.GetString("wechatPayMCHID"),
|
||||
appIns.Config.GetString("wechatPaySerialNo"),
|
||||
appIns.Config.GetString("wechatPayMApiV3Key"),
|
||||
appIns.Config.GetString("wechatPayPrivateKey"))
|
||||
|
||||
//用户侧访问前设置
|
||||
appIns.SetConnectListener(func(that *Context) (isFinished bool) {
|
||||
|
@ -30,10 +30,10 @@ var MattersCtr = Ctr{
|
||||
return
|
||||
}
|
||||
|
||||
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")})
|
||||
|
||||
res["user"] = that.Db.Get("user", "id,name,nickname,company_id", Map{"user_id": res.GetCeilInt64("user_id")})
|
||||
if res.GetMap("user") != nil && res.GetMap("user").GetCeilInt64("company_id") != 0 {
|
||||
res["company"] = that.Db.Get("company", "id,name", Map{"company_id": res.GetMap("user").GetCeilInt64("company_id")})
|
||||
}
|
||||
that.Display(0, res)
|
||||
},
|
||||
|
||||
@ -94,6 +94,15 @@ var MattersCtr = Ctr{
|
||||
|
||||
res := that.Db.Page(page, pageSize).PageSelect("matters", "*", data)
|
||||
|
||||
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")})
|
||||
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")})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
that.Display(0, Map{"total": count, "data": res})
|
||||
},
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ var OrderCtr = Ctr{
|
||||
pageSize = 20
|
||||
}
|
||||
|
||||
data := Map{"del_flag": 0}
|
||||
data := Map{"del_flag": 0, "salesman_id": that.Session("salesman_id").Data}
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
if keywords != "" {
|
||||
data["OR"] = Map{"sn[~]": keywords, "name[~]": keywords}
|
||||
|
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.16
|
||||
|
||||
require (
|
||||
github.com/garyburd/redigo v1.6.3
|
||||
github.com/go-pay/gopay v1.5.78
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/mattn/go-sqlite3 v1.14.12
|
||||
github.com/silenceper/wechat/v2 v2.1.2
|
||||
|
10
go.sum
10
go.sum
@ -8,6 +8,8 @@ github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/garyburd/redigo v1.6.3 h1:HCeeRluvAgMusMomi1+6Y5dmFOdYV/JzoRrrbFlkGIc=
|
||||
github.com/garyburd/redigo v1.6.3/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw=
|
||||
github.com/go-pay/gopay v1.5.78 h1:wIHp8g/jK0ik5bZo2MWt3jAQsktT3nkdXZxlRZvljko=
|
||||
github.com/go-pay/gopay v1.5.78/go.mod h1:M6Nlk2VdZHCbWphOw3rtbnz4SiOk6Xvxg6mxwDfg+Ps=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc=
|
||||
@ -39,20 +41,26 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364/go.mod
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364 h1:kbor60vo37v7Hu+i17gooox9Rw281fVHNna8zwtDG1w=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364/go.mod h1:LeIUBOLhc+Y5YCEpZrULPD9lgoXXV4/EmIcoEvmHz9c=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 h1:tkVvjkPTB7pnW3jnid7kNyAMPVWllTNOf/qKDze4p9o=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
Loading…
Reference in New Issue
Block a user