Updata:解决冲突
This commit is contained in:
commit
debb225291
@ -38,7 +38,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
|||||||
// }
|
// }
|
||||||
err = query.First(result).Error
|
err = query.First(result).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return nil, fmt.Errorf("总金额统计失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将字符串转换为数值进行计算
|
// 将字符串转换为数值进行计算
|
||||||
@ -72,7 +72,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
|||||||
|
|
||||||
subQuery = app.ModuleClients.BundleDB.Model(&model.Reconciliation{}).
|
subQuery = app.ModuleClients.BundleDB.Model(&model.Reconciliation{}).
|
||||||
Select("SUM(handling_fee) as new_fee_payment_amount, SUM(pay_amount) as new_payment_amount").
|
Select("SUM(handling_fee) as new_fee_payment_amount, SUM(pay_amount) as new_payment_amount").
|
||||||
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no COLLATE utf8mb4_general_ci = bundle_order_on COLLATE utf8mb4_general_ci").
|
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no COLLATE utf8mb4_general_ci = reconciliation.bundle_order_on COLLATE utf8mb4_general_ci").
|
||||||
Where("`reconciliation`.pay_time >= ?", req.Start+" 00:00:00").
|
Where("`reconciliation`.pay_time >= ?", req.Start+" 00:00:00").
|
||||||
Where("`reconciliation`.pay_time <= ?", req.End+" 23:59:59").
|
Where("`reconciliation`.pay_time <= ?", req.End+" 23:59:59").
|
||||||
Where("`reconciliation`.deleted_at is null and reconciliation.pay_status = 2 and bor.status=2 and bor.deleted_at is null")
|
Where("`reconciliation`.deleted_at is null and reconciliation.pay_status = 2 and bor.status=2 and bor.deleted_at is null")
|
||||||
@ -1342,6 +1342,12 @@ func MetricsArtistAccountExport(req *bundle.MetricsArtistAccountExportReq) (*bun
|
|||||||
ins.platform_user_id as instagram_account,
|
ins.platform_user_id as instagram_account,
|
||||||
ins.platform_user_name as instagram_nickname,
|
ins.platform_user_name as instagram_nickname,
|
||||||
ins_auth.auth_status as ins_auth_status,
|
ins_auth.auth_status as ins_auth_status,
|
||||||
|
youtube.platform_user_id as youtube_account,
|
||||||
|
youtube.platform_user_name as youtube_nickname,
|
||||||
|
youtube_auth.auth_status as youtube_auth_status,
|
||||||
|
bluesky.platform_user_id as bluesky_account,
|
||||||
|
bluesky.platform_user_name as bluesky_nickname,
|
||||||
|
bluesky_auth.auth_status as bluesky_auth_status,
|
||||||
cma.artist_name,
|
cma.artist_name,
|
||||||
bor.customer_num as user_num
|
bor.customer_num as user_num
|
||||||
`).
|
`).
|
||||||
@ -1351,6 +1357,10 @@ func MetricsArtistAccountExport(req *bundle.MetricsArtistAccountExportReq) (*bun
|
|||||||
Joins(`left join (Select * from cast_media_auth where platform_id = 4 and deleted_at = 0) dm_auth on dm_auth.user_id = dm.user_id`).
|
Joins(`left join (Select * from cast_media_auth where platform_id = 4 and deleted_at = 0) dm_auth on dm_auth.user_id = dm.user_id`).
|
||||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 3 and deleted_at = 0) ins on ins.artist_uuid = cma.artist_uuid`).
|
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 3 and deleted_at = 0) ins on ins.artist_uuid = cma.artist_uuid`).
|
||||||
Joins(`left join (Select * from cast_media_auth where platform_id = 3 and deleted_at = 0) ins_auth on ins_auth.user_id = ins.user_id`).
|
Joins(`left join (Select * from cast_media_auth where platform_id = 3 and deleted_at = 0) ins_auth on ins_auth.user_id = ins.user_id`).
|
||||||
|
Joins(`left join (Select * from cast_media_account where platform_id = 2 and deleted_at = 0) youtube on youtube.artist_uuid = cma.artist_uuid`).
|
||||||
|
Joins(`left join (Select * from cast_media_auth where platform_id = 2 and deleted_at = 0) youtube_auth on youtube_auth.user_id = youtube.user_id`).
|
||||||
|
Joins(`left join (Select * from cast_media_account where platform_id = 5 and deleted_at = 0) bluesky on bluesky.artist_uuid = cma.artist_uuid`).
|
||||||
|
Joins(`left join (Select * from cast_media_auth where platform_id = 5 and deleted_at = 0) bluesky_auth on bluesky_auth.user_id = bluesky.user_id`).
|
||||||
Joins(`left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci= cma.artist_uuid COLLATE utf8mb4_general_ci`).
|
Joins(`left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci= cma.artist_uuid COLLATE utf8mb4_general_ci`).
|
||||||
Where("bor.deleted_at is null")
|
Where("bor.deleted_at is null")
|
||||||
if req.Month != "" {
|
if req.Month != "" {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/shopspring/decimal"
|
||||||
"micro-bundle/internal/model"
|
"micro-bundle/internal/model"
|
||||||
"micro-bundle/pb/bundle"
|
"micro-bundle/pb/bundle"
|
||||||
"micro-bundle/pkg/app"
|
"micro-bundle/pkg/app"
|
||||||
@ -127,6 +128,26 @@ func UpdateOrderRecordByOrderNO(orderRecord *model.BundleOrderRecords) (res *bun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tempRecord := new(model.BundleOrderRecords)
|
||||||
|
if err := app.ModuleClients.BundleDB.Where("deleted_at is null and order_no = ?", orderRecord.OrderNo).First(&tempRecord).Error; err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, errors.New("订单记录不存在")
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("查询订单失败: %v", err)
|
||||||
|
}
|
||||||
|
if orderRecord.Status == 2 && tempRecord.AmountType == 2 && tempRecord.TotalAmount > 0 {
|
||||||
|
// 当回调支付成功,币种是美元,且订单金额大于0,计算美元手续费:订单金额*0.019(四舍五入保留两位小数字)+0.1
|
||||||
|
amount := decimal.NewFromFloat32(tempRecord.TotalAmount)
|
||||||
|
rate, _ := decimal.NewFromString("0.019")
|
||||||
|
fee := amount.Mul(rate)
|
||||||
|
// 4. 四舍五入保留两位小数
|
||||||
|
feeRounded := fee.Round(2)
|
||||||
|
addition, _ := decimal.NewFromString("0.1")
|
||||||
|
result := feeRounded.Add(addition)
|
||||||
|
valueAdd.HandlingFee = result.String()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).
|
err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).
|
||||||
@ -807,6 +828,19 @@ func UpdateReconciliationStatusBySerialNumber(req *bundle.UpdateStatusAndPayTime
|
|||||||
PayStatus: int(req.PaymentStatus),
|
PayStatus: int(req.PaymentStatus),
|
||||||
SerialNumber: req.SerialNumber,
|
SerialNumber: req.SerialNumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.PaymentStatus == 2 && existing.CurrencyType == 2 && existing.PayAmount > 0 {
|
||||||
|
// 当回调支付成功,币种是美元,且订单金额大于0,计算美元手续费:订单金额*0.019(四舍五入保留两位小数字)+0.1
|
||||||
|
amount := decimal.NewFromFloat32(existing.PayAmount)
|
||||||
|
rate, _ := decimal.NewFromString("0.019")
|
||||||
|
fee := amount.Mul(rate)
|
||||||
|
// 4. 四舍五入保留两位小数
|
||||||
|
feeRounded := fee.Round(2)
|
||||||
|
addition, _ := decimal.NewFromString("0.1")
|
||||||
|
result := feeRounded.Add(addition)
|
||||||
|
updates.HandlingFee = result.String()
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.ModuleClients.BundleDB.Model(&existing).Updates(updates).Error; err != nil {
|
if err := app.ModuleClients.BundleDB.Model(&existing).Updates(updates).Error; err != nil {
|
||||||
return nil, fmt.Errorf("更新对账单失败: %v", err)
|
return nil, fmt.Errorf("更新对账单失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -464,9 +464,9 @@ active_windows AS (
|
|||||||
bb.manual_data_analysis_number, bb.manual_data_analysis_consumption_number,
|
bb.manual_data_analysis_number, bb.manual_data_analysis_consumption_number,
|
||||||
rn.name AS user_name
|
rn.name AS user_name
|
||||||
FROM ` + "`micro-account`.`user`" + ` u
|
FROM ` + "`micro-account`.`user`" + ` u
|
||||||
INNER JOIN ` + "`micro-account`.real_name" + ` rn ON rn.id = u.real_name_id AND rn.name IS NOT NULL
|
INNER JOIN ` + "`micro-account`.real_name" + ` rn ON rn.id = u.real_name_id AND rn.name IS NOT NULL AND rn.deleted_at = 0
|
||||||
INNER JOIN bundle_activate bc ON bc.user_id = u.id AND bc.activate = 2
|
INNER JOIN bundle_activate bc ON bc.user_id = u.id AND bc.activate = 2
|
||||||
INNER JOIN latest_bor bor ON bor.customer_id = u.id
|
INNER JOIN latest_bor bor ON bor.customer_id = u.id AND u.deleted_at = 0
|
||||||
INNER JOIN newest_month nm ON nm.user_id = u.id
|
INNER JOIN newest_month nm ON nm.user_id = u.id
|
||||||
INNER JOIN bundle_balance bb ON bb.user_id = u.id AND bb.order_uuid = bor.uuid AND bb.month = nm.month AND bb.deleted_at IS NULL
|
INNER JOIN bundle_balance bb ON bb.user_id = u.id AND bb.order_uuid = bor.uuid AND bb.month = nm.month AND bb.deleted_at IS NULL
|
||||||
WHERE u.deleted_at = 0
|
WHERE u.deleted_at = 0
|
||||||
@ -527,25 +527,25 @@ balance_sum AS (
|
|||||||
GROUP BY bb2.user_id
|
GROUP BY bb2.user_id
|
||||||
),
|
),
|
||||||
|
|
||||||
-- 6. 作品统计
|
-- 6. 作品统计(只统计 origin_uuid 为空的作品)
|
||||||
cw_agg AS (
|
cw_agg AS (
|
||||||
SELECT
|
SELECT
|
||||||
aw.user_id,
|
aw.user_id,
|
||||||
COUNT(CASE WHEN cw.work_category = 2 AND cw.deleted_at = 0 AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_video_count,
|
COUNT(CASE WHEN cw.work_category = 2 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_video_count,
|
||||||
COUNT(CASE WHEN cw.work_category = 1 AND cw.deleted_at = 0 AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_post_count,
|
COUNT(CASE WHEN cw.work_category = 1 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_post_count,
|
||||||
COUNT(CASE WHEN cw.work_category = 2 AND cw.cost = 1 AND cw.deleted_at = 0 AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_video_consumed,
|
COUNT(CASE WHEN cw.work_category = 2 AND cw.cost = 1 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_video_consumed,
|
||||||
COUNT(CASE WHEN cw.work_category = 1 AND cw.cost = 1 AND cw.deleted_at = 0 AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_post_consumed
|
COUNT(CASE WHEN cw.work_category = 1 AND cw.cost = 1 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_post_consumed
|
||||||
FROM active_windows aw
|
FROM active_windows aw
|
||||||
LEFT JOIN cast_work cw ON cw.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
LEFT JOIN cast_work cw ON cw.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||||
GROUP BY aw.user_id
|
GROUP BY aw.user_id
|
||||||
),
|
),
|
||||||
|
|
||||||
-- 7. 数据分析作品统计
|
-- 7. 数据分析作品统计(排除 work_analysis_status = 1 的数据分析)
|
||||||
cwa_agg AS (
|
cwa_agg AS (
|
||||||
SELECT
|
SELECT
|
||||||
aw.user_id,
|
aw.user_id,
|
||||||
COUNT(CASE WHEN cwa.deleted_at = 0 AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS uploaded_data_count,
|
COUNT(CASE WHEN cwa.deleted_at = 0 AND (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS uploaded_data_count,
|
||||||
COUNT(CASE WHEN cwa.cost = 1 AND cwa.deleted_at = 0 AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS released_data_consumed
|
COUNT(CASE WHEN cwa.cost = 1 AND cwa.deleted_at = 0 AND (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS released_data_consumed
|
||||||
FROM active_windows aw
|
FROM active_windows aw
|
||||||
LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||||
GROUP BY aw.user_id
|
GROUP BY aw.user_id
|
||||||
@ -810,49 +810,49 @@ func GetPendingUploadBreakdownBySubNums(subNums []string, page int, pageSize int
|
|||||||
" FROM cast_work cwv\n" +
|
" FROM cast_work cwv\n" +
|
||||||
" JOIN cast_work_extra cwev ON cwev.work_uuid = cwv.uuid AND cwev.deleted_at = 0\n" +
|
" JOIN cast_work_extra cwev ON cwev.work_uuid = cwv.uuid AND cwev.deleted_at = 0\n" +
|
||||||
" WHERE cwv.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
" WHERE cwv.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
||||||
" AND cwv.deleted_at = 0 AND cwv.work_category = 2 AND cwv.cost = 1 AND cwv.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwev.cost_type = 1\n" +
|
" AND cwv.deleted_at = 0 AND cwv.work_category = 2 AND cwv.cost = 1 AND (cwv.origin_uuid = '' OR cwv.origin_uuid IS NULL) AND cwv.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwev.cost_type = 1\n" +
|
||||||
" ), 0)) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 2 AND cwe.cost_type = 1 THEN cw.uuid END), 0) AS pending_bundle_video_count,\n" +
|
" ), 0)) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 2 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cwe.cost_type = 1 THEN cw.uuid END), 0) AS pending_bundle_video_count,\n" +
|
||||||
" ((COALESCE(lbb.total_increase_video, 0) + bb.manual_video_number - bb.manual_video_consumption_number) -\n" +
|
" ((COALESCE(lbb.total_increase_video, 0) + bb.manual_video_number - bb.manual_video_consumption_number) -\n" +
|
||||||
" COALESCE((\n" +
|
" COALESCE((\n" +
|
||||||
" SELECT COUNT(DISTINCT cwv.uuid)\n" +
|
" SELECT COUNT(DISTINCT cwv.uuid)\n" +
|
||||||
" FROM cast_work cwv\n" +
|
" FROM cast_work cwv\n" +
|
||||||
" JOIN cast_work_extra cwev ON cwev.work_uuid = cwv.uuid AND cwev.deleted_at = 0\n" +
|
" JOIN cast_work_extra cwev ON cwev.work_uuid = cwv.uuid AND cwev.deleted_at = 0\n" +
|
||||||
" WHERE cwv.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
" WHERE cwv.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
||||||
" AND cwv.deleted_at = 0 AND cwv.work_category = 2 AND cwv.cost = 1 AND cwv.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwev.cost_type = 2\n" +
|
" AND cwv.deleted_at = 0 AND cwv.work_category = 2 AND cwv.cost = 1 AND (cwv.origin_uuid = '' OR cwv.origin_uuid IS NULL) AND cwv.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwev.cost_type = 2\n" +
|
||||||
" ), 0) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 2 AND cwe.cost_type = 2 THEN cw.uuid END), 0)) AS pending_increase_video_count,\n" +
|
" ), 0) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 2 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cwe.cost_type = 2 THEN cw.uuid END), 0)) AS pending_increase_video_count,\n" +
|
||||||
" (COALESCE(lbb.total_bundle_image, 0) - COALESCE((\n" +
|
" (COALESCE(lbb.total_bundle_image, 0) - COALESCE((\n" +
|
||||||
" SELECT COUNT(DISTINCT cwp.uuid)\n" +
|
" SELECT COUNT(DISTINCT cwp.uuid)\n" +
|
||||||
" FROM cast_work cwp\n" +
|
" FROM cast_work cwp\n" +
|
||||||
" JOIN cast_work_extra cwep ON cwep.work_uuid = cwp.uuid AND cwep.deleted_at = 0\n" +
|
" JOIN cast_work_extra cwep ON cwep.work_uuid = cwp.uuid AND cwep.deleted_at = 0\n" +
|
||||||
" WHERE cwp.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
" WHERE cwp.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
||||||
" AND cwp.deleted_at = 0 AND cwp.work_category = 1 AND cwp.cost = 1 AND cwp.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwep.cost_type = 1\n" +
|
" AND cwp.deleted_at = 0 AND cwp.work_category = 1 AND cwp.cost = 1 AND (cwp.origin_uuid = '' OR cwp.origin_uuid IS NULL) AND cwp.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwep.cost_type = 1\n" +
|
||||||
" ), 0)) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 1 AND cwe.cost_type = 1 THEN cw.uuid END), 0) AS pending_bundle_post_count,\n" +
|
" ), 0)) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 1 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cwe.cost_type = 1 THEN cw.uuid END), 0) AS pending_bundle_post_count,\n" +
|
||||||
" ((COALESCE(lbb.total_increase_image, 0) + bb.manual_image_number - bb.manual_image_consumption_number) -\n" +
|
" ((COALESCE(lbb.total_increase_image, 0) + bb.manual_image_number - bb.manual_image_consumption_number) -\n" +
|
||||||
" COALESCE((\n" +
|
" COALESCE((\n" +
|
||||||
" SELECT COUNT(DISTINCT cwp.uuid)\n" +
|
" SELECT COUNT(DISTINCT cwp.uuid)\n" +
|
||||||
" FROM cast_work cwp\n" +
|
" FROM cast_work cwp\n" +
|
||||||
" JOIN cast_work_extra cwep ON cwep.work_uuid = cwp.uuid AND cwep.deleted_at = 0\n" +
|
" JOIN cast_work_extra cwep ON cwep.work_uuid = cwp.uuid AND cwep.deleted_at = 0\n" +
|
||||||
" WHERE cwp.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
" WHERE cwp.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
||||||
" AND cwp.deleted_at = 0 AND cwp.work_category = 1 AND cwp.cost = 1 AND cwp.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwep.cost_type = 2\n" +
|
" AND cwp.deleted_at = 0 AND cwp.work_category = 1 AND cwp.cost = 1 AND (cwp.origin_uuid = '' OR cwp.origin_uuid IS NULL) AND cwp.submit_time BETWEEN bb.start_at AND bb.expired_at AND cwep.cost_type = 2\n" +
|
||||||
" ), 0) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 1 AND cwe.cost_type = 2 THEN cw.uuid END), 0)) AS pending_increase_post_count,\n" +
|
" ), 0) - COALESCE(COUNT(DISTINCT CASE WHEN cw.work_category = 1 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cwe.cost_type = 2 THEN cw.uuid END), 0)) AS pending_increase_post_count,\n" +
|
||||||
" (COALESCE(lbb.total_bundle_data, 0) - COALESCE((\n" +
|
" (COALESCE(lbb.total_bundle_data, 0) - COALESCE((\n" +
|
||||||
" SELECT COUNT(DISTINCT ca.uuid)\n" +
|
" SELECT COUNT(DISTINCT ca.uuid)\n" +
|
||||||
" FROM cast_work_analysis ca\n" +
|
" FROM cast_work_analysis ca\n" +
|
||||||
" JOIN cast_work_analysis_extra cae ON cae.analysis_uuid = ca.uuid AND cae.deleted_at = 0\n" +
|
" JOIN cast_work_analysis_extra cae ON cae.analysis_uuid = ca.uuid AND cae.deleted_at = 0\n" +
|
||||||
" WHERE ca.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
" WHERE ca.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
||||||
" AND ca.deleted_at = 0 AND ca.cost = 1 AND ca.submit_time BETWEEN UNIX_TIMESTAMP(bb.start_at) AND UNIX_TIMESTAMP(bb.expired_at) AND cae.cost_type = 1\n" +
|
" AND ca.deleted_at = 0 AND ca.cost = 1 AND (ca.work_analysis_status IS NULL OR ca.work_analysis_status != 1) AND ca.submit_time BETWEEN UNIX_TIMESTAMP(bb.start_at) AND UNIX_TIMESTAMP(bb.expired_at) AND cae.cost_type = 1\n" +
|
||||||
" ), 0)) - COALESCE(COUNT(DISTINCT CASE WHEN cwae.cost_type = 1 THEN cwa.uuid END), 0) AS pending_bundle_data_count,\n" +
|
" ), 0)) - COALESCE(COUNT(DISTINCT CASE WHEN (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwae.cost_type = 1 THEN cwa.uuid END), 0) AS pending_bundle_data_count,\n" +
|
||||||
" ((COALESCE(lbb.total_increase_data, 0) + bb.manual_data_analysis_number - bb.manual_data_analysis_consumption_number) -\n" +
|
" ((COALESCE(lbb.total_increase_data, 0) + bb.manual_data_analysis_number - bb.manual_data_analysis_consumption_number) -\n" +
|
||||||
" COALESCE((\n" +
|
" COALESCE((\n" +
|
||||||
" SELECT COUNT(DISTINCT ca.uuid)\n" +
|
" SELECT COUNT(DISTINCT ca.uuid)\n" +
|
||||||
" FROM cast_work_analysis ca\n" +
|
" FROM cast_work_analysis ca\n" +
|
||||||
" JOIN cast_work_analysis_extra cae ON cae.analysis_uuid = ca.uuid AND cae.deleted_at = 0\n" +
|
" JOIN cast_work_analysis_extra cae ON cae.analysis_uuid = ca.uuid AND cae.deleted_at = 0\n" +
|
||||||
" WHERE ca.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
" WHERE ca.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci\n" +
|
||||||
" AND ca.deleted_at = 0 AND ca.cost = 1 AND ca.submit_time BETWEEN UNIX_TIMESTAMP(bb.start_at) AND UNIX_TIMESTAMP(bb.expired_at) AND cae.cost_type = 2\n" +
|
" AND ca.deleted_at = 0 AND ca.cost = 1 AND (ca.work_analysis_status IS NULL OR ca.work_analysis_status != 1) AND ca.submit_time BETWEEN UNIX_TIMESTAMP(bb.start_at) AND UNIX_TIMESTAMP(bb.expired_at) AND cae.cost_type = 2\n" +
|
||||||
" ), 0) - COALESCE(COUNT(DISTINCT CASE WHEN cwae.cost_type = 2 THEN cwa.uuid END), 0)) AS pending_increase_data_count,\n" +
|
" ), 0) - COALESCE(COUNT(DISTINCT CASE WHEN (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwae.cost_type = 2 THEN cwa.uuid END), 0)) AS pending_increase_data_count,\n" +
|
||||||
" GREATEST(\n" +
|
" GREATEST(\n" +
|
||||||
" (COALESCE(lbb.total_bundle_video, 0) + COALESCE(lbb.total_increase_video, 0) + bb.manual_video_number - bb.manual_video_consumption_number) -\n" +
|
" (COALESCE(lbb.total_bundle_video, 0) + COALESCE(lbb.total_increase_video, 0) + bb.manual_video_number - bb.manual_video_consumption_number) -\n" +
|
||||||
" COALESCE((SELECT COUNT(1) FROM cast_work cw2 WHERE cw2.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci AND cw2.deleted_at = 0 AND cw2.work_category = 2 AND cw2.cost = 1 AND cw2.submit_time BETWEEN bb.start_at AND bb.expired_at), 0),\n" +
|
" COALESCE((SELECT COUNT(1) FROM cast_work cw2 WHERE cw2.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci AND cw2.deleted_at = 0 AND cw2.work_category = 2 AND cw2.cost = 1 AND (cw2.origin_uuid = '' OR cw2.origin_uuid IS NULL) AND cw2.submit_time BETWEEN bb.start_at AND bb.expired_at), 0),\n" +
|
||||||
" 0) -\n" +
|
" 0) -\n" +
|
||||||
" (SELECT COUNT(1) FROM cast_video_script cvs WHERE CAST(u.id AS CHAR) COLLATE utf8mb4_general_ci = cvs.artist_uuid COLLATE utf8mb4_general_ci AND cvs.deleted_at = 0 AND cvs.created_at BETWEEN UNIX_TIMESTAMP(CONVERT_TZ(bb.start_at, '+00:00', '+00:00')) AND UNIX_TIMESTAMP(CONVERT_TZ(bb.expired_at, '+00:00', '+00:00'))) AS pending_video_script_count\n" +
|
" (SELECT COUNT(1) FROM cast_video_script cvs WHERE CAST(u.id AS CHAR) COLLATE utf8mb4_general_ci = cvs.artist_uuid COLLATE utf8mb4_general_ci AND cvs.deleted_at = 0 AND cvs.created_at BETWEEN UNIX_TIMESTAMP(CONVERT_TZ(bb.start_at, '+00:00', '+00:00')) AND UNIX_TIMESTAMP(CONVERT_TZ(bb.expired_at, '+00:00', '+00:00'))) AS pending_video_script_count\n" +
|
||||||
"FROM\n" +
|
"FROM\n" +
|
||||||
@ -861,16 +861,16 @@ func GetPendingUploadBreakdownBySubNums(subNums []string, page int, pageSize int
|
|||||||
" (SELECT customer_id, MAX(created_at) AS max_created_time FROM bundle_order_records WHERE status = 2 AND deleted_at IS NULL GROUP BY customer_id) AS bor2\n" +
|
" (SELECT customer_id, MAX(created_at) AS max_created_time FROM bundle_order_records WHERE status = 2 AND deleted_at IS NULL GROUP BY customer_id) AS bor2\n" +
|
||||||
" ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time\n" +
|
" ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time\n" +
|
||||||
"JOIN `micro-account`.user u ON u.id = bor1.customer_id AND u.deleted_at = 0\n" +
|
"JOIN `micro-account`.user u ON u.id = bor1.customer_id AND u.deleted_at = 0\n" +
|
||||||
"JOIN `micro-account`.real_name rn ON rn.id = u.real_name_id\n" +
|
"JOIN `micro-account`.real_name rn ON rn.id = u.real_name_id AND rn.deleted_at = 0\n" +
|
||||||
"JOIN bundle_activate bc ON bc.user_id = u.id AND bc.activate = 2\n" +
|
"JOIN bundle_activate bc ON bc.user_id = u.id AND bc.activate = 2\n" +
|
||||||
"JOIN bundle_balance bb ON bb.order_uuid COLLATE utf8mb4_general_ci = bor1.uuid COLLATE utf8mb4_general_ci AND bb.user_id = u.id\n" +
|
"JOIN bundle_balance bb ON bb.order_uuid COLLATE utf8mb4_general_ci = bor1.uuid COLLATE utf8mb4_general_ci AND bb.user_id = u.id AND u.deleted_at = 0\n" +
|
||||||
"JOIN\n" +
|
"JOIN\n" +
|
||||||
" (SELECT user_id, MAX(month) AS month FROM bundle_balance WHERE deleted_at IS NULL GROUP BY user_id) AS newest_month\n" +
|
" (SELECT user_id, MAX(month) AS month FROM bundle_balance WHERE deleted_at IS NULL GROUP BY user_id) AS newest_month\n" +
|
||||||
" ON bb.user_id = newest_month.user_id AND CAST(bb.month AS CHAR) COLLATE utf8mb4_general_ci = CAST(newest_month.month AS CHAR) COLLATE utf8mb4_general_ci\n" +
|
" ON bb.user_id = newest_month.user_id AND CAST(bb.month AS CHAR) COLLATE utf8mb4_general_ci = CAST(newest_month.month AS CHAR) COLLATE utf8mb4_general_ci\n" +
|
||||||
"LEFT JOIN latest_bundle_balance lbb ON lbb.user_id = u.id\n" +
|
"LEFT JOIN latest_bundle_balance lbb ON lbb.user_id = u.id AND u.deleted_at = 0\n" +
|
||||||
"LEFT JOIN cast_work cw ON cw.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci AND cw.deleted_at = 0 AND cw.submit_time BETWEEN bb.start_at AND bb.expired_at\n" +
|
"LEFT JOIN cast_work cw ON cw.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN bb.start_at AND bb.expired_at\n" +
|
||||||
"LEFT JOIN cast_work_extra cwe ON cwe.work_uuid = cw.uuid AND cwe.deleted_at = 0\n" +
|
"LEFT JOIN cast_work_extra cwe ON cwe.work_uuid = cw.uuid AND cwe.deleted_at = 0\n" +
|
||||||
"LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci AND cwa.deleted_at = 0 AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(bb.start_at) AND UNIX_TIMESTAMP(bb.expired_at)\n" +
|
"LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone COLLATE utf8mb4_general_ci = u.tel_num COLLATE utf8mb4_general_ci AND cwa.deleted_at = 0 AND (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(bb.start_at) AND UNIX_TIMESTAMP(bb.expired_at)\n" +
|
||||||
"LEFT JOIN cast_work_analysis_extra cwae ON cwae.analysis_uuid = cwa.uuid AND cwae.deleted_at = 0\n" +
|
"LEFT JOIN cast_work_analysis_extra cwae ON cwae.analysis_uuid = cwa.uuid AND cwae.deleted_at = 0\n" +
|
||||||
"WHERE bor1.deleted_at IS NULL AND bor1.status = 2 AND DATE_ADD(UTC_TIMESTAMP(), INTERVAL 8 HOUR) BETWEEN bb.start_at AND bb.expired_at AND bor1.customer_num IN ?\n" +
|
"WHERE bor1.deleted_at IS NULL AND bor1.status = 2 AND DATE_ADD(UTC_TIMESTAMP(), INTERVAL 8 HOUR) BETWEEN bb.start_at AND bb.expired_at AND bor1.customer_num IN ?\n" +
|
||||||
"GROUP BY u.id, rn.name, u.tel_num, bor1.customer_num, bb.start_at, bb.expired_at, bb.manual_video_number, bb.manual_video_consumption_number, bb.manual_image_number, bb.manual_image_consumption_number, bb.manual_data_analysis_number, bb.manual_data_analysis_consumption_number, lbb.total_bundle_video, lbb.total_increase_video, lbb.total_bundle_image, lbb.total_increase_image, lbb.total_bundle_data, lbb.total_increase_data\n"
|
"GROUP BY u.id, rn.name, u.tel_num, bor1.customer_num, bb.start_at, bb.expired_at, bb.manual_video_number, bb.manual_video_consumption_number, bb.manual_image_number, bb.manual_image_consumption_number, bb.manual_data_analysis_number, bb.manual_data_analysis_consumption_number, lbb.total_bundle_video, lbb.total_increase_video, lbb.total_bundle_image, lbb.total_increase_image, lbb.total_bundle_data, lbb.total_increase_data\n"
|
||||||
|
|||||||
@ -306,7 +306,7 @@ func CreateBundleBalance(req *bundle.CreateBundleBalanceReq) (*bundle.CreateBund
|
|||||||
data.ExpiredAt = time.Now()
|
data.ExpiredAt = time.Now()
|
||||||
userId, err := strconv.Atoi(addValues[0].CustomerID)
|
userId, err := strconv.Atoi(addValues[0].CustomerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.New("获取用户ID失败")
|
||||||
}
|
}
|
||||||
data.Month = time.Now().Format("2006-01")
|
data.Month = time.Now().Format("2006-01")
|
||||||
data.UserId = userId
|
data.UserId = userId
|
||||||
@ -553,11 +553,11 @@ func BundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.BundleBala
|
|||||||
PageSize: 99999,
|
PageSize: 99999,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.New("余量列表数据失败")
|
||||||
}
|
}
|
||||||
prefixData, err := dao.BalanceExportPrefix()
|
prefixData, err := dao.BalanceExportPrefix()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.New("获取前缀数据失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
var prefixMap = map[int32]model.BundleExportDto{}
|
var prefixMap = map[int32]model.BundleExportDto{}
|
||||||
|
|||||||
@ -68,6 +68,7 @@ func CreateOrderRecord(req *bundle.OrderCreateRecord) (res *bundle.CommonRespons
|
|||||||
ExpirationTime: req.ExpirationTime,
|
ExpirationTime: req.ExpirationTime,
|
||||||
Language: req.Language,
|
Language: req.Language,
|
||||||
BundleOrderValueAdd: addRecords,
|
BundleOrderValueAdd: addRecords,
|
||||||
|
PlatformIds: req.PlatformIds,
|
||||||
}
|
}
|
||||||
res, err = dao.CreateOrderRecord(orderRecord)
|
res, err = dao.CreateOrderRecord(orderRecord)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql/driver"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@ -42,6 +44,7 @@ type BundleOrderRecords struct {
|
|||||||
Language string `gorm:"column:language;comment:语言" json:"language"`
|
Language string `gorm:"column:language;comment:语言" json:"language"`
|
||||||
BundleOrderValueAdd []BundleOrderValueAdd `gorm:"foreignKey:OrderUUID;references:UUID" json:"bundleOrderValueAdd"`
|
BundleOrderValueAdd []BundleOrderValueAdd `gorm:"foreignKey:OrderUUID;references:UUID" json:"bundleOrderValueAdd"`
|
||||||
ReSignature int `json:"reSignature" gorm:"column:re_signature;default:2;type:int;comment:是否重新签 1:是 2:否"`
|
ReSignature int `json:"reSignature" gorm:"column:re_signature;default:2;type:int;comment:是否重新签 1:是 2:否"`
|
||||||
|
PlatformIds PlatformIDs `gorm:"column:platform_ids;type:json;NOT NULL;comment:发布平台ID集合 TIKTOK= 1, YOUTUBE = 2, INS = 3 , DM = 4, BL = 5;" json:"platformIDs"`
|
||||||
}
|
}
|
||||||
type BundleOrderValueAdd struct {
|
type BundleOrderValueAdd struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
@ -73,6 +76,30 @@ type BundleOrderValueAdd struct {
|
|||||||
QuotaValue int32 `json:"quotaValue" gorm:"column:quota_value;type:int;comment:额度值"`
|
QuotaValue int32 `json:"quotaValue" gorm:"column:quota_value;type:int;comment:额度值"`
|
||||||
IsExpired bool `json:"isExpired" gorm:"column:is_expired;default:false;comment:是否过期作废 false:不作废 true:作废"`
|
IsExpired bool `json:"isExpired" gorm:"column:is_expired;default:false;comment:是否过期作废 false:不作废 true:作废"`
|
||||||
}
|
}
|
||||||
|
type PlatformIDs []uint32
|
||||||
|
|
||||||
|
// 实现 Scanner 接口
|
||||||
|
func (p *PlatformIDs) Scan(value interface{}) error {
|
||||||
|
if value == nil {
|
||||||
|
*p = []uint32{}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes, ok := value.([]byte)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("type assertion to []byte failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Unmarshal(bytes, p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实现 Valuer 接口
|
||||||
|
func (p PlatformIDs) Value() (driver.Value, error) {
|
||||||
|
if len(p) == 0 {
|
||||||
|
return "[]", nil
|
||||||
|
}
|
||||||
|
return json.Marshal(p)
|
||||||
|
}
|
||||||
|
|
||||||
// 财务确认状态
|
// 财务确认状态
|
||||||
const (
|
const (
|
||||||
|
|||||||
@ -213,6 +213,7 @@ message OrderCreateRecord{
|
|||||||
int32 payType = 19 [json_name = "payType"];
|
int32 payType = 19 [json_name = "payType"];
|
||||||
repeated OrderCreateAddRecord addRecords = 20 [json_name = "addRecords"]; //增值服务
|
repeated OrderCreateAddRecord addRecords = 20 [json_name = "addRecords"]; //增值服务
|
||||||
string orderNo = 21 [json_name = "orderNo"];
|
string orderNo = 21 [json_name = "orderNo"];
|
||||||
|
repeated uint32 platformIds = 22; // 发布平台ID集合 (json 格式字符串)
|
||||||
}
|
}
|
||||||
message OrderCreateAddRecord{
|
message OrderCreateAddRecord{
|
||||||
int32 serviceType = 1 [json_name = "serviceType"];
|
int32 serviceType = 1 [json_name = "serviceType"];
|
||||||
@ -1816,14 +1817,18 @@ message MetricsArtistAccountExportItem{
|
|||||||
string dmAccount = 3;
|
string dmAccount = 3;
|
||||||
string dmNickname = 4;
|
string dmNickname = 4;
|
||||||
int32 dmAuthStatus = 5;
|
int32 dmAuthStatus = 5;
|
||||||
// string youtubeAccount = 3; 现在没有YouTube了
|
|
||||||
// string youtubeNickname = 4;
|
|
||||||
string instagramAccount = 6;
|
string instagramAccount = 6;
|
||||||
string instagramNickname = 7;
|
string instagramNickname = 7;
|
||||||
int32 insAuthStatus = 8;
|
int32 insAuthStatus = 8;
|
||||||
string tiktokAccount = 9;
|
string tiktokAccount = 9;
|
||||||
string tiktokNickname = 10;
|
string tiktokNickname = 10;
|
||||||
int32 tiktokAuthStatus = 11;
|
int32 tiktokAuthStatus = 11;
|
||||||
|
string youtubeAccount = 12;
|
||||||
|
string youtubeNickname = 13;
|
||||||
|
int32 youtubeAuthStatus = 14;
|
||||||
|
string blueskyAccount = 15;
|
||||||
|
string blueskyNickname = 16;
|
||||||
|
int32 blueskyAuthStatus = 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,8 @@ import (
|
|||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
math "math"
|
math "math"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
_ "github.com/mwitkow/go-proto-validators"
|
|
||||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||||
|
_ "github.com/mwitkow/go-proto-validators"
|
||||||
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,11 @@ func loadMysqlConn(conn string) *gorm.DB {
|
|||||||
&model.BundleActivate{},
|
&model.BundleActivate{},
|
||||||
&model.BundleBalanceLayout{},
|
&model.BundleBalanceLayout{},
|
||||||
)
|
)
|
||||||
|
if db.Migrator().HasColumn(&model.BundleOrderRecords{}, "platform_ids") == false {
|
||||||
|
if err := db.Migrator().AddColumn(&model.BundleOrderRecords{}, "platform_ids"); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// return nil
|
// return nil
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user