Browse Source

Merge branch 'refs/heads/develop-zhou' into develop

Ethan 6 months ago
parent
commit
9eaf729f15

+ 83 - 8
app/controller/finance_controller.go

@@ -42,16 +42,17 @@ func (t FinanceController) GetCodeUrl(c *gin.Context) {
 	}
 	tradeId := util.GetRandomString(32)
 	fmt.Println("amount:", param.Amount)
-	codeUrl, err := service.RechargeService{}.NativeApiServicePrepay(tradeId, param.Amount)
+	codeUrl, timeExpire, err := service.RechargeService{}.NativeApiServicePrepay(tradeId, param.Amount)
 	if err != nil {
 		logrus.Errorf("[GetCodeUrl] call Show err:%+v\n", err)
-		returnError(c, 40000, "error")
+		returnError(c, 40000, err.Error())
 		return
 	}
-	reCodeUrl := new(vo.ReCodeUrl)
-	reCodeUrl.CodeUrl = codeUrl
-	reCodeUrl.TradeId = tradeId
-
+	reCodeUrl := vo.ReCodeUrl{
+		CodeUrl:    codeUrl,
+		TradeId:    tradeId,
+		TimeExpire: timeExpire.Format("2006-01-02 15:04:05"),
+	}
 	returnSuccess(c, 20000, reCodeUrl)
 }
 
@@ -67,8 +68,82 @@ func (t FinanceController) QueryOrderByTradeId(c *gin.Context) {
 	tradeState, err := service.RechargeService{}.QueryOrderByTradeId(param.TradeId)
 	if err != nil {
 		logrus.Errorf("[QueryOrderByTradeId] call Show err:%+v\n", err)
-		returnError(c, 40000, "error")
+		returnError(c, 40000, err.Error())
+		return
+	}
+	resultMap := make(map[string]string)
+	resultMap["tradeState"] = tradeState
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 余额管理——总金额、可用余额、冻结金额
+func (t FinanceController) ShowBalance(c *gin.Context) {
+	param := &vo.BalanceParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	reBalanceShow, err := service.RechargeService{}.ShowBalance(param)
+	if err != nil {
+		logrus.Errorf("[ShowBalance] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, reBalanceShow)
+}
+
+// 余额管理——冻结记录
+func (t FinanceController) FrozenInfoList(c *gin.Context) {
+	param := &vo.BalanceParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	result, err := service.RechargeService{}.FrozenInfoList(param)
+	if err != nil {
+		logrus.Errorf("[FrozenInfoList] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}
+
+// 充值管理——累计充值金额、确认中金额
+func (t FinanceController) ShowRecharge(c *gin.Context) {
+	param := &vo.RechargeParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	reRechargeShow, err := service.RechargeService{}.ShowRecharge(param)
+	if err != nil {
+		logrus.Errorf("[ShowRecharge] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, reRechargeShow)
+}
+
+// 充值管理——充值记录
+func (t FinanceController) RechargeInfoList(c *gin.Context) {
+	param := &vo.RechargeParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "参数错误")
+		return
+	}
+	result, err := service.RechargeService{}.RechargeInfoList(param)
+	if err != nil {
+		logrus.Errorf("[RechargeInfoList] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
 		return
 	}
-	returnSuccess(c, 20000, tradeState)
+	returnSuccess(c, 20000, result)
 }

+ 9 - 0
app/dao/enterprise_dao.go

@@ -4,6 +4,15 @@ import "youngee_b_api/app/entity"
 
 type EnterpriseDao struct{}
 
+func (d EnterpriseDao) GetEnterpriseInfo(enterpriseId string) (*entity.Enterprise, error) {
+	var enterprise entity.Enterprise
+	err := Db.Debug().Model(&entity.Enterprise{}).Where("enterprise_id = ?", enterpriseId).First(&enterprise).Error
+	if err != nil {
+		return nil, err
+	}
+	return &enterprise, nil
+}
+
 func (d EnterpriseDao) GetEnterprise(enterpriseId string) (*entity.Enterprise, error) {
 	var enterprise entity.Enterprise
 	err := Db.Model(&entity.Enterprise{}).Where("enterprise_id = ?", enterpriseId).Select("business_name, user_id").First(&enterprise).Error

+ 32 - 0
app/dao/project_dao.go

@@ -276,3 +276,35 @@ func (d ProjectDAO) GetProjectTargetList(param *vo.DefaultSearchParam) ([]vo.ReT
 
 	return reTaskDefaultTargets, total, nil
 }
+
+// 获取品牌种草冻结中的任务
+func (d ProjectDAO) GetProjectFrozenList(enterpriseId string) ([]*entity.Project, error) {
+	var projects []*entity.Project
+	query := Db.Debug().Model(entity.Project{})
+	query.Select("project_id, product_id, enterprise_id, sub_account_id, project_platform, payment_amount, pay_at") // 冻结金额:payment_amount
+	err := query.Where(fmt.Sprintf("enterprise_id = ? AND (project_status between 7 and 8) "), enterpriseId).Find(&projects).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return projects, nil
+		} else {
+			return nil, err
+		}
+	}
+	return projects, nil
+}
+
+// 获取品牌种草冻结解除的任务
+func (d ProjectDAO) GetProjectFrozenCancelList(enterpriseId string) ([]*entity.Project, error) {
+	var projects []*entity.Project
+	query := Db.Debug().Model(entity.Project{})
+	query.Select("project_id, product_id, enterprise_id, sub_account_id, project_platform, settlement_amount, pay_at") // 解冻金额:settlement_amount
+	err := query.Where(fmt.Sprintf("enterprise_id = ? AND (project_status between 9 and 10) "), enterpriseId).Find(&projects).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return projects, nil
+		} else {
+			return nil, err
+		}
+	}
+	return projects, nil
+}

+ 38 - 1
app/dao/recharge_record_dao.go

@@ -1,6 +1,9 @@
 package dao
 
-import "youngee_b_api/app/entity"
+import (
+	"youngee_b_api/app/entity"
+	"youngee_b_api/app/vo"
+)
 
 type RechargeRecordDao struct{}
 
@@ -11,3 +14,37 @@ func (d RechargeRecordDao) Insert(rechargeRecord *entity.RechargeRecord) error {
 	}
 	return nil
 }
+
+// 获取指定企业id的充值金额、确认中金额
+func (d RechargeRecordDao) GetRechargeAmount(enterpriseId string, status int64) (float64, error) {
+	var totalAmount float64
+	query := Db.Debug().Model(&entity.RechargeRecord{})
+	err := query.Where("enterprise_id = ? AND status = ?", enterpriseId, status).Select("SUM(recharge_amount)").Scan(&totalAmount).Error
+	if err != nil {
+		return 0, err
+	}
+	return totalAmount, nil
+}
+
+// 获取指定企业id的充值记录
+func (d RechargeRecordDao) RechargeInfoList(param *vo.RechargeParam) ([]entity.RechargeRecord, int64, error) {
+	rechargeRecords := []entity.RechargeRecord{}
+	var total int64
+	query := Db.Debug().Model(&entity.RechargeRecord{}).Where("enterprise_id = ? AND status = ?", param.EnterpriseId, param.RechargeState)
+	query.Count(&total)
+	query = query.Select("recharge_id, recharge_amount, transfer_voucher_url, recharge_method, commit_at, confirm_at, refuse_at, fail_reason")
+	offset := (param.Page - 1) * param.PageSize
+	var err error
+	if param.RechargeState == 1 {
+		err = query.Order("commit_at desc").Offset(offset).Limit(param.PageSize).Find(&rechargeRecords).Error
+	} else if param.RechargeState == 2 {
+		err = query.Order("confirm_at desc").Offset(offset).Limit(param.PageSize).Find(&rechargeRecords).Error
+	} else if param.RechargeState == 3 {
+		err = query.Order("refuse_at desc").Offset(offset).Limit(param.PageSize).Find(&rechargeRecords).Error
+	}
+	if err != nil {
+		return nil, 0, err
+	}
+
+	return rechargeRecords, total, nil
+}

+ 32 - 1
app/dao/selection_info_dao.go

@@ -168,7 +168,6 @@ func (d SelectionInfoDAO) GetSelectionDraftList(param *vo.SelectionDraftParam) (
 
 // 获取电商带货悬赏任务中全部指定状态值的项目
 func (d SelectionInfoDAO) GetSelectionInfoList(value int64, fieldName string) ([]*entity.SelectionInfo, error) {
-	fmt.Println("Db", Db)
 	var selectionInfos []*entity.SelectionInfo
 	err := Db.Model(entity.SelectionInfo{}).Where(fmt.Sprintf("task_mode = ? AND %s = ? ", fieldName), 1, value).Find(&selectionInfos).Error
 	if err != nil {
@@ -176,3 +175,35 @@ func (d SelectionInfoDAO) GetSelectionInfoList(value int64, fieldName string) ([
 	}
 	return selectionInfos, nil
 }
+
+// 获取电商带货冻结中的任务
+func (d SelectionInfoDAO) GetSelectionFrozenList(enterpriseId string) ([]*entity.SelectionInfo, error) {
+	var selectionInfos []*entity.SelectionInfo
+	query := Db.Debug().Model(entity.SelectionInfo{})
+	query.Select("selection_id, product_id, enterprise_id, sub_account_id, platform, estimated_cost, pay_at") // 冻结金额:estimated_cost
+	err := query.Where(fmt.Sprintf("enterprise_id = ? AND (selection_status between 5 and 6) "), enterpriseId).Find(&selectionInfos).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return selectionInfos, nil
+		} else {
+			return nil, err
+		}
+	}
+	return selectionInfos, nil
+}
+
+// 获取电商带货冻结解除的任务
+func (d SelectionInfoDAO) GetSelectionFrozenCancelList(enterpriseId string) ([]*entity.SelectionInfo, error) {
+	var selectionInfos []*entity.SelectionInfo
+	query := Db.Debug().Model(entity.SelectionInfo{})
+	query.Select("selection_id, product_id, enterprise_id, sub_account_id, platform, settlement_amount, pay_at") // 解冻金额:settlement_amount
+	err := query.Where(fmt.Sprintf("enterprise_id = ? AND (selection_status between 7 and 8) "), enterpriseId).Find(&selectionInfos).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return selectionInfos, nil
+		} else {
+			return nil, err
+		}
+	}
+	return selectionInfos, nil
+}

+ 1 - 0
app/entity/project.go

@@ -21,6 +21,7 @@ type Project struct {
 	EnterpriseID      string    `gorm:"column:enterprise_id"`                  // 所属企业id
 	SubAccountId      int64     `gorm:"column:sub_account_id"`                 // 子账号id
 	ProductID         int64     `gorm:"column:product_id"`                     // 关联商品id
+	ProductCategory   string    `gorm:"column:product_category"`               // 商品类目1--20
 	CreatedAt         time.Time `gorm:"column:created_at"`                     // 创建时间
 	UpdatedAt         time.Time `gorm:"column:updated_at"`                     // 修改时间
 	FeeForm           string    `gorm:"column:fee_form"`                       // 稿费形式列表

+ 2 - 1
app/entity/recharge_record.go

@@ -5,7 +5,6 @@ import "time"
 type RechargeRecord struct {
 	RechargeID         string    `gorm:"column:recharge_id;primary_key"`       // 充值订单ID
 	EnterpriseID       string    `gorm:"column:enterprise_id;NOT NULL"`        // 企业id
-	SubAccountId       int64     `gorm:"column:sub_account_id;NOT NULL"`       // 子账号id
 	RechargeAmount     float64   `gorm:"column:recharge_amount;NOT NULL"`      // 充值金额
 	TransferVoucherUrl string    `gorm:"column:transfer_voucher_url;NOT NULL"` // 转账凭证图片链接
 	Phone              string    `gorm:"column:phone;NOT NULL"`                // 联系方式
@@ -14,6 +13,8 @@ type RechargeRecord struct {
 	InvoiceStatus      int       `gorm:"column:invoice_status;NOT NULL"`       // 开票状态:1为可开票,2为待开票,3为已开票
 	CommitAt           time.Time `gorm:"column:commit_at;NOT NULL"`            // 充值申请提交时间
 	ConfirmAt          time.Time `gorm:"column:confirm_at"`                    // 充值确认时间
+	FailReason         string    `gorm:"column:fail_reason;NOT NULL"`          // 失败原因
+	RefuseAt           time.Time `gorm:"column:refuse_at;NOT NULL"`            // 充值失败时间
 }
 
 func (m *RechargeRecord) TableName() string {

+ 1 - 0
app/entity/selection_info.go

@@ -12,6 +12,7 @@ type SelectionInfo struct {
 	EnterpriseID     string    `gorm:"column:enterprise_id"`            // 所属企业id
 	SubAccountId     int64     `gorm:"column:sub_account_id"`           // 子账号id
 	ProductID        int64     `gorm:"column:product_id"`               // 关联商品id
+	ProductCategory  string    `gorm:"column:product_category"`         // 商品类目1--20
 	SelectionStatus  int64     `gorm:"column:selection_status"`         // 选品项目状态,1-8分别代表创建中、待审核、审核通过、待支付、已支付、执行中、失效、已结案
 	Platform         int64     `gorm:"column:platform"`                 // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
 	SampleNum        int64     `gorm:"column:sample_num"`               // 样品数量

+ 8 - 8
app/service/default_service.go

@@ -12,10 +12,10 @@ type DefaultService struct{}
 
 // 违约管理——违约公开任务列表
 func (s DefaultService) GetPublicDefaultList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
-	if param.Page == 0 {
+	if param.Page <= 0 {
 		param.Page = 1
 	}
-	if param.PageSize == 0 {
+	if param.PageSize <= 0 {
 		param.PageSize = 10
 	}
 	var result vo.ResultVO
@@ -74,10 +74,10 @@ func (s DefaultService) GetPublicDefaultList(param *vo.DefaultSearchParam) (vo.R
 
 // 违约管理——违约定向任务列表
 func (s DefaultService) GetTargetDefaultList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
-	if param.Page == 0 {
+	if param.Page <= 0 {
 		param.Page = 1
 	}
-	if param.PageSize == 0 {
+	if param.PageSize <= 0 {
 		param.PageSize = 10
 	}
 	var result vo.ResultVO
@@ -128,10 +128,10 @@ func (s DefaultService) GetTargetDefaultList(param *vo.DefaultSearchParam) (vo.R
 
 // 违约管理——公开任务-违约达人列表
 func (s DefaultService) GetPublicDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
-	if param.Page == 0 {
+	if param.Page <= 0 {
 		param.Page = 1
 	}
-	if param.PageSize == 0 {
+	if param.PageSize <= 0 {
 		param.PageSize = 10
 	}
 	var result vo.ResultVO
@@ -235,10 +235,10 @@ func (s DefaultService) GetPublicDefaultTalentList(param *vo.DefaultSearchParam)
 
 // 违约管理——定向任务-违约达人列表
 func (s DefaultService) GetTargetDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
-	if param.Page == 0 {
+	if param.Page <= 0 {
 		param.Page = 1
 	}
-	if param.PageSize == 0 {
+	if param.PageSize <= 0 {
 		param.PageSize = 10
 	}
 	var result vo.ResultVO

+ 1 - 0
app/service/project_service.go

@@ -48,6 +48,7 @@ func (s ProjectService) CreateProject(param *vo.ProjectCreateParam) (*string, er
 		ProjectType:      param.ProjectType,
 		ProjectId:        projectId,
 		ProductID:        param.ProductId,
+		ProductCategory:  product.ProductCategory,
 		EnterpriseID:     param.EnterpriseId,
 		SubAccountId:     param.SubAccountId,
 		ProjectPlatform:  param.Platform,

+ 226 - 12
app/service/recharge_service.go

@@ -2,13 +2,14 @@ package service
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	log "github.com/sirupsen/logrus"
 	"github.com/wechatpay-apiv3/wechatpay-go/core"
 	"github.com/wechatpay-apiv3/wechatpay-go/core/option"
 	"github.com/wechatpay-apiv3/wechatpay-go/services/payments/native"
 	"github.com/wechatpay-apiv3/wechatpay-go/utils"
-	"strconv"
+	"gorm.io/gorm"
 	"time"
 	"youngee_b_api/app/dao"
 	"youngee_b_api/app/entity"
@@ -22,13 +23,15 @@ type RechargeService struct{}
 func (s RechargeService) TransferToPublic(param *vo.RechargeTransferParam) (*string, error) {
 	var rechargeId string
 	var phone string
-	if param.SubAccountId == 0 {
-		rechargeId = util.MakeRechargeId(param.EnterpriseId)
-		phone, _ = dao.EnterpriseDao{}.GetEnterprisePhone(param.EnterpriseId)
-	} else {
-		rechargeId = util.MakeRechargeId(strconv.FormatInt(param.SubAccountId, 10))
-		phone, _ = dao.SubAccountDao{}.GetSubAccountPhone(param.SubAccountId)
-	}
+	//if param.SubAccountId == 0 {
+	//	rechargeId = util.MakeRechargeId(param.EnterpriseId)
+	//	phone, _ = dao.EnterpriseDao{}.GetEnterprisePhone(param.EnterpriseId)
+	//} else {
+	//	rechargeId = util.MakeRechargeId(strconv.FormatInt(param.SubAccountId, 10))
+	//	phone, _ = dao.SubAccountDao{}.GetSubAccountPhone(param.SubAccountId)
+	//}
+	rechargeId = util.MakeRechargeId(param.EnterpriseId)
+	phone, _ = dao.EnterpriseDao{}.GetEnterprisePhone(param.EnterpriseId)
 	rechargeRecord := entity.RechargeRecord{
 		RechargeID:         rechargeId,
 		EnterpriseID:       param.EnterpriseId,
@@ -47,7 +50,8 @@ func (s RechargeService) TransferToPublic(param *vo.RechargeTransferParam) (*str
 	return &rechargeId, nil
 }
 
-func (s RechargeService) NativeApiServicePrepay(tradeId string, amount int64) (codeUrl string, err error) {
+// 获取微信支付CodeUrl
+func (s RechargeService) NativeApiServicePrepay(tradeId string, amount int64) (string, *time.Time, error) {
 	var (
 		mchID                      string = "1615933939"                               // 商户号
 		mchCertificateSerialNumber string = "33DDFEC51BF5412F663B9B56510FD567B625FC68" // 商户证书序列号
@@ -74,13 +78,14 @@ func (s RechargeService) NativeApiServicePrepay(tradeId string, amount int64) (c
 	// 采用 Native 支付方式
 	svc := native.NativeApiService{Client: client}
 	// 发送请求
+	timeExpire := time.Now().Add(10 * time.Minute)
 	resp, result, err := svc.Prepay(ctx,
 		native.PrepayRequest{
 			Appid:         core.String("wxac396a3be7a16844"),
 			Mchid:         core.String("1615933939"),
 			Description:   core.String("样叽微信支付充值"),
 			OutTradeNo:    core.String(tradeId),
-			TimeExpire:    core.Time(time.Now().Add(10 * time.Minute)),
+			TimeExpire:    core.Time(timeExpire),
 			Attach:        core.String("微信支付充值"),
 			NotifyUrl:     core.String("https://www.weixin.qq.com/wxpay/pay.php"),
 			SupportFapiao: core.Bool(true),
@@ -94,15 +99,17 @@ func (s RechargeService) NativeApiServicePrepay(tradeId string, amount int64) (c
 	if err != nil {
 		// 处理错误
 		log.Printf("call Prepay err:%s", err)
-		return "", err
+		return "", nil, err
 	} else {
 		// 处理返回结果
 		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
 		log.Println("codeUrl:", *resp.CodeUrl)
 	}
-	return *resp.CodeUrl, nil
+	return *resp.CodeUrl, &timeExpire, nil
 }
 
+// 根据交易id查询微信是否扫码付款
+// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_2.shtml
 func (s RechargeService) QueryOrderByTradeId(tradeId string) (tradeState string, err error) {
 	var (
 		mchID                      string = "1615933939"                               // 商户号
@@ -145,3 +152,210 @@ func (s RechargeService) QueryOrderByTradeId(tradeId string) (tradeState string,
 	fmt.Printf("支付状态 %+v\n", *resp.TradeState)
 	return *resp.TradeState, nil
 }
+
+// 余额管理——总金额、可用余额、冻结金额
+func (s RechargeService) ShowBalance(param *vo.BalanceParam) (*vo.ReBalanceShow, error) {
+	reBalanceShow := new(vo.ReBalanceShow)
+	enterprise, err := dao.EnterpriseDao{}.GetEnterpriseInfo(param.EnterpriseId)
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return reBalanceShow, nil
+		} else {
+			return nil, err
+		}
+	}
+	reBalanceShow.TotalBalance = enterprise.Balance
+	reBalanceShow.AvailBalance = enterprise.AvailableBalance
+	reBalanceShow.FrozenBalance = enterprise.FrozenBalance
+	return reBalanceShow, nil
+}
+
+// 余额管理——冻结记录
+func (s RechargeService) FrozenInfoList(param *vo.BalanceParam) (vo.ResultVO, error) {
+	if param.Page <= 0 {
+		param.Page = 1
+	}
+	if param.PageSize <= 0 {
+		param.PageSize = 10
+	}
+	var result vo.ResultVO
+	var reBalanceShows []*vo.ReFrozenInfo
+	var selectionInfos []*entity.SelectionInfo
+	var projects []*entity.Project
+	if param.FrozenState == 1 {
+		// 电商带货
+		selectionInfos, _ = dao.SelectionInfoDAO{}.GetSelectionFrozenList(param.EnterpriseId)
+		// 品牌种草
+		projects, _ = dao.ProjectDAO{}.GetProjectFrozenList(param.EnterpriseId)
+		// 本地生活
+
+	} else {
+		// 电商带货
+		selectionInfos, _ = dao.SelectionInfoDAO{}.GetSelectionFrozenCancelList(param.EnterpriseId)
+		// 品牌种草
+		projects, _ = dao.ProjectDAO{}.GetProjectFrozenCancelList(param.EnterpriseId)
+		// 本地生活
+
+	}
+	// 汇总结果
+	for _, selection := range selectionInfos {
+		// 获取商品详情字段
+		var creatorName string
+		var productName string
+		var productPrice float64
+		var mainImage string
+		if selection.SubAccountId == 0 {
+			enterprise, err := dao.EnterpriseDao{}.GetEnterprise(selection.EnterpriseID)
+			if err == nil && enterprise != nil {
+				creatorName = enterprise.BusinessName
+			}
+		} else {
+			subAccount, err := dao.SubAccountDao{}.GetSubAccount(selection.SubAccountId)
+			if err == nil && subAccount != nil {
+				creatorName = subAccount.SubAccountName
+			}
+		}
+		product, err := dao.ProductDAO{}.GetProductByID(selection.ProductID)
+		if err == nil && product != nil {
+			productName = product.ProductName
+			productPrice = product.ProductPrice
+		}
+		mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(selection.ProductID)
+		// 电商带货汇总
+		reBalanceShow := &vo.ReFrozenInfo{
+			ProductId:     selection.ProductID,
+			MainImage:     mainImage,
+			ProductName:   productName,
+			ProductPrice:  productPrice,
+			Platform:      selection.Platform,
+			CreatorName:   creatorName,
+			TaskType:      "电商带货",
+			FrozenBalance: selection.EstimatedCost,
+			FrozenTime:    selection.PayAt.Format("2006-01-02 15:04:05"),
+			EnterpriseId:  selection.EnterpriseID,
+			SubAccountId:  selection.SubAccountId,
+			TaskId:        selection.SelectionID,
+		}
+		if param.FrozenState == 2 {
+			reBalanceShow.FrozenCancelBalance = selection.SettlementAmount
+		}
+		reBalanceShows = append(reBalanceShows, reBalanceShow)
+	}
+	for _, project := range projects {
+		// 获取商品详情字段
+		var creatorName string
+		var productName string
+		var productPrice float64
+		var mainImage string
+		if project.SubAccountId == 0 {
+			enterprise, err := dao.EnterpriseDao{}.GetEnterprise(project.EnterpriseID)
+			if err == nil && enterprise != nil {
+				creatorName = enterprise.BusinessName
+			}
+		} else {
+			subAccount, err := dao.SubAccountDao{}.GetSubAccount(project.SubAccountId)
+			if err == nil && subAccount != nil {
+				creatorName = subAccount.SubAccountName
+			}
+		}
+		product, err := dao.ProductDAO{}.GetProductByID(project.ProductID)
+		if err == nil && product != nil {
+			productName = product.ProductName
+			productPrice = product.ProductPrice
+		}
+		mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(project.ProductID)
+		// 电商带货汇总
+		reBalanceShow := &vo.ReFrozenInfo{
+			ProductId:     project.ProductID,
+			MainImage:     mainImage,
+			ProductName:   productName,
+			ProductPrice:  productPrice,
+			Platform:      project.ProjectPlatform,
+			CreatorName:   creatorName,
+			TaskType:      "品牌种草",
+			FrozenBalance: project.PaymentAmount,
+			FrozenTime:    project.PayAt.Format("2006-01-02 15:04:05"),
+			EnterpriseId:  project.EnterpriseID,
+			SubAccountId:  project.SubAccountId,
+			TaskId:        project.ProjectId,
+		}
+		if param.FrozenState == 2 {
+			reBalanceShow.FrozenCancelBalance = project.SettlementAmount
+		}
+		reBalanceShows = append(reBalanceShows, reBalanceShow)
+	}
+
+	startIndex := (param.Page - 1) * param.PageSize
+	endIndex := startIndex + param.PageSize
+
+	// 分页
+	if startIndex >= len(reBalanceShows) {
+		return result, nil
+	}
+	if endIndex > len(reBalanceShows) {
+		endIndex = len(reBalanceShows)
+	}
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    int64(len(reBalanceShows)),
+		Data:     reBalanceShows[startIndex:endIndex],
+	}
+	return result, nil
+}
+
+// 充值管理——累计充值金额、确认中金额
+func (s RechargeService) ShowRecharge(param *vo.RechargeParam) (*vo.ReRechargeShow, error) {
+	reRechargeShow := new(vo.ReRechargeShow)
+	confirmingRecharge, _ := dao.RechargeRecordDao{}.GetRechargeAmount(param.EnterpriseId, 1)
+	totalRecharge, _ := dao.RechargeRecordDao{}.GetRechargeAmount(param.EnterpriseId, 2)
+	reRechargeShow.ConfirmingRecharge = confirmingRecharge
+	reRechargeShow.TotalRecharge = totalRecharge
+	return reRechargeShow, nil
+}
+
+// 充值管理——充值记录
+func (s RechargeService) RechargeInfoList(param *vo.RechargeParam) (vo.ResultVO, error) {
+	if param.Page <= 0 {
+		param.Page = 1
+	}
+	if param.PageSize <= 0 {
+		param.PageSize = 10
+	}
+	var result vo.ResultVO
+	var reRechargeInfos []*vo.ReRechargeInfo
+	rechargeRecords, total, err := dao.RechargeRecordDao{}.RechargeInfoList(param)
+	if err != nil {
+		return result, err
+	}
+	for _, rechargeRecord := range rechargeRecords {
+		var creatorName string
+		enterprise, err := dao.EnterpriseDao{}.GetEnterprise(param.EnterpriseId)
+		if err == nil && enterprise != nil {
+			creatorName = enterprise.BusinessName
+		}
+		reRechargeInfo := &vo.ReRechargeInfo{
+			RechargeId:         rechargeRecord.RechargeID,
+			CreatorName:        creatorName,
+			RechargeAmount:     rechargeRecord.RechargeAmount,
+			RechargeMethod:     rechargeRecord.RechargeMethod,
+			TransferVoucherUrl: rechargeRecord.TransferVoucherUrl,
+		}
+		if param.RechargeState == 1 {
+			reRechargeInfo.CommitAt = rechargeRecord.CommitAt.Format("2006-01-02 15:04:05")
+		} else if param.RechargeState == 2 {
+			reRechargeInfo.ConfirmAt = rechargeRecord.ConfirmAt.Format("2006-01-02 15:04:05")
+		} else if param.RechargeState == 3 {
+			reRechargeInfo.RefuseAt = rechargeRecord.RefuseAt.Format("2006-01-02 15:04:05")
+			reRechargeInfo.FailReason = rechargeRecord.FailReason
+		}
+		reRechargeInfos = append(reRechargeInfos, reRechargeInfo)
+	}
+	result = vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     reRechargeInfos,
+	}
+	return result, nil
+}

+ 1 - 0
app/service/selection_info_service.go

@@ -76,6 +76,7 @@ func (s SelectionInfoService) CreateSelectionInfo(param *vo.SelectionInfoCreateP
 		SelectionStatus:  1,
 		SelectionID:      selectionId,
 		ProductID:        param.ProductId,
+		ProductCategory:  product.ProductCategory,
 		EnterpriseID:     param.EnterpriseId,
 		SubAccountId:     param.SubAccountId,
 		Platform:         param.Platform,

+ 8 - 0
app/vo/balance_param.go

@@ -0,0 +1,8 @@
+package vo
+
+type BalanceParam struct {
+	EnterpriseId string `json:"enterprise_id"` // 企业id
+	FrozenState  int64  `json:"frozen_state"`  // 冻结状态(1冻结中 2冻结解除)
+	Page         int    `json:"page"`
+	PageSize     int    `json:"page_size"`
+}

+ 7 - 5
app/vo/pay_wx_param.go

@@ -1,14 +1,16 @@
 package vo
 
 type GetCodeUrlParam struct {
-	Amount int64 `json:"amount"`
+	EnterpriseId string `json:"enterprise_id"` // 企业id
+	Amount       int64  `json:"amount"`        // 金额(分)
 }
 
-type ReCodeUrl struct {
-	CodeUrl string `json:"code_url"`
+type QueryOrderByTradeIdParam struct {
 	TradeId string `json:"trade_id"`
 }
 
-type QueryOrderByTradeIdParam struct {
-	TradeId string `json:"trade_id"`
+type ReCodeUrl struct {
+	CodeUrl    string `json:"codeUrl"`
+	TradeId    string `json:"tradeId"`
+	TimeExpire string `json:"timeExpire"`
 }

+ 7 - 0
app/vo/re_balance_show.go

@@ -0,0 +1,7 @@
+package vo
+
+type ReBalanceShow struct {
+	TotalBalance  float64 `json:"totalBalance"`  // 总金额
+	AvailBalance  float64 `json:"availBalance"`  // 可用余额
+	FrozenBalance float64 `json:"frozenBalance"` // 冻结金额
+}

+ 17 - 0
app/vo/re_frozen_info.go

@@ -0,0 +1,17 @@
+package vo
+
+type ReFrozenInfo struct {
+	ProductId           int64   `json:"productId"`
+	MainImage           string  `json:"mainImage"`
+	ProductName         string  `json:"productName"`
+	ProductPrice        float64 `json:"productPrice"`
+	Platform            int64   `json:"platform"`
+	CreatorName         string  `json:"creatorName"`
+	TaskType            string  `json:"taskType"` // 任务类型
+	FrozenBalance       float64 `json:"frozenBalance"`
+	FrozenCancelBalance float64 `json:"frozenCancelBalance"`
+	FrozenTime          string  `json:"frozenTime"`
+	EnterpriseId        string  `json:"enterpriseId"`
+	SubAccountId        int64   `json:"subAccountId"`
+	TaskId              string  `json:"taskId"`
+}

+ 13 - 0
app/vo/re_recharge_info.go

@@ -0,0 +1,13 @@
+package vo
+
+type ReRechargeInfo struct {
+	RechargeId         string  `json:"recharge_id"`
+	CreatorName        string  `json:"creatorName"`
+	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"` // 失败原因
+}

+ 6 - 0
app/vo/re_recharge_show.go

@@ -0,0 +1,6 @@
+package vo
+
+type ReRechargeShow struct {
+	TotalRecharge      float64 `json:"totalRecharge"`      // 累计充值金额
+	ConfirmingRecharge float64 `json:"rechargeConfirming"` // 充值确认中金额
+}

+ 8 - 0
app/vo/recharge_param.go

@@ -0,0 +1,8 @@
+package vo
+
+type RechargeParam struct {
+	EnterpriseId  string `json:"enterprise_id"`  // 企业id
+	RechargeState int64  `json:"recharge_state"` // 充值状态(1充值待确认 2已充值 3充值失败)
+	Page          int    `json:"page"`
+	PageSize      int    `json:"page_size"`
+}

+ 0 - 1
app/vo/recharge_transfer_param.go

@@ -2,7 +2,6 @@ package vo
 
 type RechargeTransferParam struct {
 	EnterpriseId       string  `json:"enterprise_id"`
-	SubAccountId       int64   `json:"sub_account_id"`
 	Amount             float64 `json:"amount"`
 	TransferVoucherUrl string  `json:"transfer_voucher_url"`
 }

+ 15 - 13
route/init.go

@@ -1,6 +1,8 @@
 package route
 
 import (
+	swaggerFiles "github.com/swaggo/files"
+	ginSwagger "github.com/swaggo/gin-swagger"
 	"youngee_b_api/app/controller"
 	"youngee_b_api/handler"
 	"youngee_b_api/middleware"
@@ -11,14 +13,14 @@ import (
 )
 
 func InitRoute(r *gin.Engine) {
-	//r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
-	//r.POST("/register", handler.WrapRegisterHandler)                 // 商家主账号注册
-	//r.POST("/addNewSubAccount", handler.WrapAddNewSubAccountHandler) // 商家子账号注册
-	//r.POST("/addNewJob", handler.WrapaddNewJobHandler)               // 商家新增岗位
-	//r.POST("/updateJob", handler.WrapupdateJobHandler)               // 商家修改岗位
-	//r.POST("/deleteJob", handler.WrapdeleteJobHandler)               // 商家删除岗位
-	//r.POST("/sendCode", handler.WrapSendCodeHandler)                 // 发送登录验证码
-	//r.POST("/login", handler.WrapCodeLoginHandler)                   // 商家登录
+	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
+	r.POST("/register", handler.WrapRegisterHandler)                 // 商家主账号注册
+	r.POST("/addNewSubAccount", handler.WrapAddNewSubAccountHandler) // 商家子账号注册
+	r.POST("/addNewJob", handler.WrapaddNewJobHandler)               // 商家新增岗位
+	r.POST("/updateJob", handler.WrapupdateJobHandler)               // 商家修改岗位
+	r.POST("/deleteJob", handler.WrapdeleteJobHandler)               // 商家删除岗位
+	r.POST("/sendCode", handler.WrapSendCodeHandler)                 // 发送登录验证码
+	r.POST("/login", handler.WrapCodeLoginHandler)                   // 商家登录
 	r.GET("/test/ping", func(c *gin.Context) {
 		resp := http_model.CommonResponse{
 			Status:  0,
@@ -226,14 +228,14 @@ func InitRoute(r *gin.Engine) {
 	finance := r.Group("/youngee/b/finance")
 	{
 		finance.Use(middleware.LoginAuthMiddleware)
-		// 余额管理——总金额、可用余额、冻结金额
-		// 余额管理——冻结记录
-		// 充值管理——累计充值金额、确认中金额
-		// 充值管理——充值记录
-		// YG官方汇款账号
 		finance.POST("/recharge/transferToPublic", controller.FinanceController{}.TransferToPublic)  // 充值管理——对公转账
 		finance.POST("/pay/getCodeUrl", controller.FinanceController{}.GetCodeUrl)                   // 获取微信支付codeURL
 		finance.POST("/pay/queryOrderByTradeId", controller.FinanceController{}.QueryOrderByTradeId) // 根据交易id查询微信是否扫码付款
+		finance.POST("/balance/show", controller.FinanceController{}.ShowBalance)                    // 余额管理——总金额、可用余额、冻结金额
+		finance.POST("/balance/frozen/info", controller.FinanceController{}.FrozenInfoList)          // 余额管理——冻结记录
+		finance.POST("/recharge/show", controller.FinanceController{}.ShowRecharge)                  // 充值管理——累计充值金额、确认中金额
+		finance.POST("/recharge/info", controller.FinanceController{}.RechargeInfoList)              // 充值管理——充值记录
+		// YG官方汇款账号
 	}
 
 }