冲突处理

This commit is contained in:
苏尹岚
2020-01-09 08:46:26 +08:00
10 changed files with 131 additions and 7 deletions

View File

@@ -0,0 +1,43 @@
package alipay
import (
"git.rosy.net.cn/baseapi/platformapi/alipayapi"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
AuthType = "alipaycode"
)
type Auther struct {
authprovider.DefAuther
}
var (
AutherObj *Auther
)
func init() {
AutherObj = new(Auther)
auth2.RegisterAuther(AuthType, AutherObj)
}
func (a *Auther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
globals.SugarLogger.Debugf("VerifySecret dummy:%s, code:%s", dummy, code)
tokenInfo, err := api.AliPayAPI.SystemAuthToken(alipayapi.GrantTypeCode, code, "")
if err == nil {
userInfo, err2 := api.AliPayAPI.UserInfoShare(tokenInfo.AccessToken)
if err = err2; err == nil {
if authBindEx, err = a.UnionFindAuthBind(AuthType, nil, userInfo.UserID, "", userInfo); err == nil {
authBindEx.UserHint = &auth2.UserBasic{
Name: userInfo.NickName,
Avatar: userInfo.Avatar,
}
}
}
}
return authBindEx, err
}

View File

@@ -141,6 +141,8 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
"autoReplyTypeName": model.AutoReplyTypeName,
"complaintReasons": model.ComplaintReasons,
"supplementType": model.SupplementTypeName,
"operateType": model.OperateTypeName,
"thingType": model.ThingTypeName,
},
}
}

View File

@@ -1089,7 +1089,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask)
updateFieldMap[model.FieldStatus] = 1
}
if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制
if skuBindInfo.UnitPrice != 0 && skuBind.UnitPrice != unitPrice && isCanChangePrice { // 这里是否需要加此条件限制
skuBind.UnitPrice = unitPrice
skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit)
skuBind.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), skuBind.Price)

View File

@@ -1,11 +1,54 @@
package event
import "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
import (
"strings"
"time"
func AddOperateEvent(ctx *jxcontext.Context) {
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
)
func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
var (
apiFunction string
db = dao.GetDB()
)
url := ctx.GetRequest().URL.Path
if url != "" {
apiFunction = url[strings.LastIndex(url, "/")+1 : len(url)]
}
event := &model.OperateEvent{
CreatedAt: time.Now(),
LastOperator: ctx.GetUserName(),
APIFunction: apiFunction,
UserID: ctx.GetUserID(),
AccessUUID: accessUUID,
}
dao.Begin(db)
defer func() {
if r := recover(); r != nil {
dao.Rollback(db)
panic(r)
}
}()
err = dao.CreateEntity(db, event)
dao.Commit(db)
return err
}
func AddOperateEventDetail(ctx *jxcontext.Context) {
func AddOperateEventDetail(operateEventDetail *model.OperateEventDetail) (err error) {
db := dao.GetDB()
dao.Begin(db)
defer func() {
if r := recover(); r != nil {
dao.Rollback(db)
panic(r)
}
}()
err = dao.CreateEntity(db, operateEventDetail)
dao.Commit(db)
return err
}

View File

@@ -105,6 +105,19 @@ var (
Coupon: "优惠券",
}
OperateTypeName = map[int]string{
OperateAdd: "新增",
OperateUpdate: "修改",
OperateDelete: "删除",
}
ThingTypeName = map[int]string{
ThingTypeCategory: "分类",
ThingTypeSku: "门店商品",
ThingTypeSkuName: "商品库",
ThingTypeStore: "门店",
}
MultiStoresVendorMap = map[int]int{
VendorIDJD: 1,
VendorIDMTWM: 0,
@@ -241,6 +254,12 @@ const (
Coupon = 2 //优惠券
)
const (
OperateAdd = 1 //新增操作
OperateUpdate = 2 //修改操作
OperateDelete = 4 //删除操作
)
const (
WaybillStatusRefuseFailedGetGoods = -70
WaybillStatusUnknown = 0

View File

@@ -16,7 +16,7 @@ const (
ErrCodeJsonActPriceTooLarger = "-102" // 这个错误号表示description中的是一个json对象不是错误文本
ErrCodeJsonActEarningPriceIsZero = "-103"
ErrCodeJsonUserAlreadyExist = "-104" // 用户已经存在错,且能成功登录
ErrCodeJsonSyncErr = "-105" //同步错误
ErrCodeJsonSyncErr = "-105"
)
var (

View File

@@ -4,6 +4,7 @@ const (
ThingTypeCategory = 1
ThingTypeSkuName = 2
ThingTypeSku = 3
ThingTypeStore = 4
)
type ThingMap struct {