作者 陈志颖

refactor:优化导入提示语

@@ -1414,7 +1414,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1414,7 +1414,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1414 createExchangeCashPersonCommand.PersonName, 1414 createExchangeCashPersonCommand.PersonName,
1415 createExchangeCashPersonCommand.PersonAccount, 1415 createExchangeCashPersonCommand.PersonAccount,
1416 createExchangeCashPersonCommand.ExchangedSuMoney, 1416 createExchangeCashPersonCommand.ExchangedSuMoney,
1417 - err.Error(), 1417 + "请先创建素币兑换活动",
1418 } 1418 }
1419 failureDataList = append(failureDataList, row) 1419 failureDataList = append(failureDataList, row)
1420 continue 1420 continue
@@ -1424,7 +1424,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1424,7 +1424,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1424 createExchangeCashPersonCommand.PersonName, 1424 createExchangeCashPersonCommand.PersonName,
1425 createExchangeCashPersonCommand.PersonAccount, 1425 createExchangeCashPersonCommand.PersonAccount,
1426 createExchangeCashPersonCommand.ExchangedSuMoney, 1426 createExchangeCashPersonCommand.ExchangedSuMoney,
1427 - "当前未创建素币兑换活动", 1427 + "请先创建兑换素币活动",
1428 } 1428 }
1429 failureDataList = append(failureDataList, row) 1429 failureDataList = append(failureDataList, row)
1430 continue 1430 continue
@@ -1441,7 +1441,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1441,7 +1441,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1441 createExchangeCashPersonCommand.PersonName, 1441 createExchangeCashPersonCommand.PersonName,
1442 createExchangeCashPersonCommand.PersonAccount, 1442 createExchangeCashPersonCommand.PersonAccount,
1443 createExchangeCashPersonCommand.ExchangedSuMoney, 1443 createExchangeCashPersonCommand.ExchangedSuMoney,
1444 - err.Error(), 1444 + "当前现金池为空,请先投入现金",
1445 } 1445 }
1446 failureDataList = append(failureDataList, row) 1446 failureDataList = append(failureDataList, row)
1447 continue 1447 continue
@@ -1470,7 +1470,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1470,7 +1470,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1470 createExchangeCashPersonCommand.PersonName, 1470 createExchangeCashPersonCommand.PersonName,
1471 createExchangeCashPersonCommand.PersonAccount, 1471 createExchangeCashPersonCommand.PersonAccount,
1472 createExchangeCashPersonCommand.ExchangedSuMoney, 1472 createExchangeCashPersonCommand.ExchangedSuMoney,
1473 - err.Error(), 1473 + "无效的员工",
1474 } 1474 }
1475 failureDataList = append(failureDataList, row) 1475 failureDataList = append(failureDataList, row)
1476 continue 1476 continue
@@ -1487,54 +1487,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1487,54 +1487,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1487 } 1487 }
1488 employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值 1488 employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
1489 1489
1490 - //else {  
1491 - // employeeFoundSuMoney := employeeFound.SuMoney  
1492 - // // 判断该员工兑换的素币是否超过本人持有的素币  
1493 - // if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) {  
1494 - // row := []interface{}{  
1495 - // createExchangeCashPersonCommand.PersonName,  
1496 - // createExchangeCashPersonCommand.PersonAccount,  
1497 - // createExchangeCashPersonCommand.ExchangedSuMoney,  
1498 - // "当前兑换素币超过本人持有的素币值",  
1499 - // }  
1500 - // failureDataList = append(failureDataList, row)  
1501 - // continue  
1502 - // }  
1503 - //}  
1504 -  
1505 - //// 判断当前员工是否已经在素币兑换清单中  
1506 - //_, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{  
1507 - // "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,  
1508 - // "exchangeCashActivityId": activityFound.ActivityId,  
1509 - // "offset": 0,  
1510 - // "limit": 1,  
1511 - //})  
1512 - //if err != nil {  
1513 - // row := []interface{}{  
1514 - // createExchangeCashPersonCommand.PersonName,  
1515 - // createExchangeCashPersonCommand.PersonAccount,  
1516 - // createExchangeCashPersonCommand.ExchangedSuMoney,  
1517 - // err.Error(),  
1518 - // }  
1519 - // failureDataList = append(failureDataList, row)  
1520 - // continue  
1521 - //}  
1522 -  
1523 // 判断当前员工是否已经在素币兑换清单中 1490 // 判断当前员工是否已经在素币兑换清单中
1524 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{ 1491 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
1525 "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount, 1492 "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
1526 "activityId": activityFound.ActivityId, 1493 "activityId": activityFound.ActivityId,
1527 }) 1494 })
1528 - if err != nil {  
1529 - row := []interface{}{  
1530 - createExchangeCashPersonCommand.PersonName,  
1531 - createExchangeCashPersonCommand.PersonAccount,  
1532 - createExchangeCashPersonCommand.ExchangedSuMoney,  
1533 - err.Error(),  
1534 - }  
1535 - failureDataList = append(failureDataList, row)  
1536 - continue  
1537 - }  
1538 if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单 1495 if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单
1539 // 判断该员工兑换的素币是否超过本人持有的素币 1496 // 判断该员工兑换的素币是否超过本人持有的素币
1540 if (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) > employeeFoundSuMoney { 1497 if (createExchangeCashPersonCommand.ExchangedSuMoney - employeeFoundSuMoney) > employeeFoundSuMoney {
@@ -1542,7 +1499,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1542,7 +1499,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1542 createExchangeCashPersonCommand.PersonName, 1499 createExchangeCashPersonCommand.PersonName,
1543 createExchangeCashPersonCommand.PersonAccount, 1500 createExchangeCashPersonCommand.PersonAccount,
1544 createExchangeCashPersonCommand.ExchangedSuMoney, 1501 createExchangeCashPersonCommand.ExchangedSuMoney,
1545 - "当前兑换素币超过本人持有的素币", 1502 + "当前兑换素币超过本人持有的素币",
1546 } 1503 }
1547 failureDataList = append(failureDataList, row) 1504 failureDataList = append(failureDataList, row)
1548 continue 1505 continue
@@ -1576,7 +1533,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1576,7 +1533,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1576 createExchangeCashPersonCommand.PersonName, 1533 createExchangeCashPersonCommand.PersonName,
1577 createExchangeCashPersonCommand.PersonAccount, 1534 createExchangeCashPersonCommand.PersonAccount,
1578 createExchangeCashPersonCommand.ExchangedSuMoney, 1535 createExchangeCashPersonCommand.ExchangedSuMoney,
1579 - "保存到兑换素币清单失败", 1536 + "保存到素币兑换清单失败",
1580 } 1537 }
1581 failureDataList = append(failureDataList, row) 1538 failureDataList = append(failureDataList, row)
1582 continue 1539 continue
@@ -1596,7 +1553,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1596,7 +1553,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1596 createExchangeCashPersonCommand.PersonName, 1553 createExchangeCashPersonCommand.PersonName,
1597 createExchangeCashPersonCommand.PersonAccount, 1554 createExchangeCashPersonCommand.PersonAccount,
1598 createExchangeCashPersonCommand.ExchangedSuMoney, 1555 createExchangeCashPersonCommand.ExchangedSuMoney,
1599 - "内部业务错误" + err.Error(), 1556 + err.Error(),
1600 } 1557 }
1601 failureDataList = append(failureDataList, row) 1558 failureDataList = append(failureDataList, row)
1602 continue 1559 continue
@@ -1734,7 +1691,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1734,7 +1691,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1734 createExchangeCashPersonCommand.PersonName, 1691 createExchangeCashPersonCommand.PersonName,
1735 createExchangeCashPersonCommand.PersonAccount, 1692 createExchangeCashPersonCommand.PersonAccount,
1736 createExchangeCashPersonCommand.ExchangedSuMoney, 1693 createExchangeCashPersonCommand.ExchangedSuMoney,
1737 - err.Error(), 1694 + "更新现金池失败",
1738 } 1695 }
1739 failureDataList = append(failureDataList, row) 1696 failureDataList = append(failureDataList, row)
1740 continue 1697 continue
@@ -1745,7 +1702,6 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1745,7 +1702,6 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1745 if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币 1702 if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
1746 // 素币减量 1703 // 素币减量
1747 suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney 1704 suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
1748 -  
1749 // 现金减量 1705 // 现金减量
1750 cashDecrement := suMoneyDecrement * activityFound.Rate 1706 cashDecrement := suMoneyDecrement * activityFound.Rate
1751 1707
@@ -1782,7 +1738,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1782,7 +1738,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1782 createExchangeCashPersonCommand.PersonName, 1738 createExchangeCashPersonCommand.PersonName,
1783 createExchangeCashPersonCommand.PersonAccount, 1739 createExchangeCashPersonCommand.PersonAccount,
1784 createExchangeCashPersonCommand.ExchangedSuMoney, 1740 createExchangeCashPersonCommand.ExchangedSuMoney,
1785 - "保存到兑换素币清单失败", 1741 + "保存到素币兑换清单失败",
1786 } 1742 }
1787 failureDataList = append(failureDataList, row) 1743 failureDataList = append(failureDataList, row)
1788 continue 1744 continue
@@ -1823,7 +1779,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1823,7 +1779,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1823 createExchangeCashPersonCommand.PersonName, 1779 createExchangeCashPersonCommand.PersonName,
1824 createExchangeCashPersonCommand.PersonAccount, 1780 createExchangeCashPersonCommand.PersonAccount,
1825 createExchangeCashPersonCommand.ExchangedSuMoney, 1781 createExchangeCashPersonCommand.ExchangedSuMoney,
1826 - "兑换现金活动保存失败", 1782 + "素币兑换活动保存失败",
1827 } 1783 }
1828 failureDataList = append(failureDataList, row) 1784 failureDataList = append(failureDataList, row)
1829 continue 1785 continue
@@ -1853,7 +1809,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1853,7 +1809,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1853 createExchangeCashPersonCommand.PersonName, 1809 createExchangeCashPersonCommand.PersonName,
1854 createExchangeCashPersonCommand.PersonAccount, 1810 createExchangeCashPersonCommand.PersonAccount,
1855 createExchangeCashPersonCommand.ExchangedSuMoney, 1811 createExchangeCashPersonCommand.ExchangedSuMoney,
1856 - "操作个人素币失败", 1812 + "操作素币失败",
1857 } 1813 }
1858 failureDataList = append(failureDataList, row) 1814 failureDataList = append(failureDataList, row)
1859 continue 1815 continue
@@ -1935,7 +1891,6 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1935,7 +1891,6 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1935 } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币 1891 } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
1936 // 素币增量 1892 // 素币增量
1937 suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney 1893 suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
1938 -  
1939 // 现金增量 1894 // 现金增量
1940 cashIncrement := suMoneyIncrement * activityFound.Rate 1895 cashIncrement := suMoneyIncrement * activityFound.Rate
1941 1896
@@ -2025,7 +1980,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2025,7 +1980,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2025 createExchangeCashPersonCommand.PersonName, 1980 createExchangeCashPersonCommand.PersonName,
2026 createExchangeCashPersonCommand.PersonAccount, 1981 createExchangeCashPersonCommand.PersonAccount,
2027 createExchangeCashPersonCommand.ExchangedSuMoney, 1982 createExchangeCashPersonCommand.ExchangedSuMoney,
2028 - "保存到兑换现金活动失败", 1983 + "保存到素币兑换活动失败",
2029 } 1984 }
2030 failureDataList = append(failureDataList, row) 1985 failureDataList = append(failureDataList, row)
2031 continue 1986 continue
@@ -2080,7 +2035,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2080,7 +2035,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2080 createExchangeCashPersonCommand.PersonName, 2035 createExchangeCashPersonCommand.PersonName,
2081 createExchangeCashPersonCommand.PersonAccount, 2036 createExchangeCashPersonCommand.PersonAccount,
2082 createExchangeCashPersonCommand.ExchangedSuMoney, 2037 createExchangeCashPersonCommand.ExchangedSuMoney,
2083 - "内部业务错误" + err.Error(), 2038 + err.Error(),
2084 } 2039 }
2085 failureDataList = append(failureDataList, row) 2040 failureDataList = append(failureDataList, row)
2086 continue 2041 continue
@@ -2090,7 +2045,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2090,7 +2045,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2090 createExchangeCashPersonCommand.PersonName, 2045 createExchangeCashPersonCommand.PersonName,
2091 createExchangeCashPersonCommand.PersonAccount, 2046 createExchangeCashPersonCommand.PersonAccount,
2092 createExchangeCashPersonCommand.ExchangedSuMoney, 2047 createExchangeCashPersonCommand.ExchangedSuMoney,
2093 - "无效的公司员工", 2048 + "获取公司平台素币兑换情况失败",
2094 } 2049 }
2095 failureDataList = append(failureDataList, row) 2050 failureDataList = append(failureDataList, row)
2096 continue 2051 continue
@@ -2141,49 +2096,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2141,49 +2096,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2141 createExchangeCashPersonCommand.PersonName, 2096 createExchangeCashPersonCommand.PersonName,
2142 createExchangeCashPersonCommand.PersonAccount, 2097 createExchangeCashPersonCommand.PersonAccount,
2143 createExchangeCashPersonCommand.ExchangedSuMoney, 2098 createExchangeCashPersonCommand.ExchangedSuMoney,
2144 - err.Error(), 2099 + "更新现金池失败",
2145 } 2100 }
2146 failureDataList = append(failureDataList, row) 2101 failureDataList = append(failureDataList, row)
2147 continue 2102 continue
2148 } 2103 }
2149 } 2104 }
2150 } 2105 }
2151 - //if len(peopleFound) != 0 {  
2152 - // peopleFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney  
2153 - // // 判断该员工兑换的素币是否超过本人持有的素币  
2154 - // if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFoundExchangedSuMoney {  
2155 - // if employeeFoundSuMoney < (createExchangeCashPersonCommand.ExchangedSuMoney - peopleFoundExchangedSuMoney) {  
2156 - // row := []interface{}{  
2157 - // createExchangeCashPersonCommand.PersonName,  
2158 - // createExchangeCashPersonCommand.PersonAccount,  
2159 - // createExchangeCashPersonCommand.ExchangedSuMoney,  
2160 - // "当前兑换素币超过本人持有的素币值",  
2161 - // }  
2162 - // failureDataList = append(failureDataList, row)  
2163 - // continue  
2164 - // }  
2165 - // }  
2166 - //}  
2167 - //if len(peopleFound) > 0 { // 当前导入员工在素币兑换清单中,判断追加素币兑换或撤回素币兑换  
2168 - // // 获取当前员工已兑换素币  
2169 - // //personFoundExchangedSuMoney := peopleFound[0].ExchangedSuMoney  
2170 - //  
2171 - // // 获取当前兑换员工已兑换现金  
2172 - // //personFoundExchangedCash := peopleFound[0].ExchangedCash  
2173 - //  
2174 - //  
2175 - //} else if len(peopleFound) == 0 { // 导入兑换素币清单员工不存在兑换素币清单中,新增兑换素币清单  
2176 - //  
2177 - //} else { // 未知情况  
2178 - // row := []interface{}{  
2179 - // createExchangeCashPersonCommand.PersonName,  
2180 - // createExchangeCashPersonCommand.PersonAccount,  
2181 - // createExchangeCashPersonCommand.ExchangedSuMoney,  
2182 - // "未知错误",  
2183 - // }  
2184 - // failureDataList = append(failureDataList, row)  
2185 - // continue  
2186 - //}  
2187 } 2106 }
2188 2107
2189 if len(failureDataList) == 0 { 2108 if len(failureDataList) == 0 {
@@ -438,7 +438,7 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -438,7 +438,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
438 // 文件行数校验 438 // 文件行数校验
439 rows, _ := xlsx.GetRows("Sheet1") 439 rows, _ := xlsx.GetRows("Sheet1")
440 //fmt.Print(len(rows), "\n") 440 //fmt.Print(len(rows), "\n")
441 - if len(rows) > 302 { 441 + if len(rows) > 303 {
442 err := &application.ServiceError{ 442 err := &application.ServiceError{
443 Code: 500, 443 Code: 500,
444 Message: "导入的文件超过300行", 444 Message: "导入的文件超过300行",