|
|
@ -11,6 +11,7 @@ import au.com.royalpay.payment.manage.mappers.payment.RefundMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.RefundReviewMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.RefundReviewMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.refund.RefundService;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.refund.RefundService;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.refund.events.NewRefundReviewEvent;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.refund.events.NewRefundReviewEvent;
|
|
|
@ -22,22 +23,24 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
import org.springframework.context.ApplicationEventPublisherAware;
|
|
|
|
import org.springframework.context.ApplicationEventPublisherAware;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Created by yixian on 2016-07-04.
|
|
|
|
* Created by yixian on 2016-07-04.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -62,6 +65,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
|
|
|
|
private SysConfigMapper sysConfigMapper;
|
|
|
|
private SysConfigMapper sysConfigMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CouponAccuessLogMapper couponAccuessLogMapper;
|
|
|
|
private CouponAccuessLogMapper couponAccuessLogMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ClientConfigService clientConfigService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private PaymentApi paymentApi;
|
|
|
|
private PaymentApi paymentApi;
|
|
|
@ -141,8 +146,9 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
|
|
|
|
//增加角色审核
|
|
|
|
//增加角色审核
|
|
|
|
JSONObject client = clientManager.getClientInfo(clientId);
|
|
|
|
JSONObject client = clientManager.getClientInfo(clientId);
|
|
|
|
Assert.notNull(client, "client not exists");
|
|
|
|
Assert.notNull(client, "client not exists");
|
|
|
|
|
|
|
|
JSONObject clientConfig = clientConfigService.find(clientId);
|
|
|
|
OperatorType type = account != null ? OperatorType.PARTNER : OperatorType.MANAGER;
|
|
|
|
OperatorType type = account != null ? OperatorType.PARTNER : OperatorType.MANAGER;
|
|
|
|
boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER && client.getBooleanValue("enable_refund_auth");
|
|
|
|
boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER && clientConfig.getBooleanValue("enable_refund_auth");
|
|
|
|
logger.debug("applyer type=" + type + "; require audit=" + requireAudit);
|
|
|
|
logger.debug("applyer type=" + type + "; require audit=" + requireAudit);
|
|
|
|
|
|
|
|
|
|
|
|
paymentApi.clientRefundBalanceCheck(clientId, orderId, currency, feeAmount);
|
|
|
|
paymentApi.clientRefundBalanceCheck(clientId, orderId, currency, feeAmount);
|
|
|
@ -200,6 +206,7 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject executeRefund(String orderId, BigDecimal amount, String remark, JSONObject partnerAccount, JSONObject manager, JSONObject order, JSONObject client) {
|
|
|
|
private JSONObject executeRefund(String orderId, BigDecimal amount, String remark, JSONObject partnerAccount, JSONObject manager, JSONObject order, JSONObject client) {
|
|
|
|
checkOrderUseCustomerCoupon(order, amount);
|
|
|
|
checkOrderUseCustomerCoupon(order, amount);
|
|
|
|
|
|
|
|
JSONObject clientConfig = clientConfigService.find(client.getIntValue("client_id"));
|
|
|
|
OperatorType type = partnerAccount != null ? OperatorType.PARTNER : OperatorType.MANAGER;
|
|
|
|
OperatorType type = partnerAccount != null ? OperatorType.PARTNER : OperatorType.MANAGER;
|
|
|
|
JSONObject operator = new JSONObject();
|
|
|
|
JSONObject operator = new JSONObject();
|
|
|
|
if (type == OperatorType.PARTNER) {
|
|
|
|
if (type == OperatorType.PARTNER) {
|
|
|
@ -213,7 +220,7 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
|
|
|
|
operator.put("operator_id", manager.getIntValue("manager_id"));
|
|
|
|
operator.put("operator_id", manager.getIntValue("manager_id"));
|
|
|
|
operator.put("operator", manager.getString("display_name"));
|
|
|
|
operator.put("operator", manager.getString("display_name"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(partnerAccount.getIntValue("role")) == PartnerRole.CASHIER && client.getBooleanValue("enable_refund_auth");
|
|
|
|
boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(partnerAccount.getIntValue("role")) == PartnerRole.CASHIER && clientConfig.getBooleanValue("enable_refund_auth");
|
|
|
|
logger.debug("applyer type=" + type + "; require audit=" + requireAudit);
|
|
|
|
logger.debug("applyer type=" + type + "; require audit=" + requireAudit);
|
|
|
|
return paymentApi.refundOrder(orderId, null, amount, remark, operator, type, requireAudit);
|
|
|
|
return paymentApi.refundOrder(orderId, null, amount, remark, operator, type, requireAudit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|