package order import ( "recook/internal/define" "recook/internal/model/order_preview" "github.com/golangkit/formatime" "github.com/shopspring/decimal" ) type GoodsDetail struct { ID uint `gorm:"column:id;primary_key" json:"goodsDetailId"` OrderID uint `gorm:"column:order_id;" json:"orderId"` AncestorID uint `gorm:"column:ancestor_id" json:"-"` ParentID uint `gorm:"column:parent_id" json:"parentId"` SharerID uint `gorm:"column:sharer_id" json:"sharerId"` LiveId uint `gorm:"column:live_id" json:"liveId"` UserID uint `gorm:"column:user_id" json:"userId"` VendorID uint `gorm:"column:vendor_id" json:"vendorId"` // 供应商ID: 0表示自营 VendorName string `gorm:"column:vendor_name" json:"vendorName"` BrandID uint `gorm:"column:brand_id" json:"brandId"` // 品牌 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"` // 商品名快照 IsJoinTeamPerformance uint `gorm:"column:is_join_team_performance" json:"-"` // 是否参与团队业绩计算 Hash string `gorm:"column:hash" json:"-"` // 商品哈希值如果商品信息更新了 SkuID uint `gorm:"column:sku_id" json:"skuId"` // 商品sku_id 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"` // 商品数量 FreightID uint `gorm:"column:freight_id" json:"-"` // 运费模板 Weight decimal.Decimal `gorm:"column:weight" json:"-"` // 重量 PromotionGoodsId uint `gorm:"column:promotion_goods_id" json:"-"` PromotionSkuId uint `gorm:"column:promotion_sku_id" json:"-"` // PromotionName string `gorm:"column:promotion_name" json:"promotionName"` // 活动名称 PromotionStartTime formatime.Second `gorm:"column:promotion_start_time" json:"-"` PromotionEndTime formatime.Second `gorm:"column:promotion_end_time" json:"-"` UnitPrice decimal.Decimal `gorm:"column:unit_price" json:"unitPrice"` // 单价 PurchasePrice decimal.Decimal `gorm:"column:purchase_price" json:"purchasePrice"` // 采购价 TotalCommission decimal.Decimal `gorm:"column:total_commission" json:"totalCommission"` // 提成总额 BrandCouponAmount decimal.Decimal `gorm:"column:brand_coupon_amount" json:"brandCouponAmount"` // 品牌优惠券抵扣金额 UniverseCouponAmount decimal.Decimal `gorm:"column:universe_coupon_amount" json:"universeBrandCouponAmount"` // 购物券抵扣金额 CoinAmount decimal.Decimal `gorm:"column:coin_amount" json:"coinAmount"` // 瑞币抵扣金额 GoodsAmount decimal.Decimal `gorm:"column:goods_amount" json:"goodsAmount"` // 商品总金额 单价x数量,不含其他费用减除 ExpressFee decimal.Decimal `gorm:"column:express_fee" json:"expressFee"` // 快递费 ActualAmount decimal.Decimal `gorm:"column:actual_amount" json:"actualAmount"` // 实际支付的金额 StoreID uint `gorm:"column:store_id" json:"-"` // 门店id BuyerMessage string `gorm:"column:buyer_message" json:"buyerMessage"` // 买家留言 OrderTime formatime.Second `gorm:"column:order_time" json:"orderTime"` PayStatus uint `gorm:"column:pay_status" json:"payStatus"` CreatedAt formatime.Second `gorm:"column:created_at" json:"createdAt"` // 创建时间 ExpressStatus uint `gorm:"column:express_status" json:"expressStatus"` ExpressTime formatime.Second `gorm:"column:express_time" json:"expressTime"` 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"` AssType uint `gorm:"column:ass_type" json:"assType"` RefundStatus uint `gorm:"column:refund_status" json:"refundStatus"` Status uint `gorm:"column:status" json:"status"` Addr Addr `gorm:"ForeignKey:OrderID;ASSOCIATION_FOREIGNKEY:OrderID"` ShippingMethod int `gorm:"shipping_method"` IsClosed int `gorm:"is_closed" json:"isClosed"` RStatus string `gorm:"-" json:"rStatus"` DetailInfo string Bill int `gorm:"bill" json:"bill"` //是否开发票0代表未开1处理中2已成功3失败 Fpqqlsh string `gorm:"fpqqlsh" json:"fpqqlsh"` //流水号 IsExport int `gorm:"is_export" json:"is_export"` //舶茂的是否导出 BomaoNo string `gorm:"bomao_no" json:"bomao_no"` //舶茂的订单编号 EvaluatedId int `gorm:"evaluated_id" json:"evaluated_id"` //评价id ReportMsg string `gorm:"report_msg" json:"reportMsg"` Report int `gorm:"report" json:"report"` IsImport int `gorm:"column:is_import" json:"isImport"` //是否进口商品 Storehouse int `gorm:"column:storehouse" json:"storehouse"` //进口商品仓库 IsFerme int `gorm:"column:is_ferme" json:"isFerme"` //是否包税 ActivityStatus uint `gorm:"column:activity_status" json:"activity_status"` ActivityId uint `gorm:"column:activity_id" json:"activity_id"` //活动id MakeUpStatus uint `json:"make_up_status"` ExtraPrice decimal.Decimal `json:"-"` } // TableName sets the insert table name for this struct type func (r *GoodsDetail) TableName() string { return "recook_order_goods_detail" } func (r *GoodsDetail) GetBase() decimal.Decimal { cost := r.PurchasePrice.Mul(decimal.NewFromFloat(1.03)) if !r.ExtraPrice.IsZero() { cost = r.PurchasePrice.Add(r.ExtraPrice) } base := r.UnitPrice.Sub(cost).Mul(decimal.NewFromFloat32(define.Coefficient)) return base.Round(2) } // 判断商品订单是否结束 func (r GoodsDetail) IsOrderGoodsEnd() bool { // 成功 if r.AssType == 0 && r.ExpressStatus == 1 { return true } // 售后成功 if r.RefundStatus == 2 { return true } return false } // 判断商品是否销售完成 func (r GoodsDetail) IsFinished() bool { // 成功 if r.AssType == 0 && r.ExpressStatus == 1 { return true } return false } func (*GoodsDetail) Reflect(r *order_preview.GoodsDetail, o *Information) *GoodsDetail { return &GoodsDetail{ OrderID: o.ID, AncestorID: o.AncestorID, ParentID: o.ParentID, SharerID: o.SharerID, LiveId: o.LiveId, UserID: o.UserID, VendorID: r.VendorID, VendorName: r.VendorName, BrandID: r.BrandID, BrandName: r.BrandName, CategoryName: r.CategoryName, GoodsID: r.GoodsID, GoodsName: r.GoodsName, IsJoinTeamPerformance: r.IsJoinTeamPerformance, Hash: r.Hash, SkuID: r.SkuID, SkuName: r.SkuName, SkuCode: r.SkuCode, MainPhotoURL: r.MainPhotoURL, Quantity: r.Quantity, FreightID: r.FreightID, Weight: r.Weight, PromotionGoodsId: r.PromotionGoodsId, PromotionSkuId: r.PromotionSkuId, PromotionName: r.PromotionName, PromotionStartTime: r.PromotionStartTime, PromotionEndTime: r.PromotionEndTime, UnitPrice: r.UnitPrice, PurchasePrice: r.PurchasePrice, TotalCommission: r.TotalCommission, ExpressFee: r.ExpressFee, BrandCouponAmount: r.BrandCouponAmount, UniverseCouponAmount: r.UniverseCouponAmount, CoinAmount: r.CoinAmount, GoodsAmount: r.GoodsAmount, ActualAmount: r.ActualAmount, StoreID: o.StoreID, BuyerMessage: o.BuyerMessage, OrderTime: o.CreatedAt, ShippingMethod: int(o.ShippingMethod), IsImport: r.IsImport, Storehouse: r.Storehouse, IsFerme: r.IsFerme, ExtraPrice: r.ExtraPrice, } } func (r GoodsDetail) isOrderDetail() bool { return true }