You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
6.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package after
import (
"github.com/golangkit/formatime"
"github.com/shopspring/decimal"
"recook/internal/v2/lib/db"
)
type RecookAfterSalesGoodsModel struct {
db.BaseModel
Id uint `gorm:"column:id;primary_key" json:"asID"`
AncestorId uint `gorm:"column:ancestor_id" json:"-"`
ParentId uint `gorm:"column:parent_id" json:"parentId"` // 分享者id链接购买则是分享者id。其他方式则是自己上级的id
SharerId uint `gorm:"column:sharer_id" json:"sharerId"`
UserId uint `gorm:"column:user_id" json:"userId"` // 下单者
UserRole uint `gorm:"column:user_role" json:"userRole"`
OrderId uint `gorm:"column:order_id" json:"orderId"`
OrderGoodsId uint `gorm:"column:order_goods_id" json:"orderGoodsId"` // 1审核中 2填写物流单号 3申请被拒绝 4等待商家收货 5成功
VendorId uint `gorm:"column:vendor_id" json:"vendorId"` // 供应商Id: 0表示自营
VendorName string `gorm:"column:vendor_name" json:"vendorName"`
BrandName string `gorm:"column:brand_name" json:"brandName"` // 品牌名称
CategoryName string `gorm:"column:category_name" json:"cateName"`
GoodsId uint `gorm:"column:goods_id" json:"goodsId"` // 商品Id
GoodsName string `gorm:"column:goods_name" json:"goodsName"` // 商品名快照
SkuName string `gorm:"column:sku_name" json:"skuName"` // SKU名字组合起来
SkuCode string `gorm:"column:sku_code" json:"skuCode"` // 条形码或者编码
MainPhotoUrl string `gorm:"column:main_photo_url" json:"mainPhotoUrl"` // 主图快照 先读sku 没有则读取主图
Quantity uint `gorm:"column:quantity" json:"quantity"` // 商品数量
OrderTime formatime.Second `gorm:"column:order_time" json:"orderTime"`
OrderTotalAmount decimal.Decimal `gorm:"column:order_total_amount" json:"orderTotalAmount"`
RefundAmount decimal.Decimal `gorm:"column:refund_amount" json:"refundAmount"` // 退款金额
RefundCoin decimal.Decimal `gorm:"column:refund_coin" json:"refundCoin"` // 退款瑞币
TradeNo string `gorm:"column:trade_no" json:"tradeNo"` // 传递给第三方支付的id凭证
PayMethod uint `gorm:"column:pay_method" json:"payMethod"`
IsShip uint `gorm:"column:is_ship" json:"isShip"`
AssType uint `gorm:"column:ass_type" json:"assType"`
ReturnStatus uint `gorm:"column:return_status" json:"returnStatus"`
ApplyTime formatime.Second `gorm:"column:apply_time" json:"applyTime"`
CheckTime formatime.Second `gorm:"column:check_time" json:"checkTime"`
Reason string `gorm:"column:reason" json:"reason"`
RejectReason string `gorm:"column:reject_reason" json:"rejectReason"`
ExpressCompName string `gorm:"column:express_comp_name" json:"expressCompName"` // 物流公司名称
ExpressCompCode string `gorm:"column:express_comp_code" json:"expressCompCode"` // 物流单号
ExpressNo string `gorm:"column:express_no" json:"expressNo"`
ExpressFree decimal.Decimal `gorm:"column:express_free" json:"expressFree"` //运费补偿
ExpressTime formatime.Second `gorm:"column:express_time" json:"expressTime"`
RefundNo string `gorm:"column:refund_no" json:"refundNo"`
RefundStatus uint `gorm:"column:refund_status" json:"refundStatus"`
FinishTime formatime.Second `gorm:"column:finish_time" json:"finishTime"`
CreatedAt formatime.Second `gorm:"column:created_at" json:"createdAt"`
IsClosed int `gorm:"is_closed" json:"isClosed"`
ReasonId int `gorm:"reason_id" json:"reasonId"`
ReasonType uint `gorm:"reason_type" json:"reasonType"`
ThirdPartyType int `gorm:"third_party_type" json:"thirdPartyType"`
ReasonContent string `gorm:"reason_content" json:"reasonContent"`
ReasonImg string `gorm:"reason_img" json:"reasonImg"`
SupplierPrice decimal.Decimal `gorm:"supplier_price" json:"supplierPrice"`
}
// TableName sets the insert table name for this struct type
func (r *RecookAfterSalesGoodsModel) TableName() string {
return "recook_after_sales_goods"
}
// @Style 获取列表
func (r *RecookAfterSalesGoodsModel) GetLists(start, limit int, order string, query interface{}, args ...interface{}) (result []RecookAfterSalesGoodsModel) {
r.GetDb().Model(&RecookAfterSalesGoodsModel{}).Where(query, args...).Offset(start).Limit(limit).Order(order).Find(&result)
return
}
// @Style 获取总数
func (r *RecookAfterSalesGoodsModel) GetListsTotal(query interface{}, args ...interface{}) (result int) {
r.GetDb().Model(&RecookAfterSalesGoodsModel{}).Where(query, args...).Count(&result)
return
}
// GetCount 获取数量.
func (r *RecookAfterSalesGoodsModel) GetCount(where interface{}, args ...interface{}) (count uint) {
r.GetDb().Model(&RecookAfterSalesGoodsModel{}).Where(where, args).Count(&count)
return
}
// GetAFTByID 通过id获取.
func (r *RecookAfterSalesGoodsModel) GetAFTByID(by uint) (res RecookAfterSalesGoodsModel) {
r.GetDb().Model(&RecookAfterSalesGoodsModel{}).Where("id = ?", by).Find(&res)
return
}
// UpdateByID 通过id更新.
func (r *RecookAfterSalesGoodsModel) UpdateByID(by uint, values interface{}, ignoreProtectedAttrs ...bool) error {
return r.GetDb().Model(&RecookAfterSalesGoodsModel{}).Where("id = ?", by).
Omit("id").Updates(values, ignoreProtectedAttrs...).Error
}
//
func (r *RecookAfterSalesGoodsModel) GetRefundLogContent() string {
return "退款金额<black>¥" +
r.RefundAmount.String() +
"</black>将原路退回至您的<black>付款账户</black>,请及时关注到账情况。"
}