|
@@ -12,6 +12,8 @@ import com.izouma.nineth.config.GeneralProperties;
|
|
|
import com.izouma.nineth.domain.AdapayMerchant;
|
|
import com.izouma.nineth.domain.AdapayMerchant;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.dto.adapay.MemberInfo;
|
|
import com.izouma.nineth.dto.adapay.MemberInfo;
|
|
|
|
|
+import com.izouma.nineth.dto.adapay.PaymentItem;
|
|
|
|
|
+import com.izouma.nineth.dto.adapay.PaymentList;
|
|
|
import com.izouma.nineth.dto.adapay.SettleAccountsItem;
|
|
import com.izouma.nineth.dto.adapay.SettleAccountsItem;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.AdapayMerchantRepo;
|
|
import com.izouma.nineth.repo.AdapayMerchantRepo;
|
|
@@ -249,24 +251,34 @@ public class AdapayMerchantService {
|
|
|
|
|
|
|
|
public Object query(Long merchantId, String id) throws BaseAdaPayException {
|
|
public Object query(Long merchantId, String id) throws BaseAdaPayException {
|
|
|
AdapayMerchant merchant = adapayMerchantRepo.findById(merchantId).orElseThrow(new BusinessException("商户不存在"));
|
|
AdapayMerchant merchant = adapayMerchantRepo.findById(merchantId).orElseThrow(new BusinessException("商户不存在"));
|
|
|
- Map<String, Object> map = Payment.query(id, merchant.getName());
|
|
|
|
|
- log.info(JSON.toJSONString(map, SerializerFeature.PrettyFormat));
|
|
|
|
|
- return map;
|
|
|
|
|
|
|
+ Map<String, Object> paymentParams = new HashMap<>();
|
|
|
|
|
+ paymentParams.put("app_id", merchant.getAppId());
|
|
|
|
|
+ paymentParams.put("payment_id", id);
|
|
|
|
|
+ Map<String, Object> paymentList = Payment.queryList(paymentParams, merchant.getName());
|
|
|
|
|
+ log.info(JSON.toJSONString(paymentList, SerializerFeature.PrettyFormat));
|
|
|
|
|
+ return paymentList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Object refund(Long merchantId, String id) throws BaseAdaPayException {
|
|
public Object refund(Long merchantId, String id) throws BaseAdaPayException {
|
|
|
AdapayMerchant merchant = adapayMerchantRepo.findById(merchantId).orElseThrow(new BusinessException("商户不存在"));
|
|
AdapayMerchant merchant = adapayMerchantRepo.findById(merchantId).orElseThrow(new BusinessException("商户不存在"));
|
|
|
- Map<String, Object> map = Payment.query(id, merchant.getName());
|
|
|
|
|
- if (!"succeeded".equals(MapUtils.getString(map, "status"))) {
|
|
|
|
|
- return map;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> paymentParams = new HashMap<>();
|
|
|
|
|
+ paymentParams.put("app_id", merchant.getAppId());
|
|
|
|
|
+ paymentParams.put("payment_id", id);
|
|
|
|
|
+ Map<String, Object> res = Payment.queryList(paymentParams, merchant.getName());
|
|
|
|
|
+ log.info(JSON.toJSONString(res, SerializerFeature.PrettyFormat));
|
|
|
|
|
+ PaymentList paymentList = JSON.parseObject(JSON.toJSONString(res), PaymentList.class);
|
|
|
|
|
+
|
|
|
|
|
+ if (paymentList.getPayments() != null && paymentList.getPayments().size() == 1) {
|
|
|
|
|
+ PaymentItem paymentItem = paymentList.getPayments().get(0);
|
|
|
|
|
+ Map<String, Object> refundParams = new HashMap<>();
|
|
|
|
|
+ refundParams.put("refund_amt", paymentItem.getPayAmt());
|
|
|
|
|
+ refundParams.put("refund_order_no", new SnowflakeIdWorker(0, 0).nextId() + "");
|
|
|
|
|
+ Map<String, Object> response = Refund.create(id, refundParams, merchant.getName());
|
|
|
|
|
+ log.info(JSON.toJSONString(response, SerializerFeature.PrettyFormat));
|
|
|
|
|
+ return response;
|
|
|
}
|
|
}
|
|
|
- String amt = MapUtils.getString(map, "pay_amt");
|
|
|
|
|
- Map<String, Object> refundParams = new HashMap<>();
|
|
|
|
|
- refundParams.put("refund_amt", amt);
|
|
|
|
|
- refundParams.put("refund_order_no", new SnowflakeIdWorker(0, 0).nextId() + "");
|
|
|
|
|
- Map<String, Object> response = Refund.create(id, refundParams, merchant.getName());
|
|
|
|
|
- log.info(JSON.toJSONString(response, SerializerFeature.PrettyFormat));
|
|
|
|
|
- return response;
|
|
|
|
|
|
|
+ return res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void checkSuccess(Map<String, Object> map) {
|
|
public static void checkSuccess(Map<String, Object> map) {
|