Browse Source

update

master
dengbiao 3 months ago
parent
commit
e25975db4a
4 changed files with 64 additions and 24 deletions
  1. +58
    -19
      consume/canal_guide_order_for_numerical_statement_consume.go
  2. +4
    -4
      consume/init.go
  3. +1
    -0
      consume/md/md_canal_guide_order_consume.go
  4. +1
    -1
      go.mod

+ 58
- 19
consume/canal_guide_order_for_numerical_statement_consume.go View File

@@ -71,6 +71,9 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
//2、获取masterId
masterId := utils.StrToInt(strings.Split(canalMsg.Database, "_")[1])

//TODO::日志记录
utils.FilePutContents("handleCanalGuideOrderForNumericalStatementTable_"+utils.IntToStr(masterId)+"_"+now.Format("2006-01-02"), string(msg))

//2、判断操作(insert | update)
if canalMsg.Type == md.CanalMsgInsertSqlType || canalMsg.Type == md.CanalMsgUpdateSqlType {
var isUpdate bool
@@ -83,7 +86,7 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
if err != nil {
return err
}
if statistics == nil {
if statistics == nil && canalMsg.Type == md.CanalMsgInsertSqlType {
statistics = &model.MasterGuideOrderStatistics{
MasterId: masterId,
PaymentTotal: "",
@@ -107,6 +110,9 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
return err
}
}
if statistics == nil {
return errors.New("过期订单数据不予处理")
}

paymentTotal := statistics.PaymentTotal
orderCount := statistics.OrderCount
@@ -116,20 +122,26 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
placeOrderNumOfPeople := statistics.PlaceOrderNumOfPeople
effectiveOrderCount := statistics.EffectiveOrderCount
effectiveCommission := statistics.EffectiveCommission
receiveCommission := statistics.ReceiveCommission
loseCommission := statistics.LoseCommission
avgCommission := statistics.AvgCommission
customerUnitPrice := statistics.CustomerUnitPrice
effectivePaymentTotal := statistics.EffectivePaymentTotal
if canalMsg.Type == md.CanalMsgInsertSqlType {
for _, item := range canalMsg.Data {
orderCount++
effectiveOrderCount++
if item.State == "4" {
loseOrderCount++
} else {
effectiveOrderCount++
}

cacheKey := fmt.Sprintf(ZhiOsGuidePlaceOrderNumOfPeopleHashMapCacheKey, utils.IntToStr(masterId), ordDate)
get, _ := cache.HGetString(cacheKey, item.Uid)
paymentTotal = utils.Float64ToStr(utils.StrToFloat64(paymentTotal) + utils.StrToFloat64(item.PaidPrice))
estimatedCommission = utils.Float64ToStr(utils.StrToFloat64(estimatedCommission) + utils.StrToFloat64(item.BenefitAll))
estimatedProfit = utils.Float64ToStr(utils.StrToFloat64(estimatedProfit) + utils.StrToFloat64(item.SysCommission))
effectiveCommission = utils.Float64ToStr(utils.StrToFloat64(effectiveCommission) + utils.StrToFloat64(item.BenefitAll))
paymentTotal = utils.Float64ToStr(utils.StrToFloat64(paymentTotal) + utils.StrToFloat64(item.PaidPrice)) //付款金额
estimatedCommission = utils.Float64ToStr(utils.StrToFloat64(estimatedCommission) + utils.StrToFloat64(item.BenefitAll)) //预估佣金(元)
estimatedProfit = utils.Float64ToStr(utils.StrToFloat64(estimatedProfit) + utils.StrToFloat64(item.SysCommission)) //预估利润(元)
effectiveCommission = utils.Float64ToStr(utils.StrToFloat64(effectiveCommission) + utils.StrToFloat64(item.BenefitAll)) //有效佣金(元)
effectivePaymentTotal = utils.Float64ToStr(utils.StrToFloat64(effectivePaymentTotal) + utils.StrToFloat64(item.PaidPrice)) //有效付款金额(元)

estimatedCommissionValue, _ := decimal.NewFromString(estimatedCommission)
orderCountValue := decimal.NewFromInt(int64(orderCount))
@@ -142,7 +154,6 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
cache.HSet(cacheKey, item.Uid, utils.IntToStr(utils.StrToInt(get)+1))
}
cache.Expire(cacheKey, md.ZhiOsUserVisitIpAddressHashMapCacheTime)

paymentTotalValue, _ := decimal.NewFromString(paymentTotal)
if placeOrderNumOfPeople == 0 {
return errors.New("divider cannot be 0 in division operation")
@@ -156,13 +167,6 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
if canalMsg.Type == md.CanalMsgUpdateSqlType {
judgeSate := JudgeSate(*canalMsg)
if judgeSate > 0 {
if judgeSate == 1 {
//TODO::收货
for _, item := range canalMsg.Data {
receiveCommission = utils.Float64ToStr(utils.StrToFloat64(receiveCommission) + utils.StrToFloat64(item.BenefitAll))
isUpdate = true
}
}
if judgeSate == 2 {
//TODO::未收货失效
loseOrderCount++
@@ -170,6 +174,7 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
for _, item := range canalMsg.Data {
loseCommission = utils.Float64ToStr(utils.StrToFloat64(loseCommission) + utils.StrToFloat64(item.BenefitAll))
effectiveCommission = utils.Float64ToStr(utils.StrToFloat64(effectiveCommission) - utils.StrToFloat64(item.BenefitAll))
effectivePaymentTotal = utils.Float64ToStr(utils.StrToFloat64(effectivePaymentTotal) - utils.StrToFloat64(item.PaidPrice))
isUpdate = true
}
}
@@ -180,10 +185,43 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
for _, item := range canalMsg.Data {
loseCommission = utils.Float64ToStr(utils.StrToFloat64(loseCommission) + utils.StrToFloat64(item.BenefitAll))
effectiveCommission = utils.Float64ToStr(utils.StrToFloat64(effectiveCommission) - utils.StrToFloat64(item.BenefitAll))
receiveCommission = utils.Float64ToStr(utils.StrToFloat64(receiveCommission) - utils.StrToFloat64(item.BenefitAll))
effectivePaymentTotal = utils.Float64ToStr(utils.StrToFloat64(effectivePaymentTotal) - utils.StrToFloat64(item.PaidPrice))
isUpdate = true
}
}

if judgeSate == 1 || judgeSate == 3 {
//TODO::收货额外处理

//查找是否有数据
var ordConfirmAt string
for _, item := range canalMsg.Data {
ordConfirmAt = time.Unix(utils.StrToInt64(item.ConfirmAt), 0).Format("2006-01-02")
}
ordConfirmStatistics, err := db2.GetMasterGuideOrderStatistics(db.Db, masterId, ordConfirmAt)
if err != nil {
return err
}
if ordConfirmStatistics == nil {
return errors.New("过期收货订单数据不予处理")
}

if judgeSate == 1 {
//TODO::收货
for _, item := range canalMsg.Data {
ordConfirmStatistics.ReceiveCommission = utils.Float64ToStr(utils.StrToFloat64(ordConfirmStatistics.ReceiveCommission) + utils.StrToFloat64(item.BenefitAll))
}
}
if judgeSate == 3 {
//TODO::已收货失效
for _, item := range canalMsg.Data {
ordConfirmStatistics.ReceiveCommission = utils.Float64ToStr(utils.StrToFloat64(ordConfirmStatistics.ReceiveCommission) - utils.StrToFloat64(item.BenefitAll))
}
}
ordConfirmStatistics.UpdateAt = now.Format("2006-01-02 15:04:05")
_, err = db2.MasterGuideOrderStatisticsUpdate(db.Db, ordConfirmStatistics.Id, ordConfirmStatistics,
"receive_commission", "update_at")
}
}
}

@@ -196,19 +234,20 @@ func handleCanalGuideOrderForNumericalStatementTable(msg []byte) error {
statistics.PlaceOrderNumOfPeople = placeOrderNumOfPeople
statistics.EffectiveOrderCount = effectiveOrderCount
statistics.EffectiveCommission = effectiveCommission
statistics.ReceiveCommission = receiveCommission
statistics.LoseCommission = loseCommission
statistics.AvgCommission = avgCommission
statistics.CustomerUnitPrice = customerUnitPrice
statistics.EffectivePaymentTotal = effectivePaymentTotal
statistics.UpdateAt = now.Format("2006-01-02 15:04:05")
_, err = db2.MasterGuideOrderStatisticsUpdate(db.Db, statistics.Id, statistics,
"payment_total", "order_count", "estimated_commission", "estimated_profit", "lose_order_count",
"place_order_num_of_people", "effective_order_count", "effective_commission", "receive_commission", "lose_commission",
"avg_commission", "customer_unit_price", "update_at")
"place_order_num_of_people", "effective_order_count", "effective_commission", "lose_commission",
"avg_commission", "customer_unit_price", "effective_payment_total", "update_at")
if err != nil {
return err
}
}

}
return nil
}


+ 4
- 4
consume/init.go View File

@@ -75,10 +75,10 @@ func initConsumes() {
//jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume

//////////////////////////////////////// bigData /////////////////////////////////////////////////////
//jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
//jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
//jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
//jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
jobs[consumeMd.CanalGuideOrderForNumericalStatementConsumeFunName] = CanalGuideOrderForNumericalStatementConsume

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////


+ 1
- 0
consume/md/md_canal_guide_order_consume.go View File

@@ -17,6 +17,7 @@ type CanalGuideOrder struct {
PaidPrice string `json:"paid_price"` //付款金额
BenefitAll string `json:"benefit_all"` //分润总额,供应商总额
SysCommission string `json:"sys_commission"` //平台占佣金
ConfirmAt string `json:"confirm_at"` //确认收货时间
}

type CanalGuideOrderMessage[T any] struct {


+ 1
- 1
go.mod View File

@@ -12,7 +12,7 @@ require (
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240703034234-2ab228956242
code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git v1.6.2-0.20231116085701-9ba6e19f877b
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240611024753-7cd929a03014
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240711033658-057f89bb825f
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240717064604-5e4000e89365
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/boombuler/barcode v1.0.1


Loading…
Cancel
Save