Commit 52680af7 by jianan

续年佣金计算-更新续佣检核状态前先校验9

parent 97d807c4
......@@ -85,11 +85,15 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
resp.setCommonResult(new CommonResult(false, "检核日期不能为空"));
return resp;
}
try {
// 1.更新财富等信息
// 1.检核续年佣金时先判断,前面期数的佣金是否检核过
this.validateContinuePremium(paramsList);
// 2.更新财富等信息
this.processOrderAndFortune(paramsList, status, loginId, checkBatch);
// 2.更新多年期佣金
// 3.更新多年期佣金
this.updateOrderCommission(paramsList, status, loginId, checkBatch);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
......@@ -101,14 +105,57 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
return resp;
}
private void validateContinuePremium(List<ComeCommissionParams> paramsList) throws Exception {
// 提示信息
StringBuffer stringBuffer = new StringBuffer("以下来佣的往期来佣未检核: ");
List<String> commissionNos = new ArrayList<>();
for (ComeCommissionParams params: paramsList) {
if (StringUtils.isNotBlank(params.getCommissionNo())) {
commissionNos.add(params.getCommissionNo());
}
}
String str ="";
String prefix ="";
String suffix ="";
boolean flag = false;
for (String commissionNo: commissionNos) {
str = commissionNo;
if (!"1".equals(suffix)) {
prefix = str.substring(0, str.length() -1);
suffix = str.substring(str.length()-1) ;
// 前一期的来佣编号
String preCommissionNo = prefix + (Integer.valueOf(suffix) - 1);
System.out.println("看看commissionNo------"+commissionNo);
System.out.println("看看preCommissionNo------"+preCommissionNo);
AgPoOrderCommission agPoOrderCommission = orderCommissionMapper.selectByCommissionNo(preCommissionNo);
if (agPoOrderCommission != null && "1".equals(agPoOrderCommission.getCommissionStatus())) {
stringBuffer.append(commissionNo).append(" ");
flag = true;
}
}
}
if (flag) {
throw new Exception(stringBuffer.toString());
}
}
private void processOrderAndFortune(List<ComeCommissionParams> paramsList, String status, String loginId, String checkBatch) {
// 获取首年度佣金的orderId
// 获取首年度佣金的orderId, 只有首年佣金才更新order记录和fortune记录
List<Long> orderIds = new ArrayList<>();
for (ComeCommissionParams params: paramsList) {
if ("1".equals(params.getCommissionPeriod())) {
orderIds.add(params.getOrderId());
}
}
if (orderIds.size() == 0) {
return;
}
// 操作前先检查是否已关账
// 查询对应订单记录
......@@ -151,7 +198,7 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
// 获取批次号(如2020-11的字符串)
Long checkBatchId = this.getOrderCommissionCheckBatch(checkBatch, loginId);
// 更新检核状态
for (String commissionNo: commissionNos) {
AgPoOrderCommission orderCommission = new AgPoOrderCommission();
orderCommission.setCommissionNo(commissionNo);
......
......@@ -19,4 +19,6 @@ public interface AgPoOrderCommissionMapper {
int updateByPrimaryKey(AgPoOrderCommission record);
void updateBycommissionNo(AgPoOrderCommission orderCommission);
AgPoOrderCommission selectByCommissionNo(String commissionNo);
}
\ No newline at end of file
......@@ -343,4 +343,11 @@
</set>
where commission_no = #{commissionNo,jdbcType=VARCHAR}
</update>
<select id="selectByCommissionNo" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_po_order_commission
where commission_no = #{commissionNo,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
......@@ -45,10 +45,10 @@
) o
LEFT JOIN
(SELECT policy_no policyNo, commission_no, commission_year, amount, commission_status, commission_time, commission_check_id,
commission_period, rate
commission_period, rate, order_id
from ag_po_order_commission t
) orderCommission
ON o.policy_no = orderCommission.policyNo
ON o.id = orderCommission.order_id
WHERE 1=1
<if test="startDate != null ">
and date_format(commission_year, '%Y-%m') &gt;= #{startDate}
......@@ -171,10 +171,10 @@
) o
LEFT JOIN
(SELECT policy_no policyNo, commission_no, commission_year, amount, commission_status, commission_time, rate, commission_check_id,
commission_period
commission_period, order_id
from ag_po_order_commission t
) orderCommission
ON o.policy_no = orderCommission.policyNo
ON o.id = orderCommission.order_id
WHERE 1=1
<if test="startDate != null ">
and date_format(commission_year, '%Y-%m') &gt;= #{startDate}
......
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