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
e7cef4c8
Commit
e7cef4c8
authored
Apr 02, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
2abd6a0d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
617 additions
and
64 deletions
+617
-64
RB_Education_EduSell.cs
Mall.Model/Entity/Education/RB_Education_EduSell.cs
+5
-0
RB_Member_CoffeeLog_Extend.cs
Mall.Model/Extend/Coffee/RB_Member_CoffeeLog_Extend.cs
+70
-0
ActivityModule.cs
Mall.Module.Education/ActivityModule.cs
+42
-42
CoffeeModule.cs
Mall.Module.Education/CoffeeModule.cs
+297
-16
RB_Member_CoffeeLogRepository.cs
Mall.Repository/Coffee/RB_Member_CoffeeLogRepository.cs
+69
-0
RB_AccountRepository.cs
Mall.Repository/Education/RB_AccountRepository.cs
+5
-4
AppletEducationController.cs
...WebApi/Controllers/Education/AppletEducationController.cs
+6
-2
CoffeeController.cs
Mall.WebApi/Controllers/Education/CoffeeController.cs
+123
-0
No files found.
Mall.Model/Entity/Education/RB_Education_EduSell.cs
View file @
e7cef4c8
...
...
@@ -76,5 +76,10 @@ namespace Mall.Model.Entity.Education
/// 定时器是否解绑赠送 1是
/// </summary>
public
int
IsInitFreeCoffee
{
get
;
set
;
}
/// <summary>
/// 学员是否内部员工 1是
/// </summary>
public
int
StuIsEmp
{
get
;
set
;
}
}
}
Mall.Model/Extend/Coffee/RB_Member_CoffeeLog_Extend.cs
View file @
e7cef4c8
...
...
@@ -10,6 +10,76 @@ namespace Mall.Model.Extend.Coffee
/// </summary>
public
class
RB_Member_CoffeeLog_Extend
:
RB_Member_CoffeeLog
{
/// <summary>
/// 开始时间
/// </summary>
public
string
StartTime
{
get
;
set
;
}
/// <summary>
/// 结束时间
/// </summary>
public
string
EndTime
{
get
;
set
;
}
/// <summary>
/// 查询类型 1日报表 2月报表 3年报表
/// </summary>
public
int
SelectType
{
get
;
set
;
}
/// <summary>
/// 日期
/// </summary>
public
string
Date
{
get
;
set
;
}
/// <summary>
/// 来宾赠送
/// </summary>
public
int
LBFreeNum
{
get
;
set
;
}
/// <summary>
/// 来宾购买
/// </summary>
public
int
LBBuyNum
{
get
;
set
;
}
/// <summary>
/// 员工赠送
/// </summary>
public
int
EmpFreeNum
{
get
;
set
;
}
/// <summary>
/// 员工购买
/// </summary>
public
int
EmpBuyNum
{
get
;
set
;
}
/// <summary>
/// 学生赠送
/// </summary>
public
int
StuFreeNum
{
get
;
set
;
}
/// <summary>
/// 学生购买
/// </summary>
public
int
StuBuyNum
{
get
;
set
;
}
/// <summary>
/// 收款
/// </summary>
public
decimal
Income
{
get
;
set
;
}
/// <summary>
/// 核销人
/// </summary>
public
string
EmpName
{
get
;
set
;
}
/// <summary>
/// 员工类型 1员工 2学员 3来宾
/// </summary>
public
int
EmpType
{
get
;
set
;
}
/// <summary>
/// 微信名称
/// </summary>
public
string
UserName
{
get
;
set
;
}
/// <summary>
/// 微信头像
/// </summary>
public
string
UserIcon
{
get
;
set
;
}
/// <summary>
/// 学生/内部人员名称
/// </summary>
public
string
EmpStuName
{
get
;
set
;
}
}
}
Mall.Module.Education/ActivityModule.cs
View file @
e7cef4c8
...
...
@@ -628,9 +628,9 @@ namespace Mall.Module.Education
/// </summary>
/// <param name="accountId"></param>
/// <returns></returns>
public
bool
GetEduStuLearning
(
int
accountId
)
public
bool
GetEduStuLearning
(
int
accountId
,
out
int
courseId
)
{
return
RB_AccountRepository
.
GetStuLearningCourse
(
accountId
,
out
_
)
>
0
;
return
RB_AccountRepository
.
GetStuLearningCourse
(
accountId
,
out
_
,
out
courseId
)
>
0
;
}
/// <summary>
...
...
@@ -646,46 +646,46 @@ namespace Mall.Module.Education
flag
=
education_EduSellRepository
.
Insert
(
model
)
>
0
;
if
(
flag
)
{
//绑定成功 直接初始化 免费咖啡劵
if
(
model
.
Type
==
1
)
{
//内部人员 直接初始化 内部人员的咖啡劵信息
int
FreeNum
=
Convert
.
ToInt32
(
dictvalueRepository
.
GetList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Dictvalue_Extend
()
{
MallBaseId
=
model
.
MallBaseId
??
0
,
DictKey
=
"Edu_CoffeeCoupons_EmpFree"
}).
FirstOrDefault
()?.
Content
??
"0"
);
if
(
FreeNum
>
0
)
{
var
cmodel
=
new
Model
.
Extend
.
Coffee
.
RB_Member_CoffeeCoupons_Extend
()
{
Id
=
0
,
CreateDate
=
DateTime
.
Now
,
FreeNum
=
FreeNum
,
MallBaseId
=
model
.
MallBaseId
??
0
,
SurplusBugNum
=
0
,
TotalBuyNum
=
0
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
model
.
UserId
};
member_CoffeeCouponsRepository
.
Insert
(
cmodel
);
}
}
else
if
(
model
.
Type
==
2
)
{
//学生 要看是否还有正在学习的课程 有的话 可初始化免费的咖啡劵
int
FreeNum
=
Convert
.
ToInt32
(
dictvalueRepository
.
GetList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Dictvalue_Extend
()
{
MallBaseId
=
model
.
MallBaseId
??
0
,
DictKey
=
"Edu_CoffeeCoupons_Free"
}).
FirstOrDefault
()?.
Content
??
"0"
);
if
(
FreeNum
>
0
)
{
var
cmodel
=
new
Model
.
Extend
.
Coffee
.
RB_Member_CoffeeCoupons_Extend
()
{
Id
=
0
,
CreateDate
=
DateTime
.
Now
,
FreeNum
=
FreeNum
,
MallBaseId
=
model
.
MallBaseId
??
0
,
SurplusBugNum
=
0
,
TotalBuyNum
=
0
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
model
.
UserId
};
member_CoffeeCouponsRepository
.
Insert
(
cmodel
);
}
}
//
if (model.Type == 1)
//
{
//
//内部人员 直接初始化 内部人员的咖啡劵信息
//
int FreeNum = Convert.ToInt32(dictvalueRepository.GetList(new Model.Extend.BaseSetUp.RB_Dictvalue_Extend() { MallBaseId = model.MallBaseId ?? 0, DictKey = "Edu_CoffeeCoupons_EmpFree" }).FirstOrDefault()?.Content ?? "0");
//
if (FreeNum > 0)
//
{
//
var cmodel = new Model.Extend.Coffee.RB_Member_CoffeeCoupons_Extend()
//
{
//
Id = 0,
//
CreateDate = DateTime.Now,
//
FreeNum = FreeNum,
//
MallBaseId = model.MallBaseId ?? 0,
//
SurplusBugNum = 0,
//
TotalBuyNum = 0,
//
UpdateDate = DateTime.Now,
//
UserId = model.UserId
//
};
//
member_CoffeeCouponsRepository.Insert(cmodel);
//
}
//
}
//
else if (model.Type == 2)
//
{
//
//学生 要看是否还有正在学习的课程 有的话 可初始化免费的咖啡劵
//
int FreeNum = Convert.ToInt32(dictvalueRepository.GetList(new Model.Extend.BaseSetUp.RB_Dictvalue_Extend() { MallBaseId = model.MallBaseId??0, DictKey = "Edu_CoffeeCoupons_Free" }).FirstOrDefault()?.Content ?? "0");
//
if (FreeNum > 0)
//
{
//
var cmodel = new Model.Extend.Coffee.RB_Member_CoffeeCoupons_Extend()
//
{
//
Id = 0,
//
CreateDate = DateTime.Now,
//
FreeNum = FreeNum,
//
MallBaseId = model.MallBaseId ?? 0,
//
SurplusBugNum = 0,
//
TotalBuyNum = 0,
//
UpdateDate = DateTime.Now,
//
UserId = model.UserId
//
};
//
member_CoffeeCouponsRepository.Insert(cmodel);
//
}
//
}
}
}
else
...
...
Mall.Module.Education/CoffeeModule.cs
View file @
e7cef4c8
...
...
@@ -101,7 +101,7 @@ namespace Mall.Module.Education
else
if
(
esModel
.
Type
==
2
)
{
//学生 要看是否还有正在学习的课程 有的话 可初始化免费的咖啡劵
int
learningNum
=
accountRepository
.
GetStuLearningCourse
(
esModel
.
EduSellId
,
out
int
FreeCoffeeNum
);
int
learningNum
=
accountRepository
.
GetStuLearningCourse
(
esModel
.
EduSellId
,
out
int
FreeCoffeeNum
,
out
_
);
if
(
learningNum
>
0
)
{
int
FreeNum
=
Convert
.
ToInt32
(
dictvalueRepository
.
GetList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Dictvalue_Extend
()
{
MallBaseId
=
userInfo
.
MallBaseId
,
DictKey
=
"Edu_CoffeeCoupons_Free"
}).
FirstOrDefault
()?.
Content
??
"0"
);
...
...
@@ -123,7 +123,6 @@ namespace Mall.Module.Education
}
}
}
}
if
(
cmodel
==
null
)
{
cmodel
=
new
RB_Member_CoffeeCoupons_Extend
()
...
...
@@ -140,10 +139,11 @@ namespace Mall.Module.Education
cmodel
.
Id
=
member_CoffeeCouponsRepository
.
Insert
(
cmodel
);
}
}
}
else
{
if
(
esModel
!=
null
&&
esModel
.
IsInitFreeCoffee
==
1
&&
esModel
.
Type
==
2
)
{
//该用户咖啡劵没更新赠送 验证一下 其是否还有正在学习的课程 有的话 恢复赠送咖啡劵
int
learningNum
=
accountRepository
.
GetStuLearningCourse
(
esModel
.
EduSellId
,
out
int
FreeCoffeeNum
);
int
learningNum
=
accountRepository
.
GetStuLearningCourse
(
esModel
.
EduSellId
,
out
int
FreeCoffeeNum
,
out
_
);
if
(
learningNum
>
0
)
{
int
FreeNum
=
Convert
.
ToInt32
(
dictvalueRepository
.
GetList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Dictvalue_Extend
()
{
MallBaseId
=
userInfo
.
MallBaseId
,
DictKey
=
"Edu_CoffeeCoupons_Free"
}).
FirstOrDefault
()?.
Content
??
"0"
);
...
...
@@ -366,5 +366,286 @@ namespace Mall.Module.Education
model
.
Number
};
}
#
region
咖啡劵统计
/// <summary>
/// 获取咖啡劵统计
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
object
GetCoffeeStatistics
(
RB_Member_CoffeeLog_Extend
demodel
)
{
DateTime
STime
=
Convert
.
ToDateTime
(
demodel
.
StartTime
+
(
demodel
.
SelectType
==
2
?
"-01"
:
demodel
.
SelectType
==
3
?
"-01-01"
:
""
));
DateTime
ETime
=
Convert
.
ToDateTime
(
demodel
.
EndTime
+
(
demodel
.
SelectType
==
2
?
"-01"
:
demodel
.
SelectType
==
3
?
"-01-01"
:
""
));
if
(
demodel
.
SelectType
==
2
)
{
demodel
.
StartTime
=
STime
.
ToString
(
"yyyy-MM-dd"
);
demodel
.
EndTime
=
ETime
.
AddMonths
(
1
).
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd"
);
}
else
if
(
demodel
.
SelectType
==
3
)
{
demodel
.
StartTime
=
STime
.
ToString
(
"yyyy-MM-dd"
);
demodel
.
EndTime
=
ETime
.
AddYears
(
1
).
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd"
);
}
//查询数据
var
list
=
member_CoffeeLogRepository
.
GetCoffeeStatisticsToDay
(
demodel
,
demodel
.
SelectType
);
if
(
list
.
Any
())
{
//查询核销人
string
accountIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
CreateBy
).
Distinct
());
var
elist
=
accountRepository
.
GetEmployeeListRepository
(
new
Model
.
Extend
.
Education
.
Employee_ViewModel
()
{
QIds
=
accountIds
});
foreach
(
var
item
in
list
)
{
item
.
EmpName
=
elist
.
Where
(
x
=>
x
.
Id
==
item
.
CreateBy
).
FirstOrDefault
()?.
EmployeeName
??
"-"
;
}
}
//查询当日收款
var
SKList
=
member_CoffeeLogRepository
.
GetCoffeeMoneyStatisticsToDay
(
demodel
,
demodel
.
SelectType
);
List
<
object
>
RList
=
new
List
<
object
>();
//开始遍历组装数据
while
(
true
)
{
string
DateStr
=
STime
.
ToString
(
"yyyy-MM-dd"
);
if
(
demodel
.
SelectType
==
2
)
{
DateStr
=
STime
.
ToString
(
"yyyy-MM"
);
}
else
if
(
demodel
.
SelectType
==
3
)
{
DateStr
=
STime
.
ToString
(
"yyyy"
);
}
var
clist
=
list
.
Where
(
x
=>
x
.
Date
==
DateStr
).
ToList
();
var
slist
=
SKList
.
Where
(
x
=>
x
.
Date
==
DateStr
).
ToList
();
RList
.
Add
(
new
{
Date
=
DateStr
,
Income
=
slist
.
Sum
(
x
=>
x
.
Income
),
Total
=
clist
.
Sum
(
x
=>
x
.
LBFreeNum
+
x
.
LBBuyNum
+
x
.
StuBuyNum
+
x
.
StuFreeNum
+
x
.
EmpBuyNum
+
x
.
EmpFreeNum
),
CList
=
clist
.
Select
(
x
=>
new
{
x
.
EmpName
,
x
.
EmpBuyNum
,
x
.
EmpFreeNum
,
x
.
LBBuyNum
,
x
.
LBFreeNum
,
x
.
StuBuyNum
,
x
.
StuFreeNum
})
});
if
(
STime
==
ETime
)
{
break
;
}
if
(
demodel
.
SelectType
==
1
)
{
STime
=
STime
.
AddDays
(
1
);
}
else
if
(
demodel
.
SelectType
==
2
)
{
STime
=
STime
.
AddMonths
(
1
);
}
else
{
STime
=
STime
.
AddYears
(
1
);
}
}
return
RList
;
}
/// <summary>
/// 咖啡劵导出
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
ExcelDataSource
>
GetCoffeeStatisticsToExcel
(
RB_Member_CoffeeLog_Extend
demodel
)
{
DateTime
STime
=
Convert
.
ToDateTime
(
demodel
.
StartTime
+
(
demodel
.
SelectType
==
2
?
"-01"
:
demodel
.
SelectType
==
3
?
"-01-01"
:
""
));
DateTime
ETime
=
Convert
.
ToDateTime
(
demodel
.
EndTime
+
(
demodel
.
SelectType
==
2
?
"-01"
:
demodel
.
SelectType
==
3
?
"-01-01"
:
""
));
if
(
demodel
.
SelectType
==
2
)
{
demodel
.
StartTime
=
STime
.
ToString
(
"yyyy-MM-dd"
);
demodel
.
EndTime
=
ETime
.
AddMonths
(
1
).
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd"
);
}
else
if
(
demodel
.
SelectType
==
3
)
{
demodel
.
StartTime
=
STime
.
ToString
(
"yyyy-MM-dd"
);
demodel
.
EndTime
=
ETime
.
AddYears
(
1
).
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd"
);
}
//查询数据
var
list
=
member_CoffeeLogRepository
.
GetCoffeeStatisticsToDay
(
demodel
,
demodel
.
SelectType
);
if
(
list
.
Any
())
{
//查询核销人
string
accountIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
CreateBy
).
Distinct
());
var
elist
=
accountRepository
.
GetEmployeeListRepository
(
new
Model
.
Extend
.
Education
.
Employee_ViewModel
()
{
QIds
=
accountIds
});
foreach
(
var
item
in
list
)
{
item
.
EmpName
=
elist
.
Where
(
x
=>
x
.
Id
==
item
.
CreateBy
).
FirstOrDefault
()?.
EmployeeName
??
"-"
;
}
}
//查询当日收款
var
SKList
=
member_CoffeeLogRepository
.
GetCoffeeMoneyStatisticsToDay
(
demodel
,
demodel
.
SelectType
);
List
<
ExcelDataSource
>
RList
=
new
List
<
ExcelDataSource
>();
//开始遍历组装数据
while
(
true
)
{
string
DateStr
=
STime
.
ToString
(
"yyyy-MM-dd"
);
if
(
demodel
.
SelectType
==
2
)
{
DateStr
=
STime
.
ToString
(
"yyyy-MM"
);
}
else
if
(
demodel
.
SelectType
==
3
)
{
DateStr
=
STime
.
ToString
(
"yyyy"
);
}
var
clist
=
list
.
Where
(
x
=>
x
.
Date
==
DateStr
).
ToList
();
var
slist
=
SKList
.
Where
(
x
=>
x
.
Date
==
DateStr
).
ToList
();
if
(
clist
.
Any
())
{
int
rowSpan
=
clist
.
Count
();
for
(
var
i
=
0
;
i
<
rowSpan
;
i
++)
{
var
cmodel
=
clist
[
i
];
if
(
i
==
0
)
{
ExcelDataSource
datarow
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
DateStr
){
Rowspan
=
rowSpan
},
new
ExcelColumn
(
value
:
cmodel
.
EmpName
){
},
new
ExcelColumn
(
value
:
cmodel
.
EmpFreeNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
EmpBuyNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
StuFreeNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
StuBuyNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
LBFreeNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
LBBuyNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
slist
.
Sum
(
x
=>
x
.
Income
).
ToString
(
"#0.00"
)){
Rowspan
=
rowSpan
},
new
ExcelColumn
(
value
:
clist
.
Sum
(
x
=>
x
.
LBFreeNum
+
x
.
LBBuyNum
+
x
.
StuBuyNum
+
x
.
StuFreeNum
+
x
.
EmpBuyNum
+
x
.
EmpFreeNum
).
ToString
()){
Rowspan
=
rowSpan
},
},
ColumnHight
=
30
};
RList
.
Add
(
datarow
);
}
else
{
ExcelDataSource
datarow
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
cmodel
.
EmpName
){
},
new
ExcelColumn
(
value
:
cmodel
.
EmpFreeNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
EmpBuyNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
StuFreeNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
StuBuyNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
LBFreeNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
cmodel
.
LBBuyNum
.
ToString
()){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
},
ColumnHight
=
30
};
RList
.
Add
(
datarow
);
}
}
}
else
{
ExcelDataSource
datarow
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
DateStr
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
slist
.
Sum
(
x
=>
x
.
Income
).
ToString
(
"#0.00"
)){
},
new
ExcelColumn
(
value
:
""
){
},
},
ColumnHight
=
30
};
RList
.
Add
(
datarow
);
}
if
(
STime
==
ETime
)
{
break
;
}
if
(
demodel
.
SelectType
==
1
)
{
STime
=
STime
.
AddDays
(
1
);
}
else
if
(
demodel
.
SelectType
==
2
)
{
STime
=
STime
.
AddMonths
(
1
);
}
else
{
STime
=
STime
.
AddYears
(
1
);
}
}
return
RList
;
}
/// <summary>
/// 获取咖啡劵消费列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Member_CoffeeLog_Extend
>
GetCoffeeCouponsPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Member_CoffeeLog_Extend
demodel
)
{
var
list
=
member_CoffeeLogRepository
.
GetPageList
(
pageIndex
,
pageSize
,
out
count
,
demodel
);
if
(
list
.
Any
())
{
var
userIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
UserId
+
","
+
x
.
CreateBy
));
var
memberList
=
member_UserRepository
.
GetList
(
new
Model
.
Extend
.
User
.
RB_Member_User_Extend
()
{
MallBaseId
=
demodel
.
MallBaseId
,
UserIds
=
userIds
});
var
eduSellList
=
education_EduSellRepository
.
GetEducationStuList
(
new
Model
.
Extend
.
Education
.
RB_Education_EduSell_Extend
()
{
MallBaseId
=
demodel
.
MallBaseId
,
Ids
=
userIds
},
true
);
List
<
Model
.
Extend
.
Education
.
Employee_ViewModel
>
empList
=
new
List
<
Model
.
Extend
.
Education
.
Employee_ViewModel
>();
List
<
Model
.
Extend
.
Education
.
RB_Account_ViewModel
>
StuList
=
new
List
<
Model
.
Extend
.
Education
.
RB_Account_ViewModel
>();
if
(
eduSellList
.
Any
())
{
string
EmpIds
=
string
.
Join
(
","
,
eduSellList
.
Where
(
x
=>
x
.
Type
==
1
).
Select
(
x
=>
x
.
EduSellId
));
string
StuIds
=
string
.
Join
(
","
,
eduSellList
.
Where
(
x
=>
x
.
Type
==
2
).
Select
(
x
=>
x
.
EduSellId
));
if
(!
string
.
IsNullOrEmpty
(
EmpIds
))
{
empList
=
accountRepository
.
GetEmployeeListRepository
(
new
Model
.
Extend
.
Education
.
Employee_ViewModel
()
{
QIds
=
EmpIds
});
}
if
(!
string
.
IsNullOrEmpty
(
StuIds
))
{
StuList
=
accountRepository
.
GetStudentExt
(
new
Model
.
Extend
.
Education
.
RB_Account_ViewModel
()
{
QIds
=
StuIds
});
}
}
foreach
(
var
item
in
list
)
{
item
.
UserName
=
memberList
.
Where
(
x
=>
x
.
Id
==
item
.
UserId
).
FirstOrDefault
()?.
Name
??
""
;
item
.
UserIcon
=
memberList
.
Where
(
x
=>
x
.
Id
==
item
.
UserId
).
FirstOrDefault
()?.
Photo
??
""
;
var
eduSellModel
=
eduSellList
.
Where
(
x
=>
x
.
UserId
==
item
.
UserId
).
FirstOrDefault
();
if
(
eduSellModel
==
null
)
{
item
.
EmpType
=
3
;
}
else
{
if
(
eduSellModel
.
Type
==
1
)
{
item
.
EmpStuName
=
empList
.
Where
(
x
=>
x
.
Id
==
eduSellModel
.
EduSellId
).
FirstOrDefault
()?.
EmployeeName
??
""
;
}
else
{
item
.
EmpStuName
=
StuList
.
Where
(
x
=>
x
.
Id
==
eduSellModel
.
EduSellId
).
FirstOrDefault
()?.
AccountName
??
""
;
}
if
(
eduSellModel
.
Type
==
2
&&
eduSellModel
.
StuIsEmp
==
0
)
{
item
.
EmpType
=
2
;
}
else
{
item
.
EmpType
=
1
;
}
}
var
createByModel
=
eduSellList
.
Where
(
x
=>
x
.
UserId
==
item
.
CreateBy
).
FirstOrDefault
();
if
(
createByModel
!=
null
&&
createByModel
.
Type
==
1
)
{
item
.
EmpName
=
empList
.
Where
(
x
=>
x
.
Id
==
createByModel
.
EduSellId
).
FirstOrDefault
()?.
EmployeeName
??
""
;
}
}
}
return
list
;
}
#
endregion
}
}
Mall.Repository/Coffee/RB_Member_CoffeeLogRepository.cs
View file @
e7cef4c8
...
...
@@ -38,6 +38,18 @@ WHERE 1=1
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_Member_CoffeeLog_Extend
.
Type
),
query
.
Type
);
}
if
(
query
.
BuyType
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_Member_CoffeeLog_Extend
.
BuyType
),
query
.
BuyType
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
StartTime
))
{
builder
.
AppendFormat
(
" AND {0} >='{1}' "
,
nameof
(
RB_Member_CoffeeLog_Extend
.
CreateDate
),
query
.
StartTime
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
EndTime
))
{
builder
.
AppendFormat
(
" AND {0} <='{1} 23:59:59' "
,
nameof
(
RB_Member_CoffeeLog_Extend
.
CreateDate
),
query
.
EndTime
);
}
}
builder
.
AppendFormat
(
" order by Id desc"
);
return
GetPage
<
RB_Member_CoffeeLog_Extend
>(
pageIndex
,
pageSize
,
out
count
,
builder
.
ToString
()).
ToList
();
...
...
@@ -82,5 +94,62 @@ WHERE 1=1
}
return
Get
<
RB_Member_CoffeeLog_Extend
>(
builder
.
ToString
()).
ToList
();
}
/// <summary>
/// 获取咖啡劵 日报表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Member_CoffeeLog_Extend
>
GetCoffeeStatisticsToDay
(
RB_Member_CoffeeLog_Extend
demodel
,
int
type
)
{
string
DateStr
=
"DATE_FORMAT(c.CreateDate,'%Y-%m-%d')"
;
if
(
type
==
2
)
{
DateStr
=
"DATE_FORMAT(c.CreateDate,'%Y-%m')"
;
}
else
if
(
type
==
3
)
{
DateStr
=
"DATE_FORMAT(c.CreateDate,'%Y')"
;
}
string
sql
=
$@"SELECT e1.EduSellId as CreateBy,
{
DateStr
}
as Date,
case when e.Id is null and c.BuyType =1 then SUM(c.Number) else 0 end AS LBFreeNum,
case when e.Id is null and c.BuyType =2 then SUM(c.Number) else 0 end AS LBBuyNum,
case when (e.Type =1 or (e.Type =2 and e.StuIsEmp =1)) and c.BuyType =1 then SUM(c.Number) else 0 end AS EmpFreeNum,
case when (e.Type =1 or (e.Type =2 and e.StuIsEmp =1)) and c.BuyType =2 then SUM(c.Number) else 0 end AS EmpBuyNum,
case when e.Type =2 and e.StuIsEmp =0 and c.BuyType =1 then SUM(c.Number) else 0 end AS StuFreeNum,
case when e.Type =2 and e.StuIsEmp =0 and c.BuyType =2 then SUM(c.Number) else 0 end AS StuBuyNum
FROM rb_member_coffeelog c
INNER JOIN rb_education_edusell e1 on c.CreateBy = e1.UserId
LEFT JOIN rb_education_edusell e on c.UserId = e.UserId
WHERE c.MallBaseId =
{
demodel
.
MallBaseId
}
and c.CreateDate >='
{
demodel
.
StartTime
}
' and c.CreateDate <='
{
demodel
.
EndTime
}
23:59:59'
GROUP BY e1.EduSellId,
{
DateStr
}
"
;
return
Get
<
RB_Member_CoffeeLog_Extend
>(
sql
).
ToList
();
}
/// <summary>
/// 收款
/// </summary>
/// <param name="demodel"></param>
/// <param name="type"></param>
/// <returns></returns>
public
List
<
RB_Member_CoffeeLog_Extend
>
GetCoffeeMoneyStatisticsToDay
(
RB_Member_CoffeeLog_Extend
demodel
,
int
type
)
{
string
DateStr
=
"DATE_FORMAT(c.CreateDate,'%Y-%m-%d')"
;
if
(
type
==
2
)
{
DateStr
=
"DATE_FORMAT(c.CreateDate,'%Y-%m')"
;
}
else
if
(
type
==
3
)
{
DateStr
=
"DATE_FORMAT(c.CreateDate,'%Y')"
;
}
string
sql
=
$@"SELECT
{
DateStr
}
as Date, SUM(o.Income) AS Income
FROM rb_member_coffeelog c
INNER JOIN rb_goods_order o on c.OrderId = o.OrderId
WHERE c.MallBaseId =
{
demodel
.
MallBaseId
}
and c.CreateDate >='
{
demodel
.
StartTime
}
' and c.CreateDate <='
{
demodel
.
EndTime
}
23:59:59'
GROUP BY
{
DateStr
}
"
;
return
Get
<
RB_Member_CoffeeLog_Extend
>(
sql
).
ToList
();
}
}
}
Mall.Repository/Education/RB_AccountRepository.cs
View file @
e7cef4c8
...
...
@@ -278,9 +278,9 @@ WHERE 1=1 {0}
/// </summary>
/// <param name="accountId"></param>
/// <returns></returns>
public
int
GetStuLearningCourse
(
int
accountId
,
out
int
FreeCoffeeNum
)
public
int
GetStuLearningCourse
(
int
accountId
,
out
int
FreeCoffeeNum
,
out
int
courseId
)
{
string
sql
=
$@"SELECT COUNT(0) AS IsSelectLevelNor,max(
c.FreeCoffeeNum) as FreeCoffeeNum
FROM rb_account a
string
sql
=
$@"SELECT COUNT(0) AS IsSelectLevelNor,max(
IFNULL(c.FreeCoffeeNum,0)) as FreeCoffeeNum, max(o.CourseId) as LeaveStatus
FROM rb_account a
INNER JOIN rb_student s on a.AccountId = s.StuId
INNER JOIN rb_student_orderguest sog on sog.Student_Id = s.StuId
INNER JOIN rb_order_guest og on sog.GuestId = og.Id
...
...
@@ -290,6 +290,7 @@ WHERE a.`Status` =0 and a.AccountType =4 and a.Id ={accountId} and og.GuestState
var
rmodel
=
Get
<
RB_Account_ViewModel
>(
sql
).
FirstOrDefault
();
FreeCoffeeNum
=
rmodel
?.
FreeCoffeeNum
??
0
;
courseId
=
rmodel
?.
LeaveStatus
??
0
;
return
rmodel
?.
IsSelectLevelNor
??
0
;
}
...
...
@@ -300,7 +301,7 @@ WHERE a.`Status` =0 and a.AccountType =4 and a.Id ={accountId} and og.GuestState
/// <returns></returns>
public
List
<
RB_Account_ViewModel
>
GetStuLearningCourseList
(
int
groupId
=
100000
)
{
string
sql
=
$@"SELECT a.Id,a.AccountId,IFNULL(s.StuName,'') AS AccountName,s.StuIcon as UserIcon, max(
c.FreeCoffeeNum
) as FreeCoffeeNum
string
sql
=
$@"SELECT a.Id,a.AccountId,IFNULL(s.StuName,'') AS AccountName,s.StuIcon as UserIcon, max(
IFNULL(c.FreeCoffeeNum,0)
) as FreeCoffeeNum
FROM rb_account a
INNER JOIN rb_student s on a.AccountId = s.StuId
INNER JOIN rb_student_orderguest sog on sog.Student_Id = s.StuId
...
...
Mall.WebApi/Controllers/Education/AppletEducationController.cs
View file @
e7cef4c8
...
...
@@ -2336,7 +2336,7 @@ namespace Mall.WebApi.Controllers.Education
{
return
ApiResult
.
Failed
(
"账户或密码不能为空"
);
}
int
EduSellId
;
int
EduSellId
,
StuIsEmp
=
0
;
if
(
EduType
==
1
)
{
var
model
=
activityModule
.
GetEmployeeListModule
(
new
Employee_ViewModel
()
...
...
@@ -2377,10 +2377,13 @@ namespace Mall.WebApi.Controllers.Education
EduSellId
=
model
.
Id
;
//验证 必须是在学习学生才能绑定
if
(!
activityModule
.
GetEduStuLearning
(
model
.
Id
))
if
(!
activityModule
.
GetEduStuLearning
(
model
.
Id
,
out
int
courseId
))
{
return
ApiResult
.
Failed
(
"未查询到您正在学习的课程,无法绑定信息"
);
}
if
(
courseId
==
1
)
{
StuIsEmp
=
1
;
//内部人员
}
}
else
{
...
...
@@ -2409,6 +2412,7 @@ namespace Mall.WebApi.Controllers.Education
}
eduModel
.
EduSellId
=
EduSellId
;
eduModel
.
Type
=
EduType
;
//学生 跟 内部人员区分
eduModel
.
StuIsEmp
=
StuIsEmp
;
//学员是否内部员工
bool
result
=
activityModule
.
SetEduSellBaseInfo
(
eduModel
);
return
result
?
ApiResult
.
Success
(
"信息绑定成功"
)
:
ApiResult
.
Failed
(
"信息绑定失败"
);
...
...
Mall.WebApi/Controllers/Education/CoffeeController.cs
0 → 100644
View file @
e7cef4c8
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
Dnc.Api.Throttle
;
using
Mall.CacheManager.User
;
using
Mall.Common
;
using
Mall.Common.API
;
using
Mall.Common.Enum
;
using
Mall.Common.Enum.Goods
;
using
Mall.Common.Enum.MarketingCenter
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.Coffee
;
using
Mall.Model.Extend.Product
;
using
Mall.Module.Education
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.Education
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
CoffeeController
:
BaseController
{
private
readonly
CoffeeModule
coffeeModule
=
new
CoffeeModule
();
/// <summary>
/// 获取咖啡劵统计
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetCoffeeStatistics
()
{
RB_Member_CoffeeLog_Extend
demodel
=
JsonHelper
.
DeserializeObject
<
RB_Member_CoffeeLog_Extend
>(
base
.
RequestParm
.
msg
.
ToString
());
demodel
.
MallBaseId
=
RequestParm
.
MallBaseId
;
var
list
=
coffeeModule
.
GetCoffeeStatistics
(
demodel
);
return
ApiResult
.
Success
(
""
,
list
);
}
/// <summary>
/// 咖啡劵统计下载
/// </summary>
[
HttpPost
]
public
FileContentResult
GetCoffeeStatisticsToExcel
()
{
RB_Member_CoffeeLog_Extend
demodel
=
JsonHelper
.
DeserializeObject
<
RB_Member_CoffeeLog_Extend
>(
base
.
RequestParm
.
msg
.
ToString
());
demodel
.
MallBaseId
=
RequestParm
.
MallBaseId
;
string
ExcelName
=
"咖啡统计"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)
+
".xls"
;
List
<
ExcelDataSource
>
slist
=
new
List
<
ExcelDataSource
>();
ExcelDataSource
header
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
"日期"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"核销人"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"员工赠送"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"员工购买"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"学员赠送"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"学员购买"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"来宾赠送"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"来宾购买"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"收款"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"出品杯数"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
}
}
};
slist
.
Add
(
header
);
try
{
List
<
ExcelDataSource
>
list
=
coffeeModule
.
GetCoffeeStatisticsToExcel
(
demodel
);
slist
.
AddRange
(
list
);
var
byteData
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData
,
"application/octet-stream"
,
ExcelName
);
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetFileFromWebApi_requestData: {0}"
,
JsonHelper
.
Serialize
(
RequestParm
)));
var
byteData1
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData1
,
"application/octet-stream"
,
ExcelName
);
}
}
/// <summary>
/// 获取咖啡劵消费分页列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetCoffeeCouponsPageList
()
{
ResultPageModel
pageModel
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
base
.
RequestParm
.
msg
.
ToString
());
RB_Member_CoffeeLog_Extend
demodel
=
JsonHelper
.
DeserializeObject
<
RB_Member_CoffeeLog_Extend
>(
base
.
RequestParm
.
msg
.
ToString
());
demodel
.
MallBaseId
=
RequestParm
.
MallBaseId
;
var
list
=
coffeeModule
.
GetCoffeeCouponsPageList
(
pageModel
.
pageIndex
,
pageModel
.
pageSize
,
out
long
count
,
demodel
);
pageModel
.
count
=
Convert
.
ToInt32
(
count
);
pageModel
.
pageData
=
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
Type
,
x
.
BuyType
,
x
.
Number
,
x
.
Remark
,
x
.
EmpType
,
x
.
UserName
,
x
.
UserIcon
,
x
.
EmpStuName
,
CreateByName
=
x
.
EmpName
,
CreateDate
=
x
.
CreateDate
.
ToString
(
"yyyy-MM-dd HH:mm"
)
});
return
ApiResult
.
Success
(
""
,
pageModel
);
}
}
}
\ 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