KKSU
2025-02-07 205217b3d786b9290efd2595e6206f3770e9554c
src/main/java/cc/mrbird/febs/pay/controller/FIUUController.java
@@ -3,7 +3,6 @@
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum;
import cc.mrbird.febs.common.enumerates.OrderStatusEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.ValidateEntityUtils;
import cc.mrbird.febs.mall.entity.MallOrderInfo;
import cc.mrbird.febs.mall.entity.MallOrderItem;
@@ -16,7 +15,10 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -145,45 +147,15 @@
        ValidateEntityUtils.ensureNotEqual(mallOrderInfo.getPayResult(), "1", "订单已支付");
        ValidateEntityUtils.ensureEqual(mallOrderInfo.getAmount().toString(), amount, "订单金额异常");
        // 更新订单状态
        if ("00".equals(status)) {
            mallOrderInfo.setPayMethod("FIUU支付");
            mallOrderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue());
            mallOrderInfo.setPayResult("1");
            mallOrderInfo.setPayTime(DateUtil.parseDateTime(paydate));
            mallOrderInfo.setDeliveryState(OrderDeliveryStateEnum.DELIVERY_WAIT.getValue());
            mallOrderInfo.setPayOrderNo(tranID);
            mallOrderInfoMapper.updateById(mallOrderInfo);
        }
        mallOrderInfo.setPayMethod("FIUU支付");
        mallOrderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue());
        mallOrderInfo.setPayResult("1");
        mallOrderInfo.setPayTime(DateUtil.parseDateTime(paydate));
        mallOrderInfo.setDeliveryState(OrderDeliveryStateEnum.DELIVERY_WAIT.getValue());
        mallOrderInfo.setPayOrderNo(tranID);
        mallOrderInfoMapper.updateById(mallOrderInfo);
    }
    // Java 通知接口 暂时停止使用
    @PostMapping("/callback")
    public FebsResponse handlePaymentCallback(@RequestParam Map<String, String> params) {
        String secretKey = "59c709fc18978a6a83b87f05d37cecbf";
        String tranID = params.get("tranID");
        String orderId = params.get("orderid");
        String status = params.get("status");
        String domain = params.get("domain");
        String amount = params.get("amount");
        String currency = params.get("currency");
        String paydate = params.get("paydate");
        String skey = params.get("skey");
        // 计算 skey 验证
        String preSkey = DigestUtils.md5Hex(tranID + orderId + status + domain + amount + currency);
        String calculatedSkey = DigestUtils.md5Hex(paydate + domain + preSkey + secretKey);
        if (!calculatedSkey.equals(skey)) {
            throw new FebsException("订单回调失败,---"+orderId);
        }
        updateOrderStatus(orderId, status, amount, paydate, tranID);
        if ("00".equals(status)) {
            return new FebsResponse().success().data("/pages/order/pay/paySuccess?amount="+ amount +"&type=3");
        }else{
            return new FebsResponse().fail().message("支付失败");
        }
    }
    /**
     * 根据用户ID和订单ID获取所购买商品名称