|
|
@@ -16,21 +16,29 @@
|
|
|
*/
|
|
|
package org.springblade.land.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springblade.client.constant.LandConstant;
|
|
|
import org.springblade.client.entity.CommonFile;
|
|
|
import org.springblade.client.feign.ICommonFileClient;
|
|
|
+import org.springblade.core.cache.utils.CacheUtil;
|
|
|
+import org.springblade.core.http.HttpRequest;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.land.constant.WxConstant;
|
|
|
import org.springblade.land.entity.NcpCheck;
|
|
|
-import org.springblade.land.vo.NcpCheckVO;
|
|
|
import org.springblade.land.mapper.NcpCheckMapper;
|
|
|
import org.springblade.land.service.INcpCheckService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springblade.land.vo.NcpCheckVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
@@ -54,9 +62,28 @@ public class NcpCheckServiceImpl extends ServiceImpl<NcpCheckMapper, NcpCheck> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public IPage<NcpCheck> getList(NcpCheck ncpCheck, Query query) {
|
|
|
+ LambdaQueryWrapper<NcpCheck> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.like(StringUtil.isNotBlank(ncpCheck.getPlateNo()), NcpCheck::getPlateNo, ncpCheck.getPlateNo())
|
|
|
+ .like(StringUtil.isNotBlank(ncpCheck.getTel()), NcpCheck::getTel, ncpCheck.getTel())
|
|
|
+ .between(StringUtil.isNotBlank(ncpCheck.getBeginCrateTime()) && StringUtil.isNotBlank(ncpCheck.getEndCrateTime()), NcpCheck::getCreateTime, ncpCheck.getBeginCrateTime(), ncpCheck.getEndCrateTime())
|
|
|
+ .eq(NcpCheck::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .orderByDesc(NcpCheck::getCreateTime);
|
|
|
+ return baseMapper.selectPage(Condition.getPage(query), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class)
|
|
|
public boolean saveNcpCheck(NcpCheck ncpCheck) {
|
|
|
- ncpCheck.setCreateTime(new Date());
|
|
|
- baseMapper.insert(ncpCheck);
|
|
|
+ if (ObjectUtil.isEmpty(ncpCheck.getId())) {
|
|
|
+ ncpCheck.setCreateUser(AuthUtil.getUserId());
|
|
|
+ ncpCheck.setCreateTime(new Date());
|
|
|
+ baseMapper.insert(ncpCheck);
|
|
|
+ } else {
|
|
|
+ ncpCheck.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ ncpCheck.setUpdateTime(new Date());
|
|
|
+ baseMapper.updateById(ncpCheck);
|
|
|
+ }
|
|
|
|
|
|
List<CommonFile> fileList = ncpCheck.getFileList();
|
|
|
fileList.forEach(file -> {
|
|
|
@@ -70,6 +97,54 @@ public class NcpCheckServiceImpl extends ServiceImpl<NcpCheckMapper, NcpCheck> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public boolean removeNcpCheck(List<Long> idList) {
|
|
|
+ idList.forEach(id -> {
|
|
|
+ NcpCheck ncpCheck = new NcpCheck();
|
|
|
+ ncpCheck.setId(id);
|
|
|
+ ncpCheck.setIsDeleted(1);
|
|
|
+ baseMapper.updateById(ncpCheck);
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String phone(NcpCheck ncpCheck) {
|
|
|
+ String token = CacheUtil.get(WxConstant.LAND_CACHE, WxConstant.WECHAT_TOKEN, ncpCheck.getTenantId(), String.class);
|
|
|
+ if (StringUtil.isBlank(token)) {
|
|
|
+ throw new RuntimeException("获取请求token失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("code", ncpCheck.getCode());
|
|
|
+
|
|
|
+ return HttpRequest.post("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + token)
|
|
|
+ .bodyString(json.toJSONString())
|
|
|
+ .execute()
|
|
|
+ .onSuccess(responseSpec -> {
|
|
|
+ JSONObject result = JSON.parseObject(responseSpec.asString());
|
|
|
+ String errCode = result.getString("errcode");
|
|
|
+ if (StringUtil.isNotBlank(errCode) && !WxConstant.REQ_SUCCESS.equals(errCode)) {
|
|
|
+ throw new RuntimeException(result.getString("errmsg"));
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject phoneInfo = result.getJSONObject("phone_info");
|
|
|
+ return phoneInfo.getString("purePhoneNumber");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class)
|
|
|
+ public boolean file(List<CommonFile> fileList) {
|
|
|
+ fileList.forEach(file -> {
|
|
|
+ if (ObjectUtil.isEmpty(file.getId())) {
|
|
|
+ file.setSource("LAND_NCP_CHECK");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ commonFileClient.saveList(fileList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<CommonFile> fileList(Long id) {
|
|
|
R<List<CommonFile>> fileList = commonFileClient.getList(id, "LAND_NCP_CHECK");
|
|
|
if (fileList.isSuccess() && fileList.getData() != null) {
|