Browse Source

update

master
dengbiao 2 months ago
parent
commit
82fb2f5b49
3 changed files with 116 additions and 36 deletions
  1. +7
    -3
      app/hdl/hdl_set_center.go
  2. +108
    -32
      app/svc/svc_wx_data.go
  3. +1
    -1
      go.mod

+ 7
- 3
app/hdl/hdl_set_center.go View File

@@ -449,17 +449,21 @@ func AppletUnauthorized(c *gin.Context) {
// @Router /api/setCenter/share/index [GET]
func ShareIndex(c *gin.Context) {
masterId := svc.GetMasterId(c)
userAppDomainDb := implement.NewUserAppDomainDb(db.Db)
agent, err := userAppDomainDb.GetAppDomainByType("agent", masterId)

agent := new(model.UserAppDomain)
_, err := db.Db.Where("type =?", "agent").And("uuid =?", masterId).And("is_ssl =1").Get(agent)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
medium, err := userAppDomainDb.GetAppDomainByType("medium", masterId)

medium := new(model.UserAppDomain)
_, err = db.Db.Where("type =?", "medium").And("uuid =?", masterId).And("is_ssl =1").Get(agent)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

agentDomain := ""
if agent != nil {
agentDomain = agent.Domain


+ 108
- 32
app/svc/svc_wx_data.go View File

@@ -93,7 +93,6 @@ func GenerateWxAdData(req md.GenerateWxAdData) (err error, generateWxAdData mode
generateWxAdData = model.GenerateWxAdData{
MediumId: originalWxAdData.MediumId,
Uuid: originalWxAdData.Uuid,
Platform: originalWxAdData.Platform,
AppId: originalWxAdData.AppId,
OriginalDataId: originalWxAdData.Id,
SlotId: originalWxAdData.SlotId,
@@ -122,6 +121,7 @@ func GenerateWxAdData(req md.GenerateWxAdData) (err error, generateWxAdData mode
IsGenerateReport: 0,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
Platform: originalWxAdData.Platform,
}
generateWxAdDataDb := implement.NewGenerateWxAdDataDb(db.Db)
_, err = generateWxAdDataDb.GenerateWxAdDataInsertBySession(session, &generateWxAdData)
@@ -272,19 +272,24 @@ func SettlementWxAdData(req md.SettlementWxAdData) (err error) {
if mediumSettlement == nil {
//新增一条数据
mediumSettlement = &model.MediumSettlement{
Uuid: originalWxAdData.Uuid,
MediumId: originalWxAdData.MediumId,
AppId: originalWxAdData.AppId,
BusinessKind: 1,
Kind: medium.SettlementType,
BasicIncome: generateWxAdData.MediaRevenue,
OtherIncome: 0,
State: mediumSettlementState,
PayState: mediumSettlementPayState,
StartDate: now.Format("2006-01-02"),
EndDate: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
Uuid: originalWxAdData.Uuid,
MediumId: originalWxAdData.MediumId,
AppId: originalWxAdData.AppId,
BusinessKind: 1,
Kind: medium.SettlementType,
BasicIncome: generateWxAdData.MediaRevenue,
OtherIncome: 0,
OriginalIncome: originalWxAdData.PublisherIncome,
PlatformRetention: generateWxAdData.PlatformRetention,
CommissionRetention: generateWxAdData.CommissionRetention,
PriceAdjustmentRetention: generateWxAdData.PriceAdjustmentRetention,
State: mediumSettlementState,
PayState: mediumSettlementPayState,
StartDate: now.Format("2006-01-02"),
EndDate: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
SettleFile: "",
}
_, err = mediumSettlementDb.MediumSettlementInsertBySession(session, mediumSettlement)
if err != nil {
@@ -293,14 +298,54 @@ func SettlementWxAdData(req md.SettlementWxAdData) (err error) {
}
} else {
//更新数据
basicIncomeBefore = mediumSettlement.BasicIncome
mediumSettlement.BasicIncome += generateWxAdData.MediaRevenue
mediumSettlement.State = mediumSettlementState
mediumSettlement.PayState = mediumSettlementPayState
_, err = mediumSettlementDb.UpdateMediumSettlementBySession(session, mediumSettlement, "basic_income", "pay_state", "state")
if err != nil {
_ = session.Rollback()
return
if medium.SettlementType != mediumSettlement.Kind {
//TODO::前后结算类型不一致,之前结算单状态自动变成"核算中"
mediumSettlement.State = enum.MediumSettlementStateForAccountingInProgress
//mediumSettlement.PayState = mediumSettlementPayState
_, err = mediumSettlementDb.UpdateMediumSettlementBySession(session, mediumSettlement, "state")
if err != nil {
_ = session.Rollback()
return
}

//新增一条数据
mediumSettlement = &model.MediumSettlement{
Uuid: originalWxAdData.Uuid,
MediumId: originalWxAdData.MediumId,
AppId: originalWxAdData.AppId,
BusinessKind: 1,
Kind: medium.SettlementType,
BasicIncome: generateWxAdData.MediaRevenue,
OtherIncome: 0,
OriginalIncome: originalWxAdData.PublisherIncome,
PlatformRetention: generateWxAdData.PlatformRetention,
CommissionRetention: generateWxAdData.CommissionRetention,
PriceAdjustmentRetention: generateWxAdData.PriceAdjustmentRetention,
State: mediumSettlementState,
PayState: mediumSettlementPayState,
StartDate: now.Format("2006-01-02"),
EndDate: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
SettleFile: "",
}
_, err = mediumSettlementDb.MediumSettlementInsertBySession(session, mediumSettlement)
if err != nil {
_ = session.Rollback()
return
}
} else {
basicIncomeBefore = mediumSettlement.BasicIncome
mediumSettlement.BasicIncome += generateWxAdData.MediaRevenue
mediumSettlement.OriginalIncome += originalWxAdData.PublisherIncome
mediumSettlement.PlatformRetention += generateWxAdData.PlatformRetention
mediumSettlement.CommissionRetention += generateWxAdData.CommissionRetention
mediumSettlement.PriceAdjustmentRetention += generateWxAdData.PriceAdjustmentRetention
_, err = mediumSettlementDb.UpdateMediumSettlementBySession(session, mediumSettlement, "basic_income", "original_income", "platform_retention", "commission_retention", "price_adjustment_retention")
if err != nil {
_ = session.Rollback()
return
}
}
}
if medium.SettlementType == enum.MediumSettlementTypeForPaymentInAdvance {
@@ -378,17 +423,48 @@ func SettlementWxAdData(req md.SettlementWxAdData) (err error) {
}
} else {
//更新数据
agentBasicIncomeBefore = agentSettlement.BasicIncome
agentOtherIncomeBefore = agentSettlement.OtherIncome
agentSettlement.BasicIncome += v.AgentRevenue
agentSettlement.OtherIncome += v.ExtraRevenue
agentSettlement.State += agentSettlementState
agentSettlement.PayState += agentSettlementPayState
if agentMap[v.AgentId].SettlementType != agentSettlement.Kind {
//TODO::前后结算类型不一致,之前结算单状态自动变成"核算中"
agentSettlement.State = enum.AgentSettlementStateForAccountingInProgress
_, err = agentSettlementDb.UpdateAgentSettlementBySession(session, agentSettlement, "state")
if err != nil {
_ = session.Rollback()
return
}

_, err = agentSettlementDb.UpdateAgentSettlementBySession(session, agentSettlement, "basic_income", "other_income", "pay_state", "state")
if err != nil {
_ = session.Rollback()
return
//新增一条数据
agentSettlement = &model.AgentSettlement{
Uuid: v.Uuid,
AgentId: v.AgentId,
MediumId: originalWxAdData.MediumId,
AppId: v.AppId,
BusinessKind: 1,
Kind: agentMap[v.AgentId].SettlementType,
BasicIncome: v.AgentRevenue,
OtherIncome: v.ExtraRevenue,
State: agentSettlementState,
PayState: agentSettlementPayState,
StartDate: now.Format("2006-01-02"),
EndDate: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
_, err = agentSettlementDb.AgentSettlementInsertBySession(session, agentSettlement)
if err != nil {
_ = session.Rollback()
return
}
} else {
agentBasicIncomeBefore = agentSettlement.BasicIncome
agentOtherIncomeBefore = agentSettlement.OtherIncome
agentSettlement.BasicIncome += v.AgentRevenue
agentSettlement.OtherIncome += v.ExtraRevenue

_, err = agentSettlementDb.UpdateAgentSettlementBySession(session, agentSettlement, "basic_income", "other_income")
if err != nil {
_ = session.Rollback()
return
}
}
}



+ 1
- 1
go.mod View File

@@ -2,7 +2,7 @@ module applet

go 1.18

//replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models
replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models

require (
code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240906014333-2fe6da0384ee


Loading…
Cancel
Save