Kaynağa Gözat

fix_充值记录字段

Ethan 1 ay önce
ebeveyn
işleme
03d1b0bdec

+ 11 - 0
app/dao/recharge_record_dao.go

@@ -50,6 +50,17 @@ func (d RechargeRecordDao) RechargeInfoList(param *vo.RechargeParam) ([]entity.R
 	return rechargeRecords, total, nil
 }
 
+// 获取指定企业id的指定充值状态记录数
+func (d RechargeRecordDao) RechargeStatusCount(enterpriseId string, rechargeState int64) (int64, error) {
+	var total int64
+	query := Db.Debug().Model(&entity.RechargeRecord{}).Where("enterprise_id = ? AND status = ?", enterpriseId, rechargeState)
+	err := query.Count(&total).Error
+	if err != nil {
+		return 0, err
+	}
+	return total, nil
+}
+
 // 更新充值状态
 func (d RechargeRecordDao) UpdateRechargeStatus(rechargeId string, status int64, t time.Time) error {
 	rechargeRecord := entity.RechargeRecord{

+ 9 - 1
app/service/recharge_service.go

@@ -393,11 +393,19 @@ func (s RechargeService) RechargeInfoList(param *vo.RechargeParam) (vo.ResultVO,
 		}
 		reRechargeInfos = append(reRechargeInfos, reRechargeInfo)
 	}
+	rechargingNum, _ := dao.RechargeRecordDao{}.RechargeStatusCount(param.EnterpriseId, 1)
+	rechargedNum, _ := dao.RechargeRecordDao{}.RechargeStatusCount(param.EnterpriseId, 2)
+	failNum, _ := dao.RechargeRecordDao{}.RechargeStatusCount(param.EnterpriseId, 3)
+	resMap := make(map[string]interface{})
+	resMap["rechargingNum"] = rechargingNum
+	resMap["rechargedNum"] = rechargedNum
+	resMap["failNum"] = failNum
+	resMap["reRechargeInfos"] = reRechargeInfos
 	result = vo.ResultVO{
 		Page:     param.Page,
 		PageSize: param.PageSize,
 		Total:    total,
-		Data:     reRechargeInfos,
+		Data:     resMap,
 	}
 	return result, nil
 }

+ 7 - 4
app/vo/re_recharge_info.go

@@ -6,8 +6,11 @@ type ReRechargeInfo struct {
 	RechargeAmount     float64 `json:"rechargeAmount"`
 	RechargeMethod     int64   `json:"rechargeMethod"` // 1对公转账 2微信支付
 	TransferVoucherUrl string  `json:"transferVoucherUrl"`
-	CommitAt           string  `json:"commitAt"`   // 充值申请提交时间
-	ConfirmAt          string  `json:"confirmAt"`  // 充值确认时间
-	RefuseAt           string  `json:"refuseAt"`   // 充值失败时间
-	FailReason         string  `json:"failReason"` // 失败原因
+	CommitAt           string  `json:"commitAt"`      // 充值申请提交时间
+	ConfirmAt          string  `json:"confirmAt"`     // 充值确认时间
+	RefuseAt           string  `json:"refuseAt"`      // 充值失败时间
+	FailReason         string  `json:"failReason"`    // 失败原因
+	RechargingNum      int64   `json:"rechargingNum"` // 充值待确认
+	RechargedNum       int64   `json:"rechargedNum"`  // 已充值
+	FailNum            int64   `json:"failNum"`       // 充值失败
 }