2026-08-09 10:43:45 +08:00
|
|
|
package store
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
2026-08-09 12:41:08 +08:00
|
|
|
"bsm/full/module/ec/mall/internal/impl"
|
|
|
|
|
"bsm/full/module/ec/mall/internal/models"
|
|
|
|
|
pb "bsm/full/module/ec/mall/pb"
|
2026-08-09 10:43:45 +08:00
|
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 店铺许可授权
|
2026-08-09 20:14:57 +08:00
|
|
|
func Licensing(ctx context.Context, in *pb.LicensingRequest) (reply *pb.IdentityStatusReply, err error) {
|
2026-08-09 10:43:45 +08:00
|
|
|
var identity string
|
|
|
|
|
licenseType := strings.ToUpper(in.GetLicenseType())
|
|
|
|
|
|
|
|
|
|
switch licenseType {
|
|
|
|
|
case "DOMAIN":
|
|
|
|
|
identity, err = LicensingDomain(in.Domain)
|
|
|
|
|
default:
|
|
|
|
|
return nil, errcode.ErrInvalidArgument
|
|
|
|
|
}
|
|
|
|
|
// TODO: valid code
|
|
|
|
|
if identity == "" {
|
|
|
|
|
return nil, errcode.ErrNotFound(404, "store not found")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: add your logic code & delete this line.
|
|
|
|
|
|
2026-08-09 20:14:57 +08:00
|
|
|
return &pb.IdentityStatusReply{
|
2026-08-09 10:43:45 +08:00
|
|
|
Code: 0,
|
|
|
|
|
Message: "OK",
|
|
|
|
|
Identity: identity,
|
|
|
|
|
Timeseq: time.Now().UnixMilli(),
|
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func LicensingDomain(domain string) (string, error) {
|
|
|
|
|
var store models.MallStore
|
|
|
|
|
err := impl.DBService.Model(&models.MallStore{}).Where("subdomain=?", domain).First(&store).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return store.Identity, nil
|
|
|
|
|
}
|