Bläddra i källkod

解决违约管理与解约相关问题

Ohio-HYF 2 år sedan
förälder
incheckning
554f20450d

+ 6 - 0
db/default.go

@@ -142,6 +142,12 @@ func GetTaskDefaultDataList(ctx context.Context, projectID string, pageSize, pag
 		if tag == "default_status" {
 			if value.Interface() == int64(3) {
 				db = db.Where("cur_default_type = 7")
+			} else if value.Interface() == int64(2) {
+				db = db.Where("cur_default_type = 5")
+			} else if value.Interface() == int64(1) {
+				db = db.Where("cur_default_type = 3")
+			} else if value.Interface() == int64(0) {
+				db = db.Where("cur_default_type = 1")
 			}
 			continue
 		} else if !util.IsBlank(value) {

+ 21 - 0
db/logistics.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"fmt"
 	"reflect"
+	"strconv"
 	"strings"
 	"time"
 	"youngee_b_api/model/common_model"
@@ -14,6 +15,7 @@ import (
 
 	"github.com/issue9/conv"
 	"github.com/sirupsen/logrus"
+	"github.com/tidwall/gjson"
 )
 
 //新增
@@ -129,6 +131,9 @@ func GetTaskLogisticsList(ctx context.Context, projectID string, pageSize, pageN
 		TaskLogistics := new(http_model.TaskLogistics)
 		TaskLogistics.Talent = taskMap[taskId]
 		TaskLogistics.Logistics = logisticsMap[taskId]
+		TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
+		regionCode, _ := strconv.Atoi(conv.MustString(gjson.Get(TalentPostAddrSnap, "region_code")))
+		TaskLogistics.Region = GetRegion(ctx, regionCode)
 		TaskLogisticss = append(TaskLogisticss, TaskLogistics)
 	}
 
@@ -158,3 +163,19 @@ func ChangeLogisticsStatus(ctx context.Context, taskIds []string) error {
 	}
 	return nil
 }
+
+func GetRegion(ctx context.Context, regionCode int) string {
+	db4 := GetReadDB(ctx)
+	var infoRegion *gorm_model.InfoRegion
+	fmt.Printf("regionCode: %+v", regionCode)
+	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", regionCode).First(&infoRegion)
+
+	provinceCode := conv.MustString(regionCode, "")[0:2] + "0000"
+	var province *gorm_model.InfoRegion
+	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", conv.MustInt(provinceCode, 0)).First(&province)
+
+	cityCode := conv.MustString(regionCode, "")[0:4] + "00"
+	var city *gorm_model.InfoRegion
+	db4.Debug().Model(gorm_model.InfoRegion{}).Where("self_code = ?", conv.MustInt(cityCode, 0)).First(&city)
+	return province.RegionName + city.RegionName + infoRegion.RegionName
+}

+ 5 - 2
db/project.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"reflect"
 	"strings"
+	"time"
 	"youngee_b_api/consts"
 	"youngee_b_api/model/common_model"
 	"youngee_b_api/model/gorm_model"
@@ -216,8 +217,9 @@ func GetRecruitStrategys(ctx context.Context, ProjectID string) ([]gorm_model.Re
 
 func UpdateProjectStatus(ctx context.Context, projectId string, status int64) error {
 	db := GetReadDB(ctx)
+	t := time.Now()
 	err := db.Model(gorm_model.ProjectInfo{}).
-		Where("project_id = ?", projectId).Update("project_status", status).Error
+		Where("project_id = ?", projectId).Updates(gorm_model.ProjectInfo{ProjectStatus: status, PayAt: &t}).Error
 	if err != nil {
 		log.Println("DB UpdateProjectStatus error :", err)
 		return err
@@ -287,7 +289,8 @@ func SetProjectFinish(ctx context.Context, projectId string) error {
 		}
 
 		// 1. 更新项目状态为已结束
-		err = db.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", projectId).Updates(map[string]interface{}{"project_status": 10, "payment_amount": realPayment}).Error
+		t := time.Now()
+		err = db.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", projectId).Updates(gorm_model.ProjectInfo{ProjectStatus: 10, PaymentAmount: realPayment, FinishAt: &t}).Error
 		if err != nil {
 			logrus.WithContext(ctx).Errorf("[Project db] Update ProjectInfo error,err:%+v", err)
 			return err

+ 12 - 1
db/recruit_strategy.go

@@ -61,8 +61,19 @@ func GetRecruitStrategyIdByTS(ctx context.Context, projectId string, strategyID
 	RecruitStrategy := &gorm_model.RecruitStrategy{}
 	err := db.Model(gorm_model.RecruitStrategy{}).Where("project_id = ? AND strategy_id = ?", projectId, strategyID).Scan(RecruitStrategy).Error
 	if err != nil {
-		logrus.WithContext(ctx).Errorf("[logistics db] call CreateLogistics error,err:%+v", err)
+		logrus.WithContext(ctx).Errorf("[logistics db] call GetRecruitStrategyIdByTS error,err:%+v", err)
 		return nil, err
 	}
 	return &RecruitStrategy.RecruitStrategyID, nil
 }
+
+func GetRecruitStrategyByProjectId(ctx context.Context, projectId string) ([]gorm_model.RecruitStrategy, error) {
+	db := GetReadDB(ctx)
+	RecruitStrategys := []gorm_model.RecruitStrategy{}
+	err := db.Model(gorm_model.RecruitStrategy{}).Where("project_id = ?", projectId).Scan(&RecruitStrategys).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call GetRecruitStrategyByProjectId error,err:%+v", err)
+		return nil, err
+	}
+	return RecruitStrategys, nil
+}

+ 1 - 1
db/terminate.go

@@ -11,7 +11,7 @@ import (
 // Terminate 批量提交解约申请
 func Terminate(ctx context.Context, TaskIDs []string) error {
 	db := GetReadDB(ctx)
-	err := db.Model(gorm_model.YoungeeContractInfo{}).Where("task_id in ?  and default_status = 1", TaskIDs).Updates(map[string]interface{}{"default_status": 3, "terminate_at": time.Now()}).Error
+	err := db.Model(gorm_model.YoungeeContractInfo{}).Where("task_id in ?  and (default_status = 1 or default_status = 4)", TaskIDs).Updates(map[string]interface{}{"default_status": 3, "terminate_at": time.Now()}).Error
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[Data db] Update YoungeeContractInfo error,err:%+v", err)
 		return err

+ 4 - 3
handler/getCodeUrl.go

@@ -2,12 +2,13 @@ package handler
 
 import (
 	"fmt"
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
 	"youngee_b_api/consts"
 	"youngee_b_api/model/http_model"
 	"youngee_b_api/service"
 	"youngee_b_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
 )
 
 func WrapGetCodeUrlHandler(ctx *gin.Context) {
@@ -37,7 +38,7 @@ func (g getCodeUrlHandler) run() {
 	tradeId := util.GetRandomString(32)
 	if g.req.Type == 1 {
 		fmt.Println("amount:", g.req.Amount)
-		data, err := service.NativeApiServicePrepay(tradeId, int64(g.req.Amount*100))
+		data, err := service.NativeApiServicePrepay(tradeId, g.req.Amount)
 		if err != nil {
 			logrus.WithContext(g.ctx).Errorf("[getCodeUrlHandler] error NativeApiServicePrepay, err:%+v", err)
 			util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)

+ 14 - 0
model/gorm_model/info_region.go

@@ -0,0 +1,14 @@
+// Package gorm_model Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+type InfoRegion struct {
+	RegionID    uint   `gorm:"column:region_id;primary_key;AUTO_INCREMENT"`
+	SelfCode    uint   `gorm:"column:self_code;NOT NULL"`
+	RegionLevel int    `gorm:"column:region_level;NOT NULL"`
+	ParentCode  uint   `gorm:"column:parent_code"`
+	RegionName  string `gorm:"column:region_name;NOT NULL"`
+}
+
+func (m *InfoRegion) TableName() string {
+	return "info_region"
+}

+ 1 - 0
model/gorm_model/project.go

@@ -33,6 +33,7 @@ type ProjectInfo struct {
 	FailReason        int64      `gorm:"column:fail_reason"`                           // 失效原因,1、2分别表示逾期未支付、项目存在风险
 	PassAt            *time.Time `gorm:"column:pass_at"`                               // 审核通过时间
 	FinishAt          *time.Time `gorm:"column:finish_at"`                             // 结案时间
+	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"`                     // 结算金额

+ 1 - 1
model/http_model/GetCodeUrlRequest.go

@@ -1,7 +1,7 @@
 package http_model
 
 type GetCodeUrlRequest struct {
-	Amount float64 `json:"amount"`
+	Amount int64 `json:"amount"`
 	Type   int64 `json:"type"`
 }
 

+ 1 - 0
model/http_model/project_show.go

@@ -46,6 +46,7 @@ type ShowProjectData struct {
 	Phone            string                `json:"phone"`              // 联系方式
 	CreateAt         time.Time             `json:"create_at"`          // 创建时间
 	UpdateAt         time.Time             `json:"update_at"`          // 更新时间
+	SubmitAt         time.Time             `json:"submit_at"`          // 更新时间
 	PassAt           time.Time             `json:"pass_at"`            // 审核通过时间
 	FinishAt         time.Time             `json:"finish_at"`          // 结案时间
 	PayAt            time.Time             `json:"pay_at"`             // 支付时间

+ 1 - 0
model/http_model/task_logistics.go

@@ -52,6 +52,7 @@ type TaskLogisticsInfo struct {
 type TaskLogistics struct {
 	Talent    gorm_model.YoungeeTaskInfo
 	Logistics gorm_model.YoungeeTaskLogistics
+	Region    string
 	//Account   gorm_model.YoungeePlatformAccountInfo
 }
 

+ 1 - 1
pack/task_logistics_list.go

@@ -55,7 +55,7 @@ func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.Ta
 		PlatformNickname:      conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname")),
 		FansCount:             conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")),
 		StrategyID:            TaskLogistics.Talent.StrategyID,
-		DetailAddr:            conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")),
+		DetailAddr:            TaskLogistics.Region + conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")),
 		CompanyName:           TaskLogistics.Logistics.CompanyName,
 		LogisticsNumber:       TaskLogistics.Logistics.LogisticsNumber,
 		DeliveryTime:          conv.MustString(TaskLogistics.Logistics.DeliveryTime),

+ 6 - 1
service/pay.go

@@ -2,9 +2,10 @@ package service
 
 import (
 	"context"
-	log "github.com/sirupsen/logrus"
 	"youngee_b_api/db"
 	"youngee_b_api/model/http_model"
+
+	log "github.com/sirupsen/logrus"
 )
 
 var Pay *pay
@@ -23,6 +24,10 @@ func (*pay) GetPaysum(ctx context.Context, project http_model.PaySumRequest) (*h
 		return nil, err
 	}
 	payMap := make(map[int]float64)
+	recruitStrategys, err := db.GetRecruitStrategyByProjectId(ctx, projectId)
+	for _, v := range recruitStrategys {
+		payMap[int(v.StrategyID)] = 0
+	}
 	PaySum := http_model.PaySumResponce{}
 	if tasks != nil {
 		for _, task := range tasks {

+ 3 - 0
service/project.go

@@ -208,6 +208,7 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
 		}
 	}
 	feeFroms := strings.Join(feeFrom, ",")
+	t := time.Now()
 	project := gorm_model.ProjectInfo{
 		ProjectID:     newProject.ProjectID,
 		RecruitDdl:    &RecruitDdl,
@@ -219,6 +220,7 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
 		ProjectStatus: conv.MustInt64(newProject.ProjectStatus),
 		FeeForm:       feeFroms,
 		EstimatedCost: ECost,
+		SubmitAt:      &t,
 	}
 	projectID, err := db.UpdateProject(ctx, project)
 	if err != nil {
@@ -389,6 +391,7 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID string) (*http_m
 		Phone:            user.Phone,
 		FinishAt:         util.GetTimePoionter(project.FinishAt),
 		PassAt:           util.GetTimePoionter(project.PassAt),
+		SubmitAt:         util.GetTimePoionter(project.SubmitAt),
 		PayAt:            util.GetTimePoionter(project.PayAt),
 		ProductInfo:      conv.MustString(project.ProductSnap),
 		ProductPhotoInfo: conv.MustString(project.ProductPhotoSnap),

+ 1 - 1
service/terminate.go

@@ -15,7 +15,7 @@ var Terminate *terminate
 type terminate struct {
 }
 
-// TaskTerminate 同意初稿
+// TaskTerminate 解约申请
 func (*terminate) TaskTerminate(ctx context.Context, request http_model.TaskTerminateRequest) (*http_model.TaskTerminateData, error) {
 	var TaskIDList []string
 	TaskIDs := strings.Split(request.TaskIds, ",")