Ver Fonte

我的样叽页面

yuliang1112 há 2 anos atrás
pai
commit
725a9b38db

+ 69 - 15
db/enterprise.go

@@ -3,6 +3,7 @@ package db
 import (
 	"context"
 	"github.com/issue9/conv"
+	"log"
 	"time"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
@@ -62,16 +63,35 @@ 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
+	}
+	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
+	}
 	res := &http_model.EnterpriseBalanceData{
 		Balance:          enterprise.Balance,
 		FrozenBalance:    enterprise.FrozenBalance,
 		AvailableBalance: enterprise.AvailableBalance,
+		Recharging:       enterprise.Recharging,
+		BillableAmount:   BillableAmount,
+		Invoicing:        Invoicing,
 	}
 	return res, nil
 }
 
 // 支付-修改企业账户余额
-func UpdateEnterpriseBalance(ctx context.Context, EnterpriseID int64, balance int64, availableBalance int64, frozenBalance int64) (*int64, error) {
+func UpdateEnterpriseBalance(ctx context.Context, EnterpriseID int64, balance float64, availableBalance float64, frozenBalance float64) (*float64, error) {
 	db := GetReadDB(ctx)
 	err := db.Model(gorm_model.Enterprise{}).Where("enterprise_id", EnterpriseID).
 		Updates(map[string]interface{}{"balance": gorm.Expr("balance + ?", balance), "available_balance": gorm.Expr("available_balance + ?", availableBalance), "frozen_balance": gorm.Expr("frozen_balance + ?", frozenBalance)}).Error
@@ -87,18 +107,8 @@ func UpdateEnterpriseBalance(ctx context.Context, EnterpriseID int64, balance in
 	return &enterprise.Balance, nil
 }
 
-func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) error {
+func MakeRechargeId(ctx context.Context, EnterpriseID int64) string {
 	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
-	if err != nil {
-		return err
-	}
-	enterprise := gorm_model.Enterprise{}
-	err = db.Model(gorm_model.Enterprise{}).Where("enterprise_id", EnterpriseID).Scan(&enterprise).Error
-	if err != nil {
-		return err
-	}
 	// 1、年月日
 	year := time.Now().Year()
 	month := time.Now().Month()
@@ -118,7 +128,7 @@ func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) err
 	last := ""
 	rechargeIdPrefix := "8" + conv.MustString(EnterpriseID)[len(conv.MustString(EnterpriseID))-2:] + conv.MustString(sum)
 	var rechargeIdLast string
-	err = db.Model(gorm_model.YounggeeRechargeRecord{}).Select("recharge_id").Where("recharge_id like ?", rechargeIdPrefix+"%").
+	err := db.Model(gorm_model.YounggeeRechargeRecord{}).Select("recharge_id").Where("recharge_id like ?", rechargeIdPrefix+"%").
 		Last(&rechargeIdLast).Error
 	if err != nil {
 		last = "0"
@@ -132,11 +142,27 @@ func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) err
 	} else {
 		last = conv.MustString(conv.MustInt(last) + 1)
 	}
+	return rechargeIdPrefix + last
+}
+
+func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) 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
+	if err != nil {
+		return err
+	}
+	//enterprise := gorm_model.Enterprise{}
+	//err = db.Model(gorm_model.Enterprise{}).Where("enterprise_id", EnterpriseID).Scan(&enterprise).Error
+	//if err != nil {
+	//	return err
+	//}
+	rechargeId := MakeRechargeId(ctx, EnterpriseID)
 	err = db.Model(gorm_model.YounggeeRechargeRecord{}).Create(&gorm_model.YounggeeRechargeRecord{
-		RechargeID:         rechargeIdPrefix + last,
+		RechargeID:         rechargeId,
 		RechargeAmount:     Amount,
 		EnterpriseID:       EnterpriseID,
-		Status:             1,
+		Status:             2,
 		InvoiceStatus:      1,
 		CommitAt:           time.Now(),
 		RechargeMethod:     3,
@@ -148,3 +174,31 @@ func RechargeAmount(ctx context.Context, EnterpriseID int64, Amount float64) err
 	}
 	return nil
 }
+
+func TransferToPublic(ctx context.Context, Amount float64, phone string, EnterpriseID int64, transferVoucherUrl string) error {
+	db := GetReadDB(ctx)
+	rechargeId := MakeRechargeId(ctx, EnterpriseID)
+	err := db.Model(gorm_model.YounggeeRechargeRecord{}).Create(&gorm_model.YounggeeRechargeRecord{
+		RechargeID:         rechargeId,
+		RechargeAmount:     Amount,
+		EnterpriseID:       EnterpriseID,
+		Status:             1,
+		InvoiceStatus:      1,
+		CommitAt:           time.Now(),
+		Phone:              phone,
+		RechargeMethod:     1,
+		TransferVoucherUrl: transferVoucherUrl,
+		ConfirmAt:          time.Now(),
+	}).Error
+	if err != nil {
+		return err
+	}
+	db1 := GetReadDB(ctx)
+	err = db1.Model(gorm_model.Enterprise{}).Where("enterprise_id = ?", EnterpriseID).Updates(
+		map[string]interface{}{"recharging": gorm.Expr("recharging + ?", Amount)}).Error
+	if err != nil {
+		log.Println("[TransferToPublic] recharging modify failed:", err)
+		return err
+	}
+	return nil
+}

+ 46 - 2
db/invoice.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
 	"time"
 	"youngee_b_api/consts"
 	"youngee_b_api/model/gorm_model"
@@ -122,8 +123,8 @@ func OperateReceiveAddress(ctx context.Context, enterpriseId int64, req *http_mo
 
 func AddInvoiceRecord(ctx context.Context, enterpriseId int64, req *http_model.AddInvoiceRecordRequest) error {
 	invoiceInfo := gorm_model.YounggeeInvoiceInfo{}
-	fmt.Println("req:", req)
-	fmt.Println("invoice_id", req.InvoiceID)
+	//fmt.Println("req:", req)
+	//fmt.Println("invoice_id", req.InvoiceID)
 	db1 := GetReadDB(ctx)
 	db1.Debug().Model(gorm_model.YounggeeInvoiceInfo{}).Where("invoice_id = ?", req.InvoiceID).First(&invoiceInfo)
 	invoiceInfoToJson, _ := json.Marshal(invoiceInfo)
@@ -172,6 +173,8 @@ func AddInvoiceRecord(ctx context.Context, enterpriseId int64, req *http_model.A
 		InvoiceSnap:   string(invoiceInfoToJson),
 		AddressSnap:   string(addressInfoToJson),
 		Status:        1,
+		InvoiceType:   consts.GetInvoiceType(invoiceInfo.InvoiceType),
+		Phone:         invoiceInfo.RegisteredPhone,
 		SubmitAt:      time.Now(),
 	}).Error
 	if err != nil {
@@ -182,3 +185,44 @@ func AddInvoiceRecord(ctx context.Context, enterpriseId int64, req *http_model.A
 		InvoiceStatus: 3,
 	}).Error
 }
+
+func GetInvoiceRecords(ctx context.Context, req *http_model.GetInvoiceRecordRequest) (*http_model.InvoiceRecordsData, error) {
+	db := GetReadDB(ctx)
+	var invoiceRecords []*gorm_model.YounggeeInvoiceRecord
+	db = db.Debug().Model(gorm_model.YounggeeInvoiceRecord{}).Where("status = 2")
+	if req.BillingAt != "" {
+		db.Debug().Where(fmt.Sprintf(" billing_at like '%s%%'", req.BillingAt))
+	}
+	err := db.Order("billing_at desc").Find(&invoiceRecords).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetInvoiceRecords] error query mysql limit, err:%+v", err)
+		return nil, err
+	}
+	var enterpriseIds []int64
+	for _, invoiceRecord := range invoiceRecords {
+		enterpriseIds = append(enterpriseIds, invoiceRecord.EnterpriseID)
+	}
+	util.RemoveRepByMap(enterpriseIds)
+	enterpriseIdToUserInfoMap := make(map[int64]gorm_model.Enterprise)
+	db1 := GetReadDB(ctx)
+	for _, v := range enterpriseIds {
+		enterpriseInfo := gorm_model.Enterprise{}
+		db1.Model(gorm_model.Enterprise{}).Where("enterprise_id = ?", v).Find(&enterpriseInfo)
+		enterpriseIdToUserInfoMap[v] = enterpriseInfo
+	}
+	var InvoiceRecords []*http_model.InvoiceRecordsPreviews
+	for _, invoiceRecord := range invoiceRecords {
+		InvoiceRecord := new(http_model.InvoiceRecordsPreviews)
+		InvoiceRecord.BillingId = invoiceRecord.BillingID
+		InvoiceRecord.InvoiceInfo = invoiceRecord.InvoiceSnap
+		InvoiceRecord.AddressInfo = invoiceRecord.AddressSnap
+		InvoiceRecord.InvoiceType = invoiceRecord.InvoiceType
+		InvoiceRecord.Amount = invoiceRecord.InvoiceAmount
+		InvoiceRecord.ShipmentNumber = invoiceRecord.ShipmentNumber
+		InvoiceRecord.BillingAt = conv.MustString(invoiceRecord.BillingAt, "")[:19]
+		InvoiceRecords = append(InvoiceRecords, InvoiceRecord)
+	}
+	var InvoiceRecordsData http_model.InvoiceRecordsData
+	InvoiceRecordsData.InvoiceRecordsPreviews = InvoiceRecords
+	return &InvoiceRecordsData, nil
+}

+ 1 - 1
db/pay_record.go

@@ -12,7 +12,7 @@ import (
 )
 
 // CreatePayRecord 新增
-func CreatePayRecord(ctx context.Context, enterpriseId int64, payment int64, balance int64, payType int64, projectId int64) (*int64, error) {
+func CreatePayRecord(ctx context.Context, enterpriseId int64, payment float64, balance float64, payType int64, projectId int64) (*int64, error) {
 	db := GetReadDB(ctx)
 	payRecord := gorm_model.EnterprisePayRecord{
 		EnterpriseID: enterpriseId,

+ 1 - 2
handler/addInvoiceRecord.go

@@ -1,7 +1,6 @@
 package handler
 
 import (
-	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 	"youngee_b_api/consts"
@@ -37,7 +36,7 @@ func (a AddInvoiceRecordHandler) getRequest() interface{} {
 func (a AddInvoiceRecordHandler) run() {
 	auth := middleware.GetSessionAuth(a.ctx)
 	enterpriseID := auth.EnterpriseID
-	fmt.Println("req", a.req)
+	//fmt.Println("req", a.req)
 	err := db.AddInvoiceRecord(a.ctx, enterpriseID, a.req)
 	if err != nil {
 		// 数据库查询失败,返回5001

+ 57 - 0
handler/getInvoiceRecord.go

@@ -0,0 +1,57 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/consts"
+	"youngee_b_api/db"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/util"
+)
+
+func WrapGetInvoiceRecordHandler(ctx *gin.Context) {
+	handler := newGetInvoiceRecordHandler(ctx)
+	baseRun(handler)
+}
+
+type GetInvoiceRecordHandler struct {
+	ctx  *gin.Context
+	req  *http_model.GetInvoiceRecordRequest
+	resp *http_model.CommonResponse
+}
+
+func (g GetInvoiceRecordHandler) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g GetInvoiceRecordHandler) getResponse() interface{} {
+	return g.resp
+}
+
+func (g GetInvoiceRecordHandler) getRequest() interface{} {
+	return g.req
+}
+
+func (g GetInvoiceRecordHandler) run() {
+	data, err := db.GetInvoiceRecords(g.ctx, g.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[GetInvoiceRecordHandler] call GetInvoiceRecords err:%+v\n", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
+		logrus.Info("GetInvoiceRecords fail,req:%+v", g.req)
+		return
+	}
+	g.resp.Data = data
+}
+
+func (g GetInvoiceRecordHandler) checkParam() error {
+	return nil
+}
+
+func newGetInvoiceRecordHandler(ctx *gin.Context) *GetInvoiceRecordHandler {
+	return &GetInvoiceRecordHandler{
+		ctx:  ctx,
+		req:  http_model.NewGetInvoiceRecordRequest(),
+		resp: http_model.NewGetInvoiceRecordResponse(),
+	}
+}

+ 59 - 0
handler/transferToPublic.go

@@ -0,0 +1,59 @@
+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 WrapTransferToPublicHandler(ctx *gin.Context) {
+	handler := newTransferToPublicHandler(ctx)
+	baseRun(handler)
+}
+
+type TransferToPublicHandler struct {
+	ctx  *gin.Context
+	req  *http_model.TransferToPublicRequest
+	resp *http_model.CommonResponse
+}
+
+func (t TransferToPublicHandler) getContext() *gin.Context {
+	return t.ctx
+}
+
+func (t TransferToPublicHandler) getResponse() interface{} {
+	return t.resp
+}
+
+func (t TransferToPublicHandler) getRequest() interface{} {
+	return t.req
+}
+
+func (t TransferToPublicHandler) run() {
+	enterpriseID := middleware.GetSessionAuth(t.ctx).EnterpriseID
+	phone := middleware.GetSessionAuth(t.ctx).Phone
+	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)
+		util.HandlerPackErrorResp(t.resp, consts.ErrorInternal, "")
+		logrus.Info("TransferToPublic fail,req:%+v", t.req)
+		return
+	}
+	t.resp.Message = "转账成功,请等待管理确认"
+}
+
+func (t TransferToPublicHandler) checkParam() error {
+	return nil
+}
+
+func newTransferToPublicHandler(ctx *gin.Context) *TransferToPublicHandler {
+	return &TransferToPublicHandler{
+		ctx:  ctx,
+		req:  http_model.NewTransferToPublicRequest(),
+		resp: http_model.NewTransferToPubliceResponse(),
+	}
+}

+ 12 - 10
model/gorm_model/enterprise.go

@@ -6,18 +6,20 @@ import (
 )
 
 type Enterprise struct {
-	EnterpriseID     int64       `gorm:"column:enterprise_id"` // 企业id
-	Industry         int64       `gorm:"column:industry"`                                 // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
-	BusinessName     string    `gorm:"column:business_name"`                            // 公司或组织名称
-	UserID           int64       `gorm:"column:user_id"`                                  // 对应用户id
-	Balance          int64       `gorm:"column:balance"`                                  // 账户余额
-	FrozenBalance    int64       `gorm:"column:frozen_balance"`                           // 冻结余额
-	AvailableBalance int64       `gorm:"column:available_balance"`                        // 可用余额
-	CreatedAt        time.Time `gorm:"column:created_at"`                               // 创建时间
-	UpdatedAt        time.Time `gorm:"column:updated_at"`                               // 更新时间
+	EnterpriseID     int64     `gorm:"column:enterprise_id"`     // 企业id
+	Industry         int64     `gorm:"column:industry"`          // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
+	BusinessName     string    `gorm:"column:business_name"`     // 公司或组织名称
+	UserID           int64     `gorm:"column:user_id"`           // 对应用户id
+	Balance          float64   `gorm:"column:balance"`           // 账户余额
+	FrozenBalance    float64   `gorm:"column:frozen_balance"`    // 冻结余额
+	AvailableBalance float64   `gorm:"column:available_balance"` // 可用余额
+	BillableAmount   float64   `gorm:"column:billable_amount"`   // 可开票金额
+	Invoicing        float64   `gorm:"column:invoicing"`         // 开票中金额
+	Recharging       float64   `gorm:"column:recharging"`        // 充值中金额
+	CreatedAt        time.Time `gorm:"column:created_at"`        // 创建时间
+	UpdatedAt        time.Time `gorm:"column:updated_at"`        // 更新时间
 }
 
 func (m *Enterprise) TableName() string {
 	return "enterprise"
 }
-

+ 2 - 0
model/gorm_model/invoice_record.go

@@ -9,10 +9,12 @@ import (
 type YounggeeInvoiceRecord struct {
 	BillingID      string     `gorm:"column:billing_id;primary_key"`  // 开票订单ID
 	EnterpriseID   int64      `gorm:"column:enterprise_id;NOT NULL"`  // 企业id
+	InvoiceType    string     `gorm:"column:invoice_type;NOT NULL"`   // 发票类型
 	InvoiceAmount  float64    `gorm:"column:invoice_amount;NOT NULL"` // 开票金额
 	InvoiceSnap    string     `gorm:"column:invoice_snap;NOT NULL"`   // 开票信息快照
 	AddressSnap    string     `gorm:"column:address_snap;NOT NULL"`   // 邮寄地址快照
 	Status         int64      `gorm:"column:status;NOT NULL"`         // 开票状态:1 为待开票,2为已开票
+	Phone          string     `gorm:"column:phone;NOT NULL"`          // 联系方式
 	ShipmentNumber string     `gorm:"column:shipment_number"`         // 物流单号
 	SubmitAt       time.Time  `gorm:"column:submit_at;NOT NULL"`      // 申请提交时间
 	BillingAt      *time.Time `gorm:"column:billing_at"`              // 开票时间

+ 7 - 8
model/gorm_model/pay_record.go

@@ -6,17 +6,16 @@ import (
 )
 
 type EnterprisePayRecord struct {
-	ID           int64       `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
-	Payment      int64       `gorm:"column:payment;NOT NULL"`              // 交易金额
-	Balance      int64       `gorm:"column:balance"`                       // 交易后账户可用余额
-	PayType      int64       `gorm:"column:pay_type;NOT NULL"`             // 交易类型,1表示充值,2表示支付
-	RechargeType int64       `gorm:"column:recharge_type"`                 // 充值方式,1表示在线交易,2表示对公转账
-	EnterpriseID int64       `gorm:"column:enterprise_id;NOT NULL"`        // 企业id
+	ID           int64     `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
+	Payment      float64   `gorm:"column:payment;NOT NULL"`              // 交易金额
+	Balance      float64   `gorm:"column:balance"`                       // 交易后账户可用余额
+	PayType      int64     `gorm:"column:pay_type;NOT NULL"`             // 交易类型,1表示充值,2表示支付
+	RechargeType int64     `gorm:"column:recharge_type"`                 // 充值方式,1表示在线交易,2表示对公转账
+	EnterpriseID int64     `gorm:"column:enterprise_id;NOT NULL"`        // 企业id
 	PayAt        time.Time `gorm:"column:pay_at;NOT NULL"`               // 交易时间
-	ProjectID    int64       `gorm:"column:project_id"`                    // 支付的项目id
+	ProjectID    int64     `gorm:"column:project_id"`                    // 支付的项目id
 }
 
 func (m *EnterprisePayRecord) TableName() string {
 	return "enterprise_pay_record"
 }
-

+ 1 - 0
model/gorm_model/recharge.go

@@ -11,6 +11,7 @@ type YounggeeRechargeRecord struct {
 	EnterpriseID       int64     `gorm:"column:enterprise_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"`                // 联系方式
 	RechargeMethod     int64     `gorm:"column:recharge_method;NOT NULL"`      // 充值方式:1为对公转账,2为支付宝在线支付,3为微信支付
 	Status             int64     `gorm:"column:status;NOT NULL"`               // 充值状态:0为充值待确认,1为充值已确认
 	InvoiceStatus      int       `gorm:"column:invoice_status;NOT NULL"`       // 开票状态:1为可开票,2为待开票,3为已开票

+ 30 - 0
model/http_model/GetInvoiceRecordRequest.go

@@ -0,0 +1,30 @@
+package http_model
+
+type GetInvoiceRecordRequest struct {
+	BillingAt string `json:"billing_at"`
+}
+
+type InvoiceRecordsPreviews struct {
+	BillingId      string  `json:"billing_id"`
+	Amount         float64 `json:"amount"`
+	InvoiceType    string  `json:"invoice_type"`
+	InvoiceInfo    string  `json:"invoice_info"`
+	AddressInfo    string  `json:"address_info"`
+	ShipmentNumber string  `json:"shipment_number"` // 物流单号
+	BillingAt      string  `json:"billing_at"`
+}
+
+type InvoiceRecordsData struct {
+	InvoiceRecordsPreviews []*InvoiceRecordsPreviews `json:"invoice_records_previews"`
+	Total                  string                    `json:"total"`
+}
+
+func NewGetInvoiceRecordRequest() *GetInvoiceRecordRequest {
+	return new(GetInvoiceRecordRequest)
+}
+
+func NewGetInvoiceRecordResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(InvoiceRecordsData)
+	return resp
+}

+ 14 - 0
model/http_model/TransferToPublicRequest.go

@@ -0,0 +1,14 @@
+package http_model
+
+type TransferToPublicRequest struct {
+	Amount             float64 `json:"amount"`
+	TransferVoucherUrl string  `json:"transfer_voucher_url"`
+}
+
+func NewTransferToPublicRequest() *TransferToPublicRequest {
+	return new(TransferToPublicRequest)
+}
+
+func NewTransferToPubliceResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 6 - 6
model/http_model/enterprise_balance.go

@@ -5,12 +5,12 @@ type EnterpriseBalanceRequest struct {
 }
 
 type EnterpriseBalanceData struct {
-	Balance          int64 `json:"balance"`
-	FrozenBalance    int64 `json:"frozen_balance"`
-	AvailableBalance int64 `json:"available_balance"`
-	Recharging       int64 `json:"recharging"`
-	BillableAmount   int64 `json:"billable_amount"`
-	Invoicing        int64 `json:"invoicing"`
+	Balance          float64 `json:"balance"`
+	FrozenBalance    float64 `json:"frozen_balance"`
+	AvailableBalance float64 `json:"available_balance"`
+	Recharging       float64 `json:"recharging"`
+	BillableAmount   float64 `json:"billable_amount"`
+	Invoicing        float64 `json:"invoicing"`
 }
 
 func NewEnterpriseBalanceRequest() *EnterpriseBalanceRequest {

+ 2 - 2
model/http_model/project_pay.go

@@ -1,8 +1,8 @@
 package http_model
 
 type ProjectPayRequest struct {
-	ProjectID string `json:"project_id"`
-	PaySum    int64  `json:"pay_sum"`
+	ProjectID string  `json:"project_id"`
+	PaySum    float64 `json:"pay_sum"`
 }
 
 type ProjectPayData struct {

+ 10 - 8
route/init.go

@@ -84,19 +84,21 @@ func InitRoute(r *gin.Engine) {
 		m.GET("/invoice/getReceiveAddress", handler.WrapGetReceiveAddressHandler)          // 获取收货地址
 		m.GET("/invoice/getReceiveInfo", handler.WrapGetReceiveInfoHandler)                // 获取发票信息
 		m.POST("/invoice/operateReceiveInfo", handler.WrapOperateReceiveInfoHandler)       // 修改或删除发票信息
-		m.POST("/invoice/operateReceiveAddress", handler.WrapOperateReceiveAddressHandler) // 修改或删除发票信息
-		m.POST("/invoice/addInvoiceRecord", handler.WrapAddInvoiceRecordHandler)           // 修改或删除发票信息
-		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("/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/taskteminate", handler.WrapTaskTerminateHandler)                  // 解约
 		m.POST("/project/getsketchinfo", handler.WrapGetSketchInfoHandler)                 // 获取初稿
 		m.POST("/project/taskfinishlist", handler.WrapTaskFinishListHandler)               // 查询违约列表-数据违约
-		m.POST("/project/getfinishnumberinfo", handler.WrapGetFinishNumberInfoHandler)
+		m.POST("/project/getfinishnumberinfo", handler.WrapGetFinishNumberInfoHandler)     // 获取结案数量
+		m.POST("/project/transferToPublic", handler.WrapTransferToPublicHandler)           // 对公转账
 	}
 }

+ 17 - 0
util/type.go

@@ -86,3 +86,20 @@ func GetDayNum(inputType string, inputData int) (int, error) {
 	}
 	return result, nil
 }
+
+// RemoveRepByMap 通过map主键唯一的特性过滤重复元素
+func RemoveRepByMap(slc []int64) []int64 {
+	if len(slc) == 0 {
+		return slc
+	}
+	var result []int64
+	tempMap := map[int64]byte{} // 存放不重复主键
+	for _, e := range slc {
+		l := len(tempMap)
+		tempMap[e] = 0
+		if len(tempMap) != l { // 加入map后,map长度变化,则元素不重复
+			result = append(result, e)
+		}
+	}
+	return result
+}