mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-02 21:18:05 +08:00
add 小程序查询用户鉴权卡列表接口
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
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.response.RestApiResponse;
|
||||||
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
|
import com.jsowell.pile.service.IPileAuthCardService;
|
||||||
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴权卡相关
|
||||||
|
*
|
||||||
|
* @author JS-ZZA
|
||||||
|
* @date 2023/5/23 9:32
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/uniapp/authCard")
|
||||||
|
public class AuthCardController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPileAuthCardService pileAuthCardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询鉴权卡列表
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getAuthCardList")
|
||||||
|
public RestApiResponse<?> getAuthCardList(HttpServletRequest request) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
logger.info("查询用户鉴权卡列表 param memberId:{}", memberId);
|
||||||
|
List<AuthCardVO> list = pileAuthCardService.getAuthCardListByMemberId(memberId);
|
||||||
|
response = new RestApiResponse<>(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询鉴权卡列表 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("查询用户鉴权卡列表 result : {}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定鉴权卡
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/bindAuthCard")
|
||||||
|
public RestApiResponse<?> bindAuthCard(HttpServletRequest request, @RequestBody PileAuthCardDTO dto) {
|
||||||
|
logger.info("用户绑定鉴权卡 params: {}", JSONObject.toJSONString(dto));
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
if (memberId != null) {
|
||||||
|
dto.setMemberId(memberId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ package com.jsowell.web.controller.pile;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.jsowell.common.exception.BusinessException;
|
|
||||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -87,7 +86,7 @@ public class PileAuthCardController extends BaseController {
|
|||||||
@Log(title = "充电站鉴权卡", businessType = BusinessType.INSERT)
|
@Log(title = "充电站鉴权卡", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody PileAuthCardDTO dto) {
|
public AjaxResult add(@RequestBody PileAuthCardDTO dto) {
|
||||||
return toAjax(pileAuthCardService.insertPileAuthCardForWeb(dto));
|
return toAjax(pileAuthCardService.addAuthCard(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.jsowell.pile.dto;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 鉴权卡查询dto
|
* 鉴权卡dto
|
||||||
*
|
*
|
||||||
* @author JS-ZZA
|
* @author JS-ZZA
|
||||||
* @date 2023/3/24 9:29
|
* @date 2023/3/24 9:29
|
||||||
@@ -21,4 +21,6 @@ public class PileAuthCardDTO {
|
|||||||
private String memberId;
|
private String memberId;
|
||||||
|
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
|
private String VerificationCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.jsowell.pile.domain.PileAuthCard;
|
import com.jsowell.pile.domain.PileAuthCard;
|
||||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -96,4 +97,11 @@ public interface PileAuthCardMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PileAuthCard selectSomeStatusCardInfo(@Param("status") String status, @Param("logicCard") String logicCard);
|
PileAuthCard selectSomeStatusCardInfo(@Param("status") String status, @Param("logicCard") String logicCard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过memberId查询鉴权卡列表 (小程序用)
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AuthCardVO> getAuthCardListByMemberId(@Param("memberId") String memberId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.jsowell.pile.domain.PileAuthCard;
|
import com.jsowell.pile.domain.PileAuthCard;
|
||||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +61,7 @@ public interface IPileAuthCardService {
|
|||||||
* @param dto 充电站鉴权卡
|
* @param dto 充电站鉴权卡
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int insertPileAuthCardForWeb(PileAuthCardDTO dto);
|
int addAuthCard(PileAuthCardDTO dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改充电站鉴权卡
|
* 修改充电站鉴权卡
|
||||||
@@ -111,4 +112,11 @@ public interface IPileAuthCardService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PileAuthCard selectCardInfoByLogicCard(String logicCard);
|
PileAuthCard selectCardInfoByLogicCard(String logicCard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过memberId查询鉴权卡列表 (小程序用)
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AuthCardVO> getAuthCardListByMemberId(String memberId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ import com.jsowell.common.util.DateUtils;
|
|||||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||||
|
import com.jsowell.pile.vo.uniapp.AuthCardVO;
|
||||||
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -97,7 +99,7 @@ public class PileAuthCardServiceImpl implements IPileAuthCardService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertPileAuthCardForWeb(PileAuthCardDTO dto) {
|
public int addAuthCard(PileAuthCardDTO dto) {
|
||||||
MemberBasicInfo memberBasicInfo = new MemberBasicInfo();
|
MemberBasicInfo memberBasicInfo = new MemberBasicInfo();
|
||||||
if (dto.getPhoneNumber() == null) {
|
if (dto.getPhoneNumber() == null) {
|
||||||
memberBasicInfo.setMemberId(null);
|
memberBasicInfo.setMemberId(null);
|
||||||
@@ -201,4 +203,18 @@ public class PileAuthCardServiceImpl implements IPileAuthCardService {
|
|||||||
public PileAuthCard selectCardInfoByLogicCard(String logicCard) {
|
public PileAuthCard selectCardInfoByLogicCard(String logicCard) {
|
||||||
return selectSomeStatusCardInfo(null, logicCard);
|
return selectSomeStatusCardInfo(null, logicCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过memberId查询鉴权卡列表 (小程序用)
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AuthCardVO> getAuthCardListByMemberId(String memberId) {
|
||||||
|
List<AuthCardVO> list = pileAuthCardMapper.getAuthCardListByMemberId(memberId);
|
||||||
|
for (AuthCardVO authCardVO : list) {
|
||||||
|
authCardVO.setAccountBalance(authCardVO.getPrincipalBalance().add(authCardVO.getGiftBalance()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.jsowell.pile.vo.uniapp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 桩鉴权卡VO
|
||||||
|
*
|
||||||
|
* @author JS-ZZA
|
||||||
|
* @date 2023/5/23 9:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AuthCardVO {
|
||||||
|
/**
|
||||||
|
* 卡号
|
||||||
|
*/
|
||||||
|
private String logicCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属用户电话号码
|
||||||
|
*/
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账户余额
|
||||||
|
*/
|
||||||
|
private BigDecimal accountBalance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本金金额
|
||||||
|
*/
|
||||||
|
private BigDecimal principalBalance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 赠送金额
|
||||||
|
*/
|
||||||
|
private BigDecimal giftBalance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private String createTime;
|
||||||
|
}
|
||||||
@@ -179,4 +179,22 @@
|
|||||||
<if test="phoneNumber != null and phoneNumber != ''"> and t2.mobile_number = #{phoneNumber}</if>
|
<if test="phoneNumber != null and phoneNumber != ''"> and t2.mobile_number = #{phoneNumber}</if>
|
||||||
<if test="memberId != null and memberId != ''"> and t1.member_id = #{memberId}</if>
|
<if test="memberId != null and memberId != ''"> and t1.member_id = #{memberId}</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getAuthCardListByMemberId" resultType="com.jsowell.pile.vo.uniapp.AuthCardVO">
|
||||||
|
SELECT
|
||||||
|
t1.logic_card AS logicCard,
|
||||||
|
t1.status,
|
||||||
|
t1.member_id AS memberId,
|
||||||
|
t3.principal_balance AS principalBalance,
|
||||||
|
t3.gift_balance AS giftBalance,
|
||||||
|
t1.create_time AS createTime,
|
||||||
|
t2.mobile_number AS phoneNumber
|
||||||
|
FROM
|
||||||
|
pile_auth_card t1
|
||||||
|
JOIN member_basic_info t2 ON t1.member_id = t2.member_id
|
||||||
|
JOIN member_wallet_info t3 ON t2.member_id = t3.member_id
|
||||||
|
WHERE
|
||||||
|
t1.del_flag = '0'
|
||||||
|
AND t1.member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user