作者 tangxvhui

调整 partner

... ... @@ -59,11 +59,13 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
newPartnerInfo := &domain.PartnerInfo{
Account: command.Account,
PartnerName: command.PartnerName,
Partner: domain.Partner{
Account: command.Account,
PartnerName: command.PartnerName,
},
PartnerCategory: command.PartnerCategory,
Password: command.Password,
Status: command.Status,
PartnerCategory: command.PartnerCategory,
RegionInfo: command.RegionInfo,
Salesman: command.Salesman,
CooperateTime: command.CooperateTime,
... ...
... ... @@ -48,7 +48,8 @@ type Order struct {
//买家
Buyer *Buyer `json:"buyer"`
//合伙人id
PartnerId int64 `json:"PartnerId"`
PartnerId int64 `json:"PartnerId"`
//合伙人数据
PartnerInfo *PartnerInfo `json:"partnerInfo"`
//合伙人分红百分比
PartnerBonusPercent float64 `json:"partnerBonusPercent"`
... ... @@ -57,3 +58,10 @@ type Order struct {
//最后查看得时间
LastViewTime time.Time `json:"lastViewTime"`
}
type OrderRepository interface {
// Save(*AdminUser) (*AdminUser, error)
// FindOne(qureyOptions AdminUserFindOneQuery) (*AdminUser, error)
// Find(queryOptions AdminUserFindQuery) ([]AdminUser, error)
// CountAll(queryOption AdminUserFindQuery) (int, error)
}
... ...
package domain
type Partner struct {
// 合伙人ID
Id int64 `json:"id"`
// 合伙人姓名
PartnerName string `json:"partnerName"`
// 登录账号
Account string `json:"account"`
}
... ...
... ... @@ -16,18 +16,20 @@ const (
)
type PartnerInfo struct {
// 合伙人ID
Id int64 `json:"id"`
// 合伙人姓名
PartnerName string `json:"partnerName"`
// 登录账号
Account string `json:"account"`
Partner Partner
// // 合伙人ID
// Id int64 `json:"id"`
// // 合伙人姓名
// PartnerName string `json:"partnerName"`
// // 登录账号
// Account string `json:"account"`
// 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
PartnerCategory int `json:"partnerCategory"`
// 登录密码
Password string `json:"password"`
// 状态(1:启用或者0:禁用)
Status int `json:"status"`
// 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
PartnerCategory int `json:"partnerCategory"`
//创建时间
CreateAt time.Time `json:"createAt"`
//更新时间
... ...
package repository
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction"
)
type OrderRepository struct {
transactionContext *transaction.TransactionContext
}
var (
_ domain.OrderRepository = (*OrderRepository)(nil)
)
func NewOrderRepository(transactionContext *transaction.TransactionContext) (*OrderRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
}
return &OrderRepository{transactionContext: transactionContext}, nil
}
func (reponsitory OrderRepository) transformPgModelToDomainModel(adminuserModel *models.Order) (domain.Order, error) {
result := domain.Order{}
return result, nil
}
func (repository OrderRepository) Save(orderInfo *domain.Order) error {
return nil
}
func (repository OrderRepository) Find() (*domain.Order, error) {
return nil, nil
}
func (repository OrderRepository) FindOne() ([]domain.Order, error) {
return nil, nil
}
... ...
... ... @@ -18,12 +18,14 @@ var (
func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerInfoModel *models.PartnerInfo) (domain.PartnerInfo, error) {
m := domain.PartnerInfo{
Id: partnerInfoModel.Id,
PartnerName: partnerInfoModel.PartnerName,
Account: partnerInfoModel.Account,
Partner: domain.Partner{
Id: partnerInfoModel.Id,
PartnerName: partnerInfoModel.PartnerName,
Account: partnerInfoModel.Account,
},
PartnerCategory: partnerInfoModel.PartnerCategory,
Password: partnerInfoModel.Password,
Status: partnerInfoModel.Status,
PartnerCategory: partnerInfoModel.PartnerCategory,
CreateAt: partnerInfoModel.CreateAt,
Salesman: partnerInfoModel.Salesman,
RegionInfo: partnerInfoModel.RegionInfo,
... ... @@ -45,9 +47,9 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
tx = repository.transactionContext.PgTx
)
m := &models.PartnerInfo{
Id: dm.Id,
PartnerName: dm.PartnerName,
Account: dm.Account,
Id: dm.Partner.Id,
PartnerName: dm.Partner.PartnerName,
Account: dm.Partner.Account,
Password: dm.Password,
Status: dm.Status,
PartnerCategory: dm.PartnerCategory,
... ... @@ -57,7 +59,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
}
if m.Id == 0 {
err = tx.Insert(m)
dm.Id = m.Id
dm.Partner.Id = m.Id
if err != nil {
return nil, err
}
... ...
... ... @@ -167,8 +167,8 @@ func (c *PartnerInfoController) GetPartnerInfo() {
}
//数据适配
rspResult := map[string]interface{}{
"account": partnerInfo.Account,
"partnerName": partnerInfo.PartnerName,
"account": partnerInfo.Partner.Account,
"partnerName": partnerInfo.Partner.PartnerName,
"partnerType": partnerInfo.PartnerCategory,
"area": partnerInfo.RegionInfo.RegionName,
"salesmanName": "",
... ... @@ -176,7 +176,7 @@ func (c *PartnerInfoController) GetPartnerInfo() {
"createTime": partnerInfo.CreateAt.Local().Format("2006-01-02 15:04:05"),
"cooperationTime": partnerInfo.CooperateTime.Local().Format("2006-01-02"),
"state": partnerInfo.Status,
"id": partnerInfo.Id,
"id": partnerInfo.Partner.Id,
}
if len(partnerInfo.Salesman) > 0 {
rspResult["salesmanName"] = partnerInfo.Salesman[0].Name
... ... @@ -269,9 +269,9 @@ func (c *PartnerInfoController) ListPartnerInfo() {
resp := []map[string]interface{}{}
for i := range partners {
m := map[string]interface{}{
"id": partners[i].Id,
"account": partners[i].Account,
"partnerName": partners[i].PartnerName,
"id": partners[i].Partner.Id,
"account": partners[i].Partner.Account,
"partnerName": partners[i].Partner.PartnerName,
"area": partners[i].RegionInfo.RegionName,
"createTime": partners[i].CreateAt.Local().Format("2006-01-02 15:04:05"),
"cooperationTime": partners[i].CooperateTime.Local().Format("2006-01-02"),
... ...