|
@ -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,9 +28,14 @@ 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"); |
|
@ -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 |
|
@ -76,6 +87,7 @@ 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(); |
|
@ -86,4 +98,29 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp |
|
|
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); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|