小程序查询客服电话号码接口

This commit is contained in:
Lihx 2024-09-23 18:10:56 +08:00
parent 8af9224cbb
commit bf6b379d3e
7 changed files with 101 additions and 0 deletions

View File

@ -1,5 +1,10 @@
package cn.iocoder.yudao.module.custom.controller.admin;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
@ -17,8 +22,11 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.net.ssl.HttpsURLConnection;
import javax.validation.Valid;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import static cn.iocoder.yudao.common.BaseConstants.*;
@ -171,4 +179,27 @@ public class CustomerMainController {
busiLabelService.saveBusiLable(saveReqVO.getId(), TABLE_BASE_CUSTOMER_MAIN, saveReqVO.getLabelList());
return success(true);
}
/**
* 小程序客户注册
* cusName,phoneNumber,birthday,sex,inviter
*/
@PostMapping("/addUniUser")
public CommonResult<Boolean> addUniUser(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
if(!saveReqVO.getCode().isEmpty()){
String code = saveReqVO.getCode();
JSONObject jsonObj = new JSONObject();
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code="
+code+"&grant_type=authorization_code";
String response = HttpRequest.get(url).execute().body();
JSONObject json = JSONUtil.parseObj(response);
if (json.containsKey("access_token") && json.containsKey("openid")) {
String accessToken = json.getStr("access_token");
String openid = json.getStr("openid");
}
}
return null;
}
}

View File

@ -19,4 +19,8 @@ public class CustomerMainSaveReqVO extends CustomerMain {
/**标签信息*/
List<BusiLabel> labelList;
/**
* Code
*/
private String Code;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.app.controller;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.app.service.UniShopConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/userClient/uniShopConfig")
public class UniShopConfigController {
@Autowired
UniShopConfigService uniShopConfigService;
@GetMapping("/getRepairTel")
public CommonResult<String> getRepairTel() {
return CommonResult.success(uniShopConfigService.getRepairTel());
}
}

View File

@ -0,0 +1,11 @@
package cn.iocoder.yudao.module.app.mapper;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UniShopConfigMapper {
public String getRepairTel();
}

View File

@ -0,0 +1,6 @@
package cn.iocoder.yudao.module.app.service;
public interface UniShopConfigService {
public String getRepairTel();
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.app.service.impl;
import cn.iocoder.yudao.module.app.mapper.UniShopConfigMapper;
import cn.iocoder.yudao.module.app.service.UniShopConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UniShopConfigServiceImpl implements UniShopConfigService {
@Autowired
UniShopConfigMapper uniShopConfigMapper;
@Override
public String getRepairTel() {
return uniShopConfigMapper.getRepairTel();
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.app.mapper.UniShopConfigMapper">
<select id="getRepairTel" resultType="string">
SELECT repair_tel FROM shop_config LIMIT 1
</select>
</mapper>