增值代码上传

This commit is contained in:
songchuang 2025-03-28 09:25:54 +08:00
parent 7ac7cda525
commit fb1295d561
12 changed files with 622 additions and 871 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,10 @@ syntax = "proto3";
package bundle;
option go_package = "./bundle";
import "pb/descriptor.proto";
import "pb/validator.proto";
service Bundle {
rpc CreateBundle(BundleProfile) returns (CommonResponse) {}
rpc UpdateBundle(BundleProfile) returns (CommonResponse) {}
@ -18,13 +22,9 @@ service Bundle {
rpc OrderRecordsDetail(OrderRecordsDetailRequest) returns (OrderRecordsDetailResponse) {}
//
rpc CreateValueAddBundle(ValueAddBundleProfile) returns (CommonResponse) {}
rpc UpdateValueAddBundle(ValueAddBundleProfile) returns (CommonResponse) {}
rpc DeleteValueAddBundle(DelValueAddBundleRequest) returns (CommonResponse) {}
rpc CreateValueAddBundle(CreateValueAddBundleRequest) returns (CreateValueAddBundleResponse) {}
rpc ValueAddBundleList(ValueAddBundleListRequest) returns (ValueAddBundleListResponse) {}
rpc ValueAddBundleDetail(ValueAddBundleDetailRequest) returns (ValueAddBundleDetailResponse) {}
rpc ValueAddBundleRecordDetail(ValueAddBundleDetailRequest) returns(ValueAddBundleDetailResponse) {}
}
message CommonResponse {
@ -92,16 +92,9 @@ message OrderRecord {
string orderNo = 16 [json_name = "orderNo"];
string bundleName = 17 [json_name = "bundleName"];
string contractNo = 18 [json_name = "contractNo"];
bool isHaveValueAdd = 19 [json_name = "isHaveValueAdd"]; //
bool isValueAddCustom= 20 [json_name = "isValueAddCustom"]; //
string valueAddBundleUuid= 21 [json_name= "valueAddBundleUuid"]; //UUID
int64 ValueAddBundleNum= 22 [json_name= "ValueAddBundleNum"]; //
float OriginalPrice= 23 [json_name= "OriginalPrice"]; //
float DiscountPrice= 24 [json_name= "DiscountPrice"]; //
float ValueAddBundleAmount= 25 [json_name= "ValueAddBundleAmount"]; //
float SavedAmount= 26 [json_name= "SavedAmount"]; //
float totalAmount = 27 [json_name = "totalAmount"]; //
float valueAddBundleAmount = 27 [json_name = "valueAddBundleAmount"]; //
float totalAmount = 28 [json_name = "totalAmount"]; //
}
message OrderRecordsRequest {
@ -142,43 +135,42 @@ message OrderRecordsDetailResponse {
//
message ValueAddBundleProfile {
string uuid = 1 [json_name = "uuid"];
string name = 2 [json_name = "name"];
int64 num = 3 [json_name = "num"];
float originalPrice = 4 [json_name = "originalPrice"];
float discountPrice = 5 [json_name = "discountPrice"];
int32 num = 2 [json_name = "num"];
float originalPrice = 3 [json_name = "originalPrice"];
float discountPrice = 4 [json_name = "discountPrice"];
float totalPrice = 6 [json_name = "totalPrice"];
float savedAmount = 7 [json_name = "savedAmount"];
string language = 11 [json_name = "language"];
string createdAt = 12 [json_name = "createdAt"];
string updatedAt = 13 [json_name = "updatedAt"];
bool discountPriceStatus = 8 [json_name = "discountPriceStatus"];
bool choose = 9 [json_name = "choose"];
}
message CreateValueAddBundleRequest {
int32 num = 1 [json_name = "num",(validator.field) = {int_gt: 30, int_lt:100, human_error: "至少数为30,最多数为100"}];
}
message DelValueAddBundleRequest {
message CreateValueAddBundleResponse {
string uuid = 1 [json_name = "uuid"];
float totalPrice = 2 [json_name = "totalPrice"];
float savedAmount = 3 [json_name = "savedAmount"];
string msg = 4 [json_name = "msg"];
}
//
message ValueAddBundleListRequest {
int32 page = 1 [json_name = "page"];
int32 pageSize = 2 [json_name = "pageSize"];
string name = 3 [json_name = "name"];
int64 num = 4 [json_name = "num"];
float originalPrice = 5 [json_name = "originalPrice"];
float discountPrice = 6 [json_name = "discountPrice"];
float totalPrice = 7 [json_name = "totalPrice"];
float savedAmount = 8 [json_name = "savedAmount"];
string language = 9 [json_name = "language"];
}
}
message ValueAddBundleListResponse {
repeated ValueAddBundleProfile bundles = 1 [json_name = "bundles"];
float originalPrice = 1 [json_name = "originalPrice"];
int32 total = 2 [json_name = "total"];
repeated ValueAddBundleProfile data = 3 [json_name = "data"];
string msg = 4 [json_name = "msg"];
}
message ValueAddBundleDetailRequest {
string uuid = 1 [json_name = "uuid"];
}
message ValueAddBundleDetailResponse {
ValueAddBundleProfile bundle = 1 [json_name = "bundle"];
ValueAddBundleProfile data = 1 [json_name = "data"];
string msg = 2 [json_name = "msg"];
}

View File

@ -7,6 +7,8 @@ import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/protobuf/types/descriptorpb"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
)
@ -78,17 +80,26 @@ func (this *OrderRecordsDetailResponse) Validate() error {
func (this *ValueAddBundleProfile) Validate() error {
return nil
}
func (this *DelValueAddBundleRequest) Validate() error {
func (this *CreateValueAddBundleRequest) Validate() error {
if !(this.Num > 30) {
return github_com_mwitkow_go_proto_validators.FieldError("Num", fmt.Errorf(`至少数为30,最多数为100`))
}
if !(this.Num < 100) {
return github_com_mwitkow_go_proto_validators.FieldError("Num", fmt.Errorf(`至少数为30,最多数为100`))
}
return nil
}
func (this *CreateValueAddBundleResponse) Validate() error {
return nil
}
func (this *ValueAddBundleListRequest) Validate() error {
return nil
}
func (this *ValueAddBundleListResponse) Validate() error {
for _, item := range this.Bundles {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Bundles", err)
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
@ -98,9 +109,9 @@ func (this *ValueAddBundleDetailRequest) Validate() error {
return nil
}
func (this *ValueAddBundleDetailResponse) Validate() error {
if this.Bundle != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Bundle); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Bundle", err)
if this.Data != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
return nil

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v5.29.2
// - protoc-gen-go-triple v1.0.5
// - protoc v3.21.8
// source: pb/bundle.proto
package bundle
@ -38,13 +38,10 @@ type BundleClient interface {
UpdateOrderRecordByOrderNo(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
OrderRecordsList(ctx context.Context, in *OrderRecordsRequest, opts ...grpc_go.CallOption) (*OrderRecordsResponse, common.ErrorWithAttachment)
OrderRecordsDetail(ctx context.Context, in *OrderRecordsDetailRequest, opts ...grpc_go.CallOption) (*OrderRecordsDetailResponse, common.ErrorWithAttachment)
//增值套餐
CreateValueAddBundle(ctx context.Context, in *ValueAddBundleProfile, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
UpdateValueAddBundle(ctx context.Context, in *ValueAddBundleProfile, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
DeleteValueAddBundle(ctx context.Context, in *DelValueAddBundleRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
// 增值套餐
CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment)
ValueAddBundleList(ctx context.Context, in *ValueAddBundleListRequest, opts ...grpc_go.CallOption) (*ValueAddBundleListResponse, common.ErrorWithAttachment)
ValueAddBundleDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment)
ValueAddBundleRecordDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment)
}
type bundleClient struct {
@ -62,12 +59,9 @@ type BundleClientImpl struct {
UpdateOrderRecordByOrderNo func(ctx context.Context, in *OrderRecord) (*CommonResponse, error)
OrderRecordsList func(ctx context.Context, in *OrderRecordsRequest) (*OrderRecordsResponse, error)
OrderRecordsDetail func(ctx context.Context, in *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error)
CreateValueAddBundle func(ctx context.Context, in *ValueAddBundleProfile) (*CommonResponse, error)
UpdateValueAddBundle func(ctx context.Context, in *ValueAddBundleProfile) (*CommonResponse, error)
DeleteValueAddBundle func(ctx context.Context, in *DelValueAddBundleRequest) (*CommonResponse, error)
CreateValueAddBundle func(ctx context.Context, in *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error)
ValueAddBundleList func(ctx context.Context, in *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
ValueAddBundleDetail func(ctx context.Context, in *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
ValueAddBundleRecordDetail func(ctx context.Context, in *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
}
func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient {
@ -142,24 +136,12 @@ func (c *bundleClient) OrderRecordsDetail(ctx context.Context, in *OrderRecordsD
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/OrderRecordsDetail", in, out)
}
func (c *bundleClient) CreateValueAddBundle(ctx context.Context, in *ValueAddBundleProfile, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) {
out := new(CommonResponse)
func (c *bundleClient) CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment) {
out := new(CreateValueAddBundleResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateValueAddBundle", in, out)
}
func (c *bundleClient) UpdateValueAddBundle(ctx context.Context, in *ValueAddBundleProfile, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) {
out := new(CommonResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateValueAddBundle", in, out)
}
func (c *bundleClient) DeleteValueAddBundle(ctx context.Context, in *DelValueAddBundleRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) {
out := new(CommonResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DeleteValueAddBundle", in, out)
}
func (c *bundleClient) ValueAddBundleList(ctx context.Context, in *ValueAddBundleListRequest, opts ...grpc_go.CallOption) (*ValueAddBundleListResponse, common.ErrorWithAttachment) {
out := new(ValueAddBundleListResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -172,12 +154,6 @@ func (c *bundleClient) ValueAddBundleDetail(ctx context.Context, in *ValueAddBun
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ValueAddBundleDetail", in, out)
}
func (c *bundleClient) ValueAddBundleRecordDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment) {
out := new(ValueAddBundleDetailResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ValueAddBundleRecordDetail", in, out)
}
// BundleServer is the server API for Bundle service.
// All implementations must embed UnimplementedBundleServer
// for forward compatibility
@ -192,13 +168,10 @@ type BundleServer interface {
UpdateOrderRecordByOrderNo(context.Context, *OrderRecord) (*CommonResponse, error)
OrderRecordsList(context.Context, *OrderRecordsRequest) (*OrderRecordsResponse, error)
OrderRecordsDetail(context.Context, *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error)
//增值套餐
CreateValueAddBundle(context.Context, *ValueAddBundleProfile) (*CommonResponse, error)
UpdateValueAddBundle(context.Context, *ValueAddBundleProfile) (*CommonResponse, error)
DeleteValueAddBundle(context.Context, *DelValueAddBundleRequest) (*CommonResponse, error)
// 增值套餐
CreateValueAddBundle(context.Context, *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error)
ValueAddBundleList(context.Context, *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
ValueAddBundleRecordDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
mustEmbedUnimplementedBundleServer()
}
@ -237,24 +210,15 @@ func (UnimplementedBundleServer) OrderRecordsList(context.Context, *OrderRecords
func (UnimplementedBundleServer) OrderRecordsDetail(context.Context, *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method OrderRecordsDetail not implemented")
}
func (UnimplementedBundleServer) CreateValueAddBundle(context.Context, *ValueAddBundleProfile) (*CommonResponse, error) {
func (UnimplementedBundleServer) CreateValueAddBundle(context.Context, *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateValueAddBundle not implemented")
}
func (UnimplementedBundleServer) UpdateValueAddBundle(context.Context, *ValueAddBundleProfile) (*CommonResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateValueAddBundle not implemented")
}
func (UnimplementedBundleServer) DeleteValueAddBundle(context.Context, *DelValueAddBundleRequest) (*CommonResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteValueAddBundle not implemented")
}
func (UnimplementedBundleServer) ValueAddBundleList(context.Context, *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ValueAddBundleList not implemented")
}
func (UnimplementedBundleServer) ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ValueAddBundleDetail not implemented")
}
func (UnimplementedBundleServer) ValueAddBundleRecordDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ValueAddBundleRecordDetail not implemented")
}
func (s *UnimplementedBundleServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
@ -574,7 +538,7 @@ func _Bundle_OrderRecordsDetail_Handler(srv interface{}, ctx context.Context, de
}
func _Bundle_CreateValueAddBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ValueAddBundleProfile)
in := new(CreateValueAddBundleRequest)
if err := dec(in); err != nil {
return nil, err
}
@ -602,64 +566,6 @@ func _Bundle_CreateValueAddBundle_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _Bundle_UpdateValueAddBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ValueAddBundleProfile)
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("UpdateValueAddBundle", 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_DeleteValueAddBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(DelValueAddBundleRequest)
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("DeleteValueAddBundle", 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_ValueAddBundleList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ValueAddBundleListRequest)
if err := dec(in); err != nil {
@ -718,35 +624,6 @@ func _Bundle_ValueAddBundleDetail_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _Bundle_ValueAddBundleRecordDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ValueAddBundleDetailRequest)
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("ValueAddBundleRecordDetail", 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)
@ -798,14 +675,6 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "CreateValueAddBundle",
Handler: _Bundle_CreateValueAddBundle_Handler,
},
{
MethodName: "UpdateValueAddBundle",
Handler: _Bundle_UpdateValueAddBundle_Handler,
},
{
MethodName: "DeleteValueAddBundle",
Handler: _Bundle_DeleteValueAddBundle_Handler,
},
{
MethodName: "ValueAddBundleList",
Handler: _Bundle_ValueAddBundleList_Handler,
@ -814,10 +683,6 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "ValueAddBundleDetail",
Handler: _Bundle_ValueAddBundleDetail_Handler,
},
{
MethodName: "ValueAddBundleRecordDetail",
Handler: _Bundle_ValueAddBundleRecordDetail_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "pb/bundle.proto",

Binary file not shown.

Binary file not shown.

View File

@ -20,7 +20,6 @@ func BundleOrderRouter(r *gin.RouterGroup) {
bundleOrderClientRoute := bundleOrderRoute.Group("common")
{
bundleOrderClientRoute.POST("bundle-order-list", bundle.OrderRecordsList)
bundleOrderClientRoute.POST("valueAdd-bundle-record-detail", bundle.ValueAddBundleRecordDetail)
}
bundleOrderAppRoute := bundleOrderRoute.Group("app")

View File

@ -13,18 +13,9 @@ func ValueAddBundleRouter(r *gin.RouterGroup) {
{
bundleClientRoute := valueAddBundleRoute.Group("system")
{
bundleClientRoute.POST("create", bundle.CreateBundle)
bundleClientRoute.POST("update", bundle.UpdateBundle)
bundleClientRoute.POST("remove", bundle.DeleteBundle)
}
bundleAppRoute := valueAddBundleRoute.Group("common")
{
bundleAppRoute.POST("valueAdd-bundle-list", bundle.BundleList)
}
bundleCalcRoute := valueAddBundleRoute.Group("calc")
{
bundleCalcRoute.POST("price", bundle.CalculateBundlePrice)
bundleClientRoute.POST("create", bundle.CreateValueAddBundle)
bundleClientRoute.POST("list", bundle.ValueAddBundleList)
bundleClientRoute.POST("detail", bundle.ValueAddBundleDetail)
}
}

View File

@ -39,6 +39,23 @@ func Success(c *gin.Context, datas ...interface{}) {
c.Abort()
}
func Success1(c *gin.Context, msg string, datas ...interface{}) {
var data interface{}
if datas != nil {
data = datas[0]
} else {
data = struct{}{}
}
c.JSON(http.StatusOK, Response{
Status: Ok,
Code: Ok,
Data: data,
Msg: msg,
})
c.Abort()
}
// Error 统一错误返回
func Error(c *gin.Context, err error) {
@ -57,7 +74,20 @@ func Error(c *gin.Context, err error) {
c.Abort()
}
// 重试
// Error 统一错误返回
func Error1(c *gin.Context, err error) {
c.JSON(http.StatusOK, Response{
Code: Failed,
Status: Failed,
Msg: err.Error(),
Data: struct{}{},
})
c.Abort()
}
// 重试
func Retry(c *gin.Context, err error) {
errMsg := ""
if err != nil {

View File

@ -10,6 +10,7 @@ import (
"fonchain-fiee/pkg/service/bundle/common"
"fonchain-fiee/pkg/service/bundle/logic"
bundleModel "fonchain-fiee/pkg/service/bundle/model"
"math/big"
"strconv"
"github.com/gin-gonic/gin"
@ -90,7 +91,6 @@ func CreateBundleOrderSignature(c *gin.Context) {
//获取增值套餐信息
if req.ValueAddBundleUuid != "" {
req.IsHaveValueAdd = true
valueAddBundleDetail, err := service.BundleProvider.ValueAddBundleDetail(context.Background(), &bundle.ValueAddBundleDetailRequest{
Uuid: req.ValueAddBundleUuid,
})
@ -98,21 +98,10 @@ func CreateBundleOrderSignature(c *gin.Context) {
service.Error(c, err)
return
}
//如果是增值套餐条数大于等于30 则手动计算价格
if req.IsValueAddCustom {
if req.ValueAddBundleNum < 30 || req.ValueAddBundleNum > 100 {
service.Error(c, errors.New(common.InvalidValueAddBundleNum))
return
}
valueAddBundleDetail.Bundle.TotalPrice = valueAddBundleDetail.Bundle.DiscountPrice * float32(req.ValueAddBundleNum)
req.SavedAmount = (valueAddBundleDetail.Bundle.OriginalPrice - valueAddBundleDetail.Bundle.DiscountPrice) * float32(req.ValueAddBundleNum)
} else {
req.ValueAddBundleNum = int64(valueAddBundleDetail.Bundle.Num)
req.SavedAmount = valueAddBundleDetail.Bundle.SavedAmount
}
req.OriginalPrice = valueAddBundleDetail.Bundle.OriginalPrice
req.DiscountPrice = valueAddBundleDetail.Bundle.DiscountPrice
req.ValueAddBundleAmount = valueAddBundleDetail.Bundle.TotalPrice
req.ValueAddBundleUuid = valueAddBundleDetail.Data.Uuid
req.ValueAddBundleAmount = valueAddBundleDetail.Data.TotalPrice
req.TotalAmount, _ = new(big.Float).Add(big.NewFloat(float64(req.ValueAddBundleAmount)), big.NewFloat(float64(bundleDetail.Bundle.Price))).Float32()
}
req.BundleName = bundleDetail.Bundle.Name
@ -268,32 +257,3 @@ func OrderRecordsDetail(c *gin.Context) {
service.Success(c, res)
}
func CalculateBundlePrice(c *gin.Context) {
var req bundle.ValueAddBundleProfile
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
detail, err := service.BundleProvider.ValueAddBundleDetail(context.Background(), &bundle.ValueAddBundleDetailRequest{
Uuid: req.Uuid,
})
if err != nil {
service.Error(c, err)
return
}
price := detail.Bundle.DiscountPrice * float32(req.Num)
service.Success(c, price)
}
func ValueAddBundleRecordDetail(c *gin.Context) {
var req bundle.ValueAddBundleDetailRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
detail, err := service.BundleProvider.ValueAddBundleRecordDetail(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, detail)
}

View File

@ -2,6 +2,7 @@ package bundle
import (
"context"
"fmt"
"fonchain-fiee/api/bundle"
"fonchain-fiee/pkg/service"
@ -10,70 +11,53 @@ import (
)
func CreateValueAddBundle(c *gin.Context) {
var req bundle.ValueAddBundleProfile
var req bundle.CreateValueAddBundleRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
service.Error1(c, err)
return
}
res, err := service.BundleProvider.CreateValueAddBundle(context.Background(), &req)
if err != nil {
service.Error(c, err)
fmt.Println(err)
service.Error1(c, err)
return
}
service.Success(c, res)
}
func UpdateValueAddBundle(c *gin.Context) {
var req bundle.ValueAddBundleProfile
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
res, err := service.BundleProvider.UpdateValueAddBundle(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
}
func DeleteValueAddBundle(c *gin.Context) {
var req bundle.DelValueAddBundleRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
res, err := service.BundleProvider.DeleteValueAddBundle(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
service.Success1(c, res.Msg, res)
}
func ValueAddBundleList(c *gin.Context) {
var req bundle.ValueAddBundleListRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
service.Error1(c, err)
return
}
res, err := service.BundleProvider.ValueAddBundleList(context.Background(), &req)
if err != nil {
service.Error(c, err)
service.Error1(c, err)
return
}
service.Success(c, res)
service.Success1(c, res.Msg, res)
}
func ValueAddBundleDetail(c *gin.Context) {
var req bundle.ValueAddBundleDetailRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error1(c, err)
return
}
res, err := service.BundleProvider.ValueAddBundleDetail(context.Background(), &req)
if err != nil {
service.Error1(c, err)
return
}
service.Success1(c, res.Msg, res)
}