spring boot + uniapp 微信公眾號 jsapi 支付

后端支付類

package com.ruoyi.coupon.payment;import com.google.gson.Gson;
import com.ruoyi.coupon.payment.dto.PayParamJsapiDto;
import com.ruoyi.coupon.payment.dto.RefundParam;
import com.ruoyi.coupon.service.ICouponConfigService;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig;import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.jsapi.JsapiService;
import com.wechat.pay.java.service.payments.jsapi.model.*;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.payments.model.TransactionAmount;
import com.wechat.pay.java.service.refund.RefundService;
import com.wechat.pay.java.service.refund.model.AmountReq;
import com.wechat.pay.java.service.refund.model.CreateRequest;
import com.wechat.pay.java.service.refund.model.Refund;
import com.wechat.pay.java.service.refund.model.RefundNotification;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.*;
import java.util.*;@Service
public class WeChatJsapiPayment {private static final String mchId = "165"; // 商戶號private static final String mchSerialNo = "12C5F95"; // 商戶證書序列號//商戶私鑰 //https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay3_1.shtmlprivate static final String privateKey = "-----BEGIN PRIVATE KEY-----" +"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDOo7rFC6cJF+kd" +"7cPFkmrHlbdihgznK2u5v2CDoSClwrY1hGE81VJMHjHic03Ky0Hx1lCZh+hOCZXk" +"4mnTnbeUlvq/6E6I6gexsM9ww6nz0YbPRZuNPPxBmP1rqKzlZO7LiLvIwg8x3cOr" +"qB4uPCo5Eh0Ty3r1kygfEXDyWEHWRYx1JVesmcxBp2n8HkfIpNA3tyPFnTFJEI4W" +"/7T4ScoSlRRUsYNrg0oox683HgFXWE9fAJloyt35EHPoBEx6gUGKC9Gm1luJNrSb" +"9GAQCPLVgtr3hq0kQHvVKcKsgpzPJA5G20bTM1X9Yo/nr+rt+HFZpbaNvviuhXg7" +"EvajkeprAgMBAAECggEAUXVTzBei2j/VwtmW4kys0U7gwvMLJRoF1mxt9JXRE+cl" +"AwXTezKwxZblnVpM4VOtBFOy5EMiPZkjwN3MUAKNewLliD9grjJrpA2KSO6pEZeY" +"aB8NiejvnEBeLlGJDsjyJcQaGrL9YHAGkaWteBZ5opPUaJg/OY2wNEcg2jgWhAui" +"eTqocUEnbowDCFlpHEJmAJKxuaLaV39Wad1jKs9N9CiqYyVNfNoeZJ7LSHekrz6v" +"SOVD8nz3y/1evf4LqkaIjLJwTS9UXVZuKjlyLcjsEpGf4X3cZ7hI/wJEqXDqKSL8" +"cgbnkZTI6YI32ukAIne/d3AOsRkbYomR26g3cqpeqQKBgQD9bxwYm+Z73SrfCJte" +"8Tj9ejrBWcAU1r8p1uu7kiL2gU0RVxwzBe0QNhLUybP5ciONzAtkS6/NPLkHU6HQ" +"frb9JqoipC6LT7c2R4kR+4wcLH9lbiscljPUji04sEEMzUrLWjwcAwLjlCNbqZ4m" +"UJ2y4skFFzVEa6a8uO7qX5qFpQKBgQDQu1Sgrhb2Yby/YuJyq2j8k5BRiHcjLmUI" +"Pi1uIq0lUof4F61EkFuua+bsr+oaiQxhqKIkPbURnjdkEG2bC5K/n+f2BbOFOfSz" +"14ygBoZaRGZvoS56xOETh9ao9sLCsQJgz1E3gwYpAIbh6DBvoU8w0prL/O0gbAC/" +"CywSvL1SzwKBgHJ413X+JTNZiN3JI3TU/Grx5Mwk3/AJt7sMStokfgpeCROGB0S8" +"roGeCw92NAa+GXUY7yRUU4oenWzDx9lHAxyBdGPFSQi/7v9jfHRU7MplBv4nru1w" +"ouSle6OZaSiBKgGENpZofcuRxA7JJJgl3bVJXocgHn1TKrMfzTqsCD3JAoGBAK8S";// 你的微信支付平臺證書private static final String apiV3Key = "f2f4667bfeab441";//公眾號appIdprivate static final String appid="wx29d5";private static final String secret = "58be861a9f6";public static Map<String,RSAAutoCertificateConfig> config=new HashMap<>();@Autowiredprivate ICouponConfigService couponConfigService;/*** 獲取jsapi服務類* @return*/public JsapiService getJsapiService(){RSAAutoCertificateConfig rsaAutoCertificateConfig = config.get(this.mchId);if(rsaAutoCertificateConfig == null){RSAAutoCertificateConfig build = new RSAAutoCertificateConfig.Builder().merchantId(this.mchId).privateKey(this.privateKey)//.privateKeyFromPath(WxConfig.privateKeyPath).merchantSerialNumber(this.mchSerialNo).apiV3Key(this.apiV3Key).build();config.put(this.mchId,build);rsaAutoCertificateConfig = build;}JsapiService service = new JsapiService.Builder().config(rsaAutoCertificateConfig).build();return service;}/*** 進行支付* @param payParam* @return*/public String pay(PayParamJsapiDto payParam) {String apiUrl = couponConfigService.getValue("online_domain");JsapiService jsapiService = getJsapiService();PrepayRequest request = new PrepayRequest();Amount amount = new Amount();amount.setTotal((int)(Double.parseDouble(payParam.getAmount().toPlainString())*100));//amount.setTotal(1);request.setAmount(amount);request.setAppid(payParam.getAppid());request.setMchid(payParam.getMerchantId());request.setDescription(payParam.getDescription());request.setNotifyUrl(apiUrl +"api" + "/payment/weChatOfficialAccounts/payment/notify");//這個回調url必須是https開頭的request.setOutTradeNo(payParam.getOutTradeNo());Payer payer = new Payer();payer.setOpenid(payParam.getOpenid());request.setPayer(payer);//設置回傳參數Gson gson=new Gson();request.setAttach(gson.toJson(payParam.getParam()));PrepayResponse prepay = jsapiService.prepay(request);String prepayid=prepay.getPrepayId();return prepayid;}/** 商戶訂單號查詢訂單 */public Transaction queryOrderByOutTradeNo(String orderNum) {JsapiService jsapiService = getJsapiService();QueryOrderByOutTradeNoRequest request = new QueryOrderByOutTradeNoRequest();request.setOutTradeNo(orderNum);// 調用request.setXxx(val)設置所需參數,具體參數可見Request定義// 調用接口return jsapiService.queryOrderByOutTradeNo(request);}/*** 支付成功驗簽* @param request* @return*/public Map paySuccessCheck(HttpServletRequest request) {/*Config config =new RSAAutoCertificateConfig.Builder().merchantId(dto.getWechatpayMchid()).privateKey(dto.getWechatpayPrivatekey()).merchantSerialNumber(dto.getWechatpayMchserialno()).apiV3Key(dto.getWechatpayApiv3key()).build();*/RSAAutoCertificateConfig config1 = config.get(this.mchId);if(config1 == null){RSAAutoCertificateConfig build = new RSAAutoCertificateConfig.Builder().merchantId(this.mchId).privateKey(this.privateKey)//.privateKeyFromPath(WxConfig.privateKeyPath).merchantSerialNumber(this.mchSerialNo).apiV3Key(this.apiV3Key).build();config.put(this.mchId,build);config1 = build;}// 從請求頭中獲取信息String timestamp                        = request.getHeader("Wechatpay-Timestamp");String nonce                            = request.getHeader("Wechatpay-Nonce");String signature                        = request.getHeader("Wechatpay-Signature");String singType                         = request.getHeader("Wechatpay-Signature-Type");String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");String requestBody = getRequestBody(request);// 構造 RequestParamRequestParam requestParam = new RequestParam.Builder().serialNumber(wechatPayCertificateSerialNumber).nonce(nonce).signature(signature).signType(singType).timestamp(timestamp).body(requestBody).build();// 初始化解析器 NotificationParserNotificationParser parser = new NotificationParser((NotificationConfig) config1);// 這個Transaction是微信包里面的Transaction decryptObject = parser.parse(requestParam, Transaction.class);TransactionAmount amount = decryptObject.getAmount();String outTradeNo = decryptObject.getOutTradeNo();String attach = decryptObject.getAttach();Map map=new HashMap();map.put("amount",amount.getTotal());map.put("outTradeNo",outTradeNo);map.put("attach",attach);return map;}// 獲取請求頭里的數據private String getRequestBody(HttpServletRequest request) {StringBuffer sb = new StringBuffer();try (ServletInputStream inputStream = request.getInputStream();BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));) {String line;while ((line = reader.readLine()) != null) {sb.append(line);}} catch (IOException e) {System.out.println("讀取數據流異常:"+e);}return sb.toString();}/*** 組裝支付參數* @param prepayId* @return*/public Map getPayParameter(String prepayId){Map<String,String> map=new HashMap<>();map.put("appId",this.appid);map.put("timeStamp",String.valueOf(new Date().getTime()));map.put("nonceStr", UUID.randomUUID().toString().replace("-",""));map.put("package","prepay_id="+prepayId);map.put("signType","RSA");String s = map.get("appId") + "\n" + map.get("timeStamp") + "\n" + map.get("nonceStr") + "\n" + map.get("package") + "\n";try {PrivateKey privateKey1 = PemUtil.loadPrivateKeyFromString(this.privateKey);Signature sign = Signature.getInstance("SHA256withRSA");sign.initSign(privateKey1);sign.update(s.getBytes("utf-8"));String string = Base64.getEncoder().encodeToString(sign.sign());map.put("paySign",string);return map;} catch (NoSuchAlgorithmException e) {e.printStackTrace();} catch (InvalidKeyException e) {e.printStackTrace();} catch (UnsupportedEncodingException e) {e.printStackTrace();} catch (SignatureException e) {e.printStackTrace();}return null;}/*** 公眾號 code 換取 openid* @param code* @return*/public String getOpenId(String code) {OkHttpClient client = new OkHttpClient();Request request = new Request.Builder().url("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + this.appid + "&secret=" + this.secret + "&code=" + code + "&grant_type=authorization_code").build();try {Response response = client.newCall(request).execute();String string = response.body().string();//System.out.println(string);Gson gson = new Gson();Map map = gson.fromJson(string, Map.class);/*** {* 	"session_key": "G4YmjKXmPsqjDFdtcjp/9A==",* 	"openid": "o27Z36yx16I4EF84dpTslNdVhsQY"* }*/return (String) map.get("openid");} catch (IOException e) {e.printStackTrace();}return null;}/*** 申請退款* @param refundParam*/public void refundOrder(RefundParam refundParam) {String apiUrl = couponConfigService.getValue("online_domain");BigDecimal bigDecimal = new BigDecimal(100);int total = bigDecimal.multiply(new BigDecimal(refundParam.getTotal())).intValue();int refund = bigDecimal.multiply(new BigDecimal(refundParam.getRefund())).intValue();Config config =new RSAAutoCertificateConfig.Builder().merchantId(mchId).privateKey(privateKey).merchantSerialNumber(mchSerialNo).apiV3Key(apiV3Key).build();RefundService service = new RefundService.Builder().config(config).build();//生成隨機退款訂單號String s = UUID.randomUUID().toString().replace("-","");CreateRequest request = new CreateRequest();//金額信息AmountReq amount = new AmountReq();amount.setCurrency("CNY");amount.setTotal(Long.valueOf(total));amount.setRefund(Long.valueOf(refund));request.setAmount(amount);request.setOutTradeNo(refundParam.getOutTradeNo());request.setOutRefundNo(s);//request.setNotifyUrl("http://egevdr.natappfree.cc" + "/payment/weChatPay/refund/notify");request.setNotifyUrl(apiUrl +"api" + "/payment/weChatOfficialAccounts/refund/notify");//發送請求Refund refund1 = service.create(request);}public Map refundSuccessCheck(HttpServletRequest request) {Config config =new RSAAutoCertificateConfig.Builder().merchantId(mchId).privateKey(privateKey).merchantSerialNumber(mchSerialNo).apiV3Key(apiV3Key).build();// 從請求頭中獲取信息String timestamp                        = request.getHeader("Wechatpay-Timestamp");String nonce                            = request.getHeader("Wechatpay-Nonce");String signature                        = request.getHeader("Wechatpay-Signature");String singType                         = request.getHeader("Wechatpay-Signature-Type");String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");String requestBody = getRequestBody(request);// 構造 RequestParamRequestParam requestParam = new RequestParam.Builder().serialNumber(wechatPayCertificateSerialNumber).nonce(nonce).signature(signature).signType(singType).timestamp(timestamp).body(requestBody).build();// 初始化解析器 NotificationParserNotificationParser parser = new NotificationParser((NotificationConfig) config);// 這個Transaction是微信包里面的RefundNotification decryptObject = parser.parse(requestParam, RefundNotification.class);com.wechat.pay.java.service.refund.model.Amount amount = decryptObject.getAmount();String outTradeNo = decryptObject.getOutTradeNo();Map map=new HashMap();map.put("amount",amount.getTotal());map.put("outTradeNo",outTradeNo);return map;}
}

后端下單

String openId=weChatJsapiPayment.getOpenId(code);PayParamJsapiDto payParam = new PayParamJsapiDto();//payParam.setSubject(StringUtils.isBlank(byId2.getGoodsName())?byId2.getGoodsSuffixName():byId2.getGoodsName());payParam.setDescription(StringUtils.isBlank(byId2.getGoodsName())?byId2.getGoodsSuffixName():byId2.getGoodsName());payParam.setOutTradeNo(couponOrder.getOrderNum());//payParam.setAmount(new BigDecimal("0.01"));payParam.setAmount(new BigDecimal(price.toString()));payParam.setAppid("wx29d50");payParam.setMerchantId("1651");payParam.setOpenid(openId);String pay = weChatJsapiPayment.pay(payParam);Map payParameter = weChatJsapiPayment.getPayParameter(pay);

后端退款

RefundParam param=new RefundParam();param.setOutTradeNo(byId.getOrderNum());param.setBody("卡券權益退款");param.setRefund(byId.getPayMoney().toString());param.setTotal(byId.getPayMoney().toString());//微信退款weChatJsapiPayment.refundOrder(param);

下單和退款的dto

package com.ruoyi.coupon.payment.dto;import lombok.Data;/*** 退款參數封裝*/
@Data
public class RefundParam {//訂單號private  String outTradeNo;//本次退款金額金額private  String refund;//訂單總金額private  String total;//備注private  String body;
}
package com.ruoyi.coupon.payment.dto;import lombok.Data;import java.math.BigDecimal;
@Data
public class PayParamJsapiDto {private String appid;private String merchantId;//支付描述private String description;private String openid;private String outTradeNo;//需支付金額private BigDecimal amount;private PassbackParamsJsapiDto param;
}
package com.ruoyi.coupon.payment.dto;import lombok.Data;@Data
public class PassbackParamsJsapiDto {
}

后端支付回調類

package com.ruoyi.api.controller.coupon.payment.rest;import com.ruoyi.coupon.payment.WeChatJsapiPayment;
import com.ruoyi.coupon.payment.WeChatPayment;
import com.ruoyi.coupon.payment.event.PaymentEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;/*** 商城支付項微信支付的回調接口*/
@Slf4j
@RestController
@RequestMapping("/payment/weChatOfficialAccounts")
public class WeChatOfficialAccountsNotify {@Autowiredprivate ApplicationEventPublisher publisher;@Autowiredprivate WeChatJsapiPayment weChatJsapiPayment;/*** 微信支付/充值回調*/@PostMapping("/payment/notify")public ResponseEntity.BodyBuilder  renotify(HttpServletRequest request) {Map map = weChatJsapiPayment.paySuccessCheck(request);Integer amount = (Integer)map.get("amount");String outTradeNo = (String)map.get("outTradeNo");String attach = (String)map.get("attach");Map<String, Object> map1 = new HashMap<>();//將附加信息 attach 解析到 map1 中,因為現在沒有傳遞任何參數,所以沒有解析BigDecimal divide = new BigDecimal(amount).divide(new BigDecimal("100"));publisher.publishEvent(new PaymentEvent(this, outTradeNo,0,map1,divide.toString()));return ResponseEntity.status(HttpStatus.OK);}/*** 微信退款回調*/@PostMapping("/refund/notify")public ResponseEntity.BodyBuilder parseRefundNotifyResult(HttpServletRequest request) {Map map = weChatJsapiPayment.refundSuccessCheck(request);Long amount = (Long)map.get("amount");String outTradeNo = (String)map.get("outTradeNo");BigDecimal divide = new BigDecimal(amount).divide(new BigDecimal("100"));publisher.publishEvent(new PaymentEvent(this, outTradeNo,1,null,divide.toString()));return ResponseEntity.status(HttpStatus.OK);}
}

回調參數封裝

package com.ruoyi.coupon.payment.event;import org.springframework.context.ApplicationEvent;
import org.springframework.core.annotation.Order;import java.util.Map;/*** 商城支付項的支付成功和退款成功事件*/
@Order(500)
public class PaymentEvent extends ApplicationEvent {private static final long serialVersionUID = 1L;private final String orderId;private final Integer type;//0:支付成功 1:退款成功private final Map passbackParams; //回傳參數private final String actionMoney; //支付或退款金額public PaymentEvent(Object source, String orderId, Integer type, Map passbackParams,String actionMoney) {super(source);this.orderId=orderId;this.type=type;this.passbackParams=passbackParams;this.actionMoney=actionMoney;}public String getOrderId() {return this.orderId;}public Integer getType() {return this.type;}public Map getPassbackParams() {return this.passbackParams;}public String getActionMoney() {return this.actionMoney;}
}

uniapp端獲取公眾號code

//獲取codeuni.navigateTo({url:"/pages/WeChatOfficialAccounts/getCode"})
<template><view>獲取信息中...</view>
</template><script>export default {data() {return {code:''}},onLoad(){let appid = 'wx29d501';let redirect_uri='http://qy.gsjf.cc/h5/#/pages/WeChatOfficialAccounts/getCode'redirect_uri  = encodeURIComponent(redirect_uri)//console.log('redirect_uri', redirect_uri);let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect`;this.code = this.getUrlCode().code;if (this.code == null || this.code === '' ) {//window.location.href = url;}else{//獲取到code后的邏輯console.log('code', this.code);/*let pages = getCurrentPages(); // 當前頁頁?實例console.log('pages',pages);//let nowPage = pages[pages.length -1]; //當前頁?實例let prevPage = pages[pages.length -2]; // 上一頁面實例let object ={code: this.code};prevPage.$vm.getCodeBack(object);*//* uni.navigateBack({  //uni.navigateTo跳轉的返回,默認1為返回上一級delta: 2}); */localStorage.setItem('weChatOfficialAccountsCode', this.code);window.history.go(-2);}},methods: {getUrlCode() { // 截取url中的code方法var url = location.searchvar theRequest = new Object()if (url.indexOf("?") != -1) {var str = url.substr(1)var strs = str.split("&");for (var i = 0; i < strs.length; i++) {theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])}}// console.log(theRequest)console.log(theRequest)return theRequest},}}
</script><style></style>

獲取code后,返回跳轉前頁面,在跳轉前頁面獲取code

onLoad() {const data = localStorage.getItem('weChatOfficialAccountsCode');if(data != null){this.getCodeBack(data);}else{//獲取codeuni.navigateTo({url:"/pages/WeChatOfficialAccounts/getCode"})}},onShow(){const data = localStorage.getItem('weChatOfficialAccountsCode');if(data != null){this.getCodeBack(data);}else{//獲取codeuni.navigateTo({url:"/pages/WeChatOfficialAccounts/getCode"})}},onUnload(){localStorage.removeItem('weChatOfficialAccountsCode');this.weChatOfficialAccountsCode=null;},

前端調起支付接口

npm install jweixin-module
localStorage.removeItem('weChatOfficialAccountsCode');this.weChatOfficialAccountsCode=null;let dataV=JSON.parse(res.data.payStrand)jweixin.config({debug: false,appId: dataV.appId,timestamp: dataV.timeStamp,nonceStr: dataV.nonceStr,signature: dataV.signature,jsApiList: ['chooseWXPay']});jweixin.ready(function() {jweixin.chooseWXPay({timestamp: dataV.timeStamp,nonceStr: dataV.nonceStr,package: dataV.package,signType: dataV.signType,paySign: dataV.paySign,success: function() {uni.showToast({title: '支付成功',icon: 'none'});},cancel: function(res) {uni.showToast({title: '支付失敗',icon: 'none'});},complete: function() {}});});

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/211692.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/211692.shtml
英文地址,請注明出處:http://en.pswp.cn/news/211692.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

FFmpeg抽取視頻h264數據重定向

根據視頻重定向技術解析中的 截獲解碼視頻流的思路&#xff0c;首先需要解決如何輸出視頻碼流的問題。 目前只針對h264碼流進行獲取&#xff0c;步驟如下&#xff1a; 打開mp4文件并創建一個空文件用于存儲H264數據 提取一路視頻流資源 循環讀取流中所有的包(AVPacket),為…

redis中使用pipeline批量處理請求提升系統性能

在操作數據庫時&#xff0c;為了加快程序的執行速度&#xff0c;在新增或更新數據時&#xff0c;可以通過批量提交的方式來減少應用和數據庫間的傳輸次數&#xff1b;在redis中也有這樣的技術實現批量處理&#xff0c;也就是管道——Pipeline。它也是通過批量提交數據的方式來實…

線程安全3--wait和notify

文章目錄 wait and notify&#xff08;等待通知機制notify補充 wait and notify&#xff08;等待通知機制 引入wait notify就是為了能夠從應用層面上&#xff0c;干預到多個不同線程代碼的執行順序&#xff0c;這里說的干預&#xff0c;不是影響系統的線程調度策略&#xff08…

uni-app應用設置 可以根據手機屏幕旋轉進行 (橫/豎) 屏切換

首先 我們打開項目的 manifest.json 在左側導航欄中找到 源碼視圖 然后找到 app-plus 配置 在下面加上 "orientation": [//豎屏正方向"portrait-primary",//豎屏反方向"portrait-secondary",//橫屏正方向"landscape-primary",//橫屏…

第57天:django學習(六)

模版之過濾器 語法&#xff1a; {{obj|filter__name:param}} 變量名字|過濾器名稱&#xff1a;變量 default 如果一個變量是false或者為空&#xff0c;使用給定的默認值。否則&#xff0c;使用變量的值。例如&#xff1a; {{ value|default:"nothing"}} length …

IDEA啟動應用時報錯:錯誤: 找不到或無法加載主類 @C:\Users\xxx\AppData\Local\Temp\idea_arg_filexxx

IDEA啟動應用時報錯&#xff0c;詳細錯誤消息如下&#xff1a; C:\devel\jdk1.8.0_201\bin\java.exe -agentlib:jdwptransportdt_socket,address127.0.0.1:65267,suspendy,servern -XX:TieredStopAtLevel1 -noverify -Dspring.output.ansi.enabledalways -Dcom.sun.management…

基于以太坊的智能合約開發Solidity(事件日志篇)

//聲明版本號&#xff08;程序中的版本號要和編譯器版本號一致&#xff09; pragma solidity ^0.5.17; //合約 contract EventTest {//狀態變量uint public Variable;//構造函數constructor() public{Variable 100;}event ValueChanged(uint newValue); //事件聲明event Log(…

ElasticSearch之cat plugins API

命令樣例如下&#xff1a; curl -X GET "https://localhost:9200/_cat/plugins?vtrue&pretty" --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPHQBEs5*lo7F9"執行結果輸出如下&#xff1a; name component version…

class064 Dijkstra算法、分層圖最短路【算法】

class064 Dijkstra算法、分層圖最短路【算法】 算法講解064【必備】Dijkstra算法、分層圖最短路 code1 743. 網絡延遲時間 // Dijkstra算法模版&#xff08;Leetcode&#xff09; // 網絡延遲時間 // 有 n 個網絡節點&#xff0c;標記為 1 到 n // 給你一個列表 times&…

法律服務網站建設效果如何

律師事務所及法律知識咨詢機構等往往是眾多人群需求的服務&#xff0c;服務多樣化及內容多元化&#xff0c;市場中也有大量品牌&#xff0c;在實際消費服務中大多以本地事務所為主&#xff0c;而線上咨詢服務則一般沒有區域限制&#xff0c;同行增多及人們知識獲取渠道增加&…

C++-引用和指針區別

文章目錄 1.變量的組成2.指針2.1 定義2.2 使用指針操作變量2.3 為什么使用指針 3.引用3.1 定義3.2 引用注意事項 4.引用和指針的區別 1.變量的組成 變量的組成&#xff1a;變量地址&#xff0c;變量名&#xff0c;變量值 例&#xff1a; int i 12;2.指針 2.1 定義 指針用于存…

如何為游戲角色3D模型設置紋理貼圖

在線工具推薦&#xff1a; 3D數字孿生場景編輯器 - GLTF/GLB材質紋理編輯器 - 3D模型在線轉換 - Three.js AI自動紋理開發包 - YOLO 虛幻合成數據生成器 - 三維模型預覽圖生成器 - 3D模型語義搜索引擎 當談到游戲角色的3D模型風格時&#xff0c;有幾種不同的風格&#xf…

Mybatis中的查詢操作

單表查詢 單表查詢在《初始Mybatis》中已經介紹過&#xff0c;這里就不在介紹了。咱們這里只說單表查詢中的“like查詢”。like查詢單獨使用#{}報錯 <select id"selectByKeyword" resultType"com.example.demo.entity.Userinfo">select * from use…

計網Lesson8 - NAT技術與鏈路層概述

文章目錄 NAT 技術1. 因特網的接入方式2. 公網和私網3. NAT 技術 鏈路層1. 數據鏈路層概述2. 數據鏈路層的三個問題2.1 封裝成幀2.2 透明傳輸2.3 差錯檢測 NAT 技術 1. 因特網的接入方式 光貓將電信號轉換為數字信號發送給路由器 光纖入戶 光纖傳遞的就是數字信號&#xff0c…

python+pytest接口自動化(12)-自動化用例編寫思路 (使用pytest編寫一個測試腳本)

經過之前的學習鋪墊&#xff0c;我們嘗試著利用pytest框架編寫一條接口自動化測試用例&#xff0c;來厘清接口自動化用例編寫的思路。 我們在百度搜索天氣查詢&#xff0c;會出現如下圖所示結果&#xff1a; 接下來&#xff0c;我們以該天氣查詢接口為例&#xff0c;編寫接口測…

錯題總結(三)

1.寫代碼將三個整數數按從大到小輸出。 例如&#xff1a; 輸入&#xff1a;2 3 1 輸出&#xff1a;3 2 1 int main() {int a 0;int b 0;int c 0;int tep 0;scanf("%d%d%d", &a, &b, &c);if (a < b){tep a;a b;b tep;}if (b < c){tep b…

每日一練2023.12.9—— 矩陣A乘以B【PTA】

題目鏈接&#xff1a;L1-048 矩陣A乘以B 題目要求&#xff1a; 給定兩個矩陣A和B&#xff0c;要求你計算它們的乘積矩陣AB。需要注意的是&#xff0c;只有規模匹配的矩陣才可以相乘。即若A有Ra?行、Ca?列&#xff0c;B有Rb?行、Cb?列&#xff0c;則只有Ca?與Rb?相等時&a…

Linux Shell 基礎命令

Linux 是一個開源的操作系統&#xff0c;其命令行界面是它的重要組成部分。在這個界面下&#xff0c;Shell 是一個能夠與操作系統進行交互的工具。Shell 是一種程序&#xff0c;它能夠接收用戶輸入的命令&#xff0c;并將這些命令發送到操作系統中進行處理。 在 Linux 中&…

Docker實戰筆記 三 Docker私有庫

1.拉取私有庫image rootcenots-7.5:/root#docker pull registry Using default tag: latest latest: Pulling from library/registry c926b61bad3b: Pull complete 5501dced60f8: Pull complete e875fe5e6b9c: Pull complete 21f4bf2f86f9: Pull complete 98513cca25bb: P…

VINS-MONO代碼解讀5----vins_estimator(marginalization部分)

文章目錄 0. 前言1.1 Marginalization Pipiline 1. marg factor構建1.1 變量及維度理解1.2 IMUFactor1.3 ProjectionTdFactor(ProjectionFactor)1.4 MarginalizationFactor( e p e_p ep?推導更新&#xff0c;FEJ解決的問題)1.4.1 先驗殘差的更新1.4.2 先驗Jacobian的更新 2. R…