mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-10 13:00:02 +08:00
Merge branch 'dev' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -0,0 +1,89 @@
|
|||||||
|
package com.jsowell.api.uniapp;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.jsowell.common.annotation.Anonymous;
|
||||||
|
import com.jsowell.common.core.controller.BaseController;
|
||||||
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
|
import com.jsowell.common.response.RestApiResponse;
|
||||||
|
import com.jsowell.pile.dto.CarVinDTO;
|
||||||
|
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||||
|
import com.jsowell.pile.service.ICarVinInfoService;
|
||||||
|
import com.jsowell.pile.vo.CarVinInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
|
import com.jsowell.service.MemberService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* @author JS-ZZA
|
||||||
|
* @date 2023/6/8 13:56
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/uniapp/carVin")
|
||||||
|
public class CarVinController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICarVinInfoService carVinInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户查询绑定的vin列表
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/getCarVinList")
|
||||||
|
public RestApiResponse<?> getCarVinList(HttpServletRequest request){
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
logger.info("查询用户Vin列表 param memberId:{}", memberId);
|
||||||
|
List<CarVinInfoVO> list = carVinInfoService.getCarVinListByMemberId(memberId);
|
||||||
|
response = new RestApiResponse<>(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询用户Vin列表 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("查询用户Vin列表 result : {}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/bindCarVin")
|
||||||
|
public RestApiResponse<?> bindCarVin(HttpServletRequest request, CarVinDTO dto) {
|
||||||
|
logger.info("用户绑定Vin params: {}", JSONObject.toJSONString(dto));
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
if (memberId == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
|
||||||
|
}
|
||||||
|
dto.setMemberId(memberId);
|
||||||
|
// 校验短信验证码
|
||||||
|
MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
||||||
|
.mobileNumber(dto.getPhoneNumber())
|
||||||
|
.verificationCode(dto.getVerificationCode())
|
||||||
|
.build();
|
||||||
|
memberService.checkVerificationCode(registerAndLoginDTO);
|
||||||
|
int i = carVinInfoService.bindAuthCard(dto);
|
||||||
|
response = new RestApiResponse<>(i);
|
||||||
|
}catch (BusinessException e){
|
||||||
|
logger.warn("用户绑定Vin warn:", e);
|
||||||
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("用户绑定Vin error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("用户绑定Vin result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -146,6 +146,7 @@ public enum ReturnCodeEnum {
|
|||||||
|
|
||||||
CODE_THIS_CARD_BIND_INFO_ERROR("00600006", "卡绑定信息有误!"),
|
CODE_THIS_CARD_BIND_INFO_ERROR("00600006", "卡绑定信息有误!"),
|
||||||
|
|
||||||
|
CODE_SELECT_INFO_IS_NULL("00700001", "查询信息为空!"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.jsowell.pile.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆vinDTO
|
||||||
|
*
|
||||||
|
* @author JS-ZZA
|
||||||
|
* @date 2023/6/8 15:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CarVinDTO {
|
||||||
|
private String vinCode;
|
||||||
|
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
private String verificationCode;
|
||||||
|
}
|
||||||
@@ -75,4 +75,11 @@ public interface CarVinInfoMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CarVinInfoVO getMemberInfoByVinCode(String vinCode);
|
CarVinInfoVO getMemberInfoByVinCode(String vinCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过memberId查询绑定的车辆vin列表
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CarVinInfoVO> getCarVinListByMemberId(String memberId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package com.jsowell.pile.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.jsowell.pile.domain.CarVinInfo;
|
import com.jsowell.pile.domain.CarVinInfo;
|
||||||
|
import com.jsowell.pile.dto.CarVinDTO;
|
||||||
import com.jsowell.pile.vo.CarVinInfoVO;
|
import com.jsowell.pile.vo.CarVinInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆vin码Service接口
|
* 车辆vin码Service接口
|
||||||
@@ -74,4 +76,17 @@ public interface ICarVinInfoService {
|
|||||||
*/
|
*/
|
||||||
CarVinInfoVO getMemberInfoByVinCode(String vinCode);
|
CarVinInfoVO getMemberInfoByVinCode(String vinCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过memberId查询绑定的车辆vin列表
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CarVinInfoVO> getCarVinListByMemberId(String memberId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定车辆vin
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int bindAuthCard(CarVinDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ package com.jsowell.pile.service.impl;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
|
import com.jsowell.common.util.StringUtils;
|
||||||
|
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||||
|
import com.jsowell.pile.dto.CarVinDTO;
|
||||||
|
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||||
import com.jsowell.pile.vo.CarVinInfoVO;
|
import com.jsowell.pile.vo.CarVinInfoVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -22,6 +28,9 @@ public class CarVinInfoServiceImpl implements ICarVinInfoService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CarVinInfoMapper carVinInfoMapper;
|
private CarVinInfoMapper carVinInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMemberBasicInfoService memberBasicInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆vin码
|
* 查询车辆vin码
|
||||||
*
|
*
|
||||||
@@ -114,4 +123,44 @@ public class CarVinInfoServiceImpl implements ICarVinInfoService {
|
|||||||
memberInfo.setAccountBalance(memberInfo.getPrincipalBalance().add(memberInfo.getGiftBalance()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
memberInfo.setAccountBalance(memberInfo.getPrincipalBalance().add(memberInfo.getGiftBalance()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
return memberInfo;
|
return memberInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过memberId查询绑定的车辆vin列表
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CarVinInfoVO> getCarVinListByMemberId(String memberId) {
|
||||||
|
return carVinInfoMapper.getCarVinListByMemberId(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定车辆vin
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int bindAuthCard(CarVinDTO dto) {
|
||||||
|
String phoneNumber = dto.getPhoneNumber();
|
||||||
|
// 判断此用户是否已注册小程序账号
|
||||||
|
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(phoneNumber);
|
||||||
|
if (memberBasicInfo == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
|
||||||
|
}
|
||||||
|
// 判断此vin号码是否已被绑定
|
||||||
|
CarVinInfo carVinInfo = carVinInfoMapper.selectVinInfoByVin(dto.getVinCode());
|
||||||
|
if (carVinInfo == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals("1", carVinInfo.getStatus())) {
|
||||||
|
throw new BusinessException("", "");
|
||||||
|
}
|
||||||
|
// 绑定操作
|
||||||
|
carVinInfo.setVinCode(dto.getVinCode());
|
||||||
|
carVinInfo.setStatus("1");
|
||||||
|
carVinInfo.setMemberId(dto.getMemberId());
|
||||||
|
carVinInfo.setCreateBy(dto.getMemberId());
|
||||||
|
|
||||||
|
return carVinInfoMapper.insertCarVinInfo(carVinInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,4 +110,11 @@
|
|||||||
join member_wallet_info t3 on t2.member_id = t3.member_id and t2.status = '1'
|
join member_wallet_info t3 on t2.member_id = t3.member_id and t2.status = '1'
|
||||||
where t1.vin_code = #{vinCode,jdbcType=VARCHAR}
|
where t1.vin_code = #{vinCode,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getCarVinListByMemberId" resultType="com.jsowell.pile.vo.CarVinInfoVO">
|
||||||
|
select <include refid="Base_Column_List"/>
|
||||||
|
from car_vin_info
|
||||||
|
where member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
|
and del_flag = '0'
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user