diff --git a/api/consts/option.go b/api/consts/option.go index 33637af5..b407cd61 100644 --- a/api/consts/option.go +++ b/api/consts/option.go @@ -63,3 +63,11 @@ const ( const ( StreamerAcct_MatchPhraseLen = 3 ) + +const ( + BankCard = 10 //银行卡 + Alipay = 20 //支付宝 + Weixin = 30 //微信 + MerchantWeixin = 40 //商户方微信 + CPAccount = 51 //中金支付电子账户 +) diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index 506ce95c..4da010af 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -215,6 +215,9 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeWorkerIdSrvFail: "用户职业者id映射表服务错误", ErrCodeWorkerIdNotExist: "用户职业者id映射表不存在", + ErrCodeSingleDistributeHisSrvFail: "慧用工下发打款历史表服务错误", + ErrCodeSingleDistributeHisNotExist: "慧用工下发打款历史表不存在", + ErrCodeHvyogoSrvFail: "慧用工接口服务错误", } @@ -515,6 +518,11 @@ const ( ErrCodeWorkerIdSrvFail ErrCode = -41001 // 用户职业者id映射表服务错误 ErrCodeWorkerIdNotExist ErrCode = -41002 // 用户职业者id映射表不存在 + // SingleDistributeHis: 42xxx + ErrCodeSingleDistributeHisSrvOk ErrCode = ErrCodeOk + ErrCodeSingleDistributeHisSrvFail ErrCode = -42001 // 慧用工下发打款历史表服务错误 + ErrCodeSingleDistributeHisNotExist ErrCode = -42002 // 慧用工下发打款历史表不存在 + // Media: 60xxx ErrCodeMediaSrvOk ErrCode = ErrCodeOk ErrCodeMediaSrvFail ErrCode = -60001 // 媒体服务错误 diff --git a/api/proto/hvyogo/proto/hvyogo_ext.go b/api/proto/hvyogo/proto/hvyogo_ext.go index 2d622d59..199c0bd5 100644 --- a/api/proto/hvyogo/proto/hvyogo_ext.go +++ b/api/proto/hvyogo/proto/hvyogo_ext.go @@ -4,3 +4,8 @@ type ExtAgreeCallbackReq struct { CooperatorId string `json:"cooperatorId"` // 商户对接唯一标识 BusinessBody string `json:"businessBody"` // AES加密后的字符串 } + +type ExtSingleDistributeCallbackReq struct { + CooperatorId string `json:"cooperatorId"` // 商户对接唯一标识 + BusinessBody string `json:"businessBody"` // AES加密后的字符串 +} diff --git a/api/proto/hvyogo/proto/hvyogo_vo.go b/api/proto/hvyogo/proto/hvyogo_vo.go index f556c30e..7d514be0 100644 --- a/api/proto/hvyogo/proto/hvyogo_vo.go +++ b/api/proto/hvyogo/proto/hvyogo_vo.go @@ -7,6 +7,17 @@ type ExtAgreeCallbackVO struct { WorkerMobile string `json:"workerMobile"` // 自由职业者手机号 } +type ExtSingleDistributeCallbackVO struct { + RequestNo string `json:"request_no"` //商户下发请求单号 + DistributeId string `json:"distribute_id"` //慧用工平台处理单号 + DistributeStatus int `json:"distribute_status"` //下发状态 + ServiceCharge string `json:"service_charge"` //该笔下发的服务费(单位:分) + DistributeAmount string `json:"distribute_amount"` //下发金额(单位:分) + Timestamp string `json:"timestamp"` //下单时间 + Remark string `json:"remark"` //银行返回打款备注 + ReasonCode string `json:"reason_code"` //余额不足时会返回E00001 +} + type WorkerAgreeStateVO struct { StatusCode string `json:"statusCode"` StatusText string `json:"statusText"` diff --git a/api/proto/single_distribute_his/proto/single_distribute_his_op.go b/api/proto/single_distribute_his/proto/single_distribute_his_op.go new file mode 100644 index 00000000..b738a50b --- /dev/null +++ b/api/proto/single_distribute_his/proto/single_distribute_his_op.go @@ -0,0 +1,66 @@ +package proto + +import ( + "service/api/base" + "service/dbstruct" +) + +// op 创建 +type OpCreateReq struct { + base.BaseRequest + *dbstruct.SingleDistributeHis +} + +type OpCreateData struct { +} + +type OpCreateResp struct { + base.BaseResponse + Data *OpCreateData `json:"data"` +} + +// op 删除 +type OpDeleteReq struct { + base.BaseRequest + Id int64 `json:"id"` +} + +type OpDeleteData struct { +} + +type OpDeleteResp struct { + base.BaseResponse + Data *OpDeleteData `json:"data"` +} + +// op 更新 +type OpUpdateReq struct { + base.BaseRequest + *dbstruct.SingleDistributeHis +} + +type OpUpdateData struct { +} + +type OpUpdateResp struct { + base.BaseResponse + Data *OpUpdateData `json:"data"` +} + +// op 列表 +type OpListReq struct { + base.BaseRequest + Offset int `json:"offset"` + Limit int `json:"limit"` +} + +type OpListData struct { + List []*dbstruct.SingleDistributeHis `json:"list"` + Offset int `json:"offset"` + More int `json:"more"` +} + +type OpListResp struct { + base.BaseResponse + Data *OpListData `json:"data"` +} diff --git a/app/mix/controller/hvyogo_callback.go b/app/mix/controller/hvyogo_callback.go index 50bd56a5..84ba944f 100644 --- a/app/mix/controller/hvyogo_callback.go +++ b/app/mix/controller/hvyogo_callback.go @@ -17,7 +17,7 @@ func ExtAgreeCallback(ctx *gin.Context) { // 存入数据 ec := service.DefaultService.SaveAgreeCallback(ctx, req) - if ec != errcode.ErrCodeWorkerIdSrvOk { + if ec != errcode.ErrCodeHvyogoSrvOk { logger.Error("SaveAgreeCallback fail, req: %v, ec: %v", util.ToJson(req), ec) response.ReplyErrCodeMsg(ctx, ec) return @@ -25,3 +25,18 @@ func ExtAgreeCallback(ctx *gin.Context) { response.ReplyOk(ctx, nil) } + +func ExtSingleDistributeCallback(ctx *gin.Context) { + + req := ctx.MustGet("client_req").(*hvyogoproto.ExtSingleDistributeCallbackReq) + + // 存入数据 + ec := service.DefaultService.SaveSingleDistributeCallback(ctx, req) + if ec != errcode.ErrCodeHvyogoSrvOk { + logger.Error("SaveSingleDistributeCallback fail, req: %v, ec: %v", util.ToJson(req), ec) + response.ReplyErrCodeMsg(ctx, ec) + return + } + + response.ReplyOk(ctx, nil) +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index a4068a0c..8db76b5b 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -317,6 +317,7 @@ func Init(r *gin.Engine) { // 慧用工 extHvyogoGroup := r.Group("/ext/hvyogo") extHvyogoGroup.POST("agree_callback", middleware.JSONParamValidator(hvyogoproto.ExtAgreeCallbackReq{}), ExtAgreeCallback) + extHvyogoGroup.POST("single_distribute_callback", middleware.JSONParamValidator(hvyogoproto.ExtSingleDistributeCallbackReq{}), ExtSingleDistributeCallback) // 验证码 opVeriCodeGroup := r.Group("/op/veri_code", PrepareOp()) @@ -539,6 +540,13 @@ func Init(r *gin.Engine) { // 空间相关每日报表 opDailyStatementZoneInfoGroup := r.Group("/op/daily_statement_zone_info", PrepareOp()) opDailyStatementZoneInfoGroup.POST("list", middleware.JSONParamValidator(daily_statement_zone_info_proto.OpListReq{}), middleware.JwtAuthenticator(), OpGetDailyStatementZoneInfoList) + + // 慧用工下发打款历史表 + // opSingleDistributeHisGroup := r.Group("/api/single_distribute_his", PrepareOp()) + // opSingleDistributeHisGroup.POST("create", middleware.JSONParamValidator(single_distribute_hisproto.OpCreateReq{}), middleware.JwtAuthenticator(), OpCreateSingleDistributeHis) + // opSingleDistributeHisGroup.POST("update", middleware.JSONParamValidator(single_distribute_hisproto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateSingleDistributeHis) + // opSingleDistributeHisGroup.POST("delete", middleware.JSONParamValidator(single_distribute_hisproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteSingleDistributeHis) + // opSingleDistributeHisGroup.POST("list", middleware.JSONParamValidator(single_distribute_hisproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetSingleDistributeHisList) } func ServeFile(ctx *gin.Context) { diff --git a/app/mix/controller/single_distribute_his_op.go b/app/mix/controller/single_distribute_his_op.go new file mode 100644 index 00000000..b854ee33 --- /dev/null +++ b/app/mix/controller/single_distribute_his_op.go @@ -0,0 +1,73 @@ +package controller + +import ( + "service/api/consts" + "service/api/errcode" + single_distribute_his_proto "service/api/proto/single_distribute_his/proto" + "service/app/mix/service" + "service/bizcommon/util" + "service/library/logger" + + "github.com/gin-gonic/gin" +) + +func OpCreateSingleDistributeHis(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*single_distribute_his_proto.OpCreateReq) + ec := service.DefaultService.OpCreateSingleDistributeHis(ctx, req) + if ec != errcode.ErrCodeSingleDistributeHisSrvOk { + logger.Error("OpCreateSingleDistributeHis fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrorMsg(ctx, "server error") + return + } + + ReplyOk(ctx, nil) +} + +func OpUpdateSingleDistributeHis(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*single_distribute_his_proto.OpUpdateReq) + ec := service.DefaultService.OpUpdateSingleDistributeHis(ctx, req) + if ec != errcode.ErrCodeSingleDistributeHisSrvOk { + logger.Error("OpUpdateSingleDistributeHis fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + ReplyOk(ctx, nil) +} + +func OpDeleteSingleDistributeHis(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*single_distribute_his_proto.OpDeleteReq) + ec := service.DefaultService.OpDeleteSingleDistributeHis(ctx, req.Id) + if ec != errcode.ErrCodeSingleDistributeHisSrvOk { + logger.Error("OpDeleteSingleDistributeHis fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + ReplyOk(ctx, nil) +} + +func OpGetSingleDistributeHisList(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*single_distribute_his_proto.OpListReq) + + //设置默认页长 + if req.Limit == 0 { + req.Limit = consts.DefaultPageSize + } + + list, ec := service.DefaultService.OpGetSingleDistributeHisList(ctx, req) + if ec != errcode.ErrCodeSingleDistributeHisSrvOk { + logger.Error("OpGetSingleDistributeHisList fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + data := &single_distribute_his_proto.OpListData{ + List: list, + Offset: req.Offset + len(list), + } + if len(list) >= req.Limit { + data.More = 1 + } + ReplyOk(ctx, data) +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 6ced387c..f9b62604 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -33,6 +33,7 @@ import ( moment_audit_taskproto "service/api/proto/moment_audit_task/proto" productproto "service/api/proto/product/proto" realname_authenticationproto "service/api/proto/realname_authentication/proto" + single_distribute_his_proto "service/api/proto/single_distribute_his/proto" streamerproto "service/api/proto/streamer/proto" streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto" streamerlinkproto "service/api/proto/streamerlink/proto" @@ -217,6 +218,9 @@ const ( DBWorkerId = "worker_id" COLWorkerId = "worker_id" + + DBSingleDistributeHis = "single_distribute_his" + COLSingleDistributeHis = "single_distribute_his" ) // 商品表 @@ -548,6 +552,11 @@ func (m *Mongo) getColWorkerId() *qmgo.Collection { return m.clientMix.Database(DBWorkerId).Collection(COLWorkerId) } +// 慧用工下发打款历史表表 +func (m *Mongo) getColSingleDistributeHis() *qmgo.Collection { + return m.clientMix.Database(DBSingleDistributeHis).Collection(COLSingleDistributeHis) +} + // 商品相关 func (m *Mongo) CreateProduct(ctx *gin.Context, product *dbstruct.Product) error { col := m.getColProduct() @@ -5270,3 +5279,46 @@ func (m *Mongo) GetWorkerIdByMid(ctx *gin.Context, req *workeridproto.OpListByMi } return workerId, err } + +// 慧用工下发打款历史表相关 +func (m *Mongo) CreateSingleDistributeHis(ctx *gin.Context, single_distribute_his *dbstruct.SingleDistributeHis) error { + col := m.getColSingleDistributeHis() + _, err := col.InsertOne(ctx, single_distribute_his) + return err +} + +func (m *Mongo) UpdateSingleDistributeHis(ctx *gin.Context, single_distribute_his *dbstruct.SingleDistributeHis) error { + col := m.getColSingleDistributeHis() + set := util.EntityToM(single_distribute_his) + set["ut"] = time.Now().Unix() + up := qmgo.M{ + "$set": set, + } + err := col.UpdateId(ctx, single_distribute_his.GetId(), up) + return err +} + +func (m *Mongo) DeleteSingleDistributeHis(ctx *gin.Context, id int64) error { + col := m.getColSingleDistributeHis() + update := qmgo.M{ + "$set": qmgo.M{ + "del_flag": 1, + }, + } + err := col.UpdateId(ctx, id, update) + return err +} + +func (m *Mongo) GetSingleDistributeHisList(ctx *gin.Context, req *single_distribute_his_proto.OpListReq) ([]*dbstruct.SingleDistributeHis, error) { + list := make([]*dbstruct.SingleDistributeHis, 0) + col := m.getColSingleDistributeHis() + query := qmgo.M{ + "del_flag": 0, + } + err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return list, err + } + return list, err +} diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index bb2bf8c4..4b0330e1 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -18,6 +18,7 @@ import ( momentproto "service/api/proto/moment/proto" moment_audit_taskproto "service/api/proto/moment_audit_task/proto" realname_authenticationproto "service/api/proto/realname_authentication/proto" + single_distribute_his_proto "service/api/proto/single_distribute_his/proto" streamerproto "service/api/proto/streamer/proto" streameracctproto "service/api/proto/streamer_acct/proto" streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto" @@ -3374,13 +3375,35 @@ func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.A msg := &request.HYG10010001Req{ HYGBaseReq: &request.HYGBaseReq{}, WorkerName: detailResp.WorkerName, + ReceiptChannel: consts.BankCard, + WorkerAccount: detailResp.BankCardNo, WorkerType: detailResp.CertificateType, IdNumber: detailResp.IdentNo, WorkerMobile: detailResp.WorkerMobile, DistributeAmount: req.DistributeAmount, } - // 5.调用下发打款接口 + // 5.若上送了别的渠道,则设置参数 + if req.ReceiptChannel != 0 { + msg.ReceiptChannel = int(req.ReceiptChannel) + msg.WorkerAccount = req.WorkerAccount + } + + // 6.写入下发历史表,将历史表id作为requestNo + singleDistributeHis := &single_distribute_his_proto.OpCreateReq{ + SingleDistributeHis: &dbstruct.SingleDistributeHis{ + Mid: goproto.Int64(req.BaseRequest.Mid), + }, + } + err = _DefaultSingleDistributeHis.OpCreate(ctx, singleDistributeHis) + if err != nil { + logger.Error("_DefaultSingleDistributeHis OpCreate fail, err: %v", err) + ec = errcode.ErrCodeSingleDistributeHisSrvFail + return + } + msg.RequestNo = singleDistributeHis.GetId() + + // 7.调用下发打款接口 resp, err := DefaultHvyogoService.SingleDistribute(msg) if err != nil { logger.Error("DefaultHvyogoService SingleDistribute fail, err: %v", err) @@ -3388,7 +3411,7 @@ func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.A return } - // 6.组装返回结果 + // 8.组装返回结果 data = &hvyogoproto.ApiSingleDistributeData{} deepcopier.Copy(resp).To(data) diff --git a/app/mix/service/hvyogoservice.go b/app/mix/service/hvyogoservice.go index 49ac2d51..f87e1b90 100644 --- a/app/mix/service/hvyogoservice.go +++ b/app/mix/service/hvyogoservice.go @@ -1,6 +1,7 @@ package service import ( + "encoding/hex" "encoding/json" "fmt" "service/api/message/request" @@ -9,6 +10,7 @@ import ( "service/library/configcenter" "service/library/logger" "service/library/mycrypto" + "strings" "time" hvyogoproto "service/api/proto/hvyogo/proto" @@ -119,12 +121,14 @@ func (s *HvyogoService) SingleDistribute(req *request.HYG10010001Req) (vo *hvyog func afterReceiving(resp []byte, vo any) (err error) { baseResponse := &response.HygBaseResponse{} + // 先将返回码和返回信息解码至vo err = json.Unmarshal(resp, vo) if err != nil { logger.Error("json Unmarshal fail, err: %v", err) return } + // 解码response,若不成功则直接返回 err = json.Unmarshal(resp, baseResponse) if err != nil { logger.Error("json Unmarshal fail, err: %v", err) @@ -133,6 +137,8 @@ func afterReceiving(resp []byte, vo any) (err error) { if baseResponse.StatusCode != response.StatusCodeSuccess { return } + + // 获取aes加密串 aesEncryptedStr, ok := baseResponse.Data.(string) if !ok { err = fmt.Errorf("type assertion fail") @@ -140,8 +146,15 @@ func afterReceiving(resp []byte, vo any) (err error) { return } - // 解码aes - bytes, err := mycrypto.CryptoServiceInstance().HygAES.Decrypt([]byte(aesEncryptedStr)) + // 十六进制解码 + encryptedStr, err := hex.DecodeString(strings.ToLower(aesEncryptedStr)) + if err != nil { + logger.Error("Decryption fail, err: %v", err) + return + } + + // aes解码 + bytes, err := mycrypto.CryptoServiceInstance().HygAES.Decrypt([]byte(encryptedStr)) if err != nil { logger.Error("Decryption fail, err: %v", err) return diff --git a/app/mix/service/logic/single_distribute_his.go b/app/mix/service/logic/single_distribute_his.go new file mode 100644 index 00000000..29292472 --- /dev/null +++ b/app/mix/service/logic/single_distribute_his.go @@ -0,0 +1,65 @@ +package logic + +import ( + "service/api/consts" + single_distribute_his_proto "service/api/proto/single_distribute_his/proto" + "service/app/mix/dao" + "service/dbstruct" + "service/library/idgenerator" + "service/library/logger" + "time" + + "github.com/gin-gonic/gin" + goproto "google.golang.org/protobuf/proto" +) + +type SingleDistributeHis struct { + store *dao.Store +} + +func NewSingleDistributeHis(store *dao.Store) (a *SingleDistributeHis) { + a = &SingleDistributeHis{ + store: store, + } + return +} + +func (p *SingleDistributeHis) OpCreate(ctx *gin.Context, req *single_distribute_his_proto.OpCreateReq) error { + req.SingleDistributeHis.Id = goproto.String(idgenerator.GenSingleDistributeHisId()) + req.SingleDistributeHis.Ct = goproto.Int64(time.Now().Unix()) + req.SingleDistributeHis.Ut = goproto.Int64(time.Now().Unix()) + req.SingleDistributeHis.DelFlag = goproto.Int64(consts.Exist) + err := p.store.CreateSingleDistributeHis(ctx, req.SingleDistributeHis) + if err != nil { + logger.Error("CreateSingleDistributeHis fail, err: %v", err) + return err + } + return nil +} + +func (p *SingleDistributeHis) OpUpdate(ctx *gin.Context, req *single_distribute_his_proto.OpUpdateReq) error { + err := p.store.UpdateSingleDistributeHis(ctx, req.SingleDistributeHis) + if err != nil { + logger.Error("UpdateSingleDistributeHis fail, err: %v", err) + return err + } + return nil +} + +func (p *SingleDistributeHis) OpDelete(ctx *gin.Context, id int64) error { + err := p.store.DeleteSingleDistributeHis(ctx, id) + if err != nil { + logger.Error("DeleteSingleDistributeHis fail, err: %v", err) + return err + } + return nil +} + +func (p *SingleDistributeHis) OpList(ctx *gin.Context, req *single_distribute_his_proto.OpListReq) ([]*dbstruct.SingleDistributeHis, error) { + list, err := p.store.GetSingleDistributeHisList(ctx, req) + if err != nil { + logger.Error("GetSingleDistributeHisList fail, err: %v", err) + return make([]*dbstruct.SingleDistributeHis, 0), err + } + return list, nil +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index ace84723..e7491a4e 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -32,6 +32,7 @@ import ( productproto "service/api/proto/product/proto" realname_authenticationproto "service/api/proto/realname_authentication/proto" resourceproto "service/api/proto/resource/proto" + single_distribute_his_proto "service/api/proto/single_distribute_his/proto" streamerproto "service/api/proto/streamer/proto" streameracctproto "service/api/proto/streamer_acct/proto" streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto" @@ -136,6 +137,7 @@ var ( _DefaultContentAuditRTI *logic.ContentAuditRTI _DefaultStreamerScore *logic.StreamerScore _DefaultWorkerId *logic.WorkerId + _DefaultSingleDistributeHis *logic.SingleDistributeHis ) type Service struct { @@ -228,6 +230,7 @@ func (s *Service) Init(c any) (err error) { _DefaultContentAuditRTI = logic.NewContentAuditRTI(store) _DefaultStreamerScore = logic.NewStreamerScore(store) _DefaultWorkerId = logic.NewWorkerId(store) + _DefaultSingleDistributeHis = logic.NewSingleDistributeHis(store) _DefaultVas = logic.NewVas(store, _DefaultStreamer, _DefaultAccount, _DefaultZone, _DefaultZoneThirdPartner, _DefaultZoneCollaborator) _DefaultStreamerAcct = logic.NewStreamerAcct(store) @@ -4116,7 +4119,7 @@ func (s *Service) OpGetWorkerIdByMid(ctx *gin.Context, req *workeridproto.OpList } func (s *Service) SaveAgreeCallback(ctx *gin.Context, req *hvyogoproto.ExtAgreeCallbackReq) (ec errcode.ErrCode) { - ec = errcode.ErrCodeWorkerIdSrvOk + ec = errcode.ErrCodeHvyogoSrvOk // 解密AES bytes, err := hex.DecodeString(strings.ToLower(req.BusinessBody)) @@ -4173,3 +4176,105 @@ func (s *Service) SaveAgreeCallback(ctx *gin.Context, req *hvyogoproto.ExtAgreeC return } + +func (s *Service) SaveSingleDistributeCallback(ctx *gin.Context, req *hvyogoproto.ExtSingleDistributeCallbackReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeHvyogoSrvOk + + // 解密AES + bytes, err := hex.DecodeString(strings.ToLower(req.BusinessBody)) + if err != nil { + logger.Error("hex DecodeString fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeDecryptionInterceptFail + return + } + decryptedBytes, err := mycrypto.CryptoServiceInstance().HygAES.Decrypt(bytes) + if err != nil { + logger.Error("Decryption fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeDecryptionInterceptFail + return + } + + // 解析BusinessBody + vo := &hvyogoproto.ExtSingleDistributeCallbackVO{} + if err := json.Unmarshal(decryptedBytes, vo); err != nil { + logger.Error("Unmarshal fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAssertionFail + return + } + + // 更新数据 + err = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{ + SingleDistributeHis: &dbstruct.SingleDistributeHis{ + Id: goproto.String(vo.RequestNo), + DistributeId: goproto.String(vo.DistributeId), + DistributeStatus: goproto.Int64(int64(vo.DistributeStatus)), + ServiceCharge: goproto.String(vo.ServiceCharge), + DistributeAmount: goproto.String(vo.DistributeAmount), + Timestamp: goproto.String(vo.Timestamp), + Remark: goproto.String(vo.Remark), + ReasonCode: goproto.String(vo.ReasonCode), + }, + }) + if err == qmgo.ErrNoSuchDocuments { + logger.Error("_DefaultSingleDistributeHis OpUpdate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeSingleDistributeHisNotExist + return + } + if err != nil { + logger.Error("_DefaultSingleDistributeHis OpUpdate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeSingleDistributeHisSrvFail + return + } + + return +} + +// SingleDistributeHis +func (s *Service) OpCreateSingleDistributeHis(ctx *gin.Context, req *single_distribute_his_proto.OpCreateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeSingleDistributeHisSrvOk + err := _DefaultSingleDistributeHis.OpCreate(ctx, req) + if err != nil { + logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeSingleDistributeHisSrvFail + return + } + return +} + +func (s *Service) OpUpdateSingleDistributeHis(ctx *gin.Context, req *single_distribute_his_proto.OpUpdateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeSingleDistributeHisSrvOk + err := _DefaultSingleDistributeHis.OpUpdate(ctx, req) + if err == qmgo.ErrNoSuchDocuments { + ec = errcode.ErrCodeSingleDistributeHisNotExist + err = nil + return + } + if err != nil { + logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeSingleDistributeHisSrvFail + return + } + return +} + +func (s *Service) OpDeleteSingleDistributeHis(ctx *gin.Context, id int64) (ec errcode.ErrCode) { + ec = errcode.ErrCodeSingleDistributeHisSrvOk + err := _DefaultSingleDistributeHis.OpDelete(ctx, id) + if err != nil { + logger.Error("OpDelete fail, id: %v, err: %v", id, err) + ec = errcode.ErrCodeSingleDistributeHisSrvFail + return + } + return +} + +func (s *Service) OpGetSingleDistributeHisList(ctx *gin.Context, req *single_distribute_his_proto.OpListReq) (list []*dbstruct.SingleDistributeHis, ec errcode.ErrCode) { + ec = errcode.ErrCodeSingleDistributeHisSrvOk + list, err := _DefaultSingleDistributeHis.OpList(ctx, req) + if err != nil { + logger.Error("OpGetSingleDistributeHisList fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeSingleDistributeHisSrvFail + return + } + return +} diff --git a/codecreate/codecreate.go b/codecreate/codecreate.go index f6020657..645bf5ac 100644 --- a/codecreate/codecreate.go +++ b/codecreate/codecreate.go @@ -9,10 +9,10 @@ import ( func main() { genSource := &generator.GenSource{ - EntityName: "WorkerId", - ModuleName: "worker_id", - EntityCNName: "用户职业者id映射表", - ErrCodeSeq: "41", + EntityName: "SingleDistributeHis", + ModuleName: "single_distribute_his", + EntityCNName: "慧用工下发打款历史表", + ErrCodeSeq: "42", } generator.CreateFileDirectory(genSource) diff --git a/codecreate/resource/EntityDefine.xlsx b/codecreate/resource/EntityDefine.xlsx index e87515d0..d65c315b 100644 Binary files a/codecreate/resource/EntityDefine.xlsx and b/codecreate/resource/EntityDefine.xlsx differ diff --git a/dbstruct/single_distribute_his.go b/dbstruct/single_distribute_his.go new file mode 100644 index 00000000..eb79a4a6 --- /dev/null +++ b/dbstruct/single_distribute_his.go @@ -0,0 +1,23 @@ +package dbstruct + +type SingleDistributeHis struct { + Id *string `json:"id" bson:"_id"` // 慧用工下发打款历史表id + Mid *int64 `json:"mid" bson:"mid"` // 用户id + DistributeId *string `json:"distribute_id" bson:"distribute_id"` // 慧用工平台处理单号 + DistributeStatus *int64 `json:"distribute_status" bson:"distribute_status"` // 下发状态 + ServiceCharge *string `json:"service_charge" bson:"service_charge"` // 该笔下发的服务费(单位:分) + DistributeAmount *string `json:"distribute_amount" bson:"distribute_amount"` // 下发金额(单位:分) + Timestamp *string `json:"timestamp" bson:"timestamp"` // 下单时间 + Remark *string `json:"remark" bson:"remark"` // 银行返回打款备注 + ReasonCode *string `json:"reason_code" bson:"reason_code"` // 余额不足时会返回E00001 + Ct *int64 `json:"ct" bson:"ct"` // 创建时间 + Ut *int64 `json:"ut" bson:"ut"` // 更新时间 + DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 +} + +func (p *SingleDistributeHis) GetId() string { + if p != nil && p.Id != nil { + return *p.Id + } + return "" +} diff --git a/library/idgenerator/genid.go b/library/idgenerator/genid.go index 806f8171..27100b50 100644 --- a/library/idgenerator/genid.go +++ b/library/idgenerator/genid.go @@ -54,6 +54,7 @@ const ( NodeZoneThirdPartner // node 空间代运营表 NodeDailyStatementZoneInfo // node 空间相关每日报表 NodeWorkerId // node 用户职业者id映射表 + NodeSingleDistributeHis // node 慧用工下发打款历史表 ) func GenIdInt64(node int64) (int64, error) { @@ -259,3 +260,9 @@ func GenWorkerIdId() int64 { id, _ := GenIdInt64(NodeWorkerId) return id } + +// single_distribute_his +func GenSingleDistributeHisId() string { + id, _ := GenIdString(NodeSingleDistributeHis) + return id +}