master
luoyang 6 years ago
parent bbfe9fc594
commit 2ad3ba5e73

@ -13,6 +13,9 @@ import java.util.List;
@AutoMapper(tablename = "financial_surcharge_account_detail", pkName = "detail_id")
public interface FinancialSurchargeAccountDetailMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findByDetailId(@Param("detail_id") String detail_id);
List<JSONObject> findDetailsByMonth(@Param("settle_month") String settle_month);
List<JSONObject> findDetailsByClientId(@Param("client_id") int client_id);
@ -20,9 +23,9 @@ public interface FinancialSurchargeAccountDetailMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject detail);
List<JSONObject> listSettlementDatesInMonth(@Param("month") String month);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject detail);
List<JSONObject> listSettlementDatesInMonth(@Param("month") String month);
}

@ -11,4 +11,6 @@ public interface SurchargeAccountService {
List<JSONObject> listSettledDatesInMonth(String mon);
void fillMothsSurcharge(JSONObject manager, String detail_id);
}

@ -1,9 +1,14 @@
package au.com.royalpay.payment.manage.surchargeAccount.core.impl;
import au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsSurchargeAccountsMapper;
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.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
@ -12,6 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@ -24,6 +30,10 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper;
@Resource
private FinancialSurchargeAccountDetailMapper financialSurchargeAccountDetailMapper;
@Resource
private Locker locker;
@Resource
private ClientsSurchargeAccountsMapper clientsSurchargeAccountsMapper;
Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class);
@ -50,6 +60,7 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
detail.put("wx_send", 0);
detail.put("settle_month", DateFormatUtils.format(datefrom, "yyyy-MM"));
detail.put("create_time", new Date());
detail.put("is_valid", 0);
financialSurchargeAccountDetailMapper.save(detail);
}
@ -59,8 +70,41 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
@Override
public List<JSONObject> listSettledDatesInMonth(String mon) {
List<JSONObject> settledDates = financialSurchargeAccountDetailMapper.listSettlementDatesInMonth(mon);
return financialSurchargeAccountDetailMapper.listSettlementDatesInMonth(mon);
}
return settledDates;
@Override
public void fillMothsSurcharge(JSONObject manager, String detail_id) {
if (!(ManagerRole.ADMIN.hasRole(manager.getIntValue("role")) || ManagerRole.OPERATOR.hasRole(manager.getIntValue("role")) || ManagerRole.FINANCIAL_STAFF.hasRole(manager.getIntValue("role")))) {
throw new ForbiddenException("无法执行平账操作,权限不足");
}
JSONObject detail = financialSurchargeAccountDetailMapper.findByDetailId(detail_id);
if (!locker.lock(detail.getIntValue("client_id") + "_" + detail.getString("settle_month") + "_fill", 120_000)) {
throw new ServerErrorException("Processing task, wait for a moment");
}
try {
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("type", "Credit");
transaction.put("total_surcharge", BigDecimal.ZERO);
transaction.put("tax_amount", BigDecimal.ZERO);
transaction.put("amount", detail.getBigDecimal("debit_amount"));
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")+"冲正");
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);
} finally {
locker.unlock(detail.getIntValue("client_id") + "_" + detail.getString("settle_month") + "_fill");
}
}
}

@ -19,7 +19,6 @@ import java.util.List;
@RestController
public class SurchargeAccountController {
@Resource
private SurchargeAccountService surchargeAccountService;
@ -27,4 +26,9 @@ public class SurchargeAccountController {
public List<JSONObject> surchargeAccountSettledDates(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String month) {
return surchargeAccountService.listSettledDatesInMonth(month);
}
@ManagerMapping(value = "/fill/{detail_id}", role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}, method = RequestMethod.PUT)
public void fillMothsSurcharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String detail_id) {
surchargeAccountService.fillMothsSurcharge(manager, detail_id);
}
}

@ -16,9 +16,6 @@ public class SurchargeAccountMonthTask {
@Resource
private SurchargeAccountService surchargeAccountService;
@Scheduled(cron = "0 30 6 1 * ?")
public void generateSurchargeAccountDetail() {
synchronizedScheduler.executeProcess("manage_task:generateSurchargeAccountMonth", 120_000, () ->

@ -5,7 +5,8 @@
<![CDATA[
SELECT d.client_id,c.client_moniker,c.company_name,
SUM(IF(d.type='Credit',amount,0)) credit_amount,
SUM(IF(d.type='Debit',amount,0)) debit_amount
SUM(IF(d.type='Debit',amount,0)) debit_amount,
SUM(IF(d.type='Debit',total_surcharge,0)) total_surcharge
FROM log_clearing_distributed_surcharge d INNER JOIN sys_clients c ON c.client_id=d.client_id
WHERE d.create_time >=#{datefrom} AND d.create_time < #{dateto}
AND c.is_valid= 1

@ -67,7 +67,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
return start <= mon && end >= mon
};
$scope.loadReport = function (mon) {
$http.get('/sys/surcharge_account/month/' + mon + '/settled_dates').then(function (resp) {
$scope.report = {
month: mon,
@ -97,6 +96,39 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.loadReport($scope.report.month);
});
};
$scope.openClientBoard = function (client) {
$uibModal.open({
templateUrl: '/static/analysis/templates/partner_card.html',
controller: 'partnerCardCtrl',
resolve: {
clientMoniker: function () {
return client.client_moniker
}
},
size: 'lg'
})
};
$scope.fillMonthsSurcharge = function (details) {
var contentHtml = $sce.trustAsHtml('即将为[' + $scope.details.short_name + '],<span style="color: red">冲正,请确认商户信息</span>');
commonDialog.confirm({
title: '后付费账户冲正',
content: '',
choises: [{label: 'OK', className: 'btn-success', key: '1'},
{label: 'Cancel', className: 'btn-danger', key: '2', dismiss: true}],
contentHtml: contentHtml
}).then(function () {
$http.post('/sys/settlement/settlement_notice').then(function () {
commonDialog.alert({title: 'Success', content: '发送成功', type: 'success'});
$scope.noticeResend = false;
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
$scope.noticeResend = false;
});
})
};

@ -48,24 +48,34 @@
<th>Short Name</th>
<th>充值总额</th>
<th>支出总额</th>
<th>余额</th>
<th>已结清</th>
<!--<th>余额</th>-->
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="details in report.details">
<td ng-bind="details.client_moniker"></td>
<td>
<a class="text-primary" role="button" title="Detail"
ng-click="openClientBoard(details)">
<span ng-bind="details.client_moniker"></span></a>
</td>
<td ng-bind="details.short_name"></td>
<td ng-bind="details.credit_amount|currency:'$'" style="color: green"></td>
<td ng-bind="details.debit_amount|currency:'$'" style="color: red"></td>
<td>
<span ng-if="details.balance>=0" style="color: green">{{details.balance|currency:'$'}}</span>
<span ng-if="details.balance<0" style="color: red">{{details.balance|currency:'$'}}</span>
<span ng-if="details.is_valid">已结清</span>
<span ng-if="!details.is_valid">未付款</span>
</td>
<!--<td>-->
<!--<span ng-if="details.balance>=0" style="color: green">{{details.balance|currency:'$'}}</span>-->
<!--<span ng-if="details.balance<0" style="color: red">{{details.balance|currency:'$'}}</span>-->
<!--</td>-->
<td>
<!-- 等待邮件和微信推送模板 -->
<!--<a style="cursor: pointer" > 催款</a>-->
<!--<a style="cursor: pointer" ng-click="showDetail()">充值</a>-->
<button class="btn btn-success" type="button" ng-click="fillMonthsSurcharge(details)"></button>
<i class="fa fa-bars" style="font-size: 15px;color: #3c8dbc;cursor: pointer;padding-left: 15px" ng-click="surchargeAccountDetail(details.client_moniker,details.settle_month)"></i>
</td>
</tr>

Loading…
Cancel
Save