作者 yangfu
正在显示 26 个修改的文件 包含 647 行增加264 行删除
@@ -4,6 +4,7 @@ go 1.16 @@ -4,6 +4,7 @@ go 1.16
4 4
5 require ( 5 require (
6 github.com/beego/beego/v2 v2.0.1 6 github.com/beego/beego/v2 v2.0.1
  7 + github.com/boombuler/barcode v1.0.1
7 github.com/dgrijalva/jwt-go v3.2.0+incompatible 8 github.com/dgrijalva/jwt-go v3.2.0+incompatible
8 github.com/go-pg/pg/v10 v10.10.1 9 github.com/go-pg/pg/v10 v10.10.1
9 github.com/go-redis/redis v6.14.2+incompatible 10 github.com/go-redis/redis v6.14.2+incompatible
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type LoginCommand struct {
  10 + Phone string `json:"phone" valid:"Required"`
  11 + GrantType string `json:"grantType" valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)
  12 + Password string `json:"password"`
  13 + Captcha string `json:"captcha"`
  14 +}
  15 +
  16 +func (orgAddCommand *LoginCommand) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (orgAddCommand *LoginCommand) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(orgAddCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package dto
  2 +
  3 +type CompanyItem struct {
  4 + CompanyId int `json:"companyId,string"`
  5 + CompanyName string `json:"companyName"`
  6 +}
  7 +
  8 +type OrgItem struct {
  9 + OrganizationId int `json:"organizationId,string"`
  10 + OrganizationName string `json:"organizationName"`
  11 + CompanyId int `json:"companyId"`
  12 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  8 +)
  9 +
  10 +type GetCompanyOrgsByUserQuery struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 + Phone string `json:"phone" valid:"Required"` //手机号
  14 +}
  15 +
  16 +func (orgAddCommand *GetCompanyOrgsByUserQuery) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (orgAddCommand *GetCompanyOrgsByUserQuery) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(orgAddCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package query
  2 +
  3 +type QrcodeLoginStatusQuery struct {
  4 + Token string `json:"token"`
  5 +}
  1 +package service
  2 +
  3 +import (
  4 + "errors"
  5 +
  6 + "github.com/linmadan/egglib-go/core/application"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/auth/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/auth/dto"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/auth/query"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache"
  12 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  13 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/sms_serve"
  14 +)
  15 +
  16 +type AuthService struct{}
  17 +
  18 +//AuthLogin 用户登录
  19 +func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{}, error) {
  20 + var (
  21 + result interface{}
  22 + err error
  23 + )
  24 + switch loginCommand.GrantType {
  25 + case "signInPassword":
  26 + //账号密码登录
  27 + result, err = srv.SignInPassword(loginCommand.Phone, loginCommand.Password)
  28 + case "signInCaptcha":
  29 + //手机验证码登录
  30 + result, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha)
  31 + default:
  32 + err = errors.New("登录方式无法解析")
  33 + }
  34 + return result, err
  35 +}
  36 +
  37 +//SignInPassword 使用账号密码校验
  38 +func (srv AuthService) SignInPassword(account string, password string) (interface{}, error) {
  39 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  40 + _, err := creationUserGateway.AuthCheckPassword(allied_creation_user.ReqAuthCheckPassword{
  41 + Password: password,
  42 + Phone: account,
  43 + })
  44 + if err != nil {
  45 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  46 + }
  47 + ltoken := domain.LoginToken{
  48 + UserId: 0,
  49 + Account: account,
  50 + Platform: domain.LoginPlatformApp,
  51 + CompanyId: 0,
  52 + }
  53 + authcode, err := ltoken.GenerateAuthCode()
  54 + if err != nil {
  55 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  56 + }
  57 + result := map[string]string{
  58 + "authCode": authcode,
  59 + }
  60 + return result, nil
  61 +}
  62 +
  63 +//SignInCaptcha 使用手机验证码登录
  64 +func (srv AuthService) SignInCaptcha(phone string, captcha string) (interface{}, error) {
  65 + smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
  66 + err := smsServeGateway.CheckSmsCode(phone, captcha)
  67 + if err != nil {
  68 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  69 + }
  70 + ltoken := domain.LoginToken{
  71 + UserId: 0,
  72 + Account: phone,
  73 + Platform: domain.LoginPlatformApp,
  74 + CompanyId: 0,
  75 + }
  76 + authcode, err := ltoken.GenerateAuthCode()
  77 + if err != nil {
  78 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  79 + }
  80 + result := map[string]string{
  81 + "authCode": authcode,
  82 + }
  83 + return result, nil
  84 +}
  85 +
  86 +//GetCompanyOrgsByUser 获取登录用户的公司组织列表
  87 +func (srv AuthService) GetCompanyOrgsByUser(queryParam query.GetCompanyOrgsByUserQuery) (interface{}, error) {
  88 +
  89 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator)
  90 + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  91 + Phone: queryParam.Phone,
  92 + })
  93 + if err != nil {
  94 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  95 + }
  96 + var (
  97 + companys []dto.CompanyItem
  98 + orgs []dto.OrgItem
  99 + )
  100 +
  101 + for _, v := range result.Users {
  102 + companys = append(companys, dto.CompanyItem{
  103 + CompanyId: v.Company.CompanyId,
  104 + CompanyName: v.Company.CompanyName,
  105 + })
  106 + for _, vv := range v.UserOrg {
  107 + orgs = append(orgs, dto.OrgItem{
  108 + OrganizationId: vv.OrgID,
  109 + OrganizationName: vv.OrgName,
  110 + CompanyId: v.Company.CompanyId,
  111 + })
  112 + }
  113 + }
  114 +
  115 + data := map[string]interface{}{
  116 + "companys": companys,
  117 + "organizations": orgs,
  118 + }
  119 + return data, nil
  120 +}
  121 +
  122 +//GetQrcode 获取扫码登录需要的二维码
  123 +func (srv AuthService) GetQrcode() (interface{}, error) {
  124 + qrmsg := domain.QrcodeMessage{}
  125 + imgBase64, err := qrmsg.GenerateImageBase64()
  126 + if err != nil {
  127 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  128 + }
  129 + qrCache := cache.LoginQrcodeCache{}
  130 + err = qrCache.Save(qrmsg)
  131 + if err != nil {
  132 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  133 + }
  134 + data := map[string]interface{}{
  135 + "image": imgBase64,
  136 + "token": qrmsg.Token,
  137 + }
  138 + return data, nil
  139 +}
  140 +
  141 +//QrcodeLoginStatus 扫码登录状态
  142 +func (srv AuthService) QrcodeLoginStatus(queryParam query.QrcodeLoginStatusQuery) (interface{}, error) {
  143 + qrmsg := domain.QrcodeMessage{}
  144 + err := qrmsg.ParseToken(queryParam.Token)
  145 + if err != nil {
  146 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  147 + }
  148 + qrCache := cache.LoginQrcodeCache{}
  149 + qrmsgCache, err := qrCache.Get(qrmsg.Id)
  150 + if err != nil {
  151 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  152 + }
  153 + data := map[string]interface{}{
  154 + "isLogin": qrmsgCache.IsLogin,
  155 + }
  156 + return data, nil
  157 +}
@@ -4,84 +4,14 @@ import ( @@ -4,84 +4,14 @@ import (
4 "fmt" 4 "fmt"
5 5
6 "github.com/beego/beego/v2/core/validation" 6 "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
7 ) 9 )
8 10
9 type CreateCooperationContractCommand struct { 11 type CreateCooperationContractCommand struct {
10 - CooperationContract struct {  
11 - CooperationContractId int `json:"cooperationContractId,string"`  
12 - // 共创合约描述  
13 - Description string `json:"Description"`  
14 - // 共创合约编号  
15 - CooperationContractNumber string `json:"cooperationContractNumber"`  
16 - // 共创项目编号,  
17 - CooperationProjectNumber string `json:"cooperationProjectNumber"`  
18 - // 共创合约发起部门编码  
19 - DepartmentId string `json:"departmentId"`  
20 - // 共创合约承接对象,1员工,2共创用户,3公开  
21 - CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`  
22 - // 共创合约名称  
23 - CooperationContractName string `json:"cooperationContractName"`  
24 - // 共创模式编码,手动输入,唯一确定  
25 - CooperationModeNumber string `json:"cooperationModeNumber"`  
26 - // 共创合约发起人uid  
27 - SponsorUserId string `json:"sponsorUserId"`  
28 - } `json:"cooperationContract"`  
29 -  
30 - // 业绩分红激励规则列表  
31 - DividendsIncentivesRules []struct {  
32 - // 关联的项目合约编号  
33 - CooperationContractNumber string `json:"cooperationContractNumber"`  
34 - // 推荐人抽成比例  
35 - ReferrerPercentage float64 `json:"referrerPercentage"`  
36 - // 业务员抽成比例  
37 - SalesmanPercentage float64 `json:"salesmanPercentage"`  
38 - // 分红规则激励百分点  
39 - DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`  
40 - // 分红规则激励阶段,  
41 - DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string,"`  
42 - // 分红规则激励阶段结束  
43 - DividendsIncentivesStageEnd int `json:"dividendsIncentivesStageEnd"`  
44 - // 分红规则激励阶段开始  
45 - DividendsIncentivesStageStart int `json:"dividendsIncentivesStageStart"`  
46 - } `json:"dividendsIncentivesRules"`  
47 - // 金额激励规则列表  
48 - MoneyIncentivesRules []struct {  
49 - // 金额激励规则ID  
50 - MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string,"`  
51 - // 关联的共创合约编号  
52 - CooperationContractNumber string `json:"cooperationContractNumber"`  
53 - // 激励金额  
54 - MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`  
55 - // 金额激励阶段,  
56 - MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string,"`  
57 - // 金额激励规则时间  
58 - MoneyIncentivesTime int `json:"moneyIncentivesTime"`  
59 - // 推荐人抽成比例  
60 - ReferrerPercentage float64 `json:"referrerPercentage"`  
61 - // 业务员抽成比例  
62 - SalesmanPercentage float64 `json:"salesmanPercentage"`  
63 - } `json:"moneyIncentivesRules"`  
64 -  
65 - // 关联用户id  
66 - RelationUser []int `json:"relationUser"`  
67 - //承接人列表  
68 - ContractUndertaker []struct {  
69 - HasReferrer bool `json:"hasReferrer"`  
70 - HasSalesman bool `json:"hasSalesman"`  
71 - UsersId int `json:"usersId,string,"`  
72 - ReferrerUser struct {  
73 - UserId int `json:"userId,string,"`  
74 - } `json:"referrerUser"`  
75 - SalesmanUser struct {  
76 - UserId int `json:"userId"`  
77 - } `json:"salesmanUser"`  
78 - Attachment []struct {  
79 - Name string `json:"name"`  
80 - Type string `json:"type"`  
81 - Url string `json:"url"`  
82 - FileSize int `json:"fileSize"`  
83 - } `json:"attachment"`  
84 - } `json:"contractUndertaker"` 12 + //操作人
  13 + Operator domain.Operator `json:"-"`
  14 + allied_creation_cooperation.ReqCooperationContractAdd
85 } 15 }
86 16
87 func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) { 17 func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) {
@@ -4,9 +4,12 @@ import ( @@ -4,9 +4,12 @@ import (
4 "fmt" 4 "fmt"
5 5
6 "github.com/beego/beego/v2/core/validation" 6 "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
7 ) 8 )
8 9
9 type EnableCooperationContractCommand struct { 10 type EnableCooperationContractCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
10 // 共创合约ID 13 // 共创合约ID
11 CooperationContractId []string `json:"cooperationContractId" valid:"Required"` 14 CooperationContractId []string `json:"cooperationContractId" valid:"Required"`
12 // 暂停和恢复的状态 15 // 暂停和恢复的状态
@@ -2,87 +2,16 @@ package command @@ -2,87 +2,16 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "time"  
6 5
7 "github.com/beego/beego/v2/core/validation" 6 "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
8 ) 9 )
9 10
10 type UpdateCooperationContractCommand struct { 11 type UpdateCooperationContractCommand struct {
11 - CooperationContract struct {  
12 - CooperationContractId int `json:"cooperationContractId,string"`  
13 - // 共创合约描述  
14 - Description string `json:"Description"`  
15 - // 共创合约编号  
16 - CooperationContractNumber string `json:"cooperationContractNumber"`  
17 - // 共创项目编号,  
18 - CooperationProjectNumber string `json:"cooperationProjectNumber"`  
19 - // 共创合约发起部门编码  
20 - DepartmentId string `json:"departmentId"`  
21 - // 共创合约承接对象,1员工,2共创用户,3公开  
22 - CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`  
23 - // 共创合约名称  
24 - CooperationContractName string `json:"cooperationContractName"`  
25 - // 共创模式编码,手动输入,唯一确定  
26 - CooperationModeNumber string `json:"cooperationModeNumber"`  
27 - // 共创合约发起人uid  
28 - SponsorUserId string `json:"sponsorUserId"`  
29 - } `json:"cooperationContract"`  
30 -  
31 - // 业绩分红激励规则列表  
32 - DividendsIncentivesRules []struct {  
33 - // 关联的项目合约编号  
34 - CooperationContractNumber string `json:"cooperationContractNumber"`  
35 - // 推荐人抽成比例  
36 - ReferrerPercentage float64 `json:"referrerPercentage"`  
37 - // 业务员抽成比例  
38 - SalesmanPercentage float64 `json:"salesmanPercentage"`  
39 - // 分红规则激励百分点  
40 - DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`  
41 - // 分红规则激励阶段,  
42 - DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string,"`  
43 - // 分红规则激励阶段结束  
44 - DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"`  
45 - // 分红规则激励阶段开始  
46 - DividendsIncentivesStageStart time.Time `json:"dividendsIncentivesStageStart"`  
47 - } `json:"dividendsIncentivesRules"`  
48 - // 金额激励规则列表  
49 - MoneyIncentivesRules []struct {  
50 - // 金额激励规则ID  
51 - MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string,"`  
52 - // 关联的共创合约编号  
53 - CooperationContractNumber string `json:"cooperationContractNumber"`  
54 - // 激励金额  
55 - MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`  
56 - // 金额激励阶段,  
57 - MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string,"`  
58 - // 金额激励规则时间  
59 - MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`  
60 - // 推荐人抽成比例  
61 - ReferrerPercentage float64 `json:"referrerPercentage"`  
62 - // 业务员抽成比例  
63 - SalesmanPercentage float64 `json:"salesmanPercentage"`  
64 - } `json:"moneyIncentivesRules"`  
65 -  
66 - // 关联用户id  
67 - RelationUser []int `json:"relationUser"`  
68 - //承接人列表  
69 - ContractUndertaker []struct {  
70 - HasReferrer bool `json:"hasReferrer"`  
71 - HasSalesman bool `json:"hasSalesman"`  
72 - UsersId int `json:"usersId,string,"`  
73 - ReferrerUser struct {  
74 - UserId int `json:"userId,string,"`  
75 - } `json:"referrerUser"`  
76 - SalesmanUser struct {  
77 - UserId int `json:"userId"`  
78 - } `json:"salesmanUser"`  
79 - Attachment []struct {  
80 - Name string `json:"name"`  
81 - Type string `json:"type"`  
82 - Url string `json:"url"`  
83 - FileSize int `json:"fileSize"`  
84 - } `json:"attachment"`  
85 - } `json:"contractUndertaker"` 12 + //操作人
  13 + Operator domain.Operator `json:"-"`
  14 + allied_creation_cooperation.ReqCooperationContractUpdate
86 } 15 }
87 16
88 func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) { 17 func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {
  1 +package dto
  2 +
  3 +import "time"
  4 +
  5 +type CooperationContractItem struct {
  6 + CooperationContractId int `json:"cooperationContractId,string,"`
  7 + CooperationContractNumber string `json:"cooperationContractNumber"` //合约编号
  8 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  9 + CooperationContractName string `json:"CooperationContractName"` //合约名称
  10 + Department string `json:"department"`
  11 + IncentivesType string `json:"incentivesType"` //Incentives激励方式
  12 + CooperationContractSponsor struct {
  13 + UserId int `json:"userId,string,"`
  14 + UserName string `json:"userName"`
  15 + } `json:"cooperationContractSponsor"` //共创发起人
  16 + CooperationMode struct {
  17 + CooperationModeId int `json:"cooperationModeId,string,"` // 共创模式ID
  18 + CooperationModeNumber string `json:"cooperationModeNumber"` // 共创模式编码,
  19 + CooperationModeName string `json:"cooperationModeName"` // 模式名称,
  20 + } `json:"cooperationMode"` //共创模式
  21 + Status int `json:"status"` //合约状态
  22 + CreateTtime time.Time `json:"createTtime"`
  23 + Org struct {
  24 + OrgId int `json:"orgId"` //发部门, id
  25 + OrgName string `json:"orgName"` //发起企业
  26 + } `json:"org"` //组织结构
  27 +}
  28 +
  29 +type CooperationContractInfo struct {
  30 +}
@@ -4,11 +4,14 @@ import ( @@ -4,11 +4,14 @@ import (
4 "fmt" 4 "fmt"
5 5
6 "github.com/beego/beego/v2/core/validation" 6 "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
7 ) 8 )
8 9
9 type GetCooperationContractQuery struct { 10 type GetCooperationContractQuery struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
10 // 共创合约ID 13 // 共创合约ID
11 - CooperationContractId int `json:"cooperationContractId" valid:"Required"` 14 + CooperationContractId int `json:"cooperationContractId,string" valid:"Required"`
12 } 15 }
13 16
14 func (getCooperationContractQuery *GetCooperationContractQuery) Valid(validation *validation.Validation) { 17 func (getCooperationContractQuery *GetCooperationContractQuery) Valid(validation *validation.Validation) {
@@ -4,9 +4,12 @@ import ( @@ -4,9 +4,12 @@ import (
4 "fmt" 4 "fmt"
5 5
6 "github.com/beego/beego/v2/core/validation" 6 "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
7 ) 8 )
8 9
9 type ListCooperationContractQuery struct { 10 type ListCooperationContractQuery struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
10 // 查询偏离量 13 // 查询偏离量
11 PageNumber int `json:"pageNumber"` 14 PageNumber int `json:"pageNumber"`
12 // 查询限制 15 // 查询限制
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/command" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/command"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/query" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
7 ) 8 )
8 9
9 // 共创合约管理 10 // 共创合约管理
@@ -15,7 +16,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -15,7 +16,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
15 if err := createCooperationContractCommand.ValidateCommand(); err != nil { 16 if err := createCooperationContractCommand.ValidateCommand(); err != nil {
16 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 17 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
17 } 18 }
18 - return nil, nil 19 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createCooperationContractCommand.Operator)
  20 + _, err := creationCooperationGateway.CooperationContractAdd(createCooperationContractCommand.ReqCooperationContractAdd)
  21 + if err != nil {
  22 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  23 + }
  24 + return createCooperationContractCommand, err
19 } 25 }
20 26
21 // 暂停恢复共创合约 27 // 暂停恢复共创合约
@@ -32,7 +38,14 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont @@ -32,7 +38,14 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
32 if err := getCooperationContractQuery.ValidateQuery(); err != nil { 38 if err := getCooperationContractQuery.ValidateQuery(); err != nil {
33 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 39 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
34 } 40 }
35 - return nil, nil 41 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(getCooperationContractQuery.Operator)
  42 + result, err := creationCooperationGateway.CooperationContractGet(allied_creation_cooperation.ReqCooperationContractGet{
  43 + CooperationContractId: getCooperationContractQuery.CooperationContractId,
  44 + })
  45 + if err != nil {
  46 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  47 + }
  48 + return result, nil
36 } 49 }
37 50
38 // 返回共创合约管理列表 51 // 返回共创合约管理列表
@@ -40,6 +53,12 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon @@ -40,6 +53,12 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
40 if err := listCooperationContractQuery.ValidateQuery(); err != nil { 53 if err := listCooperationContractQuery.ValidateQuery(); err != nil {
41 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 54 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
42 } 55 }
  56 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listCooperationContractQuery.Operator)
  57 + result, err := creationCooperationGateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{})
  58 + if err != nil {
  59 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  60 + }
  61 + _ = result
43 return nil, nil 62 return nil, nil
44 } 63 }
45 64
@@ -2,11 +2,10 @@ package command @@ -2,11 +2,10 @@ package command
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"  
6 ) 5 )
7 6
8 type RemoveDividendsReturnedOrderCommand struct { 7 type RemoveDividendsReturnedOrderCommand struct {
9 //操作人 8 //操作人
10 Operator domain.Operator `json:"-"` 9 Operator domain.Operator `json:"-"`
11 - allied_creation_cooperation.ReqDividendsReturnedOrderRemove 10 + DividendsReturnedOrderID []string `json:"dividendsReturnedOrderId"` //分红退货单记录id
12 } 11 }
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "strconv"
  5 +
4 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsReturnedOrder/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsReturnedOrder/command"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsReturnedOrder/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/dividendsReturnedOrder/query"
@@ -37,7 +39,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends @@ -37,7 +39,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends
37 // 移除分红退货单服务 39 // 移除分红退货单服务
38 func (dividendsReturnedOrderService *DividendsReturnedOrderService) RemoveDividendsReturnedOrder(removeDividendsReturnedOrderCommand *command.RemoveDividendsReturnedOrderCommand) (interface{}, error) { 40 func (dividendsReturnedOrderService *DividendsReturnedOrderService) RemoveDividendsReturnedOrder(removeDividendsReturnedOrderCommand *command.RemoveDividendsReturnedOrderCommand) (interface{}, error) {
39 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsReturnedOrderCommand.Operator) 41 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsReturnedOrderCommand.Operator)
40 - _, err := creationCooperationGateway.DividendsReturnedOrderRemove(removeDividendsReturnedOrderCommand.ReqDividendsReturnedOrderRemove) 42 + ids := []int{}
  43 + for _, v := range removeDividendsReturnedOrderCommand.DividendsReturnedOrderID {
  44 + id, _ := strconv.Atoi(v)
  45 + ids = append(ids, id)
  46 + }
  47 + _, err := creationCooperationGateway.DividendsReturnedOrderBatchRemove(allied_creation_cooperation.ReqDividendsReturnedOrderBatchRemove{
  48 + DividendsReturnedOrderIDs: ids,
  49 + })
41 if err != nil { 50 if err != nil {
42 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 51 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
43 } 52 }
  1 +package domain
  2 +
  3 +import (
  4 + "bytes"
  5 + "encoding/base64"
  6 + "fmt"
  7 + "image/png"
  8 + "time"
  9 +
  10 + "github.com/boombuler/barcode"
  11 + "github.com/boombuler/barcode/qr"
  12 + jwt "github.com/dgrijalva/jwt-go"
  13 +)
  14 +
  15 +const (
  16 + qrcodeTokenSecret string = "bbe35ad433dd8e67"
  17 + qrcodeCodeExpire int64 = 60 * 30 //15分钟过期
  18 +)
  19 +
  20 +type QrcodeMessage struct {
  21 + jwt.StandardClaims
  22 + Id string `json:"id"`
  23 + Token string `json:"token"`
  24 + IsLogin bool `json:"isLogin"`
  25 + //用户id
  26 + UserId int64 `json:"userId"`
  27 + UserBaseId int64 `json:"userBaseId"`
  28 + // 账号
  29 + Account string `json:"account"`
  30 + // 公司id
  31 + CompanyId int64 `json:"companyId"`
  32 + // 组织id
  33 + OrgId int64 `json:"orgId"`
  34 +}
  35 +
  36 +func (qrmsg *QrcodeMessage) GenerateImageBase64() ([]byte, error) {
  37 + nowTime := time.Now().Unix()
  38 + qrmsg.StandardClaims = jwt.StandardClaims{
  39 + NotBefore: nowTime,
  40 + IssuedAt: nowTime,
  41 + ExpiresAt: nowTime + qrcodeCodeExpire,
  42 + Issuer: "allied_creation_gateway",
  43 + }
  44 + qrmsg.Id = fmt.Sprintf("%d", time.Now().UnixNano())
  45 + token := jwt.NewWithClaims(jwt.SigningMethodHS256, *qrmsg)
  46 + str, err := token.SignedString([]byte(qrcodeTokenSecret))
  47 + if err != nil {
  48 + return nil, err
  49 + }
  50 + //初始化数据
  51 + qrmsg.Token = str
  52 + qrmsg.IsLogin = false
  53 +
  54 + qrCode, err := qr.Encode(str, qr.M, qr.Auto)
  55 + if err != nil {
  56 + return nil, err
  57 + }
  58 + qrCode, err = barcode.Scale(qrCode, 200, 200)
  59 + if err != nil {
  60 + return nil, err
  61 + }
  62 + var buf bytes.Buffer
  63 + err = png.Encode(&buf, qrCode)
  64 + if err != nil {
  65 + return nil, err
  66 + }
  67 + var result []byte
  68 + base64.StdEncoding.Encode(result, buf.Bytes())
  69 + return result, err
  70 +}
  71 +
  72 +func (qrmsg *QrcodeMessage) ParseToken(str string) error {
  73 + tokenClaims, err := jwt.ParseWithClaims(
  74 + str,
  75 + qrmsg,
  76 + func(token *jwt.Token) (interface{}, error) {
  77 + return []byte(loginTokenSecret), nil
  78 + })
  79 + if err != nil {
  80 + return err
  81 + }
  82 + if claim, ok := tokenClaims.Claims.(*QrcodeMessage); ok && tokenClaims.Valid {
  83 + *qrmsg = *claim
  84 + }
  85 + return nil
  86 +}
1 package cache 1 package cache
2 2
  3 +import (
  4 + "encoding/json"
  5 + "time"
  6 +
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  8 +)
  9 +
3 //二维码信息缓存 10 //二维码信息缓存
4 type LoginQrcodeCache struct { 11 type LoginQrcodeCache struct {
5 } 12 }
  13 +
  14 +func (lq LoginQrcodeCache) keyString(str string) string {
  15 + str1 := KEY_PREFIX + "login:qrcode:" + str
  16 + return str1
  17 +}
  18 +
  19 +func (lq LoginQrcodeCache) Save(qrcode domain.QrcodeMessage) error {
  20 + nowTime := time.Now().Unix()
  21 + exp := qrcode.ExpiresAt - nowTime
  22 + if exp <= 0 {
  23 + exp = 60 * 60 * 2
  24 + }
  25 + key := lq.keyString(qrcode.Id)
  26 + bt, _ := json.Marshal(qrcode)
  27 + result := clientRedis.Set(key, string(bt), time.Duration(exp))
  28 + return result.Err()
  29 +}
  30 +
  31 +func (lq LoginQrcodeCache) Remove(id string) error {
  32 + keyStr := lq.keyString(id)
  33 + result := clientRedis.Del(keyStr)
  34 + return result.Err()
  35 +}
  36 +
  37 +func (lq LoginQrcodeCache) Get(id string) (*domain.QrcodeMessage, error) {
  38 + keyStr := lq.keyString(id)
  39 + result := clientRedis.Get(keyStr)
  40 + re, _ := result.Result()
  41 + var data domain.QrcodeMessage
  42 + err := json.Unmarshal([]byte(re), &data)
  43 + if err != nil {
  44 + return nil, err
  45 + }
  46 + return &data, err
  47 +}
@@ -40,37 +40,6 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimateIncentive(param @@ -40,37 +40,6 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimateIncentive(param
40 return &data, err 40 return &data, err
41 } 41 }
42 42
43 -// DividendsEstimateAdd 创建分红预算  
44 -func (gateway HttplibAlliedCreationCooperation) DividendsEstimateAdd(param ReqDividendsEstimateAdd) (*DataDividendsEstimateAdd, error) {  
45 - url := gateway.baseUrL + "/dividends-estimates"  
46 - method := "POST"  
47 - req := gateway.CreateRequest(url, method)  
48 - log.Logger.Debug("向业务模块请求数据:创建分红预算。", map[string]interface{}{  
49 - "api": method + ":" + url,  
50 - "param": param,  
51 - })  
52 - req, err := req.JSONBody(param)  
53 - if err != nil {  
54 - return nil, fmt.Errorf("请求创建分红预算失败:%w", err)  
55 - }  
56 -  
57 - byteResult, err := req.Bytes()  
58 - if err != nil {  
59 - return nil, fmt.Errorf("获取创建分红预算失败:%w", err)  
60 - }  
61 - log.Logger.Debug("获取业务模块请求数据:创建分红预算。", map[string]interface{}{  
62 - "result": string(byteResult),  
63 - })  
64 - var result service_gateway.GatewayResponse  
65 - err = json.Unmarshal(byteResult, &result)  
66 - if err != nil {  
67 - return nil, fmt.Errorf("解析创建分红预算:%w", err)  
68 - }  
69 - var data DataDividendsEstimateAdd  
70 - err = gateway.GetResponseData(result, &data)  
71 - return &data, err  
72 -}  
73 -  
74 // DividendsEstimateUpdate 更新分红预算 43 // DividendsEstimateUpdate 更新分红预算
75 func (gateway HttplibAlliedCreationCooperation) DividendsEstimateUpdate(param ReqDividendsEstimateUpdate) (*DataDividendsEstimateUpdate, error) { 44 func (gateway HttplibAlliedCreationCooperation) DividendsEstimateUpdate(param ReqDividendsEstimateUpdate) (*DataDividendsEstimateUpdate, error) {
76 url := gateway.baseUrL + "/dividends-estimates/{dividendsEstimateId}" 45 url := gateway.baseUrL + "/dividends-estimates/{dividendsEstimateId}"
@@ -198,8 +198,8 @@ func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderGet(param @@ -198,8 +198,8 @@ func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderGet(param
198 } 198 }
199 199
200 // DividendsReturnedOrderBatchRemove 批量移除分红退货单 200 // DividendsReturnedOrderBatchRemove 批量移除分红退货单
201 -func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderBatchRemove(param ReqDividendsReturnedOrderRemove) (  
202 - *DataDividendsReturnedOrderRemove, error) { 201 +func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderBatchRemove(param ReqDividendsReturnedOrderBatchRemove) (
  202 + *DataDividendsReturnedOrderBatchRemove, error) {
203 url := gateway.baseUrL + "/dividends-returned-orders/batch-remove" 203 url := gateway.baseUrL + "/dividends-returned-orders/batch-remove"
204 method := "POST" 204 method := "POST"
205 req := gateway.CreateRequest(url, method) 205 req := gateway.CreateRequest(url, method)
@@ -224,7 +224,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderBatchRemov @@ -224,7 +224,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsReturnedOrderBatchRemov
224 if err != nil { 224 if err != nil {
225 return nil, fmt.Errorf("解析移除分红退货单:%w", err) 225 return nil, fmt.Errorf("解析移除分红退货单:%w", err)
226 } 226 }
227 - var data DataDividendsReturnedOrderRemove 227 + var data DataDividendsReturnedOrderBatchRemove
228 err = gateway.GetResponseData(result, &data) 228 err = gateway.GetResponseData(result, &data)
229 return &data, err 229 return &data, err
230 } 230 }
1 package allied_creation_cooperation 1 package allied_creation_cooperation
2 2
3 -import "time" 3 +import (
  4 + "time"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 +)
4 8
5 //创建共创合约 9 //创建共创合约
6 type ( 10 type (
7 - ReqCooperationContractAdd struct {  
8 - // 共创合约描述  
9 - CooperationContractDescription string ` json:"cooperationContractDescription"`  
10 - // 共创合约编号  
11 - CooperationContractNumber string ` json:"cooperationContractNumber"`  
12 - // 共创项目编号,  
13 - CooperationProjectNumber string `json:"cooperationProjectNumber" `  
14 - // 共创合约发起部门编码  
15 - DepartmentNumber string `json:"departmentNumber"`  
16 - // 共创合约承接对象,1员工,2共创用户,3公开  
17 - CooperationContractUndertakerType []int ` json:"cooperationContractUndertakerType"`  
18 - // 共创合约名称  
19 - CooperationContractName string `json:"cooperationContractName"`  
20 - // 共创模式编码,手动输入,唯一确定  
21 - CooperationModeNumber string ` json:"cooperationModeNumber"`  
22 - // 共创合约发起人uid  
23 - SponsorUid string `json:"sponsorUid,omitempty"`  
24 - // 业绩分红激励规则列表  
25 - DividendsIncentivesRules []struct { 11 + //分红激励规则
  12 + DividendsIncentivesRule struct {
26 // 关联的项目合约编号 13 // 关联的项目合约编号
27 CooperationContractNumber string `json:"cooperationContractNumber"` 14 CooperationContractNumber string `json:"cooperationContractNumber"`
28 // 推荐人抽成比例 15 // 推荐人抽成比例
@@ -31,47 +18,64 @@ type ( @@ -31,47 +18,64 @@ type (
31 SalesmanPercentage float64 `json:"salesmanPercentage"` 18 SalesmanPercentage float64 `json:"salesmanPercentage"`
32 // 分红规则激励百分点 19 // 分红规则激励百分点
33 DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"` 20 DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`
34 - // 分红规则激励阶段,阶段返回时需要转换为中文数字 21 + // 分红规则激励阶段,
35 DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string"` 22 DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string"`
36 // 分红规则激励阶段结束 23 // 分红规则激励阶段结束
37 DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"` 24 DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"`
38 // 分红规则激励阶段开始 25 // 分红规则激励阶段开始
39 DividendsIncentivesStageStart time.Time `json:"dividendsIncentivesStageStart"` 26 DividendsIncentivesStageStart time.Time `json:"dividendsIncentivesStageStart"`
40 - } `json:"dividendsIncentivesRules"`  
41 - // 金额激励规则列表  
42 - MoneyIncentivesRules []struct { 27 + }
  28 + //金额激励规则
  29 + MoneyIncentivesRule struct {
43 // 金额激励规则ID 30 // 金额激励规则ID
44 MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"` 31 MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"`
45 // 关联的共创合约编号 32 // 关联的共创合约编号
46 CooperationContractNumber string `json:"cooperationContractNumber"` 33 CooperationContractNumber string `json:"cooperationContractNumber"`
47 // 激励金额 34 // 激励金额
48 MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"` 35 MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
49 - // 金额激励阶段,阶段返回时需要转换为中文数字  
50 - MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string"`  
51 - // 金额激励阶段有效期结束  
52 - MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"`  
53 - // 金额激励阶段有效期开始  
54 - MoneyIncentivesStageStart time.Time `json:"moneyIncentivesStageStart"` 36 + // 金额激励阶段
  37 + MoneyIncentivesStage int `json:"moneyIncentivesStage"`
55 // 金额激励规则时间 38 // 金额激励规则时间
56 MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"` 39 MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`
57 // 推荐人抽成比例 40 // 推荐人抽成比例
58 ReferrerPercentage float64 `json:"referrerPercentage"` 41 ReferrerPercentage float64 `json:"referrerPercentage"`
59 // 业务员抽成比例 42 // 业务员抽成比例
60 SalesmanPercentage float64 `json:"salesmanPercentage"` 43 SalesmanPercentage float64 `json:"salesmanPercentage"`
61 - } `json:"moneyIncentivesRules"`  
62 - // 承接方列表  
63 - Undertakers []struct {  
64 - UserId int64 `json:"userId,string"`  
65 - // 用户基本id  
66 - UserBaseId int64 `json:"userBaseId,string"`  
67 - // 用户所属组织机构  
68 - Org struct {  
69 - // 组织机构ID  
70 - OrgId int64 `json:"orgId,string"`  
71 - // 组织名称  
72 - OrgName string `json:"orgName"`  
73 } 44 }
74 - } `json:"undertakers"` 45 +
  46 + //合约承接方
  47 + Undertaker struct {
  48 + UndertakerId string `json:"undertakerId"` //承接人用户id
  49 + RerferrerId string `json:"rerferrerId"` //推荐人用户id
  50 + SalesmanId string `json:"salesmanId"` //关联业务员id
  51 + Attachment domain.Attachment `json:"attachment"`
  52 + }
  53 +
  54 + ReqCooperationContractAdd struct {
  55 + // 共创合约描述
  56 + CooperationContractDescription string `json:"cooperationContractDescription"`
  57 + // 共创合约编号
  58 + CooperationContractNumber string `json:"cooperationContractNumber"`
  59 + // 共创项目编号,
  60 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  61 + // 共创合约发起部门id
  62 + DepartmentId string `json:"departmentId"`
  63 + // 共创合约承接对象,1员工,2共创用户,3公开
  64 + CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`
  65 + // 共创合约名称
  66 + CooperationContractName string `json:"cooperationContractName"`
  67 + // 共创模式编码,
  68 + CooperationModeNumber string `json:"cooperationModeNumber"`
  69 + // 共创合约发起人uid
  70 + SponsorUid string `json:"sponsorUid"`
  71 + // 业绩分红激励规则列表
  72 + DividendsIncentivesRules []DividendsIncentivesRule `json:"dividendsIncentivesRules"`
  73 + // 金额激励规则列表
  74 + MoneyIncentivesRules []MoneyIncentivesRule `json:"moneyIncentivesRules"`
  75 + // 承接方列表
  76 + Undertakers []Undertaker `json:"undertakers"`
  77 + //关联业务员
  78 + RelevantIds []string `json:"relevantIds"`
75 } 79 }
76 80
77 DataCooperationContractAdd struct { 81 DataCooperationContractAdd struct {
@@ -81,7 +85,31 @@ type ( @@ -81,7 +85,31 @@ type (
81 //更新共创合约 85 //更新共创合约
82 type ( 86 type (
83 ReqCooperationContractUpdate struct { 87 ReqCooperationContractUpdate struct {
84 - CooperationContractId int 88 + CooperationContractId int `json:"cooperationContractId"`
  89 + // 共创合约描述
  90 + CooperationContractDescription string `json:"cooperationContractDescription"`
  91 + // 共创合约编号
  92 + CooperationContractNumber string `json:"cooperationContractNumber"`
  93 + // 共创项目编号,
  94 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  95 + // 共创合约发起部门id
  96 + DepartmentId string `json:"departmentId"`
  97 + // 共创合约承接对象,1员工,2共创用户,3公开
  98 + CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`
  99 + // 共创合约名称
  100 + CooperationContractName string `json:"cooperationContractName"`
  101 + // 共创模式编码,
  102 + CooperationModeNumber string `json:"cooperationModeNumber"`
  103 + // 共创合约发起人uid
  104 + SponsorUid string `json:"sponsorUid,omitempty,"`
  105 + // 业绩分红激励规则列表
  106 + DividendsIncentivesRules []DividendsIncentivesRule `json:"dividendsIncentivesRules"`
  107 + // 金额激励规则列表
  108 + MoneyIncentivesRules []MoneyIncentivesRule `json:"moneyIncentivesRules"`
  109 + // 承接方列表
  110 + Undertakers []Undertaker `json:"undertakers"`
  111 + //关联业务员
  112 + RelevantIds []string `json:"relevantIds"`
85 } 113 }
86 114
87 DataCooperationContractUpdate struct { 115 DataCooperationContractUpdate struct {
@@ -91,6 +119,10 @@ type ( @@ -91,6 +119,10 @@ type (
91 //查询共创合约 119 //查询共创合约
92 type ( 120 type (
93 ReqCooperationContractSearch struct { 121 ReqCooperationContractSearch struct {
  122 + // 查询偏离量
  123 + PageNumber int `json:"pageNumber"`
  124 + // 查询限制
  125 + PageSize int `json:"pageSize" valid:"Required"`
94 } 126 }
95 127
96 DataCooperationContractSearch struct { 128 DataCooperationContractSearch struct {
@@ -100,6 +132,11 @@ type ( @@ -100,6 +132,11 @@ type (
100 //根据承接人查询并返回共创项目合约 132 //根据承接人查询并返回共创项目合约
101 type ( 133 type (
102 ReqCooperationContractSearchByUndertaker struct { 134 ReqCooperationContractSearchByUndertaker struct {
  135 + CooperationContractName string //合约名称
  136 + SponsorName string //项目发起人姓名
  137 + UserId int //合约发起人
  138 + PageNumber int
  139 + PageIndex int
103 } 140 }
104 141
105 DataCooperationContractSearchByUndertaker struct { 142 DataCooperationContractSearchByUndertaker struct {
@@ -128,7 +165,7 @@ type ( @@ -128,7 +165,7 @@ type (
128 //返回共创合约详情 165 //返回共创合约详情
129 type ( 166 type (
130 ReqCooperationContractGet struct { 167 ReqCooperationContractGet struct {
131 - CooperationContractId int 168 + CooperationContractId int `json:"cooperationContractId"`
132 } 169 }
133 170
134 DataCooperationContractGet struct { 171 DataCooperationContractGet struct {
1 package allied_creation_cooperation 1 package allied_creation_cooperation
2 2
  3 +import "time"
  4 +
3 //确定预算分红激励 5 //确定预算分红激励
4 type ( 6 type (
5 ReqDividendsEstimateIncentive struct { 7 ReqDividendsEstimateIncentive struct {
  8 + // companyId
  9 + // orgId
  10 + // userId
  11 + CooperationContractNumber string //合约编号
  12 + OrderOrReturnedOrderNum string //分红订单号/退货单号
6 } 13 }
7 14
8 DataDividendsEstimateIncentive struct { 15 DataDividendsEstimateIncentive struct {
9 } 16 }
10 ) 17 )
11 18
12 -//创建分红预算  
13 -type (  
14 - ReqDividendsEstimateAdd struct {  
15 - }  
16 -  
17 - DataDividendsEstimateAdd struct {  
18 - }  
19 -)  
20 -  
21 //更新分红预算 19 //更新分红预算
22 type ( 20 type (
23 ReqDividendsEstimateUpdate struct { 21 ReqDividendsEstimateUpdate struct {
@@ -39,9 +37,41 @@ type ( @@ -39,9 +37,41 @@ type (
39 //查询分红预算单 37 //查询分红预算单
40 type ( 38 type (
41 ReqDividendsEstimateSearch struct { 39 ReqDividendsEstimateSearch struct {
  40 + PageNumber int `json:"pageNumber"`
  41 + PageSize int `json:"pageSize"`
42 } 42 }
43 43
44 DataDividendsEstimateSearch struct { 44 DataDividendsEstimateSearch struct {
  45 + Grid struct {
  46 + Total int
  47 + List []struct {
  48 + DividendsEstimateId int64 `json:"dividendsEstimateId,string"` // 承接人分红预算记录ID
  49 + DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态
  50 + DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
  51 + DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"` // 承接人分红预算单号
  52 + DividendsEstimateTime time.Time `json:"dividendsEstimateTime"` // 分红预算时间
  53 + DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与分红类型,1承接人,2推荐人,3关联业务员
  54 + DividendsType int32 `json:"dividendsType"` // 分红类型,1订单分红,2退货冲销,3金额激励
  55 + OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` // 分红订单号或退货单号
  56 + CooperationProjectNumber string `json:"cooperationProjectNumber"` // 共创项目编号,
  57 + DividendsUser struct {
  58 + UserId int64 `json:"userId,string"` // 用户ID,
  59 + UserBaseId int64 `json:"userBaseId,string"` // 用户基本id
  60 + UserType int32 `json:"userType"` // 用户类型
  61 + } `json:"dividendsUser"` // 分红用户
  62 + Org struct {
  63 + OrgId int64 `json:"orgId,string"` // 组织机构ID
  64 + OrgName string `json:"orgName"` // 组织名称
  65 + } `json:"org"` // 数据所属组织机构
  66 + Company struct {
  67 + CompanyId int64 `json:"companyId,string"` // 公司ID,
  68 + CompanyLogo string `json:"companyLogo"` // 公司logo
  69 + CompanyName string `json:"companyName"` // 公司名称
  70 + } `json:"company"` // 公司
  71 + CreatedAt time.Time `json:"createdAt"` // 创建时间
  72 + UpdatedAt time.Time `json:"updatedAt"` // 更新时间
  73 + }
  74 + }
45 } 75 }
46 ) 76 )
47 77
@@ -108,6 +138,31 @@ type ( @@ -108,6 +138,31 @@ type (
108 } 138 }
109 139
110 DataDividendsEstimateGet struct { 140 DataDividendsEstimateGet struct {
  141 + DividendsEstimateId int64 `json:"dividendsEstimateId,string"` // 承接人分红预算记录ID
  142 + DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态
  143 + DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
  144 + DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"` // 承接人分红预算单号
  145 + DividendsEstimateTime time.Time `json:"dividendsEstimateTime"` // 分红预算时间
  146 + DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与分红类型,1承接人,2推荐人,3关联业务员
  147 + DividendsType int32 `json:"dividendsType"` // 分红类型,1订单分红,2退货冲销,3金额激励
  148 + OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` // 分红订单号或退货单号
  149 + CooperationProjectNumber string `json:"cooperationProjectNumber"` // 共创项目编号,
  150 + DividendsUser struct {
  151 + UserId int64 `json:"userId,string"` // 用户ID,
  152 + UserBaseId int64 `json:"userBaseId,string"` // 用户基本id
  153 + UserType int32 `json:"userType"` // 用户类型
  154 + } `json:"dividendsUser"` // 分红用户
  155 + Org struct {
  156 + OrgId int64 `json:"orgId,string"` // 组织机构ID
  157 + OrgName string `json:"orgName"` // 组织名称
  158 + } `json:"org"` // 数据所属组织机构
  159 + Company struct {
  160 + CompanyId int64 `json:"companyId,string"` // 公司ID,
  161 + CompanyLogo string `json:"companyLogo"` // 公司logo
  162 + CompanyName string `json:"companyName"` // 公司名称
  163 + } `json:"company"` // 公司
  164 + CreatedAt time.Time `json:"createdAt"` // 创建时间
  165 + UpdatedAt time.Time `json:"updatedAt"` // 更新时间
111 } 166 }
112 ) 167 )
113 168
@@ -110,6 +110,16 @@ type ( @@ -110,6 +110,16 @@ type (
110 } 110 }
111 ) 111 )
112 112
  113 +//批量移除分红退货单
  114 +type (
  115 + ReqDividendsReturnedOrderBatchRemove struct {
  116 + DividendsReturnedOrderIDs []int `json:"dividendsReturnedOrderIds"` //分红退货单记录id
  117 + }
  118 +
  119 + DataDividendsReturnedOrderBatchRemove struct {
  120 + }
  121 +)
  122 +
113 //返回分红退货单列表 123 //返回分红退货单列表
114 type ( 124 type (
115 ReqDividendsReturnedOrderList struct { 125 ReqDividendsReturnedOrderList struct {
@@ -19,23 +19,15 @@ func (controller *baseController) returnPageListData(count int64, data interface @@ -19,23 +19,15 @@ func (controller *baseController) returnPageListData(count int64, data interface
19 controller.Response(dataMap, err) 19 controller.Response(dataMap, err)
20 } 20 }
21 21
22 -func (controller *baseController) GetUserId() int64 {  
23 - return 1  
24 -}  
25 -  
26 -func (controller *baseController) GetCompanyId() int64 {  
27 - return 1  
28 -}  
29 -  
30 -func (controller *baseController) GetUserBaseId() int64 {  
31 - return 1  
32 -}  
33 -  
34 -func (controller *baseController) GetOrgId() int64 {  
35 - return 1  
36 -}  
37 -  
38 func (controller *baseController) GetOperator() domain.Operator { 22 func (controller *baseController) GetOperator() domain.Operator {
  23 +
  24 + // tk, _ := middleware.FormCtxLoginToken(controller.Ctx)
  25 + // operator := domain.Operator{
  26 + // UserId: tk.UserId,
  27 + // CompanyId: tk.CompanyId,
  28 + // OrgId: tk.OrgId,
  29 + // UserBaseId: tk.UserBaseId,
  30 + // }
39 return domain.Operator{ 31 return domain.Operator{
40 UserId: 9, 32 UserId: 9,
41 CompanyId: 23, 33 CompanyId: 23,
@@ -24,7 +24,7 @@ func (controller *CooperationContractController) UpdateCooperationContract() { @@ -24,7 +24,7 @@ func (controller *CooperationContractController) UpdateCooperationContract() {
24 updateCooperationContractCommand := &command.UpdateCooperationContractCommand{} 24 updateCooperationContractCommand := &command.UpdateCooperationContractCommand{}
25 controller.Unmarshal(updateCooperationContractCommand) 25 controller.Unmarshal(updateCooperationContractCommand)
26 contractId, _ := controller.GetInt(":contractId") 26 contractId, _ := controller.GetInt(":contractId")
27 - updateCooperationContractCommand.CooperationContract.CooperationContractId = contractId 27 + updateCooperationContractCommand.CooperationContractId = contractId
28 data, err := cooperationContractService.UpdateCooperationContract(updateCooperationContractCommand) 28 data, err := cooperationContractService.UpdateCooperationContract(updateCooperationContractCommand)
29 controller.Response(data, err) 29 controller.Response(data, err)
30 } 30 }
@@ -44,8 +44,6 @@ func (controller *DividendsReturnedOrderController) RemoveDividendsReturnedOrder @@ -44,8 +44,6 @@ func (controller *DividendsReturnedOrderController) RemoveDividendsReturnedOrder
44 if err != nil { 44 if err != nil {
45 log.Logger.Debug("json err:" + err.Error()) 45 log.Logger.Debug("json err:" + err.Error())
46 } 46 }
47 - projectId, _ := controller.GetInt(":projectId")  
48 - removeDividendsReturnedOrderCommand.DividendsReturnedOrderID = projectId  
49 removeDividendsReturnedOrderCommand.Operator = controller.GetOperator() 47 removeDividendsReturnedOrderCommand.Operator = controller.GetOperator()
50 data, err := dividendsReturnedOrderService.RemoveDividendsReturnedOrder(removeDividendsReturnedOrderCommand) 48 data, err := dividendsReturnedOrderService.RemoveDividendsReturnedOrder(removeDividendsReturnedOrderCommand)
51 controller.Response(data, err) 49 controller.Response(data, err)
1 package middleware 1 package middleware
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web/context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 +)
  7 +
  8 +type CtxKeyLoginToken struct{}
  9 +
  10 +func JWTAuth(ctx *context.Context) {
  11 + tokenStr := ctx.Input.Header("xxxx")
  12 + tk := domain.LoginToken{}
  13 + err := tk.ParseToken(tokenStr)
  14 + if err != nil {
  15 + //
  16 + return
  17 + }
  18 + ctx.Input.SetData(CtxKeyLoginToken{}, domain.LoginToken{})
  19 +}
  20 +
  21 +func NewCtxLoginToken(ctx *context.Context, tk domain.LoginToken) {
  22 + ctx.Input.SetData(CtxKeyLoginToken{}, domain.LoginToken{})
  23 +}
  24 +
  25 +func FormCtxLoginToken(ctx *context.Context) (domain.LoginToken, bool) {
  26 + val := ctx.Input.GetData(CtxKeyLoginToken{})
  27 + if v, ok := val.(domain.LoginToken); ok {
  28 + return v, true
  29 + }
  30 + return domain.LoginToken{}, false
  31 +}