Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
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
黄奎
Education
Commits
30626681
Commit
30626681
authored
Sep 03, 2024
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
6cc0ea04
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1525 additions
and
184 deletions
+1525
-184
RB_Order_Course.cs
Edu.Model/Entity/Sell/RB_Order_Course.cs
+1
-1
RB_Order_ViewModel.cs
Edu.Model/ViewModel/Sell/RB_Order_ViewModel.cs
+5
-0
OrderModule.cs
Edu.Module.Course/OrderModule.cs
+1253
-182
RB_Order_CourseRepository.cs
Edu.Repository/Sell/RB_Order_CourseRepository.cs
+45
-0
OrderController.cs
Edu.WebApi/Controllers/Course/OrderController.cs
+221
-1
No files found.
Edu.Model/Entity/Sell/RB_Order_Course.cs
View file @
30626681
...
@@ -15,7 +15,7 @@ namespace Edu.Model.Entity.Sell
...
@@ -15,7 +15,7 @@ namespace Edu.Model.Entity.Sell
/// <summary>
/// <summary>
/// 主键
/// 主键
/// </summary>
/// </summary>
public
int
Order
IdCourse
{
get
;
set
;
}
public
int
Order
CourseId
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 订单编号
/// 订单编号
...
...
Edu.Model/ViewModel/Sell/RB_Order_ViewModel.cs
View file @
30626681
...
@@ -120,6 +120,11 @@ namespace Edu.Model.ViewModel.Sell
...
@@ -120,6 +120,11 @@ namespace Edu.Model.ViewModel.Sell
/// 经理备注
/// 经理备注
/// </summary>
/// </summary>
public
List
<
RB_Order_Remark_ViewModel
>
DirectorRemarkList
{
get
;
set
;
}
public
List
<
RB_Order_Remark_ViewModel
>
DirectorRemarkList
{
get
;
set
;
}
/// <summary>
/// 订单课程 2024-09-02 add by:W
/// </summary>
public
List
<
RB_Order_Course
>
OrderCourseList
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 客人列表
/// 客人列表
/// </summary>
/// </summary>
...
...
Edu.Module.Course/OrderModule.cs
View file @
30626681
...
@@ -34,6 +34,7 @@ using Edu.Repository.StudyAbroad;
...
@@ -34,6 +34,7 @@ using Edu.Repository.StudyAbroad;
using
Edu.Repository.System
;
using
Edu.Repository.System
;
using
Edu.Repository.User
;
using
Edu.Repository.User
;
using
Newtonsoft.Json.Linq
;
using
Newtonsoft.Json.Linq
;
using
RabbitMQ.Client.Framing.Impl
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
...
@@ -241,6 +242,11 @@ namespace Edu.Module.Course
...
@@ -241,6 +242,11 @@ namespace Edu.Module.Course
/// </summary>
/// </summary>
private
readonly
RB_Student_AdvisorRepository
student_AdvisorRepository
=
new
RB_Student_AdvisorRepository
();
private
readonly
RB_Student_AdvisorRepository
student_AdvisorRepository
=
new
RB_Student_AdvisorRepository
();
/// <summary>
/// 订单课程仓储层对象
/// </summary>
private
readonly
RB_Order_CourseRepository
order_CourseRepository
=
new
RB_Order_CourseRepository
();
#
region
日语培训
#
region
日语培训
/// <summary>
/// <summary>
...
@@ -398,6 +404,18 @@ namespace Edu.Module.Course
...
@@ -398,6 +404,18 @@ namespace Edu.Module.Course
return
SetClassOrderCommonModule
(
demodel
,
userInfo
,
isEditOrder
,
out
message
,
out
_
);
return
SetClassOrderCommonModule
(
demodel
,
userInfo
,
isEditOrder
,
out
message
,
out
_
);
}
}
/// <summary>
/// 日语培训下单
/// </summary>
/// <param name="demodel"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
[
TransactionCallHandler
]
public
virtual
bool
SetClassOrderModule_V2
(
RB_Order_ViewModel
demodel
,
UserInfo
userInfo
,
bool
isEditOrder
,
out
string
message
)
{
return
SetClassOrderCommonModule_V2
(
demodel
,
userInfo
,
isEditOrder
,
out
message
,
out
_
);
}
/// <summary>
/// <summary>
/// 日语培训下单(批量)
/// 日语培训下单(批量)
/// </summary>
/// </summary>
...
@@ -418,7 +436,7 @@ namespace Edu.Module.Course
...
@@ -418,7 +436,7 @@ namespace Edu.Module.Course
string
RorderId
=
""
;
string
RorderId
=
""
;
foreach
(
var
item
in
deList
)
foreach
(
var
item
in
deList
)
{
{
flag
=
SetClassOrderCommonModule
(
item
,
userInfo
,
isEditOrder
,
out
message
,
out
int
orderId
,
IsFirstBatch
);
flag
=
SetClassOrderCommonModule
_V2
(
item
,
userInfo
,
isEditOrder
,
out
message
,
out
int
orderId
,
IsFirstBatch
);
if
(
flag
)
{
RorderId
+=
orderId
+
"、"
;
}
if
(
flag
)
{
RorderId
+=
orderId
+
"、"
;
}
else
else
{
{
...
@@ -446,7 +464,37 @@ namespace Edu.Module.Course
...
@@ -446,7 +464,37 @@ namespace Edu.Module.Course
{
{
//检查学员是否存在有效订单
//检查学员是否存在有效订单
int
orderCount
=
studentRepository
.
GetStudentOrderCount
(
x
.
StuId
);
int
orderCount
=
studentRepository
.
GetStudentOrderCount
(
x
.
StuId
);
if
(
model
.
OrderCourseList
!=
null
&&
model
.
OrderCourseList
.
Any
())
{
foreach
(
var
item
in
model
.
OrderCourseList
)
{
var
commissionModel
=
new
RB_Order_ReturnComission_ViewModel
()
{
Id
=
0
,
OrderId
=
model
.
OrderId
,
OrderSourceType
=
x
.
CreateType
,
OrderSourceId
=
x
.
CreateType
==
StuCreateTypeEnum
.
EmployeeInput
?
x
.
CreateBy
:
(
x
.
CreateType
==
StuCreateTypeEnum
.
CustomerInput
?
x
.
CustomerId
:
x
.
StuSourceId
),
Status
=
-
1
,
//下单默认为不可返佣,等待付款完成后更新为待返佣
UnionCashOutId
=
0
,
StuId
=
x
.
StuId
,
CommissionType
=
orderCount
==
0
?
1
:
2
,
SchoolId
=
model
.
School_Id
,
GroupId
=
model
.
Group_Id
,
Remark
=
""
,
};
if
(
model
.
OrderType
==
OrderTypeEnum
.
CourseOrder
)
{
FormatOrderCommissionByCourse
(
ref
commissionModel
,
item
.
CourseId
,
model
.
PreferPrice
-
model
.
DiscountMoney
);
}
else
if
(
model
.
OrderType
==
OrderTypeEnum
.
StudyabroadOrder
)
{
FormatOrderCommissionByStudyabrad
(
ref
commissionModel
,
model
.
SourceId
,
0
);
}
returnComissionRepository
.
Insert
(
commissionModel
);
}
}
else
{
var
commissionModel
=
new
RB_Order_ReturnComission_ViewModel
()
var
commissionModel
=
new
RB_Order_ReturnComission_ViewModel
()
{
{
Id
=
0
,
Id
=
0
,
...
@@ -460,7 +508,6 @@ namespace Edu.Module.Course
...
@@ -460,7 +508,6 @@ namespace Edu.Module.Course
SchoolId
=
model
.
School_Id
,
SchoolId
=
model
.
School_Id
,
GroupId
=
model
.
Group_Id
,
GroupId
=
model
.
Group_Id
,
Remark
=
""
,
Remark
=
""
,
};
};
if
(
model
.
OrderType
==
OrderTypeEnum
.
CourseOrder
)
if
(
model
.
OrderType
==
OrderTypeEnum
.
CourseOrder
)
{
{
...
@@ -471,6 +518,8 @@ namespace Edu.Module.Course
...
@@ -471,6 +518,8 @@ namespace Edu.Module.Course
FormatOrderCommissionByStudyabrad
(
ref
commissionModel
,
model
.
SourceId
,
0
);
FormatOrderCommissionByStudyabrad
(
ref
commissionModel
,
model
.
SourceId
,
0
);
}
}
returnComissionRepository
.
Insert
(
commissionModel
);
returnComissionRepository
.
Insert
(
commissionModel
);
}
});
});
}
}
}
}
...
@@ -507,13 +556,16 @@ namespace Edu.Module.Course
...
@@ -507,13 +556,16 @@ namespace Edu.Module.Course
{
{
List
<
int
>
NotOrder
=
new
List
<
int
>();
List
<
int
>
NotOrder
=
new
List
<
int
>();
//判断 课时进度是否达到发放标准
//判断 课时进度是否达到发放标准
foreach
(
var
item
in
list
.
Where
(
x
=>
x
.
CommissionReType
==
3
))
{
foreach
(
var
item
in
list
.
Where
(
x
=>
x
.
CommissionReType
==
3
))
if
(
item
.
CommissionReValue
>
(
item
.
CompleteHours
/
item
.
TotalHours
)
*
100
)
{
{
if
(
item
.
CommissionReValue
>
(
item
.
CompleteHours
/
item
.
TotalHours
)
*
100
)
{
//未达标
//未达标
NotOrder
.
Add
(
item
.
OrderId
);
NotOrder
.
Add
(
item
.
OrderId
);
}
}
}
}
if
(
NotOrder
.
Any
())
{
if
(
NotOrder
.
Any
())
{
list
=
list
.
Where
(
x
=>
!
NotOrder
.
Contains
(
x
.
OrderId
)).
ToList
();
list
=
list
.
Where
(
x
=>
!
NotOrder
.
Contains
(
x
.
OrderId
)).
ToList
();
}
}
}
}
...
@@ -637,6 +689,7 @@ namespace Edu.Module.Course
...
@@ -637,6 +689,7 @@ namespace Edu.Module.Course
public
void
FormatOrderCommissionByCourse
(
ref
RB_Order_ReturnComission_ViewModel
m
,
int
courseId
,
decimal
orderIncome
)
public
void
FormatOrderCommissionByCourse
(
ref
RB_Order_ReturnComission_ViewModel
m
,
int
courseId
,
decimal
orderIncome
)
{
{
var
courseModel
=
courseRepository
.
GetEntity
(
courseId
);
var
courseModel
=
courseRepository
.
GetEntity
(
courseId
);
if
(
courseModel
!=
null
)
if
(
courseModel
!=
null
)
{
{
...
@@ -808,61 +861,1046 @@ namespace Edu.Module.Course
...
@@ -808,61 +861,1046 @@ namespace Edu.Module.Course
}
}
else
if
((
int
)
m
.
OrderSourceType
==
3
)
else
if
((
int
)
m
.
OrderSourceType
==
3
)
{
{
if
(
courseModel
.
CommissionReType
==
1
)
if
(
courseModel
.
CommissionReType
==
1
)
{
m
.
CommissionMoeny
=
Math
.
Round
(
sellPrice
*
((
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatio
:
courseModel
.
InnerRecommendReNewRatio
)
/
100
),
2
,
MidpointRounding
.
AwayFromZero
);
}
else
{
m
.
CommissionMoeny
=
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatio
:
courseModel
.
InnerRecommendReNewRatio
;
}
m
.
CommissionReType
=
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatioType
.
ToInt
()
:
courseModel
.
InnerRecommendReNewRatioType
.
ToInt
();
m
.
CommissionReValue
=
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatioValue
:
courseModel
.
InnerRecommendReNewRatioValue
.
Value
;
m
.
Remark
=
$"学员来源为:内部介绍,学员为
{(
m
.
CommissionType
==
1
?
"首次报名"
:
"续费报名"
)}
,本次报名金额为:
{
sellPrice
}
,本次返佣金额为:
{
m
.
CommissionMoeny
:
0.00
}
"
;
}
else
if
((
int
)
m
.
OrderSourceType
==
4
)
{
if
(
courseModel
.
CommissionReType
==
1
)
{
m
.
CommissionMoeny
=
Math
.
Round
(
sellPrice
*
((
m
.
CommissionType
==
1
?
(
courseModel
.
TransIntroductceRatio
)
:
courseModel
.
TransIntroductceReNewRatio
)
/
100
),
2
,
MidpointRounding
.
AwayFromZero
);
}
else
{
m
.
CommissionMoeny
=
m
.
CommissionType
==
1
?
(
courseModel
.
TransIntroductceRatio
)
:
courseModel
.
TransIntroductceReNewRatio
;
}
m
.
CommissionReType
=
m
.
CommissionType
==
1
?
courseModel
.
TransIntroductceRatioType
.
ToInt
()
:
courseModel
.
TransIntroductceReNewRatioType
.
ToInt
();
m
.
CommissionReValue
=
m
.
CommissionType
==
1
?
courseModel
.
TransIntroductceRatioValue
:
courseModel
.
TransIntroductceReNewRatioValue
;
m
.
Remark
=
$"学员来源为:学员转介绍,学员为
{(
m
.
CommissionType
==
1
?
"首次报名"
:
"续费报名"
)}
,本次报名金额为:
{
sellPrice
}
,本次返佣金额为:
{
m
.
CommissionMoeny
:
0.00
}
"
;
}
}
else
{
//未匹配到课程,以防万一
m
.
CommissionMoeny
=
0
;
m
.
CommissionReType
=
3
;
m
.
CommissionReValue
=
0
;
m
.
Remark
=
"系统未匹配到对应的返佣信息,本订单返佣为0"
;
}
}
/// <summary>
/// 修改老订单
/// </summary>
/// <param name="OrderId"></param>
/// <param name="TargetOrderId"></param>
/// <param name="targetJoinType"></param>
/// <returns></returns>
public
bool
UpdateOrderJoinTypeModule
(
int
OrderId
,
int
TargetOrderId
,
OrderJoinTypeEnum
targetJoinType
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Order_ViewModel
.
TargetOrderId
),
TargetOrderId
},
{
nameof
(
RB_Order_ViewModel
.
TargetJoinType
),(
int
)
targetJoinType
}
};
return
orderRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Order_ViewModel
.
OrderId
),
OrderId
));
}
/// <summary>
/// 日语培训下单
/// </summary>
/// <param name="demodel"></param>
/// <param name="userInfo"></param>
/// <param name="IsFirstBatch">首次批量制单</param>
/// <returns></returns>
public
bool
SetClassOrderCommonModule
(
RB_Order_ViewModel
demodel
,
UserInfo
userInfo
,
bool
isEditOrder
,
out
string
message
,
out
int
ROrderId
,
bool
IsFirstBatch
=
false
)
{
bool
flag
=
false
;
ROrderId
=
demodel
.
OrderId
;
message
=
""
;
var
orderModel
=
new
RB_Order
();
if
(
demodel
.
OrderId
>
0
)
{
orderModel
=
orderRepository
.
GetEntity
(
demodel
.
OrderId
);
demodel
.
OrderIdentify
=
orderModel
.
OrderIdentify
;
}
//查询班级信息
var
classModel
=
classRepository
.
GetEntity
(
demodel
.
ClassId
);
if
(
classModel
==
null
)
{
flag
=
false
;
message
=
"班级不存在"
;
return
flag
;
}
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
Normal
||
demodel
.
JoinType
==
OrderJoinTypeEnum
.
RenewOrder
)
{
demodel
.
CourseId
=
classModel
.
CouseId
;
}
//课程信息
var
courseModel
=
courseRepository
.
GetEntity
(
demodel
.
CourseId
);
decimal
coursePrice
=
courseModel
.
SellPrice
;
//课程最低单价
demodel
.
CommissionReType
=
courseModel
.
CommissionReType
;
//课时单价计算
// demodel.ClassUnitPrice = "";
#
region
课程比例赋值
if
(
demodel
.
OrderId
<=
0
)
{
demodel
.
B2CRatio
=
courseModel
.
B2CRatio
;
demodel
.
B2CReNewRatio
=
courseModel
.
B2CReNewRatio
;
demodel
.
B2BRebateRatio
=
courseModel
.
B2BRebateRatio
;
demodel
.
B2BReNewRatio
=
courseModel
.
B2BReNewRatio
;
demodel
.
SchoolRebateRatio
=
courseModel
.
SchoolRebateRatio
;
demodel
.
SchoolReNewRatio
=
courseModel
.
SchoolReNewRatio
;
demodel
.
TransIntroductceRatio
=
courseModel
.
TransIntroductceRatio
;
demodel
.
TransIntroductceReNewRatio
=
courseModel
.
TransIntroductceReNewRatio
;
demodel
.
InnerRecommendRatio
=
courseModel
.
InnerRecommendRatio
;
demodel
.
InnerRecommendReNewRatio
=
courseModel
.
InnerRecommendReNewRatio
;
demodel
.
CommissionReType
=
courseModel
.
CommissionReType
;
}
else
{
//使用订单的比例
courseModel
.
B2CRatio
=
orderModel
.
B2CRatio
;
courseModel
.
B2CReNewRatio
=
orderModel
.
B2CReNewRatio
;
courseModel
.
B2BRebateRatio
=
orderModel
.
B2BRebateRatio
;
courseModel
.
B2BReNewRatio
=
orderModel
.
B2BReNewRatio
;
courseModel
.
SchoolRebateRatio
=
orderModel
.
SchoolRebateRatio
;
courseModel
.
SchoolReNewRatio
=
orderModel
.
SchoolReNewRatio
;
courseModel
.
TransIntroductceRatio
=
orderModel
.
TransIntroductceRatio
;
courseModel
.
TransIntroductceReNewRatio
=
orderModel
.
TransIntroductceReNewRatio
;
courseModel
.
InnerRecommendRatio
=
orderModel
.
InnerRecommendRatio
;
courseModel
.
InnerRecommendReNewRatio
=
orderModel
.
InnerRecommendReNewRatio
;
courseModel
.
CommissionReType
=
orderModel
.
CommissionReType
;
}
#
endregion
#
region
计算订单优惠信息
List
<
RB_Student_ViewModel
>
StuList
=
new
List
<
RB_Student_ViewModel
>();
//计算续费订单优惠
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
RenewOrder
&&
demodel
.
OrderId
==
0
)
{
demodel
.
DiscountMoney
=
coursePrice
*
(
courseModel
.
B2CReNewRatio
/
100
);
demodel
.
SaleRemark
=
"续费报名优惠"
+
courseModel
.
B2CReNewRatio
+
"%"
;
}
else
if
((
demodel
.
JoinType
==
OrderJoinTypeEnum
.
Normal
||
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
&&
demodel
.
OrderIdentify
!=
2
)
{
//默认都是首次报名优惠
//HK 2022 - 02 - 08修改
decimal
DiscountMoney
=
coursePrice
*
(
courseModel
.
B2CRatio
/
100
);
//if (demodel.DiscountMoney > DiscountMoney)
//{
// message = string.Format("优惠金额不正确,不能超过{0}元",DiscountMoney);
// return false;
//}
}
else
if
(
demodel
.
OrderIdentify
==
2
&&
demodel
.
OrderId
==
0
)
{
//查询学生列表
StuList
=
studentRepository
.
GetStudentListRepository
(
new
RB_Student_ViewModel
()
{
Group_Id
=
demodel
.
Group_Id
,
StuIds
=
demodel
.
StuIds
,
School_Id
=
-
1
});
//根据客人手机号码 验证是否是续费
if
(
StuList
.
Select
(
x
=>
x
.
CustomerId
).
Distinct
().
Count
()
>
1
)
{
message
=
"只能选择同一同行的客户报名"
;
return
false
;
}
if
(
StuList
.
Count
()
!=
demodel
.
GuestNum
)
{
message
=
"学生信息有误"
;
return
false
;
}
if
(
StuList
.
FirstOrDefault
().
CustomerId
!=
demodel
.
CustomerId
)
{
message
=
"同业信息有误"
;
return
false
;
}
int
RenewNum
=
0
;
if
(!
IsFirstBatch
)
{
var
glist
=
student_OrderGuestRepository
.
GetStuOrderList
(
demodel
.
StuIds
,
demodel
.
Group_Id
);
if
(
glist
.
Any
())
{
foreach
(
var
item
in
StuList
)
{
if
(
glist
.
Where
(
x
=>
x
.
Student_Id
==
item
.
StuId
).
Any
())
{
item
.
IsRenewGuest
=
1
;
//是续费的
}
}
}
RenewNum
=
glist
.
Select
(
x
=>
x
.
Student_Id
).
Distinct
().
Count
();
//续费订单数量
}
if
(!
StuList
.
Where
(
x
=>
x
.
IsRenewGuest
==
1
).
Any
())
{
//验证 是否从试听课过来
demodel
.
HelpEnterId
=
0
;
// 2022-05-12 第一次报名 并且有试听 带入协助老师 否则 没有协助老师 ;
int
vTeacherId
=
visitor_ReserveRepository
.
GetVisitorReserveTeacherId
(
StuList
.
FirstOrDefault
().
StuId
,
userInfo
.
Group_Id
);
if
(
vTeacherId
>
0
)
{
var
tModel
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
demodel
.
Group_Id
,
AccountId
=
vTeacherId
,
AccountType
=
AccountTypeEnum
.
Teacher
}).
FirstOrDefault
();
demodel
.
HelpEnterId
=
tModel
?.
Id
??
0
;
}
}
int
NormalNum
=
demodel
.
GuestNum
-
RenewNum
;
//首次报名数量
decimal
dmoney
=
coursePrice
*
(
courseModel
.
B2CRatio
/
100
)
*
NormalNum
+
coursePrice
*
(
courseModel
.
B2CReNewRatio
/
100
)
*
RenewNum
;
if
(
demodel
.
DiscountMoney
!=
dmoney
)
{
message
=
"优惠金额不正确"
;
return
false
;
}
}
else
if
(
demodel
.
OrderIdentify
==
2
&&
demodel
.
OrderId
>
0
)
{
//直接验证优惠金额
decimal
DiscountMoney
=
coursePrice
*
(
courseModel
.
B2CRatio
/
100
);
//HK 2022-02-08修改
//if (demodel.DiscountMoney > DiscountMoney)
//{
// message = string.Format("优惠金额有误,不能超过 {0} 元.", DiscountMoney);
// return false;
//}
}
//获取课程优惠
var
coursePreferentialList
=
course_PreferentialRepository
.
GetCoursePreferentialListRepostory
(
new
RB_Course_Preferential_Extend
()
{
CourseId
=
demodel
.
CourseId
});
if
(
coursePreferentialList
!=
null
&&
coursePreferentialList
.
Count
>
0
)
{
#
region
记录提成信息
var
coursePreferentialModel
=
coursePreferentialList
.
FirstOrDefault
();
demodel
.
CommissionType
=
coursePreferentialModel
?.
SaleCommissionType
??
0
;
demodel
.
CommissionRate
=
coursePreferentialModel
?.
SaleCommissionMoney
??
0
;
demodel
.
CommissionTypeTH
=
coursePreferentialModel
?.
B2BCommissionType
??
0
;
demodel
.
CommissionRateTH
=
coursePreferentialModel
?.
B2BCommissionMoney
??
0
;
if
(
coursePreferentialModel
!=
null
)
{
demodel
.
CommissionRemark
=
"使用优惠Id:"
+
coursePreferentialModel
.
Id
+
" 返佣类型:"
+
demodel
.
CommissionType
+
" 返佣比例/金额:"
+
demodel
.
CommissionRate
+
" 同行返佣类型:"
+
demodel
.
CommissionTypeTH
+
" 同行返佣比例/金额:"
+
demodel
.
CommissionRateTH
;
}
#
endregion
}
#
endregion
if
(
demodel
.
OrderSource
==
OrderSourceEnum
.
EduClient
||
demodel
.
OrderSource
==
OrderSourceEnum
.
Client
)
{
if
(
demodel
.
OrderSource
==
OrderSourceEnum
.
EduClient
)
{
demodel
.
GeneralOccupation
=
""
;
}
else
if
(
demodel
.
OrderSource
==
OrderSourceEnum
.
Client
)
{
demodel
.
EduOccupation
=
""
;
}
}
else
{
demodel
.
EduOccupation
=
""
;
demodel
.
GeneralOccupation
=
""
;
}
if
(
demodel
.
OrderId
>
0
)
{
int
BNum
=
orderRepository
.
GetClassOrderPeopleNumRepository
(
demodel
.
ClassId
.
ToString
()).
FirstOrDefault
()?.
GuestNum
??
0
;
if
(
BNum
+
demodel
.
GuestNum
-
orderModel
.
GuestNum
>
classModel
.
ClassPersion
)
{
flag
=
false
;
message
=
"人数报超"
+
(
classModel
.
ClassPersion
-
(
BNum
+
demodel
.
GuestNum
-
orderModel
.
GuestNum
));
return
flag
;
}
}
else
{
int
BNum
=
orderRepository
.
GetClassOrderPeopleNumRepository
(
demodel
.
ClassId
.
ToString
()).
FirstOrDefault
()?.
GuestNum
??
0
;
if
(
BNum
+
demodel
.
GuestNum
>
classModel
.
ClassPersion
)
{
flag
=
false
;
message
=
"人数报超"
+
(
classModel
.
ClassPersion
-
(
BNum
+
demodel
.
GuestNum
));
return
flag
;
}
}
//没有总经理修改订单权限
if
(!
isEditOrder
)
{
//if (demodel.Unit_Price < coursePrice)
//{
// flag = false;
// message = "成交单价不能小于最低价格";
// return flag;
//}
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
{
var
newPreferPrice
=
Math
.
Round
(
coursePrice
/
courseModel
.
ClassHours
*
(
courseModel
.
ClassHours
-
demodel
.
StartClassHours
)
*
demodel
.
GuestNum
,
2
);
if
(
demodel
.
PreferPrice
!=
newPreferPrice
)
{
flag
=
false
;
message
=
"应收总额不正确"
;
return
flag
;
}
}
else
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
TransOrder
||
demodel
.
JoinType
==
OrderJoinTypeEnum
.
SplitOrder
)
{
//不验证应收
}
else
{
if
(
demodel
.
PreferPrice
!=
(
coursePrice
*
demodel
.
GuestNum
))
{
flag
=
false
;
message
=
"应收总额不正确"
;
return
flag
;
}
}
}
//日志信息
string
LogContent
=
""
;
//销售备注
string
SaleRemark
=
""
;
if
(
demodel
.
OrderId
>
0
)
{
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
{
if
(
orderModel
.
EffectStatus
!=
2
)
{
if
(
Convert
.
ToDateTime
(
Common
.
ConvertHelper
.
FormatTime
(
demodel
.
EffectTime
))
<
Convert
.
ToDateTime
(
Common
.
ConvertHelper
.
FormatTime
(
DateTime
.
Now
)))
{
demodel
.
EffectStatus
=
1
;
}
else
{
demodel
.
EffectStatus
=
0
;
}
}
else
{
demodel
.
EffectStatus
=
orderModel
.
EffectStatus
;
}
}
else
{
demodel
.
EffectStatus
=
2
;
demodel
.
EffectTime
=
DateTime
.
Now
;
}
if
(
orderModel
==
null
)
{
flag
=
false
;
message
=
"订单不存在"
;
return
flag
;
}
if
(
orderModel
.
OrderState
==
Common
.
Enum
.
Course
.
OrderStateEnum
.
Cancel
)
{
flag
=
false
;
message
=
"取消订单无法修改"
;
return
flag
;
}
#
region
验证学生名单数量
var
glist
=
order_GuestRepository
.
GetOrderGuestListRepository
(
new
RB_Order_Guest_ViewModel
()
{
Group_Id
=
demodel
.
Group_Id
,
OrderId
=
demodel
.
OrderId
,
GuestState
=
GuestStateEnum
.
Normal
});
if
(
glist
.
Any
()
&&
orderModel
.
CustomerId
!=
demodel
.
CustomerId
)
{
message
=
"订单已创建学生名单,无法修改其同行"
;
return
false
;
}
if
(
glist
.
Count
()
>
demodel
.
GuestNum
)
{
flag
=
false
;
message
=
"请先取消学生名单再修改订单人员数量"
;
return
flag
;
}
#
endregion
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Order_ViewModel
.
GuestNum
),
demodel
.
GuestNum
},
{
nameof
(
RB_Order_ViewModel
.
Unit_Price
),
demodel
.
Unit_Price
},
{
nameof
(
RB_Order_ViewModel
.
DiscountMoney
),
demodel
.
DiscountMoney
},
{
nameof
(
RB_Order_ViewModel
.
PerDiscountMoney
),
demodel
.
PerDiscountMoney
},
{
nameof
(
RB_Order_ViewModel
.
PreferPrice
),
demodel
.
PreferPrice
},
{
nameof
(
RB_Order_ViewModel
.
OrderSource
),
demodel
.
OrderSource
},
{
nameof
(
RB_Order_ViewModel
.
SaleRemark
),
demodel
.
SaleRemark
},
{
nameof
(
RB_Order_ViewModel
.
HelpEnterId
),
demodel
.
HelpEnterId
},
{
nameof
(
RB_Order_ViewModel
.
GeneralOccupation
),
demodel
.
GeneralOccupation
},
{
nameof
(
RB_Order_ViewModel
.
EduOccupation
),
demodel
.
EduOccupation
},
{
nameof
(
RB_Order_ViewModel
.
IsLessPrice
),
demodel
.
IsLessPrice
},
{
nameof
(
RB_Order_ViewModel
.
LessPrice
),
demodel
.
LessPrice
},
{
nameof
(
RB_Order_ViewModel
.
PerLessMoney
),
demodel
.
PerLessMoney
},
{
nameof
(
RB_Order_ViewModel
.
StartClassHours
),
demodel
.
StartClassHours
},
{
nameof
(
RB_Order_ViewModel
.
CourseId
),
demodel
.
CourseId
},
{
nameof
(
RB_Order_ViewModel
.
EffectStatus
),
demodel
.
EffectStatus
},
{
nameof
(
RB_Order_ViewModel
.
EffectTime
),
demodel
.
EffectTime
},
{
nameof
(
RB_Order_ViewModel
.
UpOrderId
),
demodel
.
UpOrderId
},
{
nameof
(
RB_Order_ViewModel
.
CustomerId
),
demodel
.
CustomerId
},
{
nameof
(
RB_Order_ViewModel
.
CourseConsultantId
),
demodel
.
CourseConsultantId
},
{
nameof
(
RB_Order_ViewModel
.
TotalClassHours
),
demodel
.
TotalClassHours
},
{
nameof
(
RB_Order_ViewModel
.
TextbookFee
),
demodel
.
TextbookFee
},
{
nameof
(
RB_Order_ViewModel
.
CoursewareFee
),
demodel
.
CoursewareFee
},
};
flag
=
orderRepository
.
Update
(
keyValues
,
new
WhereHelper
(
nameof
(
RB_Order_ViewModel
.
OrderId
),
demodel
.
OrderId
));
#
region
记录日志信息
LogContent
=
$"修改日语培训订单【
{
demodel
.
OrderId
}
】"
;
if
(
orderModel
.
GuestNum
!=
demodel
.
GuestNum
)
{
LogContent
+=
$",人数由【
{
orderModel
.
GuestNum
}
】修改为【
{
demodel
.
GuestNum
}
】"
;
}
if
(
orderModel
.
Unit_Price
!=
demodel
.
Unit_Price
)
{
LogContent
+=
$",成交单价由【
{
orderModel
.
Unit_Price
}
】修改为【
{
demodel
.
Unit_Price
}
】"
;
}
if
(
orderModel
.
DiscountMoney
!=
demodel
.
DiscountMoney
)
{
LogContent
+=
$",优惠金额由【
{(
orderModel
.
DiscountMoney
)}
】修改为【
{(
demodel
.
DiscountMoney
)}
】"
;
}
if
(
orderModel
.
TotalClassHours
!=
demodel
.
TotalClassHours
)
{
LogContent
+=
$",总课时由【
{(
orderModel
.
TotalClassHours
)}
】修改为【
{(
demodel
.
TotalClassHours
)}
】"
;
}
if
(
orderModel
.
TextbookFee
!=
demodel
.
TextbookFee
)
{
LogContent
+=
$",教材费由【
{(
orderModel
.
TextbookFee
)}
】修改为【
{(
demodel
.
TextbookFee
)}
】"
;
}
if
(
orderModel
.
CoursewareFee
!=
demodel
.
CoursewareFee
)
{
LogContent
+=
$",课件费由【
{(
orderModel
.
CoursewareFee
)}
】修改为【
{(
demodel
.
CoursewareFee
)}
】"
;
}
if
(
orderModel
.
PerDiscountMoney
!=
demodel
.
PerDiscountMoney
)
{
LogContent
+=
$",每人优惠金额由【
{(
orderModel
.
PerDiscountMoney
)}
】修改为【
{(
demodel
.
PerDiscountMoney
)}
】"
;
}
if
(
orderModel
.
PreferPrice
!=
demodel
.
PreferPrice
)
{
LogContent
+=
$",应收金额由【
{
orderModel
.
PreferPrice
}
】修改为【
{
demodel
.
PreferPrice
}
】"
;
}
if
(
orderModel
.
OrderSource
!=
demodel
.
OrderSource
)
{
LogContent
+=
$",客人来源由【
{
orderModel
.
OrderSource
.
ToName
()}
】修改为【
{
demodel
.
OrderSource
.
ToName
()}
】"
;
}
if
(
orderModel
.
HelpEnterId
!=
demodel
.
HelpEnterId
)
{
var
empList
=
accountRepository
.
GetAccountListRepository
(
new
RB_Account_ViewModel
()
{
QIds
=
orderModel
.
HelpEnterId
+
","
+
demodel
.
HelpEnterId
});
LogContent
+=
$",协助人员由【
{
empList
?.
Where
(
qitem
=>
qitem
.
Id
==
orderModel
.
HelpEnterId
)?.
FirstOrDefault
()?.
AccountName
}
】修改为【
{
empList
?.
Where
(
qitem
=>
qitem
.
Id
==
demodel
.
HelpEnterId
)?.
FirstOrDefault
()?.
AccountName
}
】"
;
}
if
(
orderModel
.
CourseConsultantId
!=
demodel
.
CourseConsultantId
)
{
var
empList
=
accountRepository
.
GetAccountListRepository
(
new
RB_Account_ViewModel
()
{
QIds
=
orderModel
.
CourseConsultantId
+
","
+
demodel
.
CourseConsultantId
});
LogContent
+=
$",课程顾问由【
{
empList
?.
Where
(
qitem
=>
qitem
.
Id
==
orderModel
.
CourseConsultantId
)?.
FirstOrDefault
()?.
AccountName
}
】修改为【
{
empList
?.
Where
(
qitem
=>
qitem
.
Id
==
demodel
.
CourseConsultantId
)?.
FirstOrDefault
()?.
AccountName
}
】"
;
}
if
(
orderModel
.
CustomerId
!=
demodel
.
CustomerId
)
{
LogContent
+=
$",关联同行联系人由【
{
customerRepository
.
GetEntity
(
orderModel
.
CustomerId
)?.
CustomerName
??
""
}
】修改为【
{
customerRepository
.
GetEntity
(
demodel
.
CustomerId
)?.
CustomerName
??
""
}
】"
;
}
if
(
orderModel
.
GeneralOccupation
!=
demodel
.
GeneralOccupation
)
{
LogContent
+=
$",一般同行由【
{
orderModel
.
GeneralOccupation
}
】修改为【
{
demodel
.
GeneralOccupation
}
】"
;
}
if
(
orderModel
.
EduOccupation
!=
demodel
.
EduOccupation
)
{
LogContent
+=
$",教育同行由【
{
orderModel
.
EduOccupation
}
】修改为【
{
demodel
.
EduOccupation
}
】"
;
}
if
(
orderModel
.
IsLessPrice
!=
demodel
.
IsLessPrice
)
{
LogContent
+=
$",少价由【
{(
orderModel
.
IsLessPrice
>
0
?
"少价"
:
"不少价"
)}
】修改为【
{(
demodel
.
IsLessPrice
>
0
?
"少价"
:
"不少价"
)}
】"
;
}
if
(
orderModel
.
LessPrice
!=
demodel
.
LessPrice
)
{
LogContent
+=
$",少价金额由【
{(
orderModel
.
LessPrice
)}
】修改为【
{(
demodel
.
LessPrice
)}
】"
;
}
if
(
orderModel
.
PerLessMoney
!=
demodel
.
PerLessMoney
)
{
LogContent
+=
$",每人少价金额由【
{(
orderModel
.
PerLessMoney
)}
】修改为【
{(
demodel
.
PerLessMoney
)}
】"
;
}
//记录订单备注
if
(
orderModel
.
SaleRemark
!=
demodel
.
SaleRemark
)
{
LogContent
+=
$",销售备注由【
{
orderModel
.
SaleRemark
}
】修改为【
{
demodel
.
SaleRemark
}
】"
;
SaleRemark
=
demodel
.
SaleRemark
;
}
#
endregion
if
(
flag
&&
demodel
.
GuestNum
==
1
&&
(
orderModel
.
PreferPrice
!=
demodel
.
PreferPrice
||
orderModel
.
DiscountMoney
!=
demodel
.
DiscountMoney
))
{
if
(
demodel
.
PreferPrice
-
demodel
.
DiscountMoney
==
orderModel
.
Income
+
orderModel
.
PlatformTax
-
orderModel
.
Refund
&&
orderModel
.
Income
>
0
)
{
if
(
glist
!=
null
&&
glist
.
Count
>
0
)
{
//帐平
int
guestId
=
glist
.
FirstOrDefault
().
Id
;
var
studentMapping
=
student_OrderGuestRepository
.
GetList
(
new
RB_Student_OrderGuest_ViewModel
()
{
GuestId
=
guestId
});
if
(
studentMapping
.
Any
())
{
UpdateReturnMoneyStatus
(
studentMapping
.
First
().
Student_Id
,
demodel
.
OrderId
,
demodel
);
}
}
}
}
}
else
{
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
{
if
(
Convert
.
ToDateTime
(
Common
.
ConvertHelper
.
FormatTime
(
demodel
.
EffectTime
))
<
Convert
.
ToDateTime
(
Common
.
ConvertHelper
.
FormatTime
(
DateTime
.
Now
)))
{
demodel
.
EffectStatus
=
1
;
}
else
{
demodel
.
EffectStatus
=
0
;
}
}
else
{
demodel
.
EffectStatus
=
1
;
demodel
.
EffectTime
=
DateTime
.
Now
;
}
if
(
classModel
.
ClassStatus
==
Common
.
Enum
.
Course
.
ClassStatusEnum
.
EndClass
)
{
flag
=
false
;
message
=
"班级状态不正确"
;
return
flag
;
}
demodel
.
Class_Price
=
courseModel
.
SellPrice
;
if
(
demodel
.
EnterID
<=
0
&&
demodel
.
CreateBy
>
0
)
{
if
(
userInfo
.
AccountType
==
AccountTypeEnum
.
Teacher
&&
demodel
.
HelpEnterId
==
0
)
{
demodel
.
HelpEnterId
=
demodel
.
CreateBy
;
}
//else
//{
// demodel.EnterID = demodel.CreateBy;
//}
// 强制修改为 该学生的创建人 2022-03-08 ld
demodel
.
EnterID
=
StuList
.
FirstOrDefault
()?.
CreateBy
??
0
;
}
if
(
demodel
.
OrderIdentify
==
2
&&
StuList
.
Where
(
x
=>
x
.
IsRenewGuest
==
1
).
Any
())
{
demodel
.
JoinType
=
OrderJoinTypeEnum
.
RenewOrder
;
}
int
OrderId
=
orderRepository
.
Insert
(
demodel
);
demodel
.
OrderId
=
OrderId
;
ROrderId
=
OrderId
;
flag
=
OrderId
>
0
;
LogContent
=
"新增日语培训订单"
;
//记录订单备注
if
(!
string
.
IsNullOrEmpty
(
demodel
.
SaleRemark
))
{
SaleRemark
=
demodel
.
SaleRemark
;
}
#
region
添加学员初次成交
/
多次成交时间
if
(
StuList
!=
null
&&
StuList
.
Count
>
0
)
{
string
stuIds
=
string
.
Join
(
","
,
StuList
.
Select
(
qitem
=>
qitem
.
StuId
));
List
<
RB_Student_Advisor_Extend
>
advisorList
=
new
List
<
RB_Student_Advisor_Extend
>();
if
(!
string
.
IsNullOrEmpty
(
stuIds
))
{
advisorList
=
student_AdvisorRepository
.
GetStudentAdvisorListRepository
(
new
RB_Student_Advisor_Extend
()
{
QStuIds
=
stuIds
});
}
foreach
(
var
sItem
in
StuList
)
{
var
tempAdv
=
advisorList
.
Where
(
qitem
=>
qitem
.
AdvisorStatus
==
5
)?.
FirstOrDefault
();
if
(
tempAdv
==
null
)
{
Dictionary
<
string
,
object
>
stufileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Student_ViewModel
.
AdvisorStatus
),
5
},
{
nameof
(
RB_Student_ViewModel
.
AdvisorWinRate
),
100
},
};
studentRepository
.
Update
(
stufileds
,
new
WhereHelper
(
nameof
(
RB_Student_ViewModel
.
StuId
),
sItem
.
StuId
));
student_AdvisorRepository
.
Insert
(
new
Model
.
Entity
.
Customer
.
RB_Student_Advisor
()
{
Id
=
0
,
StuId
=
sItem
.
StuId
,
AdvisorStatus
=
5
,
AdvisorDate
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
),
AdvisorRemark
=
"新增订单,系统自动添加!"
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
demodel
.
Group_Id
,
});
}
}
}
#
endregion
#
region
预约单转订单
//预约单转订单
if
(
flag
&&
demodel
.
VisitorReserveId
>
0
)
{
string
remark
=
userInfo
.
AccountName
+
"转订单"
;
Dictionary
<
string
,
object
>
visitorFileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Visitor_Reserve_Extend
.
ReserveStatus
),
1
},
{
nameof
(
RB_Visitor_Reserve_Extend
.
Remark
),
remark
},
{
nameof
(
RB_Visitor_Reserve_Extend
.
OrderId
),
demodel
.
OrderId
},
};
flag
=
visitor_ReserveRepository
.
Update
(
visitorFileds
,
new
WhereHelper
(
nameof
(
RB_Visitor_Reserve_Extend
.
Id
),
demodel
.
VisitorReserveId
));
var
visitorModel
=
visitor_ReserveRepository
.
GetVisitorRepository
(
new
RB_Visitor_Reserve_Extend
()
{
Id
=
demodel
.
VisitorReserveId
})?.
FirstOrDefault
();
var
guestModel
=
new
RB_Order_Guest_ViewModel
()
{
Id
=
0
,
OrderId
=
demodel
.
OrderId
,
ClassId
=
demodel
.
ClassId
,
GuestName
=
visitorModel
?.
Name
??
""
,
GuestState
=
GuestStateEnum
.
Normal
,
Profession
=
""
,
Sex
=
1
,
Age
=
18
,
Mobile
=
visitorModel
?.
Tel
??
""
,
Basics
=
visitorModel
?.
LevelType
,
Education
=
GuestEducationEnum
.
N2
,
GuestSource
=
demodel
.
OrderSource
,
LearningGoals
=
""
,
Contact
=
""
,
ContactMobile
=
""
,
Status
=
0
,
Group_Id
=
demodel
.
Group_Id
,
School_Id
=
demodel
.
School_Id
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
UpdateBy
=
demodel
.
UpdateBy
,
UpdateTime
=
demodel
.
UpdateTime
,
DropOutRemark
=
""
,
IDCard
=
""
,
Domicile
=
""
,
ContactAddress
=
""
,
SourceId
=
0
,
GraduatedSchool
=
""
,
GraduatedMajor
=
""
,
VolunteerMajor
=
""
,
Price
=
0
,
StudyRemark
=
""
,
TotalHours
=
Convert
.
ToInt32
(
courseModel
.
ClassHours
),
CompleteHours
=
0
,
MakeUpHours
=
0
,
StuIcon
=
""
,
RenewState
=
1
};
SetOrderGuestInfo
(
guestModel
,
out
string
Nmessage
);
}
#
endregion
#
region
续课订单和转班订单和分拆订单
添加学员名单
if
(
flag
&&
demodel
.
OldGuestId
>
0
)
{
var
oldGuestModel
=
order_GuestRepository
.
GetEntity
(
demodel
.
OldGuestId
);
var
guestModel
=
new
RB_Order_Guest_ViewModel
()
{
Id
=
0
,
OrderId
=
demodel
.
OrderId
,
ClassId
=
demodel
.
ClassId
,
GuestName
=
oldGuestModel
?.
GuestName
??
""
,
GuestState
=
GuestStateEnum
.
Normal
,
Profession
=
oldGuestModel
?.
Profession
??
""
,
Sex
=
oldGuestModel
?.
Sex
??
1
,
Age
=
oldGuestModel
?.
Age
??
18
,
Mobile
=
oldGuestModel
?.
Mobile
??
""
,
Basics
=
oldGuestModel
?.
Basics
,
Education
=
oldGuestModel
?.
Education
??
GuestEducationEnum
.
N2
,
GuestSource
=
demodel
.
OrderSource
,
LearningGoals
=
oldGuestModel
?.
LearningGoals
??
""
,
Contact
=
oldGuestModel
?.
Contact
??
""
,
ContactMobile
=
oldGuestModel
?.
ContactMobile
??
""
,
Status
=
0
,
Group_Id
=
demodel
.
Group_Id
,
School_Id
=
demodel
.
School_Id
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
UpdateBy
=
demodel
.
UpdateBy
,
UpdateTime
=
demodel
.
UpdateTime
,
DropOutRemark
=
""
,
IDCard
=
oldGuestModel
?.
IDCard
??
""
,
Domicile
=
oldGuestModel
?.
Domicile
??
""
,
ContactAddress
=
oldGuestModel
?.
ContactAddress
??
""
,
SourceId
=
0
,
GraduatedSchool
=
oldGuestModel
?.
GraduatedSchool
??
""
,
GraduatedMajor
=
oldGuestModel
?.
GraduatedMajor
??
""
,
VolunteerMajor
=
oldGuestModel
?.
VolunteerMajor
??
""
,
Price
=
0
,
StudyRemark
=
""
,
CompleteHours
=
0
,
MakeUpHours
=
0
,
StuIcon
=
""
,
RenewState
=
1
};
if
(
demodel
.
RenewOrderId
>
0
)
{
guestModel
.
TotalHours
=
Convert
.
ToInt32
(
courseModel
.
ClassHours
);
guestModel
.
RenewState
=
2
;
}
else
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
TransOrder
)
{
//原订单学员的剩余课时
guestModel
.
TotalHours
=
oldGuestModel
.
TotalHours
-
oldGuestModel
.
CompleteHours
;
}
else
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
SplitOrder
)
{
//新订单新课程的【根据时间计算的有效课时】
guestModel
.
TotalHours
=
demodel
.
NewGuestTotalClassHours
;
}
SetOrderGuestInfo
(
guestModel
,
out
string
Nmessage
);
demodel
.
NewGuestId
=
guestModel
.
Id
;
#
region
续费
学员介绍
RB_Student_ViewModel
stuModel
=
null
;
var
sogModel
=
student_OrderGuestRepository
.
GetStrOrderGuestListRepository
(
new
RB_Student_OrderGuest_ViewModel
()
{
GuestId
=
demodel
.
OldGuestId
}).
FirstOrDefault
();
if
(
sogModel
!=
null
)
{
stuModel
=
studentRepository
.
GetEntity
<
RB_Student_ViewModel
>(
sogModel
.
Student_Id
);
}
if
(
stuModel
!=
null
&&
(
demodel
.
RenewOrderId
>
0
||
(
stuModel
.
CreateType
==
StuCreateTypeEnum
.
TransIntroduction
&&
stuModel
.
StuSourceId
>
0
)))
{
int
month
=
1
;
if
(
stuModel
.
FirstEnrollDate
.
HasValue
)
{
month
=
((
demodel
.
CreateTime
.
Year
-
stuModel
.
FirstEnrollDate
.
Value
.
Year
)
*
12
)
+
demodel
.
CreateTime
.
Month
-
stuModel
.
FirstEnrollDate
.
Value
.
Month
+
1
;
}
//续费
if
(
demodel
.
RenewOrderId
>
0
)
{
student_RenewOrderRepository
.
Insert
(
new
Model
.
Entity
.
Customer
.
RB_Student_RenewOrder
()
{
Id
=
0
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
Group_Id
=
demodel
.
Group_Id
,
Month
=
month
,
OrderId
=
OrderId
,
Status
=
0
,
StuId
=
stuModel
.
StuId
,
Type
=
1
});
}
//学员介绍
if
(
stuModel
.
CreateType
==
StuCreateTypeEnum
.
TransIntroduction
&&
stuModel
.
StuSourceId
>
0
)
{
student_RenewOrderRepository
.
Insert
(
new
Model
.
Entity
.
Customer
.
RB_Student_RenewOrder
()
{
Id
=
0
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
Group_Id
=
demodel
.
Group_Id
,
Month
=
month
,
OrderId
=
OrderId
,
Status
=
0
,
StuId
=
stuModel
.
StuId
,
Type
=
2
});
}
}
#
endregion
}
#
endregion
#
region
插入学生名单
(
客户选择转订单
)
if
(
flag
&&
demodel
.
OrderIdentify
==
2
)
{
int
MaxChapterNo
=
courseRepository
.
GetMaxChapterNum
(
demodel
.
CourseId
,
demodel
.
Group_Id
);
foreach
(
var
item
in
StuList
)
{
var
guestModel
=
new
RB_Order_Guest_ViewModel
()
{
Id
=
0
,
OrderId
=
demodel
.
OrderId
,
ClassId
=
demodel
.
ClassId
,
GuestName
=
item
.
StuName
.
Trim
(),
GuestState
=
GuestStateEnum
.
Normal
,
Profession
=
item
?.
StuProfession
??
""
,
Sex
=
(
item
?.
StuSex
??
1
)
+
1
,
Age
=
item
.
StuBirth
.
HasValue
?
DateTime
.
Now
.
Year
-
item
.
StuBirth
.
Value
.
Year
:
18
,
Mobile
=
item
?.
StuTel
??
""
,
Basics
=
""
,
Education
=
item
?.
StuEducation
??
GuestEducationEnum
.
N2
,
GuestSource
=
demodel
.
OrderSource
,
LearningGoals
=
item
?.
StuPurpose
??
""
,
Contact
=
item
?.
StuContract
??
""
,
ContactMobile
=
item
?.
StuContractMobile
??
""
,
Status
=
0
,
Group_Id
=
demodel
.
Group_Id
,
School_Id
=
demodel
.
School_Id
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
UpdateBy
=
demodel
.
UpdateBy
,
UpdateTime
=
demodel
.
UpdateTime
,
DropOutRemark
=
""
,
IDCard
=
item
?.
StuIDCard
??
""
,
Domicile
=
item
?.
StuIDCardAddress
??
""
,
ContactAddress
=
item
?.
StuAddress
??
""
,
SourceId
=
0
,
GraduatedSchool
=
""
,
GraduatedMajor
=
""
,
VolunteerMajor
=
""
,
Price
=
0
,
StudyRemark
=
""
,
CompleteHours
=
0
,
MakeUpHours
=
0
,
StuIcon
=
item
.
StuIcon
,
TotalHours
=
demodel
.
TotalClassHours
,
//Convert.ToInt32(courseModel.ClassHours),2024-08-30 add by:W
RenewState
=
item
.
IsRenewGuest
==
1
?
2
:
1
,
QQ
=
item
.
QQ
,
WeChatNo
=
item
.
WeChatNo
,
TotalChapterNo
=
MaxChapterNo
,
StudentId
=
item
.
StuId
,
ClassUnitPrice
=
Math
.
Round
(((
demodel
.
PreferPrice
-
demodel
.
TextbookFee
-
demodel
.
CoursewareFee
)
/
demodel
.
TotalClassHours
),
2
),
//课时单价 (应收总金额-教材费-课件费)/总课时
};
SetOrderGuestInfo
(
guestModel
,
out
string
Nmessage
);
#
region
更新客人阶段
//if (item.IsRenewGuest == 1 && item.StuStage == Common.Enum.User.StuStageEnum.Clinch)
//{
// Dictionary<string, object> keyValues = new Dictionary<string, object>() {
// { nameof(RB_Student_ViewModel.StuStage), Common.Enum.User.StuStageEnum.MultipleClinch}
// };
// List<WhereHelper> wheres = new List<WhereHelper>() {
// new WhereHelper(){
// FiledName = nameof (RB_Student_ViewModel.StuId),
// FiledValue = item.StuId,
// OperatorEnum =OperatorEnum.Equal
// }
// };
// studentRepository.Update(keyValues, wheres);
// student_LogRepository.Insert(new Model.Entity.Customer.RB_Student_Log()
// {
// LogId = 0,
// CreateBy = userInfo.Id,
// CreateTime = DateTime.Now,
// CreateType = 1,
// Group_Id = userInfo.Group_Id,
// LogContent = "首次续课,客户阶段由'" + (Common.Enum.User.StuStageEnum.Clinch.ToName()) + "'自动转换为'" + (Common.Enum.User.StuStageEnum.MultipleClinch.ToName()) +"'",
// LogTitle = "客户阶段变更",
// LogType = Common.Enum.Log.StudentLogTypeEnum.BasicInfo,
// StuId = item.StuId
// });
//}
//else if (item.StuStage < Common.Enum.User.StuStageEnum.Clinch)
//{
// Dictionary<string, object> keyValues = new Dictionary<string, object>() {
// { nameof(RB_Student_ViewModel.StuStage), Common.Enum.User.StuStageEnum.Clinch}
// };
// List<WhereHelper> wheres = new List<WhereHelper>() {
// new WhereHelper(){
// FiledName = nameof (RB_Student_ViewModel.StuId),
// FiledValue = item.StuId,
// OperatorEnum =OperatorEnum.Equal
// }
// };
// studentRepository.Update(keyValues, wheres);
// student_LogRepository.Insert(new Model.Entity.Customer.RB_Student_Log()
// {
// LogId = 0,
// CreateBy = userInfo.Id,
// CreateTime = DateTime.Now,
// CreateType = 1,
// Group_Id = userInfo.Group_Id,
// LogContent = "首次生成订单,客户阶段由'" + (item.StuStage.ToName()) + "'自动转换为'" + (Common.Enum.User.StuStageEnum.Clinch.ToName()) + "'",
// LogTitle = "客户阶段变更",
// LogType = Common.Enum.Log.StudentLogTypeEnum.BasicInfo,
// StuId = item.StuId
// });
//}
#
endregion
#
region
更新首次报名时间
if
(
item
.
IsRenewGuest
!=
1
)
{
//非续费 更新首次报名
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Student_ViewModel
.
FirstEnrollDate
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Student_ViewModel
.
StuId
),
FiledValue
=
item
.
StuId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
studentRepository
.
Update
(
keyValues
,
wheres
);
}
#
endregion
#
region
续费
学员介绍
if
(
item
.
IsRenewGuest
==
1
||
(
item
.
CreateType
==
StuCreateTypeEnum
.
TransIntroduction
&&
item
.
StuSourceId
>
0
))
{
int
month
=
1
;
if
(
item
.
FirstEnrollDate
.
HasValue
)
{
month
=
((
demodel
.
CreateTime
.
Year
-
item
.
FirstEnrollDate
.
Value
.
Year
)
*
12
)
+
demodel
.
CreateTime
.
Month
-
item
.
FirstEnrollDate
.
Value
.
Month
+
1
;
}
//续费
if
(
item
.
IsRenewGuest
==
1
)
{
student_RenewOrderRepository
.
Insert
(
new
Model
.
Entity
.
Customer
.
RB_Student_RenewOrder
()
{
Id
=
0
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
Group_Id
=
demodel
.
Group_Id
,
Month
=
month
,
OrderId
=
OrderId
,
Status
=
0
,
StuId
=
item
.
StuId
,
Type
=
1
});
}
//学员介绍
if
(
item
.
CreateType
==
StuCreateTypeEnum
.
TransIntroduction
&&
item
.
StuSourceId
>
0
)
{
student_RenewOrderRepository
.
Insert
(
new
Model
.
Entity
.
Customer
.
RB_Student_RenewOrder
()
{
Id
=
0
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
Group_Id
=
demodel
.
Group_Id
,
Month
=
month
,
OrderId
=
OrderId
,
Status
=
0
,
StuId
=
item
.
StuId
,
Type
=
2
});
}
}
#
endregion
}
}
#
endregion
#
region
更新甲鹤小程序规格对应的库存
if
(
flag
&&
demodel
.
JoinType
!=
OrderJoinTypeEnum
.
RenewOrder
)
//续费订单不去更新规格库存
{
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
UpdateClassInventoryNum
(
demodel
));
}
#
endregion
#
region
更新客人协助人员
if
(
demodel
.
OrderIdentify
==
2
&&
demodel
.
CourseConsultantId
>
0
)
{
//客户转订单这种适配
int
StuId
=
StuList
.
FirstOrDefault
().
StuId
;
//更新协助人员
var
list
=
student_AssistRepository
.
GetStudentAssistListRepository
(
new
RB_Student_Assist_Extend
()
{
StuId
=
StuId
});
//更新课程顾问
var
assModel
=
list
.
Where
(
x
=>
x
.
AssistType
==
Common
.
Enum
.
User
.
AssistTypeEnum
.
CourseAdviser
).
FirstOrDefault
();
if
(
assModel
==
null
)
{
student_AssistRepository
.
Insert
(
new
Model
.
Entity
.
Customer
.
RB_Student_Assist
()
{
Id
=
0
,
AssistId
=
demodel
.
CourseConsultantId
,
AssistType
=
Common
.
Enum
.
User
.
AssistTypeEnum
.
CourseAdviser
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Status
=
DateStateEnum
.
Normal
,
StuId
=
StuId
});
}
}
#
endregion
#
region
推送订单报入日志
var
queryNotifyManager
=
accountRepository
.
GetWorkUserIdByDictRepository
(
"Push_NewOrder"
);
var
param
=
new
RB_Class_ViewModel
()
{
ClassId
=
demodel
.
ClassId
,
ClassScrollType
=
0
};
var
classDetailModel
=
classRepository
.
GetClassAndCourseListRepository
(
param
).
FirstOrDefault
();
if
(
queryNotifyManager
!=
null
&&
queryNotifyManager
.
Count
>
0
)
{
queryNotifyManager
.
ForEach
(
x
=>
{
{
m
.
CommissionMoeny
=
Math
.
Round
(
sellPrice
*
((
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatio
:
courseModel
.
InnerRecommendReNewRatio
)
/
100
),
2
,
MidpointRounding
.
AwayFromZero
);
var
path
=
$"/sale/orderStatistics?OrderId=
{
OrderId
}
"
;
}
path
=
HttpUtility
.
UrlEncode
(
path
);
else
string
markdownContent
=
$"<font color='info'>新订单通知</font> 新报入订单推送通知\n>**概要信息** \n>订单编号:
{
OrderId
}
\n>关联销售:
{
userInfo
.
AccountName
}
\n>报入班级:
{
classDetailModel
.
ClassName
}
\n>带班老师:
{
classDetailModel
.
TeacherName
}
\n>学习课程:
{
classDetailModel
.
CourseName
}
\n>开班时间:
{
classDetailModel
.
OpenTime
}
\n>订单金额:<font color='warning'>¥
{
demodel
.
PreferPrice
}
(
{
demodel
.
GuestNum
}
人)</font>\n>销售备注:<font color='comment'>
{
demodel
.
SaleRemark
}
</font>\n>请点击:[查看详情](
{
Config
.
ErpUrl
}
/autologin?loginId=
{
x
.
Id
}
&target=
{
path
}
)"
;
Common
.
Message
.
PushMessageModel
modelWork
=
new
Common
.
Message
.
PushMessageModel
()
{
{
m
.
CommissionMoeny
=
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatio
:
courseModel
.
InnerRecommendReNewRatio
;
CategoryId
=
PushMessageCategoryEnum
.
SalePeople
,
Content
=
markdownContent
,
CoverImg
=
""
,
CreateByName
=
"系统"
,
JumpUrl
=
""
,
WorkMsgType
=
"markdown"
,
SendTime
=
DateTime
.
Now
,
SendType
=
0
,
Title
=
"新订单通知"
,
Platform
=
5
,
ReceiveId
=
x
.
WorkUserId
};
List
<
Common
.
Message
.
PushMessageModel
>
pushList
=
new
List
<
Common
.
Message
.
PushMessageModel
>()
{
modelWork
};
new
Common
.
Message
.
MessageHelper
().
SendMessage
(
pushList
);
});
}
}
m
.
CommissionReType
=
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatioType
.
ToInt
()
:
courseModel
.
InnerRecommendReNewRatioType
.
ToInt
();
m
.
CommissionReValue
=
m
.
CommissionType
==
1
?
courseModel
.
InnerRecommendRatioValue
:
courseModel
.
InnerRecommendReNewRatioValue
.
Value
;
#
endregion
m
.
Remark
=
$"学员来源为:内部介绍,学员为
{(
m
.
CommissionType
==
1
?
"首次报名"
:
"续费报名"
)}
,本次报名金额为:
{
sellPrice
}
,本次返佣金额为:
{
m
.
CommissionMoeny
:
0.00
}
"
;
// 处理返佣信息
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
SetReturnOrderCommission
(
demodel
));
}
}
else
if
((
int
)
m
.
OrderSourceType
==
4
)
#
region
写日志
if
(
flag
)
{
{
if
(
courseModel
.
CommissionReType
==
1
)
//销售备注
if
(!
string
.
IsNullOrEmpty
(
SaleRemark
))
{
{
m
.
CommissionMoeny
=
Math
.
Round
(
sellPrice
*
((
m
.
CommissionType
==
1
?
(
courseModel
.
TransIntroductceRatio
)
:
courseModel
.
TransIntroductceReNewRatio
)
/
100
),
2
,
MidpointRounding
.
AwayFromZero
);
order_RemarkRepository
.
Insert
(
new
RB_Order_Remark
()
}
else
{
{
m
.
CommissionMoeny
=
m
.
CommissionType
==
1
?
(
courseModel
.
TransIntroductceRatio
)
:
courseModel
.
TransIntroductceReNewRatio
;
Id
=
0
,
}
Content
=
SaleRemark
,
m
.
CommissionReType
=
m
.
CommissionType
==
1
?
courseModel
.
TransIntroductceRatioType
.
ToInt
()
:
courseModel
.
TransIntroductceReNewRatioType
.
ToInt
();
CreateBy
=
demodel
.
CreateBy
,
m
.
CommissionReValue
=
m
.
CommissionType
==
1
?
courseModel
.
TransIntroductceRatioValue
:
courseModel
.
TransIntroductceReNewRatioValue
;
CreateTime
=
DateTime
.
Now
,
m
.
Remark
=
$"学员来源为:学员转介绍,学员为
{(
m
.
CommissionType
==
1
?
"首次报名"
:
"续费报名"
)}
,本次报名金额为:
{
sellPrice
}
,本次返佣金额为:
{
m
.
CommissionMoeny
:
0.00
}
"
;
OrderId
=
demodel
.
OrderId
,
}
Type
=
1
});
}
}
else
//订单日志
if
(!
string
.
IsNullOrEmpty
(
LogContent
))
{
{
//未匹配到课程,以防万一
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
m
.
CommissionMoeny
=
0
;
{
m
.
CommissionReType
=
3
;
Id
=
0
,
m
.
CommissionReValue
=
0
;
Type
=
2
,
m
.
Remark
=
"系统未匹配到对应的返佣信息,本订单返佣为0"
;
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
userInfo
.
Group_Id
,
LogContent
=
LogContent
,
School_Id
=
userInfo
.
School_Id
,
SourceId
=
demodel
.
OrderId
});
}
}
}
}
#
endregion
/// <summary>
/// 修改老订单
return
flag
;
/// </summary>
/// <param name="OrderId"></param>
/// <param name="TargetOrderId"></param>
/// <param name="targetJoinType"></param>
/// <returns></returns>
public
bool
UpdateOrderJoinTypeModule
(
int
OrderId
,
int
TargetOrderId
,
OrderJoinTypeEnum
targetJoinType
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Order_ViewModel
.
TargetOrderId
),
TargetOrderId
},
{
nameof
(
RB_Order_ViewModel
.
TargetJoinType
),(
int
)
targetJoinType
}
};
return
orderRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Order_ViewModel
.
OrderId
),
OrderId
));
}
}
/// <summary>
/// <summary>
/// 日语培训下单
/// 日语培训下单
/// </summary>
/// </summary>
...
@@ -871,7 +1909,7 @@ namespace Edu.Module.Course
...
@@ -871,7 +1909,7 @@ namespace Edu.Module.Course
/// <param name="IsFirstBatch">首次批量制单</param>
/// <param name="IsFirstBatch">首次批量制单</param>
/// <returns></returns>
/// <returns></returns>
public
bool
SetClassOrderCommonModule
(
RB_Order_ViewModel
demodel
,
UserInfo
userInfo
,
bool
isEditOrder
,
out
string
message
,
out
int
ROrderId
,
bool
IsFirstBatch
=
false
)
public
bool
SetClassOrderCommonModule
_V2
(
RB_Order_ViewModel
demodel
,
UserInfo
userInfo
,
bool
isEditOrder
,
out
string
message
,
out
int
ROrderId
,
bool
IsFirstBatch
=
false
)
{
{
bool
flag
=
false
;
ROrderId
=
demodel
.
OrderId
;
bool
flag
=
false
;
ROrderId
=
demodel
.
OrderId
;
message
=
""
;
message
=
""
;
...
@@ -894,65 +1932,56 @@ namespace Edu.Module.Course
...
@@ -894,65 +1932,56 @@ namespace Edu.Module.Course
demodel
.
CourseId
=
classModel
.
CouseId
;
demodel
.
CourseId
=
classModel
.
CouseId
;
}
}
//课程信息
//课程信息
var
courseModel
=
courseRepository
.
GetEntity
(
demodel
.
CourseId
);
List
<
RB_Course_ViewModel
>
courseList
=
new
List
<
RB_Course_ViewModel
>();
decimal
coursePrice
=
courseModel
.
SellPrice
;
//课程最低单价
if
(
demodel
?.
OrderCourseList
!=
null
&&
demodel
.
OrderCourseList
.
Any
())
demodel
.
CommissionReType
=
courseModel
.
CommissionReType
;
//课时单价计算
// demodel.ClassUnitPrice = "";
#
region
课程比例赋值
if
(
demodel
.
OrderId
<=
0
)
{
{
demodel
.
B2CRatio
=
courseModel
.
B2CRatio
;
string
courseIds
=
string
.
Join
(
","
,
demodel
?.
OrderCourseList
?.
Where
(
x
=>
x
.
CourseId
>
0
)?.
Select
(
x
=>
x
.
CourseId
));
demodel
.
B2CReNewRatio
=
courseModel
.
B2CReNewRatio
;
if
(!
string
.
IsNullOrWhiteSpace
(
courseIds
))
demodel
.
B2BRebateRatio
=
courseModel
.
B2BRebateRatio
;
demodel
.
B2BReNewRatio
=
courseModel
.
B2BReNewRatio
;
demodel
.
SchoolRebateRatio
=
courseModel
.
SchoolRebateRatio
;
demodel
.
SchoolReNewRatio
=
courseModel
.
SchoolReNewRatio
;
demodel
.
TransIntroductceRatio
=
courseModel
.
TransIntroductceRatio
;
demodel
.
TransIntroductceReNewRatio
=
courseModel
.
TransIntroductceReNewRatio
;
demodel
.
InnerRecommendRatio
=
courseModel
.
InnerRecommendRatio
;
demodel
.
InnerRecommendReNewRatio
=
courseModel
.
InnerRecommendReNewRatio
;
demodel
.
CommissionReType
=
courseModel
.
CommissionReType
;
}
else
{
{
//使用订单的比例
courseList
=
courseRepository
.
GetCourseListRepository
(
new
RB_Course_ViewModel
{
QCourseIds
=
courseIds
});
courseModel
.
B2CRatio
=
orderModel
.
B2CRatio
;
courseModel
.
B2CReNewRatio
=
orderModel
.
B2CReNewRatio
;
courseModel
.
B2BRebateRatio
=
orderModel
.
B2BRebateRatio
;
courseModel
.
B2BReNewRatio
=
orderModel
.
B2BReNewRatio
;
courseModel
.
SchoolRebateRatio
=
orderModel
.
SchoolRebateRatio
;
courseModel
.
SchoolReNewRatio
=
orderModel
.
SchoolReNewRatio
;
courseModel
.
TransIntroductceRatio
=
orderModel
.
TransIntroductceRatio
;
courseModel
.
TransIntroductceReNewRatio
=
orderModel
.
TransIntroductceReNewRatio
;
courseModel
.
InnerRecommendRatio
=
orderModel
.
InnerRecommendRatio
;
courseModel
.
InnerRecommendReNewRatio
=
orderModel
.
InnerRecommendReNewRatio
;
courseModel
.
CommissionReType
=
orderModel
.
CommissionReType
;
}
}
#
endregion
#
region
计算订单优惠信息
List
<
RB_Student_ViewModel
>
StuList
=
new
List
<
RB_Student_ViewModel
>();
//计算续费订单优惠
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
RenewOrder
&&
demodel
.
OrderId
==
0
)
{
demodel
.
DiscountMoney
=
coursePrice
*
(
courseModel
.
B2CReNewRatio
/
100
);
demodel
.
SaleRemark
=
"续费报名优惠"
+
courseModel
.
B2CReNewRatio
+
"%"
;
}
}
else
if
((
demodel
.
JoinType
==
OrderJoinTypeEnum
.
Normal
||
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
&&
demodel
.
OrderIdentify
!=
2
)
#
region
暂时不要
课程信息
{
//默认都是首次报名优惠
//var courseModel = courseRepository.GetEntity(demodel.CourseId);
//HK 2022 - 02 - 08修改
//decimal coursePrice = courseModel.SellPrice;//课程最低单价
decimal
DiscountMoney
=
coursePrice
*
(
courseModel
.
B2CRatio
/
100
);
//demodel.CommissionReType = courseModel.CommissionReType;
//if (demodel.DiscountMoney > DiscountMoney)
//#region 课程比例赋值
//if (demodel.OrderId <= 0)
//{
//{
// message = string.Format("优惠金额不正确,不能超过{0}元",DiscountMoney);
// demodel.B2CRatio = courseModel.B2CRatio;
// return false;
// demodel.B2CReNewRatio = courseModel.B2CReNewRatio;
// demodel.B2BRebateRatio = courseModel.B2BRebateRatio;
// demodel.B2BReNewRatio = courseModel.B2BReNewRatio;
// demodel.SchoolRebateRatio = courseModel.SchoolRebateRatio;
// demodel.SchoolReNewRatio = courseModel.SchoolReNewRatio;
// demodel.TransIntroductceRatio = courseModel.TransIntroductceRatio;
// demodel.TransIntroductceReNewRatio = courseModel.TransIntroductceReNewRatio;
// demodel.InnerRecommendRatio = courseModel.InnerRecommendRatio;
// demodel.InnerRecommendReNewRatio = courseModel.InnerRecommendReNewRatio;
// demodel.CommissionReType = courseModel.CommissionReType;
//}
//}
}
//else
else
if
(
demodel
.
OrderIdentify
==
2
&&
demodel
.
OrderId
==
0
)
//{
// //使用订单的比例
// courseModel.B2CRatio = orderModel.B2CRatio;
// courseModel.B2CReNewRatio = orderModel.B2CReNewRatio;
// courseModel.B2BRebateRatio = orderModel.B2BRebateRatio;
// courseModel.B2BReNewRatio = orderModel.B2BReNewRatio;
// courseModel.SchoolRebateRatio = orderModel.SchoolRebateRatio;
// courseModel.SchoolReNewRatio = orderModel.SchoolReNewRatio;
// courseModel.TransIntroductceRatio = orderModel.TransIntroductceRatio;
// courseModel.TransIntroductceReNewRatio = orderModel.TransIntroductceReNewRatio;
// courseModel.InnerRecommendRatio = orderModel.InnerRecommendRatio;
// courseModel.InnerRecommendReNewRatio = orderModel.InnerRecommendReNewRatio;
// courseModel.CommissionReType = orderModel.CommissionReType;
//}
//#endregion
#
region
计算订单优惠信息
List
<
RB_Student_ViewModel
>
StuList
=
new
List
<
RB_Student_ViewModel
>();
if
(
demodel
.
OrderIdentify
==
2
&&
demodel
.
OrderId
==
0
)
{
{
//查询学生列表
//查询学生列表
StuList
=
studentRepository
.
GetStudentListRepository
(
new
RB_Student_ViewModel
()
{
Group_Id
=
demodel
.
Group_Id
,
StuIds
=
demodel
.
StuIds
,
School_Id
=
-
1
});
StuList
=
studentRepository
.
GetStudentListRepository
(
new
RB_Student_ViewModel
()
{
Group_Id
=
demodel
.
Group_Id
,
StuIds
=
demodel
.
StuIds
,
School_Id
=
-
1
});
...
@@ -1000,44 +2029,30 @@ namespace Edu.Module.Course
...
@@ -1000,44 +2029,30 @@ namespace Edu.Module.Course
}
}
}
}
int
NormalNum
=
demodel
.
GuestNum
-
RenewNum
;
//首次报名数量
int
NormalNum
=
demodel
.
GuestNum
-
RenewNum
;
//首次报名数量
decimal
dmoney
=
coursePrice
*
(
courseModel
.
B2CRatio
/
100
)
*
NormalNum
+
coursePrice
*
(
courseModel
.
B2CReNewRatio
/
100
)
*
RenewNum
;
if
(
demodel
.
DiscountMoney
!=
dmoney
)
{
message
=
"优惠金额不正确"
;
return
false
;
}
}
else
if
(
demodel
.
OrderIdentify
==
2
&&
demodel
.
OrderId
>
0
)
{
//直接验证优惠金额
decimal
DiscountMoney
=
coursePrice
*
(
courseModel
.
B2CRatio
/
100
);
//HK 2022-02-08修改
//if (demodel.DiscountMoney > DiscountMoney)
//{
// message = string.Format("优惠金额有误,不能超过 {0} 元.", DiscountMoney);
// return false;
//}
}
}
//获取课程优惠
//获取课程优惠
var
coursePreferentialList
=
course_PreferentialRepository
.
GetCoursePreferentialListRepostory
(
new
RB_Course_Preferential_Extend
()
//var coursePreferentialList = course_PreferentialRepository.GetCoursePreferentialListRepostory(new RB_Course_Preferential_Extend()
{
//{
CourseId
=
demodel
.
CourseId
// CourseId = demodel.CourseId
});
//});
if
(
coursePreferentialList
!=
null
&&
coursePreferentialList
.
Count
>
0
)
//if (coursePreferentialList != null && coursePreferentialList.Count > 0)
{
//{
#
region
记录提成信息
// #region 记录提成信息
var
coursePreferentialModel
=
coursePreferentialList
.
FirstOrDefault
();
// var coursePreferentialModel = coursePreferentialList.FirstOrDefault();
demodel
.
CommissionType
=
coursePreferentialModel
?.
SaleCommissionType
??
0
;
// demodel.CommissionType = coursePreferentialModel?.SaleCommissionType ?? 0;
demodel
.
CommissionRate
=
coursePreferentialModel
?.
SaleCommissionMoney
??
0
;
// demodel.CommissionRate = coursePreferentialModel?.SaleCommissionMoney ?? 0;
demodel
.
CommissionTypeTH
=
coursePreferentialModel
?.
B2BCommissionType
??
0
;
// demodel.CommissionTypeTH = coursePreferentialModel?.B2BCommissionType ?? 0;
demodel
.
CommissionRateTH
=
coursePreferentialModel
?.
B2BCommissionMoney
??
0
;
// demodel.CommissionRateTH = coursePreferentialModel?.B2BCommissionMoney ?? 0;
if
(
coursePreferentialModel
!=
null
)
// if (coursePreferentialModel != null)
{
// {
demodel
.
CommissionRemark
=
"使用优惠Id:"
+
coursePreferentialModel
.
Id
+
" 返佣类型:"
+
demodel
.
CommissionType
+
" 返佣比例/金额:"
+
demodel
.
CommissionRate
+
" 同行返佣类型:"
+
demodel
.
CommissionTypeTH
+
" 同行返佣比例/金额:"
+
demodel
.
CommissionRateTH
;
// demodel.CommissionRemark = "使用优惠Id:" + coursePreferentialModel.Id + " 返佣类型:" + demodel.CommissionType + " 返佣比例/金额:" + demodel.CommissionRate + " 同行返佣类型:" + demodel.CommissionTypeTH + " 同行返佣比例/金额:" + demodel.CommissionRateTH;
}
// }
// #endregion
//}
#
endregion
#
endregion
}
#
endregion
#
endregion
if
(
demodel
.
OrderSource
==
OrderSourceEnum
.
EduClient
||
demodel
.
OrderSource
==
OrderSourceEnum
.
Client
)
if
(
demodel
.
OrderSource
==
OrderSourceEnum
.
EduClient
||
demodel
.
OrderSource
==
OrderSourceEnum
.
Client
)
...
@@ -1087,8 +2102,13 @@ namespace Edu.Module.Course
...
@@ -1087,8 +2102,13 @@ namespace Edu.Module.Course
//}
//}
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
{
{
var
newPreferPrice
=
Math
.
Round
(
coursePrice
/
courseModel
.
ClassHours
*
(
courseModel
.
ClassHours
-
demodel
.
StartClassHours
)
*
demodel
.
GuestNum
,
2
);
if
(
demodel
.
PreferPrice
!=
newPreferPrice
)
decimal
newPreferPrice
=
0
;
// Math.Round(coursePrice / courseModel.ClassHours * (courseModel.ClassHours - demodel.StartClassHours) * demodel.GuestNum, 2);
foreach
(
var
item
in
courseList
)
{
newPreferPrice
+=
(
item
.
SellPrice
/
item
.
ClassHours
*
(
item
.
ClassHours
-
demodel
.
StartClassHours
)
*
demodel
.
GuestNum
);
}
if
(
demodel
.
PreferPrice
!=
Math
.
Round
(
newPreferPrice
,
2
))
{
{
flag
=
false
;
flag
=
false
;
message
=
"应收总额不正确"
;
message
=
"应收总额不正确"
;
...
@@ -1101,7 +2121,12 @@ namespace Edu.Module.Course
...
@@ -1101,7 +2121,12 @@ namespace Edu.Module.Course
}
}
else
else
{
{
if
(
demodel
.
PreferPrice
!=
(
coursePrice
*
demodel
.
GuestNum
))
decimal
newPreferPrice
=
0
;
// Math.Round(coursePrice / courseModel.ClassHours * (courseModel.ClassHours - demodel.StartClassHours) * demodel.GuestNum, 2);
foreach
(
var
item
in
courseList
)
{
newPreferPrice
+=
(
item
.
SellPrice
*
demodel
.
GuestNum
);
}
if
(
demodel
.
PreferPrice
!=
Math
.
Round
(
newPreferPrice
,
2
))
{
{
flag
=
false
;
flag
=
false
;
message
=
"应收总额不正确"
;
message
=
"应收总额不正确"
;
...
@@ -1193,7 +2218,7 @@ namespace Edu.Module.Course
...
@@ -1193,7 +2218,7 @@ namespace Edu.Module.Course
{
nameof
(
RB_Order_ViewModel
.
TextbookFee
),
demodel
.
TextbookFee
},
{
nameof
(
RB_Order_ViewModel
.
TextbookFee
),
demodel
.
TextbookFee
},
{
nameof
(
RB_Order_ViewModel
.
CoursewareFee
),
demodel
.
CoursewareFee
},
{
nameof
(
RB_Order_ViewModel
.
CoursewareFee
),
demodel
.
CoursewareFee
},
};
};
flag
=
orderRepository
.
Update
(
keyValues
,
new
WhereHelper
(
nameof
(
RB_Order_ViewModel
.
OrderId
),
demodel
.
OrderId
));
flag
=
orderRepository
.
Update
(
keyValues
,
new
WhereHelper
(
nameof
(
RB_Order_ViewModel
.
OrderId
),
demodel
.
OrderId
));
//更新订单信息
#
region
记录日志信息
#
region
记录日志信息
LogContent
=
$"修改日语培训订单【
{
demodel
.
OrderId
}
】"
;
LogContent
=
$"修改日语培训订单【
{
demodel
.
OrderId
}
】"
;
...
@@ -1319,7 +2344,7 @@ namespace Edu.Module.Course
...
@@ -1319,7 +2344,7 @@ namespace Edu.Module.Course
message
=
"班级状态不正确"
;
message
=
"班级状态不正确"
;
return
flag
;
return
flag
;
}
}
demodel
.
Class_Price
=
courseModel
.
SellPrice
;
demodel
.
Class_Price
=
Math
.
Round
(
courseList
.
Sum
(
x
=>
x
.
SellPrice
)
/
StuList
.
Count
(),
2
);
//
courseModel.SellPrice;
if
(
demodel
.
EnterID
<=
0
&&
demodel
.
CreateBy
>
0
)
if
(
demodel
.
EnterID
<=
0
&&
demodel
.
CreateBy
>
0
)
{
{
if
(
userInfo
.
AccountType
==
AccountTypeEnum
.
Teacher
&&
demodel
.
HelpEnterId
==
0
)
if
(
userInfo
.
AccountType
==
AccountTypeEnum
.
Teacher
&&
demodel
.
HelpEnterId
==
0
)
...
@@ -1347,6 +2372,14 @@ namespace Edu.Module.Course
...
@@ -1347,6 +2372,14 @@ namespace Edu.Module.Course
{
{
SaleRemark
=
demodel
.
SaleRemark
;
SaleRemark
=
demodel
.
SaleRemark
;
}
}
#
region
订单课程信息
2024
-
09
-
02
add
by
:
w
if
(
demodel
.
OrderCourseList
!=
null
&&
demodel
.
OrderCourseList
.
Any
())
{
demodel
.
OrderCourseList
.
ForEach
(
x
=>
x
.
OrderId
=
demodel
.
OrderId
);
order_CourseRepository
.
InsertBatch
(
demodel
.
OrderCourseList
);
}
#
endregion
#
region
添加学员初次成交
/
多次成交时间
#
region
添加学员初次成交
/
多次成交时间
if
(
StuList
!=
null
&&
StuList
.
Count
>
0
)
if
(
StuList
!=
null
&&
StuList
.
Count
>
0
)
...
@@ -1435,7 +2468,7 @@ namespace Edu.Module.Course
...
@@ -1435,7 +2468,7 @@ namespace Edu.Module.Course
VolunteerMajor
=
""
,
VolunteerMajor
=
""
,
Price
=
0
,
Price
=
0
,
StudyRemark
=
""
,
StudyRemark
=
""
,
TotalHours
=
Convert
.
ToInt32
(
courseModel
.
ClassHours
),
TotalHours
=
courseList
.
Sum
(
x
=>
x
.
ClassHours
),
//
Convert.ToInt32(courseModel.ClassHours),
CompleteHours
=
0
,
CompleteHours
=
0
,
MakeUpHours
=
0
,
MakeUpHours
=
0
,
StuIcon
=
""
,
StuIcon
=
""
,
...
@@ -1490,7 +2523,7 @@ namespace Edu.Module.Course
...
@@ -1490,7 +2523,7 @@ namespace Edu.Module.Course
};
};
if
(
demodel
.
RenewOrderId
>
0
)
if
(
demodel
.
RenewOrderId
>
0
)
{
{
guestModel
.
TotalHours
=
Convert
.
ToInt32
(
courseModel
.
ClassHours
);
guestModel
.
TotalHours
=
courseList
.
Sum
(
x
=>
x
.
ClassHours
);
//
Convert.ToInt32(courseModel.ClassHours);
guestModel
.
RenewState
=
2
;
guestModel
.
RenewState
=
2
;
}
}
else
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
TransOrder
)
else
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
TransOrder
)
...
@@ -1606,7 +2639,7 @@ namespace Edu.Module.Course
...
@@ -1606,7 +2639,7 @@ namespace Edu.Module.Course
WeChatNo
=
item
.
WeChatNo
,
WeChatNo
=
item
.
WeChatNo
,
TotalChapterNo
=
MaxChapterNo
,
TotalChapterNo
=
MaxChapterNo
,
StudentId
=
item
.
StuId
,
StudentId
=
item
.
StuId
,
ClassUnitPrice
=
Math
.
Round
(((
demodel
.
PreferPrice
-
demodel
.
TextbookFee
-
demodel
.
CoursewareFee
)
/
demodel
.
TotalClassHours
),
2
),
//课时单价 (应收总金额-教材费-课件费)/总课时
ClassUnitPrice
=
Math
.
Round
(((
demodel
.
PreferPrice
-
demodel
.
TextbookFee
-
demodel
.
CoursewareFee
)
/
demodel
.
TotalClassHours
),
2
),
//课时单价 (应收总金额-教材费-课件费)/总课时
};
};
SetOrderGuestInfo
(
guestModel
,
out
string
Nmessage
);
SetOrderGuestInfo
(
guestModel
,
out
string
Nmessage
);
...
@@ -1803,7 +2836,7 @@ namespace Edu.Module.Course
...
@@ -1803,7 +2836,7 @@ namespace Edu.Module.Course
#
endregion
#
endregion
// 处理返佣信息
// 处理返佣信息
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
SetReturnOrderCommission
(
demodel
));
//
System.Threading.Tasks.Task.Run(() => SetReturnOrderCommission(demodel));
}
}
#
region
写日志
#
region
写日志
...
@@ -1846,6 +2879,7 @@ namespace Edu.Module.Course
...
@@ -1846,6 +2879,7 @@ namespace Edu.Module.Course
return
flag
;
return
flag
;
}
}
/// <summary>
/// <summary>
/// 留学就业下单
/// 留学就业下单
/// </summary>
/// </summary>
...
@@ -2763,7 +3797,7 @@ namespace Edu.Module.Course
...
@@ -2763,7 +3797,7 @@ namespace Edu.Module.Course
if
(
list
!=
null
&&
list
.
Count
>
0
)
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
{
string
guestIds
=
string
.
Join
(
","
,
list
.
Select
(
qitem
=>
qitem
.
Id
));
string
guestIds
=
string
.
Join
(
","
,
list
.
Select
(
qitem
=>
qitem
.
Id
));
string
goalIds
=
string
.
Join
(
","
,
list
?.
Where
(
x
=>
!
string
.
IsNullOrWhiteSpace
(
x
.
LearningGoals
))?.
Select
(
qitem
=>
qitem
.
LearningGoals
));
string
goalIds
=
string
.
Join
(
","
,
list
?.
Where
(
x
=>
!
string
.
IsNullOrWhiteSpace
(
x
.
LearningGoals
))?.
Select
(
qitem
=>
qitem
.
LearningGoals
));
var
goalList
=
learningGoalsRepository
.
GetLearningGoalsListRepository
(
new
Model
.
ViewModel
.
System
.
RB_LearningGoals_Extend
()
var
goalList
=
learningGoalsRepository
.
GetLearningGoalsListRepository
(
new
Model
.
ViewModel
.
System
.
RB_LearningGoals_Extend
()
{
{
...
@@ -4446,6 +5480,41 @@ namespace Edu.Module.Course
...
@@ -4446,6 +5480,41 @@ namespace Edu.Module.Course
public
bool
UpdateClassInventoryNum
(
RB_Order_ViewModel
demodel
)
public
bool
UpdateClassInventoryNum
(
RB_Order_ViewModel
demodel
)
{
{
bool
flag
=
false
;
bool
flag
=
false
;
if
(
demodel
.
OrderCourseList
!=
null
&&
demodel
.
OrderCourseList
.
Any
())
//2024-09-03 add by:W
{
string
orderCourseIds
=
string
.
Join
(
","
,
demodel
.
OrderCourseList
.
Select
(
x
=>
x
.
CourseId
));
var
courseList
=
courseRepository
.
GetCourseListRepository
(
new
RB_Course_ViewModel
{
QCourseIds
=
orderCourseIds
});
foreach
(
var
courseModel
in
courseList
)
{
if
(
courseModel
!=
null
&&
courseModel
.
MallGoodsId
>
0
)
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
Edu
.
Model
.
ViewModel
.
Mall
.
RB_Goods_SpecificationValue_Extend
()
{
GoodsId
=
courseModel
.
MallGoodsId
,
TenantId
=
Convert
.
ToInt32
(
Config
.
JHTenantId
),
MallBaseId
=
Convert
.
ToInt32
(
Config
.
JHMallBaseId
)
});
var
splist
=
goods_SpecificationPriceRepository
.
GetList
(
new
Edu
.
Model
.
ViewModel
.
Mall
.
RB_Goods_SpecificationPrice_Extend
()
{
GoodsId
=
courseModel
.
MallGoodsId
,
TenantId
=
Convert
.
ToInt32
(
Config
.
JHTenantId
),
MallBaseId
=
Convert
.
ToInt32
(
Config
.
JHMallBaseId
)
});
if
(
svlist
!=
null
&&
svlist
.
Any
(
x
=>
x
.
ClassId
==
demodel
.
ClassId
))
{
var
svModel
=
svlist
.
Where
(
x
=>
x
.
ClassId
==
demodel
.
ClassId
).
FirstOrDefault
();
if
(
svModel
!=
null
&&
svModel
.
Id
>
0
)
{
var
spModel
=
splist
.
Where
(
x
=>
x
.
SpecificationSort
==
svModel
.
Sort
.
ToString
()).
FirstOrDefault
();
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
Edu
.
Model
.
ViewModel
.
Mall
.
RB_Goods_SpecificationPrice_Extend
.
InventoryNum
),
spModel
.
InventoryNum
-
demodel
.
GuestNum
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
Edu
.
Model
.
ViewModel
.
Mall
.
RB_Goods_SpecificationPrice_Extend
.
Id
),
FiledValue
=
spModel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
flag
=
goods_SpecificationPriceRepository
.
Update
(
keyValues
,
wheres
);
}
}
}
}
}
else
{
var
courseModel
=
courseRepository
.
GetEntity
(
demodel
.
CourseId
).
RefMapperTo
<
RB_Course_ViewModel
>();
var
courseModel
=
courseRepository
.
GetEntity
(
demodel
.
CourseId
).
RefMapperTo
<
RB_Course_ViewModel
>();
if
(
courseModel
!=
null
&&
courseModel
.
MallGoodsId
>
0
)
if
(
courseModel
!=
null
&&
courseModel
.
MallGoodsId
>
0
)
{
{
...
@@ -4472,6 +5541,8 @@ namespace Edu.Module.Course
...
@@ -4472,6 +5541,8 @@ namespace Edu.Module.Course
}
}
}
}
}
}
}
return
flag
;
return
flag
;
}
}
...
...
Edu.Repository/Sell/RB_Order_CourseRepository.cs
0 → 100644
View file @
30626681
using
Edu.Model.Entity.Sell
;
using
Edu.Model.ViewModel.Sell
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Edu.Repository.Sell
{
/// <summary>
/// 订单课程仓储类
/// </summary>
public
class
RB_Order_CourseRepository
:
BaseRepository
<
RB_Order_Course
>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <param name="orderIds"></param>
/// <returns></returns>
public
List
<
RB_Order_Course
>
GetOrderCourseListRepository
(
RB_Order_Course
demodel
,
string
OrderIds
)
{
string
where
=
$@" 1=1 "
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" AND
{
nameof
(
RB_Order_Course
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
OrderId
>
0
)
{
where
+=
$@" AND
{
nameof
(
RB_Order_Course
.
OrderId
)}
=
{
demodel
.
OrderId
}
"
;
}
if
(
demodel
.
ClassId
>
0
)
{
where
+=
$@" AND
{
nameof
(
RB_Order_Course
.
ClassId
)}
=
{
demodel
.
ClassId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
OrderIds
))
{
where
+=
$@" AND
{
nameof
(
RB_Order_Course
.
OrderId
)}
in(
{
OrderIds
}
)"
;
}
string
sql
=
$@" SELECT * FROM RB_Order_Course WHERE
{
where
}
"
;
return
Get
<
RB_Order_Course
>(
sql
).
ToList
();
}
}
}
Edu.WebApi/Controllers/Course/OrderController.cs
View file @
30626681
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
Aliyun.OSS
;
using
Edu.Cache.User
;
using
Edu.Cache.User
;
using
Edu.Common.API
;
using
Edu.Common.API
;
using
Edu.Common.Enum.Course
;
using
Edu.Common.Enum.Course
;
...
@@ -16,6 +17,7 @@ using Edu.Module.Course;
...
@@ -16,6 +17,7 @@ using Edu.Module.Course;
using
Edu.WebApi.Filter
;
using
Edu.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
MongoDB.Driver.Core.Operations
;
using
Newtonsoft.Json.Linq
;
using
Newtonsoft.Json.Linq
;
namespace
Edu.WebApi.Controllers.Course
namespace
Edu.WebApi.Controllers.Course
...
@@ -823,7 +825,185 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -823,7 +825,185 @@ namespace Edu.WebApi.Controllers.Course
return
flag
?
ApiResult
.
Success
(
message
:
message
)
:
ApiResult
.
Failed
(
message
:
message
);
return
flag
?
ApiResult
.
Success
(
message
:
message
)
:
ApiResult
.
Failed
(
message
:
message
);
}
}
/// <summary>
/// 新增修改订单
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetNewClassOrder
()
{
var
userInfo
=
base
.
UserInfo
;
RB_Order_ViewModel
demodel
=
new
RB_Order_ViewModel
()
{
OrderId
=
base
.
ParmJObj
.
GetInt
(
"OrderId"
),
ClassId
=
base
.
ParmJObj
.
GetInt
(
"ClassId"
),
GuestNum
=
base
.
ParmJObj
.
GetInt
(
"GuestNum"
),
OrderSource
=
(
OrderSourceEnum
)
base
.
ParmJObj
.
GetInt
(
"OrderSource"
),
OrderType
=
(
OrderTypeEnum
)
base
.
ParmJObj
.
GetInt
(
"OrderType"
),
PreferPrice
=
base
.
ParmJObj
.
GetDecimal
(
"PreferPrice"
),
SaleRemark
=
base
.
ParmJObj
.
GetStringValue
(
"SaleRemark"
),
SourceId
=
base
.
ParmJObj
.
GetInt
(
"SourceId"
),
Unit_Price
=
base
.
ParmJObj
.
GetDecimal
(
"Unit_Price"
),
HelpEnterId
=
base
.
ParmJObj
.
GetInt
(
"HelpEnterId"
),
GeneralOccupation
=
base
.
ParmJObj
.
GetStringValue
(
"GeneralOccupation"
),
EduOccupation
=
base
.
ParmJObj
.
GetStringValue
(
"EduOccupation"
),
OrderNature
=
(
OrderNatureEnum
)
base
.
ParmJObj
.
GetInt
(
"OrderNature"
),
OldPreferPrice
=
base
.
ParmJObj
.
GetDecimal
(
"OldPreferPrice"
),
CourseId
=
base
.
ParmJObj
.
GetInt
(
"CourseId"
),
StartClassHours
=
base
.
ParmJObj
.
GetInt
(
"StartClassHours"
),
EffectTime
=
base
.
ParmJObj
.
GetDateTime
(
"EffectTime"
),
UpOrderId
=
base
.
ParmJObj
.
GetInt
(
"UpOrderId"
),
VisitorReserveId
=
base
.
ParmJObj
.
GetInt
(
"VisitorReserveId"
),
JoinType
=
OrderJoinTypeEnum
.
Normal
,
TargetJoinType
=
OrderJoinTypeEnum
.
Normal
,
DiscountMoney
=
base
.
ParmJObj
.
GetDecimal
(
"DiscountMoney"
),
PerDiscountMoney
=
base
.
ParmJObj
.
GetDecimal
(
"PerDiscountMoney"
),
IsLessPrice
=
base
.
ParmJObj
.
GetInt
(
"IsLessPrice"
),
LessPrice
=
base
.
ParmJObj
.
GetDecimal
(
"LessPrice"
),
PerLessMoney
=
base
.
ParmJObj
.
GetDecimal
(
"PerLessMoney"
),
CustomerId
=
base
.
ParmJObj
.
GetInt
(
"CustomerId"
),
StuIds
=
base
.
ParmJObj
.
GetStringValue
(
"StuIds"
),
OrderIdentify
=
base
.
ParmJObj
.
GetInt
(
"OrderIdentify"
),
CourseConsultantId
=
base
.
ParmJObj
.
GetInt
(
"CourseConsultantId"
),
EnterID
=
base
.
ParmJObj
.
GetInt
(
"EnterId"
),
ScrollSchoolId
=
base
.
ParmJObj
.
GetInt
(
"ScrollSchoolId"
),
SellPriceType
=
base
.
ParmJObj
.
GetInt
(
"Unit_PriceType"
,
1
),
TotalClassHours
=
base
.
ParmJObj
.
GetDecimal
(
"TotalClassHours"
),
TextbookFee
=
base
.
ParmJObj
.
GetDecimal
(
"TextbookFee"
),
CoursewareFee
=
base
.
ParmJObj
.
GetDecimal
(
"CoursewareFee"
),
};
var
IsInsertClass
=
base
.
ParmJObj
.
GetInt
(
"IsChaBan"
);
if
(
IsInsertClass
==
1
)
{
demodel
.
JoinType
=
OrderJoinTypeEnum
.
InsertClass
;
}
if
(
demodel
.
OrderType
==
OrderTypeEnum
.
CourseOrder
&&
demodel
.
ClassId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递班级id"
);
}
if
(
demodel
.
GuestNum
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递报名人数"
);
}
if
(
demodel
.
Unit_Price
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"成交单价不能小于0"
);
}
if
(
demodel
.
OrderSource
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请选择客人来源"
);
}
if
(
demodel
.
OrderIdentify
==
2
&&
string
.
IsNullOrEmpty
(
demodel
.
StuIds
)
&&
demodel
.
OrderId
==
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递选择客户"
);
}
if
(
demodel
.
OrderIdentify
==
2
&&
!
string
.
IsNullOrEmpty
(
demodel
.
StuIds
))
{
//验证学生是否已有其他订单
var
vlist
=
orderModule
.
ValidataStuOrder
(
demodel
.
StuIds
,
userInfo
.
Group_Id
);
if
(
vlist
.
Any
())
{
var
vmodel
=
vlist
.
FirstOrDefault
();
return
ApiResult
.
Tip
(
"学员"
+
vmodel
.
GuestName
+
"存在有效未付款订单"
+
vmodel
.
OrderId
+
",请取消该订单后再试"
,
vmodel
.
OrderId
);
}
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
StuIds
))
{
int
gNum
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
demodel
.
StuIds
+
"]"
).
Count
();
if
(
demodel
.
GuestNum
!=
gNum
)
{
return
ApiResult
.
ParamIsNull
(
"客人数量不正确"
);
}
//ld 2023-03-22 强验证 学生的到访表
//string rmsg = orderModule.GetStudentVisitVoucher(demodel.StuIds);
//if (rmsg != "")
//{
// return ApiResult.Failed(rmsg);
//}
}
demodel
.
Group_Id
=
userInfo
.
Group_Id
;
demodel
.
School_Id
=
userInfo
.
School_Id
;
demodel
.
Dept_Id
=
userInfo
.
DeptId
;
demodel
.
OrderForm
=
OrderFormEnum
.
Computer
;
if
(
demodel
.
OrderType
==
OrderTypeEnum
.
CourseOrder
&&
demodel
.
OrderIdentify
!=
2
)
{
demodel
.
EnterID
=
userInfo
.
Id
;
//由前端传递了, 可能会不存在 (此字段为市场人员)
}
demodel
.
OrderState
=
OrderStateEnum
.
Normal
;
demodel
.
TradeWay
=
TradeWayEnum
.
OnLine
;
demodel
.
CreateBy
=
userInfo
.
Id
;
demodel
.
CreateTime
=
DateTime
.
Now
;
demodel
.
UpdateBy
=
userInfo
.
Id
;
demodel
.
UpdateTime
=
DateTime
.
Now
;
var
flag
=
false
;
string
message
=
""
;
//订单课程
demodel
.
OrderCourseList
=
new
List
<
Model
.
Entity
.
Sell
.
RB_Order_Course
>();
var
orderCourseListStr
=
base
.
ParmJObj
.
GetStringValue
(
"OrderCourseList"
);
if
(!
string
.
IsNullOrWhiteSpace
(
orderCourseListStr
))
{
List
<
object
>
OrderCourseObjList
=
JsonHelper
.
DeserializeObject
<
List
<
object
>>(
orderCourseListStr
);
foreach
(
var
itemOrderCourse
in
OrderCourseObjList
)
{
JObject
parmsI
=
JObject
.
Parse
(
itemOrderCourse
.
ToString
());
Model
.
Entity
.
Sell
.
RB_Order_Course
orderCourseModel
=
new
Model
.
Entity
.
Sell
.
RB_Order_Course
{
OrderCourseId
=
parmsI
.
GetInt
(
"OrderCourseId"
),
OrderId
=
parmsI
.
GetInt
(
"OrderId"
),
ClassId
=
parmsI
.
GetInt
(
"ClassId"
),
Class_Price
=
parmsI
.
GetDecimal
(
"Class_Price"
),
Unit_Price
=
parmsI
.
GetDecimal
(
"Unit_Price"
),
TextbookFee
=
parmsI
.
GetDecimal
(
"TextbookFee"
),
CoursewareFee
=
parmsI
.
GetDecimal
(
"CoursewareFee"
),
SellPriceType
=
parmsI
.
GetInt
(
"SellPriceType"
),
TotalClassHours
=
parmsI
.
GetDecimal
(
"TotalClassHours"
),
GuestNum
=
parmsI
.
GetInt
(
"GuestNum"
),
PreferPrice
=
parmsI
.
GetInt
(
"PreferPrice"
),
Group_Id
=
demodel
.
Group_Id
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
UpdateBy
=
demodel
.
UpdateBy
,
UpdateTime
=
demodel
.
UpdateTime
,
SourceId
=
demodel
.
SourceId
,
HelpEnterId
=
parmsI
.
GetInt
(
"HelpEnterId"
),
CourseId
=
parmsI
.
GetInt
(
"CouseId"
),
TransIntroductceRatio
=
parmsI
.
GetDecimal
(
"TransIntroductceRatio"
),
TransIntroductceReNewRatio
=
parmsI
.
GetDecimal
(
"TransIntroductceReNewRatio"
),
InnerRecommendRatio
=
parmsI
.
GetDecimal
(
"InnerRecommendRatio"
),
InnerRecommendReNewRatio
=
parmsI
.
GetDecimal
(
"InnerRecommendReNewRatio"
),
CommissionReType
=
parmsI
.
GetInt
(
"CommissionReType"
),
ScrollSchoolId
=
parmsI
.
GetInt
(
"ScrollSchoolId"
),
StudyBroadRebateMoney
=
parmsI
.
GetDecimal
(
"StudyBroadRebateMoney"
),
};
demodel
.
OrderCourseList
.
Add
(
orderCourseModel
);
}
}
if
(
demodel
.
OrderType
==
OrderTypeEnum
.
CourseOrder
)
{
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
Normal
)
{
demodel
.
StartClassHours
=
0
;
}
else
if
(
demodel
.
JoinType
==
OrderJoinTypeEnum
.
InsertClass
)
{
if
(
demodel
.
CourseId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
message
:
"请选择插班课程!"
);
}
}
flag
=
orderModule
.
SetClassOrderModule_V2
(
demodel
,
userInfo
,
base
.
CheckUserActionAuth
(
"Edit_Order"
),
out
message
);
}
else
{
flag
=
orderModule
.
SetStudyOrderModule
(
demodel
,
userInfo
,
out
message
);
}
return
flag
?
ApiResult
.
Success
(
message
:
message
)
:
ApiResult
.
Failed
(
message
:
message
);
}
/// <summary>
/// <summary>
/// 新增订单 (批量) 2024-09-02 add by:W
/// 新增订单 (批量) 2024-09-02 add by:W
...
@@ -857,7 +1037,6 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -857,7 +1037,6 @@ namespace Edu.WebApi.Controllers.Course
HelpEnterId
=
parms
.
GetInt
(
"HelpEnterId"
),
HelpEnterId
=
parms
.
GetInt
(
"HelpEnterId"
),
GeneralOccupation
=
parms
.
GetStringValue
(
"GeneralOccupation"
),
GeneralOccupation
=
parms
.
GetStringValue
(
"GeneralOccupation"
),
EduOccupation
=
parms
.
GetStringValue
(
"EduOccupation"
),
EduOccupation
=
parms
.
GetStringValue
(
"EduOccupation"
),
OrderNature
=
(
OrderNatureEnum
)
parms
.
GetInt
(
"OrderNature"
),
OrderNature
=
(
OrderNatureEnum
)
parms
.
GetInt
(
"OrderNature"
),
OldPreferPrice
=
parms
.
GetDecimal
(
"OldPreferPrice"
),
OldPreferPrice
=
parms
.
GetDecimal
(
"OldPreferPrice"
),
CourseId
=
parms
.
GetInt
(
"CourseId"
),
CourseId
=
parms
.
GetInt
(
"CourseId"
),
...
@@ -962,6 +1141,47 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -962,6 +1141,47 @@ namespace Edu.WebApi.Controllers.Course
return
ApiResult
.
Failed
(
"只能课程订单批量操作"
);
return
ApiResult
.
Failed
(
"只能课程订单批量操作"
);
}
}
//订单课程
demodel
.
OrderCourseList
=
new
List
<
Model
.
Entity
.
Sell
.
RB_Order_Course
>();
var
orderCourseListStr
=
parms
.
GetStringValue
(
"OrderCourseList"
);
if
(!
string
.
IsNullOrWhiteSpace
(
orderCourseListStr
))
{
List
<
object
>
OrderCourseObjList
=
JsonHelper
.
DeserializeObject
<
List
<
object
>>(
orderCourseListStr
);
foreach
(
var
itemOrderCourse
in
OrderCourseObjList
)
{
JObject
parmsI
=
JObject
.
Parse
(
itemOrderCourse
.
ToString
());
Model
.
Entity
.
Sell
.
RB_Order_Course
orderCourseModel
=
new
Model
.
Entity
.
Sell
.
RB_Order_Course
{
OrderCourseId
=
parmsI
.
GetInt
(
"OrderCourseId"
),
OrderId
=
parmsI
.
GetInt
(
"OrderId"
),
ClassId
=
parmsI
.
GetInt
(
"ClassId"
),
Class_Price
=
parmsI
.
GetDecimal
(
"Class_Price"
),
Unit_Price
=
parmsI
.
GetDecimal
(
"Unit_Price"
),
TextbookFee
=
parmsI
.
GetDecimal
(
"TextbookFee"
),
CoursewareFee
=
parmsI
.
GetDecimal
(
"CoursewareFee"
),
SellPriceType
=
parmsI
.
GetInt
(
"SellPriceType"
),
TotalClassHours
=
parmsI
.
GetDecimal
(
"TotalClassHours"
),
GuestNum
=
parmsI
.
GetInt
(
"GuestNum"
),
PreferPrice
=
parmsI
.
GetInt
(
"PreferPrice"
),
Group_Id
=
demodel
.
Group_Id
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
demodel
.
CreateTime
,
UpdateBy
=
demodel
.
UpdateBy
,
UpdateTime
=
demodel
.
UpdateTime
,
SourceId
=
demodel
.
SourceId
,
HelpEnterId
=
parmsI
.
GetInt
(
"HelpEnterId"
),
CourseId
=
parmsI
.
GetInt
(
"CourseId"
),
TransIntroductceRatio
=
parmsI
.
GetDecimal
(
"TransIntroductceRatio"
),
TransIntroductceReNewRatio
=
parmsI
.
GetDecimal
(
"TransIntroductceReNewRatio"
),
InnerRecommendRatio
=
parmsI
.
GetDecimal
(
"InnerRecommendRatio"
),
InnerRecommendReNewRatio
=
parmsI
.
GetDecimal
(
"InnerRecommendReNewRatio"
),
CommissionReType
=
parmsI
.
GetInt
(
"CommissionReType"
),
ScrollSchoolId
=
parmsI
.
GetInt
(
"ScrollSchoolId"
),
StudyBroadRebateMoney
=
parmsI
.
GetDecimal
(
"StudyBroadRebateMoney"
),
};
demodel
.
OrderCourseList
.
Add
(
orderCourseModel
);
}
}
deList
.
Add
(
demodel
);
deList
.
Add
(
demodel
);
}
}
if
(!
deList
.
Any
())
if
(!
deList
.
Any
())
...
...
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