Commit 47f2f8bd by YG8999

保洁记录

parent cbf2ae17
......@@ -230,6 +230,8 @@ public class WeChatConstants {
public static final String WECHAT_OAUTH2_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={}&secret={}&code={}&grant_type=authorization_code";
/** 开放平台获取用户的url */
public static final String WECHAT_SNS_USERINFO_URL = "https://api.weixin.qq.com/sns/userinfo?access_token={}&openid={}&lang={}";
/** 获取手机号的url */
public static final String WECHAT_GET_USER_PHONE_NUMBER_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={}";
/** 公众号js-sdk获取ticket的url */
public static final String WECHAT_PUBLIC_JS_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={}&type=jsapi";
......
......@@ -4,6 +4,8 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -31,6 +33,7 @@ import share.common.core.page.TableDataInfo;
*/
@RestController
@RequestMapping("/cleanRecords")
@Api(tags = "保洁记录")
public class SCleanRecordsController extends BaseController
{
@Autowired
......@@ -39,6 +42,7 @@ public class SCleanRecordsController extends BaseController
/**
* 查询保洁记录列表
*/
@ApiOperation(value = "保洁记录列表")
@GetMapping("/list")
public TableDataInfo list(SCleanRecords sCleanRecords)
{
......@@ -50,6 +54,7 @@ public class SCleanRecordsController extends BaseController
/**
* 根据保洁员id查询未开始的保洁记录列表
*/
@ApiOperation(value = "未开始的保洁记录列表")
@GetMapping("/unCleanList")
public TableDataInfo unCleanList(SCleanRecords sCleanRecords)
{
......@@ -61,6 +66,7 @@ public class SCleanRecordsController extends BaseController
/**
* 根据保洁员id查询已开始的保洁记录列表
*/
@ApiOperation(value = "已开始的保洁记录列表")
@GetMapping("/myCleanList")
public TableDataInfo myCleanList(SCleanRecords sCleanRecords)
{
......@@ -72,6 +78,7 @@ public class SCleanRecordsController extends BaseController
/**
* 获取保洁记录详细信息
*/
@ApiOperation(value = "获取保洁记录详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
......@@ -82,6 +89,7 @@ public class SCleanRecordsController extends BaseController
* 开始保洁
*/
//@Log(title = "开始保洁", businessType = BusinessType.UPDATE)
@ApiOperation(value = "开始保洁")
@PostMapping(value = "/startClean")
public AjaxResult startClean(@RequestBody SCleanRecords sCleanRecords)
{
......@@ -94,6 +102,7 @@ public class SCleanRecordsController extends BaseController
* 结束保洁
*/
//@Log(title = "结束保洁", businessType = BusinessType.UPDATE)
@ApiOperation(value = "结束保洁")
@PostMapping(value = "/endClean")
public AjaxResult endClean(@RequestBody SCleanRecords sCleanRecords)
{
......@@ -105,6 +114,7 @@ public class SCleanRecordsController extends BaseController
/**
* 通过房间ID查询保洁记录
*/
@ApiOperation(value = "通过房间ID查询保洁记录")
@GetMapping(value = "/getByRoomId/{roomId}")
public AjaxResult getByRoomId(@PathVariable("roomId") Long roomId)
{
......@@ -114,6 +124,7 @@ public class SCleanRecordsController extends BaseController
/**
* 查询正在保洁中的保洁记录
*/
@ApiOperation(value = "查询正在保洁中的保洁记录")
@GetMapping(value = "/getByCleanerId")
public AjaxResult getByCleanerId()
{
......
package share.system.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @className: share.system.domain.vo.WeChatPhoneNumberVo
* @description: 微信用户手机号数据
* @author: lwj
* @create: 2023-11-15 13:04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="WeChatPhoneNumberVo对象", description="微信用户手机号返回数据")
public class WeChatPhoneNumberVo implements Serializable {
@ApiModelProperty(value = "用户绑定的手机号(国外手机号会有区号)")
@TableField(value = "phoneNumber")
private String phoneNumber;
@ApiModelProperty(value = "没有区号的手机号")
@TableField(value = "purePhoneNumber")
private String purePhoneNumber;
@ApiModelProperty(value = "区号")
@TableField(value = "countryCode")
private String countryCode;
@ApiModelProperty(value = "错误码")
@TableField(value = "errcode")
private String errCode;
@ApiModelProperty(value = "错误信息")
@TableField(value = "errmsg")
private String errMsg;
}
......@@ -174,4 +174,12 @@ public interface WechatNewService {
* @return 小程序订阅消息模板编号(自己的)
*/
String apiAddRoutineTemplate(String tempKey, List<Integer> kidList);
/**
* 获取手机号信息
* @param code 手机号获取凭证
* @return 微信手机号信息
*/
WeChatPhoneNumberVo getPhoneNumber(String code);
}
......@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.binary.Base64;
......@@ -801,6 +802,37 @@ public class WechatNewServiceImpl implements WechatNewService {
}
/**
* 获取手机号信息
* @param code 手机号获取凭证
* @return 微信手机号信息
*/
@Override
public WeChatPhoneNumberVo getPhoneNumber(String code) {
String accessToken = getMiniAccessToken();
String url = StrUtil.format(WeChatConstants.WECHAT_GET_USER_PHONE_NUMBER_URL, accessToken);
HashMap<String, Object> map = new HashMap<>();
map.put("code", code);
JSONObject data = restTemplateUtil.postJsonDataAndReturnJson(url, new JSONObject(map));
if (ObjectUtil.isNull(data)) {
throw new BaseException("微信平台接口异常,没任何数据返回!");
}
if (data.containsKey("errcode") && !data.getString("errcode").equals("0")) {
if (data.containsKey("errmsg")) {
// 保存到微信异常表
wxExceptionDispose(data, "微信获取用户手机号异常");
throw new BaseException("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
}
}
WeChatPhoneNumberVo weChatPhoneNumberVo = new WeChatPhoneNumberVo();
weChatPhoneNumberVo.setPhoneNumber(data.getJSONObject("phone_info").getString("phoneNumber"));
weChatPhoneNumberVo.setPurePhoneNumber(data.getJSONObject("phone_info").getString("purePhoneNumber"));
weChatPhoneNumberVo.setCountryCode(data.getJSONObject("phone_info").getString("countryCode"));
weChatPhoneNumberVo.setErrCode(data.getString("errcode"));
weChatPhoneNumberVo.setErrMsg(data.getString("errmsg"));
return weChatPhoneNumberVo;
}
/**
* 获取JS-SDK的签名
* @param nonceStr 随机字符串
* @param ticket ticket
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment