| | |
| | | package com.matrix.system.shopXcx.api.action; |
| | | |
| | | import com.matrix.biz.dao.BizUserDao; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.component.wechat.externalInterface.common.Signature; |
| | | import com.matrix.component.wechat.externalInterface.common.Util; |
| | | import com.matrix.component.wechat.externalInterface.protocol.queryProtocol.NotifyData; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | |
| | | import com.matrix.system.shopXcx.dao.ShopOrderDao; |
| | | import com.matrix.system.shopXcx.dao.ShopPayLogDao; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.xml.sax.SAXException; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.xml.parsers.ParserConfigurationException; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | notityXml.append(inputLine); |
| | | } |
| | | request.getReader().close(); |
| | | // XMl转对象 |
| | | NotifyData data = (NotifyData) Util.getObjectFromXML(notityXml.toString(), NotifyData.class); |
| | | LogUtil.info(data.toString()); |
| | | LogUtil.info("notityXml ---- :{} ", notityXml); |
| | | |
| | | |
| | | // XMl转对象 |
| | | Object bb = Util.getObjectFromXML(notityXml.toString(), NotifyData.class); |
| | | NotifyData data = new NotifyData(); |
| | | BeanUtils.copyProperties(bb,data); |
| | | LogUtil.info("----return_code = {}", data.getReturn_code()); |
| | | |
| | | |
| | | // 返回状态码 SUCCESS/FAIL |
| | | if (AppConstance.CODE_SUCCESS.equals(data.getReturn_code())) { |
| | | |
| | | orderId = data.getAttach(); |
| | | // 检验订单状态 |
| | | ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); |
| | | |
| | | // 校验签名 |
| | | BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, HostInterceptor.getCompanyId()); |
| | | BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, order.getCompanyId()); |
| | | if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret.getParamValue())) { |
| | | // 校验业务结果 |
| | | if (AppConstance.CODE_SUCCESS.equals(data.getResult_code())) { |
| | |
| | | Double total_fee = Double.parseDouble(data.getTotal_fee()); |
| | | // 商户订单号 |
| | | String payNum = data.getOut_trade_no(); |
| | | orderId = data.getAttach(); |
| | | |
| | | LogUtil.info("支付回调关键信息---total_fee:{},payNum:{},orderId:{}", total_fee, payNum, orderId); |
| | | // 订单ID |
| | | BigDecimal payMoney = new BigDecimal(total_fee).divide(new BigDecimal(100), 2, |
| | | RoundingMode.HALF_UP); |
| | | |
| | | // 检验订单状态 |
| | | ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); |
| | | |
| | | if (order != null && ShopOrder.ORDER_PAY_STATUS_WAIT == order.getPayStatus()) { |
| | | ShopPayLog payLog = new ShopPayLog(); |
| | | // TODO 校验支付金额 |
| | |
| | | threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:003)"); |
| | | resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "通信标识失败"); |
| | | } |
| | | } catch (ParserConfigurationException | IOException | SAXException e) { |
| | | } catch (Exception e) { |
| | | LogUtil.error("支付回调签名错误", e); |
| | | threadResult.putInMap("status", "err"); |
| | | threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:004)"); |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | } |