|
|
@@ -1,13 +1,20 @@
|
|
|
package com.fs.app.controller;
|
|
|
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.his.domain.FsShareMaterial;
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.dto.CollectionUserPhoneDTO;
|
|
|
import com.fs.his.dto.ShareQRCRedPackageDto;
|
|
|
import com.fs.his.service.IFsShareMaterialService;
|
|
|
+import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.qw.service.IFsCompanyQrcPhoneService;
|
|
|
import com.fs.qw.service.IFsCompanyQrcRedPackageRecordService;
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -28,6 +35,12 @@ public class ShareMaterialController extends AppBaseController
|
|
|
@Autowired
|
|
|
private IFsCompanyQrcPhoneService companyQrcPhoneService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFsUserService fsUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsUserService userService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IFsCompanyQrcRedPackageRecordService companyQrcRedPackageRecordService;
|
|
|
|
|
|
@@ -44,16 +57,20 @@ public class ShareMaterialController extends AppBaseController
|
|
|
* 提交收集的客户手机号
|
|
|
*/
|
|
|
@PostMapping("/submitPhone")
|
|
|
- public R submitPhone(@RequestBody CollectionUserPhoneDTO userPhoneDTO){
|
|
|
- long userId;
|
|
|
+ public R submitPhone(@RequestBody CollectionUserPhoneDTO param){
|
|
|
+ final WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
|
|
|
try {
|
|
|
- userId = Long.parseLong(getUserId());
|
|
|
- }catch (Exception e){
|
|
|
- return R.error("用户登录信息异常");
|
|
|
+ WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
|
|
|
+ // 解密
|
|
|
+ WxMaPhoneNumberInfo phoneNoInfo = wxService.getUserService().getPhoneNoInfo(session.getSessionKey(), param.getEncryptedData(), param.getIv());
|
|
|
+ String phoneNumber = phoneNoInfo.getPhoneNumber();
|
|
|
+ param.setUserPhone(phoneNumber);
|
|
|
+ int result = companyQrcPhoneService.submitPhone(param);
|
|
|
+ return result>0?R.ok():R.error("提交失败");
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ return R.error("授权失败,"+e.getMessage());
|
|
|
}
|
|
|
- userPhoneDTO.setUserId(userId);
|
|
|
- int result = companyQrcPhoneService.submitPhone(userPhoneDTO);
|
|
|
- return result>0?R.ok():R.error("提交失败");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|