Ohio-HYF 2 роки тому
батько
коміт
c8c4ebeb72

+ 1 - 1
db/auto_task.go

@@ -38,7 +38,7 @@ func AutoUpdateApplyTimes() error {
 	db := GetReadDB(context.Background())
 	// 查询task表信息
 	db = db.Debug().Model(gorm_model.YoungeeTalentInfo{})
-	err := db.Update("apply_num", 5).Error
+	err := db.Where("1 = 1").Update("apply_num", 5).Error
 	if err != nil {
 		log.Println("DB AutoUpdateStatus error :", err)
 		return err

+ 17 - 15
db/enterprise.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/issue9/conv"
 	"log"
+	"strconv"
 	"time"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
@@ -64,27 +65,26 @@ func GetEnterpriseBalance(ctx context.Context, EnterpriseID int64) (*http_model.
 			return nil, err
 		}
 	}
-	var Invoicings []float64
 	var Invoicing float64
-	var BillableAmounts []float64
 	var BillableAmount float64
 	db1 := GetReadDB(ctx)
-	db1.Model(gorm_model.YounggeeInvoiceRecord{}).Select("invoice_amount").
-		Where("enterprise_id = ? AND status = 1", EnterpriseID).Find(&Invoicings)
-	for _, v := range Invoicings {
-		Invoicing += v
-	}
+	db1.Model(gorm_model.YounggeeInvoiceRecord{}).Select("sum(invoice_amount) as Invoicing").
+		Where("enterprise_id = ? AND status = 1", EnterpriseID).Find(&Invoicing)
+	Invoicing, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", Invoicing), 64)
 	db2 := GetReadDB(ctx)
-	db2.Model(gorm_model.YounggeeRechargeRecord{}).Select("recharge_amount").
-		Where("enterprise_id = ? AND status != 3", EnterpriseID).Find(&BillableAmounts)
-	for _, v := range BillableAmounts {
-		BillableAmount += v
-	}
+	db2.Model(gorm_model.YounggeeRechargeRecord{}).Select("sum(recharge_amount) as BillableAmount").
+		Where("enterprise_id = ? AND status = 2 AND invoice_status = 2", EnterpriseID).Find(&BillableAmount)
+	BillableAmount, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", BillableAmount), 64)
+	db3 := GetReadDB(ctx)
+	var Recharging float64
+	db3.Model(gorm_model.YounggeeRechargeRecord{}).Select("sum(recharge_amount) as Recharging").
+		Where("enterprise_id = ? AND status = 1 AND invoice_status = 1", EnterpriseID).Find(&Recharging)
+	Recharging, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", Recharging), 64)
 	res := &http_model.EnterpriseBalanceData{
 		Balance:          enterprise.Balance,
 		FrozenBalance:    enterprise.FrozenBalance,
 		AvailableBalance: enterprise.AvailableBalance,
-		Recharging:       enterprise.Recharging,
+		Recharging:       Recharging,
 		BillableAmount:   BillableAmount,
 		Invoicing:        Invoicing,
 	}
@@ -146,7 +146,7 @@ func MakeRechargeId(ctx context.Context, EnterpriseID int64) string {
 	return rechargeIdPrefix + last
 }
 
-func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) error {
+func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64, phone string) error {
 	db := GetReadDB(ctx)
 	err := db.Model(gorm_model.Enterprise{}).Where("enterprise_id", EnterpriseID).
 		Updates(map[string]interface{}{"balance": gorm.Expr("balance + ?", Amount), "available_balance": gorm.Expr("available_balance + ?", Amount)}).Error
@@ -164,10 +164,11 @@ func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) err
 		RechargeAmount:     Amount,
 		EnterpriseID:       EnterpriseID,
 		Status:             2,
-		InvoiceStatus:      1,
+		InvoiceStatus:      2,
 		CommitAt:           time.Now(),
 		RechargeMethod:     3,
 		TransferVoucherUrl: "--",
+		Phone:              phone,
 		ConfirmAt:          time.Now(),
 	}).Error
 	if err != nil {
@@ -179,6 +180,7 @@ func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) err
 func TransferToPublic(ctx context.Context, Amount float64, phone string, EnterpriseID int64, transferVoucherUrl string) error {
 	db := GetReadDB(ctx)
 	rechargeId := MakeRechargeId(ctx, EnterpriseID)
+	fmt.Println("Amount:", Amount)
 	err := db.Model(gorm_model.YounggeeRechargeRecord{}).Create(&gorm_model.YounggeeRechargeRecord{
 		RechargeID:         rechargeId,
 		RechargeAmount:     Amount,

+ 35 - 22
db/invoice.go

@@ -3,6 +3,7 @@ package db
 import (
 	context "context"
 	"encoding/json"
+	"fmt"
 	"github.com/issue9/conv"
 	"github.com/sirupsen/logrus"
 	"time"
@@ -131,6 +132,36 @@ func AddInvoiceRecord(ctx context.Context, enterpriseId int64, req *http_model.A
 	db2 := GetReadDB(ctx)
 	db2.Debug().Model(gorm_model.YounggeeInvoiceAddress{}).Where("address_id = ?", req.AddressID).First(&addressInfo)
 	addressInfoToJson, _ := json.Marshal(addressInfo)
+
+	for _, rechargeId := range req.RechargeIds {
+		rechargeId1 := rechargeId
+		rechargeInfo := gorm_model.YounggeeRechargeRecord{}
+		fmt.Println("rechargeId1:", rechargeId1)
+		db3 := GetReadDB(ctx)
+		db3.Model(gorm_model.YounggeeRechargeRecord{}).Where("recharge_id = ?", rechargeId1).Find(&rechargeInfo)
+		db := GetReadDB(ctx)
+		err := db.Debug().Model(gorm_model.YounggeeInvoiceRecord{}).Create(&gorm_model.YounggeeInvoiceRecord{
+			BillingID:     GetBillingId(ctx, enterpriseId),
+			EnterpriseID:  enterpriseId,
+			InvoiceAmount: rechargeInfo.RechargeAmount,
+			InvoiceSnap:   string(invoiceInfoToJson),
+			AddressSnap:   string(addressInfoToJson),
+			Status:        1,
+			InvoiceType:   invoiceInfo.InvoiceType,
+			Phone:         invoiceInfo.RegisteredPhone,
+			SubmitAt:      time.Now(),
+		}).Error
+		if err != nil {
+			return err
+		}
+	}
+	db3 := GetReadDB(ctx)
+	return db3.Debug().Model(gorm_model.YounggeeRechargeRecord{}).Where("recharge_id IN ?", req.RechargeIds).Updates(gorm_model.YounggeeRechargeRecord{
+		InvoiceStatus: 3,
+	}).Error
+}
+
+func GetBillingId(ctx context.Context, enterpriseId int64) string {
 	db := GetReadDB(ctx)
 	// 1、年月日
 	year := time.Now().Year()
@@ -150,13 +181,13 @@ func AddInvoiceRecord(ctx context.Context, enterpriseId int64, req *http_model.A
 	}
 	last := ""
 	billingIdPrefix := "9" + conv.MustString(enterpriseId)[len(conv.MustString(enterpriseId))-2:] + conv.MustString(sum)
-	var rechargeIdLast string
+	var billingIdLast string
 	err := db.Model(gorm_model.YounggeeInvoiceRecord{}).Select("billing_id").Where("billing_id like ?", billingIdPrefix+"%").
-		Last(&rechargeIdLast).Error
+		Last(&billingIdLast).Error
 	if err != nil {
 		last = "0"
 	} else {
-		last = rechargeIdLast[len(rechargeIdLast)-2:]
+		last = billingIdLast[len(billingIdLast)-2:]
 	}
 	var lastInt int
 	lastInt = conv.MustInt(last)
@@ -165,26 +196,8 @@ func AddInvoiceRecord(ctx context.Context, enterpriseId int64, req *http_model.A
 	} else {
 		last = conv.MustString(conv.MustInt(last) + 1)
 	}
-	err = db.Debug().Model(gorm_model.YounggeeInvoiceRecord{}).Create(&gorm_model.YounggeeInvoiceRecord{
-		BillingID:     billingIdPrefix + last,
-		EnterpriseID:  enterpriseId,
-		InvoiceAmount: req.Amount,
-		InvoiceSnap:   string(invoiceInfoToJson),
-		AddressSnap:   string(addressInfoToJson),
-		Status:        1,
-		InvoiceType:   consts.GetInvoiceType(invoiceInfo.InvoiceType),
-		Phone:         invoiceInfo.RegisteredPhone,
-		SubmitAt:      time.Now(),
-	}).Error
-	if err != nil {
-		return err
-	}
-	db3 := GetReadDB(ctx)
-	return db3.Debug().Model(gorm_model.YounggeeRechargeRecord{}).Where("recharge_id IN ?", req.RechargeIds).Updates(gorm_model.YounggeeRechargeRecord{
-		InvoiceStatus: 3,
-	}).Error
+	return billingIdPrefix + last
 }
-
 func GetInvoiceRecords(ctx context.Context, req *http_model.GetInvoiceRecordRequest) (*http_model.InvoiceRecordsData, error) {
 	db := GetReadDB(ctx)
 	var invoiceRecords []*gorm_model.YounggeeInvoiceRecord

+ 3 - 2
db/pay_record.go

@@ -35,9 +35,9 @@ func CreatePayRecord(ctx context.Context, enterpriseId int64, payment float64, b
 func GetRechargeRecord(ctx context.Context, enterpriseID int64, confirmAt string, method int) (*http_model.RechargeRecordPreview, error) {
 	db := GetReadDB(ctx)
 	// 根据企业id过滤
-	db = db.Debug().Model(gorm_model.YounggeeRechargeRecord{}).Where("enterprise_id = ? AND status = 1", enterpriseID)
+	db = db.Debug().Model(gorm_model.YounggeeRechargeRecord{}).Where("enterprise_id = ?", enterpriseID)
 	if method == 2 {
-		db = db.Where("invoice_status = 1")
+		db = db.Debug().Model(gorm_model.YounggeeRechargeRecord{}).Where("invoice_status = 2")
 	}
 	if confirmAt != "" {
 		db = db.Where("confirm_at like ?", confirmAt+"%")
@@ -49,6 +49,7 @@ func GetRechargeRecord(ctx context.Context, enterpriseID int64, confirmAt string
 		RechargeRecordData := new(http_model.RechargeRecordData)
 		RechargeRecordData.RechargeId = rechargeRecord.RechargeID
 		RechargeRecordData.RechargeAmount = conv.MustString(rechargeRecord.RechargeAmount)
+		RechargeRecordData.RechargeAmountReal = conv.MustString(rechargeRecord.RechargeAmount)
 		RechargeRecordData.TransferVoucher = conv.MustString(rechargeRecord.TransferVoucherUrl)
 		RechargeRecordData.PayMethod = consts.GetRechargeMethod(rechargeRecord.RechargeMethod)
 		RechargeRecordData.ConfirmAt = conv.MustString(rechargeRecord.ConfirmAt)[0:19]

+ 98 - 0
db/workspace.go

@@ -0,0 +1,98 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+)
+
+func GetWorkspaceNums(ctx context.Context, enterpriseID int64) (*http_model.WorkspaceNums, error) {
+	var workspaceNums http_model.WorkspaceNums
+	var PaymentPending, DraftNum, RecruitingFullNum, ExecutionSpecNum, ExecutionFullNum int64
+	db := GetReadDB(ctx)
+	db = db.Model(gorm_model.ProjectInfo{}).Where("enterprise_id = ?", enterpriseID)
+	db.Where("project_status = 1").Count(&DraftNum)
+
+	db1 := GetReadDB(ctx)
+	db1 = db1.Model(gorm_model.ProjectInfo{}).Where("enterprise_id = ?", enterpriseID)
+	db1.Where("project_status = 4 AND project_type = 1").Count(&RecruitingFullNum)
+
+	db2 := GetReadDB(ctx)
+	db2 = db2.Model(gorm_model.ProjectInfo{}).Where("enterprise_id = ?", enterpriseID)
+	db2.Where("project_status = 6").Count(&PaymentPending)
+	db3 := GetReadDB(ctx)
+	db3 = db3.Model(gorm_model.ProjectInfo{}).Where("enterprise_id = ?", enterpriseID)
+	db3.Where("project_status = 9 AND project_type = 2").Count(&ExecutionSpecNum)
+
+	db4 := GetReadDB(ctx)
+	db4 = db4.Model(gorm_model.ProjectInfo{}).Where("enterprise_id = ?", enterpriseID)
+	db4.Where("project_status = 9 AND project_type = 1").Count(&ExecutionFullNum)
+
+	var ProjectFunds float64
+	db5 := GetReadDB(ctx)
+	db5 = db5.Model(gorm_model.Enterprise{}).Select("frozen_balance").Where("enterprise_id = ?", enterpriseID).First(&ProjectFunds)
+
+	workspaceNums.PaymentPending = PaymentPending
+	workspaceNums.DraftNum = DraftNum
+	workspaceNums.RecruitingFullNum = RecruitingFullNum
+	workspaceNums.ExecutionSpecNum = ExecutionSpecNum
+	workspaceNums.ExecutionFullNum = ExecutionFullNum
+	workspaceNums.ProjectFunds = ProjectFunds
+	return &workspaceNums, nil
+}
+
+func GetWorkspacePieNums(ctx context.Context, enterpriseID int64) (*http_model.WorkspacePieNums, error) {
+	var workspaceNums http_model.WorkspacePieNums
+	var DataPendingNum, LinkPendingNum, ScriptPendingNum int64
+	db := GetReadDB(ctx)
+	var DataProjectIDs []int64
+	db = db.Model(gorm_model.ProjectInfo{}).Select("project_id").Where("enterprise_id = ? AND project_status = 9", enterpriseID).Find(&DataProjectIDs)
+	db1 := GetReadDB(ctx)
+	db1.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id IN ? AND task_stage = 14", DataProjectIDs).Count(&DataPendingNum)
+
+	db2 := GetReadDB(ctx)
+	var scriptProjectIDs []int64
+	db2 = db2.Model(gorm_model.ProjectInfo{}).Select("project_id").Where("enterprise_id = ? AND project_status = 9", enterpriseID).Find(&scriptProjectIDs)
+	db3 := GetReadDB(ctx)
+	db3.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id IN ? AND task_stage = 8", scriptProjectIDs).Count(&ScriptPendingNum)
+
+	db4 := GetReadDB(ctx)
+	var linkProjectIDs []int64
+	db4 = db4.Model(gorm_model.ProjectInfo{}).Select("project_id").Where("enterprise_id = ? AND project_status = 9", enterpriseID).Find(&linkProjectIDs)
+	db5 := GetReadDB(ctx)
+	db5 = db5.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("project_id IN ? AND task_stage = 12", linkProjectIDs).Count(&LinkPendingNum)
+
+	workspaceNums.DataPendingNum = DataPendingNum
+	workspaceNums.LinkPendingNum = LinkPendingNum
+	workspaceNums.ScriptPendingNum = ScriptPendingNum
+	return &workspaceNums, nil
+}
+
+func GetWorkspacePieNums2(ctx context.Context, enterpriseID int64) (*http_model.WorkspacePieNums2, error) {
+	var workspaceNums http_model.WorkspacePieNums2
+	var SketchPendingNum, AccSelecting, ShipmentPendingNum int64
+	db := GetReadDB(ctx)
+	var sketchProjectIDs []int64
+	db = db.Model(gorm_model.ProjectInfo{}).Select("project_id").Where("enterprise_id = ? AND project_status = 9", enterpriseID).Find(&sketchProjectIDs)
+	db5 := GetReadDB(ctx)
+	db5.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("project_id IN ? AND task_stage = 10", sketchProjectIDs).Count(&SketchPendingNum)
+	fmt.Println("SketchPendingNum:", SketchPendingNum)
+
+	var RecruitingProjectIDs []int64
+	db1 := GetReadDB(ctx)
+	db1 = db1.Model(gorm_model.ProjectInfo{}).Select("project_id").Where("enterprise_id = ? AND project_status = 4", enterpriseID).Find(&RecruitingProjectIDs)
+	db4 := GetReadDB(ctx)
+	db4.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id IN ? AND task_status = 1", RecruitingProjectIDs).Count(&AccSelecting)
+
+	db2 := GetReadDB(ctx)
+	var LogisticProjectIDs []int64
+	db2 = db2.Model(gorm_model.ProjectInfo{}).Select("project_id").Where("enterprise_id = ? AND project_status = 9", enterpriseID).Find(&LogisticProjectIDs)
+	db3 := GetReadDB(ctx)
+	db3.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id IN ? AND task_stage = 4", LogisticProjectIDs).Count(&ShipmentPendingNum)
+
+	workspaceNums.SketchPendingNum = SketchPendingNum
+	workspaceNums.AccSelecting = AccSelecting
+	workspaceNums.ShipmentPendingNum = ShipmentPendingNum
+	return &workspaceNums, nil
+}

+ 2 - 0
handler/getCodeUrl.go

@@ -1,6 +1,7 @@
 package handler
 
 import (
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 	"youngee_b_api/consts"
@@ -35,6 +36,7 @@ func (g getCodeUrlHandler) getRequest() interface{} {
 func (g getCodeUrlHandler) run() {
 	tradeId := util.GetRandomString(32)
 	if g.req.Type == 1 {
+		fmt.Println("amount:", g.req.Amount)
 		data, err := service.NativeApiServicePrepay(tradeId, g.req.Amount)
 		if err != nil {
 			logrus.WithContext(g.ctx).Errorf("[getCodeUrlHandler] error NativeApiServicePrepay, err:%+v", err)

+ 2 - 1
handler/rechargeBalance.go

@@ -35,7 +35,8 @@ func (r RechargeBalanceHandler) getRequest() interface{} {
 
 func (r RechargeBalanceHandler) run() {
 	enterpriseID := middleware.GetSessionAuth(r.ctx).EnterpriseID
-	err := db.RechargeAmount(r.ctx, enterpriseID, r.req.Amount)
+	phone := middleware.GetSessionAuth(r.ctx).Phone
+	err := db.RechargeAmount(r.ctx, enterpriseID, r.req.Amount, phone)
 	if err != nil {
 		logrus.WithContext(r.ctx).Errorf("[QueryOrderByTradeIdHandler] error QueryOrderByOutTradeNo, err:%+v", err)
 		util.HandlerPackErrorResp(r.resp, consts.ErrorInternal, consts.DefaultToast)

+ 2 - 0
handler/transferToPublic.go

@@ -1,6 +1,7 @@
 package handler
 
 import (
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 	"youngee_b_api/consts"
@@ -36,6 +37,7 @@ func (t TransferToPublicHandler) getRequest() interface{} {
 func (t TransferToPublicHandler) run() {
 	enterpriseID := middleware.GetSessionAuth(t.ctx).EnterpriseID
 	phone := middleware.GetSessionAuth(t.ctx).Phone
+	fmt.Println("Amount:", t.req.Amount)
 	err := db.TransferToPublic(t.ctx, t.req.Amount, phone, enterpriseID, t.req.TransferVoucherUrl)
 	if err != nil {
 		logrus.Errorf("[TransferToPublicHandler] call TransferToPublic err:%+v\n", err)

+ 60 - 0
handler/workspaceHeadNums.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/db"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/util"
+)
+
+func WrapWorkspaceHeadNumsHandler(ctx *gin.Context) {
+	handler := newWorkspaceNumsHandler(ctx)
+	baseRun(handler)
+}
+
+type WorkspaceNumsHandler struct {
+	ctx  *gin.Context
+	req  *http_model.WorkspaceNumsRequest
+	resp *http_model.CommonResponse
+}
+
+func (w WorkspaceNumsHandler) getContext() *gin.Context {
+	return w.ctx
+}
+
+func (w WorkspaceNumsHandler) getResponse() interface{} {
+	return w.resp
+}
+
+func (w WorkspaceNumsHandler) getRequest() interface{} {
+	return w.req
+}
+
+func (w WorkspaceNumsHandler) run() {
+	auth := middleware.GetSessionAuth(w.ctx)
+	enterpriseID := auth.EnterpriseID
+	data, err := db.GetWorkspaceNums(w.ctx, enterpriseID)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[WorkspaceNumsHandler] call GetWorkspaceNums err:%+v\n", err)
+		util.HandlerPackErrorResp(w.resp, consts.ErrorInternal, "")
+		logrus.Info("GetWorkspaceNums fail,req:%+v", w.req)
+		return
+	}
+	w.resp.Data = data
+}
+
+func (w WorkspaceNumsHandler) checkParam() error {
+	return nil
+}
+
+func newWorkspaceNumsHandler(ctx *gin.Context) *WorkspaceNumsHandler {
+	return &WorkspaceNumsHandler{
+		ctx:  ctx,
+		req:  http_model.NewWorkspaceNumsRequest(),
+		resp: http_model.NewWorkspaceNumsResponse(),
+	}
+}

+ 60 - 0
handler/workspacePieNums.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/db"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/util"
+)
+
+func WrapWorkspacePieNumsHandler(ctx *gin.Context) {
+	handler := newWorkspacePieNumsHandler(ctx)
+	baseRun(handler)
+}
+
+type WorkspacePieNumsHandler struct {
+	ctx  *gin.Context
+	req  *http_model.WorkspacePieNumsRequest
+	resp *http_model.CommonResponse
+}
+
+func (w WorkspacePieNumsHandler) getContext() *gin.Context {
+	return w.ctx
+}
+
+func (w WorkspacePieNumsHandler) getResponse() interface{} {
+	return w.resp
+}
+
+func (w WorkspacePieNumsHandler) getRequest() interface{} {
+	return w.req
+}
+
+func (w WorkspacePieNumsHandler) run() {
+	auth := middleware.GetSessionAuth(w.ctx)
+	enterpriseID := auth.EnterpriseID
+	data, err := db.GetWorkspacePieNums(w.ctx, enterpriseID)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[WorkspacePieNumsHandler] call GetWorkspacePieNums err:%+v\n", err)
+		util.HandlerPackErrorResp(w.resp, consts.ErrorInternal, "")
+		logrus.Info("GetWorkspacePieNums fail,req:%+v", w.req)
+		return
+	}
+	w.resp.Data = data
+}
+
+func (w WorkspacePieNumsHandler) checkParam() error {
+	return nil
+}
+
+func newWorkspacePieNumsHandler(ctx *gin.Context) *WorkspacePieNumsHandler {
+	return &WorkspacePieNumsHandler{
+		ctx:  ctx,
+		req:  http_model.NewWorkspacePieNumsRequest(),
+		resp: http_model.NewWorkspacePieNumsResponse(),
+	}
+}

+ 60 - 0
handler/workspacePieNums2.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/db"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/util"
+)
+
+func WrapWorkspacePieNums2Handler(ctx *gin.Context) {
+	handler := newWorkspacePieNums2Handler(ctx)
+	baseRun(handler)
+}
+
+type WorkspacePieNums2Handler struct {
+	ctx  *gin.Context
+	req  *http_model.WorkspacePieNums2Request
+	resp *http_model.CommonResponse
+}
+
+func (w WorkspacePieNums2Handler) getContext() *gin.Context {
+	return w.ctx
+}
+
+func (w WorkspacePieNums2Handler) getResponse() interface{} {
+	return w.resp
+}
+
+func (w WorkspacePieNums2Handler) getRequest() interface{} {
+	return w.req
+}
+
+func (w WorkspacePieNums2Handler) run() {
+	auth := middleware.GetSessionAuth(w.ctx)
+	enterpriseID := auth.EnterpriseID
+	data, err := db.GetWorkspacePieNums2(w.ctx, enterpriseID)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[WorkspacePieNums2Handler] call GetWorkspacePieNums2 err:%+v\n", err)
+		util.HandlerPackErrorResp(w.resp, consts.ErrorInternal, "")
+		logrus.Info("GetWorkspacePieNums2 fail,req:%+v", w.req)
+		return
+	}
+	w.resp.Data = data
+}
+
+func (w WorkspacePieNums2Handler) checkParam() error {
+	return nil
+}
+
+func newWorkspacePieNums2Handler(ctx *gin.Context) *WorkspacePieNums2Handler {
+	return &WorkspacePieNums2Handler{
+		ctx:  ctx,
+		req:  http_model.NewWorkspacePieNums2Request(),
+		resp: http_model.NewWorkspacePieNums2Response(),
+	}
+}

+ 6 - 5
model/http_model/RechargeRecordRequest.go

@@ -6,11 +6,12 @@ type RechargeRecordRequest struct {
 }
 
 type RechargeRecordData struct {
-	RechargeId      string `json:"recharge_id"`
-	RechargeAmount  string `json:"recharge_amount"`
-	PayMethod       string `json:"pay_method"`
-	TransferVoucher string `json:"transfer_voucher"`
-	ConfirmAt       string `json:"confirm_at"`
+	RechargeId         string `json:"recharge_id"`
+	RechargeAmount     string `json:"recharge_amount"`
+	RechargeAmountReal string `json:"recharge_amount_real"`
+	PayMethod          string `json:"pay_method"`
+	TransferVoucher    string `json:"transfer_voucher"`
+	ConfirmAt          string `json:"confirm_at"`
 }
 
 type RechargeRecordPreview struct {

+ 23 - 0
model/http_model/WorkspaceNumsRequest.go

@@ -0,0 +1,23 @@
+package http_model
+
+type WorkspaceNumsRequest struct {
+}
+
+type WorkspaceNums struct {
+	ProjectFunds      float64 `json:"project_funds"`       // 项目资金
+	PaymentPending    int64   `json:"payment_pending"`     // 项目待支付
+	DraftNum          int64   `json:"draft_num"`           // 草稿箱
+	RecruitingFullNum int64   `json:"recruiting_full_num"` // 全流程-招募中
+	ExecutionFullNum  int64   `json:"execution_full_num"`  // 全流程-执行中
+	ExecutionSpecNum  int64   `json:"execution_spec_num"`  // 专项-执行中
+}
+
+func NewWorkspaceNumsRequest() *WorkspaceNumsRequest {
+	return new(WorkspaceNumsRequest)
+}
+
+func NewWorkspaceNumsResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(WorkspaceNums)
+	return resp
+}

+ 20 - 0
model/http_model/WorkspacePieNums2Request.go

@@ -0,0 +1,20 @@
+package http_model
+
+type WorkspacePieNums2Request struct {
+}
+
+type WorkspacePieNums2 struct {
+	SketchPendingNum   int64 `json:"sketch_pending_num"`   // 初稿待审
+	AccSelecting       int64 `json:"acc_selecting"`        // 账号待审
+	ShipmentPendingNum int64 `json:"shipment_pending_num"` // 待发货数量
+}
+
+func NewWorkspacePieNums2Request() *WorkspacePieNums2Request {
+	return new(WorkspacePieNums2Request)
+}
+
+func NewWorkspacePieNums2Response() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(WorkspacePieNums2)
+	return resp
+}

+ 20 - 0
model/http_model/WorkspacePieNumsRequest.go

@@ -0,0 +1,20 @@
+package http_model
+
+type WorkspacePieNumsRequest struct {
+}
+
+type WorkspacePieNums struct {
+	DataPendingNum   int64 `json:"data_pending_num"`   // 数据待审
+	LinkPendingNum   int64 `json:"link_pending_num"`   // 链接待审
+	ScriptPendingNum int64 `json:"script_pending_num"` // 脚本待审
+}
+
+func NewWorkspacePieNumsRequest() *WorkspacePieNumsRequest {
+	return new(WorkspacePieNumsRequest)
+}
+
+func NewWorkspacePieNumsResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(WorkspacePieNums)
+	return resp
+}

+ 64 - 62
route/init.go

@@ -43,68 +43,70 @@ func InitRoute(r *gin.Engine) {
 			auth := middleware.GetSessionAuth(c)
 			logrus.Infof("auth:%+v", auth)
 		})
-		m.POST("/product/findall", handler.WrapFindAllProductHandler) //查询全部产品
-		m.POST("/product/find", handler.WrapFindProductHandler)
-		m.POST("/project/create", handler.WrapCreateProjectHandler)
-		m.POST("/project/show", handler.WrapShowProjectHandler)
-		m.POST("/project/update", handler.WrapUpdateProjectHandler)
-		m.POST("/project/delete", handler.WrapDeleteProjectHandler)
-		m.POST("/product/create", handler.WrapCreateProductHandler)
-		m.POST("/project/list", handler.WrapFullProjectListHandler)
-		m.POST("/project/taskList", handler.WrapProjectTaskListHandler)
-		m.POST("/project/draftlist", handler.WrapProjectDraftBoxListHandler)      // 草稿箱查询
-		m.GET("/project/getCreatingNumber", handler.WrapGetCreatingNumberHandler) // 查询创建中项目数量
-		m.POST("/project/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler)
-		m.POST("/pay/paysum", handler.WrapPaySumHandler)
-		m.POST("/pay/projectpay", handler.WrapProjectPayHandler)
-		m.POST("/enterprise/balance", handler.WrapEnterpriseBalanceHandler)
-		//m.POST("/project/recruitstrategycalculate", handler.WrapRecruitStrategyNumberCalculate)
-		m.POST("/project/tasklogisticslist", handler.WrapTaskLogisticsListHandler) //物流信息查询
-		m.POST("/project/createlogistics", handler.WrapCreateLogisticsHandler)     //创建物流信息
-		m.POST("/project/signforreceipt", handler.WrapSignForReceiptHandler)
-		m.POST("/project/taskscriptlist", handler.WrapTaskScriptListHandler)         //查询脚本列表
-		m.POST("/project/scriptopinion", handler.WrapScriptOpinionHandler)           //脚本审核意见提交
-		m.POST("/project/acceptscript", handler.WrapAcceptScriptHandler)             //同意脚本
-		m.POST("/project/tasksketchlist", handler.WrapTaskSketchListHandler)         //查询初稿列表
-		m.POST("/project/findsketchphoto", handler.WrapFindSketchPhotoHandler)       //查询脚本配图和视频demo
-		m.POST("/project/sketchopinion", handler.WrapSketchOpinionHandler)           //脚本审核意见提交
-		m.POST("/project/acceptsketch", handler.WrapAcceptSketchHandler)             //同意脚本
-		m.POST("/project/tasklinklist", handler.WrapTaskLinkListHandler)             //查询链接列表
-		m.POST("/project/linkopinion", handler.WrapLinkOpinionHandler)               //链接审核意见提交
-		m.POST("/project/acceptlink", handler.WrapAcceptLinkHandler)                 //同意链接
-		m.POST("/project/taskdatalist", handler.WrapTaskDataListHandler)             //查询数据列表
-		m.POST("/project/dataopinion", handler.WrapDataOpinionHandler)               //数据审核意见提交
-		m.POST("/project/acceptdata", handler.WrapAcceptDataHandler)                 //同意数据
-		m.POST("/pay/getCodeUrl", handler.WrapGetCodeUrlHandler)                     // 获取微信支付codeURL
-		m.POST("/pay/queryOrderByTradeId", handler.WrapQueryOrderByTradeIdHandler)   //根据交易id查询微信是否扫码付款
-		m.POST("/pay/rechargeBalance", handler.WrapRechargeBalanceHandler)           // 支付成功后修改企业余额
-		m.POST("/project/feeDetail", handler.WrapFeeDetailHandler)                   // 查看结项的费用明细
-		m.POST("/pay/rechargeRecord", handler.WrapRechargeRecordHandler)             // 查看充值记录
-		m.POST("/invoice/addReceiveAddress", handler.WrapAddReceiveAddressHandler)   // 新增收货地址
-		m.POST("/invoice/addReceiveInfo", handler.WrapAddReceiveInfoHandler)         // 新增发票信息
-		m.GET("/invoice/getReceiveAddress", handler.WrapGetReceiveAddressHandler)    // 获取收货地址
-		m.GET("/invoice/getReceiveInfo", handler.WrapGetReceiveInfoHandler)          // 获取发票信息
-		m.POST("/invoice/operateReceiveInfo", handler.WrapOperateReceiveInfoHandler) // 修改或删除发票信息
-		m.POST("/project/getlogisticsnumberinfo", handler.WrapGetLogisticsNumberInfoHandler)
-		m.POST("/invoice/operateReceiveAddress", handler.WrapOperateReceiveAddressHandler) // 修改或删除发票地址
-		m.POST("/invoice/addInvoiceRecord", handler.WrapAddInvoiceRecordHandler)           // 开票
-		m.POST("/invoice/getInvoiceRecord", handler.WrapGetInvoiceRecordHandler)           // 获取开票记录
-		m.POST("/project/getlinknumberinfo", handler.WrapGetLinkNumberInfoHandler)         // 获取链接信息
-		m.POST("/project/getdatanumberinfo", handler.WrapGetDataNumberInfoHandler)         // 获取数据信息
-		m.POST("/project/getreviewnumberinfo", handler.WrapGetReviewNumberInfoHandler)     // 获取审稿信息
-		m.POST("/project/getdefaultnumberinfo", handler.WrapGetDefaultNumberInfoHandler)   // 获取违约信息
-		m.POST("/project/taskdefaultreviewlist", handler.WrapTaskDefaultReviewListHandler) // 查询违约列表-脚本、初稿、链接上传违约
-		m.POST("/project/taskdefaultdatalist", handler.WrapTaskDefaultDataListHandler)     // 查询违约列表-数据违约
-		m.POST("/project/taskteminatinglist", handler.WrapTaskTerminatingListHandler)      // 查询违约列表-解约待处理
-		m.POST("/project/taskteminatedlist", handler.WrapTaskTerminatedListHandler)        // 查询违约列表-解约
-		m.POST("/project/taskteminate", handler.WrapTaskTerminateHandler)                  // 解约
-		m.POST("/project/getsketchinfo", handler.WrapGetSketchInfoHandler)                 // 获取初稿
-		m.POST("/project/taskfinishlist", handler.WrapTaskFinishListHandler)               // 查询违约列表-数据违约
-		m.POST("/project/getfinishdata", handler.WrapGetFinishDataHandler)
-		m.GET("/project/finduserinfo", handler.WrapFindUserInfoHandler)                //获取账户信息
-		m.POST("/project/updatauserinfo", handler.WrapUpdateUserInfoHandler)           //更新账户信息
-		m.POST("/project/getfinishnumberinfo", handler.WrapGetFinishNumberInfoHandler) // 获取结案数量
-		m.POST("/project/transferToPublic", handler.WrapTransferToPublicHandler)       // 对公转账
+		m.POST("/product/findall", handler.WrapFindAllProductHandler)                        //查询全部产品
+		m.POST("/product/find", handler.WrapFindProductHandler)                              // 查找单个产品
+		m.POST("/project/create", handler.WrapCreateProjectHandler)                          // 创建项目
+		m.POST("/project/show", handler.WrapShowProjectHandler)                              // 展示项目内容
+		m.POST("/project/update", handler.WrapUpdateProjectHandler)                          // 更新项目
+		m.POST("/project/delete", handler.WrapDeleteProjectHandler)                          // 删除项目
+		m.POST("/product/create", handler.WrapCreateProductHandler)                          // 创建项目
+		m.POST("/project/list", handler.WrapFullProjectListHandler)                          // 项目列表
+		m.POST("/project/taskList", handler.WrapProjectTaskListHandler)                      // 任务列表
+		m.POST("/project/draftlist", handler.WrapProjectDraftBoxListHandler)                 // 草稿箱查询
+		m.GET("/project/getCreatingNumber", handler.WrapGetCreatingNumberHandler)            // 查询创建中项目数量
+		m.POST("/project/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler)      // 改变任务的状态
+		m.POST("/pay/paysum", handler.WrapPaySumHandler)                                     // 支付总额
+		m.POST("/pay/projectpay", handler.WrapProjectPayHandler)                             // 支付
+		m.POST("/enterprise/balance", handler.WrapEnterpriseBalanceHandler)                  // 样叽页面各种余额
+		m.POST("/project/tasklogisticslist", handler.WrapTaskLogisticsListHandler)           // 物流信息查询
+		m.POST("/project/createlogistics", handler.WrapCreateLogisticsHandler)               // 创建物流信息
+		m.POST("/project/signforreceipt", handler.WrapSignForReceiptHandler)                 // 签收
+		m.POST("/project/taskscriptlist", handler.WrapTaskScriptListHandler)                 // 查询脚本列表
+		m.POST("/project/scriptopinion", handler.WrapScriptOpinionHandler)                   // 脚本审核意见提交
+		m.POST("/project/acceptscript", handler.WrapAcceptScriptHandler)                     // 同意脚本
+		m.POST("/project/tasksketchlist", handler.WrapTaskSketchListHandler)                 // 查询初稿列表
+		m.POST("/project/findsketchphoto", handler.WrapFindSketchPhotoHandler)               // 查询脚本配图和视频demo
+		m.POST("/project/sketchopinion", handler.WrapSketchOpinionHandler)                   // 脚本审核意见提交
+		m.POST("/project/acceptsketch", handler.WrapAcceptSketchHandler)                     // 同意脚本
+		m.POST("/project/tasklinklist", handler.WrapTaskLinkListHandler)                     // 查询链接列表
+		m.POST("/project/linkopinion", handler.WrapLinkOpinionHandler)                       // 链接审核意见提交
+		m.POST("/project/acceptlink", handler.WrapAcceptLinkHandler)                         // 同意链接
+		m.POST("/project/taskdatalist", handler.WrapTaskDataListHandler)                     // 查询数据列表
+		m.POST("/project/dataopinion", handler.WrapDataOpinionHandler)                       // 数据审核意见提交
+		m.POST("/project/acceptdata", handler.WrapAcceptDataHandler)                         // 同意数据
+		m.POST("/pay/getCodeUrl", handler.WrapGetCodeUrlHandler)                             // 获取微信支付codeURL
+		m.POST("/pay/queryOrderByTradeId", handler.WrapQueryOrderByTradeIdHandler)           // 根据交易id查询微信是否扫码付款
+		m.POST("/pay/rechargeBalance", handler.WrapRechargeBalanceHandler)                   // 支付成功后修改企业余额
+		m.POST("/project/feeDetail", handler.WrapFeeDetailHandler)                           // 查看结项的费用明细
+		m.POST("/pay/rechargeRecord", handler.WrapRechargeRecordHandler)                     // 查看充值记录
+		m.POST("/invoice/addReceiveAddress", handler.WrapAddReceiveAddressHandler)           // 新增收货地址
+		m.POST("/invoice/addReceiveInfo", handler.WrapAddReceiveInfoHandler)                 // 新增发票信息
+		m.GET("/invoice/getReceiveAddress", handler.WrapGetReceiveAddressHandler)            // 获取收货地址
+		m.GET("/invoice/getReceiveInfo", handler.WrapGetReceiveInfoHandler)                  // 获取发票信息
+		m.POST("/invoice/operateReceiveInfo", handler.WrapOperateReceiveInfoHandler)         // 修改或删除发票信息
+		m.POST("/project/getlogisticsnumberinfo", handler.WrapGetLogisticsNumberInfoHandler) // 获取物流数量
+		m.POST("/invoice/operateReceiveAddress", handler.WrapOperateReceiveAddressHandler)   // 修改或删除发票地址
+		m.POST("/invoice/addInvoiceRecord", handler.WrapAddInvoiceRecordHandler)             // 开票
+		m.POST("/invoice/getInvoiceRecord", handler.WrapGetInvoiceRecordHandler)             // 获取开票记录
+		m.POST("/project/getlinknumberinfo", handler.WrapGetLinkNumberInfoHandler)           // 获取链接信息
+		m.POST("/project/getdatanumberinfo", handler.WrapGetDataNumberInfoHandler)           // 获取数据信息
+		m.POST("/project/getreviewnumberinfo", handler.WrapGetReviewNumberInfoHandler)       // 获取审稿信息
+		m.POST("/project/getdefaultnumberinfo", handler.WrapGetDefaultNumberInfoHandler)     // 获取违约信息
+		m.POST("/project/taskdefaultreviewlist", handler.WrapTaskDefaultReviewListHandler)   // 查询违约列表-脚本、初稿、链接上传违约
+		m.POST("/project/taskdefaultdatalist", handler.WrapTaskDefaultDataListHandler)       // 查询违约列表-数据违约
+		m.POST("/project/taskteminatinglist", handler.WrapTaskTerminatingListHandler)        // 查询违约列表-解约待处理
+		m.POST("/project/taskteminatedlist", handler.WrapTaskTerminatedListHandler)          // 查询违约列表-解约
+		m.POST("/project/taskteminate", handler.WrapTaskTerminateHandler)                    // 解约
+		m.POST("/project/getsketchinfo", handler.WrapGetSketchInfoHandler)                   // 获取初稿
+		m.POST("/project/taskfinishlist", handler.WrapTaskFinishListHandler)                 // 查询违约列表-数据违约
+		m.POST("/project/getfinishdata", handler.WrapGetFinishDataHandler)                   // 获取结案信息
+		m.GET("/project/finduserinfo", handler.WrapFindUserInfoHandler)                      // 获取账户信息
+		m.POST("/project/updatauserinfo", handler.WrapUpdateUserInfoHandler)                 // 更新账户信息
+		m.POST("/project/getfinishnumberinfo", handler.WrapGetFinishNumberInfoHandler)       // 获取结案数量
+		m.POST("/project/transferToPublic", handler.WrapTransferToPublicHandler)             // 对公转账
+		m.GET("/workspace/headNums", handler.WrapWorkspaceHeadNumsHandler)                   // 工作台上面数字显示
+		m.GET("/workspace/pieNums", handler.WrapWorkspacePieNumsHandler)                     // 工作台饼图数字显示1
+		m.GET("/workspace/pieNums2", handler.WrapWorkspacePieNums2Handler)                   // 工作台饼图数字显示2
 
 		m.POST("/project/getSpecialInviteNumber", handler.WrapGetSpecialInviteNumberHandler) // 查询专项任务邀请管理任务数量
 		m.POST("/project/getSpecialReviewNumber", handler.WrapGetSpecialReviewNumberHandler) // 查询专项任务审稿管理任务数量

+ 1 - 1
service/wechatPay.go

@@ -47,7 +47,7 @@ func NativeApiServicePrepay(tradeId string, amount int64) (codeUrl string, err e
 			SupportFapiao: core.Bool(true),
 			Amount: &native.Amount{
 				Currency: core.String("CNY"),
-				Total:    core.Int64(amount * 100),
+				Total:    core.Int64(amount),
 			},
 		},
 	)