| | |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.CallApiServiceFactory; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.community.CommunityDto; |
| | | import com.java110.intf.community.ICommunityV1InnerServiceSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.WechatConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 扫码付 |
| | |
| | | @Java110Cmd(serviceCode = "payment.qrCodePayment") |
| | | public class QrCodePaymentCmd extends AbstractServiceCmdListener { |
| | | private static Logger logger = LoggerFactory.getLogger(QrCodePaymentCmd.class); |
| | | |
| | | @Autowired |
| | | private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl; |
| | | |
| | | |
| | | private IQrCodePaymentSMO qrCodePaymentSMOImpl; |
| | |
| | | throw new IllegalArgumentException("授权码错误"); |
| | | } |
| | | |
| | | int pre = Integer.parseInt(authCode.substring(0, 2)); |
| | | if (pre > 24 && pre < 31) { // 支付宝 |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeAliPaymentAdapt", IQrCodePaymentSMO.class); |
| | | String payQrAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_QR_ADAPT); |
| | | |
| | | if (StringUtil.isEmpty(payQrAdapt)) { |
| | | int pre = Integer.parseInt(authCode.substring(0, 2)); |
| | | if (pre > 24 && pre < 31) { // 支付宝 |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeAliPaymentAdapt", IQrCodePaymentSMO.class); |
| | | } else { |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeWechatPaymentAdapt", IQrCodePaymentSMO.class); |
| | | } |
| | | } else { |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeWechatPaymentAdapt", IQrCodePaymentSMO.class); |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean(payQrAdapt, IQrCodePaymentSMO.class); |
| | | } |
| | | |
| | | CommunityDto communityDto = new CommunityDto(); |
| | | communityDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<CommunityDto> communityDtos = communityV1InnerServiceSMOImpl.queryCommunitys(communityDto); |
| | | |
| | | Assert.listOnlyOne(communityDtos, "小区不存在"); |
| | | |
| | | String feeName = communityDtos.get(0).getName() + "-" + reqJson.getString("payerObjName") + "-" + reqJson.getString("feeName"); |
| | | |
| | | ResultVo resultVo = null; |
| | | try { |
| | | resultVo = qrCodePaymentSMOImpl.pay(reqJson.getString("communityId"), orderId, receivedAmount, authCode, ""); |
| | | resultVo = qrCodePaymentSMOImpl.pay(reqJson.getString("communityId"), orderId, receivedAmount, authCode, feeName); |
| | | } catch (Exception e) { |
| | | logger.error("异常了", e); |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.error(e.getLocalizedMessage())); |
| | |
| | | } |
| | | logger.debug("适配器返回结果:" + resultVo.toString()); |
| | | if (ResultVo.CODE_OK != resultVo.getCode()) { |
| | | reqJson.put("orderId", orderId); |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.error(resultVo.getMsg(), reqJson)); |
| | | return; |
| | | } |
| | | String appId = cmdDataFlowContext.getReqHeaders().get(CommonConstant.APP_ID); |
| | | String userId = cmdDataFlowContext.getReqHeaders().get(CommonConstant.USER_ID); |
| | | JSONObject paramOut = CallApiServiceFactory.postForApi(appId, reqJson, "fee.payFee", JSONObject.class, userId); |
| | | cmdDataFlowContext.setResponseEntity(new ResponseEntity(paramOut.toJSONString(), HttpStatus.OK)); |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(paramOut)); |
| | | } |
| | | |
| | | } |