| | |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.paymentPoolValue.PaymentPoolValueDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.dto.wechat.SmallWeChatDto; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolValueV1InnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWeChatInnerServiceSMO; |
| | | import com.java110.po.wechat.OnlinePayPo; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.constant.WechatConstant; |
| | |
| | | @Autowired |
| | | private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public ResultVo pay(String communityId, String orderNum, double money, String authCode, String feeName, String paymentPoolId) throws Exception { |
| | | logger.info("【小程序支付】 统一下单开始, 订单编号=" + orderNum); |
| | |
| | | Map<String, String> resMap = null; |
| | | logger.debug("resMap=" + resMap); |
| | | String systemName = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_GOOD_NAME); |
| | | SmallWeChatDto shopSmallWeChatDto = null; |
| | | SmallWeChatDto smallWeChatDto = new SmallWeChatDto(); |
| | | smallWeChatDto.setObjId(communityId); |
| | | List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto); |
| | | if (smallWeChatDtos == null && smallWeChatDtos.size() < 1) { |
| | | shopSmallWeChatDto = new SmallWeChatDto(); |
| | | shopSmallWeChatDto.setObjId(communityId); |
| | | shopSmallWeChatDto.setAppId(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appId")); |
| | | shopSmallWeChatDto.setAppSecret(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appSecret")); |
| | | } else { |
| | | shopSmallWeChatDto = smallWeChatDtos.get(0); |
| | | } |
| | | |
| | | PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto(); |
| | | paymentPoolValueDto.setPpId(paymentPoolId); |
| | |
| | | paramIn.put("sign", sign); |
| | | |
| | | String requestStr = paramIn.toJSONString(); |
| | | doSaveOnlinePay(shopSmallWeChatDto, "-1", orderNum, feeName, payAmount, OnlinePayDto.STATE_WAIT, "待支付"); |
| | | |
| | | String response = HttpConnectUtils.sendHttpSRequest(BasePay.BASE_URL + "/standard/scanPay", requestStr, "JSON", null); |
| | | System.out.println("\n响应报文:" + response); |
| | |
| | | JSONObject resData = paramOut.getJSONObject("data"); |
| | | |
| | | if ("00".equals(resData.getString("finRetcode"))) { |
| | | doUpdateOnlinePay(orderNum, OnlinePayDto.STATE_COMPILE, "支付成功"); |
| | | |
| | | return new ResultVo(ResultVo.CODE_OK, "成功"); |
| | | } else { |
| | | return new ResultVo(ResultVo.CODE_ERROR, "等待用户支付中"); |
| | |
| | | JSONObject resData = paramOut.getJSONObject("data"); |
| | | |
| | | if ("00".equals(resData.getString("finRetcode"))) { |
| | | doUpdateOnlinePay(orderNum, OnlinePayDto.STATE_COMPILE, "支付成功"); |
| | | |
| | | return new ResultVo(ResultVo.CODE_OK, "成功"); |
| | | } else { |
| | | return new ResultVo(ResultVo.CODE_ERROR, "等待用户支付中"); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void doSaveOnlinePay(SmallWeChatDto smallWeChatDto, String openId, String orderId, String feeName, double money, String state, String message) { |
| | | OnlinePayPo onlinePayPo = new OnlinePayPo(); |
| | | onlinePayPo.setAppId(smallWeChatDto.getAppId()); |
| | | onlinePayPo.setMchId(smallWeChatDto.getMchId()); |
| | | onlinePayPo.setMessage(message.length() > 1000 ? message.substring(0, 1000) : message); |
| | | onlinePayPo.setOpenId(openId); |
| | | onlinePayPo.setOrderId(orderId); |
| | | onlinePayPo.setPayId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_orderId)); |
| | | onlinePayPo.setPayName(feeName); |
| | | onlinePayPo.setRefundFee("0"); |
| | | onlinePayPo.setState(state); |
| | | onlinePayPo.setTotalFee(money + ""); |
| | | onlinePayPo.setTransactionId(orderId); |
| | | onlinePayV1InnerServiceSMOImpl.saveOnlinePay(onlinePayPo); |
| | | } |
| | | |
| | | private void doUpdateOnlinePay(String orderId, String state, String message) { |
| | | OnlinePayPo onlinePayPo = new OnlinePayPo(); |
| | | onlinePayPo.setMessage(message.length() > 1000 ? message.substring(0, 1000) : message); |
| | | onlinePayPo.setOrderId(orderId); |
| | | onlinePayPo.setState(state); |
| | | onlinePayV1InnerServiceSMOImpl.updateOnlinePay(onlinePayPo); |
| | | } |
| | | } |