Commit c1c50113 by hongzhong

Merge remote-tracking branch 'origin/dev_20210330' into dev_20210330

parents dc6ef209 45111649
......@@ -6,7 +6,7 @@ import com.yd.api.order.vo.SurrenderFortuneResponseVO;
import com.yd.dal.entity.customer.AclCustomerFortune;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List;
/**
......@@ -50,7 +50,7 @@ public interface AgmsFortuneService {
SurrenderFortuneResponseVO surrenderFortune(SurrenderFortuneRequestVO requestVO);
public void canPaymentUpDate(String paymentStatus, Long payoutBatchId , Long loginId, List<AclCustomerFortune> customerFortunes);
public void canPaymentUpDate(Date predictMonthPeriod, String paymentStatus, Long payoutBatchId , Long loginId, List<AclCustomerFortune> customerFortunes);
/**
* AGMS -- 导出财富文档
......
......@@ -130,13 +130,14 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
String payoutBatch = requestVO.getPayoutBatch();
//通过payoutBatch查询此批次是否再库中,在库中直接获取id,不在进行保存,获取id
Long payoutBatchId = findPayoutBatchIdByPayoutBatch(payoutBatch, loginId);
Date predictMonthPeriod = CommonUtil.stringParseDate(payoutBatch, "yyyy-MM");//预计发佣年月(YYYY-MM)
if (("2").equals(paymentStatus)){
if (("2").equals(paymentStatus)) {
//如paymentStatus = 2(可发放),只需统计Fortune对应Customer最后一笔未支付的Withdraw,重新计算,如没有Withdraw生成一条新的Withdraw记录
canPaymentUpDate(paymentStatus,payoutBatchId,loginId,customerFortunes);
}else {
canPaymentUpDate(predictMonthPeriod, paymentStatus, payoutBatchId, loginId, customerFortunes);
} else {
//如paymentStatus != 2(暂不可发,保留),只需统计原Fortune对应的Withdraw,重新计算
noPaymentUpDate(paymentStatus,payoutBatchId,loginId,customerFortunes);
noPaymentUpDate(predictMonthPeriod, paymentStatus, payoutBatchId, loginId, customerFortunes);
}
responseVO.setCommonResult(commonResult);
......@@ -189,8 +190,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
}
@Override
public void canPaymentUpDate(String paymentStatus, Long payoutBatchId , Long loginId, List<AclCustomerFortune> customerFortunes) {
public void canPaymentUpDate(Date predictMonthPeriod, String paymentStatus, Long payoutBatchId , Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("canPaymentUpDate");
//将查询出来的财富列表根据customerId经行分类
Map<Long,List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(customerFortunes,"customerId");
//获得所有需要修改佣金发放状的customerIds
......@@ -218,6 +220,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//不一致,进行修改,并保存需修改的fortune和记录需要新生成的fortune
if (!paymentStatus.equals(fortune.getCommissionPayoutStatus())) {
fortune.setCommissionPayoutStatus(paymentStatus);
fortune.setStatus("2");
fortune.setPredictMonthPeriod(predictMonthPeriod);
fortune.setCommissionPayoutBy(loginId);
fortune.setCommissionPayoutAt(new Date());
fortune.setPayoutBatchId(payoutBatchId);
......@@ -238,6 +242,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
fortune.setCommissionPayoutAt(new Date());
fortune.setCommissionPayoutBy(loginId);
fortune.setPayoutBatchId(payoutBatchId);
fortune.setStatus("2");
fortune.setPredictMonthPeriod(predictMonthPeriod);
if (CommonUtil.isNullOrZero(withdrawId)){
//需生成新的withdraw
newFortunes.add(fortune);
......@@ -296,7 +302,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
return customerWithdrawMap;
}
private void noPaymentUpDate(String paymentStatus,Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) {
private void noPaymentUpDate(Date predictMonthPeriod, String paymentStatus,Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("noPaymentUpDate");
//需要修改的fortune记录(需修改佣金发放状态)
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
......@@ -306,10 +312,12 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//不一致,进行修改,并保存需修改的fortune和需重新计算的withdrawIds
if (!paymentStatus.equals(fortune.getCommissionPayoutStatus())){
fortune.setCommissionPayoutStatus(paymentStatus);
fortune.setStatus(paymentStatus);
fortune.setCommissionPayoutBy(loginId);
fortune.setCommissionPayoutAt(new Date());
if (!CommonUtil.isNullOrZero(payoutBatchId)){
fortune.setPayoutBatchId(payoutBatchId);
fortune.setPredictMonthPeriod(predictMonthPeriod);
}
Long withdrawId = fortune.getWithdrawedId();
fortune.setWithdrawedId(null);
......@@ -755,7 +763,10 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
});
customerFortunePayDalService.updateAll(customerFortunePays);
//修改fortune
fortunes.forEach(f -> f.setCommissionPayoutStatus("4"));
fortunes.forEach(f -> {
f.setCommissionPayoutStatus("4");
f.setStatus("4");//新发佣检核状态字段
});
customerFortuneDalService.updateBatch(fortunes);
responseVO.setCommonResult(commonResult);
return responseVO;
......
......@@ -219,12 +219,15 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
List<Long> orderIds = new ArrayList<>();
Long orderId;
for (ComeCommissionParams params: paramsList) {
// 查询对应订单记录
orderId = params.getOrderId();
PoOrder order = poOrderDALService.findByOrderId(orderId);
if ("1".equals(params.getCommissionPeriod())) {
orderId = params.getOrderId();
orderIds.add(orderId);
this.updateOrderAndFortune(orderId, status, loginId, checkBatch);
// 只有首年记录更新order表
this.updateOrder(order, status, loginId, checkBatch);
}
this.updateFortune(params.getCommissionId(), status, loginId, checkBatch);
}
if (orderIds.size() != 0 && "3".equals(status)) {
......@@ -356,15 +359,26 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
sendService.sendEmailOrSMS("email", email, "3", messageText.toString(), null, subject, ccAddresses, "来佣比对已退保", 99, null);
}
private void updateOrderAndFortune(Long orderId, String status, String loginId, String checkBatch) {
private void updateFortune(Long commissionId, String status, String loginId, String checkBatch) {
// 查询对应的fortune记录
List<AclCustomerFortune> fortuneList = customerFortuneDalService.queryLifeFortuneListByCommissionId(commissionId);
// 查询对应订单记录
PoOrder order = poOrderDALService.findByOrderId(orderId);
// 查询保单下的所有寿险经纪人的fortune记录
List<AclCustomerFortune> fortuneList = customerFortuneDalService.queryLifeFortuneListByOrderId(orderId);
// 更新fortune记录是否可发放
String fortuneCommissionPayoutStatus = "2".equals(status) ? "2" : "1";
String fortuneCommissionPayoutStatus = "2".equals(status) ? "2" : "0";//旧发佣检核状态字段
if (fortuneList.size() > 0) {
// 批量设置fortune为可发佣
fortuneList.forEach(f -> {
f.setCommissionPayoutStatus(fortuneCommissionPayoutStatus);
f.setStatus("2".equals(fortuneCommissionPayoutStatus) ? "2" : "1");//新发佣检核状态字段
f.setCommissionPayoutAt(new Date());
f.setCommissionPayoutBy(Long.valueOf(loginId));
});
customerFortuneDalService.updateBatch(fortuneList);
}
}
private void updateOrder(PoOrder order, String status, String loginId, String checkBatch) {
// 获取批次号(如2020-11的字符串)
Long checkBatchId = this.getOrderCommissionCheckBatch(checkBatch, loginId);
// 设置order记录的CommissionCheckId
......@@ -377,32 +391,12 @@ public class LifeCommissionServiceImpl implements LifeCommissionService {
/**检核选择退保时先查看原来的来佣状态,若原来的是”已比对“则不改成已退保,若是”待来佣“就改成”已退保“*/
if ("3".equals(status)) {
if ("1".equals(order.getCommissionCheckStatus())) {
lifeCommissionMapper.setOrderCommissionCheckId(Arrays.asList(orderId), paramMap);
if (fortuneList.size() > 0) {
// 批量设置fortune为可发佣
fortuneList.forEach(f -> {
f.setCommissionPayoutStatus(fortuneCommissionPayoutStatus);
f.setCommissionPayoutAt(new Date());
f.setCommissionPayoutBy(Long.valueOf(loginId));
});
customerFortuneDalService.updateBatch(fortuneList);
}
lifeCommissionMapper.setOrderCommissionCheckId(Arrays.asList(order.getId()), paramMap);
}
} else {
lifeCommissionMapper.setOrderCommissionCheckId(Arrays.asList(orderId), paramMap);
if (fortuneList.size() > 0) {
// 批量设置fortune为可发佣
fortuneList.forEach(f -> {
f.setCommissionPayoutStatus(fortuneCommissionPayoutStatus);
f.setCommissionPayoutAt(new Date());
f.setCommissionPayoutBy(Long.valueOf(loginId));
});
customerFortuneDalService.updateBatch(fortuneList);
}
lifeCommissionMapper.setOrderCommissionCheckId(Arrays.asList(order.getId()), paramMap);
}
}
private void validateClosed(List<PoOrder> orders, List<AclCustomerFortune> fortuneList, String status) throws Exception {
StringBuilder stringBuilder = new StringBuilder();
Map<Long, String> orderIdPolicyNoMap = new HashMap<>();
......
......@@ -4,6 +4,7 @@ import lombok.Data;
@Data
public class ComeCommissionParams {
private Long commissionId;
private Long orderId;
private String commissionNo;
private String commissionPeriod;
......
......@@ -3,6 +3,9 @@ package com.yd.api.practitioner;
import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.service.PractitionerService;
import com.yd.api.practitioner.service.ScheduleTrackService;
import com.yd.api.practitioner.vo.PractitionerIdRequestVO;
import com.yd.api.practitioner.vo.commitment.QueryCommitmentByPractitionerIdResponseVO;
import com.yd.api.practitioner.vo.commitment.SignCommitmentRequestVO;
import com.yd.api.practitioner.vo.informed.*;
import com.yd.api.practitioner.vo.login.CanSeeSalaryListResponseVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
......@@ -720,4 +723,22 @@ public class PractitionerController {
result.setData(responseVO);
return result;
}
@RequestMapping("/signCommitment")
public Object signCommitment(@RequestBody SignCommitmentRequestVO requestVO) {
JsonResult result = new JsonResult();
CommonResultIDResponseVO responseVO = practitionerService.signCommitment(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
@RequestMapping("/queryCommitmentByPractitionerId")
public Object queryCommitmentByPractitionerId(@RequestBody PractitionerIdRequestVO requestVO) {
JsonResult result = new JsonResult();
QueryCommitmentByPractitionerIdResponseVO responseVO = practitionerService.queryCommitmentByPractitionerId(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
}
package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.PractitionerIdRequestVO;
import com.yd.api.practitioner.vo.commitment.QueryCommitmentByPractitionerIdResponseVO;
import com.yd.api.practitioner.vo.commitment.SignCommitmentRequestVO;
import com.yd.api.practitioner.vo.informed.*;
import com.yd.api.practitioner.vo.login.CanSeeSalaryListResponseVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
......@@ -258,4 +261,8 @@ public interface PractitionerService {
CommonResultIDResponseVO signInformedSheet(SignInformedSheetRequestVO requestVO);
QueryInformedSheetListResponseVO queryInformedSheetList(QueryInformedSheetListRequestVO requestVO);
CommonResultIDResponseVO signCommitment(SignCommitmentRequestVO requestVO);
QueryCommitmentByPractitionerIdResponseVO queryCommitmentByPractitionerId(PractitionerIdRequestVO requestVO);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.yd.api.practitioner.vo;
import lombok.Data;
@Data
public class PractitionerIdRequestVO {
private Long practitionerId;
}
package com.yd.api.practitioner.vo.commitment;
import com.yd.api.result.CommonResult;
import lombok.Data;
@Data
public class QueryCommitmentByPractitionerIdResponseVO {
private String fileOssPath;
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.commitment;
import lombok.Data;
@Data
public class SignCommitmentRequestVO {
private Long practitionerId;
private String practitionerName;
private String imgStr;
}
package com.yd.dal.entity.customer;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* fortune record of customer
......@@ -122,6 +123,7 @@ public class AclCustomerFortune {
/**
* FK ag_md_drop_options.drop_option_code where master = Commission_Payout_Status,佣金发放状态
* 待发佣-0 暂不可发-1 可发放-2 保留-3 已发并关账-4
*/
private String commissionPayoutStatus;
......@@ -154,4 +156,28 @@ public class AclCustomerFortune {
* FK ag_acl_customer.id
*/
private Long createdBy;
private Long ruleId;//关联结算规则ID
private String ruleCode;//结算规则编码
private String settlementType = "1";//结算类型(1.订单结算;2.经纪人结算;3.渠道结算;)
private Long practitionerId;//经纪人ID
private String channelId;//渠道ID
private String insurerId;//保险公司id
private String productId;//产品id
private String calculationMethod;//计算方式(1.跟单生成;2.月末计算;3.季末计算;4:次年第一季度)
private String calculationFormula;//计算公式
private Date statisticStart;//统计开始时间
private Date statisticEnd;//统计结束时间
private String segmentVlaue;//分段计算值(默认为0,条件因子值在统计时间段内变化时,需要分段计算)
private Date predictMonthPeriod;//预计发佣年月(YYYY-MM)
private String status;//状态(0:作废;1:待发佣;2:可发放;3:保留;4:已关账)
private Long commissionId;//来佣表ID
private String commissionFlag;//佣金标记(1:手工佣金;)
private Long coverIntroducerId;//关联经纪人ID
private Integer commissionPeriod;//佣金期数(1=第一年; 2=第二年; 3=第三年; 4=第四年; 5=第五年)
private String remark;//佣金备注
private Double achievementsRate;//业绩比例
private Double achievements;//业绩
private Double examineFyc;//考核FYC
private Double comprehensiveFyc;//综合业绩FYC
}
\ No newline at end of file
......@@ -2,9 +2,10 @@ package com.yd.dal.mapper.customer;
import com.yd.api.practitioner.vo.rank.AclCustomerFortuneStatistics;
import com.yd.dal.entity.customer.AclCustomerFortune;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AclCustomerFortuneMapper {
int deleteByPrimaryKey(Long id);
......@@ -37,4 +38,6 @@ public interface AclCustomerFortuneMapper {
List<AclCustomerFortuneStatistics> findBypractitionerIds(@Param("list")List<Long> practitionerIds, @Param("time")Integer time);
List<AclCustomerFortune> queryLifeFortuneListByOrderId(Long orderId);
List<AclCustomerFortune> queryLifeFortuneListByCommissionId(Long commissionId);
}
\ No newline at end of file
......@@ -29,4 +29,6 @@ public interface AclCustomerFortuneDALService {
List<AclCustomerFortuneStatistics> findBypractitionerIds(List<Long> practitionerIds, Integer time);
List<AclCustomerFortune> queryLifeFortuneListByOrderId(Long orderId);
List<AclCustomerFortune> queryLifeFortuneListByCommissionId(Long commissionId);
}
......@@ -59,4 +59,8 @@ public class AclCustomerFortuneDALServiceImpl implements AclCustomerFortuneDALSe
public List<AclCustomerFortune> queryLifeFortuneListByOrderId(Long orderId) {
return aclCustomerFortuneMapper.queryLifeFortuneListByOrderId(orderId);
}
@Override
public List<AclCustomerFortune> queryLifeFortuneListByCommissionId(Long commissionId) {
return aclCustomerFortuneMapper.queryLifeFortuneListByCommissionId(commissionId);
}
}
......@@ -36,6 +36,30 @@
<result column="fortune_payed_id" jdbcType="BIGINT" property="fortunePayedId" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="BIGINT" property="createdBy" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="rule_code" jdbcType="VARCHAR" property="ruleCode" />
<result column="settlement_type" jdbcType="VARCHAR" property="settlementType" />
<result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" />
<result column="channel_id" jdbcType="BIGINT" property="channelId" />
<result column="insurer_id" jdbcType="BIGINT" property="insurerId" />
<result column="product_id" jdbcType="BIGINT" property="productId" />
<result column="calculation_method" jdbcType="VARCHAR" property="calculationMethod" />
<result column="calculation_formula" jdbcType="VARCHAR" property="calculationFormula" />
<result column="statistic_start" jdbcType="BIGINT" property="statisticStart" />
<result column="statistic_end" jdbcType="BIGINT" property="statisticEnd" />
<result column="segment_vlaue" jdbcType="BIGINT" property="segmentVlaue" />
<result column="predict_month_period" jdbcType="TIMESTAMP" property="predictMonthPeriod" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="commission_id" jdbcType="BIGINT" property="commissionId" />
<result column="commission_flag" jdbcType="VARCHAR" property="commissionFlag" />
<result column="cover_introducer_id" jdbcType="BIGINT" property="coverIntroducerId" />
<result column="commission_period" jdbcType="INTEGER" property="commissionPeriod" />
<result column="remark" jdbcType="LONGVARCHAR" property="remark" />
<result column="achievements_rate" jdbcType="DECIMAL" property="achievementsRate" />
<result column="achievements" jdbcType="DECIMAL" property="achievements" />
<result column="examine_fyc" jdbcType="DECIMAL" property="examineFyc" />
<result column="comprehensive_fyc" jdbcType="DECIMAL" property="comprehensiveFyc" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
......@@ -43,8 +67,30 @@
fyc_rate, fyc_amount, grade_commission_rate, share_rate, referral_rate, referral_amount,
month_period, commission_type, drop_option_code, practitioner_level, is_tax, tax_amount,
net_amount, campaign_id, campaign_name, withdrawable_date, payout_batch_id, commission_payout_status,
commission_payout_at, commission_payout_by, withdrawed_id, fortune_payed_id, created_at,
created_by
commission_payout_at, commission_payout_by, withdrawed_id, fortune_payed_id, created_at, created_by,
rule_id,
rule_code,
settlement_type,
practitioner_id,
channel_id,
insurer_id,
product_id,
calculation_method,
calculation_formula,
statistic_start,
statistic_end,
segment_vlaue,
predict_month_period,
status,
commission_id,
commission_flag,
cover_introducer_id,
commission_period,
remark,
achievements_rate,
achievements,
examine_fyc,
comprehensive_fyc
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
......@@ -552,6 +598,16 @@
when id = #{item.id,jdbcType=BIGINT} then #{item.commissionPayoutBy,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="status = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.status,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="predict_month_period = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.predictMonthPeriod,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="withdrawed_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.withdrawedId,jdbcType=BIGINT}
......@@ -949,4 +1005,11 @@
and f.order_id = #{orderId,jdbcType=BIGINT}
</select>
<select id="queryLifeFortuneListByCommissionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_acl_customer_fortune f
where 1=1
and f.commission_id = #{commissionId,jdbcType=BIGINT}
</select>
</mapper>
\ No newline at end of file
......@@ -293,6 +293,15 @@
select
<include refid="Base_Column_List" />
from ag_acl_file_upload
where target_type = #{type,jdbcType=INTEGER} and target_id = #{targetId,jdbcType=BIGINT} and remark = #{remark,jdbcType=VARCHAR} and is_active = 1
where is_active = 1
<if test="type != null">
and target_type = #{type,jdbcType=INTEGER}
</if>
<if test="targetId != null">
and target_id = #{targetId,jdbcType=BIGINT}
</if>
<if test="remark != null">
and remark = #{remark,jdbcType=BIGINT}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -24,9 +24,6 @@
o.commission_type commissionType,
o.commission_item commissionItem,
b.id insurerBranchId,
b.branch_name insurerBranchName,
(case when o.cover_term in ('1','2','3') then o.coverageTerm else e.coverageTerm END) coverageTerm,
IFNULL(o.payTerm,e.payTerm) payTerm,
f.name,
......@@ -85,7 +82,7 @@
) p3
on o.config_level = p3.config_level and o.plan_id = p3.plan_id
left join ag_acl_insurer i on o.insurer_id = i.id
left join ag_acl_insurer_branch b on o.insurer_id = b.insurer_id
left join ag_acl_insurer_branch b on p.insurer_branch_id = b.id
left join (SELECT order_id, name, practitioner_type_id, f.customer_id
from (
select *
......
......@@ -20,3 +20,7 @@ pdf.position.y=150
#\u5BA2\u6237\u544A\u77E5\u4E66\u76EE\u5F55
informed.pdf.template=/opt/tomcat8/conf/ydpdf/informed/templateInformed.pdf
informed.pdf.temp.path=/opt/tomcat8/conf/ydpdf/informed
#\u7EED\u4FDD\u627F\u8BFA\u4E66\u76EE\u5F55
commitment.pdf.template=/opt/tomcat8/conf/ydpdf/commitment/templateCommitment.pdf
commitment.pdf.temp.path=/opt/tomcat8/conf/ydpdf/commitment
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