作者 yangfu

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

@@ -59,11 +59,13 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command @@ -59,11 +59,13 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command
59 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 59 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
60 } 60 }
61 newPartnerInfo := &domain.PartnerInfo{ 61 newPartnerInfo := &domain.PartnerInfo{
  62 + Partner: domain.Partner{
62 Account: command.Account, 63 Account: command.Account,
63 PartnerName: command.PartnerName, 64 PartnerName: command.PartnerName,
  65 + },
  66 + PartnerCategory: command.PartnerCategory,
64 Password: command.Password, 67 Password: command.Password,
65 Status: command.Status, 68 Status: command.Status,
66 - PartnerCategory: command.PartnerCategory,  
67 RegionInfo: command.RegionInfo, 69 RegionInfo: command.RegionInfo,
68 Salesman: command.Salesman, 70 Salesman: command.Salesman,
69 CooperateTime: command.CooperateTime, 71 CooperateTime: command.CooperateTime,
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +const (
  6 + OrderStatusReserve = iota + 1 //预定中
  7 + OrderStatusDeliverSome //部分发货
  8 + OrderStatusDeliverAll //全部发货
  9 +)
  10 +
  11 +const (
  12 + OrderReal = iota + 1 //实发订单
  13 + OrderIntention //意向订单
  14 +)
  15 +
  16 +//买家
  17 +type Buyer struct {
  18 + //买家姓名
  19 + BuyerName string `json:"buyerName"`
  20 + //联系方式
  21 + ContactInfo string `json:"contactInfo"`
  22 + //收获地址
  23 + ShippingAddress string `json:"shippingAddress"`
  24 +}
  25 +
  26 +type Order struct {
  27 + Id int64 `json:"id"`
  28 + //订单类型
  29 + OrderType int `json:"orderType"`
  30 + //订单编号
  31 + OrderCode string `json:"orderCode"`
  32 + //订单名称
  33 + OrderName string `json:"oderName"`
  34 + //订单状态
  35 + OrderStatus int `json:"orderStatus"`
  36 + //数量
  37 + OrderCount int `json:"orderCount"`
  38 + //实际数量
  39 + OrderActualCount int `json:"orderActualCount"`
  40 + //订单金额
  41 + OrderAmount int `json:"orderAmount"`
  42 + //实际订单金额
  43 + OrderActualAmount int `json:"orderActualAmount"`
  44 + //订单已支付分红金额(货款)
  45 + OrderPaymentAmount int `json:"orderPaymentAmount"`
  46 + //订单区域信息
  47 + OrderRegionInfo *RegionInfo `json:"orderRegionInfo"`
  48 + //买家
  49 + Buyer *Buyer `json:"buyer"`
  50 + //合伙人id
  51 + PartnerId int64 `json:"PartnerId"`
  52 + //合伙人数据
  53 + PartnerInfo *PartnerInfo `json:"partnerInfo"`
  54 + //合伙人分红百分比
  55 + PartnerBonusPercent float64 `json:"partnerBonusPercent"`
  56 + //业务员分红百分比
  57 + SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
  58 + //最后查看得时间
  59 + LastViewTime time.Time `json:"lastViewTime"`
  60 +}
  61 +
  62 +// type PartnerFindOneQuery struct {
  63 +// UserId int64
  64 +// AccountEqual string
  65 +// }
  66 +
  67 +type OrderRepository interface {
  68 + Save(*Order) error
  69 + //FindOne(qureyOptions AdminUserFindOneQuery) (*AdminUser, error)
  70 + // Find(queryOptions AdminUserFindQuery) ([]AdminUser, error)
  71 + // CountAll(queryOption AdminUserFindQuery) (int, error)
  72 +}
  1 +package domain
  2 +
  3 +type Partner struct {
  4 + // 合伙人ID
  5 + Id int64 `json:"id"`
  6 + // 合伙人姓名
  7 + PartnerName string `json:"partnerName"`
  8 + // 登录账号
  9 + Account string `json:"account"`
  10 +}
@@ -16,18 +16,20 @@ const ( @@ -16,18 +16,20 @@ const (
16 ) 16 )
17 17
18 type PartnerInfo struct { 18 type PartnerInfo struct {
19 - // 合伙人ID  
20 - Id int64 `json:"id"`  
21 - // 合伙人姓名  
22 - PartnerName string `json:"partnerName"`  
23 - // 登录账号  
24 - Account string `json:"account"` 19 + Partner Partner
  20 + // // 合伙人ID
  21 + // Id int64 `json:"id"`
  22 + // // 合伙人姓名
  23 + // PartnerName string `json:"partnerName"`
  24 + // // 登录账号
  25 + // Account string `json:"account"`
  26 + // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
  27 + PartnerCategory int `json:"partnerCategory"`
25 // 登录密码 28 // 登录密码
26 Password string `json:"password"` 29 Password string `json:"password"`
27 // 状态(1:启用或者0:禁用) 30 // 状态(1:启用或者0:禁用)
28 Status int `json:"status"` 31 Status int `json:"status"`
29 - // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)  
30 - PartnerCategory int `json:"partnerCategory"` 32 +
31 //创建时间 33 //创建时间
32 CreateAt time.Time `json:"createAt"` 34 CreateAt time.Time `json:"createAt"`
33 //更新时间 35 //更新时间
1 package models 1 package models
2 2
3 type AdminPermission struct { 3 type AdminPermission struct {
4 - tableName struct{} `pg:"admin_permission"` 4 + tableName struct{} `pg:"admin_permission,alias:admin_permission"`
5 //id 5 //id
6 Id int `pg:",pk"` 6 Id int `pg:",pk"`
7 //权限名称、菜单名称 7 //权限名称、菜单名称
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 ) 10 )
11 11
12 type AdminUser struct { 12 type AdminUser struct {
13 - tableName struct{} `pg:"admin_user"` 13 + tableName struct{} `pg:"admin_user,alias:admin_user"`
14 //id 14 //id
15 Id int64 `pg:",pk"` 15 Id int64 `pg:",pk"`
16 //用户账号 16 //用户账号
@@ -9,7 +9,7 @@ import ( @@ -9,7 +9,7 @@ import (
9 ) 9 )
10 10
11 type PartnerInfo struct { 11 type PartnerInfo struct {
12 - tableName struct{} `pg:"partner_info"` 12 + tableName struct{} `pg:"partner_info,alias:partner_info"`
13 // 合伙人ID 13 // 合伙人ID
14 Id int64 `pg:",pk"` 14 Id int64 `pg:",pk"`
15 // 合伙人姓名 15 // 合伙人姓名
@@ -122,6 +122,7 @@ func (reponsitory AdminUserRepository) Find(queryOption domain.AdminUserFindQuer @@ -122,6 +122,7 @@ func (reponsitory AdminUserRepository) Find(queryOption domain.AdminUserFindQuer
122 err error 122 err error
123 adminuserReturn = make([]domain.AdminUser, 0) 123 adminuserReturn = make([]domain.AdminUser, 0)
124 ) 124 )
  125 + query = query.Order("admin_user.id DESC ")
125 err = query.Select() 126 err = query.Select()
126 if err != nil { 127 if err != nil {
127 return adminuserReturn, err 128 return adminuserReturn, err
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
  7 + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
  8 + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction"
  9 +)
  10 +
  11 +type OrderRepository struct {
  12 + transactionContext *transaction.TransactionContext
  13 +}
  14 +
  15 +var (
  16 + _ domain.OrderRepository = (*OrderRepository)(nil)
  17 +)
  18 +
  19 +func NewOrderRepository(transactionContext *transaction.TransactionContext) (*OrderRepository, error) {
  20 + if transactionContext == nil {
  21 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  22 + }
  23 + return &OrderRepository{transactionContext: transactionContext}, nil
  24 +}
  25 +func (reponsitory OrderRepository) transformPgModelToDomainModel(adminuserModel *models.Order) (domain.Order, error) {
  26 + result := domain.Order{}
  27 + return result, nil
  28 +}
  29 +
  30 +func (repository OrderRepository) Save(orderInfo *domain.Order) error {
  31 + return nil
  32 +}
  33 +
  34 +func (repository OrderRepository) Find() (*domain.Order, error) {
  35 + return nil, nil
  36 +}
  37 +
  38 +func (repository OrderRepository) FindOne() ([]domain.Order, error) {
  39 + return nil, nil
  40 +}
@@ -18,12 +18,14 @@ var ( @@ -18,12 +18,14 @@ var (
18 18
19 func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerInfoModel *models.PartnerInfo) (domain.PartnerInfo, error) { 19 func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerInfoModel *models.PartnerInfo) (domain.PartnerInfo, error) {
20 m := domain.PartnerInfo{ 20 m := domain.PartnerInfo{
  21 + Partner: domain.Partner{
21 Id: partnerInfoModel.Id, 22 Id: partnerInfoModel.Id,
22 PartnerName: partnerInfoModel.PartnerName, 23 PartnerName: partnerInfoModel.PartnerName,
23 Account: partnerInfoModel.Account, 24 Account: partnerInfoModel.Account,
  25 + },
  26 + PartnerCategory: partnerInfoModel.PartnerCategory,
24 Password: partnerInfoModel.Password, 27 Password: partnerInfoModel.Password,
25 Status: partnerInfoModel.Status, 28 Status: partnerInfoModel.Status,
26 - PartnerCategory: partnerInfoModel.PartnerCategory,  
27 CreateAt: partnerInfoModel.CreateAt, 29 CreateAt: partnerInfoModel.CreateAt,
28 Salesman: partnerInfoModel.Salesman, 30 Salesman: partnerInfoModel.Salesman,
29 RegionInfo: partnerInfoModel.RegionInfo, 31 RegionInfo: partnerInfoModel.RegionInfo,
@@ -45,9 +47,9 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P @@ -45,9 +47,9 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
45 tx = repository.transactionContext.PgTx 47 tx = repository.transactionContext.PgTx
46 ) 48 )
47 m := &models.PartnerInfo{ 49 m := &models.PartnerInfo{
48 - Id: dm.Id,  
49 - PartnerName: dm.PartnerName,  
50 - Account: dm.Account, 50 + Id: dm.Partner.Id,
  51 + PartnerName: dm.Partner.PartnerName,
  52 + Account: dm.Partner.Account,
51 Password: dm.Password, 53 Password: dm.Password,
52 Status: dm.Status, 54 Status: dm.Status,
53 PartnerCategory: dm.PartnerCategory, 55 PartnerCategory: dm.PartnerCategory,
@@ -57,7 +59,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P @@ -57,7 +59,7 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
57 } 59 }
58 if m.Id == 0 { 60 if m.Id == 0 {
59 err = tx.Insert(m) 61 err = tx.Insert(m)
60 - dm.Id = m.Id 62 + dm.Partner.Id = m.Id
61 if err != nil { 63 if err != nil {
62 return nil, err 64 return nil, err
63 } 65 }
@@ -112,6 +114,7 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer @@ -112,6 +114,7 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer
112 err error 114 err error
113 partnerReturn = make([]domain.PartnerInfo, 0) 115 partnerReturn = make([]domain.PartnerInfo, 0)
114 ) 116 )
  117 + query = query.Order("partner_info.id DESC")
115 err = query.Select() 118 err = query.Select()
116 if err != nil { 119 if err != nil {
117 return partnerReturn, err 120 return partnerReturn, err
@@ -65,6 +65,9 @@ func (c *AdminLoginController) Login() { @@ -65,6 +65,9 @@ func (c *AdminLoginController) Login() {
65 c.ResponseError(errors.New("账号或密码错误")) 65 c.ResponseError(errors.New("账号或密码错误"))
66 return 66 return
67 } 67 }
  68 + if !adminuser.IsUsable {
  69 + c.ResponseError(errors.New("用户被禁用"))
  70 + }
68 newJwt := lib.NewMyToken(adminuser.Id) 71 newJwt := lib.NewMyToken(adminuser.Id)
69 newToken, err := newJwt.CreateJWTToken() 72 newToken, err := newJwt.CreateJWTToken()
70 if err != nil { 73 if err != nil {
@@ -165,14 +165,14 @@ func (controller *BaseController) ValidAdminPermission(permissionCode string, ex @@ -165,14 +165,14 @@ func (controller *BaseController) ValidAdminPermission(permissionCode string, ex
165 controller.ResponseError(errors.New("无操作权限")) 165 controller.ResponseError(errors.New("无操作权限"))
166 return false 166 return false
167 } 167 }
168 - if !adminuser.IsUsable {  
169 - controller.ResponseError(errors.New("用户被禁用"))  
170 - return false  
171 - }  
172 if adminuser.IsDefault { 168 if adminuser.IsDefault {
173 logs.Debug("用户是超级管理员") 169 logs.Debug("用户是超级管理员")
174 return true 170 return true
175 } 171 }
  172 + if !adminuser.IsUsable {
  173 + controller.ResponseError(errors.New("用户被禁用"))
  174 + return false
  175 + }
176 for _, v := range adminuser.Permission { 176 for _, v := range adminuser.Permission {
177 if v.Code == permissionCode { 177 if v.Code == permissionCode {
178 return true 178 return true
@@ -167,8 +167,8 @@ func (c *PartnerInfoController) GetPartnerInfo() { @@ -167,8 +167,8 @@ func (c *PartnerInfoController) GetPartnerInfo() {
167 } 167 }
168 //数据适配 168 //数据适配
169 rspResult := map[string]interface{}{ 169 rspResult := map[string]interface{}{
170 - "account": partnerInfo.Account,  
171 - "partnerName": partnerInfo.PartnerName, 170 + "account": partnerInfo.Partner.Account,
  171 + "partnerName": partnerInfo.Partner.PartnerName,
172 "partnerType": partnerInfo.PartnerCategory, 172 "partnerType": partnerInfo.PartnerCategory,
173 "area": partnerInfo.RegionInfo.RegionName, 173 "area": partnerInfo.RegionInfo.RegionName,
174 "salesmanName": "", 174 "salesmanName": "",
@@ -176,7 +176,7 @@ func (c *PartnerInfoController) GetPartnerInfo() { @@ -176,7 +176,7 @@ func (c *PartnerInfoController) GetPartnerInfo() {
176 "createTime": partnerInfo.CreateAt.Local().Format("2006-01-02 15:04:05"), 176 "createTime": partnerInfo.CreateAt.Local().Format("2006-01-02 15:04:05"),
177 "cooperationTime": partnerInfo.CooperateTime.Local().Format("2006-01-02"), 177 "cooperationTime": partnerInfo.CooperateTime.Local().Format("2006-01-02"),
178 "state": partnerInfo.Status, 178 "state": partnerInfo.Status,
179 - "id": partnerInfo.Id, 179 + "id": partnerInfo.Partner.Id,
180 } 180 }
181 if len(partnerInfo.Salesman) > 0 { 181 if len(partnerInfo.Salesman) > 0 {
182 rspResult["salesmanName"] = partnerInfo.Salesman[0].Name 182 rspResult["salesmanName"] = partnerInfo.Salesman[0].Name
@@ -269,9 +269,9 @@ func (c *PartnerInfoController) ListPartnerInfo() { @@ -269,9 +269,9 @@ func (c *PartnerInfoController) ListPartnerInfo() {
269 resp := []map[string]interface{}{} 269 resp := []map[string]interface{}{}
270 for i := range partners { 270 for i := range partners {
271 m := map[string]interface{}{ 271 m := map[string]interface{}{
272 - "id": partners[i].Id,  
273 - "account": partners[i].Account,  
274 - "partnerName": partners[i].PartnerName, 272 + "id": partners[i].Partner.Id,
  273 + "account": partners[i].Partner.Account,
  274 + "partnerName": partners[i].Partner.PartnerName,
275 "area": partners[i].RegionInfo.RegionName, 275 "area": partners[i].RegionInfo.RegionName,
276 "createTime": partners[i].CreateAt.Local().Format("2006-01-02 15:04:05"), 276 "createTime": partners[i].CreateAt.Local().Format("2006-01-02 15:04:05"),
277 "cooperationTime": partners[i].CooperateTime.Local().Format("2006-01-02"), 277 "cooperationTime": partners[i].CooperateTime.Local().Format("2006-01-02"),