后台管理客户信息列表
This commit is contained in:
@@ -11,4 +11,6 @@ import lombok.Data;
|
|||||||
@ApiModel(value = "客户信息 查询条件", description = "客户信息 查询条件")
|
@ApiModel(value = "客户信息 查询条件", description = "客户信息 查询条件")
|
||||||
@Data
|
@Data
|
||||||
public class LpkCustomerQuery implements Query {
|
public class LpkCustomerQuery implements Query {
|
||||||
|
private String realName;
|
||||||
|
private String mobile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,10 @@ import lombok.NoArgsConstructor;
|
|||||||
@ApiModel(value = "客户信息 视图数据对象", description = "客户信息 视图数据对象")
|
@ApiModel(value = "客户信息 视图数据对象", description = "客户信息 视图数据对象")
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LpkCustomerVo implements Vo {
|
public class LpkCustomerVo implements Vo {
|
||||||
|
private String sid;
|
||||||
|
private String mobile;
|
||||||
|
private String bindDate;
|
||||||
|
private String realName;
|
||||||
|
private String nick;
|
||||||
|
private String photo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package com.yxt.yyth.biz.lpkcustomer;
|
package com.yxt.yyth.biz.lpkcustomer;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
||||||
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
@@ -10,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface LpkCustomerMapper extends BaseMapper<LpkCustomer> {
|
public interface LpkCustomerMapper extends BaseMapper<LpkCustomer> {
|
||||||
|
|
||||||
|
IPage<LpkCustomerVo> customerListPage(IPage<LpkCustomer> page, @Param(Constants.WRAPPER) QueryWrapper<LpkCustomer> qw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,17 @@
|
|||||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||||
<!-- ${ew.customSqlSegment} -->
|
<!-- ${ew.customSqlSegment} -->
|
||||||
|
|
||||||
|
<select id="customerListPage" resultType="com.yxt.yyth.api.lpkcustomer.LpkCustomerVo">
|
||||||
|
select
|
||||||
|
sid,
|
||||||
|
date_format(bindDate, '%Y-%m-%d') as bindDate,
|
||||||
|
realName,
|
||||||
|
nick,
|
||||||
|
photo,
|
||||||
|
mobile
|
||||||
|
from lpk_customer
|
||||||
|
<where>
|
||||||
|
${ew.sqlSegment}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.yxt.yyth.biz.lpkcustomer;
|
package com.yxt.yyth.biz.lpkcustomer;
|
||||||
|
|
||||||
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
||||||
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomerQuery;
|
||||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
||||||
import com.yxt.yyth.api.lpkcustomer.WxBindMobileDto;
|
import com.yxt.yyth.api.lpkcustomer.WxBindMobileDto;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -24,12 +27,21 @@ public class LpkCustomerRest {
|
|||||||
|
|
||||||
@PostMapping("/wxBindMobile")
|
@PostMapping("/wxBindMobile")
|
||||||
@ApiOperation(value = "微信绑定手机")
|
@ApiOperation(value = "微信绑定手机")
|
||||||
public ResultBean wxBindMobile(@RequestBody WxBindMobileDto wxBindMobileDto){
|
public ResultBean wxBindMobile(@RequestBody WxBindMobileDto wxBindMobileDto) {
|
||||||
return lpkCustomerService.wxBindMobile(wxBindMobileDto);
|
return lpkCustomerService.wxBindMobile(wxBindMobileDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "微信静默登录")
|
@ApiOperation(value = "微信静默登录")
|
||||||
@GetMapping("/wxSilentLogin")
|
@GetMapping("/wxSilentLogin")
|
||||||
public ResultBean<LpkCustomerVo> wxSilentLogin(@RequestParam(value = "wxCode") String wxCode) {
|
public ResultBean<LpkCustomerVo> wxSilentLogin(@RequestParam(value = "wxCode") String wxCode) {
|
||||||
return lpkCustomerService.wxSilentLogin(wxCode);
|
return lpkCustomerService.wxSilentLogin(wxCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("客户信息列表")
|
||||||
|
@PostMapping("/customerListPage")
|
||||||
|
public ResultBean<PagerVo<LpkCustomerVo>> customerListPage(@RequestBody PagerQuery<LpkCustomerQuery> pq) {
|
||||||
|
return lpkCustomerService.customerListPage(pq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,20 +2,25 @@ package com.yxt.yyth.biz.lpkcustomer;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||||
import com.yxt.common.base.service.MybatisBaseService;
|
import com.yxt.common.base.service.MybatisBaseService;
|
||||||
|
import com.yxt.common.base.utils.PagerUtil;
|
||||||
import com.yxt.common.base.utils.StringUtils;
|
import com.yxt.common.base.utils.StringUtils;
|
||||||
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
||||||
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomerQuery;
|
||||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
||||||
import com.yxt.yyth.api.lpkcustomer.WxBindMobileDto;
|
import com.yxt.yyth.api.lpkcustomer.WxBindMobileDto;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
@@ -23,14 +28,19 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, LpkCustomer> {
|
public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, LpkCustomer> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileUploadComponent fileUploadComponent;
|
||||||
|
|
||||||
String APP_ID = "wx4724e3a3c27f36b5";
|
String APP_ID = "wx4724e3a3c27f36b5";
|
||||||
String SECRET = "971fd3b8aa7b08ce3e8a5f3e502b1a8d";
|
String SECRET = "971fd3b8aa7b08ce3e8a5f3e502b1a8d";
|
||||||
private static final String WX_URL_LOGIN = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code ";
|
private static final String WX_URL_LOGIN = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code ";
|
||||||
|
|
||||||
public ResultBean<JSONObject> wxLogin(String jsCode, String appid, String secret) {
|
public ResultBean<JSONObject> wxLogin(String jsCode, String appid, String secret) {
|
||||||
ResultBean rb=new ResultBean();
|
ResultBean rb = new ResultBean();
|
||||||
String url = WX_URL_LOGIN.replace("APPID", appid).replace("SECRET", secret).replace("JSCODE",jsCode).replace("authorization_code","authorization_code");
|
String url = WX_URL_LOGIN.replace("APPID", appid).replace("SECRET", secret).replace("JSCODE", jsCode).replace("authorization_code", "authorization_code");
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
ResponseEntity<String> forEntity = restTemplate.getForEntity(url,String.class);
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody());
|
JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody());
|
||||||
System.out.println(jsonObject);
|
System.out.println(jsonObject);
|
||||||
return rb.success().setData(jsonObject);
|
return rb.success().setData(jsonObject);
|
||||||
@@ -38,6 +48,7 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信静默登录
|
* 微信静默登录
|
||||||
|
*
|
||||||
* @param wxCode 临时凭证code值
|
* @param wxCode 临时凭证code值
|
||||||
* @return ResultBean data:Token
|
* @return ResultBean data:Token
|
||||||
* 登陆成功后data返回用户Sid
|
* 登陆成功后data返回用户Sid
|
||||||
@@ -47,8 +58,8 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
|
|||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
// 通过wxCode获取unionid,失败返回微信的错误提示。
|
// 通过wxCode获取unionid,失败返回微信的错误提示。
|
||||||
|
|
||||||
ResultBean<JSONObject> rbJsonObject = wxLogin(wxCode,APP_ID,SECRET);
|
ResultBean<JSONObject> rbJsonObject = wxLogin(wxCode, APP_ID, SECRET);
|
||||||
if (!rbJsonObject.getSuccess()){
|
if (!rbJsonObject.getSuccess()) {
|
||||||
JSONObject jsonObject = rbJsonObject.getData();
|
JSONObject jsonObject = rbJsonObject.getData();
|
||||||
String errcode = jsonObject.get("errcode").toString();
|
String errcode = jsonObject.get("errcode").toString();
|
||||||
String errmsg = jsonObject.get("errmsg").toString();
|
String errmsg = jsonObject.get("errmsg").toString();
|
||||||
@@ -56,19 +67,19 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
|
|||||||
}
|
}
|
||||||
// 判断存在不存在unionid,用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台帐号下会返回,详见 UnionID 机制说明。、
|
// 判断存在不存在unionid,用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台帐号下会返回,详见 UnionID 机制说明。、
|
||||||
JSONObject jsonObject = rbJsonObject.getData();
|
JSONObject jsonObject = rbJsonObject.getData();
|
||||||
if (!jsonObject.containsKey("openid")){
|
if (!jsonObject.containsKey("openid")) {
|
||||||
return rb.setMsg("未获得openid,请联系管理员");
|
return rb.setMsg("未获得openid,请联系管理员");
|
||||||
}
|
}
|
||||||
String unionid = jsonObject.get("unionid").toString();
|
String unionid = jsonObject.get("unionid").toString();
|
||||||
String openid = jsonObject.get("openid").toString();
|
String openid = jsonObject.get("openid").toString();
|
||||||
Map<String,String> map=new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("unionid",unionid);
|
map.put("unionid", unionid);
|
||||||
map.put("openid",openid);
|
map.put("openid", openid);
|
||||||
LpkCustomer lpkCustomer= baseMapper.selectOne(new QueryWrapper<LpkCustomer>().eq("wx_mp_openid",openid));
|
LpkCustomer lpkCustomer = baseMapper.selectOne(new QueryWrapper<LpkCustomer>().eq("wx_mp_openid", openid));
|
||||||
//查询用户是否存在
|
//查询用户是否存在
|
||||||
if(null==lpkCustomer){
|
if (null == lpkCustomer) {
|
||||||
//新增用户
|
//新增用户
|
||||||
LpkCustomer newCustomer=new LpkCustomer();
|
LpkCustomer newCustomer = new LpkCustomer();
|
||||||
newCustomer.setWxMpOpenid(openid);
|
newCustomer.setWxMpOpenid(openid);
|
||||||
newCustomer.setCreateTime(new Date());
|
newCustomer.setCreateTime(new Date());
|
||||||
baseMapper.insert(newCustomer);
|
baseMapper.insert(newCustomer);
|
||||||
@@ -76,14 +87,40 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
|
|||||||
}
|
}
|
||||||
return rb.success().setData(lpkCustomer);
|
return rb.success().setData(lpkCustomer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean wxBindMobile(WxBindMobileDto wxBindMobileDto) {
|
public ResultBean wxBindMobile(WxBindMobileDto wxBindMobileDto) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
String mobile = wxBindMobileDto.getMobile();
|
String mobile = wxBindMobileDto.getMobile();
|
||||||
LpkCustomer lpkCustomer= baseMapper.selectOne(new QueryWrapper<LpkCustomer>().eq("wx_mp_openid",wxBindMobileDto.getOpenid()));
|
LpkCustomer lpkCustomer = baseMapper.selectOne(new QueryWrapper<LpkCustomer>().eq("wx_mp_openid", wxBindMobileDto.getOpenid()));
|
||||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
lpkCustomer.setBindDate(sdf.format(new Date()));
|
lpkCustomer.setBindDate(sdf.format(new Date()));
|
||||||
lpkCustomer.setMobile(mobile);
|
lpkCustomer.setMobile(mobile);
|
||||||
baseMapper.insert(lpkCustomer);
|
baseMapper.insert(lpkCustomer);
|
||||||
return rb.setMsg("绑定成功");
|
return rb.setMsg("绑定成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResultBean<PagerVo<LpkCustomerVo>> customerListPage(PagerQuery<LpkCustomerQuery> pq) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
LpkCustomerQuery query = pq.getParams();
|
||||||
|
QueryWrapper<LpkCustomer> qw = new QueryWrapper<>();
|
||||||
|
if (StringUtils.isNotBlank(query.getMobile())) {
|
||||||
|
qw.like("mobile", query.getMobile());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(query.getRealName())) {
|
||||||
|
qw.like("realName", query.getRealName());
|
||||||
|
}
|
||||||
|
IPage<LpkCustomer> page = PagerUtil.queryToPage(pq);
|
||||||
|
IPage<LpkCustomerVo> pagging = baseMapper.customerListPage(page, qw);
|
||||||
|
PagerVo<LpkCustomerVo> p = PagerUtil.pageToVo(pagging, null);
|
||||||
|
List<LpkCustomerVo> records = pagging.getRecords();
|
||||||
|
records.removeAll(Collections.singleton(null));
|
||||||
|
if (!records.isEmpty()) {
|
||||||
|
for (LpkCustomerVo record : records) {
|
||||||
|
if (StringUtils.isNotBlank(record.getPhoto())) {
|
||||||
|
record.setPhoto(fileUploadComponent.getUrlPrefix() + record.getPhoto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rb.success().setData(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user