Merge branch 'feat-zjy-issue-013' into main

# Conflicts:
#	pb/bundle/bundle.pb.go
This commit is contained in:
周俊耀 2025-07-08 15:20:34 +08:00
commit 346dcb1d94
9 changed files with 2321 additions and 1585 deletions

View File

@ -117,3 +117,13 @@ func (b *BundleProvider) UpdateReconciliationStatusBySerialNumber(_ context.Cont
func (b *BundleProvider) DeleteValueAddService(_ context.Context, req *bundle.DeleteValueAddServiceRequest) (res *bundle.CommonResponse, err error) {
return logic.DeleteValueAddService(req)
}
// 自动创建用户且实名且下订单
func (b *BundleProvider) ListUnfinishedInfos(_ context.Context, req *bundle.AutoCreateUserAndOrderRequest) (res *bundle.UnfinishedInfos, err error) {
return logic.ListUnfinishedInfos(req)
}
// 自动创建用户且实名且下订单
func (b *BundleProvider) SoftDeleteUnfinishedInfo(_ context.Context, req *bundle.SoftDeleteUnfinishedInfoRequest) (res *bundle.CommonResponse, err error) {
return logic.SoftDeleteUnfinishedInfo(req)
}

View File

@ -32,7 +32,8 @@ func AddBundleExtendRecord(data model.BundleExtensionRecords) error {
et, _ := time.ParseInLocation(time.DateTime, record.ExpirationTime, loc)
expireTime = et
} else {
expireTime = time.Now()
t, _ := time.Parse("2006-01-02 15:04:05", record.PayTime)
expireTime = t
logger.Infof("过期时间为空,使用默认过期时间" + expireTime.Format(time.DateTime))
}

View File

@ -781,3 +781,65 @@ func DeleteValueAddService(req *bundle.DeleteValueAddServiceRequest) (res *bundl
res.Msg = msg.SuccessDeletedOrderInfo
return res, nil
}
func ListUnfinishedInfos(req *bundle.AutoCreateUserAndOrderRequest) (res *bundle.UnfinishedInfos, err error) {
res = new(bundle.UnfinishedInfos)
res.UnfinishedInfos = make([]*bundle.UnfinishedInfo, 0)
// TODO 0.捞出指定数量的数据
infos := make([]*model.FieePaymentAuto, 0)
query := app.ModuleClients.BundleDB.Where("deleted_at is null")
if req.Num != 0 {
query.Limit(int(req.Num))
}
err = query.Find(&infos).Error
if err != nil {
return nil, err
}
for _, info := range infos {
unfinishedInfo := new(bundle.UnfinishedInfo)
unfinishedInfo.ID = uint32(info.ID)
unfinishedInfo.UserNum = info.UserNum
unfinishedInfo.UserName = info.UserName
unfinishedInfo.UserTelArea = info.UserTelArea
unfinishedInfo.UserTel = info.UserTel
unfinishedInfo.UserSex = info.UserSex
unfinishedInfo.Nationality = info.Nationality
unfinishedInfo.PlaceOfResidence = info.PlaceOfResidence
unfinishedInfo.DocumentType = int32(info.DocumentType)
unfinishedInfo.UserIdCardFrontUrl = info.UserIdCardFrontUrl
unfinishedInfo.UserIdCardReverseUrl = info.UserIdCardReverseUrl
unfinishedInfo.UserIdCardValidity = info.UserIdCardValidity
unfinishedInfo.OrderNo = info.OrderNo
unfinishedInfo.OrderPayAmount = info.OrderPayAmount
unfinishedInfo.OrderSettlementAmount = info.OrderSettlementAmount
unfinishedInfo.OrderFeeAmount = info.OrderFeeAmount
unfinishedInfo.OrderPayCurrency = info.OrderPayCurrency
unfinishedInfo.OrderAccountCurrency = info.OrderAccountCurrency
unfinishedInfo.PayTime = info.PayTime.Format("2006-01-02 15:04:05")
res.UnfinishedInfos = append(res.UnfinishedInfos, unfinishedInfo)
}
return res, nil
}
func SoftDeleteUnfinishedInfo(req *bundle.SoftDeleteUnfinishedInfoRequest) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
exist := new(model.FieePaymentAuto)
// 查询未处理的数据
err = app.ModuleClients.BundleDB.Model(&model.FieePaymentAuto{}).
Where("id = ?", req.ID).
First(&exist).Error
if err != nil {
return nil, errors.New("数据不存在")
}
if err = app.ModuleClients.BundleDB.Where("id = ?", req.ID).
Delete(&model.FieePaymentAuto{}).Error; err != nil {
return res, errors.New("删除自动导入表数据失败")
}
return res, nil
}

View File

@ -13,6 +13,9 @@ func CreateOrderRecord(req *bundle.OrderCreateRecord) (res *bundle.CommonRespons
res = new(bundle.CommonResponse)
orderUUID := app.ModuleClients.SfNode.Generate().Base64()
orderNo := utils.GetOrderNo()
if req.OrderNo != "" {
orderNo = req.OrderNo
}
var addRecords []model.BundleOrderValueAdd
for _, i := range req.AddRecords {
addRecords = append(addRecords, model.BundleOrderValueAdd{
@ -34,6 +37,7 @@ func CreateOrderRecord(req *bundle.OrderCreateRecord) (res *bundle.CommonRespons
Signature: req.Signature,
SignedTime: req.SignedTime,
Snapshot: req.Snapshot,
HandlingFee: i.HandlingFee,
})
}
orderRecord := &model.BundleOrderRecords{
@ -161,3 +165,15 @@ func DeleteValueAddService(req *bundle.DeleteValueAddServiceRequest) (res *bundl
res, err = dao.DeleteValueAddService(req)
return
}
func ListUnfinishedInfos(req *bundle.AutoCreateUserAndOrderRequest) (res *bundle.UnfinishedInfos, err error) {
res = new(bundle.UnfinishedInfos)
res, err = dao.ListUnfinishedInfos(req)
return
}
func SoftDeleteUnfinishedInfo(req *bundle.SoftDeleteUnfinishedInfoRequest) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
res, err = dao.SoftDeleteUnfinishedInfo(req)
return
}

View File

@ -0,0 +1,29 @@
package model
import (
"gorm.io/gorm"
"time"
)
// 用来自动导入 来创建用户和订单的 数据
type FieePaymentAuto struct {
gorm.Model
UserNum string `json:"userNum" gorm:"column:user_num;type:varchar(64);comment:用户编号"`
UserName string `json:"userName" gorm:"column:user_name;type:varchar(128);comment:用户姓名"`
UserTelArea string `json:"userTelArea" gorm:"column:user_tel_area;type:varchar(32);comment:用户手机号区号"`
UserTel string `json:"userTel" gorm:"column:user_tel;type:varchar(32);comment:用户手机号"`
UserSex string `json:"userSex" gorm:"column:user_sex;type:varchar(16);comment:用户性别"`
Nationality string `json:"nationality" gorm:"column:nationality;type:varchar(128);comment:国籍"`
PlaceOfResidence string `json:"placeOfResidence" gorm:"column:place_of_residence;type:varchar(512);comment:用户居住地"`
DocumentType int `json:"documentType" gorm:"column:document_type;type:varchar(512);comment:证件类型:1护照 2身份证 3驾驶证 4居住证 5自拍照 6社保卡"`
UserIdCardFrontUrl string `json:"userIdCardFrontUrl" gorm:"column:user_id_card_front_url;type:varchar(1024);comment:用户身份证正面"`
UserIdCardReverseUrl string `json:"userIdCardReverseUrl" gorm:"column:user_id_card_reverse_url;type:varchar(1024);comment:用户身份证反面"`
UserIdCardValidity string `json:"userIdCardValidity" gorm:"column:user_id_card_validity;type:varchar(64);comment:证件有效期"`
OrderNo string `json:"orderNo" gorm:"column:order_no;type:varchar(128);comment:订单编号"`
OrderPayAmount string `gorm:"column:order_pay_amount;type:decimal(20,2);comment:订单支付金额" json:"orderPayAmount"`
OrderSettlementAmount string `gorm:"column:order_settlement_amount;type:decimal(20,2);comment:订单结算金额" json:"orderSettlementAmount"`
OrderFeeAmount string `gorm:"column:order_fee_amount;type:decimal(20,2);comment:订单手续费金额" json:"orderFeeAmount"`
OrderPayCurrency string `json:"orderPayCurrency" gorm:"column:order_pay_currency;type:varchar(16);comment:支付时的币种cny人民币usd美元"`
OrderAccountCurrency string `json:"orderAccountCurrency" gorm:"column:order_account_currency;type:varchar(16);comment:账户上的币种: 暂时固定usd美元"`
PayTime time.Time `gorm:"column:pay_time;type:datetime;default:null;comment:支付成功时间" json:"payTime"`
}

View File

@ -74,6 +74,10 @@ service Bundle {
rpc CreateReconciliation(ReconciliationInfo) returns (CommonResponse) {} //
rpc UpdateReconciliation(ReconciliationInfo) returns (CommonResponse) {} //
rpc UpdateReconciliationStatusBySerialNumber(UpdateStatusAndPayTimeBySerialNumber) returns (CommonResponse) {} //
//
rpc ListUnfinishedInfos(AutoCreateUserAndOrderRequest) returns (UnfinishedInfos) {} //
rpc SoftDeleteUnfinishedInfo(SoftDeleteUnfinishedInfoRequest) returns (CommonResponse) {} //
}
message DeleteValueAddServiceRequest{
string orderNo = 1;
@ -154,6 +158,7 @@ message OrderCreateRecord{
string snapshot = 18 [json_name = "snapshot"];
int32 payType = 19 [json_name = "payType"];
repeated OrderCreateAddRecord addRecords = 20 [json_name = "addRecords"]; //
string orderNo = 21 [json_name = "orderNo"];
}
message OrderCreateAddRecord{
int32 serviceType = 1 [json_name = "serviceType"];
@ -164,6 +169,7 @@ message OrderCreateAddRecord{
string unit = 6 [json_name = "unit"];
int32 source = 7 [json_name = "source"];
int32 paymentStatus = 8 [json_name = "paymentStatus"];
string handlingFee = 9 [json_name = "handlingFee"];
}
message OrderRecordsRequestV2{
string customerName = 1;
@ -831,4 +837,38 @@ message ConfirmWorkReq{
message ConfirmWorkResp{
}
}
message AutoCreateUserAndOrderRequest {
int32 num = 1; //
}
message UnfinishedInfos {
repeated UnfinishedInfo unfinishedInfos = 1;
}
message UnfinishedInfo {
uint32 ID = 1;
string userNum = 2;
string userName = 3;
string userTelArea = 4;
string userTel = 5;
string userSex = 6;
string nationality = 7;
string placeOfResidence = 8;
int32 documentType = 9;
string userIdCardFrontUrl = 10;
string userIdCardReverseUrl = 11;
string userIdCardValidity = 12;
string orderNo = 13;
string orderPayAmount = 14;
string orderSettlementAmount = 15;
string orderFeeAmount = 16;
string orderPayCurrency = 17;
string orderAccountCurrency = 18;
string payTime = 19;
}
message SoftDeleteUnfinishedInfoRequest {
uint32 ID = 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -447,3 +447,22 @@ func (this *ConfirmWorkReq) Validate() error {
func (this *ConfirmWorkResp) Validate() error {
return nil
}
func (this *AutoCreateUserAndOrderRequest) Validate() error {
return nil
}
func (this *UnfinishedInfos) Validate() error {
for _, item := range this.UnfinishedInfos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("UnfinishedInfos", err)
}
}
}
return nil
}
func (this *UnfinishedInfo) Validate() error {
return nil
}
func (this *SoftDeleteUnfinishedInfoRequest) Validate() error {
return nil
}

View File

@ -80,6 +80,9 @@ type BundleClient interface {
CreateReconciliation(ctx context.Context, in *ReconciliationInfo, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
UpdateReconciliation(ctx context.Context, in *ReconciliationInfo, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
UpdateReconciliationStatusBySerialNumber(ctx context.Context, in *UpdateStatusAndPayTimeBySerialNumber, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
// 查出没处理的数据
ListUnfinishedInfos(ctx context.Context, in *AutoCreateUserAndOrderRequest, opts ...grpc_go.CallOption) (*UnfinishedInfos, common.ErrorWithAttachment)
SoftDeleteUnfinishedInfo(ctx context.Context, in *SoftDeleteUnfinishedInfoRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
}
type bundleClient struct {
@ -134,6 +137,8 @@ type BundleClientImpl struct {
CreateReconciliation func(ctx context.Context, in *ReconciliationInfo) (*CommonResponse, error)
UpdateReconciliation func(ctx context.Context, in *ReconciliationInfo) (*CommonResponse, error)
UpdateReconciliationStatusBySerialNumber func(ctx context.Context, in *UpdateStatusAndPayTimeBySerialNumber) (*CommonResponse, error)
ListUnfinishedInfos func(ctx context.Context, in *AutoCreateUserAndOrderRequest) (*UnfinishedInfos, error)
SoftDeleteUnfinishedInfo func(ctx context.Context, in *SoftDeleteUnfinishedInfoRequest) (*CommonResponse, error)
}
func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient {
@ -430,6 +435,18 @@ func (c *bundleClient) UpdateReconciliationStatusBySerialNumber(ctx context.Cont
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateReconciliationStatusBySerialNumber", in, out)
}
func (c *bundleClient) ListUnfinishedInfos(ctx context.Context, in *AutoCreateUserAndOrderRequest, opts ...grpc_go.CallOption) (*UnfinishedInfos, common.ErrorWithAttachment) {
out := new(UnfinishedInfos)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ListUnfinishedInfos", in, out)
}
func (c *bundleClient) SoftDeleteUnfinishedInfo(ctx context.Context, in *SoftDeleteUnfinishedInfoRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) {
out := new(CommonResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SoftDeleteUnfinishedInfo", in, out)
}
// BundleServer is the server API for Bundle service.
// All implementations must embed UnimplementedBundleServer
// for forward compatibility
@ -486,6 +503,9 @@ type BundleServer interface {
CreateReconciliation(context.Context, *ReconciliationInfo) (*CommonResponse, error)
UpdateReconciliation(context.Context, *ReconciliationInfo) (*CommonResponse, error)
UpdateReconciliationStatusBySerialNumber(context.Context, *UpdateStatusAndPayTimeBySerialNumber) (*CommonResponse, error)
// 查出没处理的数据
ListUnfinishedInfos(context.Context, *AutoCreateUserAndOrderRequest) (*UnfinishedInfos, error)
SoftDeleteUnfinishedInfo(context.Context, *SoftDeleteUnfinishedInfoRequest) (*CommonResponse, error)
mustEmbedUnimplementedBundleServer()
}
@ -635,6 +655,12 @@ func (UnimplementedBundleServer) UpdateReconciliation(context.Context, *Reconcil
func (UnimplementedBundleServer) UpdateReconciliationStatusBySerialNumber(context.Context, *UpdateStatusAndPayTimeBySerialNumber) (*CommonResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateReconciliationStatusBySerialNumber not implemented")
}
func (UnimplementedBundleServer) ListUnfinishedInfos(context.Context, *AutoCreateUserAndOrderRequest) (*UnfinishedInfos, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListUnfinishedInfos not implemented")
}
func (UnimplementedBundleServer) SoftDeleteUnfinishedInfo(context.Context, *SoftDeleteUnfinishedInfoRequest) (*CommonResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SoftDeleteUnfinishedInfo not implemented")
}
func (s *UnimplementedBundleServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
@ -2026,6 +2052,64 @@ func _Bundle_UpdateReconciliationStatusBySerialNumber_Handler(srv interface{}, c
return interceptor(ctx, in, info, handler)
}
func _Bundle_ListUnfinishedInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(AutoCreateUserAndOrderRequest)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("ListUnfinishedInfos", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
func _Bundle_SoftDeleteUnfinishedInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(SoftDeleteUnfinishedInfoRequest)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("SoftDeleteUnfinishedInfo", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
// Bundle_ServiceDesc is the grpc_go.ServiceDesc for Bundle service.
// It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -2221,6 +2305,14 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "UpdateReconciliationStatusBySerialNumber",
Handler: _Bundle_UpdateReconciliationStatusBySerialNumber_Handler,
},
{
MethodName: "ListUnfinishedInfos",
Handler: _Bundle_ListUnfinishedInfos_Handler,
},
{
MethodName: "SoftDeleteUnfinishedInfo",
Handler: _Bundle_SoftDeleteUnfinishedInfo_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "pb/bundle.proto",