Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EShop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
EShop
Commits
eb75fb8a
Commit
eb75fb8a
authored
Apr 30, 2020
by
gdlcf88
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Product purchasable check feature, close #18
parent
c26fc4e8
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
0 deletions
+86
-0
IProductAppService.cs
...cts/EasyAbp/EShop/Products/Products/IProductAppService.cs
+2
-0
ProductAppService.cs
...tion/EasyAbp/EShop/Products/Products/ProductAppService.cs
+12
-0
GetProductPurchasableStatusResult.cs
...op/Products/Products/GetProductPurchasableStatusResult.cs
+9
-0
ProductPurchasableStatus.cs
...syAbp/EShop/Products/Products/ProductPurchasableStatus.cs
+8
-0
IProductPurchasableStatusProvider.cs
...op/Products/Products/IProductPurchasableStatusProvider.cs
+13
-0
ProductIsNotPurchasableException.cs
...hop/Products/Products/ProductIsNotPurchasableException.cs
+13
-0
ProductPurchasableStatusProvider.cs
...hop/Products/Products/ProductPurchasableStatusProvider.cs
+29
-0
No files found.
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/IProductAppService.cs
View file @
eb75fb8a
...
@@ -23,5 +23,7 @@ namespace EasyAbp.EShop.Products.Products
...
@@ -23,5 +23,7 @@ namespace EasyAbp.EShop.Products.Products
Task
<
ProductDto
>
GetAsync
(
Guid
id
,
Guid
storeId
);
Task
<
ProductDto
>
GetAsync
(
Guid
id
,
Guid
storeId
);
Task
<
ProductDto
>
DeleteSkuAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
);
Task
<
ProductDto
>
DeleteSkuAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
);
Task
<
GetProductPurchasableStatusResult
>
GetPurchasableStatusAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
);
}
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs
View file @
eb75fb8a
...
@@ -24,17 +24,20 @@ namespace EasyAbp.EShop.Products.Products
...
@@ -24,17 +24,20 @@ namespace EasyAbp.EShop.Products.Products
protected
override
string
GetPolicyName
{
get
;
set
;
}
=
null
;
protected
override
string
GetPolicyName
{
get
;
set
;
}
=
null
;
protected
override
string
GetListPolicyName
{
get
;
set
;
}
=
null
;
protected
override
string
GetListPolicyName
{
get
;
set
;
}
=
null
;
private
readonly
IProductPurchasableStatusProvider
_productPurchasableStatusProvider
;
private
readonly
IAttributeOptionIdsSerializer
_attributeOptionIdsSerializer
;
private
readonly
IAttributeOptionIdsSerializer
_attributeOptionIdsSerializer
;
private
readonly
IProductStoreRepository
_productStoreRepository
;
private
readonly
IProductStoreRepository
_productStoreRepository
;
private
readonly
IProductCategoryRepository
_productCategoryRepository
;
private
readonly
IProductCategoryRepository
_productCategoryRepository
;
private
readonly
IProductRepository
_repository
;
private
readonly
IProductRepository
_repository
;
public
ProductAppService
(
public
ProductAppService
(
IProductPurchasableStatusProvider
productPurchasableStatusProvider
,
IAttributeOptionIdsSerializer
attributeOptionIdsSerializer
,
IAttributeOptionIdsSerializer
attributeOptionIdsSerializer
,
IProductStoreRepository
productStoreRepository
,
IProductStoreRepository
productStoreRepository
,
IProductCategoryRepository
productCategoryRepository
,
IProductCategoryRepository
productCategoryRepository
,
IProductRepository
repository
)
:
base
(
repository
)
IProductRepository
repository
)
:
base
(
repository
)
{
{
_productPurchasableStatusProvider
=
productPurchasableStatusProvider
;
_attributeOptionIdsSerializer
=
attributeOptionIdsSerializer
;
_attributeOptionIdsSerializer
=
attributeOptionIdsSerializer
;
_productStoreRepository
=
productStoreRepository
;
_productStoreRepository
=
productStoreRepository
;
_productCategoryRepository
=
productCategoryRepository
;
_productCategoryRepository
=
productCategoryRepository
;
...
@@ -351,6 +354,15 @@ namespace EasyAbp.EShop.Products.Products
...
@@ -351,6 +354,15 @@ namespace EasyAbp.EShop.Products.Products
return
ObjectMapper
.
Map
<
Product
,
ProductDto
>(
product
);
return
ObjectMapper
.
Map
<
Product
,
ProductDto
>(
product
);
}
}
public
async
Task
<
GetProductPurchasableStatusResult
>
GetPurchasableStatusAsync
(
Guid
productId
,
Guid
productSkuId
,
Guid
storeId
)
{
var
product
=
await
_repository
.
GetAsync
(
productId
);
var
productSku
=
product
.
ProductSkus
.
Single
(
sku
=>
sku
.
Id
==
productSkuId
);
return
await
_productPurchasableStatusProvider
.
GetPurchasableStatusAsync
(
product
,
productSku
,
storeId
);
}
protected
virtual
async
Task
UpdateProductCategoriesAsync
(
Guid
productId
,
IEnumerable
<
Guid
>
categoryIds
)
protected
virtual
async
Task
UpdateProductCategoriesAsync
(
Guid
productId
,
IEnumerable
<
Guid
>
categoryIds
)
{
{
await
_productCategoryRepository
.
DeleteAsync
(
x
=>
x
.
ProductId
.
Equals
(
productId
));
await
_productCategoryRepository
.
DeleteAsync
(
x
=>
x
.
ProductId
.
Equals
(
productId
));
...
...
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/GetProductPurchasableStatusResult.cs
0 → 100644
View file @
eb75fb8a
namespace
EasyAbp.EShop.Products.Products
{
public
class
GetProductPurchasableStatusResult
{
public
ProductPurchasableStatus
PurchasableStatus
{
get
;
set
;
}
public
string
Reason
{
get
;
set
;
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductPurchasableStatus.cs
0 → 100644
View file @
eb75fb8a
namespace
EasyAbp.EShop.Products.Products
{
public
enum
ProductPurchasableStatus
{
CanBePurchased
=
1
,
CanNotBePurchased
=
2
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductPurchasableStatusProvider.cs
0 → 100644
View file @
eb75fb8a
using
System
;
using
System.Threading.Tasks
;
namespace
EasyAbp.EShop.Products.Products
{
public
interface
IProductPurchasableStatusProvider
{
Task
CheckPurchasableAsync
(
Product
product
,
ProductSku
productSku
,
Guid
storeId
);
Task
<
GetProductPurchasableStatusResult
>
GetPurchasableStatusAsync
(
Product
product
,
ProductSku
productSku
,
Guid
storeId
);
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductIsNotPurchasableException.cs
0 → 100644
View file @
eb75fb8a
using
System
;
using
Volo.Abp
;
namespace
EasyAbp.EShop.Products.Products
{
public
class
ProductIsNotPurchasableException
:
BusinessException
{
public
ProductIsNotPurchasableException
(
Guid
id
,
string
reason
)
:
base
(
message
:
$"Product
{
id
}
cannot be purchased, the reason is:
{
reason
}
"
)
{
}
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductPurchasableStatusProvider.cs
0 → 100644
View file @
eb75fb8a
using
System
;
using
System.Threading.Tasks
;
using
Volo.Abp.DependencyInjection
;
namespace
EasyAbp.EShop.Products.Products
{
public
class
ProductPurchasableStatusProvider
:
IProductPurchasableStatusProvider
,
ITransientDependency
{
public
async
Task
CheckPurchasableAsync
(
Product
product
,
ProductSku
productSku
,
Guid
storeId
)
{
var
result
=
await
GetPurchasableStatusAsync
(
product
,
productSku
,
storeId
);
if
(
result
.
PurchasableStatus
!=
ProductPurchasableStatus
.
CanBePurchased
)
{
throw
new
ProductIsNotPurchasableException
(
product
.
Id
,
result
.
Reason
);
}
}
public
async
Task
<
GetProductPurchasableStatusResult
>
GetPurchasableStatusAsync
(
Product
product
,
ProductSku
productSku
,
Guid
storeId
)
{
// Todo: Determine whether the product can be purchased.
return
new
GetProductPurchasableStatusResult
{
PurchasableStatus
=
ProductPurchasableStatus
.
CanBePurchased
,
Reason
=
null
};
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment