Commit 281bd949 by kangxiaoshan

分摊金

parent 92d49812
......@@ -8,13 +8,7 @@
<component name="ChangeListManager">
<list default="true" id="fcaffbb7-50d8-4ab8-9bad-0a6fbd39f63b" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/manage.iml" beforeDir="false" afterPath="$PROJECT_DIR$/manage.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/common/controller/ContractController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/common/controller/ContractController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/common/service/ContractService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/common/service/ContractService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/common/service/impl/ContractServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/common/service/impl/ContractServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/util/ResultStatus.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/util/ResultStatus.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/spring/applicationContext.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/spring/applicationContext.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/common/service/impl/ShareIncomeServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/common/service/impl/ShareIncomeServiceImpl.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -56,7 +50,20 @@
<property name="last_opened_file_path" value="$USER_HOME$/Desktop/GmailWebEmail-master" />
<property name="settings.editor.selected.configurable" value="sshConsole" />
</component>
<component name="RunManager">
<component name="RunManager" selected="Tomcat Server.tomcat">
<configuration name="ShareIncomeServiceImpl" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="common.service.impl.ShareIncomeServiceImpl" />
<module name="manage" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="common.service.impl.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="tomcat" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat 8.5.32" ALTERNATIVE_JRE_ENABLED="false">
<option name="OPEN_IN_BROWSER_URL" value="http://localhost:9001/" />
<option name="BROWSER_ID" value="98ca6316-2f89-46d9-a9e5-fa9e2b0625b3" />
......@@ -133,6 +140,11 @@
</option>
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.ShareIncomeServiceImpl" />
</list>
</recent_temporary>
</component>
<component name="ServiceViewManager">
<option name="viewStates">
......@@ -145,6 +157,11 @@
<item name="services root" type="e789fda9:ObjectUtils$Sentinel" />
<item name="Tomcat Server" type="7427dc5b:ServiceModel$ServiceGroupNode" />
</path>
<path>
<item name="services root" type="e789fda9:ObjectUtils$Sentinel" />
<item name="Tomcat Server" type="7427dc5b:ServiceModel$ServiceGroupNode" />
<item name="Running" type="7427dc5b:ServiceModel$ServiceGroupNode" />
</path>
</expand>
<select />
</treeState>
......@@ -175,6 +192,11 @@
<workItem from="1579312948403" duration="15000" />
<workItem from="1579316780422" duration="710000" />
<workItem from="1584328339137" duration="11675000" />
<workItem from="1595052370632" duration="3121000" />
<workItem from="1595062561232" duration="1869000" />
<workItem from="1595210254869" duration="331000" />
<workItem from="1595249283758" duration="1012000" />
<workItem from="1595296992575" duration="2571000" />
</task>
<servers />
</component>
......@@ -209,125 +231,113 @@
</option>
</component>
<component name="WindowStateProjectService">
<state x="275" y="23" key="#Deployment" timestamp="1578643071273">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="275" y="23" key="#Deployment/0.0.1366.728@0.0.1366.728" timestamp="1578643071273" />
<state x="488" y="48" key="#com.intellij.ide.util.MemberChooser" timestamp="1584341994546">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="488" y="48" key="#com.intellij.ide.util.MemberChooser/0.0.1366.728@0.0.1366.728" timestamp="1584341994546" />
<state x="463" y="119" key="FileChooserDialogImpl" timestamp="1579338306513">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="463" y="119" key="FileChooserDialogImpl/0.0.1366.728@0.0.1366.728" timestamp="1579338306513" />
<state width="1111" height="456" key="GridCell.Tab.0.bottom" timestamp="1578643352267">
<state x="438" y="66" key="#xdebugger.evaluate" timestamp="1595064059991">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.0.center" timestamp="1578643352266">
<state x="438" y="66" key="#xdebugger.evaluate/0.0.1366.728@0.0.1366.728" timestamp="1595064059991" />
<state width="454" height="438" key="DebuggerActiveHint" timestamp="1595063945975">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1578643352266" />
<state width="1111" height="456" key="GridCell.Tab.0.left" timestamp="1578643352266">
<state width="454" height="438" key="DebuggerActiveHint/0.0.1366.728@0.0.1366.728" timestamp="1595063945975" />
<state width="1111" height="308" key="GridCell.Tab.0.bottom" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1578643352266" />
<state width="1111" height="456" key="GridCell.Tab.0.right" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.0.center" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.1.bottom" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.0.left" timestamp="1595299506736">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.1.bottom/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.1.center" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506736" />
<state width="1111" height="308" key="GridCell.Tab.0.right" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.1.center/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.1.left" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.bottom" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.1.left/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.1.right" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.1.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.center" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.2.bottom" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.1.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.left" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.2.bottom/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.2.center" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.1.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.right" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.2.center/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.2.left" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.2.bottom" timestamp="1595299506738">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.2.left/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.2.right" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.2.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.2.center" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.2.right/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.3.bottom" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.2.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.2.left" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.3.bottom/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.3.center" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.2.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.2.right" timestamp="1595299506737">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.3.center/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.3.left" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.2.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.3.bottom" timestamp="1595299506738">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.3.left/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.3.right" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.3.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.center" timestamp="1595299506738">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.3.right/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.4.bottom" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.3.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.left" timestamp="1595299506738">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.4.bottom/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state width="1111" height="456" key="GridCell.Tab.4.center" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.3.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.right" timestamp="1595299506738">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.4.center/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state width="1111" height="456" key="GridCell.Tab.4.left" timestamp="1578643352267">
<state width="1111" height="308" key="GridCell.Tab.3.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.6.bottom" timestamp="1595298613992">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.4.left/0.0.1366.728@0.0.1366.728" timestamp="1578643352267" />
<state width="1111" height="456" key="GridCell.Tab.4.right" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.6.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595298613992" />
<state width="1111" height="308" key="GridCell.Tab.6.center" timestamp="1595298613992">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.4.right/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state width="1111" height="456" key="GridCell.Tab.5.bottom" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.6.center/0.0.1366.728@0.0.1366.728" timestamp="1595298613992" />
<state width="1111" height="308" key="GridCell.Tab.6.left" timestamp="1595298613992">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.5.bottom/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state width="1111" height="456" key="GridCell.Tab.5.center" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.6.left/0.0.1366.728@0.0.1366.728" timestamp="1595298613992" />
<state width="1111" height="308" key="GridCell.Tab.6.right" timestamp="1595298613992">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.5.center/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state width="1111" height="456" key="GridCell.Tab.5.left" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.6.right/0.0.1366.728@0.0.1366.728" timestamp="1595298613992" />
<state width="1111" height="308" key="GridCell.Tab.7.bottom" timestamp="1595298613394">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.5.left/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state width="1111" height="456" key="GridCell.Tab.5.right" timestamp="1578643352268">
<state width="1111" height="308" key="GridCell.Tab.7.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595298613394" />
<state width="1111" height="308" key="GridCell.Tab.7.center" timestamp="1595298613394">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="456" key="GridCell.Tab.5.right/0.0.1366.728@0.0.1366.728" timestamp="1578643352268" />
<state x="184" y="6" key="SettingsEditor" timestamp="1578643304495">
<state width="1111" height="308" key="GridCell.Tab.7.center/0.0.1366.728@0.0.1366.728" timestamp="1595298613394" />
<state width="1111" height="308" key="GridCell.Tab.7.left" timestamp="1595298613394">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="184" y="6" key="SettingsEditor/0.0.1366.728@0.0.1366.728" timestamp="1578643304495" />
<state x="359" y="102" width="647" height="534" key="find.popup" timestamp="1584329859994">
<state width="1111" height="308" key="GridCell.Tab.7.left/0.0.1366.728@0.0.1366.728" timestamp="1595298613394" />
<state width="1111" height="308" key="GridCell.Tab.7.right" timestamp="1595298613394">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="359" y="102" width="647" height="534" key="find.popup/0.0.1366.728@0.0.1366.728" timestamp="1584329859994" />
<state x="346" y="49" width="672" height="678" key="search.everywhere.popup" timestamp="1578643339513">
<state width="1111" height="308" key="GridCell.Tab.7.right/0.0.1366.728@0.0.1366.728" timestamp="1595298613394" />
<state x="225" y="100" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2" timestamp="1595063525107">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="346" y="49" width="672" height="678" key="search.everywhere.popup/0.0.1366.728@0.0.1366.728" timestamp="1578643339513" />
<state x="225" y="100" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2/0.0.1366.728@0.0.1366.728" timestamp="1595063525107" />
</component>
</project>
\ No newline at end of file
package common.service.impl;
import com.amazonaws.services.dynamodbv2.xspec.B;
import common.model.*;
import common.repository.AuthRepository;
import common.repository.ContractBodyRepository;
......@@ -93,11 +94,13 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
DateTime start = new DateTime(startDate);
DateTime end = new DateTime(endDate);
long start_ = System.currentTimeMillis();
for (Contract contract : contracts) {
this.shareIncome4Contract(contract, start, end);
contract.setMyBodyName(bodiesNameMap.get(contract.getMyBodyCode()));
}
logger.info("计算分摊收入耗时", (System.currentTimeMillis() - start_) / 1000);
return contracts;
}
......@@ -125,8 +128,10 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
int contractAllDay = getDayRange(contractPart[0], contractPart[1]) + 1;//合同总天数
//处理精度
Long dayShareIncome = new BigDecimal(excludTax * 1.0 / contractAllDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();//每日分摊收入(值扩大100倍)
/*Long dayShareIncome = new BigDecimal(excludTax * 1.0 / contractAllDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();//每日分摊收入(值扩大100倍)*/
BigDecimal dayShareIncome = new BigDecimal(excludTax * 1.0 / contractAllDay);
//作废合同处理
Contract cancleContract = this.cancledShare(contract, contractAllDay, dayShareIncome, contractPart, usePart, selected);
......@@ -149,17 +154,17 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
this.afterContract(contract, contractAllDay, dayShareIncome, contractPart, usePart, selected, creatPoints);
}
private void afterContract(Contract contract, int contractAllDay, Long dayShareIncome,
private void afterContract(Contract contract, int contractAllDay, BigDecimal dayShareIncome,
DateTime[] contractPart, DateTime[] usePart, DateTime[] selected, DateTime[] creatPoints) {
int betweenMonth = Months.monthsBetween(contractPart[0], creatPoints[0]).getMonths();
//时间范围内用于计算分摊金额的天数
int daysIncom = getDayRange(usePart[0], usePart[1]) + 1;
//区间分摊总收入
contract.setIntervaIncomeShare(dayShareIncome * daysIncom);
// contract.setIntervaIncomeShare(dayShareIncome * daysIncom);
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
Long adjustmentFund = 0L;//调整金
......@@ -193,9 +198,11 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
//所选时间范围内的分摊收入(录入月1号 即creatPoints[1] 开始计算)
DateTime useStart = creatPoints[1].compareTo(selected[0]) >= 0 ? creatPoints[1] : selected[0];
daysIncom = getDayRange(useStart, usePart[1]) + 1;
contract.setIntervaIncomeShare(dayShareIncome * daysIncom);//时间范围内分摊金
/*contract.setIntervaIncomeShare(dayShareIncome * daysIncom);//时间范围内分摊金*/
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
adjustmentFund = (getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1) * dayShareIncome;
/*adjustmentFund = (getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1) * dayShareIncome;*/
adjustmentFund = shareMultiply(dayShareIncome, new BigDecimal(getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1), 0);
if (checkTwoTime(selected[0], creatPoints[1]) && checkTwoTime(creatPoints[1], selected[1])) {
//所选时间范围包含 录入月 1 号 显示统计的调整金
......@@ -209,15 +216,21 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
//最后一日分摊金计算处理
Long lastDay;
if (isLater) {
/*lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- dayShareIncome * getDayRange(creatPoints[1], contractPart[1]);*/
lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- dayShareIncome * getDayRange(creatPoints[1], contractPart[1]);
}else{
lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- dayShareIncome * getDayRange(contractPart[0], contractPart[1]);
- shareMultiply(dayShareIncome, new BigDecimal(getDayRange(creatPoints[1], contractPart[1])), 0);
} else {
/*lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- dayShareIncome * getDayRange(contractPart[0], contractPart[1]);*/
lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- shareMultiply(dayShareIncome, new BigDecimal(getDayRange(contractPart[0], contractPart[1])), 0);
}
//最后一日 或 包含最后一日 时
contract.setIntervaIncomeShare(contract.getIntervaIncomeShare() - dayShareIncome + lastDay);
contract.setIntervaIncomeShare(contract.getIntervaIncomeShare() -
dayShareIncome.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() + lastDay);
}
......@@ -225,7 +238,7 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
}
private Contract suspendShare(Contract contract, int contractAllDay, Long dayShareIncome,
private Contract suspendShare(Contract contract, int contractAllDay, BigDecimal dayShareIncome,
DateTime[] contractPart, DateTime[] usePart, DateTime[] selected) {
if (!ContractStatusEnum.SUSPEND.getKey().equals(contract.getStatus())) {
return null;
......@@ -253,8 +266,8 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
/* adjustmentFund = new BigDecimal((getDayRange(cancelDate, suspendDate) + 1)
* contract.getIncomeExcludingTax() * 1.0 / contractAllDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * -1;*/
adjustmentFund = (getDayRange(cancelDate, suspendDate) + 1) * dayShareIncome * (-1);
/*adjustmentFund = (getDayRange(cancelDate, suspendDate) + 1) * dayShareIncome * (-1);*/
adjustmentFund = shareMultiply(new BigDecimal((getDayRange(cancelDate, suspendDate) + 1) * -1), dayShareIncome, 0);
}
DateTime usedEnd = usePart[1].compareTo(cancelDate) <= 0 ? usePart[1] : cancelDate;
......@@ -262,7 +275,8 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
daysIncom = daysIncom < 0 ? 0 : daysIncom;
//区间分摊总收入
contract.setIntervaIncomeShare(dayShareIncome * daysIncom);
/*contract.setIntervaIncomeShare(dayShareIncome * daysIncom);*/
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
if (checkTwoTime(selected[0], cancelDate) && checkTwoTime(cancelDate, selected[1])) {
contract.setAdjustmentFund(adjustmentFund);
......@@ -275,7 +289,7 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
return contract;
}
private Contract cancledShare(Contract contract, int contractAllDay, Long dayShareIncome,
private Contract cancledShare(Contract contract, int contractAllDay, BigDecimal dayShareIncome,
DateTime[] contractPart, DateTime[] usePart, DateTime[] selected) {
if (!ContractStatusEnum.CANCEL.getKey().equals(contract.getStatus())) {
......@@ -294,14 +308,16 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
// 合同终止日 或 作废日
DateTime cancelDate = new DateTime(contractChange.getDs());
Long adjustmentFund = (getDayRange(contractPart[0], cancelDate) + 1) * dayShareIncome * (-1);
/*Long adjustmentFund = (getDayRange(contractPart[0], cancelDate) + 1) * dayShareIncome * (-1);*/
Long adjustmentFund = shareMultiply(new BigDecimal((getDayRange(contractPart[0], cancelDate) + 1)), dayShareIncome, 0);
DateTime usedEnd = usePart[1].compareTo(cancelDate) <= 0 ? usePart[1] : cancelDate;
int daysIncom = Days.daysBetween(usePart[0], usedEnd).getDays() + 1;
daysIncom = daysIncom < 0 ? 0 : daysIncom;
//区间分摊总收入
contract.setIntervaIncomeShare(dayShareIncome * daysIncom);
/*contract.setIntervaIncomeShare(dayShareIncome * daysIncom);*/
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
boolean fullRange = getDayRange(selected[0], selected[1])
>= Days.daysBetween(contractPart[0], cancelDate).getDays() ? true : false;
......@@ -318,6 +334,10 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
return contract;
}
private Long shareMultiply(BigDecimal one, BigDecimal two, int scale) {
return one.multiply(two).setScale(scale, BigDecimal.ROUND_HALF_UP).longValue();
}
@Override
public boolean checkLateContract(DateTime dateTime, DateTime creatTime) {
......@@ -543,13 +563,18 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
public static void main(String[] args) {
Long aa = new BigDecimal(1000 * 100 / 1.06).setScale(2, BigDecimal.ROUND_HALF_UP).longValue();
/* Long aa = new BigDecimal(1000 * 100 / 1.06).setScale(2, BigDecimal.ROUND_HALF_UP).longValue();
Long bb = new BigDecimal(1000 / 1.06)
.setScale(2, BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(100L)).longValue();
System.out.println(aa);
System.out.println(bb);
System.out.println(bb);*/
//252.3890909090909
System.out.println(new BigDecimal(38867.92 * 1.0 / 154).doubleValue());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment