update 会员钱包明细

This commit is contained in:
Lemon
2023-07-22 15:23:31 +08:00
parent 42f2b18b99
commit a17412968c
11 changed files with 175 additions and 15 deletions

View File

@@ -191,6 +191,7 @@ public class MemberController extends BaseController {
String memberId = getMemberIdByAuthorization(request);
dto.setMemberId(memberId);
PageResponse pageResponse = memberService.getMemberBalanceChanges(dto);
// PageResponse pageResponse = memberService.getMemberWalletLog(dto);
response = new RestApiResponse<>(pageResponse);
} catch (Exception e) {
logger.error("查询用户账户余额变动信息 error:", e);

View File

@@ -22,6 +22,7 @@ import com.jsowell.common.enums.ykc.ScenarioEnum;
import com.jsowell.common.enums.ykc.StartModeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
@@ -48,10 +49,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -292,6 +290,54 @@ public class MemberService {
return pageResponse;
}
/**
* 获取会员钱包明细
* @return
*/
public PageResponse getMemberWalletLog (UniAppQueryMemberBalanceDTO dto) throws ParseException {
// 获取分页信息以及memberId
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
String tradeDate = dto.getTradeDate();
// 获取年、月
String[] split = StringUtils.split(tradeDate, "-");
int year = Integer.parseInt(split[0]);
int month = Integer.parseInt(split[1]);
// 根据年月获取当月第一天和最后一天
tradeDate = DateUtils.getFirstDay(year, month, DateUtils.YYYY_MM_DD);
String lastDay = DateUtils.getLastDay(year, month, DateUtils.YYYY_MM_DD);
// sql语句查询日期需要多加一天
Date date = DateUtils.addDays(DateUtils.parseDate(lastDay, DateUtils.YYYY_MM_DD), 1);
lastDay = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
dto.setTradeDate(tradeDate);
dto.setEndDate(lastDay);
// 根据日期查询会员钱包变动明细
// 分页
PageHelper.startPage(pageNum, pageSize);
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberWalletDetail(dto);
PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
// 获取 type 和 subType 的对应信息
for (MemberWalletLogVO walletLogVO : pageInfo.getList()) {
// 将负数转为正数
walletLogVO.setAmount(BigDecimal.valueOf(Math.abs(walletLogVO.getAmount().doubleValue())).setScale(2, BigDecimal.ROUND_HALF_UP));
String subType = walletLogVO.getSubType();
String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
if (StringUtils.isNotBlank(subTypeValue)) {
walletLogVO.setSubType(subTypeValue);
}
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
}
PageResponse pageResponse = PageResponse.builder()
.pageSize(pageSize)
.pageNum(pageNum)
.list(pageInfo.getList())
.pages(pageInfo.getPages())
.total(pageInfo.getTotal())
.build();
return pageResponse;
}
/**
* 用户绑定车牌号
* @param dto

View File

@@ -333,7 +333,7 @@ public class PileService {
}
List<String> adminList = relationList.stream()
.filter(x -> x.getType().equals("1"))
.filter(x -> x.getType().equals(Constants.ONE)) // 1-管理员用户
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(adminList)) {
@@ -341,13 +341,13 @@ public class PileService {
}
// 校验身份
if (!adminList.contains(dto.getMemberId())) {
// 如果为空,说明此用户身份有误,不是管理员,抛出异常
if (adminList.contains(dto.getMemberId())) {
// 如果为空,说明被分享的用户是管理员,抛出异常
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
}
List<String> userList = relationList.stream()
.filter(x -> !x.getType().equals("1"))
.filter(x -> !x.getType().equals(Constants.TWO)) // 2-普通用户
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());

View File

@@ -1,6 +1,7 @@
package com.jsowell.common.util;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -20,11 +21,7 @@ import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
/**
* 时间工具类
@@ -938,4 +935,42 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return true;
}
}
/**
* 根据年月获取月初第一天日期
* @param year
* @param month
* @return
*/
public static String getFirstDay(int year,int month,String format) {
Calendar cale = Calendar.getInstance();
cale.set(Calendar.YEAR, year); //赋值年份
cale.set(Calendar.MONTH, month - 1);//赋值月份
int lastDay = cale.getActualMinimum(Calendar.DAY_OF_MONTH);//获取月最大天数
cale.set(Calendar.DAY_OF_MONTH, lastDay);//设置日历中月份的最大天数
SimpleDateFormat sdf = new SimpleDateFormat(format);//格式化日期yyyy-MM-dd
String lastDayOfMonth = sdf.format(cale.getTime());
return lastDayOfMonth;
}
/**
* 根据年月获取月末最后一天日期
* @param year
* @param month
* @return
*/
public static String getLastDay(int year,int month,String format) {
Calendar cale = Calendar.getInstance();
cale.set(Calendar.YEAR, year);//赋值年份
cale.set(Calendar.MONTH, month - 1);//赋值月份
int lastDay = cale.getActualMaximum(Calendar.DAY_OF_MONTH);//获取月最大天数
cale.set(Calendar.DAY_OF_MONTH, lastDay);//设置日历中月份的最大天数
SimpleDateFormat sdf = new SimpleDateFormat(format); //格式化日期yyyy-MM-dd
String lastDayOfMonth = sdf.format(cale.getTime());
return lastDayOfMonth;
}
}

View File

@@ -22,6 +22,16 @@ public class UniAppQueryMemberBalanceDTO extends BaseMemberDTO{
*/
private String type;
/**
* 交易时间(如2023-07),只到月份,查询当月数据
*/
private String tradeDate;
/**
* 结束时间
*/
private String endDate;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)

View File

@@ -2,6 +2,7 @@ package com.jsowell.pile.mapper;
import com.jsowell.pile.domain.MemberWalletLog;
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -30,4 +31,11 @@ public interface MemberWalletLogMapper {
* @param type 1-进账2-出账 不传查全部
*/
List<MemberWalletLogVO> getMemberBalanceChanges(@Param("memberId") String memberId, @Param("type") String type);
/**
* 小程序查询会员余额明细
* @param dto
* @return
*/
List<MemberWalletLogVO> getMemberWalletDetail(@Param("dto") UniAppQueryMemberBalanceDTO dto);
}

View File

@@ -2,6 +2,7 @@ package com.jsowell.pile.service;
import com.jsowell.pile.domain.MemberBasicInfo;
import com.jsowell.pile.dto.PlatformTesterDTO;
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
@@ -121,4 +122,10 @@ public interface IMemberBasicInfoService {
void updatePlatformTester(PlatformTesterDTO dto);
PlatformTesterVO selectPlatformTesterStatus(String memberId);
/**
* 小程序查询会员钱包明细
* @return
*/
List<MemberWalletLogVO> getMemberWalletDetail(UniAppQueryMemberBalanceDTO dto);
}

View File

@@ -11,6 +11,7 @@ import com.jsowell.pile.domain.MemberPlateNumberRelation;
import com.jsowell.pile.domain.MemberWalletInfo;
import com.jsowell.pile.domain.MemberWalletLog;
import com.jsowell.pile.dto.PlatformTesterDTO;
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
import com.jsowell.pile.mapper.MemberBasicInfoMapper;
import com.jsowell.pile.mapper.MemberPlateNumberRelationMapper;
import com.jsowell.pile.mapper.MemberWalletInfoMapper;
@@ -320,5 +321,15 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
return vo;
}
/**
* 小程序查询会员钱包明细
* @param dto
* @return
*/
@Override
public List<MemberWalletLogVO> getMemberWalletDetail(UniAppQueryMemberBalanceDTO dto) {
return memberWalletLogMapper.getMemberWalletDetail(dto);
}
}

View File

@@ -613,8 +613,8 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
}
log.info("后管首页基本信息查询 authorizedMap:{}, dto:{}", JSONObject.toJSONString(authorizedMap), JSONObject.toJSONString(dto));
dto.setStationIdList(stationIdList);
// IndexGeneralSituationVO generalSituation = pileBasicInfoMapper.getGeneralSituation(dto);
IndexGeneralSituationVO generalInfo = pileBasicInfoMapper.getGeneralSituationInfo(dto);
IndexGeneralSituationVO generalInfo = pileBasicInfoMapper.getGeneralSituation(dto);
// IndexGeneralSituationVO generalInfo = pileBasicInfoMapper.getGeneralSituationInfo(dto);
List<PileInfoVO> pileInfoVOS = queryPileDetailList(stationIdList);
// 对集合根据pileSn进行去重

View File

@@ -44,4 +44,24 @@ public class MemberWalletLogVO {
* 余额类型1-本金2-赠送)
*/
private String category;
/**
* 关联订单
*/
private String relatedOrderCode;
/**
* 支付金额
*/
private BigDecimal payAmount;
/**
* 订单金额
*/
private BigDecimal orderAmount;
/**
* 退款金额
*/
private BigDecimal refundAmount;
}

View File

@@ -47,4 +47,26 @@
</if>
order by t1.create_time DESC
</select>
<select id="getMemberWalletDetail" resultType="com.jsowell.pile.vo.uniapp.MemberWalletLogVO">
SELECT
t1.member_id as memberId,
t1.type,
t1.sub_type as subType,
t1.amount,
t1.category,
t1.related_order_code as relatedOrderCode,
t2.pay_amount as payAmount,
t2.order_amount as orderAmount,
t2.refund_amount as refundAmount,
t1.create_time as transactionTime
from member_wallet_log t1
left join order_basic_info t2
on t1.related_order_code = t2.order_code
where t1.member_id = #{dto.memberId,jdbcType=VARCHAR}
and t1.create_time <![CDATA[ >= ]]> #{dto.tradeDate,jdbcType=VARCHAR}
and t1.create_time <![CDATA[ < ]]> #{dto.endDate,jdbcType=VARCHAR}
and t1.sub_type != '12'
order by t1.create_time desc
</select>
</mapper>