aa
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
package jd
|
package jd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -84,3 +89,65 @@ func JxStoreStatus2JdStatus(status int) (yn, closeStatus int) {
|
|||||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
||||||
return imgHint, err
|
return imgHint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type JdCode struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
VenderID string `json:"venderId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JdToken struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
VenderID string `json:"venderId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func OnTokenChange(values url.Values) {
|
||||||
|
db := dao.GetDB()
|
||||||
|
codeInfo := &JdCode{}
|
||||||
|
if dataStr := values.Get("code"); dataStr != "" {
|
||||||
|
json.Unmarshal([]byte(dataStr), &codeInfo)
|
||||||
|
}
|
||||||
|
if codeInfo != nil {
|
||||||
|
voc := &model.VendorOrgCode{}
|
||||||
|
sql := `
|
||||||
|
SELECT * FROM tmp_jd WHERE vendor_org_code = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{codeInfo.VenderID}
|
||||||
|
if err := dao.GetRow(db, &voc, sql, sqlParams); err == nil && voc != nil {
|
||||||
|
if result, _ := dao.GetVendorOrgCode(db, model.VendorIDJD, codeInfo.VenderID, model.VendorOrgTypePlatform); len(result) == 0 {
|
||||||
|
voc2 := &model.VendorOrgCode{
|
||||||
|
Comment: voc.Comment,
|
||||||
|
VendorOrgCode: codeInfo.VenderID,
|
||||||
|
}
|
||||||
|
dao.WrapAddIDCULDEntity(voc2, "jxadmin")
|
||||||
|
if err := dao.CreateEntity(db, voc2); err == nil {
|
||||||
|
//添加成功后去开发者后台填验证码
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("OnTokenChange, 发验证码,但是库里有这个账号了")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tokenInfo := &JdToken{}
|
||||||
|
if dataStr := values.Get("token"); dataStr != "" {
|
||||||
|
json.Unmarshal([]byte(dataStr), &tokenInfo)
|
||||||
|
}
|
||||||
|
if tokenInfo == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
voc := &model.VendorOrgCode{}
|
||||||
|
sql := `
|
||||||
|
SELECT * FROM tmp_jd WHERE vendor_org_code = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{tokenInfo.VenderID}
|
||||||
|
if err := dao.GetRow(db, &voc, sql, sqlParams); err == nil && voc != nil {
|
||||||
|
if result, _ := dao.GetVendorOrgCode(db, model.VendorIDJD, voc.VendorOrgCode, model.VendorOrgTypePlatform); len(result) > 0 {
|
||||||
|
result[0].Token = tokenInfo.Token
|
||||||
|
dao.UpdateEntity(db, result[0], "Token")
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("OnTokenChange, 发token,但是库里没这个账号")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ func (c *DjswController) Token() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false))
|
globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false))
|
||||||
}
|
}
|
||||||
|
jd.OnTokenChange(urlValues)
|
||||||
c.Data["json"] = c.transferResponse("Token", nil)
|
c.Data["json"] = c.transferResponse("Token", nil)
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user