|
|
|
@ -5,6 +5,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientsSurchargeAccountsMap
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.FinancialSurchargeAccountDetailMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService;
|
|
|
|
|
import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
import au.com.royalpay.payment.tools.lock.Locker;
|
|
|
|
@ -50,11 +51,9 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
|
|
|
|
|
Date dateto = monthCal.getTime();
|
|
|
|
|
monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1));
|
|
|
|
|
Date datefrom = monthCal.getTime();
|
|
|
|
|
|
|
|
|
|
logger.info("===============Start generator surcharge account month detail===============" + new Date());
|
|
|
|
|
List<JSONObject> thisMonthDetail = clearingDistributedSurchargeMapper.getMonthDetailByClientId(datefrom, dateto);
|
|
|
|
|
logger.info("this month details : " + thisMonthDetail.toString());
|
|
|
|
|
|
|
|
|
|
for (JSONObject detail : thisMonthDetail) {
|
|
|
|
|
detail.put("send_mail", 0);
|
|
|
|
|
detail.put("wx_send", 0);
|
|
|
|
@ -63,9 +62,7 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
|
|
|
|
|
detail.put("is_valid", 0);
|
|
|
|
|
financialSurchargeAccountDetailMapper.save(detail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.info("===============generator OVER===============" + new Date());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -79,6 +76,9 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
|
|
|
|
|
throw new ForbiddenException("无法执行平账操作,权限不足");
|
|
|
|
|
}
|
|
|
|
|
JSONObject detail = financialSurchargeAccountDetailMapper.findByDetailId(detail_id);
|
|
|
|
|
if (detail.getBooleanValue("is_valid")) {
|
|
|
|
|
throw new BadRequestException("该记录已结清");
|
|
|
|
|
}
|
|
|
|
|
if (!locker.lock(detail.getIntValue("client_id") + "_" + detail.getString("settle_month") + "_fill", 120_000)) {
|
|
|
|
|
throw new ServerErrorException("Processing task, wait for a moment");
|
|
|
|
|
}
|
|
|
|
@ -86,20 +86,19 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
|
|
|
|
|
JSONObject surcharge_account = clientsSurchargeAccountsMapper.find(detail.getIntValue("client_id"));
|
|
|
|
|
JSONObject transaction = new JSONObject();
|
|
|
|
|
transaction.put("client_id", detail.getIntValue("client_id"));
|
|
|
|
|
transaction.put("settle_date", detail.getString("settle_date"));
|
|
|
|
|
// transaction.put("settle_date", detail.getString("settle_month"));
|
|
|
|
|
transaction.put("type", "Credit");
|
|
|
|
|
transaction.put("total_surcharge", BigDecimal.ZERO);
|
|
|
|
|
transaction.put("tax_amount", BigDecimal.ZERO);
|
|
|
|
|
transaction.put("amount", detail.getBigDecimal("debit_amount"));
|
|
|
|
|
transaction.put("amount", detail.getBigDecimal("debit_amount").negate());
|
|
|
|
|
transaction.put("post_balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
|
|
|
|
|
transaction.put("operation", manager.getString("manager_id"));
|
|
|
|
|
transaction.put("create_time", new Date());
|
|
|
|
|
transaction.put("remark", detail.getString("settle_date")+"冲正");
|
|
|
|
|
transaction.put("remark", detail.getString("settle_month")+"冲正");
|
|
|
|
|
clearingDistributedSurchargeMapper.save(transaction);
|
|
|
|
|
|
|
|
|
|
surcharge_account.put("balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
|
|
|
|
|
clientsSurchargeAccountsMapper.update(surcharge_account);
|
|
|
|
|
|
|
|
|
|
detail.put("is_valid", 1);
|
|
|
|
|
detail.put("operator_id", manager.getString("manager_id"));
|
|
|
|
|
financialSurchargeAccountDetailMapper.update(detail);
|
|
|
|
|