mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-06-06 08:29:55 +08:00
代码优化
This commit is contained in:
@@ -11,6 +11,7 @@ import com.egzosn.pay.common.http.HttpConfigStorage;
|
||||
import com.egzosn.pay.common.http.UriVariables;
|
||||
import com.egzosn.pay.common.util.DateUtils;
|
||||
import com.egzosn.pay.common.util.MatrixToImageWriter;
|
||||
import com.egzosn.pay.common.util.Util;
|
||||
import com.egzosn.pay.common.util.sign.SignUtils;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -176,7 +177,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
bizContent.put("seller_id", payConfigStorage.getSeller());
|
||||
bizContent.put("subject", order.getSubject());
|
||||
bizContent.put("out_trade_no", order.getOutTradeNo());
|
||||
bizContent.put("total_amount", order.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
||||
bizContent.put("total_amount", Util.conversionAmount(order.getPrice()).toString());
|
||||
switch ((AliTransactionType) order.getTransactionType()) {
|
||||
case PAGE:
|
||||
case DIRECT:
|
||||
@@ -381,7 +382,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
if (!StringUtils.isEmpty(refundOrder.getRefundNo())) {
|
||||
bizContent.put("out_request_no", refundOrder.getRefundNo());
|
||||
}
|
||||
bizContent.put("refund_amount", refundOrder.getRefundAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
bizContent.put("refund_amount", Util.conversionAmount(refundOrder.getRefundAmount()));
|
||||
//设置请求参数的集合
|
||||
parameters.put("biz_content", JSON.toJSONString(bizContent));
|
||||
//设置签名
|
||||
@@ -441,9 +442,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
Map<String, Object> bizContent = new TreeMap<>();
|
||||
bizContent.put("bill_type", billType);
|
||||
//目前只支持日账单
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
bizContent.put("bill_date", df.format(billDate));
|
||||
bizContent.put("bill_date", DateUtils.formatDay(billDate));
|
||||
//设置请求参数的集合
|
||||
parameters.put("biz_content", JSON.toJSONString(bizContent));
|
||||
//设置签名
|
||||
@@ -501,7 +500,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
bizContent.put("payee_type", order.getTransferType().getType());
|
||||
}
|
||||
bizContent.put("payee_account", order.getPayeeAccount());
|
||||
bizContent.put("amount", order.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
bizContent.put("amount", Util.conversionAmount(order.getAmount()));
|
||||
bizContent.put("payer_show_name", order.getPayerName());
|
||||
bizContent.put("payee_real_name", order.getPayeeName());
|
||||
bizContent.put("remark", order.getRemark());
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.egzosn.pay.common.bean.result.PayException;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import com.egzosn.pay.common.http.HttpConfigStorage;
|
||||
import com.egzosn.pay.common.http.UriVariables;
|
||||
import com.egzosn.pay.common.util.DateUtils;
|
||||
import com.egzosn.pay.common.util.Util;
|
||||
import com.egzosn.pay.common.util.sign.SignUtils;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -176,7 +178,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
orderInfo = orderInfo + "&out_trade_no=\"" + order.getOutTradeNo() + "\"";
|
||||
orderInfo = orderInfo + "&subject=\"" + order.getSubject() + "\"";
|
||||
orderInfo = orderInfo + "&body=\"" + order.getBody() + "\"";
|
||||
orderInfo = orderInfo + "&total_fee=\"" + order.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString() + "\"";
|
||||
orderInfo = orderInfo + "&total_fee=\"" + Util.conversionAmount(order.getPrice()).toString() + "\"";
|
||||
orderInfo = orderInfo + "¬ify_url=\"" + this.payConfigStorage.getNotifyUrl() + "\"";
|
||||
orderInfo = orderInfo + "&service=\"mobile.securitypay.pay\"";
|
||||
orderInfo = orderInfo + "&payment_type=\"1\"";
|
||||
@@ -207,7 +209,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
// 商品详情
|
||||
orderInfo.put("body", order.getBody());
|
||||
// 商品金额
|
||||
orderInfo.put("total_fee", order.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString() );
|
||||
orderInfo.put("total_fee", Util.conversionAmount(order.getPrice()).toString() );
|
||||
// 服务器异步通知页面路径
|
||||
orderInfo.put("notify_url", payConfigStorage.getNotifyUrl() );
|
||||
// 服务接口名称, 固定值
|
||||
@@ -222,7 +224,12 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
// m-分钟,h-小时,d-天,1c-当天(无论交易何时创建,都在0点关闭)。
|
||||
// 该参数数值不接受小数点,如1.5h,可转换为90m。
|
||||
// TODO 2017/2/6 11:05 author: egan 目前写死,这一块建议配置
|
||||
orderInfo.put("it_b_pay", "30m");
|
||||
|
||||
if (null != order.getExpirationTime()) {
|
||||
orderInfo.put("timeout_express", DateUtils.minutesRemaining(order.getExpirationTime()) + "m");
|
||||
}else {
|
||||
orderInfo.put("it_b_pay", "30m");
|
||||
}
|
||||
// 支付宝处理完请求后,当前页面跳转到商户指定页面的路径,可空
|
||||
orderInfo.put("return_url", payConfigStorage.getReturnUrl());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user