作者 tangxuhui

数据结构调整

  1 +package command
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
  5 +type RemoveCooperationContractCommand struct {
  6 + //操作人
  7 + Operator domain.Operator `json:"-"`
  8 + // 共创合约ID
  9 + CooperationContractId []string `json:"cooperationContractId"`
  10 +}
@@ -90,14 +90,14 @@ type ContractUndertaker struct { @@ -90,14 +90,14 @@ type ContractUndertaker struct {
90 HasReferrer bool `json:"hasReferrer"` 90 HasReferrer bool `json:"hasReferrer"`
91 HasSalesman bool `json:"hasSalesman"` 91 HasSalesman bool `json:"hasSalesman"`
92 ReferrerUser struct { 92 ReferrerUser struct {
93 - UserId int `json:"userId,string"` 93 + UserId int `json:"userId,string,"`
94 UserInfo domain.UserInfo `json:"userInfo"` 94 UserInfo domain.UserInfo `json:"userInfo"`
95 } `json:"referrerUser"` 95 } `json:"referrerUser"`
96 SalesmanUser struct { 96 SalesmanUser struct {
97 - UserId int `json:"userId,string"` 97 + UserId int `json:"userId,string,"`
98 UserInfo domain.UserInfo `json:"userInfo"` 98 UserInfo domain.UserInfo `json:"userInfo"`
99 - }  
100 - UserId int `json:"userId,string"` 99 + } `json:"salesmanUser"`
  100 + UserId int `json:"userId,string,"`
101 UserInfo domain.UserInfo `json:"userInfo"` 101 UserInfo domain.UserInfo `json:"userInfo"`
102 } 102 }
103 type CooperationContractInfo struct { 103 type CooperationContractInfo struct {
@@ -223,3 +223,16 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC @@ -223,3 +223,16 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
223 data := []dto.CooperationContractUndertake{{}} 223 data := []dto.CooperationContractUndertake{{}}
224 return 10, data, err 224 return 10, data, err
225 } 225 }
  226 +
  227 +// 移除共创合约详情
  228 +func (cooperationContractService *CooperationContractService) RemoveCooperationContract(removeCooperationContractCommand *command.RemoveCooperationContractCommand) (interface{}, error) {
  229 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeCooperationContractCommand.Operator)
  230 + _, err := creationCooperationGateway.CooperationContractBatchRemove(allied_creation_cooperation.ReqCooperationContractBatchRemove{
  231 + CooperationContractIds: removeCooperationContractCommand.CooperationContractId,
  232 + })
  233 + if err != nil {
  234 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  235 + }
  236 +
  237 + return removeCooperationContractCommand, nil
  238 +}
@@ -38,16 +38,16 @@ func ToCreditAccountItem(param *allied_creation_cooperation.CreditAccount) *Cred @@ -38,16 +38,16 @@ func ToCreditAccountItem(param *allied_creation_cooperation.CreditAccount) *Cred
38 ActuallyPaidAmount: param.ActuallyPaidAmount, 38 ActuallyPaidAmount: param.ActuallyPaidAmount,
39 CreditAccountOrderNum: param.CreditAccountOrderNum, 39 CreditAccountOrderNum: param.CreditAccountOrderNum,
40 PaymentStatus: param.PaymentStatus, 40 PaymentStatus: param.PaymentStatus,
41 - PaymentTime: param.PaymentTime.Unix(), 41 + PaymentTime: param.PaymentTime.UnixNano() / 1e6,
42 SettlementAmount: param.SettlementAmount, 42 SettlementAmount: param.SettlementAmount,
43 - SettlementTime: param.SettlementTime.Unix(), 43 + SettlementTime: param.SettlementTime.UnixNano() / 1e6,
44 CooperationContractNumber: param.CooperationContractNumber, 44 CooperationContractNumber: param.CooperationContractNumber,
45 - ParticipateType: param.ParticipateType, // 参与类型  
46 - PaymentDocumentAttachment: param.PaymentDocumentAttachment, // 支付凭证附件  
47 - Org: param.Org, // 数据所属组织机构  
48 - Company: param.Company, // 公司  
49 - CreatedAt: param.CreatedAt.Unix(), // 创建时间  
50 - UpdatedAt: param.UpdatedAt.Unix(), // 更新时间 45 + ParticipateType: param.ParticipateType, // 参与类型
  46 + PaymentDocumentAttachment: param.PaymentDocumentAttachment, // 支付凭证附件
  47 + Org: param.Org, // 数据所属组织机构
  48 + Company: param.Company, // 公司
  49 + CreatedAt: param.CreatedAt.UnixNano() / 1e6, // 创建时间
  50 + UpdatedAt: param.UpdatedAt.UnixNano() / 1e6, // 更新时间
51 AccountDetail: param.AccountDetail, 51 AccountDetail: param.AccountDetail,
52 } 52 }
53 data.Participator.UserName = param.Participator.UserName 53 data.Participator.UserName = param.Participator.UserName
@@ -16,6 +16,8 @@ type EstimateMoneyIncentivesCommand struct { @@ -16,6 +16,8 @@ type EstimateMoneyIncentivesCommand struct {
16 UndertakerUids []string `json:"undertakerUids,omitempty"` 16 UndertakerUids []string `json:"undertakerUids,omitempty"`
17 //分红阶段 17 //分红阶段
18 DividendsIncentivesStage int `json:"dividendsIncentivesStage"` 18 DividendsIncentivesStage int `json:"dividendsIncentivesStage"`
  19 + //action [1:获取预算结果] [2:确认结果保存数据]
  20 + CmdType int `json:"cmdType"`
19 } 21 }
20 22
21 func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) Valid(validation *validation.Validation) { 23 func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) Valid(validation *validation.Validation) {
@@ -41,15 +41,26 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen @@ -41,15 +41,26 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
41 func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentives(estimateMoneyIncentivesCommand *command.EstimateMoneyIncentivesCommand) (interface{}, error) { 41 func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentives(estimateMoneyIncentivesCommand *command.EstimateMoneyIncentivesCommand) (interface{}, error) {
42 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation( 42 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
43 estimateMoneyIncentivesCommand.Operator) 43 estimateMoneyIncentivesCommand.Operator)
44 - _, err := creationCooperationGateway.DividendsEstimatesEstimateMoneys(allied_creation_cooperation.ReqDividendsEstimateMoneyIncentives{ 44 + result, err := creationCooperationGateway.DividendsEstimatesEstimateMoneys(allied_creation_cooperation.ReqDividendsEstimateMoneyIncentives{
45 CooperationContractId: estimateMoneyIncentivesCommand.CooperationContractId, 45 CooperationContractId: estimateMoneyIncentivesCommand.CooperationContractId,
46 DividendsIncentivesStage: estimateMoneyIncentivesCommand.DividendsIncentivesStage, 46 DividendsIncentivesStage: estimateMoneyIncentivesCommand.DividendsIncentivesStage,
47 UndertakerUids: estimateMoneyIncentivesCommand.UndertakerUids, 47 UndertakerUids: estimateMoneyIncentivesCommand.UndertakerUids,
  48 + Action: estimateMoneyIncentivesCommand.CmdType,
48 }) 49 })
49 if err != nil { 50 if err != nil {
50 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 51 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
51 } 52 }
52 - return estimateMoneyIncentivesCommand, nil 53 + data := []map[string]interface{}{}
  54 + for i := range result {
  55 + item := map[string]interface{}{
  56 + "userId": result[i].DividendsUser.UserId,
  57 + "userName": result[i].DividendsUser.UserName,
  58 + "DividendsAmount": result[i].DividendsAmount,
  59 + }
  60 + data = append(data, item)
  61 + }
  62 +
  63 + return data, nil
53 } 64 }
54 65
55 // 查询分红预算单列表 66 // 查询分红预算单列表
@@ -259,3 +259,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationContractsBatchOperate @@ -259,3 +259,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationContractsBatchOperate
259 err = gateway.GetResponseData(result, &data) 259 err = gateway.GetResponseData(result, &data)
260 return &data, err 260 return &data, err
261 } 261 }
  262 +
  263 +// CooperationContractBatchRemove 批量移除共创合约
  264 +func (gateway HttplibAlliedCreationCooperation) CooperationContractBatchRemove(param ReqCooperationContractBatchRemove) (*DataCooperationContractBatchRemove, error) {
  265 + url := gateway.baseUrL + "/cooperation-contracts/batch-remove"
  266 + method := "DELETE"
  267 + req := gateway.CreateRequest(url, method)
  268 + log.Logger.Debug("向业务模块请求数据:移除共创合约。", map[string]interface{}{
  269 + "api": method + ":" + url,
  270 + "param": param,
  271 + })
  272 + req, err := req.JSONBody(param)
  273 + if err != nil {
  274 + return nil, fmt.Errorf("请求移除共创合约失败:%w", err)
  275 + }
  276 +
  277 + byteResult, err := req.Bytes()
  278 + if err != nil {
  279 + return nil, fmt.Errorf("获取移除共创合约失败:%w", err)
  280 + }
  281 + log.Logger.Debug("获取业务模块请求数据:移除共创合约。", map[string]interface{}{
  282 + "result": string(byteResult),
  283 + })
  284 + var result service_gateway.GatewayResponse
  285 + err = json.Unmarshal(byteResult, &result)
  286 + if err != nil {
  287 + return nil, fmt.Errorf("解析移除共创合约:%w", err)
  288 + }
  289 + var data DataCooperationContractBatchRemove
  290 + err = gateway.GetResponseData(result, &data)
  291 + return &data, err
  292 +}
@@ -134,7 +134,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesCancel(param R @@ -134,7 +134,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesCancel(param R
134 } 134 }
135 135
136 // DividendsEstimatesEstimateMoneys 确定预算金额激励分红 136 // DividendsEstimatesEstimateMoneys 确定预算金额激励分红
137 -func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys(param ReqDividendsEstimateMoneyIncentives) (*DataDividendsEstimateMoneyIncentives, error) { 137 +func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys(param ReqDividendsEstimateMoneyIncentives) (DataDividendsEstimateMoneyIncentives, error) {
138 url := gateway.baseUrL + "/dividends-estimates/estimate-money-incentives" 138 url := gateway.baseUrL + "/dividends-estimates/estimate-money-incentives"
139 method := "POST" 139 method := "POST"
140 req := gateway.CreateRequest(url, method) 140 req := gateway.CreateRequest(url, method)
@@ -161,7 +161,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys @@ -161,7 +161,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys
161 } 161 }
162 var data DataDividendsEstimateMoneyIncentives 162 var data DataDividendsEstimateMoneyIncentives
163 err = gateway.GetResponseData(result, &data) 163 err = gateway.GetResponseData(result, &data)
164 - return &data, err 164 + return data, err
165 } 165 }
166 166
167 // DividendsEstimatesBatchCancel 批量取消分红预算 167 // DividendsEstimatesBatchCancel 批量取消分红预算
@@ -245,6 +245,16 @@ type ( @@ -245,6 +245,16 @@ type (
245 } 245 }
246 ) 246 )
247 247
  248 +//移除共创合约
  249 +type (
  250 + ReqCooperationContractBatchRemove struct {
  251 + CooperationContractIds []string `json:"cooperationContractIds"`
  252 + }
  253 +
  254 + DataCooperationContractBatchRemove struct {
  255 + }
  256 +)
  257 +
248 //返回共创合约列表 258 //返回共创合约列表
249 type ( 259 type (
250 ReqCooperationContractList struct { 260 ReqCooperationContractList struct {
@@ -131,9 +131,50 @@ type ( @@ -131,9 +131,50 @@ type (
131 DividendsIncentivesStage int `json:"dividendsIncentivesStage"` //cname:"分红阶段" 131 DividendsIncentivesStage int `json:"dividendsIncentivesStage"` //cname:"分红阶段"
132 // 承接人UID 132 // 承接人UID
133 UndertakerUids []string `json:"undertakerUids"` //cname:"承接人UID列表" 133 UndertakerUids []string `json:"undertakerUids"` //cname:"承接人UID列表"
  134 + //action [1:获取预算结果] [2:确认结果保存数据]
  135 + Action int `json:"action"`
134 } 136 }
135 137
136 DataDividendsEstimateMoneyIncentives []struct { 138 DataDividendsEstimateMoneyIncentives []struct {
  139 + // 承接人分红预算记录ID
  140 + DividendsEstimateId int64 `json:"dividendsEstimateId,string"`
  141 + // 分红结算状态,1待结算,2已结算
  142 + DividendsAccountStatus int32 `json:"dividendsAccountStatus"`
  143 + // 分红金额
  144 + DividendsAmount float64 `json:"dividendsAmount"`
  145 + // 承接人分红预算单号
  146 + DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
  147 + // 分红预算时间
  148 + DividendsEstimateTime time.Time `json:"dividendsEstimateTime"`
  149 + // 参与分红类型,1承接人,2推荐人,3关联业务员
  150 + DividendsParticipateType int32 `json:"dividendsParticipateType"`
  151 + // 分红类型,1订单分红,2退货冲销,3金额激励
  152 + DividendsType int32 `json:"dividendsType"`
  153 + // 分红类型名称
  154 + DividendsTypeName string `json:"dividendsTypeName"`
  155 + // 分红订单号或退货单号
  156 + OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
  157 + // 共创项目合约编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
  158 + CooperationContractNumber string `json:"cooperationContractNumber"`
  159 + // 分红用户(共创参与)
  160 + DividendsUser *struct {
  161 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  162 + UserId int64 `json:"userId,string"`
  163 + // 用户基本id
  164 + UserBaseId int64 `json:"userBaseId,string"`
  165 + // 用户类型
  166 + UserType int32 `json:"userType"`
  167 + // 用户姓名
  168 + UserName string `json:"userName"`
  169 + // 用户手机号
  170 + UserPhone string `json:"userPhone"`
  171 + } `json:"dividendsUser"`
  172 + // 分红阶段
  173 + DividendsStage int32 `json:"dividendsStage"`
  174 + // 操作时间
  175 + OperateTime time.Time `json:"operateTime"`
  176 + // 取消状态
  177 + IsCanceled bool `json:"isCanceled"`
137 } 178 }
138 ) 179 )
139 180
@@ -81,3 +81,14 @@ func (controller *CooperationContractController) SearchCooperationContractsByUnd @@ -81,3 +81,14 @@ func (controller *CooperationContractController) SearchCooperationContractsByUnd
81 cnt, data, err := cooperationContractService.SearchCooperationContractsByUndertake(listCooperationContractQuery) 81 cnt, data, err := cooperationContractService.SearchCooperationContractsByUndertake(listCooperationContractQuery)
82 controller.ReturnPageListData(int64(cnt), data, err, listCooperationContractQuery.PageNumber) 82 controller.ReturnPageListData(int64(cnt), data, err, listCooperationContractQuery.PageNumber)
83 } 83 }
  84 +
  85 +func (controller *CooperationContractController) RemoveCooperationContract() {
  86 + cooperationContractService := service.NewCooperationContractService(nil)
  87 + removeCooperationContractCommand := &command.RemoveCooperationContractCommand{}
  88 + err := controller.Unmarshal(removeCooperationContractCommand)
  89 + if err != nil {
  90 + log.Logger.Debug("json err:" + err.Error())
  91 + }
  92 + data, err := cooperationContractService.RemoveCooperationContract(removeCooperationContractCommand)
  93 + controller.Response(data, err)
  94 +}
@@ -21,7 +21,7 @@ func (controller *CreditAccountController) ListCreditAccount() { @@ -21,7 +21,7 @@ func (controller *CreditAccountController) ListCreditAccount() {
21 } 21 }
22 listQuery.Operator = controller.GetOperator() 22 listQuery.Operator = controller.GetOperator()
23 cnt, data, err := creditAccountService.ListCreditAccount(listQuery) 23 cnt, data, err := creditAccountService.ListCreditAccount(listQuery)
24 - controller.ReturnListData(cnt, data, err) 24 + controller.ReturnPageListData(cnt, data, err, listQuery.PageNumber)
25 } 25 }
26 26
27 //GetCreditAccount 返回账期结算详情 27 //GetCreditAccount 返回账期结算详情
@@ -10,6 +10,8 @@ func init() { @@ -10,6 +10,8 @@ func init() {
10 web.Router("/v1/web/cooperation-contracts/:contractId", &web_client.CooperationContractController{}, "Put:UpdateCooperationContract") 10 web.Router("/v1/web/cooperation-contracts/:contractId", &web_client.CooperationContractController{}, "Put:UpdateCooperationContract")
11 web.Router("/v1/web/cooperation-contracts/:contractId", &web_client.CooperationContractController{}, "Get:GetCooperationContract") 11 web.Router("/v1/web/cooperation-contracts/:contractId", &web_client.CooperationContractController{}, "Get:GetCooperationContract")
12 web.Router("/v1/web/cooperation-contracts/search", &web_client.CooperationContractController{}, "Post:ListCooperationContract") 12 web.Router("/v1/web/cooperation-contracts/search", &web_client.CooperationContractController{}, "Post:ListCooperationContract")
13 - web.Router("/v1/web/cooperation-contracts/enable", &web_client.CooperationContractController{}, "Put:EnableCooperationContract") 13 + web.Router("/v1/web/cooperation-contracts/enable", &web_client.CooperationContractController{}, "Post:EnableCooperationContract")
14 web.Router("/v1/web/cooperation-contracts/undertaker", &web_client.CooperationContractController{}, "Post:SearchCooperationContractsByUndertake") 14 web.Router("/v1/web/cooperation-contracts/undertaker", &web_client.CooperationContractController{}, "Post:SearchCooperationContractsByUndertake")
  15 + web.Router("/v1/web/cooperation-contracts/remove", &web_client.CooperationContractController{}, "Post:RemoveCooperationContract")
  16 +
15 } 17 }