Merge remote-tracking branch 'origin/mark' into su
This commit is contained in:
@@ -2,6 +2,7 @@ package weixin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
@@ -44,12 +45,29 @@ func (a *MiniAuther) VerifySecret(dummy, jsCode string) (authBindEx *auth2.AuthB
|
||||
}
|
||||
|
||||
// 特殊接口
|
||||
func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
globals.SugarLogger.Debugf("weixin mini DecryptData encryptedData:%s, iv:%s", encryptedData, iv)
|
||||
if authInfo.AuthBindInfo.Type != AuthTypeMini {
|
||||
return "", ErrAuthTypeShouldBeMini
|
||||
func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv)
|
||||
var sessionKey string
|
||||
if jsCode != "" {
|
||||
sessionInfo, err := ProxySNSCode2Session(jsCode)
|
||||
if err == nil {
|
||||
if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
|
||||
if authBindEx.UserID != authInfo.GetID() {
|
||||
return "", fmt.Errorf("jsCode与token不匹配")
|
||||
}
|
||||
} else {
|
||||
return "", err
|
||||
}
|
||||
sessionKey = sessionInfo.SessionKey
|
||||
} else {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
if authInfo.AuthBindInfo.Type != AuthTypeMini {
|
||||
return "", ErrAuthTypeShouldBeMini
|
||||
}
|
||||
sessionKey = authInfo.AuthBindInfo.UserData.(string)
|
||||
}
|
||||
sessionKey := authInfo.AuthBindInfo.UserData.(string)
|
||||
decryptedData, err := ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -75,6 +93,7 @@ func ProxySNSCode2Session(jsCode string) (sessionInfo *weixinapi.SessionInfo, er
|
||||
}
|
||||
|
||||
func ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv string) (decryptedData []byte, err error) {
|
||||
globals.SugarLogger.Debugf("ProxySNSDecodeMiniProgramData, encryptedData:%s, sessionKey:%s, iv:%s", encryptedData, sessionKey, iv)
|
||||
decryptedData, err = api.WeixinMiniAPI.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
|
||||
return decryptedData, err
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
|
||||
if dao.IsNoRowsError(err) {
|
||||
err = nil
|
||||
isNewComment = true
|
||||
if orderComment.IsReplied == 0 && time.Now().Sub(orderComment.CommentCreatedAt) < MAX_REAPLY_TIME {
|
||||
if orderComment.IsReplied == 0 && time.Now().Sub(orderComment.CommentCreatedAt) < time.Duration(orderComment.ModifyDuration)*time.Hour {
|
||||
c.replyOrderComment(orderComment)
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,10 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
|
||||
} else {
|
||||
orderComment.ConsigneeMobile = order.ConsigneeMobile
|
||||
}
|
||||
} else {
|
||||
if storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, orderComment.VendorStoreID, orderComment.VendorID); err == nil {
|
||||
orderComment.StoreID = storeDetail.ID
|
||||
}
|
||||
}
|
||||
if orderComment.StoreID > 0 {
|
||||
comment2.Jxstoreid = utils.Int2Str(orderComment.StoreID)
|
||||
|
||||
@@ -105,6 +105,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
}
|
||||
storeIDs := jxutils.IntMap2List(storeIDMap)
|
||||
skuIDs := jxutils.IntMap2List(skuIDMap)
|
||||
// 判断活动是否重叠的检查,当前忽略京东平台及所有结算信息
|
||||
if !(len(vendorIDs) == 1 && vendorIDs[0] == model.VendorIDJD || act.Type == model.ActSkuFake) {
|
||||
effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, act.BeginAt, act.EndAt)
|
||||
if err != nil {
|
||||
@@ -150,7 +151,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
v.OriginalPrice = int64(jxPrice)
|
||||
}
|
||||
var err2 error
|
||||
if act.Type != model.ActSkuFake {
|
||||
if act.Type != model.ActSkuFake { // 非结算,要计算实际活动价格
|
||||
if storeSkuInfo == nil {
|
||||
v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID)
|
||||
wrongSkuList = append(wrongSkuList, v)
|
||||
@@ -281,12 +282,14 @@ func AddActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, actSto
|
||||
if err = addActStoreSkuBind(ctx, db, actStoreSkuList, actStoreSkuMapList); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, act := range actMap {
|
||||
if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act),
|
||||
map[string]interface{}{
|
||||
model.FieldSyncStatus: act.SyncStatus | model.SyncFlagModifiedMask,
|
||||
}, ctx.GetUserName(), nil); err != nil {
|
||||
return err
|
||||
if act.Type != model.ActSkuFake {
|
||||
for _, act := range actMap {
|
||||
if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act),
|
||||
map[string]interface{}{
|
||||
model.FieldSyncStatus: act.SyncStatus | model.SyncFlagModifiedMask,
|
||||
}, ctx.GetUserName(), nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
@@ -697,11 +700,13 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act
|
||||
syncStatus = model.SyncFlagDeletedMask
|
||||
}
|
||||
syncStatus |= act.SyncStatus
|
||||
if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act),
|
||||
map[string]interface{}{
|
||||
model.FieldSyncStatus: syncStatus,
|
||||
}, ctx.GetUserName(), nil); err != nil {
|
||||
return err
|
||||
if act.Type != model.ActSkuFake {
|
||||
if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act),
|
||||
map[string]interface{}{
|
||||
model.FieldSyncStatus: syncStatus,
|
||||
}, ctx.GetUserName(), nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if isDeleteAll != isNeedCancelAct {
|
||||
@@ -709,7 +714,7 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act
|
||||
}
|
||||
}
|
||||
|
||||
if isNeedCancelAct && act.Type != model.ActSkuFake {
|
||||
if isNeedCancelAct {
|
||||
act := &model.Act{}
|
||||
act.ID = actID
|
||||
if _, err = dao.UpdateEntityLogically(db, act,
|
||||
|
||||
@@ -97,6 +97,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
||||
"configTypeName": model.ConfigTypeName,
|
||||
"autoSaleAt": AutoSaleAtStr,
|
||||
"userTypeName": model.UserTypeName,
|
||||
"storePriceTypeName": model.StorePriceTypeName,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,11 @@ type Store4User struct {
|
||||
|
||||
OriginalName string `orm:"-" json:"originalName"`
|
||||
Name string `orm:"size(255)" json:"name"`
|
||||
OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有
|
||||
CloseTime1 int16 `json:"closeTime1"` // 格式同上
|
||||
OpenTime2 int16 `json:"openTime2"` // 格式同上
|
||||
CloseTime2 int16 `json:"closeTime2"` // 格式同上
|
||||
Status int `json:"status"`
|
||||
CityCode int `orm:"default(0);null" json:"cityCode"` // todo ?
|
||||
DistrictCode int `orm:"default(0);null" json:"districtCode"` // todo ?
|
||||
Address string `orm:"size(255)" json:"address"`
|
||||
@@ -770,8 +775,8 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
}
|
||||
} else {
|
||||
dao.Commit(db)
|
||||
notifyStoreOperatorChanged(store, valid["operatorPhone"])
|
||||
}
|
||||
notifyStoreOperatorChanged(store, valid["operatorPhone"])
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("UpdateStore track:%s, store:%s", ctx.GetTrackInfo(), utils.Format4Output(store, true))
|
||||
@@ -1123,7 +1128,7 @@ func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err
|
||||
return count, err
|
||||
}
|
||||
|
||||
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) {
|
||||
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, keyword string, storeIDs []int, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) {
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
@@ -1136,6 +1141,13 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if keyword != "" {
|
||||
keywordLike := "%" + keyword + "%"
|
||||
sql += `
|
||||
AND (t1.order_id LIKE ? OR t1.jxstoreid LIKE ? OR t1.userphone LIKE ? OR t1.scorecontent LIKE ? OR t1.vendertags LIKE ? OR t1.updated_scorecontent LIKE ?
|
||||
OR t1.updated_vendertags LIKE ? OR t2.name LIKE ?)`
|
||||
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND t1.jxstoreid IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
|
||||
@@ -988,7 +988,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
for _, v := range allBinds {
|
||||
var num int64
|
||||
inSkuBind := inSkuBinsMap[v.RealSkuID]
|
||||
isCanChangePrice := (isUserCanDirectChangePrice || v.ChangePriceType != model.StoreChangePriceTypeBossDisabled)
|
||||
isCanChangePrice := (isUserCanDirectChangePrice || jxutils.TranslateStorePriceType(v.ChangePriceType) != model.StoreChangePriceTypeBossDisabled)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false))
|
||||
var skuBind *model.StoreSkuBind
|
||||
if v.ID == 0 {
|
||||
@@ -1448,7 +1448,7 @@ func shouldPendingStorePriceChange(ctx *jxcontext.Context, storeID int, skuBindI
|
||||
if err = dao.GetEntity(db, store); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return store.ChangePriceType == model.StoreChangePriceTypeNeedApprove, nil
|
||||
return jxutils.TranslateStorePriceType(store.ChangePriceType) == model.StoreChangePriceTypeNeedApprove, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
|
||||
@@ -798,3 +798,10 @@ func Point2StoreDistance(lng, lat float64, intStoreLng, intStoreLat int, deliver
|
||||
}
|
||||
return distance
|
||||
}
|
||||
|
||||
func TranslateStorePriceType(storePriceType int8) int8 {
|
||||
if storePriceType == model.StoreChangePriceTypeManagedStore {
|
||||
storePriceType = model.StoreChangePriceTypeBossDisabled
|
||||
}
|
||||
return storePriceType
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments, isBadComment b
|
||||
orderInfo = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[int(utils.Str2Int64WithDefault(comment.OrderFlag, 0))], order.OrderSeq, comment.OrderId)
|
||||
consigneeName = order.ConsigneeName
|
||||
} else {
|
||||
orderInfo = fmt.Sprintf("%s订单, %s", model.VendorChineseNames[int(utils.Str2Int64WithDefault(comment.OrderFlag, 0))], comment.OrderId)
|
||||
orderInfo = fmt.Sprintf("%s订单, %s", model.VendorChineseNames[int(utils.Str2Int64WithDefault(comment.OrderFlag, 0))] /*comment.OrderId*/, "")
|
||||
}
|
||||
data := map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
|
||||
@@ -183,10 +183,12 @@ func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int,
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
FROM store_map t1
|
||||
JOIN store t2 ON t2.id = t1.store_id AND t2.deleted_at = ?
|
||||
WHERE t1.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if len(vendorIDs) > 0 {
|
||||
sql += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||
|
||||
@@ -245,7 +245,7 @@ type OrderComment struct {
|
||||
UserCommentID string `orm:"column(user_comment_id);size(48)" json:"userCommentID"`
|
||||
IsReplied int8
|
||||
Status int8
|
||||
ModifyDuration int8 // 改评价的小时数
|
||||
ModifyDuration int16 // 改评价的小时数
|
||||
|
||||
TagList string
|
||||
Score int8
|
||||
|
||||
@@ -74,7 +74,6 @@ var (
|
||||
"长条",
|
||||
"鲜活宰杀",
|
||||
"惠",
|
||||
"鱼腥草",
|
||||
"冰冻",
|
||||
"思念",
|
||||
"散装",
|
||||
|
||||
@@ -43,9 +43,10 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
StoreChangePriceTypeDirect = 0
|
||||
StoreChangePriceTypeNeedApprove = 1
|
||||
StoreChangePriceTypeBossDisabled = 2
|
||||
StoreChangePriceTypeDirect = 0 // 普通门店
|
||||
StoreChangePriceTypeNeedApprove = 1 // 改价需要审核,暂时没用
|
||||
StoreChangePriceTypeBossDisabled = 2 // 完全禁止改价
|
||||
StoreChangePriceTypeManagedStore = 3 // 直营门店,禁止改价
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -234,6 +235,11 @@ var (
|
||||
StoreAuditStatusOnline: "上线",
|
||||
StoreAuditStatusRejected: "拒绝",
|
||||
}
|
||||
StorePriceTypeName = map[int]string{
|
||||
StoreChangePriceTypeDirect: "可直接改价",
|
||||
StoreChangePriceTypeBossDisabled: "禁止改价",
|
||||
StoreChangePriceTypeManagedStore: "直营门店",
|
||||
}
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
@@ -258,12 +264,13 @@ type Store struct {
|
||||
AutoEnableAt *time.Time `orm:"type(datetime);null" json:"autoEnableAt"` // 自动营业时间(临时休息用)
|
||||
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
||||
SMSNotify int8 `orm:"column(sms_notify);" json:"smsNotify"` // 是否通过短信接收订单消息
|
||||
PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机
|
||||
PrinterFontSize int8 `orm:"default(0)" json:"printerFontSize"` // 打印字体-1:小,0:正常,1:大
|
||||
PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"`
|
||||
PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"`
|
||||
PrinterKey string `orm:"size(64)" json:"printerKey"`
|
||||
PrinterBindInfo string `orm:"size(1024)" json:"-"`
|
||||
|
||||
PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机
|
||||
PrinterFontSize int8 `orm:"default(0)" json:"printerFontSize"` // 打印字体-1:小,0:正常,1:大
|
||||
PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"`
|
||||
PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"`
|
||||
PrinterKey string `orm:"size(64)" json:"printerKey"`
|
||||
PrinterBindInfo string `orm:"size(1024)" json:"-"`
|
||||
|
||||
IDCardFront string `orm:"size(255);column(id_card_front)" json:"idCardFront"`
|
||||
IDCardBack string `orm:"size(255);column(id_card_back)" json:"idCardBack"`
|
||||
|
||||
@@ -45,7 +45,7 @@ type StoreSkuCategoryMap struct {
|
||||
|
||||
// ElmID int64 `orm:"column(elm_id);index"`
|
||||
EbaiID int64 `orm:"column(ebai_id);index"`
|
||||
MtwmID string `orm:"column(mtwm_id);index;size(16)"` // 美团外卖没有ID,保存名字
|
||||
MtwmID string `orm:"column(mtwm_id);index;size(16)"`
|
||||
// WscID int64 `orm:"column(wsc_id);index"`
|
||||
|
||||
// ElmSyncStatus int8 `orm:"default(2)"`
|
||||
@@ -95,7 +95,7 @@ type StoreSkuBind struct {
|
||||
|
||||
// ElmID int64 `orm:"column(elm_id);index"`
|
||||
EbaiID int64 `orm:"column(ebai_id);index"`
|
||||
MtwmID int64 `orm:"column(mtwm_id)"` // 这个也不是必须的,只是为了DAO取数据语句一致
|
||||
MtwmID int64 `orm:"column(mtwm_id)"`
|
||||
// WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId
|
||||
// WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId
|
||||
|
||||
@@ -108,6 +108,7 @@ type StoreSkuBind struct {
|
||||
JdPrice int `json:"jdPrice"`
|
||||
EbaiPrice int `json:"ebaiPrice"`
|
||||
MtwmPrice int `json:"mtwmPrice"`
|
||||
// JxPrice int `json:"jxPrice"`
|
||||
// WscPrice int `json:"wscPrice"`
|
||||
|
||||
AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"`
|
||||
|
||||
@@ -22,11 +22,9 @@ const (
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) StartRefreshComment() {
|
||||
if globals.ReallyCallPlatformAPI {
|
||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||
c.refreshCommentOnce()
|
||||
})
|
||||
}
|
||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||
c.refreshCommentOnce()
|
||||
})
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) refreshCommentOnce() {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
@@ -23,9 +22,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
FakeMsgTypeOrderReceived = "orderReceived"
|
||||
FakeMsgTypeOrderDelivering = "orderDelivering"
|
||||
FakeMsgType = "fakeMsgType"
|
||||
|
||||
fakeFinishedPickup = "fake_finished_pickup"
|
||||
fakeUserApplyCancel = "fake_user_apply_cancel"
|
||||
fakeMerchantAgreeApplyCancel = "fake_merchant_agree_apply_cancel"
|
||||
fakeRefuseUserApplyCancel = "fake_refuse_user_apply_cancel"
|
||||
@@ -38,11 +37,11 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
// pickupOrderDelay = 260 * time.Second
|
||||
pickupOrderDelay = 1 * time.Second
|
||||
// pickupOrderDelay = 260 * time.Second
|
||||
// pickupOrderDelay = 1 * time.Second
|
||||
|
||||
callDeliveryDelay = 10 * time.Minute
|
||||
callDeliveryDelayGap = 30
|
||||
// callDeliveryDelay = 10 * time.Minute
|
||||
// callDeliveryDelayGap = 30
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -53,13 +52,16 @@ var (
|
||||
VendorStatus2StatusMap = map[string]int{
|
||||
mtwmapi.OrderStatusUserCommitted: model.OrderStatusUnknown,
|
||||
mtwmapi.OrderStatusNew: model.OrderStatusNew,
|
||||
mtwmapi.OrderStatusReceived: model.OrderStatusAccepted,
|
||||
mtwmapi.OrderStatusAccepted: model.OrderStatusFinishedPickup,
|
||||
mtwmapi.OrderStatusDelivering: model.OrderStatusDelivering,
|
||||
mtwmapi.OrderStatusDelivered: model.OrderStatusUnknown, // 以mtwmapi.OrderStatusFinished为结束状态,这个当成一个中间状态(且很少看到这个状态)
|
||||
mtwmapi.OrderStatusFinished: model.OrderStatusFinished,
|
||||
mtwmapi.OrderStatusCanceled: model.OrderStatusCanceled,
|
||||
// mtwmapi.OrderStatusReceived: model.OrderStatusAccepted,
|
||||
// mtwmapi.OrderStatusAccepted: model.OrderStatusFinishedPickup,
|
||||
mtwmapi.OrderStatusAccepted: model.OrderStatusAccepted,
|
||||
|
||||
mtwmapi.OrderStatusDelivering: model.OrderStatusDelivering,
|
||||
mtwmapi.OrderStatusDelivered: model.OrderStatusUnknown, // 以mtwmapi.OrderStatusFinished为结束状态,这个当成一个中间状态(且很少看到这个状态)
|
||||
mtwmapi.OrderStatusFinished: model.OrderStatusFinished,
|
||||
mtwmapi.OrderStatusCanceled: model.OrderStatusCanceled,
|
||||
|
||||
fakeFinishedPickup: model.OrderStatusFinishedPickup,
|
||||
fakeOrderAdjustFinished: model.OrderStatusAdjust,
|
||||
fakeRefuseUserApplyCancel: model.OrderStatusUnlocked,
|
||||
fakeUserApplyCancel: model.OrderStatusApplyCancel,
|
||||
@@ -142,9 +144,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
if openUID > 0 {
|
||||
order.VendorUserID = utils.Int64ToStr(openUID)
|
||||
}
|
||||
if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) {
|
||||
order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 美团外卖要求在5分钟内拣货,不然订单会被取消
|
||||
}
|
||||
// 不设置最晚拣货时间,以缺省值为准
|
||||
// if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) {
|
||||
// order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 美团外卖要求在5分钟内拣货,不然订单会被取消
|
||||
// }
|
||||
order.Status = p.getStatusFromVendorStatus(order.VendorStatus)
|
||||
if utils.IsTimeZero(order.ExpectedDeliveredTime) {
|
||||
order.BusinessType = model.BusinessTypeImmediate
|
||||
@@ -347,7 +350,7 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *mtwmapi.CallbackMsg) (orderSta
|
||||
case mtwmapi.MsgTypeOrderCanceled:
|
||||
vendorStatus = mtwmapi.OrderStatusCanceled
|
||||
remark = msg.FormData.Get("reason")
|
||||
case mtwmapi.MsgTypeNewOrder, FakeMsgTypeOrderReceived, mtwmapi.MsgTypeOrderAccepted, FakeMsgTypeOrderDelivering, mtwmapi.MsgTypeOrderFinished:
|
||||
case FakeMsgType, mtwmapi.MsgTypeNewOrder, mtwmapi.MsgTypeOrderAccepted, mtwmapi.MsgTypeOrderFinished:
|
||||
vendorStatus = msg.FormData.Get("status")
|
||||
statusTime = utils.Str2Int64(msg.FormData.Get("utime"))
|
||||
case mtwmapi.MsgTypeOrderRefund, mtwmapi.MsgTypeOrderPartialRefund:
|
||||
@@ -414,11 +417,15 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
globals.SugarLogger.Debugf("mtwm AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
|
||||
if isAcceptIt {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.OrderReceived(utils.Str2Int64(order.VendorOrderID))
|
||||
}
|
||||
if err == nil {
|
||||
c.postFakeMsg(order.VendorOrderID, FakeMsgTypeOrderReceived, mtwmapi.OrderStatusReceived)
|
||||
// err = api.MtwmAPI.OrderReceived(utils.Str2Int64(order.VendorOrderID))
|
||||
err = api.MtwmAPI.OrderConfirm(utils.Str2Int64(order.VendorOrderID))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("mtwm AcceptOrRefuseOrder orderID:%s failed with err:%v", order.VendorOrderID, err)
|
||||
}
|
||||
}
|
||||
// if err == nil {
|
||||
// c.postFakeMsg(order.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusReceived)
|
||||
// }
|
||||
} else {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = c.CancelOrder(jxcontext.AdminCtx, order, "bu")
|
||||
@@ -430,9 +437,11 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("mtwm PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.OrderConfirm(utils.Str2Int64(order.VendorOrderID))
|
||||
} else {
|
||||
c.postFakeMsg(order.VendorOrderID, mtwmapi.MsgTypeOrderAccepted, mtwmapi.OrderStatusAccepted)
|
||||
// err = api.MtwmAPI.OrderConfirm(utils.Str2Int64(order.VendorOrderID))
|
||||
err = api.MtwmAPI.PreparationMealComplete(utils.Str2Int64(order.VendorOrderID))
|
||||
}
|
||||
if err == nil {
|
||||
c.postFakeMsg(order.VendorOrderID, FakeMsgType, fakeFinishedPickup)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -495,19 +504,19 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(order *model.GoodsOrder, statusType, status int) (params *partner.StatusActionParams) {
|
||||
if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted {
|
||||
params = &partner.StatusActionParams{ // PickDeadline没有设置时才有效,美团外卖要求在5分钟内拣货,不然订单会被取消
|
||||
Timeout: pickupOrderDelay,
|
||||
}
|
||||
} else if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusFinishedPickup {
|
||||
params = &partner.StatusActionParams{ // 立即达订单有效,自配送延时召唤配送
|
||||
Timeout: callDeliveryDelay,
|
||||
TimeoutGap: callDeliveryDelayGap,
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
// func (c *PurchaseHandler) GetStatusActionTimeout(order *model.GoodsOrder, statusType, status int) (params *partner.StatusActionParams) {
|
||||
// if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted {
|
||||
// params = &partner.StatusActionParams{ // PickDeadline没有设置时才有效,美团外卖要求在5分钟内拣货,不然订单会被取消
|
||||
// Timeout: pickupOrderDelay,
|
||||
// }
|
||||
// } else if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusFinishedPickup {
|
||||
// params = &partner.StatusActionParams{ // 立即达订单有效,自配送延时召唤配送
|
||||
// Timeout: callDeliveryDelay,
|
||||
// TimeoutGap: callDeliveryDelayGap,
|
||||
// }
|
||||
// }
|
||||
// return params
|
||||
// }
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package mtwm
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -16,17 +18,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
RefreshCommentTime = 36 * time.Hour
|
||||
RefreshCommentTime = 7 * 24 * time.Hour // 此值必须大于24小时
|
||||
RefreshCommentTimeInterval = 60 * time.Minute
|
||||
BAD_COMMENTS_MAX_MODIFY_TIME = 24 // 小时
|
||||
BAD_COMMENTS_MAX_MODIFY_TIME = 24 * 6 // 小时
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) StartRefreshComment() {
|
||||
if globals.ReallyCallPlatformAPI {
|
||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||
c.refreshCommentOnce()
|
||||
})
|
||||
}
|
||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||
c.refreshCommentOnce()
|
||||
})
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) refreshCommentOnce() {
|
||||
@@ -36,43 +36,75 @@ func (c *PurchaseHandler) refreshCommentOnce() {
|
||||
})
|
||||
}
|
||||
|
||||
func formalizeTagList(mtwmTagList string) (outTagList string) {
|
||||
if mtwmTagList != "" {
|
||||
outTagList = string(utils.Format4Output(strings.Split(mtwmTagList, ","), true))
|
||||
}
|
||||
return outTagList
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "")
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
task := tasksch.NewParallelTask("mtwm RefreshComment", nil, jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
startDateStr := time.Now().Format("20060102")
|
||||
endDateStr := time.Now().Add(-RefreshCommentTime).Format("20060102")
|
||||
commentList, err2 := api.MtwmAPI.CommentQuery(storeMap.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusAll)
|
||||
if err = err2; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return commentList, nil
|
||||
}, storeMapList)
|
||||
task.Run()
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
var orderCommentList []*model.OrderComment
|
||||
for _, result := range resultList {
|
||||
mtwmComment := result.(*mtwmapi.OrderComment)
|
||||
orderComment := &model.OrderComment{
|
||||
VendorID: model.VendorIDMTWM,
|
||||
TagList: mtwmComment.CommentLables,
|
||||
Score: int8(mtwmComment.FoodCommentScore),
|
||||
storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, model.StoreStatusAll, model.StoreIsSyncYes, "")
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
task := tasksch.NewParallelTask("mtwm RefreshComment", nil, jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
endDateStr := time.Now().Add(-24 * time.Hour).Format("20060102")
|
||||
startDateStr := time.Now().Add(-RefreshCommentTime).Format("20060102")
|
||||
commentList, err2 := api.MtwmAPI.CommentQuery(storeMap.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusAll)
|
||||
|
||||
var orderCommentList []*model.OrderComment
|
||||
if err = err2; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
for _, mtwmComment := range commentList {
|
||||
createdTime, err := utils.TryStr2Time(mtwmComment.CommentTime)
|
||||
if err == nil {
|
||||
orderComment := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(mtwmComment.CommentID), // 美团评价不能得到订单号,以评价ID代替
|
||||
VendorID: model.VendorIDMTWM,
|
||||
UserCommentID: utils.Int64ToStr(mtwmComment.CommentID),
|
||||
VendorStoreID: storeMap.VendorStoreID,
|
||||
TagList: formalizeTagList(mtwmComment.CommentLables),
|
||||
Score: int8(mtwmComment.FoodCommentScore),
|
||||
ModifyDuration: BAD_COMMENTS_MAX_MODIFY_TIME,
|
||||
OriginalMsg: string(utils.MustMarshal(mtwmComment)),
|
||||
IsReplied: int8(mtwmComment.ReplyStatus),
|
||||
}
|
||||
if orderComment.IsReplied == 0 {
|
||||
orderComment.Content = mtwmComment.CommentContent
|
||||
orderComment.CommentCreatedAt = createdTime
|
||||
} else {
|
||||
orderComment.Content = mtwmComment.AddComment
|
||||
if updatedTime, err := utils.TryStr2Time(mtwmComment.CommentTime); err == nil {
|
||||
orderComment.CommentCreatedAt = updatedTime
|
||||
}
|
||||
}
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
}
|
||||
return orderCommentList, nil
|
||||
}, storeMapList)
|
||||
task.Run()
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
var orderCommentList []*model.OrderComment
|
||||
for _, result := range resultList {
|
||||
orderComment := result.(*model.OrderComment)
|
||||
orderCommentList = append(orderCommentList, orderComment)
|
||||
}
|
||||
if len(orderCommentList) > 0 {
|
||||
err = partner.CurOrderManager.OnOrderComments(orderCommentList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
globals.SugarLogger.Debugf("mtwm ReplyOrderComment, orderComment:%s, replyComment:%s", utils.Format4Output(orderComment, true), replyComment)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.CommentAddReply(orderComment.VendorStoreID, utils.Str2Int64(orderComment.UserCommentID), replyComment)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package mtwm
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -33,17 +30,7 @@ func (c *PurchaseHandler) onWaybillMsg(msg *mtwmapi.CallbackMsg) (response *mtwm
|
||||
waybill := c.callbackMsg2Waybill(msg)
|
||||
err := partner.CurOrderManager.OnWaybillStatusChanged(waybill)
|
||||
if err == nil && waybill.Status == model.WaybillStatusDelivering {
|
||||
msg := &mtwmapi.CallbackMsg{
|
||||
Cmd: FakeMsgTypeOrderDelivering,
|
||||
FormData: url.Values{},
|
||||
}
|
||||
msg.FormData.Set("timestamp", utils.Int64ToStr(time.Now().Unix()))
|
||||
msg.FormData.Set("utime", msg.FormData.Get("timestamp"))
|
||||
msg.FormData.Set(mtwmapi.KeyOrderID, waybill.VendorOrderID)
|
||||
msg.FormData.Set("status", mtwmapi.OrderStatusDelivering)
|
||||
utils.CallFuncAsync(func() {
|
||||
c.onOrderMsg(msg)
|
||||
})
|
||||
c.postFakeMsg(waybill.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusDelivering)
|
||||
}
|
||||
return mtwmapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
@@ -14,7 +13,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
@@ -297,30 +295,3 @@ func (c *Auth2Controller) ChangePassword() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 解密小程序数据
|
||||
// @Description 解密小程序数据
|
||||
// @Param token header string true "认证token"
|
||||
// @Param data formData string true "加密数据"
|
||||
// @Param iv formData string true "iv"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /MiniDecryptData [post]
|
||||
func (c *Auth2Controller) MiniDecryptData() {
|
||||
c.callMiniDecryptData(func(params *tAuth2MiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
|
||||
authInfo, err := params.Ctx.GetV2AuthInfo()
|
||||
if err == nil {
|
||||
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, params.Data, params.Iv)
|
||||
if err = err2; err == nil {
|
||||
var userInfo *weixinapi.MiniUserInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil {
|
||||
if user := params.Ctx.GetFullUser(); user != nil {
|
||||
user.Avatar = userInfo.AvatarURL
|
||||
dao.UpdateEntity(dao.GetDB(), user, "Avatar")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() {
|
||||
if err = err2; err == nil {
|
||||
pageSize := jxutils.FormalizePageSize(params.Size)
|
||||
offset := (params.Page - 1) * pageSize
|
||||
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1])
|
||||
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, "", []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1])
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -247,11 +247,12 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() {
|
||||
// @Description 得到门店评价列表(多店)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param type query int true "评论类型,0:差评,1:所有,2:已解决"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param storeIDs query string false "门店I列表"
|
||||
// @Param offset query int false "起始页,从1开始"
|
||||
// @Param pageSize query int false "页大小(-1表示无限大)"
|
||||
// @Param fromTime query string false "创建起始时间"
|
||||
// @Param toTime query string false "创建结束时间"
|
||||
// @Param offset query int false "起始页,从1开始"
|
||||
// @Param pageSize query int false "页大小(-1表示无限大)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /TmpGetJxBadComments [get]
|
||||
@@ -261,7 +262,7 @@ func (c *StoreController) TmpGetJxBadComments() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
|
||||
timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime)
|
||||
if err = err2; err == nil {
|
||||
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1])
|
||||
retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, params.Keyword, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1])
|
||||
}
|
||||
}
|
||||
return retVal, "", err
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/authz"
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
@@ -374,3 +377,37 @@ func (c *User2Controller) GetSelfInfo() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 根据小程序jsCode修改用户信息
|
||||
// @Description 根据小程序jsCode修改用户信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param jsCode query string true "小程序jsCode"
|
||||
// @Param data query string true "加密数据"
|
||||
// @Param iv query string true "iv"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateUserByMiniInfo [put]
|
||||
func (c *Auth2Controller) UpdateUserByMiniInfo() {
|
||||
c.callUpdateUserByMiniInfo(func(params *tAuth2UpdateUserByMiniInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
authInfo, err := params.Ctx.GetV2AuthInfo()
|
||||
if err == nil {
|
||||
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv)
|
||||
if err = err2; err == nil {
|
||||
var userInfo *weixinapi.MiniUserInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil {
|
||||
retVal = userInfo
|
||||
if user := params.Ctx.GetFullUser(); user != nil {
|
||||
if userInfo.AvatarURL != "" {
|
||||
user.Avatar = userInfo.AvatarURL
|
||||
}
|
||||
if userInfo.PurePhoneNumber != "" {
|
||||
user.Mobile = utils.String2Pointer(userInfo.PurePhoneNumber)
|
||||
}
|
||||
dao.UpdateEntity(dao.GetDB(), user)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@@ -21,6 +21,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
@@ -66,6 +67,7 @@ func Init() {
|
||||
|
||||
if globals.IsProductEnv() {
|
||||
ebai.CurPurchaseHandler.StartRefreshComment()
|
||||
mtwm.CurPurchaseHandler.StartRefreshComment()
|
||||
}
|
||||
misc.Init()
|
||||
}
|
||||
|
||||
@@ -151,15 +151,6 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||
beego.ControllerComments{
|
||||
Method: "MiniDecryptData",
|
||||
Router: `/MiniDecryptData`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||
beego.ControllerComments{
|
||||
Method: "RemoveAuthBind",
|
||||
@@ -178,6 +169,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||
beego.ControllerComments{
|
||||
Method: "UpdateUserByMiniInfo",
|
||||
Router: `/UpdateUserByMiniInfo`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||
beego.ControllerComments{
|
||||
Method: "WeixinMPOAuth2",
|
||||
|
||||
Reference in New Issue
Block a user