Commit 7bfec141 by wenyang

1、当月经纪人由有【可发放】的发佣数据, 变更为没有【可发放】 的发佣数据状态时,如果已经计算过薪资,需要把薪资与税务信息删除

2、当月经纪人发佣数据设置可发放并发放金额为0时,在还没有关账前做下月的可发放操作时,会导致下月的发佣数关联到本月数据中
parent bf315255
......@@ -13,9 +13,11 @@ import com.yd.dal.entity.customer.*;
import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo;
import com.yd.dal.entity.meta.MdIncometaxRate;
import com.yd.dal.entity.order.PoOrder;
import com.yd.dal.entity.practitioner.payscale.AgAclLifePractitionerSalary;
import com.yd.dal.entity.product.Product;
import com.yd.dal.entity.product.ProductPlan;
import com.yd.dal.entity.user.AclUser;
import com.yd.dal.mapper.practitioner.AgAclLifePractitionerSalaryMapper;
import com.yd.dal.service.agms.AgmsFortuneDALService;
import com.yd.dal.service.customer.*;
import com.yd.dal.service.order.PoOrderDALService;
......@@ -61,6 +63,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
private AclUserDALService userDalService;
@Autowired
private AclPractitionerSubordinateSystemDALService aclPractitionerSubordinateSystemDalService;
@Autowired
private AgAclLifePractitionerSalaryMapper practitionerSalaryMapper;
@Autowired
public void setAclCustomerFortuneDalService(AclCustomerFortuneDALService customerFortuneDalService) {
......@@ -144,7 +148,28 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//通过payoutBatch查询此批次是否再库中,在库中直接获取id,不在进行保存,获取id
Long payoutBatchId = findPayoutBatchIdByPayoutBatch(payoutBatch, loginId);
if (("2").equals(paymentStatus)) {
AclCustomerFortunePayoutBatch aclCustomerFortunePayoutBatch;
AgAclLifePractitionerSalary aclLifePractitionerSalary;
Set<AgAclLifePractitionerSalary> salarySet = new HashSet<>();
for (AclCustomerFortune fortune : customerFortunes) {
if("2".equals(fortune.getCommissionPayoutStatus()) && fortune.getPractitionerId() != null && fortune.getPayoutBatchId() != null){
aclCustomerFortunePayoutBatch = customerFortunePayoutBatchDalService.selectByPrimaryKey(fortune.getPayoutBatchId());
if(aclCustomerFortunePayoutBatch != null){
aclLifePractitionerSalary = new AgAclLifePractitionerSalary();
aclLifePractitionerSalary.setYearMonth(aclCustomerFortunePayoutBatch.getPayoutYearmonth());
aclLifePractitionerSalary.setPayoutBatchId(fortune.getPayoutBatchId());
AclPractitioner aclPractitioner = aclPractitionerDALService.findByCustomerIdIsActive(fortune.getCustomerId(), 1);
if(aclPractitioner != null){
aclLifePractitionerSalary.setPractitionerId(aclPractitioner.getId());
}else{
aclLifePractitionerSalary.setPractitionerId(fortune.getPractitionerId());
}
salarySet.add(aclLifePractitionerSalary);
}
}
}
if ("2".equals(paymentStatus)) {
//如paymentStatus = 2(可发放),只需统计Fortune对应Customer最后一笔未支付的Withdraw,重新计算,如没有Withdraw生成一条新的Withdraw记录
canPaymentUpDate(paymentStatus, payoutBatchId, loginId, customerFortunes);
} else {
......@@ -152,6 +177,23 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
noPaymentUpDate(paymentStatus, payoutBatchId, loginId, customerFortunes);
}
//当月经纪人由有【可发放】的发佣数据, 变更为没有【可发放】 的发佣数据状态时,如果已经计算过薪资,需要把薪资与税务信息删除
AclCustomerFortune aclCustomerFortune;
List<AclCustomerFortune> aclCustomerFortuneList;
for (AgAclLifePractitionerSalary salary : salarySet) {
aclCustomerFortune = new AclCustomerFortune();
aclCustomerFortune.setPractitionerId(salary.getPractitionerId());
aclCustomerFortune.setPayoutBatchId(salary.getPayoutBatchId());
aclCustomerFortuneList = customerFortuneDalService.queryByPractitionerIdAndPayoutBatchId(aclCustomerFortune);
if(aclCustomerFortuneList == null || aclCustomerFortuneList.size() <= 0){
//1、删除薪资税务信息ag_acl_life_practitioner_salary_tax表
practitionerSalaryMapper.deleteSalaryTaxByPractitionerIdAndYearMonth(salary);
//2、删除总薪资信息ag_acl_life_practitioner_salary表
salary.setYearMonth(salary.getYearMonth().replace("-", ""));
practitionerSalaryMapper.deleteByPractitionerIdAndYearMonth(salary);
}
}
responseVO.setCommonResult(commonResult);
return responseVO;
}
......@@ -203,8 +245,6 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
@Override
public void canPaymentUpDate(String paymentStatus, Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("canPaymentUpDate");
//将查询出来的财富列表根据customerId经行分类
Map<Long, List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(customerFortunes, "customerId");
//获得所有需要修改佣金发放状的customerIds
......@@ -314,7 +354,6 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
}
private void noPaymentUpDate(String paymentStatus, Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("noPaymentUpDate");
//需要修改的fortune记录(需修改佣金发放状态)
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
//需要重新计算的withdraw.id
......
......@@ -55,6 +55,7 @@ public class AgAclLifePractitionerSalary implements Serializable {
* 0,预览薪资单,1,经纪人查看薪资单
*/
private Integer isActive;
private Long payoutBatchId;
private static final long serialVersionUID = 1L;
......@@ -149,6 +150,7 @@ public class AgAclLifePractitionerSalary implements Serializable {
&& (this.getPayableAmount() == null ? other.getPayableAmount() == null : this.getPayableAmount().equals(other.getPayableAmount()))
&& (this.getTaxoutAmount() == null ? other.getTaxoutAmount() == null : this.getTaxoutAmount().equals(other.getTaxoutAmount()))
&& (this.getNetAmount() == null ? other.getNetAmount() == null : this.getNetAmount().equals(other.getNetAmount()))
&& (this.getPayoutBatchId() == null ? other.getPayoutBatchId() == null : this.getPayoutBatchId().equals(other.getPayoutBatchId()))
&& (this.getPdfOssPath() == null ? other.getPdfOssPath() == null : this.getPdfOssPath().equals(other.getPdfOssPath()));
}
......@@ -163,6 +165,7 @@ public class AgAclLifePractitionerSalary implements Serializable {
result = prime * result + ((getPayableAmount() == null) ? 0 : getPayableAmount().hashCode());
result = prime * result + ((getTaxoutAmount() == null) ? 0 : getTaxoutAmount().hashCode());
result = prime * result + ((getNetAmount() == null) ? 0 : getNetAmount().hashCode());
result = prime * result + ((getPayoutBatchId() == null) ? 0 : getPayoutBatchId().hashCode());
result = prime * result + ((getPdfOssPath() == null) ? 0 : getPdfOssPath().hashCode());
return result;
}
......@@ -193,4 +196,13 @@ public class AgAclLifePractitionerSalary implements Serializable {
public void setIsBasic(String isBasic) {
this.isBasic = isBasic;
}
public Long getPayoutBatchId() {
return payoutBatchId;
}
public void setPayoutBatchId(Long payoutBatchId) {
this.payoutBatchId = payoutBatchId;
}
}
......@@ -42,4 +42,6 @@ public interface AclCustomerFortuneMapper {
List<AclCustomerFortune> queryLifeFortuneListByOrderId(Long orderId);
List<AclCustomerFortune> queryLifeFortuneListByCommissionId(Long commissionId);
List<AclCustomerFortune> queryByPractitionerIdAndPayoutBatchId(AclCustomerFortune aclCustomerFortune);
}
\ No newline at end of file
......@@ -24,4 +24,9 @@ public interface AgAclLifePractitionerSalaryMapper {
@Param("isActive") Integer isActive, @Param("isHistory") String isHistory);
List<AgAclLifePractitionerSalary> queryByRecord(AgAclLifePractitionerSalary lifePractitionerSalary);
int deleteByPractitionerIdAndYearMonth(AgAclLifePractitionerSalary lifePractitionerSalary);
int deleteSalaryTaxByPractitionerIdAndYearMonth(AgAclLifePractitionerSalary lifePractitionerSalary);
}
......@@ -33,4 +33,7 @@ public interface AclCustomerFortuneDALService {
List<AclCustomerFortune> queryLifeFortuneListByOrderId(Long orderId);
List<AclCustomerFortune> queryLifeFortuneListByCommissionId(Long commissionId);
List<AclCustomerFortune> queryByPractitionerIdAndPayoutBatchId(AclCustomerFortune aclCustomerFortune);
}
......@@ -13,4 +13,6 @@ public interface AclCustomerFortunePayoutBatchDALService {
void save(AclCustomerFortunePayoutBatch customerFortunePayoutBatch);
List<String> findAll();
AclCustomerFortunePayoutBatch selectByPrimaryKey(Long id);
}
......@@ -68,4 +68,9 @@ public class AclCustomerFortuneDALServiceImpl implements AclCustomerFortuneDALSe
public List<AclCustomerFortune> queryLifeFortuneListByCommissionId(Long commissionId) {
return aclCustomerFortuneMapper.queryLifeFortuneListByCommissionId(commissionId);
}
@Override
public List<AclCustomerFortune> queryByPractitionerIdAndPayoutBatchId(AclCustomerFortune aclCustomerFortune) {
return aclCustomerFortuneMapper.queryByPractitionerIdAndPayoutBatchId(aclCustomerFortune);
}
}
......@@ -31,4 +31,10 @@ public class AclCustomerFortunePayoutBatchDALServiceImpl implements AclCustomerF
public List<String> findAll() {
return customerFortunePayoutBatchMapper.selectAll();
}
@Override
public AclCustomerFortunePayoutBatch selectByPrimaryKey(Long id) {
return customerFortunePayoutBatchMapper.selectByPrimaryKey(id);
}
}
......@@ -1057,4 +1057,13 @@
where 1=1
and f.commission_id = #{commissionId,jdbcType=BIGINT}
</select>
<select id="queryByPractitionerIdAndPayoutBatchId" resultMap="BaseResultMap" parameterType="com.yd.dal.entity.customer.AclCustomerFortune">
select
<include refid="Base_Column_List" />
from ag_acl_customer_fortune f
where f.commission_payout_status = 2 and f.practitioner_id = #{practitionerId,jdbcType=BIGINT}
and f.payout_batch_id = #{payoutBatchId,jdbcType=BIGINT}
</select>
</mapper>
\ No newline at end of file
......@@ -549,7 +549,8 @@
#{item}
</foreach>
and w.is_paid != 1
and (f.payout_batch_id = #{payoutBatchId,jdbcType=BIGINT} or w.withdraw_amount = 0)
and f.payout_batch_id = #{payoutBatchId,jdbcType=BIGINT}
<!-- and (f.payout_batch_id = #{payoutBatchId,jdbcType=BIGINT} or w.withdraw_amount = 0) -->
group by w.customer_id
</select>
......
......@@ -167,4 +167,18 @@
and is_active = #{isActive,jdbcType=VARCHAR}
</if>
</select>
<delete id="deleteByPractitionerIdAndYearMonth" parameterType="com.yd.dal.entity.practitioner.payscale.AgAclLifePractitionerSalary">
delete from ag_acl_life_practitioner_salary
where is_basic = 1 and is_active = 0 and practitioner_id = #{practitionerId,jdbcType=BIGINT}
and `year_month` = #{yearMonth,jdbcType=VARCHAR}
</delete>
<delete id="deleteSalaryTaxByPractitionerIdAndYearMonth" parameterType="com.yd.dal.entity.practitioner.payscale.AgAclLifePractitionerSalary">
delete from ag_acl_life_practitioner_salary_tax
where is_active = 1 and practitioner_id = #{practitionerId,jdbcType=BIGINT}
and salary_year_month = #{yearMonth,jdbcType=VARCHAR}
</delete>
</mapper>
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