fusenapi/model/fsordermodel_gen.go
laodaming 6f6da3f481 fix
2023-06-14 14:05:27 +08:00

135 lines
8.1 KiB
Go
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Code generated by goctl. DO NOT EDIT.
package model
import (
"context"
"database/sql"
"fmt"
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
fsOrderFieldNames = builder.RawFieldNames(&FsOrder{})
fsOrderRows = strings.Join(fsOrderFieldNames, ",")
fsOrderRowsExpectAutoSet = strings.Join(stringx.Remove(fsOrderFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
fsOrderRowsWithPlaceHolder = strings.Join(stringx.Remove(fsOrderFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
fsOrderModel interface {
Insert(ctx context.Context, data *FsOrder) (sql.Result, error)
FindOne(ctx context.Context, id int64) (*FsOrder, error)
FindOneBySn(ctx context.Context, sn string) (*FsOrder, error)
Update(ctx context.Context, data *FsOrder) error
Delete(ctx context.Context, id int64) error
}
defaultFsOrderModel struct {
conn sqlx.SqlConn
table string
}
FsOrder struct {
Id int64 `db:"id"`
Sn string `db:"sn"` // 订单编号 FS211224OL2XDKNP
UserId sql.NullInt64 `db:"user_id"` // 用户ID
SellerUserId sql.NullInt64 `db:"seller_user_id"` // 销售员ID 0:自主下单
TotalAmount int64 `db:"total_amount"` // 总价
PayedAmount int64 `db:"payed_amount"` // 已支付金额
PayMethod int64 `db:"pay_method"` // 支付方式 1paypal 2strip
Ctime sql.NullInt64 `db:"ctime"` // 添加时间
Utime sql.NullInt64 `db:"utime"` // 更新时间
Ptime sql.NullInt64 `db:"ptime"` // 最后一次 支付时间(可能多次支付)
AddressId int64 `db:"address_id"` // 地址ID或者云仓ID
DeliveryMethod int64 `db:"delivery_method"` // 配送方式 1:直接发货到收获地址 2云仓
CustomerMark sql.NullString `db:"customer_mark"` // 客户备注
Mark sql.NullString `db:"mark"` // 后台订单备注
AddressInfo sql.NullString `db:"address_info"` // 详细地址信息JSON
IsSup int64 `db:"is_sup"` // 0不是补货 1是补货
Status int64 `db:"status"` // 状态位0未支付1部分支付2支付完成3部分生产4部分生产完成5全部生产6全部生产完成7部分发货8发货完成9完成订单10取消订单11:退款中12退款完成13:订单已删除14:订单已关闭)
IsPartPay int64 `db:"is_part_pay"` // 是否部分支付01
IsPayCompleted int64 `db:"is_pay_completed"` // 是否支付完成01
IsPartProduct int64 `db:"is_part_product"` // 是否部分生产01
IsPartProductCompleted int64 `db:"is_part_product_completed"` // 是否部分生产完成01
IsAllProduct int64 `db:"is_all_product"` // 是否全部生产01
IsAllProductCompleted int64 `db:"is_all_product_completed"` // 是否全部生产完成01
IsPartDelivery int64 `db:"is_part_delivery"` // 是否部分发货01
IsDeliveryCompleted int64 `db:"is_delivery_completed"` // 是否发货完成01
IsComplated int64 `db:"is_complated"` // 是否完成订单01
IsCancel int64 `db:"is_cancel"` // 是否取消订单01
IsRefunding int64 `db:"is_refunding"` // 是否退款中01
IsRefunded int64 `db:"is_refunded"` // 是否退款完成01
IsDeleted int64 `db:"is_deleted"` // 是否删除01
RefundReasonId sql.NullInt64 `db:"refund_reason_id"` // 取消订单原因ID
RefundReason sql.NullString `db:"refund_reason"` // 取消订单原因
TsTime time.Time `db:"ts_time"`
IsSure int64 `db:"is_sure"` // 是否确认订单 1确认0未确认
DeliverSn string `db:"deliver_sn"` // 发货单号
EmailTime int64 `db:"email_time"` // 邮件发送时间
}
)
func newFsOrderModel(conn sqlx.SqlConn) *defaultFsOrderModel {
return &defaultFsOrderModel{
conn: conn,
table: "`fs_order`",
}
}
func (m *defaultFsOrderModel) Delete(ctx context.Context, id int64) error {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, id)
return err
}
func (m *defaultFsOrderModel) FindOne(ctx context.Context, id int64) (*FsOrder, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsOrderRows, m.table)
var resp FsOrder
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
switch err {
case nil:
return &resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultFsOrderModel) FindOneBySn(ctx context.Context, sn string) (*FsOrder, error) {
var resp FsOrder
query := fmt.Sprintf("select %s from %s where `sn` = ? limit 1", fsOrderRows, m.table)
err := m.conn.QueryRowCtx(ctx, &resp, query, sn)
switch err {
case nil:
return &resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultFsOrderModel) Insert(ctx context.Context, data *FsOrder) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsOrderRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.Sn, data.UserId, data.SellerUserId, data.TotalAmount, data.PayedAmount, data.PayMethod, data.Ctime, data.Utime, data.Ptime, data.AddressId, data.DeliveryMethod, data.CustomerMark, data.Mark, data.AddressInfo, data.IsSup, data.Status, data.IsPartPay, data.IsPayCompleted, data.IsPartProduct, data.IsPartProductCompleted, data.IsAllProduct, data.IsAllProductCompleted, data.IsPartDelivery, data.IsDeliveryCompleted, data.IsComplated, data.IsCancel, data.IsRefunding, data.IsRefunded, data.IsDeleted, data.RefundReasonId, data.RefundReason, data.TsTime, data.IsSure, data.DeliverSn, data.EmailTime)
return ret, err
}
func (m *defaultFsOrderModel) Update(ctx context.Context, newData *FsOrder) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsOrderRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, newData.Sn, newData.UserId, newData.SellerUserId, newData.TotalAmount, newData.PayedAmount, newData.PayMethod, newData.Ctime, newData.Utime, newData.Ptime, newData.AddressId, newData.DeliveryMethod, newData.CustomerMark, newData.Mark, newData.AddressInfo, newData.IsSup, newData.Status, newData.IsPartPay, newData.IsPayCompleted, newData.IsPartProduct, newData.IsPartProductCompleted, newData.IsAllProduct, newData.IsAllProductCompleted, newData.IsPartDelivery, newData.IsDeliveryCompleted, newData.IsComplated, newData.IsCancel, newData.IsRefunding, newData.IsRefunded, newData.IsDeleted, newData.RefundReasonId, newData.RefundReason, newData.TsTime, newData.IsSure, newData.DeliverSn, newData.EmailTime, newData.Id)
return err
}
func (m *defaultFsOrderModel) tableName() string {
return m.table
}