作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/partnermg into dev

... ... @@ -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,
... ...
package domain
import "time"
const (
OrderStatusReserve = iota + 1 //预定中
OrderStatusDeliverSome //部分发货
OrderStatusDeliverAll //全部发货
)
const (
OrderReal = iota + 1 //实发订单
OrderIntention //意向订单
)
//买家
type Buyer struct {
//买家姓名
BuyerName string `json:"buyerName"`
//联系方式
ContactInfo string `json:"contactInfo"`
//收获地址
ShippingAddress string `json:"shippingAddress"`
}
type Order struct {
Id int64 `json:"id"`
//订单类型
OrderType int `json:"orderType"`
//订单编号
OrderCode string `json:"orderCode"`
//订单名称
OrderName string `json:"oderName"`
//订单状态
OrderStatus int `json:"orderStatus"`
//数量
OrderCount int `json:"orderCount"`
//实际数量
OrderActualCount int `json:"orderActualCount"`
//订单金额
OrderAmount int `json:"orderAmount"`
//实际订单金额
OrderActualAmount int `json:"orderActualAmount"`
//订单已支付分红金额(货款)
OrderPaymentAmount int `json:"orderPaymentAmount"`
//订单区域信息
OrderRegionInfo *RegionInfo `json:"orderRegionInfo"`
//买家
Buyer *Buyer `json:"buyer"`
//合伙人id
PartnerId int64 `json:"PartnerId"`
//合伙人数据
PartnerInfo *PartnerInfo `json:"partnerInfo"`
//合伙人分红百分比
PartnerBonusPercent float64 `json:"partnerBonusPercent"`
//业务员分红百分比
SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
//最后查看得时间
LastViewTime time.Time `json:"lastViewTime"`
}
// type PartnerFindOneQuery struct {
// UserId int64
// AccountEqual string
// }
type OrderRepository interface {
Save(*Order) 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 models
type AdminPermission struct {
tableName struct{} `pg:"admin_permission"`
tableName struct{} `pg:"admin_permission,alias:admin_permission"`
//id
Id int `pg:",pk"`
//权限名称、菜单名称
... ...
... ... @@ -10,7 +10,7 @@ import (
)
type AdminUser struct {
tableName struct{} `pg:"admin_user"`
tableName struct{} `pg:"admin_user,alias:admin_user"`
//id
Id int64 `pg:",pk"`
//用户账号
... ...
... ... @@ -9,7 +9,7 @@ import (
)
type PartnerInfo struct {
tableName struct{} `pg:"partner_info"`
tableName struct{} `pg:"partner_info,alias:partner_info"`
// 合伙人ID
Id int64 `pg:",pk"`
// 合伙人姓名
... ...
... ... @@ -122,6 +122,7 @@ func (reponsitory AdminUserRepository) Find(queryOption domain.AdminUserFindQuer
err error
adminuserReturn = make([]domain.AdminUser, 0)
)
query = query.Order("admin_user.id DESC ")
err = query.Select()
if err != nil {
return adminuserReturn, err
... ...
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
}
... ... @@ -112,6 +114,7 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer
err error
partnerReturn = make([]domain.PartnerInfo, 0)
)
query = query.Order("partner_info.id DESC")
err = query.Select()
if err != nil {
return partnerReturn, err
... ...
... ... @@ -65,6 +65,9 @@ func (c *AdminLoginController) Login() {
c.ResponseError(errors.New("账号或密码错误"))
return
}
if !adminuser.IsUsable {
c.ResponseError(errors.New("用户被禁用"))
}
newJwt := lib.NewMyToken(adminuser.Id)
newToken, err := newJwt.CreateJWTToken()
if err != nil {
... ...
... ... @@ -165,14 +165,14 @@ func (controller *BaseController) ValidAdminPermission(permissionCode string, ex
controller.ResponseError(errors.New("无操作权限"))
return false
}
if !adminuser.IsUsable {
controller.ResponseError(errors.New("用户被禁用"))
return false
}
if adminuser.IsDefault {
logs.Debug("用户是超级管理员")
return true
}
if !adminuser.IsUsable {
controller.ResponseError(errors.New("用户被禁用"))
return false
}
for _, v := range adminuser.Permission {
if v.Code == permissionCode {
return true
... ...
... ... @@ -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"),
... ...