Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
黄奎
mall.oytour.com
Commits
b67b8eac
Commit
b67b8eac
authored
May 15, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
727c6330
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
224 additions
and
10 deletions
+224
-10
RB_DiscountCoupon_Extend.cs
....Model/Extend/MarketingCenter/RB_DiscountCoupon_Extend.cs
+11
-1
RB_DiscountCoupon_Product_Extend.cs
...xtend/MarketingCenter/RB_DiscountCoupon_Product_Extend.cs
+11
-0
RB_Member_DiscountCoupon_Extend.cs
Mall.Model/Extend/User/RB_Member_DiscountCoupon_Extend.cs
+3
-0
CouponModule.cs
Mall.Module.MarketingCenter/CouponModule.cs
+19
-4
RB_DiscountCouponRepository.cs
...Repository/MarketingCenter/RB_DiscountCouponRepository.cs
+108
-2
RB_Member_CouponRepository.cs
Mall.Repository/User/RB_Member_CouponRepository.cs
+8
-3
AppletCouponController.cs
...Api/Controllers/MarketingCenter/AppletCouponController.cs
+64
-0
No files found.
Mall.Model/Extend/MarketingCenter/RB_DiscountCoupon_Extend.cs
View file @
b67b8eac
...
...
@@ -19,10 +19,12 @@ namespace Mall.Model.Extend.MarketingCenter
public
List
<
RB_DiscountCoupon_Product_Extend
>
ProductList
{
get
;
set
;
}
/// <summary>
/// 发放优惠券的时候会员id
/// 发放优惠券的时候会员id
s
/// </summary>
public
string
UserIds
{
get
;
set
;
}
/// <summary>
/// 发放数量
/// </summary>
...
...
@@ -36,5 +38,13 @@ namespace Mall.Model.Extend.MarketingCenter
/// 会员等级
/// </summary>
public
int
[]
MemberLevelList
{
get
;
set
;
}
/// <summary>
/// 发放优惠券的时候会员id
/// </summary>
public
int
UserId
{
get
;
set
;
}
}
}
Mall.Model/Extend/MarketingCenter/RB_DiscountCoupon_Product_Extend.cs
View file @
b67b8eac
...
...
@@ -17,5 +17,16 @@ namespace Mall.Model.Extend.MarketingCenter
/// 关联信息(商品图片/分类名称)
/// </summary>
public
string
Relevance
{
get
;
set
;
}
/// <summary>
/// 商品价格(下单获取优惠券)
/// </summary>
public
decimal
GoodsPrice
{
get
;
set
;
}
/// <summary>
/// 商品分类id
/// </summary>
public
int
[]
GoodsClassId
{
get
;
set
;
}
}
}
Mall.Model/Extend/User/RB_Member_DiscountCoupon_Extend.cs
View file @
b67b8eac
...
...
@@ -57,5 +57,8 @@ namespace Mall.Model.Extend.User
/// 优惠卷ids
/// </summary>
public
string
CouponIds
{
get
;
set
;
}
}
}
Mall.Module.MarketingCenter/CouponModule.cs
View file @
b67b8eac
...
...
@@ -178,6 +178,7 @@ namespace Mall.Module.MarketingCenter
id
=
discountCouponRepository
.
Insert
(
model
,
trans
);
if
(
id
>
0
&&
model
.
ProductList
!=
null
&&
model
.
ProductList
.
Any
())
{
model
.
ProductList
.
ForEach
(
x
=>
x
.
DiscountCouponType
=
model
.
UseType
);
model
.
ProductList
.
ForEach
(
x
=>
x
.
MallBaseId
=
model
.
MallBaseId
);
model
.
ProductList
.
ForEach
(
x
=>
x
.
TenantId
=
model
.
TenantId
);
model
.
ProductList
.
ForEach
(
x
=>
x
.
CreateDate
=
model
.
CreateDate
);
...
...
@@ -202,7 +203,7 @@ namespace Mall.Module.MarketingCenter
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_DiscountCoupon_Product
.
DiscountCouponId
),
FiledValue
=
id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
productRepository
.
Update
(
fileds
,
whereHelpers
,
trans
);
productRepository
.
Update
(
fileds
,
whereHelpers
,
trans
);
////var listProduct = productRepository.GetCouponProductList(new RB_DiscountCoupon_Product { TenantId = model.TenantId, MallBaseId = model.MallBaseId, DiscountCouponId = id });
////if (listProduct != null && listProduct.Any())
////{
...
...
@@ -223,6 +224,7 @@ namespace Mall.Module.MarketingCenter
if
(
model
.
ProductList
!=
null
&&
model
.
ProductList
.
Any
())
{
model
.
ProductList
.
ForEach
(
x
=>
x
.
DiscountCouponType
=
model
.
UseType
);
model
.
ProductList
.
ForEach
(
x
=>
x
.
MallBaseId
=
model
.
MallBaseId
);
model
.
ProductList
.
ForEach
(
x
=>
x
.
TenantId
=
model
.
TenantId
);
model
.
ProductList
.
ForEach
(
x
=>
x
.
CreateDate
=
model
.
CreateDate
);
...
...
@@ -412,6 +414,19 @@ namespace Mall.Module.MarketingCenter
}
return
flag
;
}
/// <summary>
/// 根据用户id和商品分类以及商品id获取未使用的优惠券信息
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
RB_DiscountCoupon_Extend
>
GetNoUseCouponList
(
RB_DiscountCoupon_Extend
query
)
{
return
discountCouponRepository
.
GetNoUseCouponList
(
query
);
}
#
endregion
#
region
自动发放优惠券规则
...
...
@@ -439,7 +454,7 @@ namespace Mall.Module.MarketingCenter
public
List
<
RB_Coupon_SelfMotion_Extend
>
GettRepositoryList
(
RB_Coupon_SelfMotion_Extend
query
)
{
var
list
=
selfMotionRepository
.
GettRepositoryList
(
query
);
return
list
;
}
...
...
@@ -486,7 +501,7 @@ namespace Mall.Module.MarketingCenter
{
id
=
model
.
ID
;
flag
=
selfMotionRepository
.
Update
(
model
,
trans
);
// var listProduct = selfMotionMemberRepository.GetListRepository(new RB_Coupon_SelfMotionMember_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, SelfMotionId = id });
// var listProduct = selfMotionMemberRepository.GetListRepository(new RB_Coupon_SelfMotionMember_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, SelfMotionId = id });
//if (listProduct != null && listProduct.Any())
//{
// foreach (var item in model.UserList)
...
...
@@ -514,7 +529,7 @@ namespace Mall.Module.MarketingCenter
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Coupon_SelfMotionMember
.
MallBaseId
),
FiledValue
=
model
.
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Coupon_SelfMotionMember
.
TenantId
),
FiledValue
=
model
.
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
selfMotionMemberRepository
.
Update
(
fileds
,
whereHelpers
,
trans
);
selfMotionMemberRepository
.
Update
(
fileds
,
whereHelpers
,
trans
);
if
(
model
.
UserList
!=
null
&&
model
.
UserList
.
Any
())
...
...
Mall.Repository/MarketingCenter/RB_DiscountCouponRepository.cs
View file @
b67b8eac
using
Mall.Model.Entity.MarketingCenter
;
using
Mall.Model.Entity.User
;
using
Mall.Model.Extend.MarketingCenter
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -7,12 +8,18 @@ using System.Text;
namespace
Mall.Repository.MarketingCenter
{
public
class
RB_DiscountCouponRepository
:
RepositoryBase
<
RB_DiscountCoupon
>
public
class
RB_DiscountCouponRepository
:
RepositoryBase
<
RB_DiscountCoupon
>
{
/// <summary>
/// 表名称
/// </summary>
public
string
TableName
{
get
{
return
nameof
(
RB_DiscountCoupon
);
}
}
/// <summary>
/// 表名称
/// </summary>
public
string
discountCouponTableName
{
get
{
return
nameof
(
RB_Member_DiscountCoupon
);
}
}
/// <summary>
/// 卡券信息列表
/// </summary>
...
...
@@ -71,12 +78,111 @@ namespace Mall.Repository.MarketingCenter
{
builder
.
Append
(
$" AND
{
nameof
(
RB_DiscountCoupon_Extend
.
Name
)}
like '%
{
query
.
Name
}
%'"
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
CouponIds
))
if
(!
string
.
IsNullOrEmpty
(
query
.
CouponIds
))
{
builder
.
Append
(
$" AND
{
nameof
(
RB_DiscountCoupon_Extend
.
ID
)}
in(
{
query
.
CouponIds
}
)"
);
}
}
return
Get
<
RB_DiscountCoupon_Extend
>(
builder
.
ToString
()).
ToList
();
}
/// <summary>
/// 根据用户id和商品分类以及商品id获取未使用的优惠券信息
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
RB_DiscountCoupon_Extend
>
GetNoUseCouponList
(
RB_DiscountCoupon_Extend
query
)
{
string
where
=
" and a.StartDate<NOW() and a.EndDate>NOW() and b.`Status`=0 "
;
string
goodsClassWhere
=
""
;
//分类
string
goodsWhere
=
""
;
//商品
string
allWhere
=
""
;
//通用
if
(
query
!=
null
)
{
if
(
query
.
TenantId
>
0
)
{
where
+=
$" AND b.
{
nameof
(
RB_DiscountCoupon_Extend
.
TenantId
)}
=
{
query
.
TenantId
}
"
;
}
if
(
query
.
MallBaseId
>
0
)
{
where
+=
$" AND b.
{
nameof
(
RB_DiscountCoupon_Extend
.
MallBaseId
)}
=
{
query
.
MallBaseId
}
"
;
}
if
(
query
.
UserId
>
0
)
{
where
+=
$" AND a.
{
nameof
(
RB_DiscountCoupon_Extend
.
UserId
)}
=
{
query
.
UserId
}
"
;
}
if
(
query
.
ProductList
!=
null
&&
query
.
ProductList
.
Any
())
{
List
<
int
>
allGoodsClass
=
new
List
<
int
>();
foreach
(
var
item
in
query
.
ProductList
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
goodsWhere
))
{
goodsWhere
+=
$" or (c.ProductId =
{
item
.
ProductId
}
and b.MinConsumePrice<=
{
item
.
GoodsPrice
}
) "
;
}
else
{
goodsWhere
+=
$" (c.ProductId =
{
item
.
ProductId
}
and b.MinConsumePrice<=
{
item
.
GoodsPrice
}
) "
;
}
allGoodsClass
.
AddRange
(
item
.
GoodsClassId
.
ToList
());
}
goodsWhere
=
" and ("
+
goodsWhere
+
")"
;
//分类
var
goodsClassList
=
allGoodsClass
.
GroupBy
(
x
=>
x
);
foreach
(
var
item
in
goodsClassList
)
{
decimal
nowPrice
=
0
;
foreach
(
var
classItem
in
query
.
ProductList
)
{
if
(
classItem
.
GoodsClassId
.
Any
(
x
=>
x
==
item
.
Key
))
{
nowPrice
+=
classItem
.
GoodsPrice
;
}
}
if
(!
string
.
IsNullOrWhiteSpace
(
goodsClassWhere
))
{
goodsClassWhere
+=
$" or (c.ProductId =
{
item
.
Key
}
and b.MinConsumePrice<=
{
nowPrice
}
) "
;
}
else
{
goodsClassWhere
+=
$" (c.ProductId =
{
item
.
Key
}
and b.MinConsumePrice<=
{
nowPrice
}
) "
;
}
}
goodsClassWhere
=
" and ("
+
goodsClassWhere
+
")"
;
decimal
allPrice
=
query
.
ProductList
.
Sum
(
x
=>
x
.
GoodsPrice
);
allWhere
=
$" and b.MinConsumePrice<=
{
allPrice
}
"
;
}
}
string
sql
=
@
$" SELECT a.ID,a.UserId,b.`Name`,b.CouponType,b.UseType,b.MinConsumePrice,b.DiscountsPrice,b.MaxDiscountsPrice,b.Describe,a.StartDate,a.EndDate from rb_discountcoupon as b
LEFT
JOIN
rb_discountcoupon_product
as
c
on
b
.
ID
=
c
.
DiscountCouponId
LEFT
JOIN
rb_member_discountcoupon
as
a
on
a
.
CouponId
=
b
.
ID
where
b
.
UseType
=
1
and
c
.
`
Status
`
=
0
{
where
}
{
goodsClassWhere
}
UNION
ALL
SELECT
a
.
ID
,
a
.
UserId
,
b
.
`
Name
`
,
b
.
CouponType
,
b
.
UseType
,
b
.
MinConsumePrice
,
b
.
DiscountsPrice
,
b
.
MaxDiscountsPrice
,
b
.
Describe
,
a
.
StartDate
,
a
.
EndDate
from
rb_discountcoupon
as
b
LEFT
JOIN
rb_discountcoupon_product
as
c
on
b
.
ID
=
c
.
DiscountCouponId
LEFT
JOIN
rb_member_discountcoupon
as
a
on
a
.
CouponId
=
b
.
ID
where
b
.
UseType
=
2
and
c
.
`
Status
`
=
0
{
where
}
{
goodsWhere
}
UNION
all
SELECT
a
.
ID
,
a
.
UserId
,
b
.
`
Name
`
,
b
.
CouponType
,
b
.
UseType
,
b
.
MinConsumePrice
,
b
.
DiscountsPrice
,
b
.
MaxDiscountsPrice
,
b
.
Describe
,
a
.
StartDate
,
a
.
EndDate
from
rb_discountcoupon
as
b
LEFT
JOIN
rb_member_discountcoupon
as
a
on
a
.
CouponId
=
b
.
ID
where
b
.
UseType
=
3
{
where
}
{
allWhere
}
";
return
Get
<
RB_DiscountCoupon_Extend
>(
sql
).
ToList
();
}
}
}
Mall.Repository/User/RB_Member_CouponRepository.cs
View file @
b67b8eac
...
...
@@ -55,13 +55,16 @@ namespace Mall.Repository.User
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UserId
)}
=
{
query
.
UserId
}
"
);
}
if
(
query
.
CouponId
>
0
)
{
if
(
query
.
CouponId
>
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
CouponId
)}
=
{
query
.
CouponId
}
"
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
CouponIds
))
{
if
(!
string
.
IsNullOrEmpty
(
query
.
CouponIds
))
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
CouponId
)}
in (
{
query
.
CouponIds
}
)"
);
}
if
(
query
.
UseState
>=
0
)
{
if
(
query
.
UseState
>=
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UseState
)}
=
{
query
.
UseState
}
"
);
}
}
...
...
@@ -69,6 +72,8 @@ namespace Mall.Repository.User
return
Get
<
RB_Member_DiscountCoupon_Extend
>(
sql
).
ToList
();
}
/// <summary>
/// 会员优惠券
/// </summary>
...
...
Mall.WebApi/Controllers/MarketingCenter/AppletCouponController.cs
0 → 100644
View file @
b67b8eac
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Mall.Common
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.MarketingCenter
;
using
Mall.Module.MarketingCenter
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.MarketingCenter
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
AppletCouponController
:
BaseController
{
private
CouponModule
couponModule
=
new
CouponModule
();
/// <summary>
/// 设置购物车数量
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetNoUseCouponList
()
{
var
req
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
JObject
prams
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
var
query
=
JsonConvert
.
DeserializeObject
<
RB_DiscountCoupon_Extend
>(
RequestParm
.
msg
.
ToString
());
if
(
userInfo
==
null
)
{
userInfo
.
TenantId
=
1
;
userInfo
.
MallBaseId
=
1
;
userInfo
.
UserId
=
3
;
}
query
.
TenantId
=
userInfo
.
TenantId
;
query
.
MallBaseId
=
userInfo
.
MallBaseId
;
query
.
UserId
=
userInfo
.
UserId
;
var
list
=
couponModule
.
GetNoUseCouponList
(
query
);
var
result
=
list
.
Select
(
x
=>
new
{
x
.
ID
,
StartDate
=
x
.
StartDate
.
HasValue
?
x
.
StartDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
EndDate
=
x
.
EndDate
.
HasValue
?
x
.
EndDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
x
.
Name
,
x
.
Describe
,
x
.
MinConsumePrice
,
x
.
CouponType
,
x
.
MaxDiscountsPrice
,
x
.
UseType
});
return
ApiResult
.
Success
(
""
,
result
);
}
}
}
\ 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