入驻
This commit is contained in:
@@ -1162,6 +1162,7 @@ func checkStoreHaveLinkedStore(storeID, linkStoreID int) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建京西门店,同时生成专送门店。
|
||||||
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||||
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
||||||
if err = checkBankBranch(storeExt.PayeeBankBranchName); err != nil {
|
if err = checkBankBranch(storeExt.PayeeBankBranchName); err != nil {
|
||||||
@@ -1269,6 +1270,127 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建京西门店,不在生成专送门店!
|
||||||
|
func CreateStore2JX(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||||
|
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
||||||
|
if err = checkBankBranch(storeExt.PayeeBankBranchName); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
store := &storeExt.Store
|
||||||
|
if store.ID != 0 && !jxutils.IsLegalStoreID(store.ID) {
|
||||||
|
return 0, fmt.Errorf("ID:%d不是合法的京西门店编号", store.ID)
|
||||||
|
}
|
||||||
|
db := dao.GetDB()
|
||||||
|
if globals.EnableWXAuth2 {
|
||||||
|
if err = dao.ValidateRoles(db, store.MarketManRole, store.OperatorRole, store.OperatorRole2, store.OperatorRole3); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
realLinkStoreID, err := dao.GetRealLinkStoreID(db, storeExt.LinkStoreID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if err = checkStoreHaveLinkedStore(storeExt.ID, realLinkStoreID); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
storeExt.LinkStoreID = realLinkStoreID
|
||||||
|
|
||||||
|
if storeExt.MarketManName == "" {
|
||||||
|
storeExt.MarketManName = ctx.GetUserName()
|
||||||
|
}
|
||||||
|
if storeExt.MarketManPhone == "" {
|
||||||
|
storeExt.MarketManPhone, _ = ctx.GetMobileAndUserID()
|
||||||
|
}
|
||||||
|
|
||||||
|
existingID := store.ID
|
||||||
|
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
|
||||||
|
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
|
||||||
|
if err = checkCreateStore(&storeExt.Store); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
store.Name = jxutils.FormalizeName(store.Name)
|
||||||
|
store.DeliveryRange = strings.Trim(store.DeliveryRange, ";")
|
||||||
|
if store.PrinterSN != "" {
|
||||||
|
handler := partner.GetPrinterPlatformFromVendorID(store.PrinterVendorID)
|
||||||
|
if handler == nil {
|
||||||
|
return 0, fmt.Errorf("不支持的打印机厂商ID:%d", store.PrinterVendorID)
|
||||||
|
}
|
||||||
|
newID1, newID2, err2 := handler.RegisterPrinter(ctx, store.PrinterSN, store.PrinterKey, store.Name)
|
||||||
|
if err = err2; err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
handler.EmptyPrintList(ctx, newID1, newID2)
|
||||||
|
if newID1 != "" {
|
||||||
|
store.PrinterSN = newID1
|
||||||
|
}
|
||||||
|
if newID2 != "" {
|
||||||
|
store.PrinterKey = newID2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if store.StoreLevel == "" {
|
||||||
|
store.StoreLevel = "C"
|
||||||
|
}
|
||||||
|
if store.Tel1 == "" {
|
||||||
|
store.Tel1 = model.DefaultPhone
|
||||||
|
}
|
||||||
|
if store.IDName == "" {
|
||||||
|
store.IDName = model.DefaultName
|
||||||
|
}
|
||||||
|
if store.IDCode == "" {
|
||||||
|
store.IDCode = model.DefaultIdCard
|
||||||
|
}
|
||||||
|
// 默认无品牌
|
||||||
|
store.BrandID = 9
|
||||||
|
|
||||||
|
dao.WrapAddIDCULDEntity(store, userName)
|
||||||
|
store.ID = existingID
|
||||||
|
if err = dao.CreateEntity(db, store); err == nil {
|
||||||
|
if globals.IsAddEvent {
|
||||||
|
err = AddEventDetail(db, ctx, model.OperateAdd, store.ID, model.ThingTypeStore, store.ID, "", "")
|
||||||
|
}
|
||||||
|
// 同步门店信息
|
||||||
|
//UpdateOrCreateCourierStores(ctx, store.ID, false, false, false)
|
||||||
|
TryAddStoreBossRole4StoreByMobile(ctx, storeExt.ID, []string{storeExt.Tel1, storeExt.Tel2})
|
||||||
|
// InsertStoreCategories(ctx, db, store.ID)
|
||||||
|
AddStoreVendorMap(ctx, db, model.VendorIDJX, "", store.ID, &model.StoreMap{
|
||||||
|
VendorStoreID: utils.Int2Str(store.ID),
|
||||||
|
AutoPickup: 1,
|
||||||
|
DeliveryCompetition: 1,
|
||||||
|
PricePercentage: 100,
|
||||||
|
IsSync: 0,
|
||||||
|
Status: model.StoreStatusOpened,
|
||||||
|
PricePercentagePack: "无",
|
||||||
|
CreateDeliveryType: model.YES, // 菜市门店默认门店发单
|
||||||
|
VendorID: model.VendorIDJX,
|
||||||
|
})
|
||||||
|
//尝试把平台负责人加到他自己的权限里
|
||||||
|
if store.MarketManPhone != "" {
|
||||||
|
user, _ := dao.GetUserByID(db, "mobile", store.MarketManPhone)
|
||||||
|
if roles, _ := dao.GetRole(db, user.Name, ""); len(roles) > 0 {
|
||||||
|
role := roles[0]
|
||||||
|
if role.StoreIDs != "" {
|
||||||
|
role.StoreIDs = role.StoreIDs + "," + utils.Int2Str(store.ID)
|
||||||
|
} else {
|
||||||
|
role.StoreIDs = utils.Int2Str(store.ID)
|
||||||
|
}
|
||||||
|
dao.UpdateEntity(db, role, "StoreIDs")
|
||||||
|
} else {
|
||||||
|
if roles, _ := dao.GetRole(db, user.Name+"城市", ""); len(roles) > 0 {
|
||||||
|
role := roles[0]
|
||||||
|
if role.StoreIDs != "" {
|
||||||
|
role.StoreIDs = role.StoreIDs + "," + utils.Int2Str(store.ID)
|
||||||
|
} else {
|
||||||
|
role.StoreIDs = utils.Int2Str(store.ID)
|
||||||
|
}
|
||||||
|
dao.UpdateEntity(db, role, "StoreIDs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return store.ID, err
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
func CreateStoreByUser(ctx *jxcontext.Context, mobile string) (id int, err error) {
|
func CreateStoreByUser(ctx *jxcontext.Context, mobile string) (id int, err error) {
|
||||||
store := &model.Store{}
|
store := &model.Store{}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
@@ -3952,7 +4074,7 @@ func StoreAudit(ctx *jxcontext.Context, storeAudits []*model.StoreAudit, status
|
|||||||
storeExt.Status = model.StoreStatusDisabled
|
storeExt.Status = model.StoreStatusDisabled
|
||||||
storeExt.MarketManName = ctx.GetUserName()
|
storeExt.MarketManName = ctx.GetUserName()
|
||||||
storeExt.MarketManPhone, _ = ctx.GetMobileAndUserID()
|
storeExt.MarketManPhone, _ = ctx.GetMobileAndUserID()
|
||||||
storeID, err := CreateStore(ctx, storeExt, ctx.GetUserName())
|
storeID, err := CreateStore2JX(ctx, storeExt, ctx.GetUserName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return retVal, fmt.Errorf(err.Error())
|
return retVal, fmt.Errorf(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,6 +437,12 @@ const (
|
|||||||
TiktokQrCode = "tiktok"
|
TiktokQrCode = "tiktok"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultName = "石锋"
|
||||||
|
DefaultPhone = "18048531223"
|
||||||
|
DefaultIdCard = "610126198012230014"
|
||||||
|
)
|
||||||
|
|
||||||
func IsPurchaseVendorExist(vendorID int) bool {
|
func IsPurchaseVendorExist(vendorID int) bool {
|
||||||
_, ok := VendorNames[vendorID]
|
_, ok := VendorNames[vendorID]
|
||||||
return ok && vendorID >= VendorIDPurchaseBegin && vendorID <= VendorIDPurchaseEnd
|
return ok && vendorID >= VendorIDPurchaseBegin && vendorID <= VendorIDPurchaseEnd
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"github.com/astaxie/beego/client/orm"
|
"github.com/astaxie/beego/client/orm"
|
||||||
"github.com/astaxie/beego/server/web"
|
"github.com/astaxie/beego/server/web"
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
@@ -33,9 +31,9 @@ func Init() {
|
|||||||
// orm.RegisterModel(new(legacymodel.WeiXins))
|
// orm.RegisterModel(new(legacymodel.WeiXins))
|
||||||
// }
|
// }
|
||||||
// 这个注册的2022年之前的表,包括2022年数据
|
// 这个注册的2022年之前的表,包括2022年数据
|
||||||
//orm.RegisterModel(new(model.GoodsOrder))
|
orm.RegisterModel(new(model.GoodsOrder))
|
||||||
// 这个注册的是当前年份下一年的表,实现分表。不包括当前年份。
|
// 这个注册的是当前年份下一年的表,实现分表。不包括当前年份。
|
||||||
orm.RegisterModelWithSuffix("_"+strconv.Itoa(time.Now().Year()+1), new(model.GoodsOrder))
|
//orm.RegisterModelWithSuffix("_"+strconv.Itoa(time.Now().Year()+1), new(model.GoodsOrder))
|
||||||
orm.RegisterModel(new(model.GoodsOrderOriginal))
|
orm.RegisterModel(new(model.GoodsOrderOriginal))
|
||||||
orm.RegisterModel(new(model.TempGoodsOrderMobile))
|
orm.RegisterModel(new(model.TempGoodsOrderMobile))
|
||||||
orm.RegisterModel(new(model.OrderSku))
|
orm.RegisterModel(new(model.OrderSku))
|
||||||
|
|||||||
Reference in New Issue
Block a user