|
@@ -2,6 +2,8 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"errors"
|
|
"errors"
|
|
|
|
+ "fmt"
|
|
|
|
+ "strconv"
|
|
"time"
|
|
"time"
|
|
"youngee_b_api/app/dao"
|
|
"youngee_b_api/app/dao"
|
|
"youngee_b_api/app/entity"
|
|
"youngee_b_api/app/entity"
|
|
@@ -183,6 +185,180 @@ func (s BillService) GetBillProjectTaskList(param *vo.ProjectSearchParam) (vo.Re
|
|
return result, nil
|
|
return result, nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 品牌种草账单服务商列表
|
|
|
|
+func (s BillService) GetBillProjectSupplierList(param *vo.SearchSupplierBillParam) (vo.ResultVO, error) {
|
|
|
|
+ if param.Page == 0 {
|
|
|
|
+ param.Page = 1
|
|
|
|
+ }
|
|
|
|
+ if param.PageSize == 0 {
|
|
|
|
+ param.PageSize = 10
|
|
|
|
+ }
|
|
|
|
+ var result vo.ResultVO
|
|
|
|
+ var reBillSuppliers []vo.ReBillSupplier
|
|
|
|
+ var status int64
|
|
|
|
+ if param.Status == 1 {
|
|
|
|
+ status = 8
|
|
|
|
+ } else if param.Status == 2 {
|
|
|
|
+ status = 10
|
|
|
|
+ }
|
|
|
|
+ sProjectInfos, total, err := dao.SProjectDao{}.GetSProjectByProjectStatus(param.TaskId, status, param.Page, param.PageSize)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return result, err
|
|
|
|
+ }
|
|
|
|
+ project, err01 := dao.ProjectDAO{}.GetProjectById(param.TaskId)
|
|
|
|
+ if err01 != nil || project == nil {
|
|
|
|
+ return result, err01
|
|
|
|
+ }
|
|
|
|
+ serviceRate := project.ServiceChargeRate
|
|
|
|
+ type SumResult struct {
|
|
|
|
+ PayAmount float64 `json:"payAmount" gorm:"column:payAmount"`
|
|
|
|
+ RealAmount float64 `json:"realAmount" gorm:"column:realAmount"`
|
|
|
|
+ Count int `json:"count" gorm:"column:count"`
|
|
|
|
+ }
|
|
|
|
+ var sumResult SumResult
|
|
|
|
+ _ = dao.Db.Debug().
|
|
|
|
+ Model(&entity.ProjectTaskInfo{}).
|
|
|
|
+ Where("project_id = ? and task_status = ? and supplier_id = ?", param.TaskId, 2, 0).
|
|
|
|
+ Select("SUM(real_payment) as payAmount, SUM(real_service_charge) as realAmount, count(1) as count").
|
|
|
|
+ Scan(&sumResult).Error
|
|
|
|
+
|
|
|
|
+ for _, sProjectInfo := range sProjectInfos {
|
|
|
|
+ reBillSupplier := vo.ReBillSupplier{
|
|
|
|
+ SupplierId: sProjectInfo.SupplierID,
|
|
|
|
+ TalentNum: sProjectInfo.RecruitNum,
|
|
|
|
+ ChargeActual: sProjectInfo.ServiceChargeActual,
|
|
|
|
+ ChargeSettle: sProjectInfo.ServiceChargeSettle,
|
|
|
|
+ ServiceRate: serviceRate,
|
|
|
|
+ }
|
|
|
|
+ supplier, err1 := dao.SupplierDao{}.GetSupplierInfoById(sProjectInfo.SupplierID)
|
|
|
|
+ if err1 == nil && supplier != nil {
|
|
|
|
+ reBillSupplier.SupplierName = supplier.SupplierName
|
|
|
|
+ reBillSupplier.Avatar = supplier.Avatar
|
|
|
|
+ reBillSupplier.SupplierName = supplier.SupplierName
|
|
|
|
+ reBillSupplier.CompanyName = supplier.CompanyName
|
|
|
|
+ reBillSupplier.SupplierType = supplier.SupplierType
|
|
|
|
+ }
|
|
|
|
+ if sProjectInfo.BOperatorType == 1 {
|
|
|
|
+ // 商家主账号
|
|
|
|
+ enterprise, err := dao.EnterpriseDao{}.GetEnterprise(sProjectInfo.BOperator)
|
|
|
|
+ if err == nil && enterprise != nil {
|
|
|
|
+ reBillSupplier.Inviter = enterprise.BusinessName
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 商家子账号
|
|
|
|
+ subId, err2 := strconv.ParseInt(sProjectInfo.BOperator, 10, 64)
|
|
|
|
+ if err2 != nil {
|
|
|
|
+ fmt.Println("子账号转换错误:", err)
|
|
|
|
+ subId = 0
|
|
|
|
+ }
|
|
|
|
+ subAccount, err := dao.SubAccountDao{}.GetSubAccount(subId)
|
|
|
|
+ if err == nil && subAccount != nil {
|
|
|
|
+ reBillSupplier.Inviter = subAccount.SubAccountName
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reBillSuppliers = append(reBillSuppliers, reBillSupplier)
|
|
|
|
+ }
|
|
|
|
+ resMap := make(map[string]interface{})
|
|
|
|
+ resMap["talentNum"] = sumResult.Count
|
|
|
|
+ resMap["payAmount"] = sumResult.PayAmount
|
|
|
|
+ resMap["realAmount"] = sumResult.RealAmount
|
|
|
|
+ resMap["reBillSuppliers"] = reBillSuppliers
|
|
|
|
+ result = vo.ResultVO{
|
|
|
|
+ Page: param.Page,
|
|
|
|
+ PageSize: param.PageSize,
|
|
|
|
+ Total: total,
|
|
|
|
+ Data: resMap,
|
|
|
|
+ }
|
|
|
|
+ return result, nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 本地生活账单服务商列表
|
|
|
|
+func (s BillService) GetBillLocalSupplierList(param *vo.SearchSupplierBillParam) (vo.ResultVO, error) {
|
|
|
|
+ if param.Page == 0 {
|
|
|
|
+ param.Page = 1
|
|
|
|
+ }
|
|
|
|
+ if param.PageSize == 0 {
|
|
|
|
+ param.PageSize = 10
|
|
|
|
+ }
|
|
|
|
+ var result vo.ResultVO
|
|
|
|
+ var reBillSuppliers []vo.ReBillSupplier
|
|
|
|
+ var status int64
|
|
|
|
+ if param.Status == 1 {
|
|
|
|
+ status = 8
|
|
|
|
+ } else if param.Status == 2 {
|
|
|
|
+ status = 10
|
|
|
|
+ }
|
|
|
|
+ sLocalInfos, total, err := dao.SLocalLifeDao{}.GetSLocalByLocalStatus(param.TaskId, status, param.Page, param.PageSize)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return result, err
|
|
|
|
+ }
|
|
|
|
+ local, err01 := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
|
|
|
|
+ if err01 != nil || local == nil {
|
|
|
|
+ return result, err01
|
|
|
|
+ }
|
|
|
|
+ serviceRate := local.ServiceChargeRate
|
|
|
|
+ type SumResult struct {
|
|
|
|
+ PayAmount float64 `json:"payAmount" gorm:"column:payAmount"`
|
|
|
|
+ RealAmount float64 `json:"realAmount" gorm:"column:realAmount"`
|
|
|
|
+ Count int `json:"count" gorm:"column:count"`
|
|
|
|
+ }
|
|
|
|
+ var sumResult SumResult
|
|
|
|
+ _ = dao.Db.Debug().
|
|
|
|
+ Model(&entity.LocalLifeTaskInfo{}).
|
|
|
|
+ Where("local_id = ? and task_status = ? and supplier_id = ?", param.TaskId, 2, 0).
|
|
|
|
+ Select("SUM(real_payment) as payAmount, SUM(real_service_charge) as realAmount, count(1) as count").
|
|
|
|
+ Scan(&sumResult).Error
|
|
|
|
+
|
|
|
|
+ for _, sLocalInfo := range sLocalInfos {
|
|
|
|
+ reBillSupplier := vo.ReBillSupplier{
|
|
|
|
+ SupplierId: sLocalInfo.SupplierID,
|
|
|
|
+ TalentNum: sLocalInfo.RecruitNum,
|
|
|
|
+ ChargeActual: sLocalInfo.ServiceChargeActual,
|
|
|
|
+ ChargeSettle: sLocalInfo.ServiceChargeSettle,
|
|
|
|
+ ServiceRate: serviceRate,
|
|
|
|
+ }
|
|
|
|
+ supplier, err1 := dao.SupplierDao{}.GetSupplierInfoById(sLocalInfo.SupplierID)
|
|
|
|
+ if err1 == nil && supplier != nil {
|
|
|
|
+ reBillSupplier.SupplierName = supplier.SupplierName
|
|
|
|
+ reBillSupplier.Avatar = supplier.Avatar
|
|
|
|
+ reBillSupplier.SupplierName = supplier.SupplierName
|
|
|
|
+ reBillSupplier.CompanyName = supplier.CompanyName
|
|
|
|
+ reBillSupplier.SupplierType = supplier.SupplierType
|
|
|
|
+ }
|
|
|
|
+ if sLocalInfo.BOperatorType == 1 {
|
|
|
|
+ // 商家主账号
|
|
|
|
+ enterprise, err := dao.EnterpriseDao{}.GetEnterprise(sLocalInfo.BOperator)
|
|
|
|
+ if err == nil && enterprise != nil {
|
|
|
|
+ reBillSupplier.Inviter = enterprise.BusinessName
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 商家子账号
|
|
|
|
+ subId, err2 := strconv.ParseInt(sLocalInfo.BOperator, 10, 64)
|
|
|
|
+ if err2 != nil {
|
|
|
|
+ fmt.Println("子账号转换错误:", err)
|
|
|
|
+ subId = 0
|
|
|
|
+ }
|
|
|
|
+ subAccount, err := dao.SubAccountDao{}.GetSubAccount(subId)
|
|
|
|
+ if err == nil && subAccount != nil {
|
|
|
|
+ reBillSupplier.Inviter = subAccount.SubAccountName
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reBillSuppliers = append(reBillSuppliers, reBillSupplier)
|
|
|
|
+ }
|
|
|
|
+ resMap := make(map[string]interface{})
|
|
|
|
+ resMap["talentNum"] = sumResult.Count
|
|
|
|
+ resMap["payAmount"] = sumResult.PayAmount
|
|
|
|
+ resMap["realAmount"] = sumResult.RealAmount
|
|
|
|
+ resMap["reBillSuppliers"] = reBillSuppliers
|
|
|
|
+ result = vo.ResultVO{
|
|
|
|
+ Page: param.Page,
|
|
|
|
+ PageSize: param.PageSize,
|
|
|
|
+ Total: total,
|
|
|
|
+ Data: resMap,
|
|
|
|
+ }
|
|
|
|
+ return result, nil
|
|
|
|
+}
|
|
|
|
+
|
|
// 本地生活账单列表
|
|
// 本地生活账单列表
|
|
func (s BillService) GetBillLocalLifeTaskList(param *vo.LocalSearchParam) (vo.ResultVO, error) {
|
|
func (s BillService) GetBillLocalLifeTaskList(param *vo.LocalSearchParam) (vo.ResultVO, error) {
|
|
if param.Page == 0 {
|
|
if param.Page == 0 {
|