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

@ -141,5 +141,5 @@ public interface TransactionMapper {
void removeSettleRemark(@Param("clearing_id") int clearingId); 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>
<select id="getHfClearAmount" resultType="com.alibaba.fastjson.JSONObject"> <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' SELECT sum(clearing_amount) clear_amount,
AND transaction_time >= #{datefrom} sum(channel_surcharge) charge_amount ,
AND transaction_time &lt;= #{dateto} transaction_type
GROUP BY transaction_type FROM pmt_transactions where channel='hf'
AND transaction_time >= #{datefrom}
AND transaction_time &lt;= #{dateto}
GROUP BY transaction_type
</select> </select>
</mapper> </mapper>

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

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