作者 陈志颖

refactor:导入素币兑换清单

@@ -1319,7 +1319,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1319,7 +1319,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1319 1319
1320 // 导入新增兑换素币清单 1320 // 导入新增兑换素币清单
1321 func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand, failureDataList []interface{}) ([]interface{}, error) { 1321 func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExchangeCashPersonCommands []*command.CreateExchangeCashPersonCommand, failureDataList []interface{}) ([]interface{}, error) {
1322 - // 批量校验 1322 + // 新增素币兑换清单命令校验
1323 for _, createExchangeCashPersonCommand := range createExchangeCashPersonCommands { 1323 for _, createExchangeCashPersonCommand := range createExchangeCashPersonCommands {
1324 if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { 1324 if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
1325 row := []interface{}{ 1325 row := []interface{}{
@@ -1332,7 +1332,6 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1332,7 +1332,6 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1332 continue 1332 continue
1333 } 1333 }
1334 } 1334 }
1335 -  
1336 if len(failureDataList) > 0 { 1335 if len(failureDataList) > 0 {
1337 return []interface{}{}, application.ThrowError(application.TRANSACTION_ERROR, "校验失败") 1336 return []interface{}{}, application.ThrowError(application.TRANSACTION_ERROR, "校验失败")
1338 } 1337 }
@@ -1432,12 +1431,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1432,12 +1431,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1432 failureDataList = append(failureDataList, row) 1431 failureDataList = append(failureDataList, row)
1433 continue 1432 continue
1434 } 1433 }
1435 -  
1436 - activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney  
1437 - activityFoundExchangedCash := activityFound.ExchangedCash 1434 + activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币
  1435 + activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币
1438 1436
1439 // 获取当前公司现金池 1437 // 获取当前公司现金池
1440 - _, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{ 1438 + cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
1441 "companyId": activityFound.CompanyId, 1439 "companyId": activityFound.CompanyId,
1442 }) 1440 })
1443 if err != nil { 1441 if err != nil {
@@ -1450,7 +1448,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1450,7 +1448,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1450 failureDataList = append(failureDataList, row) 1448 failureDataList = append(failureDataList, row)
1451 continue 1449 continue
1452 } 1450 }
1453 - if len(cashPoolsFound) == 0 { 1451 + if cashPoolFound == nil {
1454 row := []interface{}{ 1452 row := []interface{}{
1455 createExchangeCashPersonCommand.PersonName, 1453 createExchangeCashPersonCommand.PersonName,
1456 createExchangeCashPersonCommand.PersonAccount, 1454 createExchangeCashPersonCommand.PersonAccount,
@@ -1460,17 +1458,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1460,17 +1458,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1460 failureDataList = append(failureDataList, row) 1458 failureDataList = append(failureDataList, row)
1461 continue 1459 continue
1462 } 1460 }
  1461 + cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
  1462 + cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
1463 1463
1464 - cashPoolFoundUnExchangeCash := cashPoolsFound[0].UnExchangeCash  
1465 - cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash  
1466 -  
1467 - // 获取员工查询条件 1464 + // 判断当前员工是否有效
1468 getEmployee := map[string]interface{}{ 1465 getEmployee := map[string]interface{}{
1469 "account": createExchangeCashPersonCommand.PersonAccount, 1466 "account": createExchangeCashPersonCommand.PersonAccount,
1470 "companyId": activityFound.CompanyId, 1467 "companyId": activityFound.CompanyId,
1471 } 1468 }
1472 -  
1473 - // 判断当前员工是否有效  
1474 employeeFound, err := employeeRepository.FindOne(getEmployee) 1469 employeeFound, err := employeeRepository.FindOne(getEmployee)
1475 if err != nil { 1470 if err != nil {
1476 row := []interface{}{ 1471 row := []interface{}{
@@ -1491,45 +1486,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1491,45 +1486,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1491 } 1486 }
1492 failureDataList = append(failureDataList, row) 1487 failureDataList = append(failureDataList, row)
1493 continue 1488 continue
1494 - } else {  
1495 - employeeFoundSuMoney := employeeFound.SuMoney  
1496 - // 判断该员工兑换的素币是否超过本人持有的素币  
1497 - if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) {  
1498 - row := []interface{}{  
1499 - createExchangeCashPersonCommand.PersonName,  
1500 - createExchangeCashPersonCommand.PersonAccount,  
1501 - createExchangeCashPersonCommand.ExchangedSuMoney,  
1502 - "当前兑换素币超过本人持有的素币值",  
1503 - }  
1504 - failureDataList = append(failureDataList, row)  
1505 - continue  
1506 - }  
1507 } 1489 }
  1490 + employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
1508 1491
1509 - employeeFoundSuMoney := employeeFound.SuMoney  
1510 -  
1511 - // 判断当前员工是否已经在素币兑换清单中  
1512 - _, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{  
1513 - "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,  
1514 - "exchangeCashActivityId": activityFound.ActivityId,  
1515 - "offset": 0,  
1516 - "limit": 1,  
1517 - })  
1518 - if err != nil {  
1519 - row := []interface{}{  
1520 - createExchangeCashPersonCommand.PersonName,  
1521 - createExchangeCashPersonCommand.PersonAccount,  
1522 - createExchangeCashPersonCommand.ExchangedSuMoney,  
1523 - err.Error(),  
1524 - }  
1525 - failureDataList = append(failureDataList, row)  
1526 - continue  
1527 - }  
1528 - //if len(peopleFound) != 0 {  
1529 - // peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney 1492 + //else {
  1493 + // employeeFoundSuMoney := employeeFound.SuMoney
1530 // // 判断该员工兑换的素币是否超过本人持有的素币 1494 // // 判断该员工兑换的素币是否超过本人持有的素币
1531 - // if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {  
1532 - // if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) { 1495 + // if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) {
1533 // row := []interface{}{ 1496 // row := []interface{}{
1534 // createExchangeCashPersonCommand.PersonName, 1497 // createExchangeCashPersonCommand.PersonName,
1535 // createExchangeCashPersonCommand.PersonAccount, 1498 // createExchangeCashPersonCommand.PersonAccount,
@@ -1539,32 +1502,32 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1539,32 +1502,32 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1539 // failureDataList = append(failureDataList, row) 1502 // failureDataList = append(failureDataList, row)
1540 // continue 1503 // continue
1541 // } 1504 // }
1542 - // }  
1543 //} 1505 //}
1544 - if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换  
1545 - // 获取当前员工已兑换素币  
1546 - personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney  
1547 -  
1548 - // 获取当前兑换员工已兑换现金  
1549 - //personFoundExchangedCash := peopleFound[0].ExchangedCash  
1550 -  
1551 - if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币  
1552 - // 素币减量  
1553 - suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney  
1554 1506
1555 - // 现金减量  
1556 - cashDecrement := suMoneyDecrement * activityFound.Rate  
1557 -  
1558 - // 更新兑换素币清单命令  
1559 - updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{  
1560 - ListId: peopleFound[0].ListId,  
1561 - ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,  
1562 - ExchangedCash: (personFoundExchangedSuMoney - suMoneyDecrement) * activityFound.Rate,  
1563 - Operator: createExchangeCashPersonCommand.Operator,  
1564 - } 1507 + //// 判断当前员工是否已经在素币兑换清单中
  1508 + //_, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
  1509 + // "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
  1510 + // "exchangeCashActivityId": activityFound.ActivityId,
  1511 + // "offset": 0,
  1512 + // "limit": 1,
  1513 + //})
  1514 + //if err != nil {
  1515 + // row := []interface{}{
  1516 + // createExchangeCashPersonCommand.PersonName,
  1517 + // createExchangeCashPersonCommand.PersonAccount,
  1518 + // createExchangeCashPersonCommand.ExchangedSuMoney,
  1519 + // err.Error(),
  1520 + // }
  1521 + // failureDataList = append(failureDataList, row)
  1522 + // continue
  1523 + //}
1565 1524
1566 - // 更新兑换素币清单  
1567 - if err := peopleFound[0].Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1525 + // 判断当前员工是否已经在素币兑换清单中
  1526 + personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
  1527 + "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
  1528 + "activityId": activityFound.ActivityId,
  1529 + })
  1530 + if err != nil {
1568 row := []interface{}{ 1531 row := []interface{}{
1569 createExchangeCashPersonCommand.PersonName, 1532 createExchangeCashPersonCommand.PersonName,
1570 createExchangeCashPersonCommand.PersonAccount, 1533 createExchangeCashPersonCommand.PersonAccount,
@@ -1574,32 +1537,33 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1574,32 +1537,33 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1574 failureDataList = append(failureDataList, row) 1537 failureDataList = append(failureDataList, row)
1575 continue 1538 continue
1576 } 1539 }
1577 -  
1578 - // 保存兑换素币清单更新  
1579 - _, err := exchangeCashPersonListRepository.Save(peopleFound[0])  
1580 - if err != nil { 1540 + if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单
  1541 + // 判断该员工兑换的素币是否超过本人持有的素币
  1542 + if (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) > employeeFoundSuMoney {
1581 row := []interface{}{ 1543 row := []interface{}{
1582 createExchangeCashPersonCommand.PersonName, 1544 createExchangeCashPersonCommand.PersonName,
1583 createExchangeCashPersonCommand.PersonAccount, 1545 createExchangeCashPersonCommand.PersonAccount,
1584 createExchangeCashPersonCommand.ExchangedSuMoney, 1546 createExchangeCashPersonCommand.ExchangedSuMoney,
1585 - err.Error(), 1547 + "当前兑换素币超过本人持有的素币值",
1586 } 1548 }
1587 failureDataList = append(failureDataList, row) 1549 failureDataList = append(failureDataList, row)
1588 continue 1550 continue
1589 } 1551 }
1590 1552
1591 - // 更新素币兑换活动命令  
1592 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{  
1593 - ExchangeCashActivityId: peopleFound[0].ExchangeCashActivityId,  
1594 - ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,  
1595 - ExchangedCash: activityFoundExchangedCash - cashDecrement,  
1596 - Deadline: activityFound.Deadline,  
1597 - CountDown: activityFound.CountDown,  
1598 - ExchangeRate: activityFound.Rate, 1553 + // 新增兑换素币清单
  1554 + newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
  1555 + newPerson := &domain.ExchangeCashPersonList{
  1556 + EmployeeInfo: &domain.EmployeeInfo{
  1557 + Uid: employeeFound.EmployeeInfo.Uid,
  1558 + EmployeeName: employeeFound.EmployeeInfo.EmployeeName,
  1559 + EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
  1560 + },
  1561 + ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
  1562 + ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  1563 + ExchangedCash: newPersonExchangedCash,
1599 } 1564 }
1600 -  
1601 - // 更新兑换活动  
1602 - if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1565 + personSaved, err := exchangeCashPersonListRepository.Save(newPerson)
  1566 + if err != nil {
1603 row := []interface{}{ 1567 row := []interface{}{
1604 createExchangeCashPersonCommand.PersonName, 1568 createExchangeCashPersonCommand.PersonName,
1605 createExchangeCashPersonCommand.PersonAccount, 1569 createExchangeCashPersonCommand.PersonAccount,
@@ -1609,77 +1573,100 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1609,77 +1573,100 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1609 failureDataList = append(failureDataList, row) 1573 failureDataList = append(failureDataList, row)
1610 continue 1574 continue
1611 } 1575 }
  1576 + if personSaved == nil {
  1577 + row := []interface{}{
  1578 + createExchangeCashPersonCommand.PersonName,
  1579 + createExchangeCashPersonCommand.PersonAccount,
  1580 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1581 + "保存到兑换素币清单失败",
  1582 + }
  1583 + failureDataList = append(failureDataList, row)
  1584 + continue
  1585 + }
1612 1586
1613 - // 保存兑换现金活动更新  
1614 - activityUpdated, err := exchangeCashActivityRepository.Save(activityFound) 1587 + // 操作素币,生成素币流水
  1588 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
  1589 + Uid: employeeFound.EmployeeInfo.Uid,
  1590 + Operator: createExchangeCashPersonCommand.Operator,
  1591 + SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  1592 + OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
  1593 + OperationDescription: "参与" + activityFound.ExchangeActivityName,
  1594 + }
  1595 + task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1615 if err != nil { 1596 if err != nil {
1616 row := []interface{}{ 1597 row := []interface{}{
1617 createExchangeCashPersonCommand.PersonName, 1598 createExchangeCashPersonCommand.PersonName,
1618 createExchangeCashPersonCommand.PersonAccount, 1599 createExchangeCashPersonCommand.PersonAccount,
1619 createExchangeCashPersonCommand.ExchangedSuMoney, 1600 createExchangeCashPersonCommand.ExchangedSuMoney,
1620 - err.Error(), 1601 + "内部业务错误" + err.Error(),
1621 } 1602 }
1622 failureDataList = append(failureDataList, row) 1603 failureDataList = append(failureDataList, row)
1623 continue 1604 continue
1624 } 1605 }
1625 - if activityUpdated == nil { 1606 + if task == nil {
1626 row := []interface{}{ 1607 row := []interface{}{
1627 createExchangeCashPersonCommand.PersonName, 1608 createExchangeCashPersonCommand.PersonName,
1628 createExchangeCashPersonCommand.PersonAccount, 1609 createExchangeCashPersonCommand.PersonAccount,
1629 createExchangeCashPersonCommand.ExchangedSuMoney, 1610 createExchangeCashPersonCommand.ExchangedSuMoney,
1630 - "兑换现金活动保存失败", 1611 + "操作素币失败",
1631 } 1612 }
1632 failureDataList = append(failureDataList, row) 1613 failureDataList = append(failureDataList, row)
1633 continue 1614 continue
1634 } 1615 }
1635 1616
1636 - // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励  
1637 -  
1638 - // 个人素币操作命令  
1639 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{  
1640 - Uid: employeeFound.EmployeeInfo.Uid,  
1641 - Operator: createExchangeCashPersonCommand.Operator,  
1642 - SuMoney: suMoneyDecrement,  
1643 - OperationType: 41,  
1644 - OperationDescription: activityFound.ExchangeActivityName + "调整", 1617 + // 更新兑换活动
  1618 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
  1619 + ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
  1620 + ExchangeActivityName: activityFound.ExchangeActivityName,
  1621 + ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
  1622 + ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
  1623 + Deadline: activityFound.Deadline,
  1624 + CountDown: activityFound.CountDown,
  1625 + ExchangeRate: activityFound.Rate,
1645 } 1626 }
1646 -  
1647 - // 操作个人素币,生成素币流水记录  
1648 - task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1627 + if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
  1628 + row := []interface{}{
  1629 + createExchangeCashPersonCommand.PersonName,
  1630 + createExchangeCashPersonCommand.PersonAccount,
  1631 + createExchangeCashPersonCommand.ExchangedSuMoney,
  1632 + err.Error(),
  1633 + }
  1634 + failureDataList = append(failureDataList, row)
  1635 + continue
  1636 + }
  1637 + activityUpdated, err := exchangeCashActivityRepository.Save(activityFound)
1649 if err != nil { 1638 if err != nil {
1650 row := []interface{}{ 1639 row := []interface{}{
1651 createExchangeCashPersonCommand.PersonName, 1640 createExchangeCashPersonCommand.PersonName,
1652 createExchangeCashPersonCommand.PersonAccount, 1641 createExchangeCashPersonCommand.PersonAccount,
1653 createExchangeCashPersonCommand.ExchangedSuMoney, 1642 createExchangeCashPersonCommand.ExchangedSuMoney,
1654 - "操作个人素币失败", 1643 + err.Error(),
1655 } 1644 }
1656 failureDataList = append(failureDataList, row) 1645 failureDataList = append(failureDataList, row)
1657 continue 1646 continue
1658 } 1647 }
1659 - if task == nil { 1648 + if activityUpdated == nil {
1660 row := []interface{}{ 1649 row := []interface{}{
1661 createExchangeCashPersonCommand.PersonName, 1650 createExchangeCashPersonCommand.PersonName,
1662 createExchangeCashPersonCommand.PersonAccount, 1651 createExchangeCashPersonCommand.PersonAccount,
1663 createExchangeCashPersonCommand.ExchangedSuMoney, 1652 createExchangeCashPersonCommand.ExchangedSuMoney,
1664 - "操作个人素币失败", 1653 + "更新兑换活动失败",
1665 } 1654 }
1666 failureDataList = append(failureDataList, row) 1655 failureDataList = append(failureDataList, row)
1667 continue 1656 continue
1668 } 1657 }
1669 1658
1670 // 判断是否超过平台未兑换现金 1659 // 判断是否超过平台未兑换现金
1671 - if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {  
1672 - if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash { 1660 + if createExchangeCashPersonCommand.ExchangedSuMoney * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
1673 row := []interface{}{ 1661 row := []interface{}{
1674 createExchangeCashPersonCommand.PersonName, 1662 createExchangeCashPersonCommand.PersonName,
1675 createExchangeCashPersonCommand.PersonAccount, 1663 createExchangeCashPersonCommand.PersonAccount,
1676 createExchangeCashPersonCommand.ExchangedSuMoney, 1664 createExchangeCashPersonCommand.ExchangedSuMoney,
1677 - "已超过现金池未兑换现金", 1665 + "已超过投入现金池的未兑换现金",
1678 } 1666 }
1679 failureDataList = append(failureDataList, row) 1667 failureDataList = append(failureDataList, row)
1680 continue 1668 continue
1681 } 1669 }
1682 - }  
1683 1670
1684 // 获取平台素币兑换情况 1671 // 获取平台素币兑换情况
1685 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId) 1672 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityFound.CompanyId)
@@ -1698,36 +1685,32 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1698,36 +1685,32 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1698 createExchangeCashPersonCommand.PersonName, 1685 createExchangeCashPersonCommand.PersonName,
1699 createExchangeCashPersonCommand.PersonAccount, 1686 createExchangeCashPersonCommand.PersonAccount,
1700 createExchangeCashPersonCommand.ExchangedSuMoney, 1687 createExchangeCashPersonCommand.ExchangedSuMoney,
1701 - "无效的公司", 1688 + "获取公司素币兑换情况失败",
1702 } 1689 }
1703 failureDataList = append(failureDataList, row) 1690 failureDataList = append(failureDataList, row)
1704 continue 1691 continue
1705 } 1692 }
1706 - systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)  
1707 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 1693 + systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
  1694 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
1708 1695
1709 - // 计算平均兑换汇率 1696 + // 更新现金池
1710 var newRate float64 1697 var newRate float64
1711 if systemExchangedSuMoney == 0 { 1698 if systemExchangedSuMoney == 0 {
1712 newRate = 0 1699 newRate = 0
1713 } else { 1700 } else {
1714 - newRate = (cashPoolFoundExchangedCash - cashDecrement) / systemExchangedSuMoney 1701 + newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
1715 } 1702 }
1716 -  
1717 - // 更新现金池命令  
1718 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1703 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1719 - CashPoolId: cashPoolsFound[0].CashPoolId,  
1720 - Cash: cashPoolsFound[0].Cash,  
1721 - ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,  
1722 - UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement, 1704 + CashPoolId: cashPoolFound.CashPoolId,
  1705 + Cash: cashPoolFound.Cash,
  1706 + ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
  1707 + UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
1723 ExchangedSuMoney: systemExchangedSuMoney, 1708 ExchangedSuMoney: systemExchangedSuMoney,
1724 UnExchangeSuMoney: systemUnExchangeSuMoney, 1709 UnExchangeSuMoney: systemUnExchangeSuMoney,
1725 Rate: newRate, 1710 Rate: newRate,
1726 - LastRate: cashPoolsFound[0].LastRate, 1711 + LastRate: cashPoolFound.LastRate,
1727 } 1712 }
1728 -  
1729 - // 更新现金池  
1730 - if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1713 + if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1731 row := []interface{}{ 1714 row := []interface{}{
1732 createExchangeCashPersonCommand.PersonName, 1715 createExchangeCashPersonCommand.PersonName,
1733 createExchangeCashPersonCommand.PersonAccount, 1716 createExchangeCashPersonCommand.PersonAccount,
@@ -1737,15 +1720,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1737,15 +1720,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1737 failureDataList = append(failureDataList, row) 1720 failureDataList = append(failureDataList, row)
1738 continue 1721 continue
1739 } 1722 }
1740 -  
1741 - // 保存现金池更新  
1742 - cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0]) 1723 + cashPoolUpdated, err := cashPoolRepository.Save(cashPoolFound)
1743 if err != nil { 1724 if err != nil {
1744 row := []interface{}{ 1725 row := []interface{}{
1745 createExchangeCashPersonCommand.PersonName, 1726 createExchangeCashPersonCommand.PersonName,
1746 createExchangeCashPersonCommand.PersonAccount, 1727 createExchangeCashPersonCommand.PersonAccount,
1747 createExchangeCashPersonCommand.ExchangedSuMoney, 1728 createExchangeCashPersonCommand.ExchangedSuMoney,
1748 - "内部业务错误" + err.Error(), 1729 + err.Error(),
1749 } 1730 }
1750 failureDataList = append(failureDataList, row) 1731 failureDataList = append(failureDataList, row)
1751 continue 1732 continue
@@ -1755,93 +1736,86 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1755,93 +1736,86 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1755 createExchangeCashPersonCommand.PersonName, 1736 createExchangeCashPersonCommand.PersonName,
1756 createExchangeCashPersonCommand.PersonAccount, 1737 createExchangeCashPersonCommand.PersonAccount,
1757 createExchangeCashPersonCommand.ExchangedSuMoney, 1738 createExchangeCashPersonCommand.ExchangedSuMoney,
1758 - "内部业务错误" + err.Error(), 1739 + err.Error(),
1759 } 1740 }
1760 failureDataList = append(failureDataList, row) 1741 failureDataList = append(failureDataList, row)
1761 continue 1742 continue
1762 } 1743 }
1763 - } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币  
1764 - // 素币增量  
1765 - suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney 1744 + } else { // 当前人员存在兑换素币清单中
  1745 + personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币
  1746 + personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
  1747 + if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
  1748 + // 素币减量
  1749 + suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
1766 1750
1767 - // 现金增量  
1768 - cashIncrement := suMoneyIncrement * activityFound.Rate 1751 + // 现金减量
  1752 + cashDecrement := suMoneyDecrement * activityFound.Rate
1769 1753
1770 - // 判断该员工兑换的素币是否超过本人持有的素币  
1771 - if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) { 1754 + // 更新兑换素币清单
  1755 + updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
  1756 + ListId: personFound.ListId,
  1757 + ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
  1758 + ExchangedCash: personFoundExchangedCash - cashDecrement,
  1759 + Operator: createExchangeCashPersonCommand.Operator,
  1760 + }
  1761 + if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
1772 row := []interface{}{ 1762 row := []interface{}{
1773 createExchangeCashPersonCommand.PersonName, 1763 createExchangeCashPersonCommand.PersonName,
1774 createExchangeCashPersonCommand.PersonAccount, 1764 createExchangeCashPersonCommand.PersonAccount,
1775 createExchangeCashPersonCommand.ExchangedSuMoney, 1765 createExchangeCashPersonCommand.ExchangedSuMoney,
1776 - "当前兑换素币超过本人持有的素币值", 1766 + err.Error(),
1777 } 1767 }
1778 failureDataList = append(failureDataList, row) 1768 failureDataList = append(failureDataList, row)
1779 continue 1769 continue
1780 } 1770 }
1781 -  
1782 - // 更新兑换素币清单命令  
1783 - updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{  
1784 - ListId: peopleFound[0].ListId,  
1785 - ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,  
1786 - ExchangedCash: (personFoundExchangedSuMoney + suMoneyIncrement) * activityFound.Rate,  
1787 - Operator: createExchangeCashPersonCommand.Operator,  
1788 - }  
1789 -  
1790 - // 更新兑换素币清单  
1791 - if err := peopleFound[0].Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1771 + exchangeCashPersonListUpdated, err := exchangeCashPersonListRepository.Save(personFound)
  1772 + if err != nil {
1792 row := []interface{}{ 1773 row := []interface{}{
1793 createExchangeCashPersonCommand.PersonName, 1774 createExchangeCashPersonCommand.PersonName,
1794 createExchangeCashPersonCommand.PersonAccount, 1775 createExchangeCashPersonCommand.PersonAccount,
1795 createExchangeCashPersonCommand.ExchangedSuMoney, 1776 createExchangeCashPersonCommand.ExchangedSuMoney,
1796 - "内部业务错误" + err.Error(), 1777 + err.Error(),
1797 } 1778 }
1798 failureDataList = append(failureDataList, row) 1779 failureDataList = append(failureDataList, row)
1799 continue 1780 continue
1800 } 1781 }
1801 -  
1802 - // 保存兑换素币清单更新  
1803 - _, err := exchangeCashPersonListRepository.Save(peopleFound[0])  
1804 - if err != nil { 1782 + if exchangeCashPersonListUpdated == nil {
1805 row := []interface{}{ 1783 row := []interface{}{
1806 createExchangeCashPersonCommand.PersonName, 1784 createExchangeCashPersonCommand.PersonName,
1807 createExchangeCashPersonCommand.PersonAccount, 1785 createExchangeCashPersonCommand.PersonAccount,
1808 createExchangeCashPersonCommand.ExchangedSuMoney, 1786 createExchangeCashPersonCommand.ExchangedSuMoney,
1809 - "内部业务错误" + err.Error(), 1787 + "保存到兑换素币清单失败",
1810 } 1788 }
1811 failureDataList = append(failureDataList, row) 1789 failureDataList = append(failureDataList, row)
1812 continue 1790 continue
1813 } 1791 }
1814 1792
1815 - // 更新素币兑换活动命令 1793 + // 更新素币兑换活动
1816 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1794 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1817 - ExchangeCashActivityId: peopleFound[0].ExchangeCashActivityId,  
1818 - ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,  
1819 - ExchangedCash: activityFoundExchangedCash + cashIncrement, 1795 + ExchangeCashActivityId: personFound.ExchangeCashActivityId,
  1796 + ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
  1797 + ExchangedCash: activityFoundExchangedCash - cashDecrement,
1820 Deadline: activityFound.Deadline, 1798 Deadline: activityFound.Deadline,
1821 CountDown: activityFound.CountDown, 1799 CountDown: activityFound.CountDown,
1822 ExchangeRate: activityFound.Rate, 1800 ExchangeRate: activityFound.Rate,
1823 } 1801 }
1824 -  
1825 - // 更新兑换活动  
1826 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1802 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1827 row := []interface{}{ 1803 row := []interface{}{
1828 createExchangeCashPersonCommand.PersonName, 1804 createExchangeCashPersonCommand.PersonName,
1829 createExchangeCashPersonCommand.PersonAccount, 1805 createExchangeCashPersonCommand.PersonAccount,
1830 createExchangeCashPersonCommand.ExchangedSuMoney, 1806 createExchangeCashPersonCommand.ExchangedSuMoney,
1831 - "内部业务错误" + err.Error(), 1807 + err.Error(),
1832 } 1808 }
1833 failureDataList = append(failureDataList, row) 1809 failureDataList = append(failureDataList, row)
1834 continue 1810 continue
1835 } 1811 }
1836 -  
1837 - // 保存兑换现金活动更新  
1838 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound) 1812 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound)
1839 if err != nil { 1813 if err != nil {
1840 row := []interface{}{ 1814 row := []interface{}{
1841 createExchangeCashPersonCommand.PersonName, 1815 createExchangeCashPersonCommand.PersonName,
1842 createExchangeCashPersonCommand.PersonAccount, 1816 createExchangeCashPersonCommand.PersonAccount,
1843 createExchangeCashPersonCommand.ExchangedSuMoney, 1817 createExchangeCashPersonCommand.ExchangedSuMoney,
1844 - "内部业务错误" + err.Error(), 1818 + err.Error(),
1845 } 1819 }
1846 failureDataList = append(failureDataList, row) 1820 failureDataList = append(failureDataList, row)
1847 continue 1821 continue
@@ -1851,31 +1825,27 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1851,31 +1825,27 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1851 createExchangeCashPersonCommand.PersonName, 1825 createExchangeCashPersonCommand.PersonName,
1852 createExchangeCashPersonCommand.PersonAccount, 1826 createExchangeCashPersonCommand.PersonAccount,
1853 createExchangeCashPersonCommand.ExchangedSuMoney, 1827 createExchangeCashPersonCommand.ExchangedSuMoney,
1854 - "内部业务错误", 1828 + "兑换现金活动保存失败",
1855 } 1829 }
1856 failureDataList = append(failureDataList, row) 1830 failureDataList = append(failureDataList, row)
1857 continue 1831 continue
1858 } 1832 }
1859 1833
1860 - // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励  
1861 -  
1862 - // 操作素币命令 1834 + // 操作个人素币,生成素币流水记录
1863 operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 1835 operationSuMoneyCommand := &command.OperationSuMoneyCommand{
1864 Uid: employeeFound.EmployeeInfo.Uid, 1836 Uid: employeeFound.EmployeeInfo.Uid,
1865 Operator: createExchangeCashPersonCommand.Operator, 1837 Operator: createExchangeCashPersonCommand.Operator,
1866 - SuMoney: suMoneyIncrement,  
1867 - OperationType: 4, 1838 + SuMoney: suMoneyDecrement,
  1839 + OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
1868 OperationDescription: activityFound.ExchangeActivityName + "调整", 1840 OperationDescription: activityFound.ExchangeActivityName + "调整",
1869 } 1841 }
1870 -  
1871 - // 操作素币,生成素币流水  
1872 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1842 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1873 if err != nil { 1843 if err != nil {
1874 row := []interface{}{ 1844 row := []interface{}{
1875 createExchangeCashPersonCommand.PersonName, 1845 createExchangeCashPersonCommand.PersonName,
1876 createExchangeCashPersonCommand.PersonAccount, 1846 createExchangeCashPersonCommand.PersonAccount,
1877 createExchangeCashPersonCommand.ExchangedSuMoney, 1847 createExchangeCashPersonCommand.ExchangedSuMoney,
1878 - "内部业务错误" + err.Error(), 1848 + err.Error(),
1879 } 1849 }
1880 failureDataList = append(failureDataList, row) 1850 failureDataList = append(failureDataList, row)
1881 continue 1851 continue
@@ -1885,33 +1855,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1885,33 +1855,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1885 createExchangeCashPersonCommand.PersonName, 1855 createExchangeCashPersonCommand.PersonName,
1886 createExchangeCashPersonCommand.PersonAccount, 1856 createExchangeCashPersonCommand.PersonAccount,
1887 createExchangeCashPersonCommand.ExchangedSuMoney, 1857 createExchangeCashPersonCommand.ExchangedSuMoney,
1888 - "内部业务错误",  
1889 - }  
1890 - failureDataList = append(failureDataList, row)  
1891 - continue  
1892 - }  
1893 -  
1894 - //// 判断是否超过平台未兑换现金  
1895 - //if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {  
1896 - // if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {  
1897 - // row := []interface{}{  
1898 - // createExchangeCashPersonCommand.PersonName,  
1899 - // createExchangeCashPersonCommand.PersonAccount,  
1900 - // createExchangeCashPersonCommand.ExchangedSuMoney,  
1901 - // "已超过现金池未兑换现金",  
1902 - // }  
1903 - // failureDataList = append(failureDataList, row)  
1904 - // continue  
1905 - // }  
1906 - //}  
1907 -  
1908 - // 判断是否超过平台未兑换现金  
1909 - if createExchangeCashPersonCommand.ExchangedSuMoney * activityUpdated.Rate > cashPoolFoundUnExchangeCash {  
1910 - row := []interface{}{  
1911 - createExchangeCashPersonCommand.PersonName,  
1912 - createExchangeCashPersonCommand.PersonAccount,  
1913 - createExchangeCashPersonCommand.ExchangedSuMoney,  
1914 - "已超过现金池未兑换现金", 1858 + "操作个人素币失败",
1915 } 1859 }
1916 failureDataList = append(failureDataList, row) 1860 failureDataList = append(failureDataList, row)
1917 continue 1861 continue
@@ -1924,7 +1868,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1924,7 +1868,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1924 createExchangeCashPersonCommand.PersonName, 1868 createExchangeCashPersonCommand.PersonName,
1925 createExchangeCashPersonCommand.PersonAccount, 1869 createExchangeCashPersonCommand.PersonAccount,
1926 createExchangeCashPersonCommand.ExchangedSuMoney, 1870 createExchangeCashPersonCommand.ExchangedSuMoney,
1927 - "内部业务错误" + err.Error(), 1871 + err.Error(),
1928 } 1872 }
1929 failureDataList = append(failureDataList, row) 1873 failureDataList = append(failureDataList, row)
1930 continue 1874 continue
@@ -1934,54 +1878,48 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1934,54 +1878,48 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1934 createExchangeCashPersonCommand.PersonName, 1878 createExchangeCashPersonCommand.PersonName,
1935 createExchangeCashPersonCommand.PersonAccount, 1879 createExchangeCashPersonCommand.PersonAccount,
1936 createExchangeCashPersonCommand.ExchangedSuMoney, 1880 createExchangeCashPersonCommand.ExchangedSuMoney,
1937 - "无效的公司员工", 1881 + "获取公司素币兑换情况失败",
1938 } 1882 }
1939 failureDataList = append(failureDataList, row) 1883 failureDataList = append(failureDataList, row)
1940 continue 1884 continue
1941 } 1885 }
1942 - systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)  
1943 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 1886 + systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
  1887 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
1944 1888
1945 - // 计算平均兑换汇率 1889 + // 更新现金池
1946 var newRate float64 1890 var newRate float64
1947 if systemExchangedSuMoney == 0 { 1891 if systemExchangedSuMoney == 0 {
1948 newRate = 0 1892 newRate = 0
1949 } else { 1893 } else {
1950 - newRate = (cashPoolFoundExchangedCash + cashIncrement) / systemExchangedSuMoney 1894 + newRate = (cashPoolFoundExchangedCash - cashDecrement) / systemExchangedSuMoney
1951 } 1895 }
1952 -  
1953 - // 更新现金池命令  
1954 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1896 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1955 - CashPoolId: cashPoolsFound[0].CashPoolId,  
1956 - Cash: cashPoolsFound[0].Cash,  
1957 - ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,  
1958 - UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement, 1897 + CashPoolId: cashPoolFound.CashPoolId,
  1898 + Cash: cashPoolFound.Cash,
  1899 + ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
  1900 + UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
1959 ExchangedSuMoney: systemExchangedSuMoney, 1901 ExchangedSuMoney: systemExchangedSuMoney,
1960 UnExchangeSuMoney: systemUnExchangeSuMoney, 1902 UnExchangeSuMoney: systemUnExchangeSuMoney,
1961 Rate: newRate, 1903 Rate: newRate,
1962 - LastRate: cashPoolsFound[0].LastRate, 1904 + LastRate: cashPoolFound.LastRate,
1963 } 1905 }
1964 -  
1965 - // 更新现金池  
1966 - if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1906 + if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1967 row := []interface{}{ 1907 row := []interface{}{
1968 createExchangeCashPersonCommand.PersonName, 1908 createExchangeCashPersonCommand.PersonName,
1969 createExchangeCashPersonCommand.PersonAccount, 1909 createExchangeCashPersonCommand.PersonAccount,
1970 createExchangeCashPersonCommand.ExchangedSuMoney, 1910 createExchangeCashPersonCommand.ExchangedSuMoney,
1971 - "内部业务错误" + err.Error(), 1911 + err.Error(),
1972 } 1912 }
1973 failureDataList = append(failureDataList, row) 1913 failureDataList = append(failureDataList, row)
1974 continue 1914 continue
1975 } 1915 }
1976 -  
1977 - // 保存现金池更新  
1978 - cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0]) 1916 + cashPoolUpdated, err := cashPoolRepository.Save(cashPoolFound)
1979 if err != nil { 1917 if err != nil {
1980 row := []interface{}{ 1918 row := []interface{}{
1981 createExchangeCashPersonCommand.PersonName, 1919 createExchangeCashPersonCommand.PersonName,
1982 createExchangeCashPersonCommand.PersonAccount, 1920 createExchangeCashPersonCommand.PersonAccount,
1983 createExchangeCashPersonCommand.ExchangedSuMoney, 1921 createExchangeCashPersonCommand.ExchangedSuMoney,
1984 - "内务业务错误" + err.Error(), 1922 + err.Error(),
1985 } 1923 }
1986 failureDataList = append(failureDataList, row) 1924 failureDataList = append(failureDataList, row)
1987 continue 1925 continue
@@ -1991,15 +1929,20 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1991,15 +1929,20 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1991 createExchangeCashPersonCommand.PersonName, 1929 createExchangeCashPersonCommand.PersonName,
1992 createExchangeCashPersonCommand.PersonAccount, 1930 createExchangeCashPersonCommand.PersonAccount,
1993 createExchangeCashPersonCommand.ExchangedSuMoney, 1931 createExchangeCashPersonCommand.ExchangedSuMoney,
1994 - "内部业务错误" + err.Error(), 1932 + "更新现金池失败",
1995 } 1933 }
1996 failureDataList = append(failureDataList, row) 1934 failureDataList = append(failureDataList, row)
1997 continue 1935 continue
1998 } 1936 }
1999 - }  
2000 - } else if len(peopleFound) == 0 { // 导入兑换素币清单员工不存在兑换素币清单中,新增兑换素币清单 1937 + } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
  1938 + // 素币增量
  1939 + suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
  1940 +
  1941 + // 现金增量
  1942 + cashIncrement := suMoneyIncrement * activityFound.Rate
  1943 +
2001 // 判断该员工兑换的素币是否超过本人持有的素币 1944 // 判断该员工兑换的素币是否超过本人持有的素币
2002 - if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) { 1945 + if suMoneyIncrement > employeeFoundSuMoney {
2003 row := []interface{}{ 1946 row := []interface{}{
2004 createExchangeCashPersonCommand.PersonName, 1947 createExchangeCashPersonCommand.PersonName,
2005 createExchangeCashPersonCommand.PersonAccount, 1948 createExchangeCashPersonCommand.PersonAccount,
@@ -2010,97 +1953,71 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2010,97 +1953,71 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2010 continue 1953 continue
2011 } 1954 }
2012 1955
2013 - // 新增兑换素币清单命令  
2014 - newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)  
2015 - newPerson := &domain.ExchangeCashPersonList{  
2016 - EmployeeInfo: &domain.EmployeeInfo{  
2017 - Uid: employeeFound.EmployeeInfo.Uid,  
2018 - EmployeeName: employeeFound.EmployeeInfo.EmployeeName,  
2019 - EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,  
2020 - },  
2021 - ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,  
2022 - ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,  
2023 - ExchangedCash: newPersonExchangedCash, 1956 + // 更新兑换素币清单
  1957 + updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
  1958 + ListId: personFound.ListId,
  1959 + ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
  1960 + ExchangedCash: personFoundExchangedCash + cashIncrement,
  1961 + Operator: createExchangeCashPersonCommand.Operator,
2024 } 1962 }
2025 -  
2026 - // 保存兑换素币清单  
2027 - personSaved, err := exchangeCashPersonListRepository.Save(newPerson)  
2028 - if err != nil { 1963 + if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
2029 row := []interface{}{ 1964 row := []interface{}{
2030 createExchangeCashPersonCommand.PersonName, 1965 createExchangeCashPersonCommand.PersonName,
2031 createExchangeCashPersonCommand.PersonAccount, 1966 createExchangeCashPersonCommand.PersonAccount,
2032 createExchangeCashPersonCommand.ExchangedSuMoney, 1967 createExchangeCashPersonCommand.ExchangedSuMoney,
2033 - "内务业务错误" + err.Error(), 1968 + err.Error(),
2034 } 1969 }
2035 failureDataList = append(failureDataList, row) 1970 failureDataList = append(failureDataList, row)
2036 continue 1971 continue
2037 } 1972 }
2038 -  
2039 - // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励  
2040 -  
2041 - // 操作素币命令  
2042 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{  
2043 - Uid: employeeFound.EmployeeInfo.Uid,  
2044 - Operator: createExchangeCashPersonCommand.Operator,  
2045 - SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,  
2046 - OperationType: 4,  
2047 - OperationDescription: "参与" + activityFound.ExchangeActivityName,  
2048 - }  
2049 -  
2050 - // 操作素币,生成素币流水  
2051 - task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1973 + exchangeCashPersonListUpdated, err := exchangeCashPersonListRepository.Save(personFound)
2052 if err != nil { 1974 if err != nil {
2053 row := []interface{}{ 1975 row := []interface{}{
2054 createExchangeCashPersonCommand.PersonName, 1976 createExchangeCashPersonCommand.PersonName,
2055 createExchangeCashPersonCommand.PersonAccount, 1977 createExchangeCashPersonCommand.PersonAccount,
2056 createExchangeCashPersonCommand.ExchangedSuMoney, 1978 createExchangeCashPersonCommand.ExchangedSuMoney,
2057 - "内部业务错误" + err.Error(), 1979 + err.Error(),
2058 } 1980 }
2059 failureDataList = append(failureDataList, row) 1981 failureDataList = append(failureDataList, row)
2060 continue 1982 continue
2061 } 1983 }
2062 - if task == nil { 1984 + if exchangeCashPersonListUpdated == nil {
2063 row := []interface{}{ 1985 row := []interface{}{
2064 createExchangeCashPersonCommand.PersonName, 1986 createExchangeCashPersonCommand.PersonName,
2065 createExchangeCashPersonCommand.PersonAccount, 1987 createExchangeCashPersonCommand.PersonAccount,
2066 createExchangeCashPersonCommand.ExchangedSuMoney, 1988 createExchangeCashPersonCommand.ExchangedSuMoney,
2067 - "内部业务错误", 1989 + "保存到兑换现金活动失败",
2068 } 1990 }
2069 failureDataList = append(failureDataList, row) 1991 failureDataList = append(failureDataList, row)
2070 continue 1992 continue
2071 } 1993 }
2072 1994
2073 - // 更新兑换活动命令 1995 + // 更新兑换活动
2074 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1996 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
2075 - ExchangeCashActivityId: personSaved.ExchangeCashActivityId,  
2076 - ExchangeActivityName: activityFound.ExchangeActivityName,  
2077 - ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,  
2078 - ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate, 1997 + ExchangeCashActivityId: personFound.ExchangeCashActivityId,
  1998 + ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
  1999 + ExchangedCash: activityFoundExchangedCash + cashIncrement,
2079 Deadline: activityFound.Deadline, 2000 Deadline: activityFound.Deadline,
2080 CountDown: activityFound.CountDown, 2001 CountDown: activityFound.CountDown,
2081 ExchangeRate: activityFound.Rate, 2002 ExchangeRate: activityFound.Rate,
2082 } 2003 }
2083 -  
2084 - // 更新兑换活动  
2085 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 2004 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
2086 row := []interface{}{ 2005 row := []interface{}{
2087 createExchangeCashPersonCommand.PersonName, 2006 createExchangeCashPersonCommand.PersonName,
2088 createExchangeCashPersonCommand.PersonAccount, 2007 createExchangeCashPersonCommand.PersonAccount,
2089 createExchangeCashPersonCommand.ExchangedSuMoney, 2008 createExchangeCashPersonCommand.ExchangedSuMoney,
2090 - "内部业务错误" + err.Error(), 2009 + err.Error(),
2091 } 2010 }
2092 failureDataList = append(failureDataList, row) 2011 failureDataList = append(failureDataList, row)
2093 continue 2012 continue
2094 } 2013 }
2095 -  
2096 - // 保存兑换现金活动更新  
2097 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound) 2014 activityUpdated, err := exchangeCashActivityRepository.Save(activityFound)
2098 if err != nil { 2015 if err != nil {
2099 row := []interface{}{ 2016 row := []interface{}{
2100 createExchangeCashPersonCommand.PersonName, 2017 createExchangeCashPersonCommand.PersonName,
2101 createExchangeCashPersonCommand.PersonAccount, 2018 createExchangeCashPersonCommand.PersonAccount,
2102 createExchangeCashPersonCommand.ExchangedSuMoney, 2019 createExchangeCashPersonCommand.ExchangedSuMoney,
2103 - "内部业务错误" + err.Error(), 2020 + err.Error(),
2104 } 2021 }
2105 failureDataList = append(failureDataList, row) 2022 failureDataList = append(failureDataList, row)
2106 continue 2023 continue
@@ -2110,37 +2027,52 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2110,37 +2027,52 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2110 createExchangeCashPersonCommand.PersonName, 2027 createExchangeCashPersonCommand.PersonName,
2111 createExchangeCashPersonCommand.PersonAccount, 2028 createExchangeCashPersonCommand.PersonAccount,
2112 createExchangeCashPersonCommand.ExchangedSuMoney, 2029 createExchangeCashPersonCommand.ExchangedSuMoney,
2113 - "内部业务错误", 2030 + "保存到兑换现金活动失败",
2114 } 2031 }
2115 failureDataList = append(failureDataList, row) 2032 failureDataList = append(failureDataList, row)
2116 continue 2033 continue
2117 } 2034 }
2118 2035
2119 - //// 判断是否超过平台未兑换现金  
2120 - //if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {  
2121 - // if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {  
2122 - // row := []interface{}{  
2123 - // createExchangeCashPersonCommand.PersonName,  
2124 - // createExchangeCashPersonCommand.PersonAccount,  
2125 - // createExchangeCashPersonCommand.ExchangedSuMoney,  
2126 - // "已超过现金池未兑换现金",  
2127 - // }  
2128 - // failureDataList = append(failureDataList, row)  
2129 - // continue  
2130 - // }  
2131 - //} 2036 + // 操作素币,生成素币流水
  2037 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
  2038 + Uid: employeeFound.EmployeeInfo.Uid,
  2039 + Operator: createExchangeCashPersonCommand.Operator,
  2040 + SuMoney: suMoneyIncrement,
  2041 + OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
  2042 + OperationDescription: activityFound.ExchangeActivityName + "调整",
  2043 + }
  2044 + task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
  2045 + if err != nil {
  2046 + row := []interface{}{
  2047 + createExchangeCashPersonCommand.PersonName,
  2048 + createExchangeCashPersonCommand.PersonAccount,
  2049 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2050 + err.Error(),
  2051 + }
  2052 + failureDataList = append(failureDataList, row)
  2053 + continue
  2054 + }
  2055 + if task == nil {
  2056 + row := []interface{}{
  2057 + createExchangeCashPersonCommand.PersonName,
  2058 + createExchangeCashPersonCommand.PersonAccount,
  2059 + createExchangeCashPersonCommand.ExchangedSuMoney,
  2060 + "操作素币错误",
  2061 + }
  2062 + failureDataList = append(failureDataList, row)
  2063 + continue
  2064 + }
2132 2065
2133 // 判断是否超过平台未兑换现金 2066 // 判断是否超过平台未兑换现金
2134 - if createExchangeCashPersonCommand.ExchangedSuMoney * activityUpdated.Rate > cashPoolFoundUnExchangeCash { 2067 + if personFoundExchangedCash > cashPoolFoundUnExchangeCash {
2135 row := []interface{}{ 2068 row := []interface{}{
2136 createExchangeCashPersonCommand.PersonName, 2069 createExchangeCashPersonCommand.PersonName,
2137 createExchangeCashPersonCommand.PersonAccount, 2070 createExchangeCashPersonCommand.PersonAccount,
2138 createExchangeCashPersonCommand.ExchangedSuMoney, 2071 createExchangeCashPersonCommand.ExchangedSuMoney,
2139 - "已超过现金池未兑换现金", 2072 + "已超过投入现金池的未兑换现金",
2140 } 2073 }
2141 failureDataList = append(failureDataList, row) 2074 failureDataList = append(failureDataList, row)
2142 continue 2075 continue
2143 - //return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")  
2144 } 2076 }
2145 2077
2146 // 获取平台素币兑换情况 2078 // 获取平台素币兑换情况
@@ -2168,46 +2100,40 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2168,46 +2100,40 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2168 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 2100 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
2169 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 2101 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
2170 2102
2171 - // 重新计算现金池平均兑换汇率 2103 + // 更新现金池命令
2172 var newRate float64 2104 var newRate float64
2173 if systemExchangedSuMoney == 0 { 2105 if systemExchangedSuMoney == 0 {
2174 newRate = 0 2106 newRate = 0
2175 } else { 2107 } else {
2176 - newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney 2108 + newRate = (cashPoolFoundExchangedCash + cashIncrement) / systemExchangedSuMoney
2177 } 2109 }
2178 -  
2179 - // 更新现金池命令  
2180 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2110 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2181 - CashPoolId: cashPoolsFound[0].CashPoolId,  
2182 - Cash: cashPoolsFound[0].Cash,  
2183 - ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,  
2184 - UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash, 2111 + CashPoolId: cashPoolFound.CashPoolId,
  2112 + Cash: cashPoolFound.Cash,
  2113 + ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
  2114 + UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
2185 ExchangedSuMoney: systemExchangedSuMoney, 2115 ExchangedSuMoney: systemExchangedSuMoney,
2186 UnExchangeSuMoney: systemUnExchangeSuMoney, 2116 UnExchangeSuMoney: systemUnExchangeSuMoney,
2187 Rate: newRate, 2117 Rate: newRate,
2188 - LastRate: cashPoolsFound[0].LastRate, 2118 + LastRate: cashPoolFound.LastRate,
2189 } 2119 }
2190 -  
2191 - // 更新现金池  
2192 - if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 2120 + if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
2193 row := []interface{}{ 2121 row := []interface{}{
2194 createExchangeCashPersonCommand.PersonName, 2122 createExchangeCashPersonCommand.PersonName,
2195 createExchangeCashPersonCommand.PersonAccount, 2123 createExchangeCashPersonCommand.PersonAccount,
2196 createExchangeCashPersonCommand.ExchangedSuMoney, 2124 createExchangeCashPersonCommand.ExchangedSuMoney,
2197 - "内部业务错误" + err.Error(), 2125 + err.Error(),
2198 } 2126 }
2199 failureDataList = append(failureDataList, row) 2127 failureDataList = append(failureDataList, row)
2200 continue 2128 continue
2201 } 2129 }
2202 -  
2203 - // 保存现金池更新  
2204 - cashPoolUpdated, err := cashPoolRepository.Save(cashPoolsFound[0]) 2130 + cashPoolUpdated, err := cashPoolRepository.Save(cashPoolFound)
2205 if err != nil { 2131 if err != nil {
2206 row := []interface{}{ 2132 row := []interface{}{
2207 createExchangeCashPersonCommand.PersonName, 2133 createExchangeCashPersonCommand.PersonName,
2208 createExchangeCashPersonCommand.PersonAccount, 2134 createExchangeCashPersonCommand.PersonAccount,
2209 createExchangeCashPersonCommand.ExchangedSuMoney, 2135 createExchangeCashPersonCommand.ExchangedSuMoney,
2210 - "内部业务错误" + err.Error(), 2136 + err.Error(),
2211 } 2137 }
2212 failureDataList = append(failureDataList, row) 2138 failureDataList = append(failureDataList, row)
2213 continue 2139 continue
@@ -2217,21 +2143,49 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2217,21 +2143,49 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2217 createExchangeCashPersonCommand.PersonName, 2143 createExchangeCashPersonCommand.PersonName,
2218 createExchangeCashPersonCommand.PersonAccount, 2144 createExchangeCashPersonCommand.PersonAccount,
2219 createExchangeCashPersonCommand.ExchangedSuMoney, 2145 createExchangeCashPersonCommand.ExchangedSuMoney,
2220 - "内部业务错误" + err.Error(), 2146 + err.Error(),
2221 } 2147 }
2222 failureDataList = append(failureDataList, row) 2148 failureDataList = append(failureDataList, row)
2223 continue 2149 continue
2224 } 2150 }
2225 - } else { // 未知情况  
2226 - row := []interface{}{  
2227 - createExchangeCashPersonCommand.PersonName,  
2228 - createExchangeCashPersonCommand.PersonAccount,  
2229 - createExchangeCashPersonCommand.ExchangedSuMoney,  
2230 - "未知错误",  
2231 } 2151 }
2232 - failureDataList = append(failureDataList, row)  
2233 - continue  
2234 } 2152 }
  2153 + //if len(peopleFound) != 0 {
  2154 + // peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
  2155 + // // 判断该员工兑换的素币是否超过本人持有的素币
  2156 + // if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {
  2157 + // if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) {
  2158 + // row := []interface{}{
  2159 + // createExchangeCashPersonCommand.PersonName,
  2160 + // createExchangeCashPersonCommand.PersonAccount,
  2161 + // createExchangeCashPersonCommand.ExchangedSuMoney,
  2162 + // "当前兑换素币超过本人持有的素币值",
  2163 + // }
  2164 + // failureDataList = append(failureDataList, row)
  2165 + // continue
  2166 + // }
  2167 + // }
  2168 + //}
  2169 + //if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换
  2170 + // // 获取当前员工已兑换素币
  2171 + // //personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney
  2172 + //
  2173 + // // 获取当前兑换员工已兑换现金
  2174 + // //personFoundExchangedCash := peopleFound[0].ExchangedCash
  2175 + //
  2176 + //
  2177 + //} else if len(peopleFound) == 0 { // 导入兑换素币清单员工不存在兑换素币清单中,新增兑换素币清单
  2178 + //
  2179 + //} else { // 未知情况
  2180 + // row := []interface{}{
  2181 + // createExchangeCashPersonCommand.PersonName,
  2182 + // createExchangeCashPersonCommand.PersonAccount,
  2183 + // createExchangeCashPersonCommand.ExchangedSuMoney,
  2184 + // "未知错误",
  2185 + // }
  2186 + // failureDataList = append(failureDataList, row)
  2187 + // continue
  2188 + //}
2235 } 2189 }
2236 2190
2237 if len(failureDataList) == 0 { 2191 if len(failureDataList) == 0 {
@@ -47,6 +47,9 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str @@ -47,6 +47,9 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str
47 if activityId, ok := queryOptions["activityId"]; ok { 47 if activityId, ok := queryOptions["activityId"]; ok {
48 query = query.Where("exchange_cash_person_list.activity_id = ?", activityId) 48 query = query.Where("exchange_cash_person_list.activity_id = ?", activityId)
49 } 49 }
  50 + if employeeAccount, ok := queryOptions["employeeAccount"]; ok {
  51 + query = query.Where("exchange_cash_person_list.employee_account = ?", employeeAccount)
  52 + }
50 if err := query.First(); err != nil { 53 if err := query.First(); err != nil {
51 if err.Error() == "pg: no rows in result set" { 54 if err.Error() == "pg: no rows in result set" {
52 return nil, fmt.Errorf("没有此资源") 55 return nil, fmt.Errorf("没有此资源")