作者 yangfu
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 {
... ... @@ -203,7 +203,6 @@ func ToCooperationContractInfo(param *allied_creation_cooperation.CooperationCon
UndertakerTypesUncheckedAvailable: undertakerTypesUncheckedAvailable,
}
return &data
}
type CooperationContractUndertake 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
}
... ...
... ... @@ -4,7 +4,7 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domai
type PayCreditAccountCommand struct {
Operator domain.Operator `json:"-"` //操作人
CreditAccountId int `json:"creditAccountId"` //账期结算id
CreditAccountId int `json:"creditAccountId,string"` //账期结算id
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"` //实际金额
Remarks string `json:"remarks"` //备注
Attachment domain.Attachment `json:"attachment"` //附件
... ...
... ... @@ -5,5 +5,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domai
type RemoveCreditAccountCommand struct {
//操作人
Operator domain.Operator `json:"-"`
CreditAccountId int `json:"creditAccountId"` //账期结算id
CreditAccountId int `json:"creditAccountId,string"` //账期结算id
}
... ...
... ... @@ -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
... ...
... ... @@ -11,10 +11,7 @@ import (
type EstimateDividendsIncentivesCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 分红订单号/退货单号
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
// 合约编号
CooperationContractNumber string `json:"cooperationContractNumber" `
OrderGoodIds []string `json:"orderGoodIds"`
}
func (estimateDividendsIncentivesCommand *EstimateDividendsIncentivesCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -10,12 +10,14 @@ import (
type EstimateMoneyIncentivesCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目合约编号
CooperationContractNumber string `json:"cooperationContractNumber" valid:"Required"`
// 共创项目合约id
CooperationContractId string `json:"cooperationContractId" valid:"Required"`
// 承接人UID
UndertakerUid string `json:"undertakerUid,omitempty"`
UndertakerUids []string `json:"undertakerUids,omitempty"`
//分红阶段
DividendsIncentivesStage int `json:"dividendsIncentivesStage"`
//action [1:获取预算结果] [2:确认结果保存数据]
CmdType int `json:"cmdType"`
}
func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -10,6 +10,7 @@ type MoneyIncentivesItem struct {
//业绩分红列表
type DividendsEstimateDividendItem struct {
OrderGoodId int `json:"orderGoodId,string"`
CooperationContractNumber string `json:"cooperationContractNumber"` //共创合约编号
CustomerName string `json:"customerName"` //客户名称
DividendsIncentivesAmount float64 `json:"dividendsIncentivesAmount"` //业绩激励分红金额
... ... @@ -23,6 +24,7 @@ func ToDividendsEstimateDividendItem(param *allied_creation_cooperation.DataDivi
var listdata []DividendsEstimateDividendItem
for _, v := range param.List {
item := DividendsEstimateDividendItem{
OrderGoodId: v.OrderGoodId,
CooperationContractNumber: v.CooperationContractNumber,
CustomerName: v.CustomerName,
DividendsIncentivesAmount: v.OrderAmount,
... ...
... ... @@ -29,8 +29,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
estimateDividendsIncentivesCommand.Operator)
_, err := creationCooperationGateway.DividendsEstimateDividendsIncentives(allied_creation_cooperation.ReqDividendsEstimateDividendsIncentives{
CooperationContractNumber: estimateDividendsIncentivesCommand.CooperationContractNumber,
OrderOrReturnedOrderNum: estimateDividendsIncentivesCommand.OrderOrReturnedOrderNum,
OrderGoodIds: estimateDividendsIncentivesCommand.OrderGoodIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -43,14 +42,25 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
estimateMoneyIncentivesCommand.Operator)
result, err := creationCooperationGateway.DividendsEstimatesEstimateMoneys(allied_creation_cooperation.ReqDividendsEstimateMoneyIncentives{
CooperationContractNumber: estimateMoneyIncentivesCommand.CooperationContractNumber,
CooperationContractId: estimateMoneyIncentivesCommand.CooperationContractId,
DividendsIncentivesStage: estimateMoneyIncentivesCommand.DividendsIncentivesStage,
UndertakerUid: estimateMoneyIncentivesCommand.UndertakerUid,
UndertakerUids: estimateMoneyIncentivesCommand.UndertakerUids,
Action: estimateMoneyIncentivesCommand.CmdType,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, 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
}
// 查询分红预算单列表
... ... @@ -111,7 +121,7 @@ func NewDividendsEstimateService(options map[string]interface{}) *DividendsEstim
return newDividendsEstimateService
}
func (dividendsEmmateService *DividendsEstimateService) MoneyIncentivesSelector(queryParam query.MoneyIncentiveSelectorQuery) (interface{}, error) {
func (dividendsEmmateService *DividendsEstimateService) MoneyIncentivesSelector(queryParam *query.MoneyIncentiveSelectorQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
queryParam.Operator)
resultContract, err := creationCooperationGateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
... ... @@ -134,7 +144,7 @@ func (dividendsEmmateService *DividendsEstimateService) MoneyIncentivesSelector(
for _, v := range contractData.MoneyIncentivesRules {
r := dto.MoneyIncentivesRule{
MoneyIncentivesStage: v.MoneyIncentivesStage,
MoneyIncentivesStageStart: int(v.MoneyIncentivesTime.Unix()),
MoneyIncentivesStageStart: int(v.MoneyIncentivesTime.UnixNano() / 1e6),
}
rules = append(rules, r)
}
... ...
... ... @@ -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 {
... ...
... ... @@ -15,7 +15,7 @@ type (
Total int `json:"total"`
List []struct {
// 分红订单产品ID
OrderGoodId int64 `json:"orderGoodId,string"`
OrderGoodId int `json:"orderGoodId,string"`
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 分红订单号或退货单号、
... ... @@ -29,7 +29,7 @@ type (
// 订单金额
OrderAmount float64 `json:"orderAmount"`
// 订单/退货单日期
OrderDate time.Time `json:"-"` //TODO 等待数据调整
OrderDate time.Time `json:"orderData"`
} `json:"list"`
}
)
... ... @@ -125,13 +125,56 @@ type (
//确定预算金额激励分红
type (
ReqDividendsEstimateMoneyIncentives struct {
//合约编码
// 共创合约ID
CooperationContractId string `json:"cooperationContractId"` //cname:"共创合约ID"
// 分红阶段
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"`
DividendsIncentivesStage int `json:"dividendsIncentivesStage"`
UndertakerUid string `json:"undertakerUid"`
}
DataDividendsEstimateMoneyIncentives struct {
// 分红用户(共创参与)
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"`
}
)
... ... @@ -184,10 +227,9 @@ type (
//确定业绩分红激励
type (
ReqDividendsEstimateDividendsIncentives struct {
CooperationContractNumber string `json:"cooperationContractNumber"`
OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
OrderGoodIds []string `json:"orderGoodIds"`
}
DataDividendsEstimateDividendsIncentives struct {
DataDividendsEstimateDividendsIncentives []struct {
}
)
... ...
... ... @@ -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 返回账期结算详情
... ...
... ... @@ -88,3 +88,16 @@ func (controller *DividendsEstimateController) EstimateDividendsIncentives() {
data, err := dividendsEstimateService.EstimateDividendsIncentives(estimateDividendsIncentivesCommand)
controller.Response(data, err)
}
//MoneyIncentivesSelector
func (controller *DividendsEstimateController) MoneyIncentivesSelector() {
dividendsEstimateService := service.NewDividendsEstimateService(nil)
moneyIncentivesSelectorQuery := &query.MoneyIncentiveSelectorQuery{}
err := controller.Unmarshal(moneyIncentivesSelectorQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
moneyIncentivesSelectorQuery.Operator = controller.GetOperator()
data, err := dividendsEstimateService.MoneyIncentivesSelector(moneyIncentivesSelectorQuery)
controller.Response(data, err)
}
... ...
... ... @@ -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")
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
)
func init() {
web.Router("/v1/web/credit-accounts/:creditAccountId", &web_client.CreditAccountController{}, "Get:GetCreditAccount")
web.Router("/v1/web/credit-accounts/search", &web_client.CreditAccountController{}, "Post:ListCreditAccount")
web.Router("/v1/web/credit-accounts/remove", &web_client.CreditAccountController{}, "Post:RemoveCreditAccount")
web.Router("/v1/web/credit-accounts/pay", &web_client.CreditAccountController{}, "Post:PayCreditAccount")
}
... ...
... ... @@ -12,4 +12,5 @@ func init() {
web.Router("/v1/web/dividends-estimate/money-incentives/search", &web_client.DividendsEstimateController{}, "Post:SearchMoneyIncentives")
web.Router("/v1/web/dividends-estimate/money-incentives/estimate", &web_client.DividendsEstimateController{}, "Post:EstimateMoneyIncentives")
web.Router("/v1/web/dividends-estimate/dividends-incentives/estimate", &web_client.DividendsEstimateController{}, "Post:EstimateDividendsIncentives")
web.Router("/v1/web/dividends-estimate/money-incentives/selector", &web_client.DividendsEstimateController{}, "Post:MoneyIncentivesSelector")
}
... ...