Skip to content

Commit

Permalink
Merge branch 'main' into main-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ixre committed Mar 10, 2023
2 parents b222c9a + 188e420 commit 67e42e5
Show file tree
Hide file tree
Showing 123 changed files with 3,753 additions and 2,771 deletions.
4 changes: 2 additions & 2 deletions core/domain/cart/normal_cart.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (c *cartImpl) setAttachGoodsInfo(items []*cart.NormalCartItem) {
SpecData: "",
SpecWord: "",
Code: iv.Code,
RetailPrice: iv.RetailPrice,
OriginPrice: iv.OriginPrice,
Price: iv.Price,
Cost: iv.Cost,
Weight: iv.Weight,
Expand Down Expand Up @@ -297,7 +297,7 @@ func (c *cartImpl) put(itemId, skuId int64, num int32, reset bool, checkOnly boo
c.snapMap = nil

// 设置商品的相关信息
c.setItemInfo(iv, c.getBuyerLevelId())
c.setItemInfo(&iv, c.getBuyerLevelId())

v := &cart.NormalCartItem{
CartId: c.GetAggregateRootId(),
Expand Down
4 changes: 2 additions & 2 deletions core/domain/cart/wholesale_cart.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (c *wholesaleCartImpl) setAttachGoodsInfo(items []*cart.WsCartItem) {
SpecData: "",
SpecWord: "",
Code: iv.Code,
RetailPrice: iv.RetailPrice,
OriginPrice: iv.OriginPrice,
Price: iv.Price,
Cost: iv.Cost,
Weight: iv.Weight,
Expand Down Expand Up @@ -315,7 +315,7 @@ func (c *wholesaleCartImpl) put(itemId, skuId int64, quantity int32, reset bool,
c.snapMap = nil

// 设置商品的相关信息
c.setItemInfo(iv, c.getBuyerLevelId())
c.setItemInfo(&iv, c.getBuyerLevelId())

v := &cart.WsCartItem{
CartId: c.GetAggregateRootId(),
Expand Down
18 changes: 9 additions & 9 deletions core/domain/interface/cart/cart.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var (
ErrNoSuchCart = domain.NewError(
"empty_shopping_no_such_cart", "购物车无法使用")
"empty_shopping_no_such_cart", "购物车不存在")

ErrKindNotMatch = domain.NewError(
"err_cart_kind_not_match", "购物车类型不匹配")
Expand Down Expand Up @@ -183,21 +183,21 @@ type (
// NormalCart 购物车
NormalCart struct {
// 编号
Id int32 `db:"id" pk:"yes" auto:"yes"`
Id int32 `db:"id" pk:"yes" auto:"yes"`
// 购物车代码
CartCode string `db:"code"`
CartCode string `db:"code"`
// 买家编号
BuyerId int64 `db:"buyer_id"`
BuyerId int64 `db:"buyer_id"`
// 支付选项
PaymentOpt int32 `db:"payment_opt"`
PaymentOpt int32 `db:"payment_opt"`
//todo: del???
DeliverId int64 `db:"deliver_id"`
DeliverId int64 `db:"deliver_id"`
// 创建时间
CreateTime int64 `db:"create_time"`
CreateTime int64 `db:"create_time"`
// 更新时间
UpdateTime int64 `db:"update_time"`
UpdateTime int64 `db:"update_time"`
// 商品项目
Items []*NormalCartItem `db:"-"`
Items []*NormalCartItem `db:"-"`
}

// NormalCartItem 购物车项
Expand Down
33 changes: 30 additions & 3 deletions core/domain/interface/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package item

import (
"sort"

promodel "github.com/ixre/go2o/core/domain/interface/pro_model"
"github.com/ixre/go2o/core/domain/interface/product"
"github.com/ixre/go2o/core/domain/interface/promotion"
Expand Down Expand Up @@ -85,7 +87,7 @@ type (
// GetAggregateRootId 获取聚合根编号
GetAggregateRootId() int64
// GetValue 设置值
GetValue() *GoodsItem
GetValue() GoodsItem
// GetPackedValue 获取包装过的商品信息
GetPackedValue() *valueobject.Goods
// SetValue 设置值
Expand Down Expand Up @@ -145,7 +147,10 @@ type (
//
//// 获取最新的快照
//GetLatestSnapshot() *goods.GoodsSnapshot

// 回收商品
Recycle() error
// 从回收站中撤回
RecycleRevert() error
// Destroy 删除商品
Destroy() error
}
Expand Down Expand Up @@ -400,7 +405,7 @@ type (
// 销售价
Price int64 `db:"price"`
// 零售价
RetailPrice int64 `db:"retail_price"`
OriginPrice int64 `db:"origin_price"`
// 重量:克(g)
Weight int32 `db:"weight"`
// 体积:毫升(ml)
Expand All @@ -413,6 +418,8 @@ type (
ReviewRemark string `db:"review_remark"`
// 排序序号
SortNum int32 `db:"sort_num"`
// 是否已被回收
IsRecycle int `db:"is_recycle"`
// 创建时间
CreateTime int64 `db:"create_time"`
// 更新时间
Expand Down Expand Up @@ -474,3 +481,23 @@ type (
OriginRateC int `db:"origin_rate_c"`
}
)

var _ sort.Interface = SkuList{}

type SkuList []*Sku

func (s SkuList) Len() int {
return len(s)
}

// Less reports whether the element with
// index i should sort before the element with index j.
func (s SkuList) Less(i, j int) bool {
b := s[i].Price - s[j].Price
return b < 0 || b == 0 && s[i].Id < s[j].Id
}

// Swap swaps the elements with indexes i and j.
func (s SkuList) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
12 changes: 5 additions & 7 deletions core/domain/interface/item/sku_service.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package item

import (
"github.com/ixre/go2o/core/domain/interface/pro_model"
)
import promodel "github.com/ixre/go2o/core/domain/interface/pro_model"

type (
ISkuService interface {
Expand Down Expand Up @@ -45,7 +43,7 @@ type (
// 产品编码
Code string `db:"code"`
// 参考价
RetailPrice int64 `db:"retail_price"`
OriginPrice int64 `db:"origin_price"`
// 价格(分)
Price int64 `db:"price"`
// 成本(分)
Expand Down Expand Up @@ -91,7 +89,7 @@ type (
// 产品编码
ItemCode string `db:"code"`
// 参考价
RetailPrice int64 `db:"retail_price"`
OriginPrice int64 `db:"origin_price"`
// 价格(分)
Price int64 `db:"price"`
// 重量(克)
Expand All @@ -106,7 +104,7 @@ type (
)

// 转换为SKU媒体
func ParseSkuMedia(it *GoodsItem, sku *Sku) *SkuMedia {
func ParseSkuMedia(it GoodsItem, sku *Sku) *SkuMedia {
media := &SkuMedia{
CatId: it.CategoryId,
Price: it.Price,
Expand All @@ -119,7 +117,7 @@ func ParseSkuMedia(it *GoodsItem, sku *Sku) *SkuMedia {
if sku != nil {
media.SpecData = sku.SpecData
media.SpecWord = sku.SpecWord
media.RetailPrice = sku.RetailPrice
media.OriginPrice = sku.OriginPrice
media.Price = sku.Price
media.Stock = sku.Stock
if sku.Image != "" {
Expand Down
2 changes: 1 addition & 1 deletion core/domain/interface/item/snapshot_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type (
// 售价
Price int64 `db:"price"`
// 零售价
RetailPrice int64 `db:"retail_price"`
OriginPrice int64 `db:"origin_price"`
// 重量(g)
Weight int32 `db:"weight"`
// 体积(ml)
Expand Down
4 changes: 3 additions & 1 deletion core/domain/interface/member/member_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ type IMemberRepo interface {
// 创建会员,仅作为某些操作使用,不保存
CreateMemberById(memberId int64) IMember

// 保存
// SaveMember 保存
SaveMember(v *Member) (int64, error)
// ResetMemberIdCache 重置会员缓存
ResetMemberIdCache(field string, value string) error

// 获取会员最后更新时间
GetMemberLatestUpdateTime(id int64) int64
Expand Down
2 changes: 2 additions & 0 deletions core/domain/interface/order/normal_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type (
OnlinePaymentTradeFinish() error
// Submit 提交订单。如遇拆单,需均摊优惠抵扣金额到商品
Submit() error
// Cancel 取消订单
Cancel(buyerCancel bool, reason string) error

//根据运营商拆单,返回拆单结果,及拆分的订单数组
//BreakUpByVendor() ([]IOrder, error)
Expand Down
2 changes: 2 additions & 0 deletions core/domain/interface/order/order_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type (
GetOrderByNo(orderNo string) IOrder
// 获取子订单
GetSubOrder(id int64) ISubOrder
// 取消订单
Cancel(orderNo string, subOrder bool, userCancel bool, reason string) error
}

// 订单提交附带的数据, //todo: 改为struct
Expand Down
10 changes: 7 additions & 3 deletions core/domain/interface/pro_model/product_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import "github.com/ixre/go2o/core/infrastructure/domain"

var (
ErrEmptyAttrArray = domain.NewError(
"err_empty_attr_array", "请至少包含一个属性")
"err_empty_attr_array", "模型至少包含一个属性")
ErrEmptySpecArray = domain.NewError(
"err_empty_spec_array", "请至少包含一个规格")
"err_empty_spec_array", "模型至少包含一个规格")
ErrEmptyBrandArray = domain.NewError(
"err_empty_brand_array", "请至少包含一个品牌")
"err_empty_brand_array", "模型至少包含一个品牌")
ErrExistsBrand = domain.NewError(
"err_exists_brand", "已存在相同名称的品牌")
)

type ProductModel struct {
Expand Down Expand Up @@ -131,6 +133,8 @@ type IProductModelRepo interface {
DeleteProBrand(primary interface{}) error
// Select ProductBrand
SelectProBrand(where string, v ...interface{}) []*ProductBrand
// IsExistsBrand 是否存在相同名称的品牌
IsExistsBrand(name string, id int) bool

// Batch Delete ProductBrand
BatchDeleteProBrand(where string, v ...interface{}) (int64, error)
Expand Down
2 changes: 1 addition & 1 deletion core/domain/interface/valueobject/goods.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Goods struct {
// 视频
IntroVideo string `db:"intro_video"`
//定价
RetailPrice int64 `db:"retail_price"`
OriginPrice int64 `db:"origin_price"`

//销售价
Price int64 `db:"price"`
Expand Down
Loading

0 comments on commit 67e42e5

Please sign in to comment.