正在显示
7 个修改的文件
包含
197 行增加
和
2 行删除
| @@ -328,7 +328,7 @@ func (service UsersService) GetUserData(userId int64, companyId int64) (map[stri | @@ -328,7 +328,7 @@ func (service UsersService) GetUserData(userId int64, companyId int64) (map[stri | ||
| 328 | Id: userId, CompanyId: companyId, | 328 | Id: userId, CompanyId: companyId, |
| 329 | }) | 329 | }) |
| 330 | if err != nil { | 330 | if err != nil { |
| 331 | - e := fmt.Sprintf("获取用户(id=%d)数据失败;%s", userId, err) | 331 | + e := fmt.Sprintf("获取用户(id=%d;company_id=%d)数据失败;%s", userId, companyId, err) |
| 332 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | 332 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) |
| 333 | } | 333 | } |
| 334 | var partnerIds []int64 | 334 | var partnerIds []int64 |
pkg/domain/business_bonus.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import "time" | ||
| 4 | + | ||
| 5 | +// 业务分红信息 是否关闭【0;否】【1:是】 | ||
| 6 | +const ( | ||
| 7 | + BUSINESS_BONUS_ENABLE int8 = 0 | ||
| 8 | + BUSINESS_BONUS_DISABLE int8 = 1 | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +// 分红状态 1:待支付分红 2:已支付分红 | ||
| 12 | +const ( | ||
| 13 | + //待支付 | ||
| 14 | + BUSINESS_BONUS_WAIT_PAY int = 1 | ||
| 15 | + //已支付 | ||
| 16 | + BUSINESS_BONUS_HAS_PAY int = 2 | ||
| 17 | +) | ||
| 18 | + | ||
| 19 | +// 业务分红信息 | ||
| 20 | +type BusinessBonus struct { | ||
| 21 | + // 唯一标识 | ||
| 22 | + Id int64 `json:"id"` | ||
| 23 | + // 公司编号 | ||
| 24 | + CompanyId int64 `json:"companyId"` | ||
| 25 | + // 合伙人信息Id | ||
| 26 | + PartnerInfoId int64 `json:"partnerInfoId"` | ||
| 27 | + // 应收分红 | ||
| 28 | + Bonus float64 `json:"bonus"` | ||
| 29 | + // 未收分红 | ||
| 30 | + BonusNot float64 `json:"bonusNot"` | ||
| 31 | + // 分红支出 | ||
| 32 | + BonusExpense float64 `json:"bonusExpense"` | ||
| 33 | + // 是否关闭【0;否】【1:是】 | ||
| 34 | + IsDisable int8 `json:"isDisable"` | ||
| 35 | + // 分红状态 1:待支付分红 2:已支付分红 | ||
| 36 | + BonusStatus int8 `json:"bonusStatus"` | ||
| 37 | + // 创建时间 | ||
| 38 | + CreateAt time.Time `json:"createAt"` | ||
| 39 | + // 更新时间 | ||
| 40 | + UpdateAt time.Time `json:"updateAt"` | ||
| 41 | + // 删除时间 | ||
| 42 | + DeleteAt time.Time `json:"deleteAt"` | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +type BusinessBonusFindOneQuery struct { | ||
| 46 | + Id int64 | ||
| 47 | + PartnerId int64 | ||
| 48 | +} | ||
| 49 | +type BusinessBonusFindQuery struct { | ||
| 50 | + Offset int | ||
| 51 | + Limit int | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +type BusinessBonusRepository interface { | ||
| 55 | + Add(dm *BusinessBonus) error | ||
| 56 | + Edit(dm *BusinessBonus) error | ||
| 57 | + FindOne(BusinessBonusFindOneQuery) (*BusinessBonus, error) | ||
| 58 | + Find(BusinessBonusFindQuery) (int, []BusinessBonus, error) | ||
| 59 | +} |
pkg/domain/service/change_user_type.go
0 → 100644
| @@ -15,7 +15,7 @@ type BusinessBonus struct { | @@ -15,7 +15,7 @@ type BusinessBonus struct { | ||
| 15 | // 公司编号 | 15 | // 公司编号 |
| 16 | CompanyId int64 | 16 | CompanyId int64 |
| 17 | // 合伙人信息Id | 17 | // 合伙人信息Id |
| 18 | - PartnerInfoId string | 18 | + PartnerInfoId int64 |
| 19 | // 应收分红 | 19 | // 应收分红 |
| 20 | Bonus float64 | 20 | Bonus float64 |
| 21 | // 未收分红 | 21 | // 未收分红 |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "errors" | ||
| 5 | + "fmt" | ||
| 6 | + | ||
| 7 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" | ||
| 9 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type BusinessBonusRepository struct { | ||
| 13 | + transactionContext *transaction.TransactionContext | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +func (repository *BusinessBonusRepository) transformPgModelToDomainModel(BusinessBonusModel *models.BusinessBonus) (domain.BusinessBonus, error) { | ||
| 17 | + m := domain.BusinessBonus{} | ||
| 18 | + return m, nil | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewBusinessBonusRepository(transactionContext *transaction.TransactionContext) (*BusinessBonusRepository, error) { | ||
| 22 | + if transactionContext == nil { | ||
| 23 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
| 24 | + } | ||
| 25 | + return &BusinessBonusRepository{transactionContext: transactionContext}, nil | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (repository *BusinessBonusRepository) Add(dm *domain.BusinessBonus) error { | ||
| 29 | + tx := repository.transactionContext.PgTx | ||
| 30 | + bonusModel := models.BusinessBonus{ | ||
| 31 | + Id: dm.Id, | ||
| 32 | + CompanyId: dm.CompanyId, | ||
| 33 | + PartnerInfoId: dm.PartnerInfoId, | ||
| 34 | + Bonus: dm.Bonus, | ||
| 35 | + BonusNot: dm.Bonus, | ||
| 36 | + BonusExpense: dm.BonusExpense, | ||
| 37 | + IsDisable: dm.IsDisable, | ||
| 38 | + BonusStatus: dm.BonusStatus, | ||
| 39 | + } | ||
| 40 | + _, err := tx.Model(&bonusModel). | ||
| 41 | + Insert() | ||
| 42 | + dm.CreateAt = bonusModel.CreateAt | ||
| 43 | + dm.UpdateAt = bonusModel.UpdateAt | ||
| 44 | + dm.Id = bonusModel.Id | ||
| 45 | + return err | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +func (repository *BusinessBonusRepository) Edit(dm *domain.BusinessBonus) error { | ||
| 49 | + tx := repository.transactionContext.PgTx | ||
| 50 | + bonusModel := models.BusinessBonus{ | ||
| 51 | + Id: dm.Id, | ||
| 52 | + CompanyId: dm.CompanyId, | ||
| 53 | + PartnerInfoId: dm.PartnerInfoId, | ||
| 54 | + Bonus: dm.Bonus, | ||
| 55 | + BonusNot: dm.Bonus, | ||
| 56 | + BonusExpense: dm.BonusExpense, | ||
| 57 | + IsDisable: dm.IsDisable, | ||
| 58 | + BonusStatus: dm.BonusStatus, | ||
| 59 | + CreateAt: dm.CreateAt, | ||
| 60 | + UpdateAt: dm.UpdateAt, | ||
| 61 | + } | ||
| 62 | + _, err := tx.Model(&bonusModel).WherePK().Update() | ||
| 63 | + return err | ||
| 64 | + | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +func (repository *BusinessBonusRepository) FindOne(queryOptions domain.BusinessBonusFindOneQuery) (*domain.BusinessBonus, error) { | ||
| 68 | + tx := repository.transactionContext.PgTx | ||
| 69 | + BusinessBonusModel := new(models.BusinessBonus) | ||
| 70 | + var hasCondition bool | ||
| 71 | + query := tx.Model(BusinessBonusModel).Where("delete_at ISNULL") | ||
| 72 | + if queryOptions.Id > 0 { | ||
| 73 | + hasCondition = true | ||
| 74 | + query = query.Where("id=?", queryOptions.Id) | ||
| 75 | + } | ||
| 76 | + if queryOptions.PartnerId > 0 { | ||
| 77 | + hasCondition = true | ||
| 78 | + query = query.Where("partner_info_id=?", queryOptions.PartnerId) | ||
| 79 | + } | ||
| 80 | + if !hasCondition { | ||
| 81 | + return nil, errors.New("没有查询条件") | ||
| 82 | + } | ||
| 83 | + if err := query.First(); err != nil { | ||
| 84 | + return nil, err | ||
| 85 | + } | ||
| 86 | + data, err := repository.transformPgModelToDomainModel(BusinessBonusModel) | ||
| 87 | + return &data, err | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +func (repository *BusinessBonusRepository) Find(queryOptions domain.BusinessBonusFindQuery) (int, []domain.BusinessBonus, error) { | ||
| 91 | + tx := repository.transactionContext.PgTx | ||
| 92 | + var ( | ||
| 93 | + err error | ||
| 94 | + cnt int | ||
| 95 | + businessBonuss []domain.BusinessBonus | ||
| 96 | + businessBonusModels []models.BusinessBonus | ||
| 97 | + ) | ||
| 98 | + query := tx.Model(&businessBonusModels) | ||
| 99 | + if cnt, err = query.SelectAndCount(); err != nil { | ||
| 100 | + return 0, businessBonuss, err | ||
| 101 | + } | ||
| 102 | + for i := range businessBonusModels { | ||
| 103 | + if businessBonus, err := repository.transformPgModelToDomainModel(&businessBonusModels[i]); err != nil { | ||
| 104 | + return 0, businessBonuss, err | ||
| 105 | + } else { | ||
| 106 | + businessBonuss = append(businessBonuss, businessBonus) | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + return cnt, businessBonuss, nil | ||
| 110 | +} |
| @@ -10,6 +10,7 @@ import ( | @@ -10,6 +10,7 @@ import ( | ||
| 10 | "github.com/astaxie/beego/logs" | 10 | "github.com/astaxie/beego/logs" |
| 11 | userCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/command" | 11 | userCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/command" |
| 12 | userService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/service" | 12 | userService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/service" |
| 13 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | ||
| 13 | ) | 14 | ) |
| 14 | 15 | ||
| 15 | type AdminLoginController struct { | 16 | type AdminLoginController struct { |
| @@ -23,7 +24,9 @@ func (c *AdminLoginController) Prepare() { | @@ -23,7 +24,9 @@ func (c *AdminLoginController) Prepare() { | ||
| 23 | urlIn := map[string]int{ | 24 | urlIn := map[string]int{ |
| 24 | "/v1/auth/captcha-init": 1, | 25 | "/v1/auth/captcha-init": 1, |
| 25 | "/v1/auth/login": 1, | 26 | "/v1/auth/login": 1, |
| 27 | + "/v1/auth/login2": 1, | ||
| 26 | } | 28 | } |
| 29 | + | ||
| 27 | nowUrl := c.Ctx.Input.URL() | 30 | nowUrl := c.Ctx.Input.URL() |
| 28 | if _, ok := urlIn[nowUrl]; ok { | 31 | if _, ok := urlIn[nowUrl]; ok { |
| 29 | //跳过校验 | 32 | //跳过校验 |
| @@ -99,6 +102,23 @@ func (c *AdminLoginController) Login() { | @@ -99,6 +102,23 @@ func (c *AdminLoginController) Login() { | ||
| 99 | return | 102 | return |
| 100 | } | 103 | } |
| 101 | 104 | ||
| 105 | +//Login2 开发临时使用 | ||
| 106 | +func (c *AdminLoginController) Login2() { | ||
| 107 | + newToken := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.` + | ||
| 108 | + `eyJleHAiOjE1OTk3NjEwNDQsImlhdCI6MTU5OTcxNzg0NCwiaXNzI` + | ||
| 109 | + `joibW1tX3BhcnRuZXJtZyIsIm5iZiI6MTU5OTcxNzg0NCwidWlkIjo` + | ||
| 110 | + `zMjU0ODUxNzgyMTYzMjAwLCJjb21wYW55SWQiOjF9.H6EKUJAtv22OZ` + | ||
| 111 | + `2R59K1xAAaqUzSROAkXfprpqoBpMX8` | ||
| 112 | + returnData := map[string]interface{}{ | ||
| 113 | + "access": map[string]interface{}{ | ||
| 114 | + "accessToken": newToken, | ||
| 115 | + "expiresIn": lib.JWtExpiresSecond, | ||
| 116 | + }, | ||
| 117 | + } | ||
| 118 | + c.ResponseData(returnData) | ||
| 119 | + return | ||
| 120 | +} | ||
| 121 | + | ||
| 102 | //CaptchaInit 极验初始化 | 122 | //CaptchaInit 极验初始化 |
| 103 | func (c *AdminLoginController) CaptchaInit() { | 123 | func (c *AdminLoginController) CaptchaInit() { |
| 104 | const ( | 124 | const ( |
| @@ -11,6 +11,7 @@ func init() { | @@ -11,6 +11,7 @@ func init() { | ||
| 11 | beego.NSRouter("/login", &controllers.AdminLoginController{}, "POST:Login"), | 11 | beego.NSRouter("/login", &controllers.AdminLoginController{}, "POST:Login"), |
| 12 | beego.NSRouter("/captcha-init", &controllers.AdminLoginController{}, "POST:CaptchaInit"), | 12 | beego.NSRouter("/captcha-init", &controllers.AdminLoginController{}, "POST:CaptchaInit"), |
| 13 | beego.NSRouter("/profile", &controllers.AdminLoginController{}, "POST:AdminpPofile"), | 13 | beego.NSRouter("/profile", &controllers.AdminLoginController{}, "POST:AdminpPofile"), |
| 14 | + beego.NSRouter("/login2", &controllers.AdminLoginController{}, "POST:Login2"), //开发临时使用 | ||
| 14 | // beego.NSRouter("/pwd-update", &controllers.AdminLoginController{}, "POST:PwdUpdate"), | 15 | // beego.NSRouter("/pwd-update", &controllers.AdminLoginController{}, "POST:PwdUpdate"), |
| 15 | ), | 16 | ), |
| 16 | beego.NSNamespace("/admin", | 17 | beego.NSNamespace("/admin", |
-
请 注册 或 登录 后发表评论