Files
full/module/ec/mall/internal/logic/store/get_payment.go

44 lines
1.2 KiB
Go
Raw Normal View History

package store
import (
"context"
"bsm/full/module/ec/mall/internal/impl"
"bsm/full/module/ec/mall/internal/models"
pb "bsm/full/module/ec/mall/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/service"
)
// 获取支付方式配置
func GetPayment(ctx context.Context, in *pb.IdentRequest) (reply *pb.ConfigsReply, err error) {
// parse authorization meta.
2026-09-22 21:15:34 +08:00
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
if err != nil {
return nil, err
}
if in.Id == 0 && in.Identity == "" {
return nil, errcode.ErrInvalidArgument
}
2026-09-22 21:15:34 +08:00
// 只能读取当前登录者所属店铺的配置
owner, _ := auth.Owner.(map[string]any)
storeIdentity, _ := owner["store_identity"].(string)
sotre := models.MallStore{}
2026-09-22 21:15:34 +08:00
tx := impl.DBService.Model(&models.MallStore{}).Select("pay_configs").
Where("id=? or identity=?", in.GetId(), in.GetIdentity()).
Where("identity = ?", storeIdentity).Find(&sotre)
if tx.Error != nil {
print(tx.Error.Error())
return nil, errcode.ErrDB
}
2026-09-22 21:15:34 +08:00
if storeIdentity == "" || tx.RowsAffected == 0 {
return nil, errcode.ErrPermissionDenied
}
return &pb.ConfigsReply{Configs: sotre.PayConfigs}, nil
}