基础整理
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var CompanyCtr = Ctr{
|
||||
"info": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
id := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if id == 0 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
res := that.Db.Get("company", "*", Map{"id": id})
|
||||
if res == nil {
|
||||
that.Display(4, "找不到企业")
|
||||
return
|
||||
}
|
||||
//先不做限制
|
||||
//if res.GetCeilInt("salesman_id")!=that.Session("salesman_id").ToCeilInt(){
|
||||
// that.Display(4,"不是你的企业")
|
||||
// return
|
||||
//}
|
||||
|
||||
res["technology_center_flag"] = ObjToSlice(res["technology_center_flag"])
|
||||
res["engineering_center_flag"] = ObjToSlice(res["engineering_center_flag"])
|
||||
res["engineering_laboratory_flag"] = ObjToSlice(res["engineering_laboratory_flag"])
|
||||
res["key_laboratory_flag"] = ObjToSlice(res["key_laboratory_flag"])
|
||||
res["industrial_design_center_flag"] = ObjToSlice(res["industrial_design_center_flag"])
|
||||
|
||||
that.Display(0, res)
|
||||
},
|
||||
"edit": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
id := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if id == 0 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
company := that.Db.Get("company", "*", Map{"id": id})
|
||||
delete(company, "id")
|
||||
delete(company, "salesman_id")
|
||||
delete(company, "provider_id")
|
||||
delete(company, "user_id")
|
||||
delete(company, "del_flag")
|
||||
delete(company, "state")
|
||||
delete(company, "create_time")
|
||||
delete(company, "modify_time")
|
||||
data := Map{}
|
||||
for k, _ := range company {
|
||||
if that.Req.Form[k] != nil {
|
||||
if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
|
||||
data[k] = ObjToStr(that.Req.Form[k])
|
||||
} else {
|
||||
data[k] = that.Req.FormValue(k)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
that.Db.Update("company", company, Map{"id": id})
|
||||
|
||||
that.Display(0, "更新成功")
|
||||
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Project 管理端项目
|
||||
var Project = Proj{
|
||||
"salesman": Salesman,
|
||||
"wechat": Wechat,
|
||||
}
|
||||
|
||||
//生成随机码的6位md5
|
||||
func getSn() string {
|
||||
x := Rand(8)
|
||||
return Substr(Md5(ObjToStr(int64(x)+time.Now().UnixNano()+int64(Rand(6)))), 0, 6)
|
||||
}
|
||||
|
||||
//生成随机码的4位随机数
|
||||
func getCode() string {
|
||||
//res := ""
|
||||
//for i := 0; i < 4; i++ {
|
||||
res := ObjToStr(RandX(1000, 9999))
|
||||
//}
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var MattersCtr = Ctr{
|
||||
|
||||
"info": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
id := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if id == 0 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
res := that.Db.Get("matters", "*", Map{"id": id})
|
||||
if res == nil {
|
||||
that.Display(4, "找不到事项")
|
||||
return
|
||||
}
|
||||
if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
|
||||
that.Display(4, "不是你的事项")
|
||||
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")})
|
||||
|
||||
that.Display(0, res)
|
||||
},
|
||||
|
||||
//用户微信公众号或者小程序登录
|
||||
"search": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
userId := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
page := ObjToInt(that.Req.FormValue("page"))
|
||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
||||
|
||||
tp := that.Req.FormValue("type")
|
||||
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
if pageSize <= 0 {
|
||||
pageSize = 20
|
||||
}
|
||||
|
||||
data := Map{"del_flag": 0, "salesman_id": that.Session("salesman_id").Data}
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
if keywords != "" {
|
||||
data["OR"] = Map{"title[~]": keywords, "description[~]": keywords, "content[~]": keywords}
|
||||
}
|
||||
|
||||
if userId != 0 {
|
||||
|
||||
user := that.Db.Get("user", "id", Map{"AND": Map{"id": userId, "salesman_id": that.Session("salesman_id").Data}})
|
||||
if user != nil {
|
||||
data["user_id"] = userId
|
||||
}
|
||||
}
|
||||
|
||||
if tp != "" {
|
||||
data["type"] = ObjToInt("tp")
|
||||
}
|
||||
|
||||
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("matters", data)
|
||||
|
||||
res := that.Db.Page(page, pageSize).PageSelect("matters", "*", data)
|
||||
|
||||
that.Display(0, Map{"total": count, "data": res})
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var OrderCtr = Ctr{
|
||||
"info": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
id := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if id == 0 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
res := that.Db.Get("order", "*", Map{"id": 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("user_id") > 0 {
|
||||
res["user"] = that.Db.Get("user", "name,nickname,avatar", Map{"id": res.GetCeilInt("user_id")})
|
||||
}
|
||||
|
||||
res["order_record"] = that.Db.Select("order_record", "remarks,modify_time", Map{"order_id": res.GetCeilInt("id"), "ORDER": "modify_time DESC"})
|
||||
|
||||
that.Display(0, res)
|
||||
},
|
||||
"create_order_record": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
id := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if id == 0 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
remarks := that.Req.FormValue("remarks")
|
||||
|
||||
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
|
||||
if salesman == nil {
|
||||
that.Display(2, "登录错误")
|
||||
return
|
||||
}
|
||||
|
||||
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "salesman_id": that.Session("salesman_id").Data}})
|
||||
if order == nil {
|
||||
that.Display(4, "不是属于你的订单")
|
||||
return
|
||||
}
|
||||
|
||||
if order.GetCeilInt("status") != 0 {
|
||||
that.Display(4, "已完结订单,不可操作")
|
||||
return
|
||||
}
|
||||
|
||||
orderRecordId := that.Db.Insert("order_record", Map{
|
||||
"order_id": id,
|
||||
"user_id": order.GetCeilInt64("user_id"),
|
||||
"remarks": salesman.GetString("name") + ":" + remarks,
|
||||
"salesman_id": order.GetCeilInt64("salesman_id"),
|
||||
"create_time[#]": "now()",
|
||||
"modify_time[#]": "now()",
|
||||
"del_flag": 0,
|
||||
})
|
||||
|
||||
that.Db.Update("order", Map{"order_record_id": orderRecordId}, Map{"id": id})
|
||||
|
||||
that.Display(0, "新增订单记录成功")
|
||||
|
||||
},
|
||||
"edit": func(that *Context) {
|
||||
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
id := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if id == 0 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
|
||||
if salesman == nil {
|
||||
that.Display(2, "登录错误")
|
||||
return
|
||||
}
|
||||
|
||||
policyDeclareFlag := ObjToInt(that.Req.FormValue("policy_declare_flag"))
|
||||
declareId := ObjToInt(that.Req.FormValue("declare_id"))
|
||||
|
||||
intellectualPropertyFlag := ObjToInt(that.Req.FormValue("intellectual_property_flag"))
|
||||
intellectualPropertyCount := ObjToInt(that.Req.FormValue("intellectual_property_count"))
|
||||
taxOnsultingFlag := ObjToInt(that.Req.FormValue("tax_onsulting_flag"))
|
||||
|
||||
lawFlag := ObjToInt(that.Req.FormValue("law_flag"))
|
||||
status := ObjToInt(that.Req.FormValue("status"))
|
||||
|
||||
data := Map{
|
||||
"policy_declare_flag": policyDeclareFlag,
|
||||
"intellectual_property_flag": intellectualPropertyFlag,
|
||||
"intellectual_property_count": intellectualPropertyCount,
|
||||
"tax_onsulting_flag": taxOnsultingFlag,
|
||||
"law_flag": lawFlag,
|
||||
"status": status,
|
||||
"modify_time[#]": "now()",
|
||||
}
|
||||
|
||||
if declareId != 0 {
|
||||
data["declare_id"] = declareId
|
||||
}
|
||||
|
||||
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "salesman_id": that.Session("salesman_id").Data}})
|
||||
if order == nil {
|
||||
that.Display(4, "不是属于你的订单")
|
||||
return
|
||||
}
|
||||
|
||||
if order.GetCeilInt("status") != 0 {
|
||||
that.Display(4, "已完结订单,不可操作")
|
||||
return
|
||||
}
|
||||
|
||||
data["order_record_id"] = that.Db.Insert("order_record", Map{
|
||||
"order_id": id,
|
||||
"user_id": order.GetCeilInt64("user_id"),
|
||||
"remarks": salesman.GetString("name") + "变更了订单服务内容",
|
||||
"salesman_id": order.GetCeilInt64("salesman_id"),
|
||||
"create_time[#]": "now()",
|
||||
"modify_time[#]": "now()",
|
||||
"del_flag": 0,
|
||||
})
|
||||
re := that.Db.Update("order", data, Map{"id": id})
|
||||
if re == 0 {
|
||||
that.Display(4, "变更订单内容失败")
|
||||
return
|
||||
}
|
||||
|
||||
that.Display(0, "变更订单内容成功")
|
||||
},
|
||||
//用户微信公众号或者小程序登录
|
||||
"search": func(that *Context) {
|
||||
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
userId := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
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["OR"] = Map{"sn[~]": keywords, "name[~]": keywords}
|
||||
}
|
||||
|
||||
if userId != 0 {
|
||||
|
||||
user := that.Db.Get("user", "id", Map{"AND": Map{"id": userId, "salesman_id": that.Session("salesman_id").Data}})
|
||||
if user != nil {
|
||||
data["user_id"] = userId
|
||||
}
|
||||
}
|
||||
|
||||
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("order", data)
|
||||
|
||||
res := that.Db.Page(page, pageSize).PageSelect("order", "*", data)
|
||||
for _, v := range res {
|
||||
|
||||
//if v.GetCeilInt("policy_id")>0{
|
||||
// v["policy"]=that.Db.Get("policy","id,tag",Map{"id":v.GetCeilInt("policy_id")})
|
||||
//}
|
||||
if v.GetCeilInt("user_id") > 0 {
|
||||
v["user"] = that.Db.Get("user", "name,nickname,avatar", Map{"id": v.GetCeilInt("user_id")})
|
||||
}
|
||||
if v.GetCeilInt("order_record_id") > 0 {
|
||||
v["order_record"] = that.Db.Get("order_record", "remarks,modify_time", Map{"id": v.GetCeilInt("order_record_id")})
|
||||
}
|
||||
}
|
||||
|
||||
that.Display(0, Map{"total": count, "data": res})
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var Salesman = Ctr{
|
||||
"info": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
|
||||
if salesman == nil {
|
||||
that.Display(4, "找不到该业务员")
|
||||
return
|
||||
}
|
||||
salesman["user"] = that.Db.Count("user", Map{"AND": Map{"salesman_id": that.Session("salesman_id").Data, "del_flag": 0}})
|
||||
salesman["matters"] = that.Db.Count("matters", Map{"AND": Map{"salesman_id": that.Session("salesman_id").Data, "del_flag": 0}})
|
||||
|
||||
salesman["admin"] = that.Db.Get("admin", "id,name,avatar", Map{"id": salesman.GetCeilInt64("admin_id")})
|
||||
salesman["provider"] = that.Db.Get("provider", "*", Map{"id": salesman.GetCeilInt64("provider_id")})
|
||||
if salesman["provider"] != nil {
|
||||
salesman["provider_salesman"] = that.Db.Get("salesman", "id,nickname,name,avatar", Map{"id": salesman.GetMap("provider").GetCeilInt64("salesman_id")})
|
||||
}
|
||||
|
||||
that.Display(0, salesman)
|
||||
},
|
||||
|
||||
"search": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
|
||||
if salesman == nil {
|
||||
that.Display(4, "找不到该业务员")
|
||||
return
|
||||
}
|
||||
|
||||
provider := that.Db.Get("provider", "*", Map{"id": salesman.GetCeilInt64("provider_id")})
|
||||
|
||||
if provider.GetCeilInt("salesman_id") != salesman.GetCeilInt("id") {
|
||||
that.Display(0, Slice{})
|
||||
return
|
||||
}
|
||||
|
||||
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, "provider_id": salesman.GetCeilInt64("provider_id")}
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
if keywords != "" {
|
||||
data["OR"] = Map{"name[~]": keywords, "nickname[~]": keywords, "phone[~]": keywords}
|
||||
}
|
||||
|
||||
startTime := that.Req.FormValue("starttime")
|
||||
finishTime := that.Req.FormValue("finishtime")
|
||||
|
||||
if startTime != "" {
|
||||
data["modifye_time[>=]"] = startTime
|
||||
}
|
||||
if finishTime != "" {
|
||||
data["modifye_time[<=]"] = finishTime
|
||||
}
|
||||
|
||||
count := that.Db.Count("salesman", data)
|
||||
|
||||
res := that.Db.Page(page, pageSize).PageSelect("salesman", "id,name,nickname,avatar", data)
|
||||
|
||||
that.Display(0, Map{"total": count, "data": res})
|
||||
},
|
||||
//用户微信公众号或者小程序登录
|
||||
"login": func(that *Context) {
|
||||
|
||||
code := that.Req.FormValue("code")
|
||||
phone := that.Req.FormValue("phone")
|
||||
|
||||
if phone != that.Session("phone").ToStr() && code != that.Session("code").ToStr() {
|
||||
that.Display(3, "手机号或者验证码错误")
|
||||
return
|
||||
}
|
||||
|
||||
if that.Session("wechat_id").Data == nil {
|
||||
that.Display(2, "还未登录")
|
||||
return
|
||||
}
|
||||
|
||||
wechat := that.Db.Get("wechat", "*", Map{"id": that.Session("wechat_id").ToCeilInt()})
|
||||
|
||||
salesman := that.Db.Get("salesman", "*", Map{"phone": phone})
|
||||
|
||||
if salesman == nil {
|
||||
that.Display(3, "找不到企服商")
|
||||
return
|
||||
}
|
||||
|
||||
if wechat == nil {
|
||||
that.Display(2, "还未绑定微信")
|
||||
return
|
||||
}
|
||||
|
||||
//有用户直接返回
|
||||
if wechat.GetCeilInt("salesman_id") != 0 && wechat.GetCeilInt64("salesman_id") != salesman.GetInt64("id") {
|
||||
that.Display(5, "你已经绑定了其他商户")
|
||||
return
|
||||
}
|
||||
|
||||
that.Db.Update("wechat", Map{"salesman_id": salesman.GetCeilInt64("id")}, Map{"id": wechat.GetInt64("id")})
|
||||
|
||||
wechat["salesman_id"] = salesman.GetCeilInt64("id")
|
||||
that.Session("salesman_id", salesman.GetCeilInt64("id"))
|
||||
that.Display(0, "登录成功!")
|
||||
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
"code.hoteas.com/golang/hotime/dri/ddsms"
|
||||
)
|
||||
|
||||
var Sms = Ctr{
|
||||
//只允许微信验证过的或者登录成功的发送短信
|
||||
"send": func(that *Context) {
|
||||
|
||||
phone := that.Req.FormValue("phone")
|
||||
if len(phone) < 11 {
|
||||
that.Display(3, "手机号格式错误")
|
||||
return
|
||||
}
|
||||
|
||||
if that.Session("wechat_id").Data == nil && that.Session("salesman_id").Data == nil {
|
||||
that.Display(2, "没有登录不可发送短信")
|
||||
return
|
||||
}
|
||||
|
||||
code := getCode()
|
||||
that.Session("phone", phone)
|
||||
that.Session("code", code)
|
||||
|
||||
ddsms.DDY.SendYZM(phone, that.Config.GetString("smsLogin"), map[string]string{"code": code})
|
||||
|
||||
that.Display(0, "发送成功")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var UserCtr = Ctr{
|
||||
//用户微信公众号或者小程序登录
|
||||
"info": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
userId := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if userId == 0 {
|
||||
that.Display(3, "参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").ToCeilInt()})
|
||||
if user == nil {
|
||||
that.Display(4, "获取个人信息失败")
|
||||
return
|
||||
}
|
||||
|
||||
delete(user, "password")
|
||||
|
||||
that.Display(0, user)
|
||||
},
|
||||
|
||||
"edit": func(that *Context) {
|
||||
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
userId := ObjToInt(that.Req.FormValue("id"))
|
||||
|
||||
if userId == 0 {
|
||||
that.Display(3, "参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
name := that.Req.FormValue("name")
|
||||
nickname := that.Req.FormValue("nickname")
|
||||
sex := that.Req.FormValue("sex")
|
||||
email := that.Req.FormValue("email")
|
||||
avatar := that.Req.FormValue("avatar")
|
||||
address := that.Req.FormValue("address")
|
||||
phone := that.Req.FormValue("phone") //如果更换手机号则要有新的短信验证码
|
||||
|
||||
data := Map{"modify_time[#]": "now()"}
|
||||
if name != "" {
|
||||
data["name"] = name
|
||||
}
|
||||
if nickname != "" {
|
||||
data["nickname"] = nickname
|
||||
}
|
||||
if sex != "" {
|
||||
data["sex"] = sex
|
||||
}
|
||||
if email != "" {
|
||||
data["email"] = email
|
||||
}
|
||||
if avatar != "" {
|
||||
data["avatar"] = avatar
|
||||
}
|
||||
if address != "" {
|
||||
data["address"] = address
|
||||
}
|
||||
if phone != "" {
|
||||
|
||||
data["phone"] = phone
|
||||
}
|
||||
|
||||
re := that.Db.Update("user", data, Map{"id": userId})
|
||||
if re == 0 {
|
||||
that.Display(4, "更新失败")
|
||||
return
|
||||
}
|
||||
|
||||
that.Display(4, "修改成功")
|
||||
},
|
||||
|
||||
"search": func(that *Context) {
|
||||
if that.Session("salesman_id").Data != nil {
|
||||
that.Display(2, "没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
page := ObjToInt(that.Req.FormValue("page"))
|
||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
||||
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
if pageSize <= 0 {
|
||||
pageSize = 20
|
||||
}
|
||||
|
||||
tp := ObjToInt(that.Req.FormValue("type")) //0,无操作,1,已扫码未认证,2,已认证,3,VIP会员
|
||||
|
||||
data := Map{"del_flag": 0, "salesman_id": that.Session("salesman_id").Data}
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
if keywords != "" {
|
||||
data["OR"] = Map{"name[~]": keywords, "nickname[~]": keywords, "phone[~]": keywords}
|
||||
}
|
||||
|
||||
startTime := that.Req.FormValue("starttime")
|
||||
finishTime := that.Req.FormValue("finishtime")
|
||||
|
||||
if startTime != "" {
|
||||
data["modifye_time[>=]"] = startTime
|
||||
}
|
||||
if finishTime != "" {
|
||||
data["modifye_time[<=]"] = finishTime
|
||||
}
|
||||
if tp == 1 {
|
||||
data["certification_flag"] = 0
|
||||
}
|
||||
|
||||
if tp == 2 {
|
||||
data["certification_flag"] = 1
|
||||
data["expiration_time[<]"] = "now()"
|
||||
}
|
||||
|
||||
if tp == 3 {
|
||||
data["certification_flag"] = 1
|
||||
data["expiration_time[>]"] = "now()"
|
||||
}
|
||||
|
||||
count := that.Db.Count("user", data)
|
||||
|
||||
res := that.Db.Page(page, pageSize).PageSelect("user", "*", data)
|
||||
|
||||
for _, v := range res {
|
||||
delete(v, "password")
|
||||
}
|
||||
|
||||
that.Display(0, Map{"total": count, "data": res})
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"code.hoteas.com/golang/hotime/dri/wechat"
|
||||
)
|
||||
|
||||
var Wechat = Ctr{
|
||||
|
||||
////微信注册
|
||||
"code": func(that *Context) {
|
||||
|
||||
if that.Req.FormValue("code") == "" {
|
||||
that.Display(3, "参数不足")
|
||||
return
|
||||
}
|
||||
|
||||
appid, resToken, userInfo, err := wechat.H5Program.GetUserInfo(that.Req.FormValue("code"))
|
||||
|
||||
if err != nil {
|
||||
that.Display(4, err)
|
||||
return
|
||||
}
|
||||
//此次获取的微信信息
|
||||
wechatInfo := Map{
|
||||
"openid": userInfo.OpenID,
|
||||
"acttoken": resToken.AccessToken,
|
||||
"retoken": resToken.RefreshToken,
|
||||
"appid": appid,
|
||||
"unionid": userInfo.Unionid,
|
||||
"nickname": userInfo.Nickname,
|
||||
"avatar": userInfo.HeadImgURL,
|
||||
//"create_time[#]":"now()",
|
||||
"modify_time[#]": "now()",
|
||||
"del_flag": 0,
|
||||
"type": 1,
|
||||
}
|
||||
|
||||
wechat := that.Db.Get("wechat", "*", Map{"AND": Map{"openid": userInfo.OpenID, "del_flag": 0}})
|
||||
|
||||
if wechat != nil {
|
||||
//有用户直接返回
|
||||
if wechat.GetCeilInt("salesman_id") != 0 {
|
||||
|
||||
that.Session("salesman_id", wechat.GetCeilInt("salesman_id"))
|
||||
|
||||
that.Display(0, "登录成功")
|
||||
return
|
||||
}
|
||||
that.Session("wechat_id", wechat.GetCeilInt("id"))
|
||||
that.Display(2, "暂未绑定")
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
wechatInfo["create_time[#]"] = "now()"
|
||||
|
||||
wechatInfo["id"] = that.Db.Insert("wechat", wechatInfo)
|
||||
if wechatInfo.GetCeilInt("id") == 0 {
|
||||
that.Display(4, "创建用户失败")
|
||||
return
|
||||
}
|
||||
|
||||
that.Session("wechat_id", wechatInfo.GetCeilInt("id"))
|
||||
that.Display(2, "暂未绑定")
|
||||
},
|
||||
|
||||
//网页签名
|
||||
"sign": func(that *Context) {
|
||||
|
||||
signUrl := that.Req.FormValue("url")
|
||||
if signUrl == "" {
|
||||
that.Display(3, "参数不足")
|
||||
return
|
||||
}
|
||||
|
||||
cfg1, e := wechat.H5Program.GetSignUrl(signUrl)
|
||||
|
||||
if e != nil {
|
||||
that.Display(4, e)
|
||||
return
|
||||
}
|
||||
|
||||
sign := Map{
|
||||
"appId": cfg1.AppID,
|
||||
"timestamp": cfg1.Timestamp,
|
||||
"nonceStr": cfg1.NonceStr,
|
||||
"signature": cfg1.Signature,
|
||||
}
|
||||
|
||||
that.Display(0, sign)
|
||||
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user