增加增值套餐服务

This commit is contained in:
孙肖扬 2025-03-25 16:30:09 +08:00
parent 795d9e9005
commit e01d5dcb0f
13 changed files with 1580 additions and 421 deletions

View File

@ -51,3 +51,27 @@ func (b *BundleProvider) OrderRecordsList(_ context.Context, req *bundle.OrderRe
func (b *BundleProvider) OrderRecordsDetail(_ context.Context, req *bundle.OrderRecordsDetailRequest) (res *bundle.OrderRecordsDetailResponse, err error) {
return logic.OrderRecordsDetail(req)
}
// 增值套餐相关
func (b *BundleProvider) CreateValueAddBundle(_ context.Context, req *bundle.ValueAddBundleProfile) (res *bundle.CommonResponse, err error) {
return logic.CreateValueAddBundle(req)
}
func (b *BundleProvider) UpdateValueAddBundle(_ context.Context, req *bundle.ValueAddBundleProfile) (res *bundle.CommonResponse, err error) {
return logic.UpdateValueAddBundle(req)
}
func (b *BundleProvider) DeleteValueAddBundle(_ context.Context, req *bundle.DelValueAddBundleRequest) (res *bundle.CommonResponse, err error) {
return logic.DeleteValueAddBundle(req)
}
func (b *BundleProvider) ValueAddBundleList(_ context.Context, req *bundle.ValueAddBundleListRequest) (res *bundle.ValueAddBundleListResponse, err error) {
return logic.ValueAddBundleList(req)
}
func (b *BundleProvider) ValueAddBundleDetail(_ context.Context, req *bundle.ValueAddBundleDetailRequest) (res *bundle.ValueAddBundleDetailResponse, err error) {
return logic.ValueAddBundleDetail(req)
}
func ValueAddBundleRecordDetail(req *bundle.ValueAddBundleDetailRequest) (res *bundle.ValueAddBundleDetailResponse, err error) {
return logic.ValueAddBundleRecordDetail(req)
}

View File

@ -9,15 +9,39 @@ import (
"micro-bundle/pkg/utils"
)
func CreateOrderRecord(orderRecord *model.BundleOrderRecords) (res *bundle.CommonResponse, err error) {
func CreateOrderRecord(orderRecord *model.BundleOrderRecords, valueAddRecord *model.ValueAddBundleRecord) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
orderRecord.UUID = app.ModuleClients.SfNode.Generate().Base64()
orderRecord.OrderNo = utils.GetOrderNo()
err = app.ModuleClients.BundleDB.Model(&model.BundleOrderRecords{}).Create(&orderRecord).Error
if err != nil {
// 开启事务
tx := app.ModuleClients.BundleDB.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()
// 创建主订单
if err = tx.Model(&model.BundleOrderRecords{}).Create(&orderRecord).Error; err != nil {
tx.Rollback()
res.Msg = msg.ErrorCreateOrderInfo
return res, commonErr.ReturnError(err, msg.ErrorCreateOrderInfo, "创建订单信息失败: ")
}
// 创建增值套餐订单
if err = tx.Model(&model.ValueAddBundleRecord{}).Create(&valueAddRecord).Error; err != nil {
tx.Rollback()
res.Msg = msg.ErrorCreateValueAddBundleInfo
return res, commonErr.ReturnError(err, msg.ErrorCreateValueAddBundleInfo, "创建增值套餐订单信息失败: ")
}
// 提交事务
if err = tx.Commit().Error; err != nil {
res.Msg = msg.ErrorCommitTransaction
return res, commonErr.ReturnError(err, msg.ErrorCommitTransaction, "提交事务失败: ")
}
res.Uuid = orderRecord.UUID
res.OrderNo = orderRecord.OrderNo
res.Msg = msg.SuccessCreateOrderInfo
@ -99,6 +123,11 @@ func OrderRecordsList(req *bundle.OrderRecordsRequest) (res *bundle.OrderRecords
query = query.Where("pay_time <= ?", req.EndPayTime)
}
if req.IsHaveValueAdd == "有" {
query = query.Where("is_have_value_add=1")
} else {
query = query.Where("is_have_value_add=0")
}
count := *query
if req.PageSize != 0 && req.Page != 0 {
@ -114,24 +143,27 @@ func OrderRecordsList(req *bundle.OrderRecordsRequest) (res *bundle.OrderRecords
for _, record := range records {
res.OrderRecords = append(res.OrderRecords, &bundle.OrderRecord{
Uuid: record.UUID,
OrderNo: record.OrderNo,
BundleUuid: record.BundleUUID,
BundleName: record.BundleName,
CustomerID: record.CustomerID,
CustomerNum: record.CustomerNum,
CustomerName: record.CustomerName,
Amount: record.Amount,
AmountType: record.AmountType,
SignContract: record.SignContract,
Signature: record.Signature,
SignedTime: record.SignedTime,
PayType: record.PayType,
PayTime: record.PayTime,
CheckoutSessionId: record.CheckoutSessionId,
CheckoutSessionUrl: record.CheckoutSessionUrl,
Status: record.Status,
ContractNo: record.ContractNo,
Uuid: record.UUID,
OrderNo: record.OrderNo,
BundleUuid: record.BundleUUID,
BundleName: record.BundleName,
CustomerID: record.CustomerID,
CustomerNum: record.CustomerNum,
CustomerName: record.CustomerName,
Amount: record.Amount,
AmountType: record.AmountType,
SignContract: record.SignContract,
Signature: record.Signature,
SignedTime: record.SignedTime,
PayType: record.PayType,
PayTime: record.PayTime,
CheckoutSessionId: record.CheckoutSessionId,
CheckoutSessionUrl: record.CheckoutSessionUrl,
Status: record.Status,
ContractNo: record.ContractNo,
ValueAddBundleUuid: record.ValueAddBundleRecordUUID,
ValueAddBundleAmount: record.ValueAddBundleAmount,
TotalAmount: record.TotalAmount,
})
}
@ -169,24 +201,47 @@ func OrderRecordDetail(req *bundle.OrderRecordsDetailRequest) (res *bundle.Order
//_ = copier.CopyWithOption(&res, orderRecord, copier.Option{DeepCopy: true})
res = &bundle.OrderRecord{
Uuid: orderRecord.UUID,
OrderNo: orderRecord.OrderNo,
BundleUuid: orderRecord.BundleUUID,
BundleName: orderRecord.BundleName,
CustomerID: orderRecord.CustomerID,
CustomerNum: orderRecord.CustomerNum,
CustomerName: orderRecord.CustomerName,
Amount: orderRecord.Amount,
AmountType: orderRecord.AmountType,
SignContract: orderRecord.SignContract,
Signature: orderRecord.Signature,
SignedTime: orderRecord.SignedTime,
PayType: orderRecord.PayType,
PayTime: orderRecord.PayTime,
CheckoutSessionId: orderRecord.CheckoutSessionId,
CheckoutSessionUrl: orderRecord.CheckoutSessionUrl,
Status: orderRecord.Status,
ContractNo: orderRecord.ContractNo,
Uuid: orderRecord.UUID,
OrderNo: orderRecord.OrderNo,
BundleUuid: orderRecord.BundleUUID,
BundleName: orderRecord.BundleName,
CustomerID: orderRecord.CustomerID,
CustomerNum: orderRecord.CustomerNum,
CustomerName: orderRecord.CustomerName,
Amount: orderRecord.Amount,
AmountType: orderRecord.AmountType,
SignContract: orderRecord.SignContract,
Signature: orderRecord.Signature,
SignedTime: orderRecord.SignedTime,
PayType: orderRecord.PayType,
PayTime: orderRecord.PayTime,
CheckoutSessionId: orderRecord.CheckoutSessionId,
CheckoutSessionUrl: orderRecord.CheckoutSessionUrl,
Status: orderRecord.Status,
ContractNo: orderRecord.ContractNo,
ValueAddBundleAmount: orderRecord.ValueAddBundleAmount,
TotalAmount: orderRecord.TotalAmount,
}
return
}
func ValueAddBundleRecordDetail(req *bundle.ValueAddBundleDetailRequest) (res *bundle.ValueAddBundleDetailResponse, err error) {
res = new(bundle.ValueAddBundleDetailResponse)
record := new(model.ValueAddBundleProfile)
err = app.ModuleClients.BundleDB.Where("uuid = ?", req.Uuid).First(&record).Error
if err != nil {
return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取套餐信息失败: ")
}
bundle := &bundle.ValueAddBundleProfile{
Uuid: record.UUID,
Name: record.Name,
OriginalPrice: record.OriginalPrice,
DiscountPrice: record.DiscountPrice,
TotalPrice: record.TotalPrice,
SavedAmount: record.SavedAmount,
Language: record.Language,
CreatedAt: record.CreatedAt.String(),
UpdatedAt: record.UpdatedAt.String(),
}
res.Bundle = bundle
return
}

View File

@ -0,0 +1,111 @@
package dao
import (
"micro-bundle/internal/model"
"micro-bundle/pb/bundle"
"micro-bundle/pkg/app"
commonErr "micro-bundle/pkg/err"
"micro-bundle/pkg/msg"
)
// 增值套餐创建
func CreateValueAddBundle(req *model.ValueAddBundleProfile) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
err = app.ModuleClients.BundleDB.Model(&model.ValueAddBundleProfile{}).Create(&req).Error
if err != nil {
res.Msg = msg.ErrorCreateValueAddBundleInfo
return res, commonErr.ReturnError(err, msg.ErrorCreateValueAddBundleInfo, "创建增值套餐信息失败: ")
}
res.Msg = msg.SuccessCreateValueAddBundleInfo
return
}
// 增值套餐更新
func UpdateValueAddBundle(req *model.ValueAddBundleProfile) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
err = app.ModuleClients.BundleDB.Model(&model.ValueAddBundleProfile{}).Where("uuid = ?", req.UUID).Updates(req).Error
if err != nil {
res.Msg = msg.ErrorUpdateValueAddBundleInfo
return res, commonErr.ReturnError(err, msg.ErrorUpdateValueAddBundleInfo, "更新套餐信息失败: ")
}
res.Msg = msg.SuccessUpdateValueAddBundleInfo
return
}
// 增值套餐删除
func DeleteValueAddBundle(req *bundle.DelValueAddBundleRequest) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
err = app.ModuleClients.BundleDB.Model(&model.ValueAddBundleProfile{}).Where("uuid = ?", req.Uuid).Delete(&model.ValueAddBundleProfile{}).Error
if err != nil {
res.Msg = msg.ErrorDeleteValueAddBundleInfo
return res, commonErr.ReturnError(err, msg.ErrorDeleteValueAddBundleInfo, "删除增值套餐信息失败: ")
}
res.Msg = msg.SuccessDeleteValueAddBundleInfo
return
}
// 增值套餐列表
func ValueAddBundleList(req *bundle.ValueAddBundleListRequest) (res *bundle.ValueAddBundleListResponse, err error) {
res = new(bundle.ValueAddBundleListResponse)
res.Bundles = make([]*bundle.ValueAddBundleProfile, 0)
bundles := make([]*model.ValueAddBundleProfile, 0)
query := app.ModuleClients.BundleDB.Model(&model.ValueAddBundleProfile{})
if req.Name != "" {
query = query.Where("name like ?", "%"+req.Name+"%")
}
if req.Language != "" {
query = query.Where("language like ?", req.Language)
}
count := *query
if req.PageSize != 0 && req.Page != 0 {
query = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize))
}
if err = query.Find(&bundles).Error; err != nil {
return res, commonErr.ReturnError(err, msg.ErrorGetBundleList, "获取套餐列表失败: ")
}
for _, valueAddBundleProfile := range bundles {
res.Bundles = append(res.Bundles, &bundle.ValueAddBundleProfile{
Uuid: valueAddBundleProfile.UUID,
Name: valueAddBundleProfile.Name,
OriginalPrice: valueAddBundleProfile.OriginalPrice,
DiscountPrice: valueAddBundleProfile.DiscountPrice,
TotalPrice: valueAddBundleProfile.TotalPrice,
SavedAmount: valueAddBundleProfile.SavedAmount,
Language: valueAddBundleProfile.Language,
CreatedAt: valueAddBundleProfile.CreatedAt.String(),
UpdatedAt: valueAddBundleProfile.UpdatedAt.String(),
})
}
var total int64
count.Count(&total)
res.Total = int32(total)
return
}
// 增值套餐详情
func ValueAddBundleDetail(uuid string) (res *bundle.ValueAddBundleProfile, err error) {
res = new(bundle.ValueAddBundleProfile)
valueAddBundleProfile := new(model.ValueAddBundleProfile)
err = app.ModuleClients.BundleDB.Where("uuid = ?", uuid).First(&valueAddBundleProfile).Error
if err != nil {
return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取套餐信息失败: ")
}
res = &bundle.ValueAddBundleProfile{
Uuid: valueAddBundleProfile.UUID,
Name: valueAddBundleProfile.Name,
OriginalPrice: valueAddBundleProfile.OriginalPrice,
DiscountPrice: valueAddBundleProfile.DiscountPrice,
TotalPrice: valueAddBundleProfile.TotalPrice,
SavedAmount: valueAddBundleProfile.SavedAmount,
Language: valueAddBundleProfile.Language,
CreatedAt: valueAddBundleProfile.CreatedAt.String(),
UpdatedAt: valueAddBundleProfile.UpdatedAt.String(),
}
return
}

View File

@ -2,12 +2,13 @@ package logic
import (
"fmt"
"github.com/jinzhu/copier"
"micro-bundle/internal/dao"
"micro-bundle/internal/model"
"micro-bundle/pb/bundle"
"micro-bundle/pkg/app"
"micro-bundle/pkg/utils"
"github.com/jinzhu/copier"
)
func CreateOrderRecord(req *bundle.OrderRecord) (res *bundle.CommonResponse, err error) {
@ -17,8 +18,17 @@ func CreateOrderRecord(req *bundle.OrderRecord) (res *bundle.CommonResponse, err
orderRecord.UUID = app.ModuleClients.SfNode.Generate().Base64()
orderRecord.OrderNo = utils.GetOrderNo()
orderRecord.BundleUUID = req.BundleUuid
orderRecord.ValueAddBundleRecordUUID = app.ModuleClients.SfNode.Generate().Base64()
fmt.Printf("orderRecord %+v\n", orderRecord)
res, err = dao.CreateOrderRecord(orderRecord)
valueAddRecord := &model.ValueAddBundleRecord{
UUID: orderRecord.ValueAddBundleRecordUUID,
OriginalPrice: req.OriginalPrice,
DiscountPrice: req.DiscountPrice,
TotalPrice: req.ValueAddBundleAmount,
ValueAddBundleNum: int(req.ValueAddBundleNum),
SavedAmount: req.SavedAmount,
}
res, err = dao.CreateOrderRecord(orderRecord, valueAddRecord)
return
}
@ -28,6 +38,7 @@ func UpdateOrderRecord(req *bundle.OrderRecord) (res *bundle.CommonResponse, err
_ = copier.CopyWithOption(&orderRecord, req, copier.Option{DeepCopy: true})
orderRecord.UUID = req.Uuid
orderRecord.BundleUUID = req.BundleUuid
orderRecord.ValueAddBundleRecordUUID = req.ValueAddBundleUuid
res, err = dao.UpdateOrderRecord(orderRecord)
return
}
@ -57,3 +68,11 @@ func OrderRecordsDetail(req *bundle.OrderRecordsDetailRequest) (res *bundle.Orde
}
return
}
func ValueAddBundleRecordDetail(req *bundle.ValueAddBundleDetailRequest) (res *bundle.ValueAddBundleDetailResponse, err error) {
res = new(bundle.ValueAddBundleDetailResponse)
res, err = dao.ValueAddBundleRecordDetail(req)
if err != nil {
res.Msg = err.Error()
}
return
}

View File

@ -0,0 +1,54 @@
package logic
import (
"micro-bundle/internal/dao"
"micro-bundle/internal/model"
"micro-bundle/pb/bundle"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"github.com/jinzhu/copier"
)
// 增值套餐创建
func CreateValueAddBundle(req *bundle.ValueAddBundleProfile) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
valueAddBundleProfile := new(model.ValueAddBundleProfile)
_ = copier.CopyWithOption(&valueAddBundleProfile, req, copier.Option{DeepCopy: true})
valueAddBundleProfile.UUID = utils.GetUUID()
res, err = dao.CreateValueAddBundle(valueAddBundleProfile)
return
}
// 增值套餐更新
func UpdateValueAddBundle(req *bundle.ValueAddBundleProfile) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
valueAddBundleProfile := new(model.ValueAddBundleProfile)
_ = copier.CopyWithOption(&valueAddBundleProfile, req, copier.Option{DeepCopy: true})
res, err = dao.UpdateValueAddBundle(valueAddBundleProfile)
return
}
// 增值套餐删除
func DeleteValueAddBundle(req *bundle.DelValueAddBundleRequest) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
res, err = dao.DeleteValueAddBundle(req)
return
}
// 增值套餐列表
func ValueAddBundleList(req *bundle.ValueAddBundleListRequest) (res *bundle.ValueAddBundleListResponse, err error) {
res = new(bundle.ValueAddBundleListResponse)
res, err = dao.ValueAddBundleList(req)
return
}
// 增值套餐详情
func ValueAddBundleDetail(req *bundle.ValueAddBundleDetailRequest) (res *bundle.ValueAddBundleDetailResponse, err error) {
res = new(bundle.ValueAddBundleDetailResponse)
res.Bundle = new(bundle.ValueAddBundleProfile)
res.Bundle, err = dao.ValueAddBundleDetail(req.Uuid)
if err != nil {
res.Msg = err.Error()
}
return
}

View File

@ -5,14 +5,19 @@ import "gorm.io/gorm"
// BundleOrderRecords struct
type BundleOrderRecords struct {
gorm.Model
UUID string `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:UUID"`
OrderNo string `json:"orderNo" gorm:"column:order_no;type:varchar(1024);comment:交易编号"`
BundleUUID string `json:"bundleUUID" gorm:"column:bundle_uuid;type:varchar(1024);comment:套餐UUID"`
BundleName string `json:"bundleName" gorm:"column:bundle_name;type:varchar(2048);comment:套餐名"`
CustomerID string `json:"customerID" gorm:"column:customer_id;type:varchar(1024);comment:客户ID"`
CustomerNum string `json:"customerNum" gorm:"column:customer_num;type:varchar(1024);comment:客户编号"`
CustomerName string `json:"customerName" gorm:"column:customer_name;type:varchar(1024);comment:客户名"`
Amount float32 `json:"amount" gorm:"column:amount;type:decimal(12,2);comment:金额"`
UUID string `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:UUID"`
OrderNo string `json:"orderNo" gorm:"column:order_no;type:varchar(1024);comment:交易编号"`
BundleUUID string `json:"bundleUUID" gorm:"column:bundle_uuid;type:varchar(1024);comment:套餐UUID"`
BundleName string `json:"bundleName" gorm:"column:bundle_name;type:varchar(2048);comment:套餐名"`
CustomerID string `json:"customerID" gorm:"column:customer_id;type:varchar(1024);comment:客户ID"`
CustomerNum string `json:"customerNum" gorm:"column:customer_num;type:varchar(1024);comment:客户编号"`
CustomerName string `json:"customerName" gorm:"column:customer_name;type:varchar(1024);comment:客户名"`
Amount float32 `json:"amount" gorm:"column:amount;type:decimal(12,2);comment:套餐金额"`
ValueAddBundleRecordUUID string `json:"valueAddBundleRecordUUID" gorm:"column:value_add_bundle_record_uuid;type:varchar(1024);comment:增值套餐记录UUID"`
ValueAddBundleAmount float32 `json:"valueAddBundleAmount" gorm:"column:value_add_bundle_amount;type:decimal(12,2);comment:增值套餐金额"`
TotalAmount float32 `json:"totalAmount" gorm:"column:total_amount;type:decimal(12,2);comment:总金额"`
AmountType int64 `json:"amountType" gorm:"column:amount_type;type:int;comment:金额类型"`
SignContract string `json:"signContract" gorm:"column:sign_contract;type:varchar(1024);comment:签约合同"`
Signature string `json:"signature" gorm:"column:signature;type:text;comment:签字"`
@ -23,4 +28,5 @@ type BundleOrderRecords struct {
CheckoutSessionUrl string `json:"checkoutSessionUrl" gorm:"column:checkout_session_url;type:varchar(1024);default:null;comment:checkoutSessionUrl"`
Status int64 `json:"status" gorm:"column:status;type:int;comment:状态 1:已签未支付 2:已签已支付"`
ContractNo string `json:"contractNo" gorm:"column:contract_no;type:varchar(1024);comment:合同编号"`
IsHaveValueAdd bool `json:"isHaveValueAdd" gorm:"column:is_have_value_add;type:tinyint(1);comment:是否有增值"` // 是否有增值 0:否 1:是
}

View File

@ -0,0 +1,27 @@
package model
import "gorm.io/gorm"
// 增值套餐
type ValueAddBundleProfile struct {
gorm.Model
UUID string `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:增值套餐UUID"`
Name string `json:"name" gorm:"column:name;type:varchar(2048);comment:套餐名称"`
Num int `json:"num" gorm:"column:num;type:int;comment:套餐数量"`
OriginalPrice float32 `json:"originalPrice" gorm:"column:original_price;type:decimal(12,2);comment:原单价"`
DiscountPrice float32 `json:"discountPrice" gorm:"column:discount_price;type:decimal(12,2);comment:优惠单价"`
TotalPrice float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:套餐总价"`
SavedAmount float32 `json:"savedAmount" gorm:"column:saved_amount;type:decimal(12,2);comment:节省金额"`
// PriceType int64 `json:"priceType" gorm:"column:price_type;type:int;comment:套餐价格类型 1:人民币 2:美元"`
Language string `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN EN"`
}
type ValueAddBundleRecord struct {
gorm.Model
UUID string `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:增值套餐UUID"`
OriginalPrice float32 `json:"originalPrice" gorm:"column:original_price;type:decimal(12,2);comment:原单价"`
ValueAddBundleNum int `json:"valueAddBundleNum" gorm:"column:value_add_bundle_num;type:int;comment:增值套餐数量"`
DiscountPrice float32 `json:"discountPrice" gorm:"column:discount_price;type:decimal(12,2);comment:优惠单价"`
SavedAmount float32 `json:"savedAmount" gorm:"column:saved_amount;type:decimal(12,2);comment:节省金额"`
TotalPrice float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:增值套餐总价"`
}

View File

@ -17,6 +17,14 @@ service Bundle {
rpc OrderRecordsList(OrderRecordsRequest) returns (OrderRecordsResponse) {}
rpc OrderRecordsDetail(OrderRecordsDetailRequest) returns (OrderRecordsDetailResponse) {}
//
rpc CreateValueAddBundle(ValueAddBundleProfile) returns (CommonResponse) {}
rpc UpdateValueAddBundle(ValueAddBundleProfile) returns (CommonResponse) {}
rpc DeleteValueAddBundle(DelValueAddBundleRequest) returns (CommonResponse) {}
rpc ValueAddBundleList(ValueAddBundleListRequest) returns (ValueAddBundleListResponse) {}
rpc ValueAddBundleDetail(ValueAddBundleDetailRequest) returns (ValueAddBundleDetailResponse) {}
rpc ValueAddBundleRecordDetail(ValueAddBundleDetailRequest) returns(ValueAddBundleDetailResponse) {}
}
message CommonResponse {
@ -84,6 +92,16 @@ 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"]; //
}
message OrderRecordsRequest {
@ -100,6 +118,7 @@ message OrderRecordsRequest {
string startPayTime = 11 [json_name = "startPayTime"];
string endPayTime = 12 [json_name = "endPayTime"];
string customerID = 13 [json_name = "customerID"];
string IsHaveValueAdd = 14 [json_name = "IsHaveValueAdd"];//
}
message OrderRecordsResponse {
@ -116,4 +135,50 @@ message OrderRecordsDetailRequest {
message OrderRecordsDetailResponse {
OrderRecord orderRecord = 1 [json_name = "orderRecord"];
string msg = 2 [json_name = "msg"];
}
//
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"];
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"];
}
message DelValueAddBundleRequest {
string uuid = 1 [json_name = "uuid"];
}
//
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"];
int32 total = 2 [json_name = "total"];
}
message ValueAddBundleDetailRequest {
string uuid = 1 [json_name = "uuid"];
}
message ValueAddBundleDetailResponse {
ValueAddBundleProfile bundle = 1 [json_name = "bundle"];
string msg = 2 [json_name = "msg"];
}

File diff suppressed because it is too large Load Diff

View File

@ -75,3 +75,33 @@ func (this *OrderRecordsDetailResponse) Validate() error {
}
return nil
}
func (this *ValueAddBundleProfile) Validate() error {
return nil
}
func (this *DelValueAddBundleRequest) Validate() error {
return nil
}
func (this *ValueAddBundleListRequest) Validate() error {
return nil
}
func (this *ValueAddBundleListResponse) Validate() error {
for _, item := range this.Bundles {
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 nil
}
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)
}
}
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 v3.10.1
// - protoc v5.29.2
// source: pb/bundle.proto
package bundle
@ -38,6 +38,13 @@ 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)
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 {
@ -55,6 +62,12 @@ 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)
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 {
@ -129,6 +142,42 @@ 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)
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)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ValueAddBundleList", in, out)
}
func (c *bundleClient) ValueAddBundleDetail(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+"/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
@ -143,6 +192,13 @@ 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)
ValueAddBundleList(context.Context, *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
ValueAddBundleRecordDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
mustEmbedUnimplementedBundleServer()
}
@ -181,6 +237,24 @@ 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) {
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
}
@ -499,6 +573,180 @@ func _Bundle_OrderRecordsDetail_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler)
}
func _Bundle_CreateValueAddBundle_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("CreateValueAddBundle", 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_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 {
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("ValueAddBundleList", 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_ValueAddBundleDetail_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("ValueAddBundleDetail", 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_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)
@ -546,6 +794,30 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "OrderRecordsDetail",
Handler: _Bundle_OrderRecordsDetail_Handler,
},
{
MethodName: "CreateValueAddBundle",
Handler: _Bundle_CreateValueAddBundle_Handler,
},
{
MethodName: "UpdateValueAddBundle",
Handler: _Bundle_UpdateValueAddBundle_Handler,
},
{
MethodName: "DeleteValueAddBundle",
Handler: _Bundle_DeleteValueAddBundle_Handler,
},
{
MethodName: "ValueAddBundleList",
Handler: _Bundle_ValueAddBundleList_Handler,
},
{
MethodName: "ValueAddBundleDetail",
Handler: _Bundle_ValueAddBundleDetail_Handler,
},
{
MethodName: "ValueAddBundleRecordDetail",
Handler: _Bundle_ValueAddBundleRecordDetail_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "pb/bundle.proto",

View File

@ -40,7 +40,10 @@ func loadMysqlConn(conn string) *gorm.DB {
sqlDB.SetMaxIdleConns(20) //设置连接池,空闲
sqlDB.SetMaxOpenConns(100) //打开
sqlDB.SetConnMaxLifetime(time.Second * 30)
err = db.AutoMigrate(&model.BundleProfile{}, &model.BundleOrderRecords{})
err = db.AutoMigrate(
&model.BundleProfile{},
&model.BundleOrderRecords{},
&model.ValueAddBundleProfile{})
if err != nil {
return nil
}

View File

@ -47,3 +47,25 @@ const (
ErrorGetOrderList = "获取订单列表失败"
)
// 增值套餐信息
const (
ErrorCreateValueAddBundleInfo = "创建增值套餐信息失败"
SuccessCreateValueAddBundleInfo = "创建增值套餐信息成功"
ErrorUpdateValueAddBundleInfo = "更新增值套餐信息失败"
SuccessUpdateValueAddBundleInfo = "更新增值套餐信息成功"
ErrorDeleteValueAddBundleInfo = "删除增值套餐信息失败"
SuccessDeleteValueAddBundleInfo = "删除增值套餐信息成功"
ErrorGetValueAddBundleList = "获取增值套餐列表失败"
ErrorGetValueAddBundleInfo = "获取增值套餐信息失败"
)
// 事务
const (
ErrorTransaction = "事务失败"
ErrorCommitTransaction = "提交事务失败"
)