作者 tangxuhui

数据结构调整

package command
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
type RemoveCooperationContractCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创合约ID
CooperationContractId []string `json:"cooperationContractId"`
}
... ...
... ... @@ -90,14 +90,14 @@ type ContractUndertaker struct {
HasReferrer bool `json:"hasReferrer"`
HasSalesman bool `json:"hasSalesman"`
ReferrerUser struct {
UserId int `json:"userId,string"`
UserId int `json:"userId,string,"`
UserInfo domain.UserInfo `json:"userInfo"`
} `json:"referrerUser"`
SalesmanUser struct {
UserId int `json:"userId,string"`
UserId int `json:"userId,string,"`
UserInfo domain.UserInfo `json:"userInfo"`
}
UserId int `json:"userId,string"`
} `json:"salesmanUser"`
UserId int `json:"userId,string,"`
UserInfo domain.UserInfo `json:"userInfo"`
}
type CooperationContractInfo struct {
... ...
... ... @@ -223,3 +223,16 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
data := []dto.CooperationContractUndertake{{}}
return 10, data, err
}
// 移除共创合约详情
func (cooperationContractService *CooperationContractService) RemoveCooperationContract(removeCooperationContractCommand *command.RemoveCooperationContractCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeCooperationContractCommand.Operator)
_, err := creationCooperationGateway.CooperationContractBatchRemove(allied_creation_cooperation.ReqCooperationContractBatchRemove{
CooperationContractIds: removeCooperationContractCommand.CooperationContractId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return removeCooperationContractCommand, nil
}
... ...
... ... @@ -38,16 +38,16 @@ func ToCreditAccountItem(param *allied_creation_cooperation.CreditAccount) *Cred
ActuallyPaidAmount: param.ActuallyPaidAmount,
CreditAccountOrderNum: param.CreditAccountOrderNum,
PaymentStatus: param.PaymentStatus,
PaymentTime: param.PaymentTime.Unix(),
PaymentTime: param.PaymentTime.UnixNano() / 1e6,
SettlementAmount: param.SettlementAmount,
SettlementTime: param.SettlementTime.Unix(),
SettlementTime: param.SettlementTime.UnixNano() / 1e6,
CooperationContractNumber: param.CooperationContractNumber,
ParticipateType: param.ParticipateType, // 参与类型
PaymentDocumentAttachment: param.PaymentDocumentAttachment, // 支付凭证附件
Org: param.Org, // 数据所属组织机构
Company: param.Company, // 公司
CreatedAt: param.CreatedAt.Unix(), // 创建时间
UpdatedAt: param.UpdatedAt.Unix(), // 更新时间
CreatedAt: param.CreatedAt.UnixNano() / 1e6, // 创建时间
UpdatedAt: param.UpdatedAt.UnixNano() / 1e6, // 更新时间
AccountDetail: param.AccountDetail,
}
data.Participator.UserName = param.Participator.UserName
... ...
... ... @@ -16,6 +16,8 @@ type EstimateMoneyIncentivesCommand struct {
UndertakerUids []string `json:"undertakerUids,omitempty"`
//分红阶段
DividendsIncentivesStage int `json:"dividendsIncentivesStage"`
//action [1:获取预算结果] [2:确认结果保存数据]
CmdType int `json:"cmdType"`
}
func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -41,15 +41,26 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentives(estimateMoneyIncentivesCommand *command.EstimateMoneyIncentivesCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
estimateMoneyIncentivesCommand.Operator)
_, err := creationCooperationGateway.DividendsEstimatesEstimateMoneys(allied_creation_cooperation.ReqDividendsEstimateMoneyIncentives{
result, err := creationCooperationGateway.DividendsEstimatesEstimateMoneys(allied_creation_cooperation.ReqDividendsEstimateMoneyIncentives{
CooperationContractId: estimateMoneyIncentivesCommand.CooperationContractId,
DividendsIncentivesStage: estimateMoneyIncentivesCommand.DividendsIncentivesStage,
UndertakerUids: estimateMoneyIncentivesCommand.UndertakerUids,
Action: estimateMoneyIncentivesCommand.CmdType,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return estimateMoneyIncentivesCommand, nil
data := []map[string]interface{}{}
for i := range result {
item := map[string]interface{}{
"userId": result[i].DividendsUser.UserId,
"userName": result[i].DividendsUser.UserName,
"DividendsAmount": result[i].DividendsAmount,
}
data = append(data, item)
}
return data, nil
}
// 查询分红预算单列表
... ...
... ... @@ -259,3 +259,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationContractsBatchOperate
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CooperationContractBatchRemove 批量移除共创合约
func (gateway HttplibAlliedCreationCooperation) CooperationContractBatchRemove(param ReqCooperationContractBatchRemove) (*DataCooperationContractBatchRemove, error) {
url := gateway.baseUrL + "/cooperation-contracts/batch-remove"
method := "DELETE"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:移除共创合约。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求移除共创合约失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取移除共创合约失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:移除共创合约。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析移除共创合约:%w", err)
}
var data DataCooperationContractBatchRemove
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -134,7 +134,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesCancel(param R
}
// DividendsEstimatesEstimateMoneys 确定预算金额激励分红
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys(param ReqDividendsEstimateMoneyIncentives) (*DataDividendsEstimateMoneyIncentives, error) {
func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys(param ReqDividendsEstimateMoneyIncentives) (DataDividendsEstimateMoneyIncentives, error) {
url := gateway.baseUrL + "/dividends-estimates/estimate-money-incentives"
method := "POST"
req := gateway.CreateRequest(url, method)
... ... @@ -161,7 +161,7 @@ func (gateway HttplibAlliedCreationCooperation) DividendsEstimatesEstimateMoneys
}
var data DataDividendsEstimateMoneyIncentives
err = gateway.GetResponseData(result, &data)
return &data, err
return data, err
}
// DividendsEstimatesBatchCancel 批量取消分红预算
... ...
... ... @@ -245,6 +245,16 @@ type (
}
)
//移除共创合约
type (
ReqCooperationContractBatchRemove struct {
CooperationContractIds []string `json:"cooperationContractIds"`
}
DataCooperationContractBatchRemove struct {
}
)
//返回共创合约列表
type (
ReqCooperationContractList struct {
... ...
... ... @@ -131,9 +131,50 @@ type (
DividendsIncentivesStage int `json:"dividendsIncentivesStage"` //cname:"分红阶段"
// 承接人UID
UndertakerUids []string `json:"undertakerUids"` //cname:"承接人UID列表"
//action [1:获取预算结果] [2:确认结果保存数据]
Action int `json:"action"`
}
DataDividendsEstimateMoneyIncentives []struct {
// 承接人分红预算记录ID
DividendsEstimateId int64 `json:"dividendsEstimateId,string"`
// 分红结算状态,1待结算,2已结算
DividendsAccountStatus int32 `json:"dividendsAccountStatus"`
// 分红金额
DividendsAmount float64 `json:"dividendsAmount"`
// 承接人分红预算单号
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
// 分红预算时间
DividendsEstimateTime time.Time `json:"dividendsEstimateTime"`
// 参与分红类型,1承接人,2推荐人,3关联业务员
DividendsParticipateType int32 `json:"dividendsParticipateType"`
// 分红类型,1订单分红,2退货冲销,3金额激励
DividendsType int32 `json:"dividendsType"`
// 分红类型名称
DividendsTypeName string `json:"dividendsTypeName"`
// 分红订单号或退货单号
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
// 共创项目合约编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
CooperationContractNumber string `json:"cooperationContractNumber"`
// 分红用户(共创参与)
DividendsUser *struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId,string"`
// 用户类型
UserType int32 `json:"userType"`
// 用户姓名
UserName string `json:"userName"`
// 用户手机号
UserPhone string `json:"userPhone"`
} `json:"dividendsUser"`
// 分红阶段
DividendsStage int32 `json:"dividendsStage"`
// 操作时间
OperateTime time.Time `json:"operateTime"`
// 取消状态
IsCanceled bool `json:"isCanceled"`
}
)
... ...
... ... @@ -81,3 +81,14 @@ func (controller *CooperationContractController) SearchCooperationContractsByUnd
cnt, data, err := cooperationContractService.SearchCooperationContractsByUndertake(listCooperationContractQuery)
controller.ReturnPageListData(int64(cnt), data, err, listCooperationContractQuery.PageNumber)
}
func (controller *CooperationContractController) RemoveCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
removeCooperationContractCommand := &command.RemoveCooperationContractCommand{}
err := controller.Unmarshal(removeCooperationContractCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
data, err := cooperationContractService.RemoveCooperationContract(removeCooperationContractCommand)
controller.Response(data, err)
}
... ...
... ... @@ -21,7 +21,7 @@ func (controller *CreditAccountController) ListCreditAccount() {
}
listQuery.Operator = controller.GetOperator()
cnt, data, err := creditAccountService.ListCreditAccount(listQuery)
controller.ReturnListData(cnt, data, err)
controller.ReturnPageListData(cnt, data, err, listQuery.PageNumber)
}
//GetCreditAccount 返回账期结算详情
... ...
... ... @@ -10,6 +10,8 @@ func init() {
web.Router("/v1/web/cooperation-contracts/:contractId", &web_client.CooperationContractController{}, "Put:UpdateCooperationContract")
web.Router("/v1/web/cooperation-contracts/:contractId", &web_client.CooperationContractController{}, "Get:GetCooperationContract")
web.Router("/v1/web/cooperation-contracts/search", &web_client.CooperationContractController{}, "Post:ListCooperationContract")
web.Router("/v1/web/cooperation-contracts/enable", &web_client.CooperationContractController{}, "Put:EnableCooperationContract")
web.Router("/v1/web/cooperation-contracts/enable", &web_client.CooperationContractController{}, "Post:EnableCooperationContract")
web.Router("/v1/web/cooperation-contracts/undertaker", &web_client.CooperationContractController{}, "Post:SearchCooperationContractsByUndertake")
web.Router("/v1/web/cooperation-contracts/remove", &web_client.CooperationContractController{}, "Post:RemoveCooperationContract")
}
... ...