7 changed files with 152 additions and 37 deletions
@ -1,28 +0,0 @@ |
|||
package com.yxt.yythmall.biz.wx.invoice; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.yythmall.biz.wx.WxConfig; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2024/3/15 16:09 |
|||
*/ |
|||
public class ElectronicInvoice { |
|||
private static final String AUTHORIZATION_PAGE="https://api.weixin.qq.com/card/invoice/getauthurl?access_token=ACCESS_TOKEN"; |
|||
|
|||
public ResultBean getAuthorizationPage(String appid, String secret) { |
|||
ResultBean rb= ResultBean.fireFail(); |
|||
String url = AUTHORIZATION_PAGE.replace("ACCESS_TOKEN", WxConfig.wxAccessToken()); |
|||
Map<String, String> map = new HashMap<>(); |
|||
RequestMes res = new RestTemplate().postForObject(url,map,RequestMes.class); |
|||
if(!res.getErrcode().equals("0")){ |
|||
return rb; |
|||
} |
|||
return rb; |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.yxt.yythmall.biz.wx.invoice; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.yythmall.api.ordorder.OrdOrder; |
|||
import com.yxt.yythmall.biz.ordorder.OrdOrderService; |
|||
import com.yxt.yythmall.biz.wx.RequestMes; |
|||
import com.yxt.yythmall.biz.wx.WxConfig; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2024/3/15 16:09 |
|||
*/ |
|||
@Service |
|||
public class ElectronicInvoiceService { |
|||
@Autowired |
|||
OrdOrderService ordOrderService; |
|||
private static final String AUTHORIZATION_PAGE="https://api.weixin.qq.com/card/invoice/getauthurl?access_token=ACCESS_TOKEN"; |
|||
|
|||
|
|||
public ResultBean getAuthorizationPage(String sid) { |
|||
ResultBean rb= ResultBean.fireFail(); |
|||
OrdOrder order=ordOrderService.getOne(new QueryWrapper<OrdOrder>().eq("sid",sid)); |
|||
String url = AUTHORIZATION_PAGE.replace("ACCESS_TOKEN", WxConfig.wxAccessToken()); |
|||
Map<String, String> map = new HashMap<>(); |
|||
long timestamp = System.currentTimeMillis() / 1000; |
|||
map.put("s_pappid",WxConfig.getSPAppId()); |
|||
map.put("order_id",order.getOutTradeNo()); |
|||
map.put("money",order.getTotalTee()); |
|||
map.put("timestamp",String.valueOf(timestamp)); |
|||
map.put("source","wxa"); |
|||
map.put("redirect_url",""); |
|||
map.put("ticket",WxConfig.wxTicket()); |
|||
map.put("type","1"); |
|||
RequestMes res = new RestTemplate().postForObject(url,map,RequestMes.class); |
|||
if(!res.getErrcode().equals("0")){ |
|||
return rb.setCode(res.getErrcode()).setMsg(res.getErrmsg()); |
|||
} |
|||
return rb.success().setData(res); |
|||
} |
|||
} |
Loading…
Reference in new issue