resource

package
Version: v0.0.0-...-2cd4ea5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RESOURCE_TYPE_COUPON = "coupon"
View Source
const RESOURCE_TYPE_IMONEY = "imoney"
View Source
const RESOURCE_TYPE_PRODUCT = "product"
View Source
const RESOURCE_TYPE_SKU_MERGED_PRODUCT = "sku_merged_product"

Variables

This section is empty.

Functions

func NewCouponResourceAllocator

func NewCouponResourceAllocator(ctx context.Context) business.IResourceAllocator

func NewIMoneyResourceAllocator

func NewIMoneyResourceAllocator(ctx context.Context) business.IResourceAllocator

func NewProductResourceAllocator

func NewProductResourceAllocator(ctx context.Context) business.IResourceAllocator

Types

type AllocateResourceService

type AllocateResourceService struct {
	eel.ServiceBase
	// contains filtered or unexported fields
}

func NewAllocateResourceService

func NewAllocateResourceService(ctx context.Context) *AllocateResourceService

func (*AllocateResourceService) Allocate

func (this *AllocateResourceService) Allocate(resources []business.IResource, newOrder business.IOrder) error

func (*AllocateResourceService) Release

func (this *AllocateResourceService) Release(resources []business.IResource)

type CouponResource

type CouponResource struct {
	eel.EntityBase
	Resource

	Code string
	// contains filtered or unexported fields
}

func NewCouponResource

func NewCouponResource(ctx context.Context) *CouponResource

func (*CouponResource) CanSplit

func (this *CouponResource) CanSplit() bool

func (*CouponResource) GetCoupon

func (this *CouponResource) GetCoupon() *b_coupon.Coupon

func (*CouponResource) GetDeductionMoney

func (this *CouponResource) GetDeductionMoney(deductableMoney int) int

func (*CouponResource) GetLockName

func (this *CouponResource) GetLockName() string

func (*CouponResource) GetPostage

func (this *CouponResource) GetPostage() int

func (*CouponResource) GetPrice

func (this *CouponResource) GetPrice() int

func (*CouponResource) GetRawResourceObject

func (this *CouponResource) GetRawResourceObject() interface{}

func (*CouponResource) GetType

func (this *CouponResource) GetType() string

func (*CouponResource) IsAllocated

func (this *CouponResource) IsAllocated() bool

func (*CouponResource) IsNeedLockWhenConsume

func (this *CouponResource) IsNeedLockWhenConsume() bool

func (*CouponResource) IsValid

func (this *CouponResource) IsValid() error

func (*CouponResource) ResetAllocation

func (this *CouponResource) ResetAllocation()

func (*CouponResource) SaveForOrder

func (this *CouponResource) SaveForOrder(order business.IOrder) error

func (*CouponResource) SetAllocated

func (this *CouponResource) SetAllocated()

func (*CouponResource) ToMap

func (this *CouponResource) ToMap() map[string]interface{}

type CouponResourceAllocator

type CouponResourceAllocator struct {
	eel.ServiceBase
}

func (*CouponResourceAllocator) Allocate

func (this *CouponResourceAllocator) Allocate(resource business.IResource, newOrder business.IOrder) error

Allocate 申请优惠券资源,使用优惠券

func (*CouponResourceAllocator) Release

func (this *CouponResourceAllocator) Release(resource business.IResource)

Release 释放冻结的资产

type CouponUsage

type CouponUsage struct {
	Code  string
	Money float64
}

type GroupResourceService

type GroupResourceService struct {
	eel.ServiceBase
}

func NewGroupResourceService

func NewGroupResourceService(ctx context.Context) *GroupResourceService

func (*GroupResourceService) Group

func (this *GroupResourceService) Group(resources []business.IResource) map[int]*ResourceGroup

type IMoneyResource

type IMoneyResource struct {
	eel.EntityBase
	Resource

	Code            string
	Count           int
	SourceUserId    int
	DestUserId      int
	FrozenRecordIds []int
}

func NewIMoneyResource

func NewIMoneyResource(ctx context.Context) *IMoneyResource

func (*IMoneyResource) AddFrozenRecord

func (this *IMoneyResource) AddFrozenRecord(frozenRecordId int)

func (*IMoneyResource) CanSplit

func (this *IMoneyResource) CanSplit() bool

func (*IMoneyResource) GetDeductionMoney

func (this *IMoneyResource) GetDeductionMoney(deductableMoney int) int

func (*IMoneyResource) GetLockName

func (this *IMoneyResource) GetLockName() string

func (*IMoneyResource) GetPostage

func (this *IMoneyResource) GetPostage() int

func (*IMoneyResource) GetPrice

func (this *IMoneyResource) GetPrice() int

func (*IMoneyResource) GetRawResourceObject

func (this *IMoneyResource) GetRawResourceObject() interface{}

func (*IMoneyResource) GetType

func (this *IMoneyResource) GetType() string

func (*IMoneyResource) IsNeedLockWhenConsume

func (this *IMoneyResource) IsNeedLockWhenConsume() bool

func (*IMoneyResource) IsValid

func (this *IMoneyResource) IsValid() error

func (*IMoneyResource) ToMap

func (this *IMoneyResource) ToMap() map[string]interface{}

type IMoneyResourceAllocator

type IMoneyResourceAllocator struct {
	eel.ServiceBase
}

func (*IMoneyResourceAllocator) Allocate

func (this *IMoneyResourceAllocator) Allocate(resource business.IResource, newOrder business.IOrder) error

Allocate 申请商品资源,减少库存

func (*IMoneyResourceAllocator) Release

func (this *IMoneyResourceAllocator) Release(resource business.IResource)

Release 释放冻结的资产

type MergeSameSkuProductService

type MergeSameSkuProductService struct {
	eel.ServiceBase
}

func NewMergeSameSkuProductService

func NewMergeSameSkuProductService(ctx context.Context) *MergeSameSkuProductService

func (*MergeSameSkuProductService) Merge

func (this *MergeSameSkuProductService) Merge(resources []business.IResource) []*SkuMergedProduct

type ParseResourceService

type ParseResourceService struct {
	eel.ServiceBase
}

func NewParseResourceService

func NewParseResourceService(ctx context.Context) *ParseResourceService

func (*ParseResourceService) Parse

func (this *ParseResourceService) Parse(salesmanId int, productsArray []interface{}, imoneysArray []interface{}, couponUsage *CouponUsage) []business.IResource

func (*ParseResourceService) ParseFromOrderResources

func (this *ParseResourceService) ParseFromOrderResources(resourcesData []map[string]interface{}) []business.IResource

从订单数据中反序列化资源 todo

type ProductResource

type ProductResource struct {
	eel.EntityBase
	Resource

	PoolProductId int
	Sku           string
	Count         int
	SalesmanId    int
	Price         int
	// contains filtered or unexported fields
}

func NewProductResource

func NewProductResource(ctx context.Context) *ProductResource

func (*ProductResource) CanSplit

func (this *ProductResource) CanSplit() bool

func (*ProductResource) GetDeductionMoney

func (this *ProductResource) GetDeductionMoney(deductableMoney int) int

func (*ProductResource) GetLockName

func (this *ProductResource) GetLockName() string

func (*ProductResource) GetPoolProduct

func (this *ProductResource) GetPoolProduct() *product.PoolProduct

func (*ProductResource) GetPostage

func (this *ProductResource) GetPostage() int

func (*ProductResource) GetPrice

func (this *ProductResource) GetPrice() int

func (*ProductResource) GetRawResourceObject

func (this *ProductResource) GetRawResourceObject() interface{}

func (*ProductResource) GetType

func (this *ProductResource) GetType() string

func (*ProductResource) IsAllocated

func (this *ProductResource) IsAllocated() bool

func (*ProductResource) IsNeedLockWhenConsume

func (this *ProductResource) IsNeedLockWhenConsume() bool

func (*ProductResource) IsValid

func (this *ProductResource) IsValid() error

func (*ProductResource) ResetAllocation

func (this *ProductResource) ResetAllocation()

func (*ProductResource) SaveForOrder

func (this *ProductResource) SaveForOrder(order business.IOrder) error

func (*ProductResource) SetAllocated

func (this *ProductResource) SetAllocated()

func (*ProductResource) SetPoolProduct

func (this *ProductResource) SetPoolProduct(poolProduct *product.PoolProduct)

func (*ProductResource) ToMap

func (this *ProductResource) ToMap() map[string]interface{}

type ProductResourceAllocator

type ProductResourceAllocator struct {
	eel.ServiceBase
}

func (*ProductResourceAllocator) Allocate

func (this *ProductResourceAllocator) Allocate(resource business.IResource, newOrder business.IOrder) error

Allocate 申请商品资源,减少库存

func (*ProductResourceAllocator) Release

func (this *ProductResourceAllocator) Release(resource business.IResource)

Release 释放商品资源,恢复库存

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

func (*Resource) CanSplit

func (this *Resource) CanSplit() bool

func (*Resource) GetDeductionMoney

func (this *Resource) GetDeductionMoney() float64

func (*Resource) GetLockName

func (this *Resource) GetLockName() string

func (*Resource) GetPostage

func (this *Resource) GetPostage() float64

func (*Resource) GetPrice

func (this *Resource) GetPrice() float64

func (*Resource) GetType

func (this *Resource) GetType() string

func (*Resource) IsAllocated

func (this *Resource) IsAllocated() bool

func (*Resource) IsNeedLockWhenConsume

func (this *Resource) IsNeedLockWhenConsume() bool

func (*Resource) IsValid

func (this *Resource) IsValid() error

func (*Resource) ResetAllocation

func (this *Resource) ResetAllocation()

func (*Resource) SaveForOrder

func (this *Resource) SaveForOrder(order business.IOrder) error

func (*Resource) SetAllocated

func (this *Resource) SetAllocated()

func (*Resource) ToMap

func (this *Resource) ToMap() map[string]interface{}

type ResourceGroup

type ResourceGroup struct {
	eel.EntityBase
	SupplierId int
	Resources  []business.IResource
	// contains filtered or unexported fields
}

func (*ResourceGroup) AddResource

func (this *ResourceGroup) AddResource(resource business.IResource)

func (*ResourceGroup) GetImoneyResources

func (this *ResourceGroup) GetImoneyResources() []business.IResource

func (*ResourceGroup) GetProductResources

func (this *ResourceGroup) GetProductResources() []business.IResource

type ResourceManager

type ResourceManager struct {
	eel.ServiceBase

	Resources []business.IResource
	// contains filtered or unexported fields
}

func NewResourceManager

func NewResourceManager(ctx context.Context) *ResourceManager

func (*ResourceManager) AddResource

func (this *ResourceManager) AddResource(resource business.IResource)

func (*ResourceManager) AddResources

func (this *ResourceManager) AddResources(resources []business.IResource)

func (*ResourceManager) AllocateForOrder

func (this *ResourceManager) AllocateForOrder(newOrder business.IOrder) error

Allocate 申请订单中涉及的资源

func (*ResourceManager) GetNonProductResources

func (this *ResourceManager) GetNonProductResources() []business.IResource

func (*ResourceManager) GetProductResources

func (this *ResourceManager) GetProductResources() []business.IResource

func (*ResourceManager) GroupResourceBySupplier

func (this *ResourceManager) GroupResourceBySupplier() []*ResourceGroup

func (*ResourceManager) Lock

func (this *ResourceManager) Lock() error

func (*ResourceManager) ReleaseAllocatedResources

func (this *ResourceManager) ReleaseAllocatedResources()

ReleaseAllocatedResources 释放订单中涉及的资源

func (*ResourceManager) Unlock

func (this *ResourceManager) Unlock() error

func (*ResourceManager) Validate

func (this *ResourceManager) Validate() error

type SkuMergedProduct

type SkuMergedProduct struct {
	eel.EntityBase

	TotalCount  int
	TotalWeight float64
	TotalPrice  float64
	PoolProduct *product.PoolProduct
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL