新增:生成订单核销小程序码

This commit is contained in:
gxwebsoft
2024-06-03 21:40:10 +08:00
parent 410c149120
commit 340b1cbe3a
3 changed files with 25 additions and 7 deletions

View File

@@ -55,7 +55,6 @@ public class RequestUtil {
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
System.out.println("jsonObject = " + jsonObject);
final String data = jsonObject.getString("data");
return JSONObject.parseObject(data, User.class);
} catch (Exception e) {

View File

@@ -80,7 +80,6 @@ public class TenantController extends BaseController {
@ApiOperation("添加租户")
@PostMapping()
public ApiResult<?> save(@RequestBody Tenant tenant) {
System.out.println("tenant = " + tenant);
if (tenantService.save(tenant)) {
return success("添加成功");
}

View File

@@ -16,10 +16,7 @@ import com.gxwebsoft.common.core.security.JwtUtil;
import com.gxwebsoft.common.core.utils.CommonUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.LoginRecord;
import com.gxwebsoft.common.system.entity.Role;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.entity.UserRole;
import com.gxwebsoft.common.system.entity.*;
import com.gxwebsoft.common.system.param.UserParam;
import com.gxwebsoft.common.system.result.LoginResult;
import com.gxwebsoft.common.system.service.*;
@@ -229,7 +226,6 @@ public class WxLoginController extends BaseController {
if (value != null) {
// 解析access_token
JSONObject response = JSON.parseObject(value);
System.out.println("response = " + response);
// return response.getString("access_token");
}
// 微信获取凭证接口
@@ -307,6 +303,30 @@ public class WxLoginController extends BaseController {
return fail("获取失败",null);
}
@ApiOperation("获取微信小程序码-订单核销码")
@GetMapping("/getOrderQRCode/{orderNo}")
public ApiResult<?> getOrderQRCode(@PathVariable("orderNo") String orderNo) {
String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken();
final HashMap<String, Object> map = new HashMap<>();
map.put("path","/package/admin/order-scan?orderNo=".concat(orderNo));
map.put("env_version","trial");
// 获取图片 Buffer
byte[] qrCode = HttpRequest.post(apiUrl)
.body(JSON.toJSONString(map))
.execute().bodyBytes();
// 保存的文件名称
final String fileName = CommonUtil.randomUUID8().concat(".png");
// 保存路径
String filePath = getUploadDir().concat("qrcode/") + fileName;
File file = FileUtil.writeBytes(qrCode, filePath);
if(file != null){
config.setFileServer("https://file.gxwebsoft.com");
return success(config.getFileServer().concat("/qrcode/").concat(fileName));
}
return fail("获取失败",null);
}
/**
* 文件上传位置(服务器)
*/