提交代码

master
胡锐 6 months ago committed by yuanye
parent bbf955b63e
commit 1bec2b1a12
  1. 17
      service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java
  2. 4
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java
  3. 10
      service/src/main/java/com/hfkj/service/pay/HuiPayService.java

@ -22,7 +22,9 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -79,6 +81,7 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply
&& (!record.getStatus().equals(OrderAfterSalesApplyStatusEnum.type5.getCode()) && !record.getStatus().equals(OrderAfterSalesApplyStatusEnum.type2.getCode()))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此订单已提交售后,请勿重复提交");
}
BsOrderAfterSalesApply apply = new BsOrderAfterSalesApply();
apply.setType(applyType.getCode());
apply.setUserId(order.getUserId());
@ -98,6 +101,20 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply
apply.setPhoto(photo);
apply.setRemarks(remarks);
apply.setStatus(OrderAfterSalesApplyStatusEnum.type1.getCode());
if (orderChild.getSurplusRefundCount().equals(productCount)) {
// 全部退款
apply.setRefundPrice(orderChild.getSurplusRefundPrice());
apply.setRefundIntegral(orderChild.getSurplusRefundIntegral());
} else {
// 部分退款
// 计算单价
BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
.divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
apply.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
apply.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
}
editData(apply);
// 操作记录

@ -63,8 +63,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
try {
if (OrderPayChannelEnum.type1.getCode() == orderRefund.getRefundPayChannel()) {
// 渠道退款
JSONObject refund = HuiPayService.refund(orderRefund.getAccountMerchantNo(), orderRefund.getOrderNo(), orderRefund.getRefundOrderNo(), orderRefund.getRefundPrice());
if (refund.getString("").equals("000000")) {
JSONObject refund = HuiPayService.refund(HuiPayService.DEFAULT_MER_NO, orderRefund.getOrderNo(), orderRefund.getRefundOrderNo(), orderRefund.getRefundPrice());
if (refund.getString("return_code").equals("000000")) {
JSONObject data = refund.getJSONObject("return_data");
orderRefund.setRefundPayChannelOrderNo(data.getString("refundTradeNo"));
orderRefund.setRefundSerialNo(data.getString("accTradeNo"));

@ -28,7 +28,7 @@ public class HuiPayService {
static Logger log = LoggerFactory.getLogger(HuiPayService.class);
// 请求地址
private final static String REQUEST_URL = "https://pay.dctpay.com/openApi/v1/";
private final static String DEFAULT_MER_NO = "2023041916292112804";
public final static String DEFAULT_MER_NO = "2023041916292112804";
private final static String DEFAULT_MER_KEY = "2jLO2WjXcSRSzTCaca0Kmv0OFrfYBbrA";
public static Map<Object, Object> preorder(String openId,OrderModel order) throws Exception {
@ -82,10 +82,10 @@ public class HuiPayService {
public static JSONObject refund(String merchantNo,String outTradeNo,String refundTradeNo, BigDecimal refundAmount) throws Exception {
Map<String,Object> param = new HashMap<>();
param.put("merchantNo", "");
param.put("outTradeNo", "");
param.put("refundTradeNo", "");
param.put("refundAmount", "");
param.put("merchantNo", merchantNo);
param.put("outTradeNo", outTradeNo);
param.put("refundTradeNo", refundTradeNo);
param.put("refundAmount", refundAmount);
param.put("sign" , SignatureUtil.createSign(param, DEFAULT_MER_KEY));
return HttpsUtils.doPost(REQUEST_URL + "trade/refund", param, new HashMap<>());

Loading…
Cancel
Save