44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
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.
|
|
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
|
|
}
|
|
|
|
// 只能读取当前登录者所属店铺的配置
|
|
owner, _ := auth.Owner.(map[string]any)
|
|
storeIdentity, _ := owner["store_identity"].(string)
|
|
|
|
sotre := models.MallStore{}
|
|
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
|
|
}
|
|
if storeIdentity == "" || tx.RowsAffected == 0 {
|
|
return nil, errcode.ErrPermissionDenied
|
|
}
|
|
|
|
return &pb.ConfigsReply{Configs: sotre.PayConfigs}, nil
|
|
|
|
}
|