taylor.dang 6 years ago
parent 6acf488ce6
commit 8bcede71bc

@ -2,51 +2,54 @@ package au.com.royalpay.payment.manage.dev.core.impl;
import au.com.royalpay.payment.manage.dev.core.HfClearAmountService;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.List;
@Service
public class HfClearAmountServiceImpl implements HfClearAmountService{
private final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss");
public class HfClearAmountServiceImpl implements HfClearAmountService {
@Resource
private TransactionMapper transactionMapper;
@Override
public JSONObject hfjsonobject(String dateto,String datefrom) {
JSONObject hfAmountInfo = new JSONObject();
JSONObject parms = new JSONObject();
parms.put("dateto", dateto + " 02:00:00");
parms.put("datefrom", datefrom + " 02:00:00");
List<JSONObject> hflist = transactionMapper.getHfClearAmount(parms);
Double payallAmount = 0.0;
Double refundAllAmount = 0.0;
Double paySurAmount = 0.0;
Double refundSurAllAmount = 0.0;
if (hflist.isEmpty()) {
hfAmountInfo.put("PayAmount", 0);
hfAmountInfo.put("RefundAmount", 0);
public JSONObject hfjsonobject(String dateto, String datefrom) {
JSONObject params = new JSONObject();
try {
params.put("datefrom", DateUtils.addMinutes(DateUtils.parseDate(datefrom), PlatformEnvironment.getEnv().getTimeZoneOffsetMinutes()));
params.put("dateto", DateUtils.addMinutes(DateUtils.parseDate(dateto), PlatformEnvironment.getEnv().getTimeZoneOffsetMinutes()));
} catch (ParseException e) {
throw new ServerErrorException("时间转换异常");
}
for(JSONObject hfAmount : hflist){
if ("Credit".equals(hfAmount.getString("transaction_type"))) {
hfAmountInfo.put("PayAmount",hfAmount.getBigDecimal("clearingamount").setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
payallAmount = hfAmount.getDouble("clearingamount");
paySurAmount = hfAmount.getDouble("suramount");
List<JSONObject> hfClearAmountResult = transactionMapper.getHfClearAmount(params);
JSONObject result = new JSONObject();
result.put("payment_amount", BigDecimal.ZERO);
result.put("refund_amount", BigDecimal.ZERO);
result.put("gross_amount", BigDecimal.ZERO);
result.put("charge_amount", BigDecimal.ZERO);
result.put("clear_amount", BigDecimal.ZERO);
if (hfClearAmountResult.isEmpty()) {
return result;
}
hfClearAmountResult.forEach(dbResult -> {
if ("Credit".equals(dbResult.getString("transaction_type"))) {
result.put("payment_amount", dbResult.getBigDecimal("clear_amount"));
result.put("payment_surcharge", dbResult.getBigDecimal("charge_amount"));
}
if ("Debit".equals(hfAmount.getString("transaction_type"))) {
hfAmountInfo.put("RefundAmount",hfAmount.getBigDecimal("clearingamount").setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
refundAllAmount = hfAmount.getDouble("clearingamount");
refundSurAllAmount = hfAmount.getDouble("suramount");
if ("Debit".equals(dbResult.getString("transaction_type"))) {
result.put("refund_amount", dbResult.getBigDecimal("clear_amount"));
result.put("refund_surcharge", dbResult.getBigDecimal("charge_amount"));
}
}
hfAmountInfo.put("realAmount", new BigDecimal(payallAmount - refundAllAmount).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue());
hfAmountInfo.put("surAmount", new BigDecimal(paySurAmount - refundSurAllAmount).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue());
hfAmountInfo.put("hfAmount", new BigDecimal(((payallAmount - refundAllAmount) - (paySurAmount - refundSurAllAmount))).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue());
return hfAmountInfo;
});
result.put("gross_amount", result.getBigDecimal("payment_amount").subtract(result.getBigDecimal("refund_amount")));
result.put("real_charge", result.getBigDecimal("payment_surcharge").subtract(result.getBigDecimal("refund_surcharge")));
result.put("clear_amount", result.getBigDecimal("gross_amount").subtract(result.getBigDecimal("real_charge")));
return result;
}
}

@ -141,5 +141,5 @@ public interface TransactionMapper {
void removeSettleRemark(@Param("clearing_id") int clearingId);
List<JSONObject> getHfClearAmount(JSONObject parms);
List<JSONObject> getHfClearAmount(JSONObject params);
}

@ -859,10 +859,13 @@ select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,
</select>
<select id="getHfClearAmount" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(clearing_amount) as ClearingAmount,sum(channel_surcharge) as SurAmount,transaction_type FROM pmt_transactions where channel='hf'
AND transaction_time >= #{datefrom}
AND transaction_time &lt;= #{dateto}
GROUP BY transaction_type
SELECT sum(clearing_amount) clear_amount,
sum(channel_surcharge) charge_amount ,
transaction_type
FROM pmt_transactions where channel='hf'
AND transaction_time >= #{datefrom}
AND transaction_time &lt;= #{dateto}
GROUP BY transaction_type
</select>
</mapper>

@ -353,13 +353,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
params.datefrom = $filter('date')(params.datefrom, 'yyyy-MM-dd');
params.dateto = $filter('date')(params.dateto, 'yyyy-MM-dd');
$http.get('/dev/hfClearAmount',{params:params}).then(function (resp) {
$scope.hfClearResult =resp.data;
$scope.totalhide = false;
$scope.selecttotal = true;
$scope.PayAmount = resp.data.PayAmount;
$scope.RefundAmount = resp.data.RefundAmount;
$scope.hfAmount = resp.data.hfAmount;
$scope.realAmount = resp.data.realAmount;
$scope.surAmount = resp.data.surAmount;
}, function (resp) {
alert(resp.data.message);
})

@ -31,14 +31,14 @@
</div>
<div style="padding-left: 3%;padding-top: 2%" ng-hide="totalhide">
<label>付款金额:</label>
<label><u>{{PayAmount}}</u></label> <br>
<label><u>{{hfClearResult.payment_amount}}</u></label> <br>
<label> 退款金额:</label>
<label><u>{{RefundAmount}}</u></label><br>
<label><u>{{hfClearResult.refund_amount}}</u></label><br>
<label>实际交易金额:</label>
<label><u>{{realAmount}}</u></label><br>
<label><u>{{hfClearResult.gross_amount}}</u></label><br>
<label>手续费:</label>
<label><u>{{surAmount}}</u></label><br>
<label><u>{{hfClearResult.charge_amount}}</u></label><br>
<label>应转款金额:</label>
<label><u>{{hfAmount}}</u></label>
<label><u>{{hfClearResult.clear_amount}}</u></label>
</div>
</section>
Loading…
Cancel
Save