|
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.net.url.UrlBuilder;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -39,10 +40,14 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -85,10 +90,16 @@ public class WxController extends BaseController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation("获取二维码")
|
|
|
- @RequestMapping(value = "getwxQrCode", method = RequestMethod.POST)
|
|
|
- public String getWxQrCodeUtil(@RequestBody JSONObject param) {
|
|
|
- String cOpenId = param.getString("cOpenId");
|
|
|
- return wxQrCodeUtil.getWxQrcode(cOpenId);
|
|
|
+// @RequestMapping(value = "getwxQrCode", method = RequestMethod.POST)
|
|
|
+// public String getWxQrCodeUtil(@RequestBody JSONObject param) throws IOException {
|
|
|
+// String cOpenId = param.getString("cOpenId");
|
|
|
+// return wxQrCodeUtil.generateQRCode(null,null,null);
|
|
|
+// }
|
|
|
+ //生成小程序码方式
|
|
|
+ @PostMapping(value="getwxQrCode",produces = MediaType.IMAGE_JPEG_VALUE)
|
|
|
+ public byte[] inviteCode(@RequestParam ("inviteUserId")String inviteUserId) throws WxErrorException {
|
|
|
+ File file=wxMaService.getQrcodeService().createWxaCodeUnlimit(inviteUserId,null,300,true,null,true);
|
|
|
+ return FileUtil.readBytes(file);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -212,7 +223,7 @@ public class WxController extends BaseController {
|
|
|
@Log(title = "小程序登录", businessType = BusinessType.OTHER)
|
|
|
@PostMapping("/login")
|
|
|
public R<Object> login(@RequestParam("code") String code, @RequestParam("encryptedData") String encryptedData,
|
|
|
- @RequestParam("iv") String iv) {
|
|
|
+ @RequestParam("iv") String iv, @RequestParam(required = false, value = "parentOpenId") String parentOpenId) {
|
|
|
try {
|
|
|
// 调用微信 API 获取用户的 openid 和 session_key
|
|
|
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
|
@@ -248,7 +259,7 @@ public class WxController extends BaseController {
|
|
|
wxUserService.save(user);
|
|
|
//异步 添加新人优惠卷
|
|
|
TWxUser finalUser = user;
|
|
|
- threadPoolTaskExecutor.submit(()->couponReceiveService.submit(new CouponReceive().setOpenid(finalUser.getcOpenid()).setCouponId("1")));
|
|
|
+ threadPoolTaskExecutor.submit(() -> couponReceiveService.submit(new CouponReceive().setOpenid(finalUser.getcOpenid()).setCouponId("1")));
|
|
|
user.setId(user.getId());
|
|
|
}
|
|
|
|
|
@@ -270,6 +281,9 @@ public class WxController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 更新用户信息接口
|
|
|
*/
|
|
@@ -339,4 +353,6 @@ public class WxController extends BaseController {
|
|
|
return R.ok(pageSelect);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|