Kaynağa Gözat

开票金额数据

Ethan 1 ay önce
ebeveyn
işleme
ddcc7e98d2

+ 18 - 0
app/controller/finance_controller.go

@@ -239,3 +239,21 @@ func (f FinanceController) GetBillableList(c *gin.Context) {
 	}
 	returnSuccess(c, 20000, result)
 }
+
+// 开票金额数据-已开票、可开票、开票中
+func (f FinanceController) ShowInvoiceBill(c *gin.Context) {
+	param := &vo.InvoiceBillListParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	res, err := service.InvoiceService{}.ShowInvoiceBill(param)
+	if err != nil {
+		logrus.Errorf("[ShowInvoiceBill] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, res)
+}

+ 10 - 0
app/dao/local_life_dao.go

@@ -581,3 +581,13 @@ func (d LocalLifeDao) GetDefaultToDo(enterpriseId string, subAccountId int64, pl
 
 	return resultMap, nil
 }
+
+// 获取指定商家已结案的指定开票状态数据
+func (d LocalLifeDao) GetLocalLifeFinished(enterpriseId string, invoiceStatus int64) (float64, error) {
+	var localLifeAmount float64
+	err := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and task_status = ? and invoice_status = ?", enterpriseId, 10, invoiceStatus).Select("COALESCE(SUM(settlement_amount), 0)").Find(&localLifeAmount).Error
+	if err != nil {
+		return 0, err
+	}
+	return localLifeAmount, err
+}

+ 10 - 0
app/dao/project_dao.go

@@ -644,3 +644,13 @@ func (d ProjectDAO) GetDefaultToDo(enterpriseId string, subAccountId int64, plat
 
 	return resultMap, nil
 }
+
+// 获取指定商家已结案的指定开票状态数据
+func (d ProjectDAO) GetProjectFinished(enterpriseId string, invoiceStatus int64) (float64, error) {
+	var projectAmount float64
+	err := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_status = ? and invoice_status = ?", enterpriseId, 10, invoiceStatus).Select("COALESCE(SUM(settlement_amount), 0)").Find(&projectAmount).Error
+	if err != nil {
+		return 0, err
+	}
+	return projectAmount, err
+}

+ 10 - 0
app/dao/selection_info_dao.go

@@ -409,3 +409,13 @@ func (d SelectionInfoDAO) GetLogisticsToDo(enterpriseId string, subAccountId int
 
 	return resultMap, nil
 }
+
+// 获取指定商家已结案的指定开票状态数据
+func (d SelectionInfoDAO) GetSelectionFinished(enterpriseId string, invoiceStatus int64) (float64, error) {
+	var selectionAmount float64
+	err := Db.Model(&entity.SelectionInfo{}).Where("enterprise_id = ? and selection_status = ? and invoice_status = ?", enterpriseId, 8, invoiceStatus).Select("COALESCE(SUM(settlement_amount), 0)").Scan(&selectionAmount).Error
+	if err != nil {
+		return 0, err
+	}
+	return selectionAmount, err
+}

+ 1 - 1
app/entity/local_life_info.go

@@ -41,7 +41,7 @@ type LocalLifeInfo struct {
 	PassAt              time.Time `gorm:"column:pass_at"`                                   // 审核通过时间
 	FinishAt            time.Time `gorm:"column:finish_at"`                                 // 结案时间
 	EstimatedCost       float64   `gorm:"column:estimated_cost"`                            // 预估成本
-	SettlementAmount    float64   `gorm:"column:settlement_amount"`                         // 结算金额
+	SettlementAmount    float64   `gorm:"column:settlement_amount;NOT NULL"`                // 结算金额
 	TotalRecruitNum     int64     `gorm:"column:total_recruit_num"`                         // 此任务各策略招募人数总和
 	Tools               string    `gorm:"column:tools"`                                     // 工具选择,1邀约招募 2结算账单 3样品物流 4审稿工具 5作品审查 6数据巡检(,分隔)
 	NeedReview          int64     `gorm:"column:need_review;default:0;NOT NULL"`            // 待审稿

+ 1 - 1
app/entity/project.go

@@ -39,7 +39,7 @@ type Project struct {
 	SubmitAt          time.Time `gorm:"column:submit_at"`                      // 结案时间
 	EstimatedCost     float64   `gorm:"column:estimated_cost"`                 // 预估成本
 	IsRead            int64     `gorm:"column:is_read"`                        // 是否已读
-	SettlementAmount  float64   `gorm:"column:settlement_amount"`              // 结算金额
+	SettlementAmount  float64   `gorm:"column:settlement_amount;NOT NULL"`     // 结算金额
 	ProductSnap       string    `gorm:"column:product_snap"`                   // 商品信息快照
 	ProductPhotoSnap  string    `gorm:"column:product_photo_snap"`             // 商品图片快照
 	NeedReview        int64     `gorm:"column:need_review"`                    // 待审稿

+ 1 - 1
app/entity/selection_info.go

@@ -28,7 +28,7 @@ type SelectionInfo struct {
 	TaskReward       float64   `gorm:"column:task_reward"`                   // 任务悬赏
 	SampleCondition  string    `gorm:"column:sample_condition"`              // 领样条件
 	RewardCondition  string    `gorm:"column:reward_condition"`              // 返现悬赏条件
-	SettlementAmount float64   `gorm:"column:settlement_amount"`             // 结算金额
+	SettlementAmount float64   `gorm:"column:settlement_amount;NOT NULL"`    // 结算金额
 	Detail           string    `gorm:"column:detail"`                        // 卖点总结
 	ProductSnap      string    `gorm:"column:product_snap"`                  // 商品信息快照
 	ProductPhotoSnap string    `gorm:"column:product_photo_snap"`            // 商品图片快照

+ 50 - 0
app/service/invoice_service.go

@@ -307,3 +307,53 @@ func (s InvoiceService) GetBillableList(param *vo.InvoiceBillListParam) (vo.Resu
 	}
 	return result, nil
 }
+
+// 开票金额数据-已开票、可开票、开票中
+func (s InvoiceService) ShowInvoiceBill(param *vo.InvoiceBillListParam) (map[string]float64, error) {
+	resMap := make(map[string]float64)
+	// 可开票
+	selectionAmount1, err1 := dao.SelectionInfoDAO{}.GetSelectionFinished(param.EnterpriseId, 0)
+	if err1 != nil {
+		return resMap, err1
+	}
+	projectAmount1, err1 := dao.ProjectDAO{}.GetProjectFinished(param.EnterpriseId, 0)
+	if err1 != nil {
+		return resMap, err1
+	}
+	localLifeAmount1, err1 := dao.LocalLifeDao{}.GetLocalLifeFinished(param.EnterpriseId, 0)
+	if err1 != nil {
+		return resMap, err1
+	}
+	// 开票中
+	selectionAmount2, err2 := dao.SelectionInfoDAO{}.GetSelectionFinished(param.EnterpriseId, 1)
+	if err2 != nil {
+		return resMap, err2
+	}
+	projectAmount2, err2 := dao.ProjectDAO{}.GetProjectFinished(param.EnterpriseId, 1)
+	if err2 != nil {
+		return resMap, err2
+	}
+	localLifeAmount2, err2 := dao.LocalLifeDao{}.GetLocalLifeFinished(param.EnterpriseId, 1)
+	if err2 != nil {
+		return resMap, err2
+	}
+	// 已开票
+	selectionAmount3, err3 := dao.SelectionInfoDAO{}.GetSelectionFinished(param.EnterpriseId, 2)
+	if err3 != nil {
+		return resMap, err3
+	}
+	projectAmount3, err3 := dao.ProjectDAO{}.GetProjectFinished(param.EnterpriseId, 2)
+	if err3 != nil {
+		return resMap, err3
+	}
+	localLifeAmount3, err3 := dao.LocalLifeDao{}.GetLocalLifeFinished(param.EnterpriseId, 2)
+	if err3 != nil {
+		return resMap, err3
+	}
+
+	resMap["invoicableAmount"] = selectionAmount1 + projectAmount1 + localLifeAmount1
+	resMap["invoicingAmount"] = selectionAmount2 + projectAmount2 + localLifeAmount2
+	resMap["invoicedAmount"] = selectionAmount3 + projectAmount3 + localLifeAmount3
+
+	return resMap, nil
+}

+ 1 - 0
route/init.go

@@ -323,6 +323,7 @@ func InitRoute(r *gin.Engine) {
 		finance.POST("/invoice/bill", controller.FinanceController{}.BillInvoice)                    // 确认开票
 		finance.POST("/invoice/list/bill", controller.FinanceController{}.GetBillList)               // 开票记录
 		finance.POST("/invoice/list/billable", controller.FinanceController{}.GetBillableList)       // 可开票账单
+		finance.POST("/invoice/bill/show", controller.FinanceController{}.ShowInvoiceBill)           // 开票金额数据-已开票、可开票、开票中
 
 		finance.POST("/bill/selection/pay", controller.BillController{}.SelectionPay)       // 电商带货账单支付
 		finance.POST("/bill/project/pay", controller.BillController{}.ProjectPay)           // 品牌种草账单支付