| | |
| | | import com.stylefeng.guns.modular.system.service.ICompanyService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.util.CbyzxOrderPayHelper; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import com.stylefeng.guns.modular.system.util.rongyun.RongYunUtil; |
| | | import com.stylefeng.guns.modular.system.util.rongyun.model.CloudRecordingCallback; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | /** |
| | | * 第三方支付回调控制器 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/base") |
| | | public class CallbackController { |
| | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private CbyzxOrderPayHelper cbyzxOrderPayHelper; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | |
| | | |
| | | @Autowired |
| | | private IOrderCrossCityService orderCrossCityService; |
| | | |
| | | /** |
| | | * 创博优微信支付统一回调。 |
| | | * out_trade_no 为平台业务单号,用于反解跨城完成支付或改派支付; |
| | | * trade_no 为创博优支付流水号,用于回填真实支付流水; |
| | | * trade_status=TRADE_SUCCESS 视为支付成功; |
| | | * notify_type=directpay.status.sync 表示支付结果通知。 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/cbyzxPayOrderTaxi") |
| | | public Map<String, Object> cbyzxPayOrderTaxi(@RequestBody String params, HttpServletRequest request) { |
| | | try { |
| | | JSONObject payload = JSONObject.parseObject(params); |
| | | log.info("创博优完成订单支付回调,outRequestNo={}, paymentOrderId={}, paidTime={}, paidAmount={}", |
| | | cbyzxOrderPayHelper.extractOutRequestNo(payload), |
| | | cbyzxOrderPayHelper.extractThirdPartyOrderNo(payload), |
| | | payload == null ? null : payload.getString("paidTime"), |
| | | payload == null ? null : payload.getString("paidAmount")); |
| | | if (payload == null) { |
| | | return buildCbyzxCallbackResponse(1, "invalid request"); |
| | | } |
| | | // if (!cbyzxOrderPayHelper.isPaySuccess(payload)) { |
| | | // return buildCbyzxCallbackResponse(1, cbyzxOrderPayHelper.extractMessage(payload)); |
| | | // } |
| | | |
| | | String outTradeNo = cbyzxOrderPayHelper.extractOutRequestNo(payload); |
| | | if (ToolUtil.isEmpty(outTradeNo)) { |
| | | return buildCbyzxCallbackResponse(1, "missing out_trade_no"); |
| | | } |
| | | String tradeNo = cbyzxOrderPayHelper.extractThirdPartyOrderNo(payload); |
| | | String orderId = ToolUtil.isNotEmpty(tradeNo) ? tradeNo : outTradeNo; |
| | | |
| | | if (outTradeNo.startsWith("crossCity_")) { |
| | | String legacyOutTradeNo = outTradeNo.substring("crossCity_".length()); |
| | | String[] split = legacyOutTradeNo.split("_"); |
| | | if (split.length < 2) { |
| | | return buildCbyzxCallbackResponse(1, "invalid crossCity out_trade_no"); |
| | | } |
| | | orderCrossCityService.payOrderCrossCityCallback(Integer.valueOf(split[0]), orderId, 1); |
| | | return buildCbyzxCallbackResponse(0, "success"); |
| | | } |
| | | if (outTradeNo.startsWith("onBehalf_")) { |
| | | String legacyOutTradeNo = outTradeNo.substring("onBehalf_".length()); |
| | | String[] split = legacyOutTradeNo.split("_"); |
| | | if (split.length < 2) { |
| | | return buildCbyzxCallbackResponse(1, "invalid onBehalf out_trade_no"); |
| | | } |
| | | orderCrossCityService.payOrderCrossCityCallback(Integer.valueOf(split[0]), orderId, 1); |
| | | return buildCbyzxCallbackResponse(0, "success"); |
| | | } |
| | | if (outTradeNo.startsWith("reassign_")) { |
| | | String legacyOutTradeNo = outTradeNo.substring("reassign_".length()); |
| | | reassignService.payReassign(legacyOutTradeNo, orderId, 1); |
| | | return buildCbyzxCallbackResponse(0, "success"); |
| | | } |
| | | if (outTradeNo.startsWith("reassignBatch_")) { |
| | | String legacyOutTradeNo = outTradeNo.substring("reassignBatch_".length()); |
| | | reassignService.payReassign(legacyOutTradeNo, orderId, 1); |
| | | return buildCbyzxCallbackResponse(0, "success"); |
| | | } |
| | | return buildCbyzxCallbackResponse(1, "unsupported out_trade_no"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return buildCbyzxCallbackResponse(1, "fail"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | out.close(); |
| | | } |
| | | |
| | | private Map<String, Object> buildCbyzxCallbackResponse(Integer code, String msg) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("code", code); |
| | | result.put("msg", msg); |
| | | return result; |
| | | } |
| | | |
| | | } |