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
07237255
Commit
07237255
authored
Nov 11, 2021
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1投稿提成
parent
b903aaf0
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
2697 additions
and
7 deletions
+2697
-7
RB_TeaCon_Commission_Details.cs
Edu.Model/Entity/Sell/RB_TeaCon_Commission_Details.cs
+66
-0
RB_TeaCon_Commission_Periods.cs
Edu.Model/Entity/Sell/RB_TeaCon_Commission_Periods.cs
+61
-0
RB_TeaCon_Commission_Rule.cs
Edu.Model/Entity/Sell/RB_TeaCon_Commission_Rule.cs
+56
-0
RB_Contribute_Info.cs
Edu.Model/Entity/WeChat/RB_Contribute_Info.cs
+10
-0
RB_WeChat_CustomerInfo.cs
Edu.Model/Entity/WeChat/RB_WeChat_CustomerInfo.cs
+1
-1
RB_TeaCon_Commission_Details_ViewModel.cs
.../ViewModel/Sell/RB_TeaCon_Commission_Details_ViewModel.cs
+43
-0
RB_TeaCon_Commission_Periods_ViewModel.cs
.../ViewModel/Sell/RB_TeaCon_Commission_Periods_ViewModel.cs
+15
-0
RB_TeaCon_Commission_Rule_ViewModel.cs
...del/ViewModel/Sell/RB_TeaCon_Commission_Rule_ViewModel.cs
+15
-0
RB_WeChat_CustomerClueRule_ViewModel.cs
.../ViewModel/WeChat/RB_WeChat_CustomerClueRule_ViewModel.cs
+35
-0
TeachingRewardsModule.cs
Edu.Module.Course/TeachingRewardsModule.cs
+400
-3
EducationReceiptModule.cs
Edu.Module.EduTask/EducationReceiptModule.cs
+2
-1
QYCustomerModule.cs
Edu.Module.QYWeChat/QYCustomerModule.cs
+1002
-0
RB_TeaCon_Commission_DetailsRepository.cs
...Repository/Sell/RB_TeaCon_Commission_DetailsRepository.cs
+180
-0
RB_TeaCon_Commission_PeriodsRepository.cs
...Repository/Sell/RB_TeaCon_Commission_PeriodsRepository.cs
+70
-0
RB_TeaCon_Commission_RuleRepository.cs
Edu.Repository/Sell/RB_TeaCon_Commission_RuleRepository.cs
+37
-0
RB_Contribute_InfoRepository.cs
Edu.Repository/WeChat/RB_Contribute_InfoRepository.cs
+13
-0
RB_WeChat_CustomerClueRuleRepository.cs
...Repository/WeChat/RB_WeChat_CustomerClueRuleRepository.cs
+84
-0
RB_WeChat_CustomerInfoRepository.cs
Edu.Repository/WeChat/RB_WeChat_CustomerInfoRepository.cs
+1
-1
TeachingRewardsController.cs
Edu.WebApi/Controllers/Course/TeachingRewardsController.cs
+362
-0
QYContributeController.cs
Edu.WebApi/Controllers/QYWeChat/QYContributeController.cs
+2
-0
QYCustomerController.cs
Edu.WebApi/Controllers/QYWeChat/QYCustomerController.cs
+242
-1
No files found.
Edu.Model/Entity/Sell/RB_TeaCon_Commission_Details.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Common.Enum.Course
;
using
System
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.Sell
{
/// <summary>
/// 投稿提成明细实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_TeaCon_Commission_Details
{
/// <summary>
/// 编号
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 教师ID
/// </summary>
public
int
TeacherId
{
get
;
set
;
}
/// <summary>
/// 投稿ID
/// </summary>
public
int
ContributeId
{
get
;
set
;
}
/// <summary>
/// 父级ID
/// </summary>
public
int
PeriodId
{
get
;
set
;
}
/// <summary>
/// 期号
/// </summary>
public
string
Periods
{
get
;
set
;
}
/// <summary>
/// 提成总金额
/// </summary>
public
decimal
CommissionMoney
{
get
;
set
;
}
/// <summary>
/// 部门id
/// </summary>
public
int
Depart_Id
{
get
;
set
;
}
/// <summary>
/// 校区id
/// </summary>
public
int
School_Id
{
get
;
set
;
}
/// <summary>
/// 集团id
/// </summary>
public
int
Group_Id
{
get
;
set
;
}
/// <summary>
/// 备注, 记录抵扣金额等等
/// </summary>
public
string
Remark
{
get
;
set
;
}
}
}
Edu.Model/Entity/Sell/RB_TeaCon_Commission_Periods.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Common.Enum.Course
;
using
System
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.Sell
{
/// <summary>
/// 投稿提成期数实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_TeaCon_Commission_Periods
{
/// <summary>
/// 编号
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 名称
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// 期数
/// </summary>
public
string
Periods
{
get
;
set
;
}
/// <summary>
/// 创建人
/// </summary>
public
int
CreateBy
{
get
;
set
;
}
/// <summary>
/// 创建日期
/// </summary>
public
DateTime
CreateTime
{
get
;
set
;
}
/// <summary>
/// 累计金额
/// </summary>
public
decimal
SumPrice
{
get
;
set
;
}
/// <summary>
/// 集团编号
/// </summary>
public
int
Group_Id
{
get
;
set
;
}
/// <summary>
/// 关联财务单据ids
/// </summary>
public
string
Financials
{
get
;
set
;
}
/// <summary>
/// 已发放人员的列表
/// </summary>
public
string
EmpIds
{
get
;
set
;
}
}
}
Edu.Model/Entity/Sell/RB_TeaCon_Commission_Rule.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Common.Enum.Course
;
using
System
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.Sell
{
/// <summary>
/// 投稿提成规则实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_TeaCon_Commission_Rule
{
/// <summary>
/// Id
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 单篇投稿的提成金额
/// </summary>
public
decimal
Money
{
get
;
set
;
}
/// <summary>
/// 删除状态
/// </summary>
public
int
Status
{
get
;
set
;
}
/// <summary>
/// 集团编号
/// </summary>
public
int
Group_Id
{
get
;
set
;
}
/// <summary>
/// 创建人
/// </summary>
public
int
CreateBy
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
public
DateTime
CreateTime
{
get
;
set
;
}
/// <summary>
/// 修改人
/// </summary>
public
int
UpdateBy
{
get
;
set
;
}
/// <summary>
/// 修改时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
}
}
Edu.Model/Entity/WeChat/RB_Contribute_Info.cs
View file @
07237255
...
...
@@ -133,5 +133,15 @@ namespace Edu.Model.Entity.WeChat
/// </summary>
public
string
SourceUrl
{
get
;
set
;
}
/// <summary>
/// 是否已发放提成 1是
/// </summary>
public
int
IsSendCommission
{
get
;
set
;
}
/// <summary>
/// 提成金额
/// </summary>
public
decimal
CommissionMoney
{
get
;
set
;
}
}
}
Edu.Model/Entity/WeChat/RB_WeChat_CustomerInfo.cs
View file @
07237255
...
...
@@ -179,7 +179,7 @@ namespace Edu.Model.Entity.WeChat
public
int
ClueState
{
get
;
set
;
}
/// <summary>
/// 转客户时间 ClueState=4
///
线索
转客户时间 ClueState=4
/// </summary>
public
DateTime
?
TurnCustomerTime
{
get
;
set
;
}
...
...
Edu.Model/ViewModel/Sell/RB_TeaCon_Commission_Details_ViewModel.cs
0 → 100644
View file @
07237255
using
Edu.Model.Entity.Sell
;
using
System
;
using
System.Collections.Generic
;
namespace
Edu.Model.ViewModel.Sell
{
/// <summary>
/// 投稿提成明细实体类
/// </summary>
[
Serializable
]
public
class
RB_TeaCon_Commission_Details_ViewModel
:
RB_TeaCon_Commission_Details
{
/// <summary>
/// 老师ids
/// </summary>
public
string
TeacherIds
{
get
;
set
;
}
/// <summary>
/// 教师
/// </summary>
public
string
TeacherName
{
get
;
set
;
}
/// <summary>
/// 部门
/// </summary>
public
string
DeptName
{
get
;
set
;
}
/// <summary>
/// 校区
/// </summary>
public
string
SchoolName
{
get
;
set
;
}
/// <summary>
/// 投稿标题
/// </summary>
public
string
ContributeTitle
{
get
;
set
;
}
/// <summary>
/// 投稿类型
/// </summary>
public
string
ContributeType
{
get
;
set
;
}
}
}
\ No newline at end of file
Edu.Model/ViewModel/Sell/RB_TeaCon_Commission_Periods_ViewModel.cs
0 → 100644
View file @
07237255
using
Edu.Model.Entity.Sell
;
using
System
;
using
System.Collections.Generic
;
namespace
Edu.Model.ViewModel.Sell
{
/// <summary>
/// 投稿提成期数实体类
/// </summary>
[
Serializable
]
public
class
RB_TeaCon_Commission_Periods_ViewModel
:
RB_TeaCon_Commission_Periods
{
}
}
\ No newline at end of file
Edu.Model/ViewModel/Sell/RB_TeaCon_Commission_Rule_ViewModel.cs
0 → 100644
View file @
07237255
using
Edu.Model.Entity.Sell
;
using
System
;
using
System.Collections.Generic
;
namespace
Edu.Model.ViewModel.Sell
{
/// <summary>
/// 投稿提成规则实体类
/// </summary>
[
Serializable
]
public
class
RB_TeaCon_Commission_Rule_ViewModel
:
RB_TeaCon_Commission_Rule
{
}
}
\ No newline at end of file
Edu.Model/ViewModel/WeChat/RB_WeChat_CustomerClueRule_ViewModel.cs
0 → 100644
View file @
07237255
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Edu.Common.Enum.Sale
;
using
Edu.Model.Entity.WeChat
;
using
Edu.Model.Public
;
namespace
Edu.Model.ViewModel.WeChat
{
/// <summary>
/// 企业微信客户线索规则扩展类
/// </summary>
public
class
RB_WeChat_CustomerClueRule_ViewModel
:
RB_WeChat_CustomerClueRule
{
/// <summary>
/// 分配的部门
/// </summary>
public
List
<
User
.
RB_Department_ViewModel
>
DeptList
{
get
;
set
;
}
/// <summary>
/// 分配的员工
/// </summary>
public
List
<
User
.
Employee_ViewModel
>
EmpList
{
get
;
set
;
}
/// <summary>
/// 客户筛选列表 (标签 + 自定义字段)
/// </summary>
public
List
<
CustomerCommissionSelectModel
>
ConditionList
{
get
;
set
;
}
/// <summary>
/// 条件描述列表
/// </summary>
public
List
<
string
>
ConditionStrList
{
get
;
set
;
}
}
}
Edu.Module.Course/TeachingRewardsModule.cs
View file @
07237255
...
...
@@ -109,6 +109,10 @@ namespace Edu.Module.Course
/// </summary>
private
readonly
RB_AccountRepository
accountRepository
=
new
RB_AccountRepository
();
/// <summary>
/// 部门
/// </summary>
private
readonly
RB_DepartmentRepository
departmentRepository
=
new
RB_DepartmentRepository
();
/// <summary>
/// 财务配置
/// </summary>
private
readonly
RB_Finance_ConfigRepository
finance_ConfigRepository
=
new
RB_Finance_ConfigRepository
();
...
...
@@ -116,6 +120,23 @@ namespace Edu.Module.Course
/// 财务单据
/// </summary>
private
readonly
RB_FinanceRepository
financeRepository
=
new
RB_FinanceRepository
();
/// <summary>
/// 投稿提成规则
/// </summary>
private
readonly
RB_TeaCon_Commission_RuleRepository
teaCon_Commission_RuleRepository
=
new
RB_TeaCon_Commission_RuleRepository
();
/// <summary>
/// 投稿提成期数
/// </summary>
private
readonly
RB_TeaCon_Commission_PeriodsRepository
teaCon_Commission_PeriodsRepository
=
new
RB_TeaCon_Commission_PeriodsRepository
();
/// <summary>
/// 投稿提成明细
/// </summary>
private
readonly
RB_TeaCon_Commission_DetailsRepository
teaCon_Commission_DetailsRepository
=
new
RB_TeaCon_Commission_DetailsRepository
();
/// <summary>
/// 投稿信息
/// </summary>
private
readonly
Repository
.
WeChat
.
RB_Contribute_InfoRepository
contribute_InfoRepository
=
new
Repository
.
WeChat
.
RB_Contribute_InfoRepository
();
#
region
教务配置
...
...
@@ -893,8 +914,6 @@ namespace Edu.Module.Course
}
/// <summary>
/// 新增教师奖励
/// </summary>
...
...
@@ -1146,7 +1165,7 @@ namespace Edu.Module.Course
{
return
true
;
}
}
}
/// <summary>
/// 修改绩效状态
...
...
@@ -2016,5 +2035,383 @@ namespace Edu.Module.Course
}
#
endregion
#
region
投稿提成
/// <summary>
/// 获取投稿提成配置
/// </summary>
/// <param name="group_Id"></param>
/// <returns></returns>
public
RB_TeaCon_Commission_Rule_ViewModel
GetTeacherContributeConfig
(
int
group_Id
)
{
return
teaCon_Commission_RuleRepository
.
GetList
(
new
RB_TeaCon_Commission_Rule_ViewModel
()
{
Group_Id
=
group_Id
}).
FirstOrDefault
();
}
/// <summary>
/// 保存投稿提成配置
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
string
SetTeacherContributeConfig
(
RB_TeaCon_Commission_Rule_ViewModel
demodel
)
{
if
(
demodel
.
Id
>
0
)
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_TeaCon_Commission_Rule_ViewModel
.
Money
),
demodel
.
Money
},
{
nameof
(
RB_TeaCon_Commission_Rule_ViewModel
.
UpdateBy
),
demodel
.
UpdateBy
},
{
nameof
(
RB_TeaCon_Commission_Rule_ViewModel
.
UpdateTime
),
demodel
.
UpdateTime
},
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_TeaCon_Commission_Rule_ViewModel
.
Id
),
FiledValue
=
demodel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
teaCon_Commission_RuleRepository
.
Update
(
keyValues
,
wheres
);
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
bool
flag
=
teaCon_Commission_RuleRepository
.
Insert
(
demodel
)
>
0
;
return
flag
?
""
:
"出错了,请联系管理员"
;
}
}
/// <summary>
/// 获取投稿提成分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Periods_ViewModel
>
GetTeaConCommissionPeriodsPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_TeaCon_Commission_Periods_ViewModel
dmodel
)
{
var
list
=
teaCon_Commission_PeriodsRepository
.
GetPageList
(
pageIndex
,
pageSize
,
out
count
,
dmodel
);
if
(
list
.
Any
())
{
//查询财务单据
string
periodsIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Id
));
var
financeList
=
financeRepository
.
GetListSingle
(
new
RB_Finance_Extend
()
{
RB_Group_Id
=
dmodel
.
Group_Id
,
FinanceType
=
2
,
OtherType
=
47
,
ReFinanceIds
=
periodsIds
,
IsSelectNormal
=
1
});
foreach
(
var
item
in
list
)
{
var
flist
=
financeList
.
Where
(
x
=>
x
.
ReFinanceId
==
item
.
Id
).
Select
(
x
=>
x
.
FrID
);
if
(
flist
.
Any
())
{
item
.
Financials
=
string
.
Join
(
","
,
flist
);
}
}
}
return
list
;
}
/// <summary>
/// 获取投稿提成列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Periods_ViewModel
>
GetTeaConCommissionPeriodsList
(
RB_TeaCon_Commission_Periods_ViewModel
dmodel
)
{
return
teaCon_Commission_PeriodsRepository
.
GetList
(
dmodel
);
}
/// <summary>
/// 获取投稿用户提成列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Details_ViewModel
>
GetTeaConCommissionUserList
(
RB_TeaCon_Commission_Details_ViewModel
dmodel
)
{
var
list
=
teaCon_Commission_DetailsRepository
.
GetTeaConCommissionUserList
(
dmodel
);
if
(
list
.
Any
())
{
//查询用户 部门 校区
string
userIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
TeacherId
).
Distinct
());
string
deptIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Depart_Id
).
Distinct
());
string
schoolIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
School_Id
).
Distinct
());
var
ulist
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QIds
=
userIds
});
var
dlist
=
departmentRepository
.
GetDepartmentListRepository
(
new
RB_Department_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QDeptIds
=
deptIds
});
var
slist
=
schoolRepository
.
GetSchoolListRepository
(
new
RB_School_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QSIds
=
schoolIds
});
foreach
(
var
item
in
list
)
{
var
umodel
=
ulist
.
Where
(
x
=>
x
.
Id
==
item
.
TeacherId
).
FirstOrDefault
();
item
.
TeacherName
=
umodel
.
EmployeeName
+
(
umodel
.
LeaveStatus
==
Common
.
Enum
.
User
.
LeaveStatusEnum
.
Departure
?
"离职"
:
""
);
item
.
DeptName
=
dlist
.
Where
(
x
=>
x
.
DeptId
==
item
.
Depart_Id
).
FirstOrDefault
()?.
DeptName
??
""
;
item
.
SchoolName
=
slist
.
Where
(
x
=>
x
.
SId
==
item
.
School_Id
).
FirstOrDefault
()?.
SName
??
""
;
}
}
return
list
;
}
/// <summary>
/// 获取用户提成明细
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Details_ViewModel
>
GetTeaConCommissionUserDetailList
(
RB_TeaCon_Commission_Details_ViewModel
dmodel
)
{
var
list
=
teaCon_Commission_DetailsRepository
.
GetList
(
dmodel
);
if
(
list
.
Any
())
{
//查询用户 部门 校区
string
userIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
TeacherId
).
Distinct
());
string
deptIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Depart_Id
).
Distinct
());
string
schoolIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
School_Id
).
Distinct
());
var
ulist
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QIds
=
userIds
});
var
dlist
=
departmentRepository
.
GetDepartmentListRepository
(
new
RB_Department_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QDeptIds
=
deptIds
});
var
slist
=
schoolRepository
.
GetSchoolListRepository
(
new
RB_School_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QSIds
=
schoolIds
});
string
conIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
ContributeId
));
var
clist
=
contribute_InfoRepository
.
GetList
(
new
Model
.
ViewModel
.
WeChat
.
RB_Contribute_Info_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
Q_ContributeIds
=
conIds
});
foreach
(
var
item
in
list
)
{
var
umodel
=
ulist
.
Where
(
x
=>
x
.
Id
==
item
.
TeacherId
).
FirstOrDefault
();
item
.
TeacherName
=
umodel
.
EmployeeName
+
(
umodel
.
LeaveStatus
==
Common
.
Enum
.
User
.
LeaveStatusEnum
.
Departure
?
"离职"
:
""
);
item
.
DeptName
=
dlist
.
Where
(
x
=>
x
.
DeptId
==
item
.
Depart_Id
).
FirstOrDefault
()?.
DeptName
??
""
;
item
.
SchoolName
=
slist
.
Where
(
x
=>
x
.
SId
==
item
.
School_Id
).
FirstOrDefault
()?.
SName
??
""
;
var
cmodel
=
clist
.
Where
(
x
=>
x
.
Id
==
item
.
ContributeId
).
FirstOrDefault
();
item
.
ContributeTitle
=
cmodel
?.
Title
??
""
;
item
.
ContributeType
=
cmodel
?.
Type
.
ToName
()
??
""
;
}
}
return
list
;
}
/// <summary>
/// 获取提成统计分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Details_ViewModel
>
GetTeaConCommissionStatisticsPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_TeaCon_Commission_Details_ViewModel
dmodel
)
{
var
list
=
teaCon_Commission_DetailsRepository
.
GetPageList
(
pageIndex
,
pageSize
,
out
count
,
dmodel
);
if
(
list
.
Any
())
{
//查询用户 部门 校区
string
userIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
TeacherId
).
Distinct
());
string
deptIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Depart_Id
).
Distinct
());
string
schoolIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
School_Id
).
Distinct
());
var
ulist
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QIds
=
userIds
});
var
dlist
=
departmentRepository
.
GetDepartmentListRepository
(
new
RB_Department_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QDeptIds
=
deptIds
});
var
slist
=
schoolRepository
.
GetSchoolListRepository
(
new
RB_School_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
QSIds
=
schoolIds
});
string
conIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
ContributeId
));
var
clist
=
contribute_InfoRepository
.
GetList
(
new
Model
.
ViewModel
.
WeChat
.
RB_Contribute_Info_ViewModel
()
{
Group_Id
=
dmodel
.
Group_Id
,
Q_ContributeIds
=
conIds
});
foreach
(
var
item
in
list
)
{
var
umodel
=
ulist
.
Where
(
x
=>
x
.
Id
==
item
.
TeacherId
).
FirstOrDefault
();
item
.
TeacherName
=
umodel
.
EmployeeName
+
(
umodel
.
LeaveStatus
==
Common
.
Enum
.
User
.
LeaveStatusEnum
.
Departure
?
"离职"
:
""
);
item
.
DeptName
=
dlist
.
Where
(
x
=>
x
.
DeptId
==
item
.
Depart_Id
).
FirstOrDefault
()?.
DeptName
??
""
;
item
.
SchoolName
=
slist
.
Where
(
x
=>
x
.
SId
==
item
.
School_Id
).
FirstOrDefault
()?.
SName
??
""
;
var
cmodel
=
clist
.
Where
(
x
=>
x
.
Id
==
item
.
ContributeId
).
FirstOrDefault
();
item
.
ContributeTitle
=
cmodel
?.
Title
??
""
;
item
.
ContributeType
=
cmodel
?.
Type
.
ToName
()
??
""
;
}
}
return
list
;
}
/// <summary>
/// 获取累积金额
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public
decimal
GetTeaConCommissionStatistics
(
RB_TeaCon_Commission_Details_ViewModel
dmodel
)
{
return
teaCon_Commission_DetailsRepository
.
GetTeaConCommissionStatistics
(
dmodel
);
}
/// <summary>
/// 创建投稿提成
/// </summary>
/// <param name="month"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
string
SetTeaConCommissionInfo
(
string
month
,
UserInfo
userInfo
)
{
//首先查询该月是否已创建
var
plist
=
teaCon_Commission_PeriodsRepository
.
GetList
(
new
RB_TeaCon_Commission_Periods_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
Periods
=
month
});
if
(
plist
.
Any
())
{
return
"当月提成已创建"
;
}
string
EDate
=
Convert
.
ToDateTime
(
month
+
"-01"
).
AddMonths
(
1
).
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd"
);
var
contributeList
=
contribute_InfoRepository
.
GetCanSendCommissionList
(
userInfo
.
Group_Id
,
EDate
);
if
(
contributeList
.
Any
())
{
#
region
基础数据
//查询规则列表
var
ruleModel
=
teaCon_Commission_RuleRepository
.
GetList
(
new
RB_TeaCon_Commission_Rule_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
}).
FirstOrDefault
();
if
(
ruleModel
==
null
||
ruleModel
.
Status
==
1
)
{
return
"未设置投稿提成配置"
;
}
//查询所有的人员
var
userIds
=
string
.
Join
(
","
,
contributeList
.
Select
(
x
=>
x
.
CreateBy
).
Distinct
());
var
UserList
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
QIds
=
userIds
});
#
endregion
#
region
开始创建
var
trans
=
teaCon_Commission_PeriodsRepository
.
DbTransaction
;
try
{
int
PeriodsId
=
teaCon_Commission_PeriodsRepository
.
Insert
(
new
RB_TeaCon_Commission_Periods
()
{
Id
=
0
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Financials
=
""
,
Group_Id
=
userInfo
.
Group_Id
,
Name
=
month
+
"期提成"
,
Periods
=
month
,
SumPrice
=
0
},
trans
);
if
(
PeriodsId
>
0
)
{
decimal
SumPrice
=
0
;
foreach
(
var
item
in
contributeList
)
{
var
empModel
=
UserList
.
Where
(
x
=>
x
.
Id
==
item
.
CreateBy
).
FirstOrDefault
();
teaCon_Commission_DetailsRepository
.
Insert
(
new
RB_TeaCon_Commission_Details_ViewModel
()
{
Id
=
0
,
TeacherId
=
item
.
CreateBy
,
ContributeId
=
item
.
Id
,
PeriodId
=
PeriodsId
,
Periods
=
item
.
PublishDate
.
Value
.
ToString
(
"yyyy-MM"
),
CommissionMoney
=
ruleModel
.
Money
,
Depart_Id
=
empModel
?.
Dept_Id
??
0
,
School_Id
=
empModel
?.
School_Id
??
0
,
Group_Id
=
userInfo
.
Group_Id
,
Remark
=
""
},
trans
);
SumPrice
+=
ruleModel
.
Money
;
#
region
投稿更新
//查询这些投稿 更新为已发放提成
foreach
(
var
ditem
in
contributeList
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
Model
.
ViewModel
.
WeChat
.
RB_Contribute_Info_ViewModel
.
CommissionMoney
),
ruleModel
.
Money
},
{
nameof
(
Model
.
ViewModel
.
WeChat
.
RB_Contribute_Info_ViewModel
.
IsSendCommission
),
1
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
Model
.
ViewModel
.
WeChat
.
RB_Contribute_Info_ViewModel
.
Id
),
FiledValue
=
ditem
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
contribute_InfoRepository
.
Update
(
keyValues1
,
wheres1
,
trans
);
}
#
endregion
}
#
region
更新累计应发
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Sell_Commission_Periods
.
SumPrice
),
SumPrice
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Sell_Commission_Periods
.
Id
),
FiledValue
=
PeriodsId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
teaCon_Commission_PeriodsRepository
.
Update
(
keyValues
,
wheres
,
trans
);
#
endregion
}
teaCon_Commission_PeriodsRepository
.
DBSession
.
Commit
();
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetTeaConCommissionInfo"
);
teaCon_Commission_PeriodsRepository
.
DBSession
.
Rollback
();
return
"出错了,请联系管理员"
;
}
#
endregion
}
else
{
return
"当月暂无可发放提成"
;
}
return
""
;
}
/// <summary>
/// 获取提成可发放人员列表
/// </summary>
/// <param name="periodId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
object
GetTeaConCommissionSendEmployeeList
(
int
periodId
,
UserInfo
userInfo
)
{
var
model
=
teaCon_Commission_PeriodsRepository
.
GetEntity
(
periodId
);
if
(
model
==
null
)
{
return
"周期不存在"
;
}
List
<
int
>
EmpIdList
=
new
List
<
int
>();
if
(!
string
.
IsNullOrEmpty
(
model
.
EmpIds
))
{
EmpIdList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
model
.
EmpIds
+
"]"
);
}
var
list
=
GetTeaConCommissionUserList
(
new
RB_TeaCon_Commission_Details_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
PeriodId
=
periodId
});
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
x
.
TeacherId
,
x
.
TeacherName
,
x
.
CommissionMoney
,
IsGiveOut
=
EmpIdList
.
Contains
(
x
.
TeacherId
)
?
1
:
2
}));
}
/// <summary>
/// 设置提成发放人员
/// </summary>
/// <param name="periodId"></param>
/// <param name="empIds"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
string
SetTeaConCommissionSendEmployee
(
int
periodId
,
string
empIds
,
UserInfo
userInfo
)
{
var
model
=
teaCon_Commission_PeriodsRepository
.
GetEntity
(
periodId
);
if
(
model
==
null
)
{
return
"周期不存在"
;
}
if
(
model
.
Group_Id
!=
userInfo
.
Group_Id
)
{
return
"集团不正确"
;
}
List
<
int
>
EmpIdList
=
new
List
<
int
>();
if
(!
string
.
IsNullOrEmpty
(
model
.
EmpIds
))
{
EmpIdList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
model
.
EmpIds
+
"]"
);
}
List
<
int
>
NewIdList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
empIds
+
"]"
);
foreach
(
var
item
in
NewIdList
)
{
if
(
EmpIdList
.
Contains
(
item
))
{
return
"用户ID"
+
item
+
"已发放了提成,无法重复发放"
;
}
}
EmpIdList
.
AddRange
(
NewIdList
);
string
empids2
=
string
.
Join
(
","
,
EmpIdList
);
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
EmpIds
),
empids2
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
Id
),
FiledValue
=
periodId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
teaCon_Commission_PeriodsRepository
.
Update
(
keyValues
,
wheres
);
return
flag
?
""
:
"出错了,请联系管理员"
;
}
#
endregion
}
}
Edu.Module.EduTask/EducationReceiptModule.cs
View file @
07237255
...
...
@@ -1541,7 +1541,8 @@ namespace Edu.Module.EduTask
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Contribute_Info_ViewModel
.
AuditState
),(
int
)
Common
.
Enum
.
WeChat
.
ContributeInfoStateEnum
.
Audited
}
{
nameof
(
RB_Contribute_Info_ViewModel
.
AuditState
),(
int
)
Common
.
Enum
.
WeChat
.
ContributeInfoStateEnum
.
Audited
},
{
nameof
(
RB_Contribute_Info_ViewModel
.
PublishDate
),
DateTime
.
Now
}
};
flag
=
contribute_InfoRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Contribute_Info_ViewModel
.
Id
),
receiptModel
.
RelationId
));
}
...
...
Edu.Module.QYWeChat/QYCustomerModule.cs
View file @
07237255
...
...
@@ -60,6 +60,10 @@ namespace Edu.Module.QYWeChat
/// </summary>
private
readonly
RB_WeChat_CustomerConfigRepository
weChat_CustomerConfigRepository
=
new
RB_WeChat_CustomerConfigRepository
();
/// <summary>
/// 客户线索规则
/// </summary>
private
readonly
RB_WeChat_CustomerClueRuleRepository
weChat_CustomerClueRuleRepository
=
new
RB_WeChat_CustomerClueRuleRepository
();
/// <summary>
/// 部门
/// </summary>
private
RB_DepartmentRepository
departmentRepository
=
new
RB_DepartmentRepository
();
...
...
@@ -1843,6 +1847,1004 @@ namespace Edu.Module.QYWeChat
}
}
/// <summary>
/// 获取客户线索规则列表
/// </summary>
/// <param name="group_Id"></param>
/// <returns></returns>
public
List
<
RB_WeChat_CustomerClueRule_ViewModel
>
GetCustomerClueRuleList
(
int
group_Id
)
{
var
Rlist
=
new
List
<
RB_WeChat_CustomerClueRule_ViewModel
>();
var
list
=
weChat_CustomerClueRuleRepository
.
GetList
(
new
RB_WeChat_CustomerClueRule_ViewModel
()
{
Group_Id
=
group_Id
});
var
defaultModel
=
list
.
Where
(
x
=>
x
.
IsDefault
==
1
).
FirstOrDefault
();
if
(
defaultModel
==
null
)
{
defaultModel
=
new
RB_WeChat_CustomerClueRule_ViewModel
()
{
Id
=
0
,
IsDefault
=
1
,
DeptIds
=
"-1"
,
EmpIds
=
"-1"
,
RuleAllotWay
=
1
,
Sort
=
0
};
}
Rlist
.
Add
(
defaultModel
);
//添加默认的
var
otherList
=
list
.
Where
(
x
=>
x
.
IsDefault
!=
1
).
ToList
();
if
(
otherList
.
Any
())
{
Rlist
.
AddRange
(
otherList
.
OrderBy
(
x
=>
x
.
Sort
));
}
if
(
Rlist
.
Any
())
{
//组装 条件 + 部门 + 员工
//查询所有的字段
var
fieldList
=
weChat_CustomerFieldRepository
.
GetList
(
new
RB_WeChat_CustomerField_ViewModel
()
{
Group_Id
=
group_Id
});
foreach
(
var
item
in
fieldList
)
{
item
.
OptionsList
=
new
List
<
CustomerOptions
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
Options
))
{
item
.
OptionsList
=
JsonHelper
.
DeserializeObject
<
List
<
CustomerOptions
>>(
item
.
Options
);
}
}
//查询部门 员工
string
deptIds
=
string
.
Join
(
","
,
Rlist
.
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
.
DeptIds
)
&&
x
.
DeptIds
!=
"-1"
).
Select
(
x
=>
x
.
DeptIds
));
List
<
RB_Department_ViewModel
>
deptList
=
new
List
<
RB_Department_ViewModel
>();
if
(!
string
.
IsNullOrEmpty
(
deptIds
))
{
deptList
=
departmentRepository
.
GetDepartmentListRepository
(
new
RB_Department_ViewModel
()
{
Group_Id
=
group_Id
,
QDeptIds
=
deptIds
});
}
string
empIds
=
string
.
Join
(
","
,
Rlist
.
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
.
EmpIds
)
&&
x
.
EmpIds
!=
"-1"
).
Select
(
x
=>
x
.
EmpIds
));
List
<
Employee_ViewModel
>
empList
=
new
List
<
Employee_ViewModel
>();
if
(!
string
.
IsNullOrEmpty
(
empIds
))
{
empList
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
group_Id
,
QIds
=
empIds
});
}
foreach
(
var
item
in
Rlist
)
{
//反序列化条件列表 List<CustomerCommissionSelectModel> ConditionList
item
.
ConditionList
=
new
List
<
CustomerCommissionSelectModel
>();
item
.
ConditionStrList
=
new
List
<
string
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
RuleSelectValue
))
{
item
.
ConditionList
=
JsonHelper
.
DeserializeObject
<
List
<
CustomerCommissionSelectModel
>>(
item
.
RuleSelectValue
);
}
int
num
=
1
;
int
count
=
item
.
ConditionList
.
Count
();
foreach
(
var
qitem
in
item
.
ConditionList
)
{
string
conditionStr
=
""
,
destiption
=
""
;
conditionStr
=
GetConditionName
(
qitem
,
conditionStr
);
if
(
qitem
.
IsCustom
==
1
)
{
var
fieldModel
=
fieldList
.
Where
(
x
=>
x
.
Id
==
qitem
.
Id
).
FirstOrDefault
();
if
(
fieldModel
==
null
)
{
continue
;
}
destiption
=
$"
{
fieldModel
.
Name
}
{
conditionStr
}
"
;
switch
(
fieldModel
.
Type
)
{
case
Common
.
Enum
.
WeChat
.
CustomerFieldTypeEnum
.
Radio
:
int
vInt
=
Convert
.
ToInt32
(
qitem
.
StartValue
==
""
?
"0"
:
qitem
.
StartValue
);
var
Name
=
fieldModel
.
OptionsList
.
Where
(
x
=>
x
.
Id
==
vInt
).
FirstOrDefault
()?.
Name
??
""
;
destiption
+=
"“"
+
Name
+
"”"
;
break
;
case
Common
.
Enum
.
WeChat
.
CustomerFieldTypeEnum
.
MultiSelect
:
var
optionList
=
fieldModel
.
OptionsList
.
Where
(
x
=>
(
","
+
qitem
.
StartValue
+
","
).
Contains
(
","
+
x
.
Id
+
","
)).
ToList
();
destiption
+=
"“"
+
string
.
Join
(
","
,
optionList
.
Select
(
x
=>
x
.
Name
))
+
"”"
;
break
;
case
Common
.
Enum
.
WeChat
.
CustomerFieldTypeEnum
.
Time
:
destiption
+=
"“"
+
qitem
.
StartValue
+
"至"
+
qitem
.
EndValue
+
"”"
;
break
;
default
:
destiption
+=
"“"
+
qitem
.
StartValue
+
"”"
;
break
;
}
}
else
if
(
qitem
.
IsCustom
==
2
)
{
destiption
=
$"标签
{
conditionStr
}
"
;
//标签
if
(!
string
.
IsNullOrEmpty
(
qitem
.
StartValue
))
{
var
lableList
=
weChat_LableRepository
.
GetList
(
new
RB_WeChat_Lable_ViewModel
()
{
Group_Id
=
group_Id
,
LableIds
=
qitem
.
StartValue
});
destiption
+=
"“"
+
string
.
Join
(
","
,
lableList
.
Select
(
x
=>
x
.
Name
))
+
"”"
;
}
}
item
.
ConditionStrList
.
Add
(
destiption
+
"的客户"
+
((
count
==
1
||
num
==
count
)
?
""
:
(
item
.
RuleSelectType
==
1
?
" 且"
:
" 或"
)));
num
++;
}
item
.
DeptList
=
new
List
<
RB_Department_ViewModel
>();
item
.
EmpList
=
new
List
<
Employee_ViewModel
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
DeptIds
)
&&
item
.
DeptIds
!=
"-1"
)
{
item
.
DeptList
=
deptList
.
Where
(
x
=>
(
","
+
item
.
DeptIds
+
","
).
Contains
(
","
+
x
.
DeptId
+
","
)).
ToList
();
}
if
(!
string
.
IsNullOrEmpty
(
item
.
EmpIds
)
&&
item
.
EmpIds
!=
"-1"
)
{
item
.
EmpList
=
empList
.
Where
(
x
=>
(
","
+
item
.
EmpIds
+
","
).
Contains
(
","
+
x
.
Id
+
","
)).
ToList
();
}
}
}
return
Rlist
.
OrderBy
(
x
=>
x
.
Sort
).
ToList
();
}
/// <summary>
/// 获取线索信息
/// </summary>
/// <param name="ruleId"></param>
/// <param name="group_Id"></param>
/// <returns></returns>
public
RB_WeChat_CustomerClueRule_ViewModel
GetCustomerClueRuleInfo
(
int
ruleId
,
int
group_Id
)
{
var
Rlist
=
weChat_CustomerClueRuleRepository
.
GetList
(
new
RB_WeChat_CustomerClueRule_ViewModel
()
{
Group_Id
=
group_Id
,
Id
=
ruleId
});
if
(
Rlist
.
Any
())
{
//组装 条件 + 部门 + 员工
//查询所有的字段
var
fieldList
=
weChat_CustomerFieldRepository
.
GetList
(
new
RB_WeChat_CustomerField_ViewModel
()
{
Group_Id
=
group_Id
});
foreach
(
var
item
in
fieldList
)
{
item
.
OptionsList
=
new
List
<
CustomerOptions
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
Options
))
{
item
.
OptionsList
=
JsonHelper
.
DeserializeObject
<
List
<
CustomerOptions
>>(
item
.
Options
);
}
}
//查询部门 员工
string
deptIds
=
string
.
Join
(
","
,
Rlist
.
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
.
DeptIds
)
&&
x
.
DeptIds
!=
"-1"
).
Select
(
x
=>
x
.
DeptIds
));
List
<
RB_Department_ViewModel
>
deptList
=
new
List
<
RB_Department_ViewModel
>();
if
(!
string
.
IsNullOrEmpty
(
deptIds
))
{
deptList
=
departmentRepository
.
GetDepartmentListRepository
(
new
RB_Department_ViewModel
()
{
Group_Id
=
group_Id
,
QDeptIds
=
deptIds
});
}
string
empIds
=
string
.
Join
(
","
,
Rlist
.
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
.
EmpIds
)
&&
x
.
EmpIds
!=
"-1"
).
Select
(
x
=>
x
.
EmpIds
));
List
<
Employee_ViewModel
>
empList
=
new
List
<
Employee_ViewModel
>();
if
(!
string
.
IsNullOrEmpty
(
empIds
))
{
empList
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
group_Id
,
QIds
=
empIds
});
}
foreach
(
var
item
in
Rlist
)
{
//反序列化条件列表 List<CustomerCommissionSelectModel> ConditionList
item
.
ConditionList
=
new
List
<
CustomerCommissionSelectModel
>();
item
.
ConditionStrList
=
new
List
<
string
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
RuleSelectValue
))
{
item
.
ConditionList
=
JsonHelper
.
DeserializeObject
<
List
<
CustomerCommissionSelectModel
>>(
item
.
RuleSelectValue
);
}
int
num
=
1
;
int
count
=
item
.
ConditionList
.
Count
();
foreach
(
var
qitem
in
item
.
ConditionList
)
{
string
conditionStr
=
""
,
destiption
=
""
;
conditionStr
=
GetConditionName
(
qitem
,
conditionStr
);
if
(
qitem
.
IsCustom
==
1
)
{
var
fieldModel
=
fieldList
.
Where
(
x
=>
x
.
Id
==
qitem
.
Id
).
FirstOrDefault
();
if
(
fieldModel
==
null
)
{
continue
;
}
destiption
=
$"
{
fieldModel
.
Name
}
{
conditionStr
}
"
;
switch
(
fieldModel
.
Type
)
{
case
Common
.
Enum
.
WeChat
.
CustomerFieldTypeEnum
.
Radio
:
int
vInt
=
Convert
.
ToInt32
(
qitem
.
StartValue
==
""
?
"0"
:
qitem
.
StartValue
);
var
Name
=
fieldModel
.
OptionsList
.
Where
(
x
=>
x
.
Id
==
vInt
).
FirstOrDefault
()?.
Name
??
""
;
destiption
+=
"“"
+
Name
+
"”"
;
break
;
case
Common
.
Enum
.
WeChat
.
CustomerFieldTypeEnum
.
MultiSelect
:
var
optionList
=
fieldModel
.
OptionsList
.
Where
(
x
=>
(
","
+
qitem
.
StartValue
+
","
).
Contains
(
","
+
x
.
Id
+
","
)).
ToList
();
destiption
+=
"“"
+
string
.
Join
(
","
,
optionList
.
Select
(
x
=>
x
.
Name
))
+
"”"
;
break
;
case
Common
.
Enum
.
WeChat
.
CustomerFieldTypeEnum
.
Time
:
destiption
+=
"“"
+
qitem
.
StartValue
+
"至"
+
qitem
.
EndValue
+
"”"
;
break
;
default
:
destiption
+=
"“"
+
qitem
.
StartValue
+
"”"
;
break
;
}
}
else
if
(
qitem
.
IsCustom
==
2
)
{
destiption
=
$"标签
{
conditionStr
}
"
;
//标签
if
(!
string
.
IsNullOrEmpty
(
qitem
.
StartValue
))
{
var
lableList
=
weChat_LableRepository
.
GetList
(
new
RB_WeChat_Lable_ViewModel
()
{
Group_Id
=
group_Id
,
LableIds
=
qitem
.
StartValue
});
destiption
+=
"“"
+
string
.
Join
(
","
,
lableList
.
Select
(
x
=>
x
.
Name
))
+
"”"
;
}
}
item
.
ConditionStrList
.
Add
(
destiption
+
"的客户"
+
((
count
==
1
||
num
==
count
)
?
""
:
(
item
.
RuleSelectType
==
1
?
" 且"
:
" 或"
)));
num
++;
}
item
.
DeptList
=
new
List
<
RB_Department_ViewModel
>();
item
.
EmpList
=
new
List
<
Employee_ViewModel
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
DeptIds
)
&&
item
.
DeptIds
!=
"-1"
)
{
item
.
DeptList
=
deptList
.
Where
(
x
=>
(
","
+
item
.
DeptIds
+
","
).
Contains
(
","
+
x
.
DeptId
+
","
)).
ToList
();
}
if
(!
string
.
IsNullOrEmpty
(
item
.
EmpIds
)
&&
item
.
EmpIds
!=
"-1"
)
{
item
.
EmpList
=
empList
.
Where
(
x
=>
(
","
+
item
.
EmpIds
+
","
).
Contains
(
","
+
x
.
Id
+
","
)).
ToList
();
}
}
}
return
Rlist
.
FirstOrDefault
();
}
/// <summary>
/// 新增修改线索规则
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
string
SetCustomerClueRuleInfo
(
RB_WeChat_CustomerClueRule_ViewModel
demodel
)
{
if
(
demodel
.
Id
>
0
)
{
var
oldModel
=
weChat_CustomerClueRuleRepository
.
GetEntity
(
demodel
.
Id
);
if
(
oldModel
==
null
)
{
return
"规则不存在"
;
}
if
(
oldModel
.
IsDefault
==
1
)
{
demodel
.
RuleSelectValue
=
""
;
}
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
RuleSelectType
),
demodel
.
RuleSelectType
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
RuleSelectValue
),
demodel
.
RuleSelectValue
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
DeptIds
),
demodel
.
DeptIds
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
EmpIds
),
demodel
.
EmpIds
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
RuleAllotWay
),
demodel
.
RuleAllotWay
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateBy
),
demodel
.
UpdateBy
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateTime
),
demodel
.
UpdateTime
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Id
),
FiledValue
=
demodel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
weChat_CustomerClueRuleRepository
.
Update
(
keyValues
,
wheres
);
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
demodel
.
Sort
=
1
;
int
Id
=
weChat_CustomerClueRuleRepository
.
Insert
(
demodel
);
if
(
Id
>
0
)
{
//更新后面规则排序
weChat_CustomerClueRuleRepository
.
UpdateLastClueRuleSortAdd
(
demodel
.
Group_Id
,
Id
);
}
return
Id
>
0
?
""
:
"出错了,请联系管理员"
;
}
}
/// <summary>
/// 设置线索规则状态
/// </summary>
/// <param name="ruleId"></param>
/// <param name="type"></param>
/// <param name="targetId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
string
SetCustomerClueRuleState
(
int
ruleId
,
int
type
,
int
targetId
,
UserInfo
userInfo
)
{
if
(
type
==
1
)
{
//转移
var
oldModel
=
weChat_CustomerClueRuleRepository
.
GetEntity
(
ruleId
);
if
(
targetId
==
0
)
{
if
(
oldModel
.
Sort
==
1
)
{
return
""
;
}
//排在第一个
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Sort
),
1
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateBy
),
userInfo
.
Id
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateTime
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Id
),
FiledValue
=
ruleId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
weChat_CustomerClueRuleRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新后面的排序 +1 至到当前的
weChat_CustomerClueRuleRepository
.
UpdateLastClueRuleSortAdd
(
userInfo
.
Group_Id
,
ruleId
,
1
,
oldModel
.
Sort
);
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
var
tarModel
=
weChat_CustomerClueRuleRepository
.
GetEntity
(
targetId
);
//移这个的后面
if
(
oldModel
.
Sort
>
tarModel
.
Sort
)
{
if
(
oldModel
.
Sort
==
tarModel
.
Sort
+
1
)
{
//说明就在屁股后面
return
""
;
}
int
newSort
=
tarModel
.
Sort
+
1
;
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Sort
),
newSort
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateBy
),
userInfo
.
Id
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateTime
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Id
),
FiledValue
=
ruleId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
weChat_CustomerClueRuleRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新后面的排序 +1 至到当前的
weChat_CustomerClueRuleRepository
.
UpdateLastClueRuleSortAdd
(
userInfo
.
Group_Id
,
ruleId
,
newSort
,
oldModel
.
Sort
);
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Sort
),
tarModel
.
Sort
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateBy
),
userInfo
.
Id
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateTime
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Id
),
FiledValue
=
ruleId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
weChat_CustomerClueRuleRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新前面排序 -1
weChat_CustomerClueRuleRepository
.
UpdateLastClueRuleSortSubtract
(
userInfo
.
Group_Id
,
ruleId
,
oldModel
.
Sort
,
tarModel
.
Sort
);
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
}
}
else
if
(
type
==
2
)
{
//删除
var
oldModel
=
weChat_CustomerClueRuleRepository
.
GetEntity
(
ruleId
);
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Status
),
1
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateBy
),
userInfo
.
Id
},
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
UpdateTime
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Id
),
FiledValue
=
ruleId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
weChat_CustomerClueRuleRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新后面的排序
weChat_CustomerClueRuleRepository
.
UpdateLastClueRuleSortAdd
(
userInfo
.
Group_Id
,
ruleId
,
oldModel
.
Sort
);
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
return
"类型有误"
;
}
}
/// <summary>
/// 获取条件关联名称
/// </summary>
/// <param name="qitem"></param>
/// <param name="conditionStr"></param>
/// <returns></returns>
private
string
GetConditionName
(
CustomerCommissionSelectModel
qitem
,
string
conditionStr
)
{
switch
(
qitem
.
Type
)
{
case
1
:
switch
(
qitem
.
Direction
)
{
case
1
:
conditionStr
=
"包含所有"
;
break
;
case
2
:
conditionStr
=
"包含任意"
;
break
;
case
3
:
conditionStr
=
"不包含"
;
break
;
case
4
:
conditionStr
=
"为空"
;
break
;
case
5
:
conditionStr
=
"不为空"
;
break
;
}
break
;
case
2
:
switch
(
qitem
.
Direction
)
{
case
1
:
conditionStr
=
"等于"
;
break
;
case
2
:
conditionStr
=
"不等于"
;
break
;
case
3
:
conditionStr
=
"为空"
;
break
;
case
4
:
conditionStr
=
"不为空"
;
break
;
case
5
:
conditionStr
=
"模糊匹配"
;
break
;
}
break
;
case
5
:
switch
(
qitem
.
Direction
)
{
case
1
:
conditionStr
=
"等于"
;
break
;
case
2
:
conditionStr
=
"大于"
;
break
;
case
3
:
conditionStr
=
"大于等于"
;
break
;
case
4
:
conditionStr
=
"小于"
;
break
;
case
5
:
conditionStr
=
"小于等于"
;
break
;
}
break
;
}
return
conditionStr
;
}
/// <summary>
/// 新增线索
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
string
SetCustomerClueInfo
(
RB_WeChat_CustomerInfo_ViewModel
demodel
)
{
int
Id
=
weChat_CustomerInfoRepository
.
Insert
(
demodel
);
bool
flag
=
Id
>
0
;
if
(
flag
)
{
//记录日志
string
Remark
=
""
;
foreach
(
var
item
in
demodel
.
CustomFiledList
)
{
Remark
+=
item
.
Name
+
":"
+
item
.
ShowValue
+
"、"
;
}
weChat_CustomerTripRepository
.
Insert
(
new
Model
.
Entity
.
WeChat
.
RB_WeChat_CustomerTrip
()
{
Id
=
0
,
CreateBy
=
demodel
.
CreateBy
,
CreateTime
=
DateTime
.
Now
,
CustomerId
=
Id
,
Description
=
"创建了该客户"
,
EmpId
=
0
,
Files
=
""
,
Group_Id
=
demodel
.
Group_Id
,
Images
=
""
,
Remark
=
Remark
,
Status
=
0
,
Type
=
Common
.
Enum
.
WeChat
.
CustomerTripTypeEnum
.
Operate
,
UpdateBy
=
demodel
.
UpdateBy
,
UpdateTime
=
DateTime
.
Now
});
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
/// <summary>
/// 设置线索状态
/// </summary>
/// <param name="customerIds"></param>
/// <param name="type"></param>
/// <param name="empIds"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
string
SetCustomerClueState
(
string
customerIds
,
int
type
,
string
empIds
,
UserInfo
userInfo
)
{
//获取用户列表
var
clist
=
weChat_CustomerInfoRepository
.
GetList
(
new
RB_WeChat_CustomerInfo_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
Q_CustomerIds
=
customerIds
});
if
(
clist
.
Where
(
x
=>
x
.
CustomerState
==
2
).
Any
())
{
return
"客户状态不正确"
;
}
bool
flag
=
false
;
string
Remark
=
""
;
//类型 1有效线索 2无效线索 3待回访 4直接分配(员工ID) 5重置无效线索
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>();
if
(
type
==
1
)
{
//有效线索 如果开启自动分配、需自动分配 未开启的话 =》待分配
//获取配置
var
cconfig
=
weChat_CustomerConfigRepository
.
GetList
(
new
RB_WeChat_CustomerConfig_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
}).
FirstOrDefault
();
if
((
cconfig
?.
ClueType
??
1
)
==
2
)
{
//获取所有分配规则
var
list
=
weChat_CustomerClueRuleRepository
.
GetList
(
new
RB_WeChat_CustomerClueRule_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
});
var
defaultRuleModel
=
list
.
Where
(
x
=>
x
.
IsDefault
==
1
).
FirstOrDefault
();
if
(
defaultRuleModel
==
null
)
{
defaultRuleModel
=
new
RB_WeChat_CustomerClueRule_ViewModel
()
{
Id
=
0
,
IsDefault
=
1
,
DeptIds
=
"-1"
,
EmpIds
=
"-1"
,
RuleAllotWay
=
1
,
Sort
=
0
};
}
var
otherRuleList
=
list
.
Where
(
x
=>
x
.
IsDefault
!=
1
).
OrderBy
(
x
=>
x
.
Sort
).
ToList
();
//根据sort升序
foreach
(
var
qqitem
in
otherRuleList
)
{
qqitem
.
ConditionList
=
new
List
<
CustomerCommissionSelectModel
>();
if
(!
string
.
IsNullOrEmpty
(
qqitem
.
RuleSelectValue
))
{
qqitem
.
ConditionList
=
JsonHelper
.
DeserializeObject
<
List
<
CustomerCommissionSelectModel
>>(
qqitem
.
RuleSelectValue
);
}
}
//获取所有字段
var
cFieldList
=
weChat_CustomerFieldRepository
.
GetList
(
new
RB_WeChat_CustomerField_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
Enable
=
1
});
Dictionary
<
int
,
int
>
customerRuleList
=
new
Dictionary
<
int
,
int
>();
//客户匹配的规则, key:规则 value:客户
//开始匹配规则
foreach
(
var
item
in
clist
)
{
//处理客户自定义字段
List
<
CustomerFiledContentModel
>
CustomValueList
=
new
List
<
CustomerFiledContentModel
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
CustomContent
))
{
var
keyValueList
=
JsonHelper
.
DeserializeObject
<
Dictionary
<
string
,
string
>>(
item
.
CustomContent
);
foreach
(
var
kitem
in
keyValueList
)
{
CustomValueList
.
Add
(
new
CustomerFiledContentModel
{
Id
=
Convert
.
ToInt32
(
kitem
.
Key
.
Replace
(
"z"
,
""
)),
Value
=
kitem
.
Value
});
}
}
//开始验证
//首先根据 规则排序 依次验证该用户 适用哪一个规则
bool
IsSure
=
false
;
foreach
(
var
ritem
in
otherRuleList
)
{
IsSure
=
false
;
if
(
ritem
.
RuleSelectType
==
1
)
{
//并且 所有条件必须满足
bool
ConditionOk
=
false
;
foreach
(
var
citem
in
ritem
.
ConditionList
)
{
//bool IsContinue = true;//是否继续下一个条件
string
cvValue
=
""
;
if
(
citem
.
IsCustom
==
1
)
{
var
fieldModel
=
cFieldList
.
Where
(
x
=>
x
.
Id
==
citem
.
Id
).
FirstOrDefault
();
if
(
fieldModel
==
null
)
{
continue
;
}
var
cvModel
=
CustomValueList
.
Where
(
x
=>
x
.
Id
==
citem
.
Id
).
FirstOrDefault
();
cvValue
=
cvModel
.
Value
;
}
else
if
(
citem
.
IsCustom
==
2
)
{
//标签
cvValue
=
item
.
LableIds
;
}
else
if
(
citem
.
IsCustom
==
3
)
{
//客户阶段
cvValue
=
item
.
StageId
.
ToString
();
}
//写成一个通用方法
switch
(
citem
.
Type
)
{
case
1
:
//包含
//方向 1包含所有/等于/等于 2包含任意/不等于/大于 3不包含/为空/大于等于 4为空/不为空/小于 5不为空/模糊/小于等于 对应 type的1/2/5
List
<
int
>
dxList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
citem
.
StartValue
+
"]"
);
switch
(
citem
.
Direction
)
{
case
1
:
//包含所有
ConditionOk
=
true
;
foreach
(
var
dxitem
in
dxList
)
{
if
(!(
","
+
cvValue
+
","
).
Contains
(
","
+
dxitem
+
","
))
{
//不包含
ConditionOk
=
false
;
//此条件不成立
break
;
}
}
break
;
case
2
:
//包含任意
ConditionOk
=
false
;
foreach
(
var
dxitem
in
dxList
)
{
if
((
","
+
cvValue
+
","
).
Contains
(
","
+
dxitem
+
","
))
{
//包含
ConditionOk
=
true
;
break
;
}
}
break
;
case
3
:
//不包含
ConditionOk
=
true
;
foreach
(
var
dxitem
in
dxList
)
{
if
((
","
+
cvValue
+
","
).
Contains
(
","
+
dxitem
+
","
))
{
//包含
ConditionOk
=
false
;
break
;
}
}
break
;
case
4
:
//为空
ConditionOk
=
true
;
if
(!
string
.
IsNullOrEmpty
(
cvValue
))
{
ConditionOk
=
false
;
}
break
;
case
5
:
//不为空
ConditionOk
=
true
;
if
(
string
.
IsNullOrEmpty
(
cvValue
))
{
ConditionOk
=
false
;
}
break
;
}
break
;
case
2
:
//等于
switch
(
citem
.
Direction
)
{
case
1
:
//等于
ConditionOk
=
true
;
if
(
cvValue
!=
citem
.
StartValue
)
{
ConditionOk
=
false
;
}
break
;
case
2
:
//不等于
ConditionOk
=
true
;
if
(
cvValue
==
citem
.
StartValue
)
{
ConditionOk
=
false
;
}
break
;
case
3
:
//为空
ConditionOk
=
true
;
if
(!
string
.
IsNullOrEmpty
(
cvValue
))
{
ConditionOk
=
false
;
}
break
;
case
4
:
//不为空
ConditionOk
=
true
;
if
(
string
.
IsNullOrEmpty
(
cvValue
))
{
ConditionOk
=
false
;
}
break
;
case
5
:
//模糊
ConditionOk
=
true
;
if
(!
cvValue
.
Contains
(
citem
.
StartValue
))
{
ConditionOk
=
false
;
}
break
;
}
break
;
case
3
:
//日期
List
<
string
>
vList
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
citem
.
StartValue
);
if
(
string
.
IsNullOrEmpty
(
cvValue
))
{
ConditionOk
=
false
;
}
else
{
if
(!
vList
.
Contains
(
Convert
.
ToDateTime
(
cvValue
).
ToString
(
"MM月dd号"
)))
{
ConditionOk
=
false
;
}
}
break
;
case
4
:
//日期范围
if
(
string
.
IsNullOrEmpty
(
cvValue
))
{
ConditionOk
=
false
;
}
else
{
if
(!(
Convert
.
ToDateTime
(
cvValue
)
>=
Convert
.
ToDateTime
(
citem
.
StartValue
)
&&
Convert
.
ToDateTime
(
cvValue
)
<=
Convert
.
ToDateTime
(
citem
.
EndValue
)))
{
ConditionOk
=
false
;
}
}
break
;
case
5
:
//数值
switch
(
citem
.
Direction
)
{
case
1
:
//等于
ConditionOk
=
true
;
if
(
Convert
.
ToDecimal
(
cvValue
)
!=
Convert
.
ToDecimal
(
citem
.
StartValue
))
{
ConditionOk
=
false
;
}
break
;
case
2
:
//大于
ConditionOk
=
true
;
if
(
Convert
.
ToDecimal
(
cvValue
)
<=
Convert
.
ToDecimal
(
citem
.
StartValue
))
{
ConditionOk
=
false
;
}
break
;
case
3
:
//大于等于
ConditionOk
=
true
;
if
(
Convert
.
ToDecimal
(
cvValue
)
<
Convert
.
ToDecimal
(
citem
.
StartValue
))
{
ConditionOk
=
false
;
}
break
;
case
4
:
//小于
ConditionOk
=
true
;
if
(
Convert
.
ToDecimal
(
cvValue
)
>=
Convert
.
ToDecimal
(
citem
.
StartValue
))
{
ConditionOk
=
false
;
}
break
;
case
5
:
//小于等于
ConditionOk
=
true
;
if
(
Convert
.
ToDecimal
(
cvValue
)
>
Convert
.
ToDecimal
(
citem
.
StartValue
))
{
ConditionOk
=
false
;
}
break
;
}
break
;
}
if
(
ConditionOk
==
false
)
{
break
;
}
}
//所有条件都必须Ok才算Ok
if
(
ConditionOk
)
{
IsSure
=
true
;
}
}
else
{
//或者 满足一个条件就可以
}
if
(
IsSure
)
{
customerRuleList
.
Add
(
ritem
.
Id
,
item
.
Id
);
break
;
}
}
if
(!
IsSure
)
{
//继续匹配为默认的
customerRuleList
.
Add
(
defaultRuleModel
.
Id
,
item
.
Id
);
}
}
//怎么验证重复分配(重复分配之后 又该怎么分配)
//
}
else
{
//进入待分配
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
ClueState
),
4
);
//已转客户
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
AllotState
),
1
);
//待分配
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
Id
),
FiledValue
=
customerIds
,
OperatorEnum
=
OperatorEnum
.
IN
}
};
flag
=
weChat_CustomerInfoRepository
.
Update
(
keyValues
,
wheres
);
Remark
=
"修改线索为待分配"
;
}
}
else
if
(
type
==
2
)
{
if
(
clist
.
Where
(
x
=>
x
.
ClueState
==
3
||
x
.
ClueState
==
4
).
Any
())
{
return
"客户状态不正确"
;
}
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
ClueState
),
3
);
//无效线索
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
Id
),
FiledValue
=
customerIds
,
OperatorEnum
=
OperatorEnum
.
IN
}
};
flag
=
weChat_CustomerInfoRepository
.
Update
(
keyValues
,
wheres
);
Remark
=
"修改线索为无效线索"
;
}
else
if
(
type
==
3
)
{
if
(
clist
.
Where
(
x
=>
x
.
ClueState
!=
1
).
Any
())
{
return
"客户状态不正确"
;
}
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
ClueState
),
2
);
//待回访
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
Id
),
FiledValue
=
customerIds
,
OperatorEnum
=
OperatorEnum
.
IN
}
};
flag
=
weChat_CustomerInfoRepository
.
Update
(
keyValues
,
wheres
);
Remark
=
"修改线索为待回访"
;
}
else
if
(
type
==
4
)
{
List
<
int
>
empIdList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
empIds
+
"]"
);
//获取配置
var
cconfig
=
weChat_CustomerConfigRepository
.
GetList
(
new
RB_WeChat_CustomerConfig_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
}).
FirstOrDefault
();
//获取用户
var
elist
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
QIds
=
empIds
});
if
(
elist
.
Where
(
x
=>
string
.
IsNullOrEmpty
(
x
.
WorkUserId
)).
Any
())
{
return
"有用户未绑定企业微信"
;
}
//直接分配
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
ClueState
),
4
);
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
AllotState
),
2
);
//已分配
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
CustomerState
),
1
);
//正常客户
List
<
int
>
customerIdList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
customerIds
+
"]"
);
var
trans
=
weChat_CustomerInfoRepository
.
DbTransaction
;
try
{
if
((
cconfig
?.
ClueAllotWay
??
1
)
==
1
)
{
//依次分配
int
Num
=
1
;
foreach
(
var
item
in
customerIdList
)
{
//获取用户ID
int
empId
=
GetRankEmpId
(
empIdList
,
Num
);
//获取顺序用户
var
empModel
=
elist
.
Where
(
x
=>
x
.
Id
==
empId
).
FirstOrDefault
();
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
EmpId
),
empId
);
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
WorkEmpId
),
empId
);
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
Id
),
FiledValue
=
item
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
flag
=
weChat_CustomerInfoRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
==
false
)
{
weChat_CustomerInfoRepository
.
DBSession
.
Rollback
();
}
else
{
weChat_CustomerTripRepository
.
Insert
(
new
Model
.
Entity
.
WeChat
.
RB_WeChat_CustomerTrip
()
{
Id
=
0
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
CustomerId
=
item
,
Description
=
userInfo
.
AccountName
+
"将该客户分配给"
+
(
empModel
?.
EmployeeName
??
""
),
EmpId
=
0
,
Files
=
""
,
Group_Id
=
userInfo
.
Group_Id
,
Images
=
""
,
Remark
=
""
,
Status
=
0
,
Type
=
Common
.
Enum
.
WeChat
.
CustomerTripTypeEnum
.
Operate
,
UpdateBy
=
userInfo
.
Id
,
UpdateTime
=
DateTime
.
Now
});
}
Num
++;
}
}
else
{
//随机分配
foreach
(
var
item
in
customerIdList
)
{
//获取用户ID
int
empId
=
GetRandomEmpId
(
empIdList
);
//获取随机用户
var
empModel
=
elist
.
Where
(
x
=>
x
.
Id
==
empId
).
FirstOrDefault
();
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
EmpId
),
empId
);
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
Id
),
FiledValue
=
item
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
flag
=
weChat_CustomerInfoRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
==
false
)
{
weChat_CustomerInfoRepository
.
DBSession
.
Rollback
();
}
else
{
weChat_CustomerTripRepository
.
Insert
(
new
Model
.
Entity
.
WeChat
.
RB_WeChat_CustomerTrip
()
{
Id
=
0
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
CustomerId
=
item
,
Description
=
userInfo
.
AccountName
+
"将该客户分配给"
+
(
empModel
?.
EmployeeName
??
""
),
EmpId
=
0
,
Files
=
""
,
Group_Id
=
userInfo
.
Group_Id
,
Images
=
""
,
Remark
=
""
,
Status
=
0
,
Type
=
Common
.
Enum
.
WeChat
.
CustomerTripTypeEnum
.
Operate
,
UpdateBy
=
userInfo
.
Id
,
UpdateTime
=
DateTime
.
Now
});
}
}
}
weChat_CustomerInfoRepository
.
DBSession
.
Commit
();
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetCustomerClueState"
);
weChat_CustomerInfoRepository
.
DBSession
.
Rollback
();
}
}
else
if
(
type
==
5
)
{
if
(
clist
.
Where
(
x
=>
x
.
ClueState
!=
3
).
Any
())
{
return
"客户状态不正确"
;
}
keyValues
.
Add
(
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
ClueState
),
1
);
//未处理
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_WeChat_CustomerInfo_ViewModel
.
Id
),
FiledValue
=
customerIds
,
OperatorEnum
=
OperatorEnum
.
IN
}
};
flag
=
weChat_CustomerInfoRepository
.
Update
(
keyValues
,
wheres
);
Remark
=
"修改线索为未处理"
;
}
else
{
return
"类型有误"
;
}
if
(
flag
)
{
//新增日志
if
(!
string
.
IsNullOrEmpty
(
Remark
))
{
//暂时 -----------------------------------
foreach
(
var
item
in
clist
)
{
weChat_CustomerTripRepository
.
Insert
(
new
Model
.
Entity
.
WeChat
.
RB_WeChat_CustomerTrip
()
{
Id
=
0
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
CustomerId
=
item
.
Id
,
Description
=
Remark
,
EmpId
=
0
,
Files
=
""
,
Group_Id
=
userInfo
.
Group_Id
,
Images
=
""
,
Remark
=
""
,
Status
=
0
,
Type
=
Common
.
Enum
.
WeChat
.
CustomerTripTypeEnum
.
Operate
,
UpdateBy
=
userInfo
.
Id
,
UpdateTime
=
DateTime
.
Now
});
}
}
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
/// <summary>
/// 获取顺序人员ID
/// </summary>
/// <param name="empIdList"></param>
/// <param name="num"></param>
/// <returns></returns>
private
int
GetRankEmpId
(
List
<
int
>
empIdList
,
int
num
)
{
int
ecount
=
empIdList
.
Count
();
if
(
num
>
ecount
)
{
num
%=
ecount
;
if
(
num
==
0
)
{
num
=
ecount
;
}
}
return
empIdList
[
num
-
1
];
}
/// <summary>
/// 获取随机人员ID
/// </summary>
/// <param name="empIdList"></param>
/// <returns></returns>
private
int
GetRandomEmpId
(
List
<
int
>
empIdList
)
{
int
ecount
=
empIdList
.
Count
();
int
num
=
new
Random
().
Next
(
1
,
ecount
);
return
empIdList
[
num
-
1
];
}
#
endregion
}
}
Edu.Repository/Sell/RB_TeaCon_Commission_DetailsRepository.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Model.Entity.Course
;
using
Edu.Model.Entity.Sell
;
using
Edu.Model.ViewModel.Course
;
using
Edu.Model.ViewModel.Sell
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VT.FW.DB.Dapper
;
namespace
Edu.Repository.Sell
{
/// <summary>
/// 投稿提成期数明细仓储层
/// </summary>
public
class
RB_TeaCon_Commission_DetailsRepository
:
BaseRepository
<
RB_TeaCon_Commission_Details
>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Details_ViewModel
>
GetList
(
RB_TeaCon_Commission_Details_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
PeriodId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
PeriodId
)}
=
{
demodel
.
PeriodId
}
"
;
}
if
(
demodel
.
TeacherId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
TeacherId
)}
=
{
demodel
.
TeacherId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
TeacherIds
))
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
TeacherId
)}
in(
{
demodel
.
TeacherIds
}
)"
;
}
if
(
demodel
.
ContributeId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
ContributeId
)}
=
{
demodel
.
ContributeId
}
"
;
}
string
sql
=
$@" select r.* from RB_TeaCon_Commission_Details r where
{
where
}
order by r.Id asc"
;
return
Get
<
RB_TeaCon_Commission_Details_ViewModel
>(
sql
).
ToList
();
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Details_ViewModel
>
GetPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_TeaCon_Commission_Details_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
School_Id
>=
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
School_Id
)}
=
{
demodel
.
School_Id
}
"
;
}
if
(
demodel
.
Depart_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Depart_Id
)}
=
{
demodel
.
Depart_Id
}
"
;
}
if
(
demodel
.
PeriodId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
PeriodId
)}
=
{
demodel
.
PeriodId
}
"
;
}
if
(
demodel
.
TeacherId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
TeacherId
)}
=
{
demodel
.
TeacherId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
TeacherIds
))
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
TeacherId
)}
in(
{
demodel
.
TeacherIds
}
)"
;
}
if
(
demodel
.
ContributeId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
ContributeId
)}
=
{
demodel
.
ContributeId
}
"
;
}
string
sql
=
$@" select r.* from RB_TeaCon_Commission_Details r where
{
where
}
order by r.Id desc"
;
return
GetPage
<
RB_TeaCon_Commission_Details_ViewModel
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
/// <summary>
/// 获取用户提成列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Details_ViewModel
>
GetTeaConCommissionUserList
(
RB_TeaCon_Commission_Details_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
School_Id
>=
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
School_Id
)}
=
{
demodel
.
School_Id
}
"
;
}
if
(
demodel
.
Depart_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Depart_Id
)}
=
{
demodel
.
Depart_Id
}
"
;
}
if
(
demodel
.
PeriodId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
PeriodId
)}
=
{
demodel
.
PeriodId
}
"
;
}
if
(
demodel
.
TeacherId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
TeacherId
)}
=
{
demodel
.
TeacherId
}
"
;
}
if
(
demodel
.
ContributeId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
ContributeId
)}
=
{
demodel
.
ContributeId
}
"
;
}
string
sql
=
$@" select r.TeacherId,r.Depart_Id,r.School_Id,sum(r.CommissionMoney) as CommissionMoney
from RB_TeaCon_Commission_Details r where
{
where
}
group by r.TeacherId,r.Depart_Id,r.School_Id"
;
return
Get
<
RB_TeaCon_Commission_Details_ViewModel
>(
sql
).
ToList
();
}
/// <summary>
/// 累计提成金额
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
decimal
GetTeaConCommissionStatistics
(
RB_TeaCon_Commission_Details_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
School_Id
>=
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
School_Id
)}
=
{
demodel
.
School_Id
}
"
;
}
if
(
demodel
.
Depart_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
Depart_Id
)}
=
{
demodel
.
Depart_Id
}
"
;
}
if
(
demodel
.
PeriodId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
PeriodId
)}
=
{
demodel
.
PeriodId
}
"
;
}
if
(
demodel
.
TeacherId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
TeacherId
)}
=
{
demodel
.
TeacherId
}
"
;
}
if
(
demodel
.
ContributeId
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Details_ViewModel
.
ContributeId
)}
=
{
demodel
.
ContributeId
}
"
;
}
string
sql
=
$@" select sum(r.CommissionMoney) from RB_TeaCon_Commission_Details r where
{
where
}
"
;
var
obj
=
ExecuteScalar
(
sql
);
return
obj
==
null
?
0
:
Convert
.
ToDecimal
(
obj
);
}
}
}
Edu.Repository/Sell/RB_TeaCon_Commission_PeriodsRepository.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Model.Entity.Course
;
using
Edu.Model.Entity.Sell
;
using
Edu.Model.ViewModel.Course
;
using
Edu.Model.ViewModel.Sell
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VT.FW.DB.Dapper
;
namespace
Edu.Repository.Sell
{
/// <summary>
/// 投稿提成期数仓储层
/// </summary>
public
class
RB_TeaCon_Commission_PeriodsRepository
:
BaseRepository
<
RB_TeaCon_Commission_Periods
>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Periods_ViewModel
>
GetList
(
RB_TeaCon_Commission_Periods_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
Name
))
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
Name
)}
like '%
{
demodel
.
Name
}
%'"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
Periods
))
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
Periods
)}
='
{
demodel
.
Periods
}
'"
;
}
string
sql
=
$@" select r.* from RB_TeaCon_Commission_Periods r where
{
where
}
order by r.Id desc"
;
return
Get
<
RB_TeaCon_Commission_Periods_ViewModel
>(
sql
).
ToList
();
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Periods_ViewModel
>
GetPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_TeaCon_Commission_Periods_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
Name
))
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Periods_ViewModel
.
Name
)}
like '%
{
demodel
.
Name
}
%'"
;
}
string
sql
=
$@" select r.* from RB_TeaCon_Commission_Periods r where
{
where
}
order by r.Id desc"
;
return
GetPage
<
RB_TeaCon_Commission_Periods_ViewModel
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
}
}
Edu.Repository/Sell/RB_TeaCon_Commission_RuleRepository.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Model.Entity.Course
;
using
Edu.Model.Entity.Sell
;
using
Edu.Model.ViewModel.Course
;
using
Edu.Model.ViewModel.Sell
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VT.FW.DB.Dapper
;
namespace
Edu.Repository.Sell
{
/// <summary>
/// 投稿提成规则仓储层
/// </summary>
public
class
RB_TeaCon_Commission_RuleRepository
:
BaseRepository
<
RB_TeaCon_Commission_Rule
>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_TeaCon_Commission_Rule_ViewModel
>
GetList
(
RB_TeaCon_Commission_Rule_ViewModel
demodel
)
{
string
where
=
$@" 1=1"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_TeaCon_Commission_Rule_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
string
sql
=
$@" select r.* from RB_TeaCon_Commission_Rule r where
{
where
}
order by r.Id desc"
;
return
Get
<
RB_TeaCon_Commission_Rule_ViewModel
>(
sql
).
ToList
();
}
}
}
Edu.Repository/WeChat/RB_Contribute_InfoRepository.cs
View file @
07237255
...
...
@@ -100,5 +100,18 @@ WHERE {where}
ORDER BY r.Id DESC "
;
return
Get
<
RB_Contribute_Info_ViewModel
>(
sql
,
parameters
).
ToList
();
}
/// <summary>
/// 获取可发放提成的投稿列表
/// </summary>
/// <param name="group_Id"></param>
/// <param name="eDate"></param>
/// <returns></returns>
public
List
<
RB_Contribute_Info_ViewModel
>
GetCanSendCommissionList
(
int
group_Id
,
string
eDate
)
{
string
sql
=
$@"SELECT * FROM rb_contribute_info WHERE `Status` =0 and Group_Id =
{
group_Id
}
and AuditState =2 and PublishDate <='
{
eDate
}
23:59:59' and IFNULL(IsSendCommission,0) <>1"
;
return
Get
<
RB_Contribute_Info_ViewModel
>(
sql
).
ToList
();
}
}
}
Edu.Repository/WeChat/RB_WeChat_CustomerClueRuleRepository.cs
0 → 100644
View file @
07237255
using
Edu.Common.Enum
;
using
Edu.Model.Entity.WeChat
;
using
Edu.Model.ViewModel.WeChat
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VT.FW.DB
;
using
VT.FW.DB.Dapper
;
namespace
Edu.Repository.WeChat
{
/// <summary>
/// 企业微信客户线索规则仓储层
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_WeChat_CustomerClueRuleRepository
:
BaseRepository
<
RB_WeChat_CustomerClueRule
>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_WeChat_CustomerClueRule_ViewModel
>
GetList
(
RB_WeChat_CustomerClueRule_ViewModel
demodel
)
{
DynamicParameters
parameters
=
new
DynamicParameters
();
string
where
=
$@" 1=1 and r.
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Status
)}
=0"
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
Id
>
0
)
{
where
+=
$@" and r.
{
nameof
(
RB_WeChat_CustomerClueRule_ViewModel
.
Id
)}
=
{
demodel
.
Id
}
"
;
}
string
sql
=
$@"
SELECT * From RB_WeChat_CustomerClueRule r
WHERE
{
where
}
ORDER BY r.Id DESC "
;
return
Get
<
RB_WeChat_CustomerClueRule_ViewModel
>(
sql
,
parameters
).
ToList
();
}
/// <summary>
/// 执行排序+1
/// </summary>
/// <param name="group_Id"></param>
/// <param name="id"></param>
public
void
UpdateLastClueRuleSortAdd
(
int
group_Id
,
int
id
,
int
minSort
=
0
,
int
maxSort
=
0
)
{
string
sql
=
$@" update RB_WeChat_CustomerClueRule set Sort = Sort +1 where Status =0 and Group_Id =
{
group_Id
}
and Sort >0 and Id <>
{
id
}
"
;
if
(
minSort
>
0
)
{
sql
+=
$" and Sort >="
+
minSort
;
}
if
(
maxSort
>
0
)
{
sql
+=
$" and Sort <="
+
maxSort
;
}
Execute
(
sql
);
}
/// <summary>
/// 执行排序-1
/// </summary>
/// <param name="group_Id"></param>
/// <param name="id"></param>
/// <param name="minSort"></param>
/// <param name="maxSort"></param>
public
void
UpdateLastClueRuleSortSubtract
(
int
group_Id
,
int
id
,
int
minSort
=
0
,
int
maxSort
=
0
)
{
string
sql
=
$@" update RB_WeChat_CustomerClueRule set Sort = Sort -1 where Status =0 and Group_Id =
{
group_Id
}
and Sort >0 and Id <>
{
id
}
"
;
if
(
minSort
>
0
)
{
sql
+=
$" and Sort >="
+
minSort
;
}
if
(
maxSort
>
0
)
{
sql
+=
$" and Sort <="
+
maxSort
;
}
Execute
(
sql
);
}
}
}
Edu.Repository/WeChat/RB_WeChat_CustomerInfoRepository.cs
View file @
07237255
...
...
@@ -259,7 +259,7 @@ namespace Edu.Repository.WeChat
string
vstr
=
"'"
+
string
.
Join
(
"','"
,
vList
)
+
"'"
;
if
(
item
.
IsCustom
==
1
)
{
where
+=
$@"
r.CustomContent -> '$.
{
item
.
Name
}
'
in(
{
vstr
}
) "
;
where
+=
$@"
DATE_FORMAT(r.CustomContent -> '$.
{
item
.
Name
}
','%m月%d号')
in(
{
vstr
}
) "
;
}
else
{
...
...
Edu.WebApi/Controllers/Course/TeachingRewardsController.cs
View file @
07237255
...
...
@@ -1085,5 +1085,367 @@ namespace Edu.WebApi.Controllers.Course
}
#
endregion
#
region
教师投稿提成
/// <summary>
/// 获取投稿提成配置
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeacherContributeConfig
()
{
var
userInfo
=
base
.
UserInfo
;
var
model
=
teachingRewardsModule
.
GetTeacherContributeConfig
(
userInfo
.
Group_Id
);
return
ApiResult
.
Success
(
""
,
new
{
model
?.
Id
,
model
?.
Money
});
}
/// <summary>
/// 保存投稿提成配置
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetTeacherContributeConfig
()
{
var
userInfo
=
base
.
UserInfo
;
RB_TeaCon_Commission_Rule_ViewModel
demodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Rule_ViewModel
>(
base
.
RequestParm
.
Msg
.
ToString
());
if
(
demodel
.
Money
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请输入投稿提成金额"
);
}
demodel
.
Group_Id
=
userInfo
.
Group_Id
;
demodel
.
Status
=
0
;
demodel
.
CreateBy
=
userInfo
.
Id
;
demodel
.
UpdateBy
=
userInfo
.
Id
;
demodel
.
CreateTime
=
DateTime
.
Now
;
demodel
.
UpdateTime
=
DateTime
.
Now
;
string
msg
=
teachingRewardsModule
.
SetTeacherContributeConfig
(
demodel
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 获取投稿提成期数分页列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeaConCommissionPeriodsPageList
()
{
var
userInfo
=
base
.
UserInfo
;
ResultPageModel
pageModel
=
JsonHelper
.
DeserializeObject
<
ResultPageModel
>(
base
.
RequestParm
.
Msg
.
ToString
());
RB_TeaCon_Commission_Periods_ViewModel
dmodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Periods_ViewModel
>(
base
.
RequestParm
.
Msg
.
ToString
());
dmodel
.
Group_Id
=
userInfo
.
Group_Id
;
var
list
=
teachingRewardsModule
.
GetTeaConCommissionPeriodsPageList
(
pageModel
.
PageIndex
,
pageModel
.
PageSize
,
out
long
count
,
dmodel
);
pageModel
.
Count
=
Convert
.
ToInt32
(
count
);
pageModel
.
PageData
=
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
Periods
,
x
.
SumPrice
,
x
.
Name
,
FrIdList
=
string
.
IsNullOrEmpty
(
x
.
Financials
)
?
new
List
<
string
>()
:
x
.
Financials
.
Split
(
','
).
ToList
(),
x
.
CreateBy
,
CreateByName
=
UserReidsCache
.
GetUserLoginInfo
(
x
.
CreateBy
)?.
AccountName
??
""
,
CreateTime
=
x
.
CreateTime
.
ToString
(
"yyyy-MM-dd"
)
});
return
ApiResult
.
Success
(
""
,
pageModel
);
}
/// <summary>
/// 获取期数列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeaConCommissionPeriodsList
()
{
var
userInfo
=
base
.
UserInfo
;
var
dmodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Periods_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
dmodel
.
Group_Id
=
userInfo
.
Group_Id
;
var
list
=
teachingRewardsModule
.
GetTeaConCommissionPeriodsList
(
dmodel
);
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
Periods
,
x
.
Name
,
}));
}
/// <summary>
/// 获取提成用户列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeaConCommissionUserList
()
{
var
userInfo
=
base
.
UserInfo
;
var
dmodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Details_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
dmodel
.
Group_Id
=
userInfo
.
Group_Id
;
if
(
dmodel
.
PeriodId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递期数id"
);
}
var
list
=
teachingRewardsModule
.
GetTeaConCommissionUserList
(
dmodel
);
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
x
.
School_Id
,
x
.
SchoolName
,
x
.
Depart_Id
,
x
.
DeptName
,
x
.
TeacherId
,
x
.
TeacherName
,
x
.
CommissionMoney
}));
}
/// <summary>
/// 获取提成用户明细列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeaConCommissionUserDetailList
()
{
var
userInfo
=
base
.
UserInfo
;
var
dmodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Details_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
dmodel
.
Group_Id
=
userInfo
.
Group_Id
;
if
(
dmodel
.
PeriodId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递期数id"
);
}
var
list
=
teachingRewardsModule
.
GetTeaConCommissionUserDetailList
(
dmodel
);
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
x
.
School_Id
,
x
.
SchoolName
,
x
.
Depart_Id
,
x
.
DeptName
,
x
.
TeacherId
,
x
.
TeacherName
,
x
.
ContributeId
,
x
.
ContributeTitle
,
x
.
ContributeType
,
x
.
Periods
,
x
.
CommissionMoney
,
x
.
Remark
}));
}
/// <summary>
/// 提成统计
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeaConCommissionStatistics
()
{
var
userInfo
=
base
.
UserInfo
;
var
pageModel
=
JsonHelper
.
DeserializeObject
<
ResultPageModel
>(
RequestParm
.
Msg
.
ToString
());
var
dmodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Details_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
dmodel
.
Group_Id
=
userInfo
.
Group_Id
;
var
list
=
teachingRewardsModule
.
GetTeaConCommissionStatisticsPageList
(
pageModel
.
PageIndex
,
pageModel
.
PageSize
,
out
long
count
,
dmodel
);
decimal
TotalMoney
=
teachingRewardsModule
.
GetTeaConCommissionStatistics
(
dmodel
);
pageModel
.
Count
=
Convert
.
ToInt32
(
count
);
pageModel
.
PageData
=
new
{
TotalCommission
=
TotalMoney
,
List
=
list
.
Select
(
x
=>
new
{
x
.
School_Id
,
x
.
SchoolName
,
x
.
Depart_Id
,
x
.
DeptName
,
x
.
TeacherId
,
x
.
TeacherName
,
x
.
ContributeId
,
x
.
ContributeTitle
,
x
.
ContributeType
,
x
.
Periods
,
x
.
CommissionMoney
,
x
.
Remark
})
};
return
ApiResult
.
Success
(
""
,
pageModel
);
}
/// <summary>
/// 导出提成统计 Excel
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
Obsolete
]
public
FileContentResult
GetTeaConCommissionStatisticsToExcel
()
{
var
userInfo
=
base
.
UserInfo
;
var
dmodel
=
JsonHelper
.
DeserializeObject
<
RB_TeaCon_Commission_Details_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
dmodel
.
Group_Id
=
userInfo
.
Group_Id
;
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
=
25
,
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
{
var
list
=
teachingRewardsModule
.
GetTeaConCommissionStatisticsPageList
(
1
,
1000000
,
out
long
count
,
dmodel
);
decimal
TotalMoney
=
teachingRewardsModule
.
GetTeaConCommissionStatistics
(
dmodel
);
#
region
组装数据
foreach
(
var
item
in
list
)
{
ExcelDataSource
datarow
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
item
.
SchoolName
){
},
new
ExcelColumn
(
value
:
item
.
DeptName
){
},
new
ExcelColumn
(
value
:
item
.
TeacherName
){
},
new
ExcelColumn
(
value
:
item
.
ContributeType
){
},
new
ExcelColumn
(
value
:
item
.
ContributeTitle
){
},
new
ExcelColumn
(
value
:
item
.
CommissionMoney
.
ToString
(
"#0.00"
)){
},
new
ExcelColumn
(
value
:
item
.
Periods
){
},
new
ExcelColumn
(
value
:
item
.
Remark
){
},
},
ColumnHight
=
30
};
slist
.
Add
(
datarow
);
}
//统计
ExcelDataSource
datarows
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
"汇总"
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
TotalMoney
.
ToString
(
"#0.00"
)){
},
new
ExcelColumn
(
value
:
""
){
},
new
ExcelColumn
(
value
:
""
){
},
},
ColumnHight
=
30
};
slist
.
Add
(
datarows
);
#
endregion
var
byteData
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData
,
"application/octet-stream"
,
ExcelName
);
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetTeachingBonusDetailToExcel: {0}"
,
JsonHelper
.
Serialize
(
RequestParm
)));
var
byteData1
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData1
,
"application/octet-stream"
,
ExcelName
);
}
}
/// <summary>
/// 创建投稿提成
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetTeaConCommissionInfo
()
{
var
userInfo
=
base
.
UserInfo
;
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
Msg
.
ToString
());
string
Month
=
parms
.
GetStringValue
(
"Month"
);
//月份
if
(
string
.
IsNullOrEmpty
(
Month
))
{
return
ApiResult
.
ParamIsNull
();
}
try
{
Month
=
Convert
.
ToDateTime
(
Month
+
"-01"
).
ToString
(
"yyyy-MM"
);
}
catch
(
Exception
)
{
return
ApiResult
.
Failed
(
"日期格式有误"
);
}
string
msg
=
teachingRewardsModule
.
SetTeaConCommissionInfo
(
Month
,
userInfo
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 获取提成可发放人员列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetTeaConCommissionSendEmployeeList
()
{
var
userInfo
=
base
.
UserInfo
;
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
Msg
.
ToString
());
int
PeriodId
=
parms
.
GetInt
(
"PeriodId"
,
0
);
//期数id
if
(
PeriodId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
var
list
=
teachingRewardsModule
.
GetTeaConCommissionSendEmployeeList
(
PeriodId
,
userInfo
);
return
ApiResult
.
Success
(
""
,
list
);
}
/// <summary>
/// 设置提成发放人员
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetTeaConCommissionSendEmployee
()
{
var
userInfo
=
base
.
UserInfo
;
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
Msg
.
ToString
());
int
PeriodId
=
parms
.
GetInt
(
"PeriodId"
,
0
);
//期数id
string
EmpIds
=
parms
.
GetStringValue
(
"EmpIds"
);
//人员列表
if
(
PeriodId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
if
(
string
.
IsNullOrEmpty
(
EmpIds
))
{
return
ApiResult
.
ParamIsNull
(
"请传递用户id"
);
}
string
msg
=
teachingRewardsModule
.
SetTeaConCommissionSendEmployee
(
PeriodId
,
EmpIds
,
userInfo
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
(
""
);
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
#
endregion
}
}
Edu.WebApi/Controllers/QYWeChat/QYContributeController.cs
View file @
07237255
...
...
@@ -597,6 +597,8 @@ namespace Edu.WebApi.Controllers.QYWeChat
}),
x
.
AuditState
,
AuditStateName
=
x
.
AuditState
.
ToName
(),
x
.
IsSendCommission
,
x
.
CommissionMoney
,
x
.
UpdateBy
,
UpdateByName
=
Cache
.
User
.
UserReidsCache
.
GetUserLoginInfo
(
x
.
UpdateBy
)?.
AccountName
??
""
,
UpdateTime
=
x
.
UpdateTime
.
ToString
(
"yyyy-MM-dd HH:mm"
)
...
...
Edu.WebApi/Controllers/QYWeChat/QYCustomerController.cs
View file @
07237255
...
...
@@ -410,6 +410,7 @@ namespace Edu.WebApi.Controllers.QYWeChat
var
model
=
customerModule
.
GetCustomerConfig
(
userInfo
.
Group_Id
);
return
ApiResult
.
Success
(
""
,
new
{
model
?.
Id
,
model
?.
IsPublicAudit
,
model
?.
PublicGetDept
,
model
?.
AbandonType
,
...
...
@@ -490,6 +491,10 @@ namespace Edu.WebApi.Controllers.QYWeChat
}
demdoel
.
AbandonSelectValue
=
JsonHelper
.
Serialize
(
demdoel
.
AbandonKHSelect
);
}
if
(
demdoel
.
AbandonReasonList
!=
null
&&
demdoel
.
AbandonReasonList
.
Any
())
{
demdoel
.
AbandonReason
=
JsonHelper
.
Serialize
(
demdoel
.
AbandonReasonList
);
}
demdoel
.
Group_Id
=
userInfo
.
Group_Id
;
demdoel
.
Status
=
0
;
demdoel
.
CreateBy
=
userInfo
.
Id
;
...
...
@@ -944,7 +949,7 @@ namespace Edu.WebApi.Controllers.QYWeChat
}
//修改客户企业标签(批量处理)
//批量转移
放弃 导出 删除
//批量转移
导出
#
endregion
...
...
@@ -995,8 +1000,149 @@ namespace Edu.WebApi.Controllers.QYWeChat
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 获取客户线索规则列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetCustomerClueRuleList
()
{
var
userInfo
=
base
.
UserInfo
;
var
list
=
customerModule
.
GetCustomerClueRuleList
(
userInfo
.
Group_Id
);
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
RuleSelectType
,
x
.
IsDefault
,
DeptList
=
x
.
DeptList
.
Select
(
z
=>
new
{
z
.
DeptId
,
z
.
DeptName
}),
EmpList
=
x
.
EmpList
.
Select
(
z
=>
new
{
z
.
Id
,
z
.
EmployeeName
}),
x
.
RuleAllotWay
,
x
.
Sort
,
x
.
ConditionList
,
x
.
ConditionStrList
}));
}
/// <summary>
/// 获取客户线索规则信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetCustomerClueRuleInfo
()
{
var
userInfo
=
base
.
UserInfo
;
JObject
parms
=
JObject
.
Parse
(
base
.
RequestParm
.
Msg
.
ToString
());
int
RuleId
=
parms
.
GetInt
(
"RuleId"
,
0
);
if
(
RuleId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递规则ID"
);
}
var
model
=
customerModule
.
GetCustomerClueRuleInfo
(
RuleId
,
userInfo
.
Group_Id
);
return
ApiResult
.
Success
(
""
,
new
{
model
.
Id
,
model
.
RuleSelectType
,
model
.
IsDefault
,
DeptList
=
model
.
DeptList
.
Select
(
z
=>
new
{
z
.
DeptId
,
z
.
DeptName
}),
EmpList
=
model
.
EmpList
.
Select
(
z
=>
new
{
z
.
Id
,
z
.
EmployeeName
}),
model
.
RuleAllotWay
,
model
.
Sort
,
model
.
ConditionList
,
model
.
ConditionStrList
});
}
/// <summary>
/// 新增修改线索规则
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetCustomerClueRuleInfo
()
{
var
userInfo
=
base
.
UserInfo
;
RB_WeChat_CustomerClueRule_ViewModel
demodel
=
JsonHelper
.
DeserializeObject
<
RB_WeChat_CustomerClueRule_ViewModel
>(
base
.
RequestParm
.
Msg
.
ToString
());
if
(
demodel
.
ConditionList
==
null
||
!
demodel
.
ConditionList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请选择条件"
);
}
if
((
demodel
.
DeptList
==
null
||
!
demodel
.
DeptList
.
Any
())
&&
(
demodel
.
EmpList
==
null
||
!
demodel
.
EmpList
.
Any
()))
{
return
ApiResult
.
ParamIsNull
(
"请选择适用部门/成员"
);
}
demodel
.
RuleSelectValue
=
JsonHelper
.
Serialize
(
demodel
.
ConditionList
);
demodel
.
DeptIds
=
"-1"
;
demodel
.
EmpIds
=
"-1"
;
if
(
demodel
.
DeptList
==
null
||
!
demodel
.
DeptList
.
Any
())
{
demodel
.
DeptIds
=
string
.
Join
(
","
,
demodel
.
DeptList
.
Select
(
x
=>
x
.
DeptId
));
}
if
(
demodel
.
EmpList
==
null
||
!
demodel
.
EmpList
.
Any
())
{
demodel
.
EmpIds
=
string
.
Join
(
","
,
demodel
.
EmpList
.
Select
(
x
=>
x
.
Id
));
}
demodel
.
Group_Id
=
userInfo
.
Group_Id
;
demodel
.
Status
=
0
;
demodel
.
CreateBy
=
userInfo
.
Id
;
demodel
.
CreateTime
=
DateTime
.
Now
;
demodel
.
UpdateBy
=
userInfo
.
Id
;
demodel
.
UpdateTime
=
DateTime
.
Now
;
demodel
.
IsDefault
=
2
;
string
msg
=
customerModule
.
SetCustomerClueRuleInfo
(
demodel
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 设置线索规则状态
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetCustomerClueRuleState
()
{
var
userInfo
=
base
.
UserInfo
;
JObject
parms
=
JObject
.
Parse
(
base
.
RequestParm
.
Msg
.
ToString
());
int
RuleId
=
parms
.
GetInt
(
"RuleId"
,
0
);
//规则ID
int
Type
=
parms
.
GetInt
(
"Type"
,
1
);
//类型 1移动规则 2删除
int
TargetId
=
parms
.
GetInt
(
"TargetId"
,
0
);
//移动至目标的后面 0 表示移动至第一个
if
(
RuleId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递规则Id"
);
}
if
(
Type
==
1
&&
TargetId
<
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递目标ID"
);
}
string
msg
=
customerModule
.
SetCustomerClueRuleState
(
RuleId
,
Type
,
TargetId
,
userInfo
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
#
endregion
#
region
客户线索
/// <summary>
/// 获取客户线索分页列表
/// </summary>
...
...
@@ -1043,6 +1189,101 @@ namespace Edu.WebApi.Controllers.QYWeChat
return
ApiResult
.
Success
(
""
,
pmodel
);
}
/// <summary>
/// 新增线索
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetCustomerClueInfo
()
{
var
userInfo
=
base
.
UserInfo
;
RB_WeChat_CustomerInfo_ViewModel
demodel
=
JsonHelper
.
DeserializeObject
<
RB_WeChat_CustomerInfo_ViewModel
>(
base
.
RequestParm
.
Msg
.
ToString
());
if
(
demodel
.
CustomFiledList
==
null
||
!
demodel
.
CustomFiledList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递字段内容"
);
}
#
region
验证自定义字段
if
(
demodel
.
CustomFiledList
.
Where
(
x
=>
x
.
Id
<=
0
).
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递客户字段ID"
);
}
string
xName
=
demodel
.
CustomFiledList
.
Where
(
x
=>
x
.
Name
==
"姓名"
).
FirstOrDefault
()?.
Value
??
""
;
string
mobile
=
demodel
.
CustomFiledList
.
Where
(
x
=>
x
.
Name
==
"电话"
).
FirstOrDefault
()?.
Value
??
""
;
if
(
string
.
IsNullOrEmpty
(
xName
))
{
return
ApiResult
.
ParamIsNull
(
"请输入客人姓名"
);
}
if
(
string
.
IsNullOrEmpty
(
mobile
))
{
return
ApiResult
.
ParamIsNull
(
"请输入客人电话"
);
}
Dictionary
<
string
,
string
>
CustomContentKV
=
new
Dictionary
<
string
,
string
>();
foreach
(
var
qitem
in
demodel
.
CustomFiledList
)
{
CustomContentKV
.
Add
(
"z"
+
qitem
.
Id
,
qitem
.
Value
);
}
demodel
.
CustomContent
=
JsonHelper
.
Serialize
(
CustomContentKV
);
demodel
.
CustomerMobile
=
mobile
;
demodel
.
CustomerName
=
xName
;
#
endregion
#
region
基本信息
demodel
.
Status
=
0
;
demodel
.
Group_Id
=
userInfo
.
Group_Id
;
demodel
.
CreateBy
=
userInfo
.
Id
;
demodel
.
CreateTime
=
DateTime
.
Now
;
demodel
.
UpdateBy
=
userInfo
.
Id
;
demodel
.
UpdateTime
=
DateTime
.
Now
;
demodel
.
AddWay
=
CustomerAddWayEnum
.
Person
;
demodel
.
CustomerState
=
2
;
//线索
demodel
.
ClueState
=
1
;
//未处理
demodel
.
AllotState
=
0
;
//分配状态
demodel
.
EmpId
=
0
;
demodel
.
WorkEmpId
=
""
;
demodel
.
WorkEmpName
=
""
;
demodel
.
ExternalUserId
=
""
;
demodel
.
CustomerType
=
1
;
//微信用户
demodel
.
StageId
=
0
;
//阶段 根据领用用户来判断
demodel
.
FriendState
=
2
;
#
endregion
string
msg
=
customerModule
.
SetCustomerClueInfo
(
demodel
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 批量设置线索状态
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetCustomerClueState
()
{
var
userInfo
=
base
.
UserInfo
;
JObject
parms
=
JObject
.
Parse
(
base
.
RequestParm
.
Msg
.
ToString
());
string
CustomerIds
=
parms
.
GetStringValue
(
"CustomerIds"
);
//客户ids
int
Type
=
parms
.
GetInt
(
"Type"
,
1
);
//类型 1有效线索 2无效线索 3待回访 4直接分配(员工ID) 5重置无效线索
string
EmpIds
=
parms
.
GetStringValue
(
"EmpIds"
);
//分配员工
if
(
string
.
IsNullOrEmpty
(
CustomerIds
))
{
return
ApiResult
.
ParamIsNull
(
"请传递客户ids"
);
}
if
(
Type
==
4
&&
string
.
IsNullOrEmpty
(
EmpIds
))
{
return
ApiResult
.
ParamIsNull
(
"请传递分配员工"
);
}
string
msg
=
customerModule
.
SetCustomerClueState
(
CustomerIds
,
Type
,
EmpIds
,
userInfo
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
ParamIsNull
(
msg
);
}
}
#
endregion
#
endregion
}
}
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