|
@@ -26,14 +26,14 @@ func allDataReturnMoneyRecordForAccountReturn() {
|
|
|
}()
|
|
|
|
|
|
var total int64
|
|
|
- AnalysisDB.Debug().Model(&ReturnMoneyRecord{}).Where("state = ?", 1).Where("autoUpdate < ?", "2024-10-16").Count(&total)
|
|
|
+ AnalysisDB.Debug().Model(&ReturnMoneyRecord{}).Where("state = ?", 1).Where("autoUpdate < ?", endTime).Count(&total)
|
|
|
log.Info("allDataReturnMoneyRecordForAccountReturn", zap.Any("RefundRecord 退款表 总数是", total))
|
|
|
|
|
|
rowsPerPage := 100 // 每页的数量
|
|
|
totalPages := (int(total) / rowsPerPage) + 1 //总页数
|
|
|
for page := 0; page < totalPages; page++ {
|
|
|
offset := page * rowsPerPage
|
|
|
- rows, err := AnalysisDB.Debug().Model(&ReturnMoneyRecord{}).Where("state = ?", 1).Where("autoUpdate < ?", "2024-10-16").Order("id desc").Offset(offset).Limit(rowsPerPage).Rows()
|
|
|
+ rows, err := AnalysisDB.Debug().Model(&ReturnMoneyRecord{}).Where("state = ?", 1).Where("autoUpdate < ?", endTime).Order("id desc").Offset(offset).Limit(rowsPerPage).Rows()
|
|
|
defer func() {
|
|
|
err = rows.Close()
|
|
|
if err != nil {
|
|
@@ -45,6 +45,7 @@ func allDataReturnMoneyRecordForAccountReturn() {
|
|
|
var account_return DwdFAccountReturn //归集后的剑鱼回款表
|
|
|
var return_money_record ReturnMoneyRecord //原来回款表
|
|
|
var order_sale_record OrderSaleRecord // 原来业绩表更
|
|
|
+ var order_sale_record2 OrderSaleRecord // 原来业绩表更2
|
|
|
//var account_order_change DwdFAccountOrderChange // 归集后的业绩变更表
|
|
|
var data_exOrder DataexportOrder //原来的订单表
|
|
|
//var account_order DwdFAccountOrder //归集后的订单表
|
|
@@ -118,7 +119,17 @@ func allDataReturnMoneyRecordForAccountReturn() {
|
|
|
account_return.ReturnType = "对公转账"
|
|
|
}
|
|
|
//业绩统计日期
|
|
|
- account_return.SaleTime = data_exOrder.SaleTime //业绩统计日期
|
|
|
+ account_return.SaleTime = data_exOrder.SaleTime //业绩统计日期
|
|
|
+ //归集后的回款表-业绩统计日期。如果订单表的sale_time 值为空,就用order_sale_record.
|
|
|
+ //业绩统计时间,去时间最早的一条并且state!=2和-2;
|
|
|
+ if data_exOrder.SaleTime == nil {
|
|
|
+ //3.业绩变更表- order_sale_record
|
|
|
+ err = JianyuDB.Where("ordercode =? AND state !=2 AND state !=-2 ", return_money_record.OrderCode).Order("id asc").First(&order_sale_record2).Error
|
|
|
+ if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ log.Info("allDataRefundRecordForAccountOrderChange", zap.Error(err))
|
|
|
+ }
|
|
|
+ account_return.SaleTime = order_sale_record2.StatisticsTime //业绩统计日期
|
|
|
+ }
|
|
|
account_return.ReturnTime = return_money_record.ReturnTime //回款日期
|
|
|
account_return.ReturnMoney = return_money_record.ReturnMoney //回款金额
|
|
|
//签约主体
|
|
@@ -173,11 +184,11 @@ func allDataReturnMoneyRecordForAccountReturn() {
|
|
|
//退款状态
|
|
|
switch data_exOrder.RefundStatus {
|
|
|
case 1:
|
|
|
- account_return.RefundStatus = "全额回款"
|
|
|
+ account_return.RefundStatus = "全额退款"
|
|
|
case 2:
|
|
|
- account_return.RefundStatus = "部分回款"
|
|
|
+ account_return.RefundStatus = "部分退款"
|
|
|
case 0:
|
|
|
- account_return.RefundStatus = "未回款"
|
|
|
+ account_return.RefundStatus = "未退款"
|
|
|
}
|
|
|
//关联方式,operate_type;1-手动回款 2-自动回款
|
|
|
if return_money_record.OperateType == 1 {
|
|
@@ -215,14 +226,14 @@ func allDataDataexportOrderForAccountReturn() {
|
|
|
log.Info("aaaaaaaaaaaa")
|
|
|
}()
|
|
|
var total int64
|
|
|
- AnalysisDB.Debug().Model(&DataexportOrder{}).Where("order_status =? AND is_backstage_order =? AND NOT (pay_way =? AND product_type =?)", 1, 0, "transferAccounts", "VIP订阅").Where("autoUpdate < ?", "2024-10-16").Count(&total)
|
|
|
+ AnalysisDB.Debug().Model(&DataexportOrder{}).Where("order_status =? AND is_backstage_order =? AND NOT (pay_way =? AND product_type =?)", 1, 0, "transferAccounts", "VIP订阅").Where("autoUpdate < ?", endTime).Count(&total)
|
|
|
log.Info("allDataDataexportOrderForAccountReturn", zap.Any("dataexport_order 订单表 ,order_status=1 and is_backstage_order=0 ,\n\t并排除pay_way=’transferAccounts’ and product_type=’VIP订阅’,总数是", total))
|
|
|
|
|
|
rowsPerPage := 100 // 每页的数量
|
|
|
totalPages := (int(total) / rowsPerPage) + 1 //总页数
|
|
|
for page := 0; page < totalPages; page++ {
|
|
|
offset := page * rowsPerPage
|
|
|
- rows, err := AnalysisDB.Debug().Model(&DataexportOrder{}).Where("order_status =? AND is_backstage_order =? AND NOT (pay_way =? AND product_type =?)", 1, 0, "transferAccounts", "VIP订阅").Where("autoUpdate < ?", "2024-10-16").Order("id desc").Offset(offset).Limit(rowsPerPage).Rows()
|
|
|
+ rows, err := AnalysisDB.Debug().Model(&DataexportOrder{}).Where("order_status =? AND is_backstage_order =? AND NOT (pay_way =? AND product_type =?)", 1, 0, "transferAccounts", "VIP订阅").Where("autoUpdate < ?", endTime).Order("id desc").Offset(offset).Limit(rowsPerPage).Rows()
|
|
|
defer func() {
|
|
|
err = rows.Close()
|
|
|
if err != nil {
|
|
@@ -234,7 +245,8 @@ func allDataDataexportOrderForAccountReturn() {
|
|
|
var data_exOrder DataexportOrder //原来的订单表
|
|
|
var account_return DwdFAccountReturn //归集后的剑鱼回款表
|
|
|
//var return_money_record ReturnMoneyRecord //原来回款表
|
|
|
- var order_sale_record OrderSaleRecord // 原来业绩表更
|
|
|
+ var order_sale_record OrderSaleRecord // 原来业绩表更
|
|
|
+ var order_sale_record2 OrderSaleRecord // 原来业绩表更
|
|
|
// ScanRows 方法用于将一行记录扫描至结构体
|
|
|
err = AnalysisDB.ScanRows(rows, &data_exOrder)
|
|
|
if err != nil {
|
|
@@ -299,6 +311,16 @@ func allDataDataexportOrderForAccountReturn() {
|
|
|
//
|
|
|
|
|
|
account_return.SaleTime = data_exOrder.SaleTime
|
|
|
+ //归集后的回款表-业绩统计日期。如果订单表的sale_time 值为空,就用order_sale_record.
|
|
|
+ //业绩统计时间,去时间最早的一条并且state!=2和-2;
|
|
|
+ if data_exOrder.SaleTime == nil {
|
|
|
+ //3.业绩变更表- order_sale_record
|
|
|
+ err = JianyuDB.Where("ordercode =? AND state !=2 AND state !=-2 ", data_exOrder.OrderCode).Order("id asc").First(&order_sale_record2).Error
|
|
|
+ if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ log.Info("allDataRefundRecordForAccountOrderChange", zap.Error(err))
|
|
|
+ }
|
|
|
+ account_return.SaleTime = order_sale_record2.StatisticsTime //业绩统计日期
|
|
|
+ }
|
|
|
account_return.ReturnTime = data_exOrder.PayTime
|
|
|
account_return.ReturnMoney = util.IntAll(filterMap["originalAmount"]) //回款金额
|
|
|
//签约主体
|
|
@@ -345,11 +367,11 @@ func allDataDataexportOrderForAccountReturn() {
|
|
|
//退款状态-refund_status
|
|
|
switch data_exOrder.RefundStatus {
|
|
|
case 1:
|
|
|
- account_return.RefundStatus = "全额回款"
|
|
|
+ account_return.RefundStatus = "全额退款"
|
|
|
case 2:
|
|
|
- account_return.RefundStatus = "部分回款"
|
|
|
+ account_return.RefundStatus = "部分退款"
|
|
|
case 0:
|
|
|
- account_return.RefundStatus = "未回款"
|
|
|
+ account_return.RefundStatus = "未退款"
|
|
|
}
|
|
|
account_return.OperateType = "自动回款" //关联方式
|
|
|
account_return.OperatePerson = "jianyu@admin" //创建人
|