作者 陈志颖

feat:增加修改手机号

... ... @@ -17,11 +17,11 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
)
// 任务服务
// TaskService 任务服务
type TaskService struct {
}
// 对抢单任务进行确认
// ConfirmRobTask 对抢单任务进行确认
func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -411,11 +411,11 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
// 搜索任务
func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTaskCommand) (interface{}, error) {
if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令
if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文
transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -918,7 +918,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
}
sponsor, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.Sponsor,
"uid": createTaskCommand.Sponsor,
"status": 1,
})
if err != nil {
... ... @@ -935,14 +935,14 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if sponsorInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+ sponsorInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+sponsorInvalid.EmployeeInfo.EmployeeName)
}
// 获取任务指派人
var assignedPerson *domain.EmployeeInfo
if createTaskCommand.AssignedPerson != 0 {
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.AssignedPerson,
"uid": createTaskCommand.AssignedPerson,
"status": 1,
})
if err != nil {
... ... @@ -959,7 +959,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
}
assignedPerson = employee.EmployeeInfo
}
... ... @@ -978,7 +978,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
CustomerValues: createTaskCommand.CustomerValues,
TaskNature: createTaskCommand.TaskNature,
SuMoney: createTaskCommand.SuMoney,
MinSuMoney: createTaskCommand.MinSuMoney,
MinSuMoney: createTaskCommand.MinSuMoney,
MaxSuMoney: createTaskCommand.MaxSuMoney,
AcceptanceStandard: createTaskCommand.AcceptanceStandard,
TaskDescription: createTaskCommand.TaskDescription,
... ... @@ -1150,7 +1150,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
}
// 返回任务素币奖励范围
if taskDto.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
if taskDto.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
taskDto.MinSuMoney = 0
taskDto.MaxSuMoney = task.SuMoney
}
... ... @@ -1291,7 +1291,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
employeeRepository = value
}
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": updateTaskCommand.AssignedPerson,
"uid": updateTaskCommand.AssignedPerson,
"status": 1,
})
if err != nil {
... ... @@ -1308,7 +1308,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
}
updateData["assignedPerson"] = employee.EmployeeInfo
} else {
... ... @@ -1457,7 +1457,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in
}
var retTasks []*domain.Task
for _, task := range tasks {
if task.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
if task.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
task.MinSuMoney = 0
task.MaxSuMoney = task.SuMoney
}
... ...
... ... @@ -49,6 +49,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
var uid int64
var employeeName string
var employeeAccount string
var oldPhone string
var newPhone string
var employeeAvatarUrl string
var isPrincipal bool
var status int
... ... @@ -74,6 +76,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
if value, ok := data["avatar"]; ok {
employeeAvatarUrl = value.(string)
}
if value, ok := data["oldPhone"]; ok {
oldPhone = value.(string)
}
if value, ok := data["newPhone"]; ok {
newPhone = value.(string)
}
if value, ok := data["admin_type"]; ok {
if int(value.(float64)) == 2 {
isPrincipal = true
... ... @@ -89,12 +97,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
uids = append(uids, int64(uid.(float64)))
}
}
if value, ok := data["add"]; ok { // 添加员工
if value, ok := data["add"]; ok { // 添加员工
for _, addEmployee := range value.([]interface{}) {
addEmployees = append(addEmployees, addEmployee.(map[string]interface{}))
}
}
if value, ok := data["edit"]; ok { // 编辑员工
if value, ok := data["edit"]; ok { // 编辑员工
for _, editEmployee := range value.([]interface{}) {
editEmployees = append(editEmployees, editEmployee.(map[string]interface{}))
}
... ... @@ -144,8 +152,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
EmployeeAvatarUrl: employeeAvatarUrl,
IsPrincipal: isPrincipal,
},
Status: status,
SuMoney: 0,
Status: status,
SuMoney: 0,
CreateTime: time.Now(),
}
... ... @@ -206,8 +214,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
EmployeeAvatarUrl: employeeAvatarUrl,
IsPrincipal: isPrincipal,
},
Status: status,
SuMoney: 0,
Status: status,
SuMoney: 0,
CreateTime: time.Now(),
}
if _, err := employeeRepository.Save(employee); err != nil {
... ... @@ -234,7 +242,6 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
if _, err := employeeRepository.Save(employee); err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//TODO 业务数据修改
break
case "batchDelete":
err := employeeDao.BatchRemove(uids)
... ... @@ -248,6 +255,15 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
break
case "changePhone": // TODO 修改手机号
// 修改用户数据
err := employeeDao.ChangePhone(oldPhone, newPhone)
if err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//TODO 修改业务数据
break
default:
return false, nil
}
... ...
... ... @@ -10,7 +10,7 @@ type BidInfosDao struct {
}
//TODO ChangeBidInfosSuccessfulBidderAccount
func (dao *BidInfosDao) ChangeBidInfosSuccessfulBidderAccount() {
func (dao *BidInfosDao) ChangeBidInfosSuccessfulBidderAccount(uid int64, newAccount string) {
}
... ...
... ... @@ -57,6 +57,18 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string)
return nil
}
// ChangePhone TODO 修改用户手机号
func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error {
tx := dao.transactionContext.PgTx
if _, err := tx.QueryOne(
pg.Scan(),
"UPDATE employees SET employee_account=? WHERE employee_account=?",
oldPhone, newPhone); err != nil {
return err
}
return nil
}
// 更新用户素币
func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error {
tx := dao.transactionContext.PgTx
... ... @@ -139,7 +151,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
}
// 计算系统已兑换现金素币、未兑换素币
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] interface{}, error) {
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string]interface{}, error) {
var systemUnExchangeSuMoney float64
var systemExchangedSuMoney float64
var systemExchangedSuMoneyRestore float64
... ... @@ -172,18 +184,18 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
Select(&systemExchangedSuMoneyRestore); err != nil {
return nil, err
}
return map[string] interface{} {
return map[string]interface{}{
"systemUnExchangeSuMoney": systemUnExchangeSuMoney,
"systemExchangedSuMoney": systemExchangedSuMoney - systemExchangedSuMoneyRestore,
},nil
"systemExchangedSuMoney": systemExchangedSuMoney - systemExchangedSuMoneyRestore,
}, nil
}
// 计算现金池已兑换现金、未兑换现金
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interface{}, error) {
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string]interface{}, error) {
tx := dao.transactionContext.PgTx
var (
systemUnExchangeCash float64
systemExchangedCash float64
systemExchangedCash float64
)
// 系统已兑换现金
cashPool := new(models.CashPool)
... ... @@ -192,7 +204,7 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
Where("cash_pool.company_id = ?", companyId).
Order("id DESC").
Limit(1).
Select(&systemExchangedCash) ; err != nil {
Select(&systemExchangedCash); err != nil {
return nil, err
}
// 系统未兑换现金
... ... @@ -201,22 +213,22 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
Where("cash_pool.company_id = ?", companyId).
Order("id DESC").
Limit(1).
Select(&systemUnExchangeCash) ; err != nil {
Select(&systemUnExchangeCash); err != nil {
return nil, err
}
return map[string] interface{} {
return map[string]interface{}{
"systemUnExchangeCash": systemUnExchangeCash,
"systemExchangedCash": systemExchangedCash,
"systemExchangedCash": systemExchangedCash,
}, nil
}
// 计算个人素币收支(素币明细收支)
func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
var (
incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)
expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除)
expendSuMoneyExchange float64 // 5: 兑换现金
incomeSuMoneyExchangeRestore float64 // 6: 兑换素币撤回
incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)
expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除)
expendSuMoneyExchange float64 // 5: 兑换现金
incomeSuMoneyExchangeRestore float64 // 6: 兑换素币撤回
)
tx := dao.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
... ... @@ -261,7 +273,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
return nil, err
}
return map[string]interface{}{
"incomeSuMoney": incomeSuMoney, // 个人素币收入
"incomeSuMoney": incomeSuMoney, // 个人素币收入
"expendSuMoney": expendSuMoney + (expendSuMoneyExchange - incomeSuMoneyExchangeRestore), // 个人素币支出
}, nil
}
... ... @@ -269,8 +281,8 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
// 计算个人贡献值收支(贡献明细收支)
func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
var (
incomeContributions float64 // 收入的贡献值(2:任务奖励,3:增加)
expendContributions float64 // 支出的贡献值 (4: 扣除)
incomeContributions float64 // 收入的贡献值(2:任务奖励,3:增加)
expendContributions float64 // 支出的贡献值 (4: 扣除)
)
tx := dao.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
... ... @@ -301,37 +313,37 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans
return nil, err
}
return map[string]interface{}{
"incomeContributions": incomeContributions, // 个人贡献值收入
"expendContributions": expendContributions, // 个人贡献支出
"contributions": incomeContributions - expendContributions, // 个人贡献值
"incomeContributions": incomeContributions, // 个人贡献值收入
"expendContributions": expendContributions, // 个人贡献支出
"contributions": incomeContributions - expendContributions, // 个人贡献值
}, nil
}
// 贡献值、财富值总榜和年榜,
func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
var retWealth []struct { // 个人财富值
Uid int64
EmployeeName string
var retWealth []struct { // 个人财富值
Uid int64
EmployeeName string
EmployeeSuMoney float64
Ranking int
Ranking int
}
var retEmployeeWealth []struct { // 个人贡献值
Uid int64
EmployeeName string
var retEmployeeWealth []struct { // 个人贡献值
Uid int64
EmployeeName string
EmployeeSuMoney float64
Ranking int
Ranking int
}
var retContributions []struct { // 员工贡献值
Uid int64
EmployeeName string
var retContributions []struct { // 员工贡献值
Uid int64
EmployeeName string
EmployeesContributions float64
Ranking int
Ranking int
}
var retEmployeeContributions []struct { // 员工贡献值
Uid int64
EmployeeName string
var retEmployeeContributions []struct { // 员工贡献值
Uid int64
EmployeeName string
EmployeesContributions float64
Ranking int
Ranking int
}
tx := dao.transactionContext.PgTx
... ... @@ -496,23 +508,23 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
}
return map[string]interface{}{
"employeesWealth": retWealth,
"employeesContributions": retContributions,
"employeesWealth": retWealth,
"employeesContributions": retContributions,
"currentEmployeeContributions": retCurrentEmployeeContributions,
"currentEmployeeWealth": retCurrentEmployeeWealth,
"currentEmployeeWealth": retCurrentEmployeeWealth,
}, nil
}
// 公司员工贡献值分组统计
func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
var ret []struct { // 员工贡献值
Uid int
EmployeeName string
var ret []struct { // 员工贡献值
Uid int
EmployeeName string
EmployeesContributions float64
}
var retDecrease []struct { // 员工减少的贡献值
Uid int
EmployeeName string
var retDecrease []struct { // 员工减少的贡献值
Uid int
EmployeeName string
EmployeesContributions float64
}
tx := dao.transactionContext.PgTx
... ... @@ -562,8 +574,8 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime
// 公司员工财富值分组统计
func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
var ret []struct {
Uid int
EmployeeName string
Uid int
EmployeeName string
EmployeeSuMoney float64
}
tx := dao.transactionContext.PgTx
... ... @@ -574,7 +586,7 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.
ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").
Where(`e.company_id = ?`, companyId).
//Where(`e.status = ?`, 1).
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
Where(`su_money_transaction_record.create_time > ?`, startTime).
Where(`su_money_transaction_record.create_time < ?`, endTime).
Group("su_money_transaction_record.employee").
... ...
... ... @@ -9,7 +9,7 @@ type SentNotificationDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeSentNotificationReceiverAccount
// ChangeSentNotificationReceiverAccount TODO
func (dao *SentNotificationDao) ChangeSentNotificationReceiverAccount() {
}
... ... @@ -22,4 +22,4 @@ func NewSentNotificationDao(transactionContext *pgTransaction.TransactionContext
transactionContext: transactionContext,
}, nil
}
}
\ No newline at end of file
}
... ...