| | |
| | | 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; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | 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.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Controller |
| | | @RestController |
| | | @Api(value = "FIUUController", tags = "FIUU支付") |
| | | @RequestMapping(value = "/api/fuPay") |
| | | public class FIUUController { |
| | |
| | | mallOrderInfoMapper.updateById(mallOrderInfo); |
| | | } |
| | | |
| | | // Java 通知接口 暂时停止使用 |
| | | @PostMapping("/callback") |
| | | public String handlePaymentCallback(@RequestParam Map<String, String> params, Model model) { |
| | | 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); |
| | | MallOrderInfo mallOrderInfo = ValidateEntityUtils |
| | | .ensureColumnReturnEntity(orderId, MallOrderInfo::getId, mallOrderInfoMapper::selectOne, "订单不存在"); |
| | | log.info("callback status: {}", status); |
| | | log.info("callback skey: {}", preSkey); |
| | | log.info("callback calculatedSkey: {}", calculatedSkey); |
| | | log.info("callback payResult: {}", mallOrderInfo.getPayResult()); |
| | | if("1".equals(mallOrderInfo.getPayResult())){ |
| | | return "success"; |
| | | } |
| | | |
| | | if (!calculatedSkey.equals(skey)) { |
| | | throw new FebsException("订单回调失败,---"+orderId); |
| | | } |
| | | if ("00".equals(status)) { |
| | | updateOrderStatus(orderId, status, amount, paydate, tranID); |
| | | return "success"; |
| | | }else{ |
| | | return "fail"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID和订单ID获取所购买商品名称 |