by Robin at 20240621

This commit is contained in:
Leufolium 2024-06-21 18:25:24 +08:00
parent e6d1b90338
commit 9ee568f858
15 changed files with 277 additions and 20 deletions

View File

@ -1,6 +1,9 @@
package request
import "service/api/message"
import (
"service/api/message"
"service/library/validator"
)
// 自由职业者网签查询报文
type HYG10000001Req struct {
@ -16,3 +19,11 @@ func (req *HYG10000001Req) GetArgList() []*message.JsonParamEntry {
list = append(list, &message.JsonParamEntry{Name: "workerId", Value: req.WorkerId})
return list
}
func (p *HYG10000001Req) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewStringParam("商户id不可为空", p.GetCooperatorId()))
params = append(params, validator.NewStringParam("时间戳不可为空!", p.Timestamp))
params = append(params, validator.NewStringParam("职业者Id不可为空", p.WorkerId))
return params
}

View File

@ -1,6 +1,9 @@
package request
import "service/api/message"
import (
"service/api/message"
"service/library/validator"
)
// 自由职业者信息详情查询
type HYG10000002Req struct {
@ -16,3 +19,11 @@ func (req *HYG10000002Req) GetArgList() []*message.JsonParamEntry {
list = append(list, &message.JsonParamEntry{Name: "workerId", Value: req.WorkerId})
return list
}
func (p *HYG10000002Req) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewStringParam("商户id不可为空", p.GetCooperatorId()))
params = append(params, validator.NewStringParam("时间戳不可为空!", p.Timestamp))
params = append(params, validator.NewStringParam("职业者Id不可为空", p.WorkerId))
return params
}

View File

@ -1,6 +1,9 @@
package request
import "service/api/message"
import (
"service/api/message"
"service/library/validator"
)
// 下发(打款)报文
type HYG10010001Req struct {
@ -35,12 +38,38 @@ func (req *HYG10010001Req) GetArgList() []*message.JsonParamEntry {
list = append(list, &message.JsonParamEntry{Name: "workerMobile", Value: req.WorkerMobile})
list = append(list, &message.JsonParamEntry{Name: "distributeAmount", Value: req.DistributeAmount})
list = append(list, &message.JsonParamEntry{Name: "requestNo", Value: req.RequestNo})
list = append(list, &message.JsonParamEntry{Name: "callbackUrl", Value: req.CallbackUrl})
list = append(list, &message.JsonParamEntry{Name: "remark", Value: req.Remark})
list = append(list, &message.JsonParamEntry{Name: "workerContent", Value: req.WorkerContent})
list = append(list, &message.JsonParamEntry{Name: "wageStatement", Value: req.WageStatement})
list = append(list, &message.JsonParamEntry{Name: "workTime", Value: req.WorkTime})
if req.CallbackUrl != "" {
list = append(list, &message.JsonParamEntry{Name: "callbackUrl", Value: req.CallbackUrl})
}
if req.Remark != "" {
list = append(list, &message.JsonParamEntry{Name: "remark", Value: req.Remark})
}
if req.WorkerContent != "" {
list = append(list, &message.JsonParamEntry{Name: "workerContent", Value: req.WorkerContent})
}
if req.WageStatement != "" {
list = append(list, &message.JsonParamEntry{Name: "wageStatement", Value: req.WageStatement})
}
if req.WorkTime != "" {
list = append(list, &message.JsonParamEntry{Name: "workTime", Value: req.WorkTime})
}
list = append(list, &message.JsonParamEntry{Name: "positionId", Value: req.PositionId})
list = append(list, &message.JsonParamEntry{Name: "weChatAppId", Value: req.WeChatAppId})
if req.WeChatAppId != "" {
list = append(list, &message.JsonParamEntry{Name: "weChatAppId", Value: req.WeChatAppId})
}
return list
}
func (p *HYG10010001Req) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewStringParam("商户id不可为空", p.GetCooperatorId()))
params = append(params, validator.NewStringParam("时间戳不可为空!", p.Timestamp))
params = append(params, validator.NewStringParam("收款人姓名不可为空!", p.WorkerName))
params = append(params, validator.NewStringParam("收款人账号不可为空!", p.WorkerAccount))
params = append(params, validator.NewStringParam("职业者身份证号码不可为空!", p.IdNumber))
params = append(params, validator.NewStringParam("职业者手机号码不可为空!", p.WorkerMobile))
params = append(params, validator.NewStringParam("打款金额不可为空!", p.DistributeAmount))
params = append(params, validator.NewStringParam("下发请求单号不可为空!", p.RequestNo))
params = append(params, validator.NewStringParam("任务ID不可为空", p.PositionId))
return params
}

View File

@ -0,0 +1,38 @@
package request
import (
"service/api/message"
"service/library/validator"
)
// 自由职业者信息修改报文
type HYG10010002Req struct {
*HYGBaseReq
Timestamp string `json:"timestamp"` // 时间戳
WorkerId string `json:"workerId"` // 职业者id
WorkerMobile string `json:"workerMobile"` // 职业者手机号码
BankCard string `json:"bankCard"` // 收款账号
ReceiptChannel int `json:"receiptChannel"` // 收款渠道
}
func (req *HYG10010002Req) GetArgList() []*message.JsonParamEntry {
list := make([]*message.JsonParamEntry, 0)
list = append(list, &message.JsonParamEntry{Name: "cooperatorId", Value: req.HYGBaseReq.CooperatorId})
list = append(list, &message.JsonParamEntry{Name: "timestamp", Value: req.Timestamp})
list = append(list, &message.JsonParamEntry{Name: "workerId", Value: req.WorkerId})
list = append(list, &message.JsonParamEntry{Name: "workerMobile", Value: req.WorkerMobile})
list = append(list, &message.JsonParamEntry{Name: "bankCard", Value: req.BankCard})
list = append(list, &message.JsonParamEntry{Name: "receiptChannel", Value: req.ReceiptChannel})
return list
}
func (p *HYG10010002Req) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewStringParam("商户id不可为空", p.GetCooperatorId()))
params = append(params, validator.NewStringParam("时间戳不可为空!", p.Timestamp))
params = append(params, validator.NewStringParam("职业者Id不可为空", p.WorkerId))
params = append(params, validator.NewStringParam("职业者手机号码不可为空!", p.WorkerMobile))
params = append(params, validator.NewStringParam("收款账号不可为空!", p.BankCard))
return params
}

View File

@ -6,9 +6,15 @@ type HYGBaseReq struct {
}
func (req *HYGBaseReq) SetSign(sign string) {
if req == nil {
return
}
req.Sign = sign
}
func (req *HYGBaseReq) GetCooperatorId() string {
if req == nil {
return ""
}
return req.CooperatorId
}

View File

@ -8,8 +8,9 @@ import (
)
const (
StatusCodeSuccess = "000000"
StatusCodeFail = "999999"
StatusCodeSuccess = "000000"
StatusCodeFail = "999999"
StatusCodeInnerError = "-1"
)
const (

View File

@ -9,7 +9,7 @@ type ApiQueryAgreeStateReq struct {
type ApiQueryAgreeStateData struct {
StatusCode string `json:"status_code" deepcopier:"field:StatusCode"` // 返回码
StatusText string `json:"status_text" deepcopier:"field:StatusText"` // 返回信息
AgreeState string `json:"agree_state" deepcopier:"field:AgreeState"` // 签约状态
AgreeState int `json:"agree_state" deepcopier:"field:AgreeState"` // 签约状态
AgreeDesc string `json:"agree_desc" deepcopier:"field:AgreeDesc"` // 签约状态描述
}
@ -66,3 +66,23 @@ type ApiSingleDistributeResp struct {
base.BaseResponse
Data *ApiSingleDistributeData `json:"data"`
}
type ApiWorkerUpdateReq struct {
base.BaseRequest
WorkerMobile string `json:"worker_mobile"` // 自由职业者手机号
BankCard string `json:"bank_card"` // 收款账号
ReceiptChannel int64 `json:"receipt_channel"` // 收款渠道
}
type ApiWorkerUpdateData struct {
StatusCode string `json:"status_code" deepcopier:"field:StatusCode"` // 返回码
StatusText string `json:"status_text" deepcopier:"field:StatusText"` // 返回信息
WorkerId string `json:"worker_id" deepcopier:"field:WorkerId"` // 自由职业者ID
WorkerMobile string `json:"worker_mobile" deepcopier:"field:WorkerMobile"` // 自由职业者手机号
BankCardNo string `json:"bank_card_no" deepcopier:"field:BankCardNo"` // 收款账号
}
type ApiWorkerUpdateResp struct {
base.BaseResponse
Data *ApiWorkerUpdateData `json:"data"`
}

View File

@ -22,7 +22,7 @@ type WorkerAgreeStateVO struct {
StatusCode string `json:"statusCode"`
StatusText string `json:"statusText"`
WorkerId string `json:"workerId"`
AgreeState string `json:"agreeState"`
AgreeState int `json:"agreeState"`
AgreeDesc string `json:"agreeDesc"`
IdCardFront string `json:"idCardFront"`
IdCardBack string `json:"idCardBack"`
@ -54,3 +54,11 @@ type SingleDistributeVO struct {
DistributeAmount string `json:"distributeAmount"` // 下发金额(与上送金额相同)
DistributeId string `json:"distributeId"` // 慧用工平台处理单号
}
type WorkerUpdateVO struct {
StatusCode string `json:"statusCode"`
StatusText string `json:"statusText"`
WorkerId string `json:"workerId"` // 自由职业者ID
WorkerMobile string `json:"workerMobile"` // 自由职业者手机号
BankCardNo string `json:"bankCardNo"` // 收款账号
}

View File

@ -15,7 +15,11 @@ func ApiHvyogoQueryAgreeState(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*hvyogoproto.ApiQueryAgreeStateReq)
// 存入数据
data, ec := service.DefaultService.ApiHvyogoQueryAgreeState(ctx, req)
data, ec, err := service.DefaultService.ApiHvyogoQueryAgreeState(ctx, req)
if err != nil {
ReplyErrorMsg(ctx, err.Error())
return
}
if ec != errcode.ErrCodeHvyogoSrvOk {
logger.Error("ApiHygQueryAgreeState fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
@ -30,7 +34,11 @@ func ApiHvyogoWorkerFindDetail(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*hvyogoproto.ApiWorkerFindDetailReq)
// 存入数据
data, ec := service.DefaultService.ApiHvyogoWorkerFindDetail(ctx, req)
data, ec, err := service.DefaultService.ApiHvyogoWorkerFindDetail(ctx, req)
if err != nil {
ReplyErrorMsg(ctx, err.Error())
return
}
if ec != errcode.ErrCodeHvyogoSrvOk {
logger.Error("ApiHygWorkerFindDetail fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
@ -45,7 +53,11 @@ func ApiHvyogoSingleDistribute(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*hvyogoproto.ApiSingleDistributeReq)
// 存入数据
data, ec := service.DefaultService.ApiHvyogoSingleDistribute(ctx, req)
data, ec, err := service.DefaultService.ApiHvyogoSingleDistribute(ctx, req)
if err != nil {
ReplyErrorMsg(ctx, err.Error())
return
}
if ec != errcode.ErrCodeHvyogoSrvOk {
logger.Error("ApiHygSingleDistribute fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
@ -54,3 +66,22 @@ func ApiHvyogoSingleDistribute(ctx *gin.Context) {
ReplyOk(ctx, data)
}
func ApiHvyogoWorkerUpdate(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*hvyogoproto.ApiWorkerUpdateReq)
// 存入数据
data, ec, err := service.DefaultService.ApiHvyogoWorkerUpdate(ctx, req)
if err != nil {
ReplyErrorMsg(ctx, err.Error())
return
}
if ec != errcode.ErrCodeHvyogoSrvOk {
logger.Error("ApiHygWorkerUpdate fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, data)
}

View File

@ -267,6 +267,7 @@ func Init(r *gin.Engine) {
apiHvyogoGroup.POST("query_agree_state", middleware.JSONParamValidator(hvyogoproto.ApiQueryAgreeStateReq{}), middleware.JwtAuthenticator(), ApiHvyogoQueryAgreeState)
apiHvyogoGroup.POST("worker_find_detail", middleware.JSONParamValidator(hvyogoproto.ApiWorkerFindDetailReq{}), middleware.JwtAuthenticator(), ApiHvyogoWorkerFindDetail)
apiHvyogoGroup.POST("single_distribute", middleware.JSONParamValidator(hvyogoproto.ApiSingleDistributeReq{}), middleware.JwtAuthenticator(), ApiHvyogoSingleDistribute)
apiHvyogoGroup.POST("worker_update", middleware.JSONParamValidator(hvyogoproto.ApiWorkerUpdateReq{}), middleware.JwtAuthenticator(), ApiHvyogoWorkerUpdate)
// =============================== 以下是服务,只允许内网调用 ===============================

View File

@ -3258,7 +3258,7 @@ func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collabo
return
}
func (s *Service) ApiHvyogoQueryAgreeState(ctx *gin.Context, req *hvyogoproto.ApiQueryAgreeStateReq) (data *hvyogoproto.ApiQueryAgreeStateData, ec errcode.ErrCode) {
func (s *Service) ApiHvyogoQueryAgreeState(ctx *gin.Context, req *hvyogoproto.ApiQueryAgreeStateReq) (data *hvyogoproto.ApiQueryAgreeStateData, ec errcode.ErrCode, err error) {
ec = errcode.ErrCodeHvyogoSrvOk
@ -3298,7 +3298,7 @@ func (s *Service) ApiHvyogoQueryAgreeState(ctx *gin.Context, req *hvyogoproto.Ap
return
}
func (s *Service) ApiHvyogoWorkerFindDetail(ctx *gin.Context, req *hvyogoproto.ApiWorkerFindDetailReq) (data *hvyogoproto.ApiWorkerFindDetailData, ec errcode.ErrCode) {
func (s *Service) ApiHvyogoWorkerFindDetail(ctx *gin.Context, req *hvyogoproto.ApiWorkerFindDetailReq) (data *hvyogoproto.ApiWorkerFindDetailData, ec errcode.ErrCode, err error) {
ec = errcode.ErrCodeHvyogoSrvOk
@ -3338,7 +3338,7 @@ func (s *Service) ApiHvyogoWorkerFindDetail(ctx *gin.Context, req *hvyogoproto.A
return
}
func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.ApiSingleDistributeReq) (data *hvyogoproto.ApiSingleDistributeData, ec errcode.ErrCode) {
func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.ApiSingleDistributeReq) (data *hvyogoproto.ApiSingleDistributeData, ec errcode.ErrCode, err error) {
ec = errcode.ErrCodeHvyogoSrvOk
@ -3411,9 +3411,68 @@ func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.A
return
}
// 8.组装返回结果
// 8.更新至历史表
err = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{
SingleDistributeHis: &dbstruct.SingleDistributeHis{
Id: singleDistributeHis.Id,
StatusCode: goproto.String(resp.StatusCode),
StatusText: goproto.String(resp.StatusText),
DistributeId: goproto.String(resp.DistributeId),
DistributeAmount: goproto.String(resp.DistributeAmount),
},
})
if err != nil {
logger.Error("_DefaultSingleDistributeHis OpUpdate fail, err: %v", err)
ec = errcode.ErrCodeSingleDistributeHisSrvFail
return
}
// 9.组装返回结果
data = &hvyogoproto.ApiSingleDistributeData{}
deepcopier.Copy(resp).To(data)
return
}
func (s *Service) ApiHvyogoWorkerUpdate(ctx *gin.Context, req *hvyogoproto.ApiWorkerUpdateReq) (data *hvyogoproto.ApiWorkerUpdateData, ec errcode.ErrCode, err error) {
ec = errcode.ErrCodeHvyogoSrvOk
// 1.查询workerId
workerId, err := _DefaultWorkerId.OpListByMid(ctx, &workeridproto.OpListByMidReq{
BaseRequest: req.BaseRequest,
})
if err != nil {
logger.Error("_DefaultWorkerId OpListByMid fail, err: %v", err)
ec = errcode.ErrCodeWorkerIdSrvFail
return
}
if workerId == nil {
logger.Error("No worker_id entity was found")
ec = errcode.ErrCodeWorkerIdNotExist
return
}
// 2.组装查询报文
msg := &request.HYG10010002Req{
HYGBaseReq: &request.HYGBaseReq{},
WorkerId: workerId.GetWorkerId(),
WorkerMobile: req.WorkerMobile,
BankCard: req.BankCard,
ReceiptChannel: int(req.ReceiptChannel),
}
// 3.调用查询接口
resp, err := DefaultHvyogoService.WorkerUpdate(msg)
if err != nil {
logger.Error("DefaultHvyogoService WorkerAgreeState fail, err: %v", err)
ec = errcode.ErrCodeHvyogoSrvFail
return
}
// 4.组装返回结果
data = &hvyogoproto.ApiWorkerUpdateData{}
deepcopier.Copy(resp).To(data)
return
}

View File

@ -118,6 +118,35 @@ func (s *HvyogoService) SingleDistribute(req *request.HYG10010001Req) (vo *hvyog
return
}
func (s *HvyogoService) WorkerUpdate(req *request.HYG10010002Req) (vo *hvyogoproto.WorkerUpdateVO, err error) {
// 写参
req.HYGBaseReq.CooperatorId = s.CooperatorId
req.Timestamp = fmt.Sprint(time.Now().UnixMilli())
// 加签
msg, err := DefaultService.utilSignHvyogoMessage(req)
if err != nil {
logger.Error("utilSignHvyogoMessage fail, req: %v, err: %v", util.ToJson(req), err)
return
}
// 发送消息
resp, err := DefaultEsbService.SendMsg("HYG10010002", msg)
if err != nil {
logger.Error("SendMsg fail, req: %v, err: %v", util.ToJson(req), err)
return
}
// 处理返回数据
vo = &hvyogoproto.WorkerUpdateVO{}
err = afterReceiving(resp, vo)
if err != nil {
logger.Error("afterReceiving fail, req: %v, err: %v", util.ToJson(req), err)
return
}
return
}
func afterReceiving(resp []byte, vo any) (err error) {
baseResponse := &response.HygBaseResponse{}

View File

@ -33,6 +33,7 @@ import (
"service/library/logger"
"service/library/mycrypto"
"service/library/redis"
"service/library/validator"
"strconv"
"strings"
"time"
@ -2097,6 +2098,15 @@ func (s *Service) utilAssembleDailyStatementZoneInfo(zoneprofits, zonerefunds []
}
func (s *Service) utilSignHvyogoMessage(msg interfaces.HvyogoSignable) ([]byte, error) {
// 非空校验
if notNullItem, ok := msg.(validator.NotNullItem); ok {
err := validator.GetDefaultNotNullValidator().Validate(notNullItem)
if err != nil {
return make([]byte, 0), fmt.Errorf("非空校验失败: %v", err)
}
}
// 1.RSA加密生成签名
sign, err := mycrypto.CryptoServiceInstance().HygSHA1WithRSA.Sign([]byte(util.SortParam(msg.GetArgList())))
if err != nil {

View File

@ -2,6 +2,8 @@ package dbstruct
type SingleDistributeHis struct {
Id *string `json:"id" bson:"_id"` // 慧用工下发打款历史表id
StatusCode *string `json:"status_code" bson:"status_code"` // 返回状态码
StatusText *string `json:"status_text" bson:"status_text"` // 返回状态描述
Mid *int64 `json:"mid" bson:"mid"` // 用户id
DistributeId *string `json:"distribute_id" bson:"distribute_id"` // 慧用工平台处理单号
DistributeStatus *int64 `json:"distribute_status" bson:"distribute_status"` // 下发状态

View File

@ -3,4 +3,5 @@
<msg name = "HYG10000001">https://boapi.hvyogo.com/api/worker/agree/state</msg>
<msg name = "HYG10000002">https://boapi.hvyogo.com/api/v2/hire/worker/findDetails</msg>
<msg name = "HYG10010001">https://boapi.hvyogo.com/api/distribute/singleDistribute</msg>
<msg name = "HYG10010002">https://boapi.hvyogo.com/api/v2/hire/worker/update</msg>
</esb_routing_table>