优化订单、用户信息

This commit is contained in:
墨大叔 2024-05-06 15:07:24 +08:00
parent c8d55e7df9
commit 1b342869d3
37 changed files with 527 additions and 208 deletions

View File

@ -53,6 +53,7 @@ public class SmUser extends BaseEntity
@Excel(name = "手机号码")
@ApiModelProperty("手机号码")
@Sensitive(desensitizedType = DesensitizedType.PHONE)
@JsonView(JsonViewProfile.App.class)
private String phonenumber;
/** 出生日期 */

View File

@ -5,10 +5,10 @@ import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriod;
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery;
import com.ruoyi.ss.balancePeriod.mapper.SmBalancePeriodMapper;
import com.ruoyi.ss.dashboard.BillCountVo;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.mapper.SmTransactionBillMapper;
import com.ruoyi.ss.transactionBill.mapper.TransactionBillMapper;
import com.ruoyi.ss.user.domain.SmUserQuery;
import com.ruoyi.ss.user.mapper.SmUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,7 +36,7 @@ public class SmBalancePeriodServiceImpl implements ISmBalancePeriodService
private SmUserMapper smUserMapper;
@Autowired
private SmTransactionBillMapper smTransactionBillMapper;
private TransactionBillMapper transactionBillMapper;
/**
* 查询余额时段记录
@ -123,16 +123,16 @@ public class SmBalancePeriodServiceImpl implements ISmBalancePeriodService
data.setUserBalance(smUserMapper.selectBalanceCount(new SmUserQuery()));
// 平台总余额
List<BillCountVo> platFormBillCount = smTransactionBillMapper.selectCount(new SmTransactionBillQuery());
List<BillCountVo> platFormBillCount = transactionBillMapper.selectCount(new TransactionBillQuery());
data.setPlatformBalance(CollectionUtils.isEmpty(platFormBillCount) ? BigDecimal.ZERO : platFormBillCount.get(0).getServiceCharge());
// 充值
SmTransactionBillQuery dto = new SmTransactionBillQuery();
TransactionBillQuery dto = new TransactionBillQuery();
dto.setCreateDate(now);
dto.setHour(now.getHours());
dto.setGroupBy(TransactionBillGroupBy.create_hour.name());
dto.setStatus(TransactionBillStatus.SUCCESS.getStatus());
List<BillCountVo> billCount = smTransactionBillMapper.selectCount(dto);
List<BillCountVo> billCount = transactionBillMapper.selectCount(dto);
data.setRecharge(CollectionUtils.isEmpty(billCount) ? BigDecimal.ZERO : billCount.get(0).getRecharge());
data.setCreateTime(now);

View File

@ -1,7 +1,6 @@
package com.ruoyi.ss.businessRecord.service;
import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecord;
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordQuery;
@ -14,9 +13,9 @@ import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus;
import com.ruoyi.ss.device.service.ISmDeviceService;
import com.ruoyi.ss.model.domain.SmModelQuery;
import com.ruoyi.ss.model.service.ISmModelService;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.user.domain.SmUserQuery;
import com.ruoyi.ss.user.service.ISmUserService;
import org.springframework.beans.factory.annotation.Autowired;
@ -48,7 +47,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
private ISmModelService modelService;
@Autowired
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
/**
* 查询经营记录
@ -174,7 +173,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
brief.setTenantCount(userService.selectCount(tenantDto));
// 充值金额总数
SmTransactionBillQuery rechargeDto = new SmTransactionBillQuery();
TransactionBillQuery rechargeDto = new TransactionBillQuery();
rechargeDto.setStatus(TransactionBillStatus.SUCCESS.getStatus());
List<BillCountVo> billCount = transactionBillService.selectCount(rechargeDto);
if (!CollectionUtils.isEmpty(billCount)) {

View File

@ -0,0 +1,18 @@
package com.ruoyi.ss.store.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wjh
* 2024/5/6
*/
@Data
public class StoreCountVO {
@ApiModelProperty("用户ID")
private Long userId;
@ApiModelProperty("数量")
private Integer count;
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.ss.store.domain;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.valid.EnumValid;
import com.ruoyi.ss.store.domain.enums.StoreGroupBy;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -30,4 +32,15 @@ public class StoreQuery extends Store {
@ApiModelProperty("店铺id列表")
private List<Long> storeIds;
@ApiModelProperty("用户id列表")
private List<Long> userIds;
@ApiModelProperty("分组字段")
@EnumValid(
clazz = StoreGroupBy.class,
message = "非法的分组字段",
method = "name"
)
private String groupBy;
}

View File

@ -0,0 +1,11 @@
package com.ruoyi.ss.store.domain.enums;
/**
* @author wjh
* 2024/5/6
*/
public enum StoreGroupBy {
user_id;
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.ss.store.mapper;
import com.ruoyi.ss.store.domain.Store;
import com.ruoyi.ss.store.domain.StoreCountVO;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.domain.StoreVo;
import org.apache.ibatis.annotations.Param;
@ -112,4 +113,11 @@ public interface StoreMapper
* @return
*/
StoreVo selectOne(StoreQuery query);
/**
* 通用查询数量方法
* @param query
* @return
*/
List<StoreCountVO> selectCommonCount(StoreQuery query);
}

View File

@ -95,6 +95,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
limit 1
</select>
<select id="selectCommonCount" resultType="com.ruoyi.ss.store.domain.StoreCountVO">
<trim prefix="select" suffixOverrides=",">
<if test="groupBy != null">
ss.${groupBy},
</if>
count(ss.store_id) as `count`
</trim>
from sm_store ss
<where>
<include refid="searchCondition"/>
</where>
<if test="groupBy != null">
group by ss.${groupBy}
</if>
</select>
<insert id="insertSmStore" parameterType="Store" useGeneratedKeys="true" keyProperty="storeId">
<selectKey keyProperty="storeId" resultType="Long" order="AFTER">
SELECT LAST_INSERT_ID();

View File

@ -1,10 +1,13 @@
package com.ruoyi.ss.store.service;
import com.ruoyi.ss.store.domain.Store;
import com.ruoyi.ss.store.domain.StoreCountVO;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.domain.StoreVo;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* 商户Service接口
@ -90,4 +93,12 @@ public interface IStoreService
* @param query 查询条件
*/
int selectCount(StoreQuery query);
/**
* 查询用户ID列表
* @param userIds
* @return
*/
Map<Long, Integer> selectCountMapByUserIds(List<Long> userIds);
}

View File

@ -6,8 +6,10 @@ import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.device.domain.SmDeviceQuery;
import com.ruoyi.ss.device.service.ISmDeviceService;
import com.ruoyi.ss.store.domain.Store;
import com.ruoyi.ss.store.domain.StoreCountVO;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.domain.StoreVo;
import com.ruoyi.ss.store.domain.enums.StoreGroupBy;
import com.ruoyi.ss.store.mapper.StoreMapper;
import com.ruoyi.ss.store.service.IStoreService;
import com.ruoyi.ss.store.service.StoreAssembler;
@ -19,6 +21,8 @@ import com.ruoyi.common.utils.CollectionUtils;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 店铺Service业务层处理
@ -236,4 +240,33 @@ public class StoreServiceImpl implements IStoreService
return storeMapper.selectCount(query);
}
/**
* 查询用户ID列表
*
* @param userIds
* @return
*/
@Override
public Map<Long, Integer> selectCountMapByUserIds(List<Long> userIds) {
StoreQuery query = new StoreQuery();
query.setUserIds(userIds);
query.setGroupBy(StoreGroupBy.user_id.name());
return this.selectCountMap(query, StoreCountVO::getUserId);
}
/**
* 通用查询数量
*
* @param query
* @param keyMapper
* @return
*/
private <K> Map<K, Integer> selectCountMap(StoreQuery query, Function<? super StoreCountVO, ? extends K > keyMapper) {
List<StoreCountVO> list = storeMapper.selectCommonCount(query);
if (CollectionUtils.isEmptyElement(list)) {
return Collections.emptyMap();
}
return list.stream().collect(Collectors.toMap(keyMapper, StoreCountVO::getCount));
}
}

View File

@ -6,8 +6,6 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.valid.EnumValid;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillPayType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -24,7 +22,7 @@ import java.util.List;
* @date 2024-02-21
*/
@Data
public class SmTransactionBill extends BaseEntity
public class TransactionBill extends BaseEntity
{
private static final long serialVersionUID = 1L;

View File

@ -17,7 +17,7 @@ import java.util.List;
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SmTransactionBillQuery extends SmTransactionBill {
public class TransactionBillQuery extends TransactionBill {
@ApiModelProperty("年份")
private Integer year;
@ -61,4 +61,10 @@ public class SmTransactionBillQuery extends SmTransactionBill {
@ApiModelProperty("订单id列表")
private List<Long> billIds;
@ApiModelProperty("设备充值状态列表")
private List<String> deviceRechargeStatusList;
@ApiModelProperty("状态列表")
private List<String> statusList;
}

View File

@ -12,8 +12,9 @@ import lombok.Data;
*/
@ApiModel
@Data
public class SmTransactionBillVo extends SmTransactionBill {
public class TransactionBillVo extends TransactionBill {
@ApiModelProperty("用户名称")
@JsonView(JsonViewProfile.App.class)
private String userName;
@ApiModelProperty("商户(到账用户)名称")

View File

@ -1,6 +1,6 @@
package com.ruoyi.ss.transactionBill.domain.bo;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -9,7 +9,7 @@ import lombok.Data;
* 2024/3/27
*/
@Data
public class SmTransactionBillBO extends SmTransactionBill {
public class TransactionBillBO extends TransactionBill {
@ApiModelProperty("提现密码")
private String payPassword;

View File

@ -1,9 +1,9 @@
package com.ruoyi.ss.transactionBill.mapper;
import com.ruoyi.ss.dashboard.BillCountVo;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@ -15,7 +15,7 @@ import java.util.List;
* @author 邱贞招
* @date 2024-02-21
*/
public interface SmTransactionBillMapper
public interface TransactionBillMapper
{
/**
* 查询充值记录
@ -23,7 +23,7 @@ public interface SmTransactionBillMapper
* @param billId 充值记录主键
* @return 充值记录
*/
public SmTransactionBillVo selectSmTransactionBillByBillId(Long billId);
public TransactionBillVo selectSmTransactionBillByBillId(Long billId);
/**
* 查询充值记录列表
@ -31,23 +31,23 @@ public interface SmTransactionBillMapper
* @param smTransactionBill 充值记录
* @return 充值记录集合
*/
public List<SmTransactionBillVo> selectSmTransactionBillList(SmTransactionBillQuery smTransactionBill);
public List<TransactionBillVo> selectSmTransactionBillList(TransactionBillQuery smTransactionBill);
/**
* 新增充值记录
*
* @param smTransactionBill 充值记录
* @param transactionBill 充值记录
* @return 结果
*/
public int insertSmTransactionBill(SmTransactionBill smTransactionBill);
public int insertSmTransactionBill(TransactionBill transactionBill);
/**
* 修改充值记录
*
* @param smTransactionBill 充值记录
* @param transactionBill 充值记录
* @return 结果
*/
public int updateSmTransactionBill(SmTransactionBill smTransactionBill);
public int updateSmTransactionBill(TransactionBill transactionBill);
/**
* 删除充值记录
@ -69,7 +69,7 @@ public interface SmTransactionBillMapper
* 获取账单统计数据
* @param dto 查询条件
*/
List<BillCountVo> selectCount(SmTransactionBillQuery dto);
List<BillCountVo> selectCount(TransactionBillQuery dto);
/**
* 修改支付方式
@ -89,7 +89,7 @@ public interface SmTransactionBillMapper
* @param billNo 订单编号
* @return
*/
SmTransactionBill selectSmTransactionBillByBillNo(String billNo);
TransactionBill selectSmTransactionBillByBillNo(String billNo);
/**
* 订单取消

View File

@ -2,9 +2,9 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.ss.transactionBill.mapper.SmTransactionBillMapper">
<mapper namespace="com.ruoyi.ss.transactionBill.mapper.TransactionBillMapper">
<resultMap type="SmTransactionBillVo" id="SmTransactionBillResult" autoMapping="true">
<resultMap type="TransactionBillVo" id="SmTransactionBillResult" autoMapping="true">
<result property="transferIds" column="transfer_ids" typeHandler="com.ruoyi.system.mapper.typehandler.StringListTypeHandler"/>
</resultMap>
@ -69,9 +69,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endDate != null"> and date(stb.create_time) &lt;= date(#{endDate}) </if>
<if test="deviceRechargeStatus != null"> and stb.device_recharge_status = #{deviceRechargeStatus} </if>
<if test="suitId != null"> and stb.suit_id = #{suitId} </if>
<if test="deviceRechargeStatusList != null and deviceRechargeStatusList.size() > 0">
and stb.device_recharge_status in
<foreach item="item" collection="deviceRechargeStatusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="statusList != null and statusList.size() > 0">
and stb.status in
<foreach item="item" collection="statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</sql>
<select id="selectSmTransactionBillList" parameterType="SmTransactionBillQuery" resultMap="SmTransactionBillResult">
<select id="selectSmTransactionBillList" parameterType="TransactionBillQuery" resultMap="SmTransactionBillResult">
<include refid="selectSmTransactionBillVo"/>
<where>
<include refid="searchCondition"/>
@ -137,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
limit 1
</select>
<insert id="insertSmTransactionBill" parameterType="SmTransactionBill" useGeneratedKeys="true" keyProperty="billId">
<insert id="insertSmTransactionBill" parameterType="TransactionBill" useGeneratedKeys="true" keyProperty="billId">
insert into sm_transaction_bill
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="billNo != null">bill_no,</if>
@ -207,7 +219,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="updateSmTransactionBill" parameterType="SmTransactionBill">
<update id="updateSmTransactionBill" parameterType="TransactionBill">
update sm_transaction_bill
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
@ -271,7 +283,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="cancelRecharge">
update sm_transaction_bill
set status = #{status}
where bill_no = #{billNo} and status = '1' and `type` = '1'
where bill_no = #{billNo} and status in ('1', '6') and `type` = '1'
</update>
<sql id="approvalWithDraw">

View File

@ -1,6 +1,6 @@
package com.ruoyi.ss.transactionBill.service;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import java.util.List;
@ -14,6 +14,6 @@ public interface TransactionAssembler {
* 拼接渠道名称
* @param list
*/
void assembleChannelName(List<SmTransactionBillVo> list);
void assembleChannelName(List<TransactionBillVo> list);
}

View File

@ -1,15 +1,16 @@
package com.ruoyi.ss.transactionBill.service;
import com.ruoyi.ss.dashboard.BillCountVo;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.bo.SmTransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.bo.TransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillPayType;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 充值记录Service接口
@ -17,7 +18,7 @@ import java.util.List;
* @author 邱贞招
* @date 2024-02-21
*/
public interface ISmTransactionBillService
public interface TransactionBillService
{
/**
* 查询充值记录
@ -25,7 +26,7 @@ public interface ISmTransactionBillService
* @param billId 充值记录主键
* @return 充值记录
*/
public SmTransactionBillVo selectSmTransactionBillByBillId(Long billId);
public TransactionBillVo selectSmTransactionBillByBillId(Long billId);
/**
* 查询充值记录列表
@ -33,23 +34,23 @@ public interface ISmTransactionBillService
* @param smTransactionBillQuery 充值记录查询条件
* @return 充值记录集合
*/
public List<SmTransactionBillVo> selectSmTransactionBillList(SmTransactionBillQuery smTransactionBillQuery);
public List<TransactionBillVo> selectSmTransactionBillList(TransactionBillQuery smTransactionBillQuery);
/**
* 新增充值记录
*
* @param smTransactionBill 充值记录
* @param transactionBill 充值记录
* @return 结果
*/
public int insertSmTransactionBill(SmTransactionBill smTransactionBill);
public int insertSmTransactionBill(TransactionBill transactionBill);
/**
* 修改充值记录
*
* @param smTransactionBill 充值记录
* @param transactionBill 充值记录
* @return 结果
*/
public int updateSmTransactionBill(SmTransactionBill smTransactionBill);
public int updateSmTransactionBill(TransactionBill transactionBill);
/**
* 批量删除充值记录
@ -72,14 +73,14 @@ public interface ISmTransactionBillService
* @param dto
* @return
*/
List<BillCountVo> selectCount(SmTransactionBillQuery dto);
List<BillCountVo> selectCount(TransactionBillQuery dto);
/**
* 创建订单
* @param body 订单信息
* @return 新增的数据订单编号
*/
String addOrder(SmTransactionBill body);
String addOrder(TransactionBill body);
/**
* 更新支付方式
@ -112,18 +113,18 @@ public interface ISmTransactionBillService
* 根据订单编号查询数据
* @param billNo 订单编号
*/
SmTransactionBill selectSmTransactionBillByBillNo(String billNo);
TransactionBill selectSmTransactionBillByBillNo(String billNo);
/**
* 获取未支付的充值订单
* @return 订单列表
*/
List<SmTransactionBillVo> selectUnpaidRecharge();
List<TransactionBillVo> selectNoPayedRecharge();
/**
* 提现
*/
String addWithdraw(SmTransactionBillBO data);
String addWithdraw(TransactionBillBO data);
/**
* 提现审核通过
@ -169,7 +170,7 @@ public interface ISmTransactionBillService
* @param dto 查询条件
* @return 统计信息
*/
List<BillCountVo> selectLandlordCount(SmTransactionBillQuery dto);
List<BillCountVo> selectLandlordCount(TransactionBillQuery dto);
/**
* 刷新订单支付结果
@ -195,5 +196,13 @@ public interface ISmTransactionBillService
* @param userId
* @return
*/
List<SmTransactionBillVo> selectDeviceRechargeFailList(Long userId);
List<TransactionBillVo> selectDeviceRechargeFailList(Long userId);
/**
* 查询支付结果直到过期
* @param billNo 订单编号
* @param delay 延迟时间
* @param timeUnit 时间单位
*/
void refreshPayResultBeforeExpire(String billNo, int delay, TimeUnit timeUnit);
}

View File

@ -1,7 +1,7 @@
package com.ruoyi.ss.transactionBill.service;
import com.ruoyi.common.core.domain.ValidateResult;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
/**
* 2024/4/22
@ -13,7 +13,7 @@ public interface TransactionBillValidator {
* @param data
* @return
*/
ValidateResult preAddOrder(SmTransactionBill data);
ValidateResult preAddOrder(TransactionBill data);
/**
* 获取订单详情前校验

View File

@ -4,12 +4,11 @@ import com.ruoyi.common.utils.CollectionUtils;
import com.ruoyi.ss.channel.domain.SmChannel;
import com.ruoyi.ss.channel.domain.SmChannelQuery;
import com.ruoyi.ss.channel.service.ISmChannelService;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -31,15 +30,15 @@ public class TransactionAssemblerImpl implements TransactionAssembler {
* @param list
*/
@Override
public void assembleChannelName(List<SmTransactionBillVo> list) {
public void assembleChannelName(List<TransactionBillVo> list) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
SmChannelQuery query = new SmChannelQuery();
query.setChannelIds(list.stream().map(SmTransactionBillVo::getChannelId).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
query.setChannelIds(list.stream().map(TransactionBillVo::getChannelId).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
Map<Long, SmChannel> map = channelService.selectMap(query, SmChannel::getChannelId);
for (SmTransactionBillVo bill : list) {
for (TransactionBillVo bill : list) {
SmChannel channel = map.get(bill.getChannelId());
if (channel != null) {
bill.setChannelName(channel.getName());

View File

@ -16,13 +16,13 @@ import com.ruoyi.ss.store.domain.StoreVo;
import com.ruoyi.ss.store.service.IStoreService;
import com.ruoyi.ss.suit.domain.SuitVo;
import com.ruoyi.ss.suit.service.ISuitService;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.bo.SmTransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.bo.TransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.enums.*;
import com.ruoyi.ss.transactionBill.mapper.SmTransactionBillMapper;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.mapper.TransactionBillMapper;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.mapper.SmUserMapper;
@ -43,6 +43,7 @@ import com.ruoyi.common.utils.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -54,9 +55,9 @@ import java.util.stream.Collectors;
*/
@Service("transactionBillService")
@Slf4j
public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
public class TransactionBillServiceImpl implements TransactionBillService {
@Autowired
private SmTransactionBillMapper smTransactionBillMapper;
private TransactionBillMapper transactionBillMapper;
@Autowired
private ISmChannelService channelService;
@ -94,6 +95,9 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Autowired
private ISuitService suitService;
@Autowired
private ScheduledExecutorService scheduledExecutorService;
@Value("${sm.withdraw.password.enable}")
private Boolean smWithdrawPasswordEnable; // 是否开启提现密码
@ -104,9 +108,9 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
* @return 充值记录
*/
@Override
public SmTransactionBillVo selectSmTransactionBillByBillId(Long billId)
public TransactionBillVo selectSmTransactionBillByBillId(Long billId)
{
return smTransactionBillMapper.selectSmTransactionBillByBillId(billId);
return transactionBillMapper.selectSmTransactionBillByBillId(billId);
}
/**
@ -116,36 +120,36 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
* @return 充值记录
*/
@Override
public List<SmTransactionBillVo> selectSmTransactionBillList(SmTransactionBillQuery smTransactionBillQuery)
public List<TransactionBillVo> selectSmTransactionBillList(TransactionBillQuery smTransactionBillQuery)
{
return smTransactionBillMapper.selectSmTransactionBillList(smTransactionBillQuery);
return transactionBillMapper.selectSmTransactionBillList(smTransactionBillQuery);
}
/**
* 新增充值记录
*
* @param smTransactionBill 充值记录
* @param transactionBill 充值记录
* @return 结果
*/
@Override
@Transactional
public int insertSmTransactionBill(SmTransactionBill smTransactionBill)
public int insertSmTransactionBill(TransactionBill transactionBill)
{
smTransactionBill.setCreateTime(DateUtils.getNowDate());
smTransactionBill.setBillNo(String.valueOf(SnowFlakeUtil.newId()));
return smTransactionBillMapper.insertSmTransactionBill(smTransactionBill);
transactionBill.setCreateTime(DateUtils.getNowDate());
transactionBill.setBillNo(String.valueOf(SnowFlakeUtil.newId()));
return transactionBillMapper.insertSmTransactionBill(transactionBill);
}
/**
* 修改充值记录
*
* @param smTransactionBill 充值记录
* @param transactionBill 充值记录
* @return 结果
*/
@Override
public int updateSmTransactionBill(SmTransactionBill smTransactionBill)
public int updateSmTransactionBill(TransactionBill transactionBill)
{
return smTransactionBillMapper.updateSmTransactionBill(smTransactionBill);
return transactionBillMapper.updateSmTransactionBill(transactionBill);
}
/**
@ -157,7 +161,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Override
public int deleteSmTransactionBillByBillIds(Long[] billIds)
{
return smTransactionBillMapper.deleteSmTransactionBillByBillIds(billIds);
return transactionBillMapper.deleteSmTransactionBillByBillIds(billIds);
}
/**
@ -169,7 +173,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Override
public int deleteSmTransactionBillByBillId(Long billId)
{
return smTransactionBillMapper.deleteSmTransactionBillByBillId(billId);
return transactionBillMapper.deleteSmTransactionBillByBillId(billId);
}
/**
@ -178,18 +182,18 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
* @return
*/
@Override
public List<BillCountVo> selectCount(SmTransactionBillQuery dto) {
return smTransactionBillMapper.selectCount(dto);
public List<BillCountVo> selectCount(TransactionBillQuery dto) {
return transactionBillMapper.selectCount(dto);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String addOrder(SmTransactionBill data) {
public String addOrder(TransactionBill data) {
// 校验
ServiceUtil.assertion(transactionBillValidator.preAddOrder(data));
// 下单
SmTransactionBill order = parseToOrder(data);
TransactionBill order = parseToOrder(data);
ServiceUtil.assertion(this.insertSmTransactionBill(order) != 1, "下单失败");
// 加入延时队列超时取消
@ -199,8 +203,8 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
}
// 转换为订单所需的数据
private SmTransactionBill parseToOrder(SmTransactionBill data) {
SmTransactionBill order = new SmTransactionBill();
private TransactionBill parseToOrder(TransactionBill data) {
TransactionBill order = new TransactionBill();
// 基础信息
order.setUserId(data.getUserId());
order.setSuitTime(data.getSuitTime());
@ -251,7 +255,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Override
@Transactional(rollbackFor = Exception.class)
public String addWithdraw(SmTransactionBillBO data) {
public String addWithdraw(TransactionBillBO data) {
Long userId = data.getUserId();
// 参数校验
ServiceUtil.assertion(userId == null, "参数错误用户id为空");
@ -300,7 +304,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
SmUserVo afterUser = smUserMapper.selectSimpleById(userId);
// 创建申请订单
SmTransactionBill bill = new SmTransactionBill();
TransactionBill bill = new TransactionBill();
bill.setUserId(userId);
bill.setType(TransactionBillType.WITHDRAW.getType());
bill.setMchId(userId);
@ -331,7 +335,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
try {
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.APPROVAL_WITHDRAW, billId.toString()), "该提现申请正在审核,请刷新后重试");
int updateCount = smTransactionBillMapper.doPassWithdraw(billId, remark);
int updateCount = transactionBillMapper.doPassWithdraw(billId, remark);
ServiceUtil.assertion(updateCount != 1, "提现审核失败,请刷新后重试");
return true;
@ -346,11 +350,11 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
try {
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.APPROVAL_WITHDRAW, billId.toString()), "该提现申请正在审核,请刷新后重试");
int updateCount = smTransactionBillMapper.doRejectWithdraw(billId, remark);
int updateCount = transactionBillMapper.doRejectWithdraw(billId, remark);
ServiceUtil.assertion(updateCount != 1, "提现审核失败,请刷新后重试");
// 返还客户余额
SmTransactionBill bill = smTransactionBillMapper.selectSmTransactionBillByBillId(billId);
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillId(billId);
ServiceUtil.assertion(bill == null || bill.getUserId() == null, "数据不存在");
userService.addBalance(bill.getUserId(), bill.getMoney());
@ -371,11 +375,11 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
try {
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.PAY_WITHDRAW, billId.toString()), "该提现申请正在打款,请刷新后重试");
SmTransactionBill bill = smTransactionBillMapper.selectSmTransactionBillByBillId(billId);
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillId(billId);
ServiceUtil.assertion(bill == null, "单据不存在");
// 更新为打款中
int updateCount = smTransactionBillMapper.doPayWithdraw(billId);
int updateCount = transactionBillMapper.doPayWithdraw(billId);
ServiceUtil.assertion(updateCount != 1, "单据状态发生变化,请刷新后重试");
// 发起打款
@ -396,7 +400,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Transactional
public void withdrawSuccess(Long billId) {
// 修改状态
int updateCount = smTransactionBillMapper.withdrawSuccess(billId);
int updateCount = transactionBillMapper.withdrawSuccess(billId);
ServiceUtil.assertion(updateCount != 1, "单据状态发生变化,请刷新后重试");
}
@ -404,7 +408,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Transactional
public void withdrawFailed(Long billId) {
// 修改状态
int updateCount = smTransactionBillMapper.withdrawFailed(billId);
int updateCount = transactionBillMapper.withdrawFailed(billId);
ServiceUtil.assertion(updateCount != 1, "单据状态发生变化,请刷新后重试");
}
@ -416,14 +420,14 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Override
public boolean updateWxTransferDetailIds(Long billId, List<String> transferIds) {
ServiceUtil.assertion(billId == null || CollectionUtils.isEmpty(transferIds), "参数错误:提现单号或微信批次明细列表为空");
SmTransactionBill bill = new SmTransactionBill();
TransactionBill bill = new TransactionBill();
bill.setBillId(billId);
bill.setTransferIds(transferIds);
return smTransactionBillMapper.updateSmTransactionBill(bill) == 1;
return transactionBillMapper.updateSmTransactionBill(bill) == 1;
}
@Override
public List<BillCountVo> selectLandlordCount(SmTransactionBillQuery dto) {
public List<BillCountVo> selectLandlordCount(TransactionBillQuery dto) {
List<BillCountVo> list = this.selectCount(dto);
// 若startDate与endDate不为空则将其中间数据补全不让其为空
@ -463,16 +467,16 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Override
@Transactional
public void refreshPayResult(List<Long> billIds) {
SmTransactionBillQuery dto = new SmTransactionBillQuery();
TransactionBillQuery dto = new TransactionBillQuery();
dto.setBillIds(billIds);
List<SmTransactionBillVo> billList = smTransactionBillMapper.selectSmTransactionBillList(dto);
List<TransactionBillVo> billList = transactionBillMapper.selectSmTransactionBillList(dto);
if (CollectionUtils.isEmpty(billList)) {
return;
}
// 获取支付结果并判断是否支付成功若成功则更新数据
Date now = new Date();
for (SmTransactionBillVo bill : billList) {
for (TransactionBillVo bill : billList) {
if (TransactionBillStatus.PAYING.getStatus().equals(bill.getStatus()) || TransactionBillStatus.UNPAID.getStatus().equals(bill.getStatus()) ) {
boolean payResult = getPayResult(bill.getBillNo());
if (payResult) {
@ -486,7 +490,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Transactional
public void paying(Long billId) {
ServiceUtil.assertion(billId == null, "订单id不允许为空");
int updateCount = smTransactionBillMapper.paying(billId);
int updateCount = transactionBillMapper.paying(billId);
ServiceUtil.assertion(updateCount != 1, "订单状态发生变化,请刷新后重试");
}
@ -500,7 +504,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
public boolean rechargeDevice(Long billId, boolean validate) {
ServiceUtil.assertion(billId == null, "参数错误,billId不允许为空");
SmTransactionBill bill = smTransactionBillMapper.selectSmTransactionBillByBillId(billId);
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillId(billId);
if (validate) {
ServiceUtil.assertion(bill == null || !TransactionBillType.RECHARGE.getType().equals(bill.getType()), "不存在的充值订单");
@ -512,7 +516,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
// deviceService.addElectricity(bill.getDeviceId(), computeElectricity(bill));
// 修改设备充值状态成功
smTransactionBillMapper.updateDeviceRechargeStatus(bill.getBillId(), TransactionBillDeviceRechargeStatus.SUCCESS.getStatus());
transactionBillMapper.updateDeviceRechargeStatus(bill.getBillId(), TransactionBillDeviceRechargeStatus.SUCCESS.getStatus());
return true;
}
@ -527,11 +531,11 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Transactional
public int updatePayType(Long billId, TransactionBillPayType transactionBillPayType, String accountNo) {
ServiceUtil.assertion( billId == null, "订单id不允许为空");
SmTransactionBill dbBill = smTransactionBillMapper.selectSmTransactionBillByBillId(billId);
TransactionBill dbBill = transactionBillMapper.selectSmTransactionBillByBillId(billId);
ServiceUtil.assertion(dbBill == null, "订单不存在");
ServiceUtil.assertion(!TransactionBillStatus.UNPAID.getStatus().equals(dbBill.getStatus()), "只有未支付的订单可以更改支付方式");
return smTransactionBillMapper.updatePayType(billId, transactionBillPayType.getType(), accountNo);
return transactionBillMapper.updatePayType(billId, transactionBillPayType.getType(), accountNo);
}
/**
@ -543,7 +547,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Transactional
public boolean getPayResult(String billNo) {
// 查询订单
SmTransactionBill bill = smTransactionBillMapper.selectSmTransactionBillByBillNo(billNo);
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillNo(billNo);
ServiceUtil.assertion(bill == null, "订单不存在");
if (TransactionBillPayType.WECHAT.getType().equals(bill.getChannelId())) {
@ -563,11 +567,11 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
@Override
@Transactional
public void rechargeSuccess(String billNo, Date payTime) {
SmTransactionBill bill = smTransactionBillMapper.selectSmTransactionBillByBillNo(billNo);
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillNo(billNo);
ServiceUtil.assertion(bill == null || !TransactionBillType.RECHARGE.getType().equals(bill.getType()), "充值订单不存在");
// 修改订单状态为成功
int updateCount = smTransactionBillMapper.rechargeSuccess(bill.getBillId(), payTime);
int updateCount = transactionBillMapper.rechargeSuccess(bill.getBillId(), payTime);
ServiceUtil.assertion(updateCount != 1, "修改订单状态失败,请刷新后重试");
// 房东余额增加
@ -583,7 +587,7 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
}
// 计算充值电量
// private BigDecimal computeElectricity(SmTransactionBill bill) {
// private BigDecimal computeElectricity(TransactionBill bill) {
// if (bill == null) {
// return BigDecimal.ZERO;
// }
@ -596,10 +600,10 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
* @param balance 余额
*/
private void updateAfterBalance(Long billId, BigDecimal balance) {
SmTransactionBill data = new SmTransactionBill();
TransactionBill data = new TransactionBill();
data.setBillId(billId);
data.setAfterBalance(balance);
smTransactionBillMapper.updateSmTransactionBill(data);
transactionBillMapper.updateSmTransactionBill(data);
}
/**
@ -612,35 +616,36 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
public int cancelRecharge(String billNo, TransactionBillStatus status) {
ServiceUtil.assertion(!TransactionBillStatus.isCancel(status.getStatus()), "参数错误:状态并非取消状态");
SmTransactionBill bill = smTransactionBillMapper.selectSmTransactionBillByBillNo(billNo);
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillNo(billNo);
ServiceUtil.assertion(bill == null, "订单不存在");
// 用户自行取消验证身份
ServiceUtil.assertion(TransactionBillStatus.CANCELED.equals(status) && !UserUtil.hasFrontUser(bill.getUserId()), "这不是您的订单");
ServiceUtil.assertion(!TransactionBillStatus.UNPAID.getStatus().equals(bill.getStatus()), "订单状态非未支付,不允许取消");
List<String> allowCancel = Arrays.asList(TransactionBillStatus.UNPAID.getStatus(), TransactionBillStatus.PAYING.getStatus());
ServiceUtil.assertion(!allowCancel.contains(bill.getStatus()), "订单状态非未支付或支付中,不允许取消");
ServiceUtil.assertion(!TransactionBillType.RECHARGE.getType().equals(bill.getType()), "非充值订单,不允许取消");
// 执行取消订单
int updateCount = smTransactionBillMapper.cancelRecharge(billNo, status.getStatus());
int updateCount = transactionBillMapper.cancelRecharge(billNo, status.getStatus());
ServiceUtil.assertion(updateCount != 1, "订单取消失败,请刷新后重试");
// 关闭支付订单
if (TransactionBillPayType.WECHAT.getType().equals(bill.getChannelId())) {
wxPayService.closeOrder(billNo);
if (TransactionBillStatus.PAYING.getStatus().equals(bill.getStatus())) {
this.closeOrder(billNo);
}
return updateCount;
}
@Override
public SmTransactionBill selectSmTransactionBillByBillNo(String billNo) {
return smTransactionBillMapper.selectSmTransactionBillByBillNo(billNo);
public TransactionBill selectSmTransactionBillByBillNo(String billNo) {
return transactionBillMapper.selectSmTransactionBillByBillNo(billNo);
}
@Override
public List<SmTransactionBillVo> selectUnpaidRecharge() {
SmTransactionBillQuery dto = new SmTransactionBillQuery();
dto.setStatus(TransactionBillStatus.UNPAID.getStatus());
public List<TransactionBillVo> selectNoPayedRecharge() {
TransactionBillQuery dto = new TransactionBillQuery();
dto.setStatusList(Arrays.asList(TransactionBillStatus.UNPAID.getStatus(), TransactionBillStatus.PAYING.getStatus()));
dto.setType(TransactionBillType.RECHARGE.getType());
return this.selectSmTransactionBillList(dto);
}
@ -652,22 +657,22 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
* @return
*/
@Override
public List<SmTransactionBillVo> selectDeviceRechargeFailList(Long userId) {
public List<TransactionBillVo> selectDeviceRechargeFailList(Long userId) {
if (userId == null) {
return Collections.emptyList();
}
// 查询充值失败列表
SmTransactionBillQuery dto = new SmTransactionBillQuery();
TransactionBillQuery dto = new TransactionBillQuery();
dto.setUserId(userId);
dto.setStatus(TransactionBillStatus.SUCCESS.getStatus());
dto.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.FAIL.getStatus());
dto.setType(TransactionBillType.RECHARGE.getType());
List<SmTransactionBillVo> list = this.selectSmTransactionBillList(dto);
List<TransactionBillVo> list = this.selectSmTransactionBillList(dto);
if (!CollectionUtils.isEmptyElement(list)) {
// 修改状态为蓝牙充值
smTransactionBillMapper.updateDeviceRechargeStatusByIds(
list.stream().map(SmTransactionBillVo::getBillId).collect(Collectors.toList()),
transactionBillMapper.updateDeviceRechargeStatusByIds(
list.stream().map(TransactionBillVo::getBillId).collect(Collectors.toList()),
TransactionBillDeviceRechargeStatus.BLUETOOTH.getStatus());
}
@ -675,4 +680,70 @@ public class SmTransactionBillServiceImpl implements ISmTransactionBillService {
dto.setDeviceRechargeStatus(TransactionBillDeviceRechargeStatus.BLUETOOTH.getStatus());
return selectSmTransactionBillList(dto);
}
/**
* 查询支付结果直到过期
*
* @param billNo 订单编号
* @param delay 延迟时间
* @param timeUnit 时间单位
*/
@Override
@Transactional
public void refreshPayResultBeforeExpire(String billNo, int delay, TimeUnit timeUnit) {
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillNo(billNo);
if (bill == null) {
log.error("获取订单{}为空", billNo);
return;
}
Date now = new Date();
boolean payResult = false;
// 判断是否支付成功
try {
if (TransactionBillStatus.PAYING.getStatus().equals(bill.getStatus())) {
payResult = getPayResult(bill.getBillNo());
if (payResult) {
// 支付成功
this.rechargeSuccess(bill.getBillNo(), now);
return;
}
}
} catch (Exception e) {
log.error("刷新支付结果出错:{}", e.getMessage());
}
// 未支付成功
if (!payResult) {
if (bill.getExpireTime() != null && now.compareTo(bill.getExpireTime()) < 0) {
// 未过期继续延迟查询
log.info("{}支付失败,未过期,继续延迟查询", billNo);
scheduledExecutorService.schedule(() -> {
this.refreshPayResultBeforeExpire(billNo, delay , timeUnit);
}, delay, timeUnit);
} else {
log.info("{}支付失败,过期取消订单", billNo);
// 过期取消订单
int updateCount = transactionBillMapper.cancelRecharge(billNo, TransactionBillStatus.SYS_CANCELED.getStatus());
log.info("过期取消订单,结果:{}", updateCount);
if (updateCount == 1) {
// 关闭支付订单
this.closeOrder(billNo);
}
}
}
}
// 关闭订单
private void closeOrder(String billNo) {
TransactionBill bill = transactionBillMapper.selectSmTransactionBillByBillNo(billNo);
if (bill == null) {
return;
}
if (TransactionBillPayType.WECHAT.getType().equals(bill.getChannelId())) {
wxPayService.closeOrder(billNo);
}
}
}

View File

@ -11,8 +11,8 @@ import com.ruoyi.ss.model.domain.enums.ModelTag;
import com.ruoyi.ss.store.service.StoreValidator;
import com.ruoyi.ss.suit.domain.SuitVo;
import com.ruoyi.ss.suit.service.ISuitService;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
import com.ruoyi.ss.user.service.UserValidator;
import org.springframework.beans.factory.annotation.Autowired;
@ -45,10 +45,10 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
private StoreValidator storeValidator;
@Autowired
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
@Override
public ValidateResult preAddOrder(SmTransactionBill data) {
public ValidateResult preAddOrder(TransactionBill data) {
if (data == null) {
return error("数据不能为空");
}
@ -128,7 +128,7 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
* @return
*/
private boolean allowGet(Long billId, Long userId) {
SmTransactionBill bill = transactionBillService.selectSmTransactionBillByBillId(billId);
TransactionBill bill = transactionBillService.selectSmTransactionBillByBillId(billId);
if (bill != null ) {
List<Long> allowUsers = Arrays.asList(bill.getUserId(), bill.getMchId());
return allowUsers.contains(userId);

View File

@ -1,6 +1,8 @@
package com.ruoyi.ss.user.domain;
import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.common.core.domain.entity.SmUser;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -29,4 +31,8 @@ public class SmUserVo extends SmUser {
@ApiModelProperty("总收入")
private BigDecimal totalIncome; // 总收入
@ApiModelProperty("商户店铺数量")
@JsonView(JsonViewProfile.App.class)
private Integer storeCount;
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.ss.user.service;
import com.ruoyi.ss.user.domain.SmUserVo;
import java.util.List;
/**
* @author wjh
* 2024/5/6
*/
public interface UserAssembler {
/**
* 拼接用户店铺数量
* @param list
*/
void assembleStoreCount(List<SmUserVo> list);
}

View File

@ -0,0 +1,44 @@
package com.ruoyi.ss.user.service.impl;
import com.ruoyi.common.utils.CollectionUtils;
import com.ruoyi.ss.store.domain.StoreCountVO;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.service.IStoreService;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.UserAssembler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author wjh
* 2024/5/6
*/
@Service
public class UserAssemblerImpl implements UserAssembler {
@Autowired
private IStoreService storeService;
/**
* 拼接用户店铺数量
*
* @param list
*/
@Override
public void assembleStoreCount(List<SmUserVo> list) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
Map<Long, Integer> map = storeService.selectCountMapByUserIds(list.stream().map(SmUserVo::getUserId).collect(Collectors.toList()));
for (SmUserVo user : list) {
Integer count = map.get(user.getUserId());
user.setStoreCount(count == null ? 0 : count);
}
}
}

View File

@ -11,11 +11,11 @@ import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.SnowFlakeUtil;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.ss.account.service.ISmAccountService;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillPayType;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.ISmUserService;
import com.ruoyi.ss.wxPay.domain.enums.TransferScene;
@ -44,6 +44,8 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -65,7 +67,7 @@ public class WxPayService implements IWxPayService {
private WxPayConfig wxPayConfig;
@Autowired
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
@Autowired
private ISmUserService smUserService;
@ -85,6 +87,9 @@ public class WxPayService implements IWxPayService {
@Autowired
private TransferBatchService transferBatchService;
@Autowired
private ScheduledExecutorService scheduledExecutorService;
private static final String CNY = "CNY";
@Override
@ -93,7 +98,7 @@ public class WxPayService implements IWxPayService {
try {
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.PREPAY.getKey() + ":" + billNo), "当前订单正在支付,请刷新后重试");
SmTransactionBill bill = transactionBillService.selectSmTransactionBillByBillNo(billNo);
TransactionBill bill = transactionBillService.selectSmTransactionBillByBillNo(billNo);
ServiceUtil.assertion(bill == null, "未查询到相关订单");
ServiceUtil.assertion(!Objects.equals(bill.getChannelId(), TransactionBillPayType.WECHAT.getType()), "该订单不是微信支付订单");
ServiceUtil.assertion(!TransactionBillStatus.UNPAID.getStatus().equals(bill.getStatus()), "只能支付未支付的订单");
@ -117,7 +122,14 @@ public class WxPayService implements IWxPayService {
// 支付中
try {
// 支付中
transactionBillService.paying(bill.getBillId());
// 每隔20秒查询支付结果直到过期首次10秒查询
scheduledExecutorService.schedule(() -> {
transactionBillService.refreshPayResultBeforeExpire(bill.getBillNo(), 20, TimeUnit.SECONDS);
}, 10, TimeUnit.SECONDS);
} catch (Exception e) {
this.closeOrder(bill.getBillNo());
throw e;
@ -209,7 +221,7 @@ public class WxPayService implements IWxPayService {
@Transactional
public InitiateBatchTransferResponse payWithdraw(Long billId) {
ServiceUtil.assertion(billId == null, "订单id不允许为空");
SmTransactionBill bill = transactionBillService.selectSmTransactionBillByBillId(billId);
TransactionBill bill = transactionBillService.selectSmTransactionBillByBillId(billId);
ServiceUtil.assertion(bill == null, "单据不存在");
ServiceUtil.assertion(TransactionBillStatus.WITHDRAW_PASSED.getStatus().equals(bill.getStatus()), "当前提现单据状态异常");
ServiceUtil.assertion(StringUtils.isBlank(bill.getAccountNo()), "提现账号异常");
@ -248,7 +260,7 @@ public class WxPayService implements IWxPayService {
if (NotifyEventType.MCHTRANSFER_BATCH_FINISHED.getValue().equals(notification.getEventType())) {
// 验签解密并转换成 TransferBatchGet
TransferBatchGet transferBatchGet = checkAndParse(request, body, TransferBatchGet.class);
SmTransactionBill bill = transactionBillService.selectSmTransactionBillByBillNo(transferBatchGet.getOutBatchNo());
TransactionBill bill = transactionBillService.selectSmTransactionBillByBillNo(transferBatchGet.getOutBatchNo());
ServiceUtil.assertion(bill == null, "订单不存在");
// 修改订单状态
@ -306,7 +318,7 @@ public class WxPayService implements IWxPayService {
* @param plaintext 明文
*/
private void saveNotifyData(String billNo, Notification body, Object plaintext) {
SmTransactionBill bill = transactionBillService.selectSmTransactionBillByBillNo(billNo);
TransactionBill bill = transactionBillService.selectSmTransactionBillByBillNo(billNo);
SmWxPayNotify data = new SmWxPayNotify();
data.setNotifyId(body.getId());
data.setBillId(bill.getBillId());
@ -348,7 +360,7 @@ public class WxPayService implements IWxPayService {
return amount;
}
private String getDescription(SmTransactionBill bill) {
private String getDescription(TransactionBill bill) {
return TransactionBillType.parse(bill.getType()).getDescription();
}

View File

@ -2,7 +2,7 @@ package com.ruoyi.task.bill;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.wxPay.service.IWxPayService;
import com.ruoyi.ss.wxPay.service.WxPayService;
import lombok.Getter;
@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
@Setter
public class BillDelayed implements Delayed {
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
private IWxPayService wxPayService = SpringUtils.getBean(WxPayService.class);

View File

@ -1,6 +1,6 @@
package com.ruoyi.task.bill;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -47,7 +47,7 @@ public class BillDelayedManager {
@Bean
@Scope("prototype")
public BillDelayed billDelayed() {
ISmTransactionBillService transactionBillService = context.getBean(ISmTransactionBillService.class);
TransactionBillService transactionBillService = context.getBean(TransactionBillService.class);
BillDelayed delayed = new BillDelayed();
delayed.setTransactionBillService(transactionBillService);
return delayed;

View File

@ -1,9 +1,9 @@
package com.ruoyi.task.bill;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
@ -25,7 +25,7 @@ import java.util.stream.Collectors;
public class BillStartTask implements ApplicationRunner {
@Autowired
private ISmTransactionBillService billService;
private TransactionBillService billService;
@Autowired
private BillDelayedManager billDelayedManager;
@ -33,7 +33,7 @@ public class BillStartTask implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("开始处理未支付的充值订单");
List<SmTransactionBillVo> billList = billService.selectUnpaidRecharge();
List<TransactionBillVo> billList = billService.selectNoPayedRecharge();
if (CollectionUtils.isEmpty(billList)) {
log.info("没有需要处理的订单");
return;
@ -42,7 +42,7 @@ public class BillStartTask implements ApplicationRunner {
// 未支付已过期
Date now = new Date();
for (SmTransactionBillVo bill : billList.stream().filter(item -> item.getExpireTime() != null && now.compareTo(item.getExpireTime()) >= 0).collect(Collectors.toList())) {
for (TransactionBillVo bill : billList.stream().filter(item -> item.getExpireTime() != null && now.compareTo(item.getExpireTime()) >= 0).collect(Collectors.toList())) {
log.info("[未支付已过期]正在处理:{}", bill.getBillNo());
try {
billService.cancelRecharge(bill.getBillNo(), TransactionBillStatus.SYS_CANCELED);
@ -52,7 +52,7 @@ public class BillStartTask implements ApplicationRunner {
}
// 未支付未过期加入延时队列
for (SmTransactionBill bill : billList.stream().filter(item -> item.getExpireTime() != null && now.compareTo(item.getExpireTime()) < 0).collect(Collectors.toList())) {
for (TransactionBill bill : billList.stream().filter(item -> item.getExpireTime() != null && now.compareTo(item.getExpireTime()) < 0).collect(Collectors.toList())) {
log.info("[未支付未过期]加入延时队列:{}", bill.getBillNo());
try {
billDelayedManager.add(bill.getBillNo(), bill.getExpireTime().getTime());

View File

@ -1,20 +1,23 @@
package com.ruoyi.task.bill;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -23,10 +26,10 @@ import java.util.stream.Collectors;
*/
@Component("payTask")
@Slf4j
public class PayTask {
public class PayTask implements ApplicationRunner {
@Autowired
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
/**
* 更新支付结果
@ -36,17 +39,40 @@ public class PayTask {
// 查询十分钟以内支付中的充值订单
Date now = new Date();
Date past = DateUtils.addMinutes(now, -10);
SmTransactionBillQuery dto = new SmTransactionBillQuery();
TransactionBillQuery dto = new TransactionBillQuery();
dto.setStartDate(past);
dto.setType(TransactionBillType.RECHARGE.getType());
dto.setStatus(TransactionBillStatus.PAYING.getStatus());
List<SmTransactionBillVo> billList = transactionBillService.selectSmTransactionBillList(dto);
List<TransactionBillVo> billList = transactionBillService.selectSmTransactionBillList(dto);
if (CollectionUtils.isEmpty(billList)) {
log.info("十分钟以内没有支付中的订单");
return;
}
transactionBillService.refreshPayResult(billList.stream().map(SmTransactionBill::getBillId).collect(Collectors.toList()));
transactionBillService.refreshPayResult(billList.stream().map(TransactionBill::getBillId).collect(Collectors.toList()));
}
@Override
public void run(ApplicationArguments args) throws Exception {
// 查询支付中的充值订单将其加入到延迟队列
log.info("查询支付中的充值订单,将其加入到延迟队列");
TransactionBillQuery dto = new TransactionBillQuery();
dto.setStatus(TransactionBillStatus.PAYING.getStatus());
dto.setType(TransactionBillType.RECHARGE.getType());
List<TransactionBillVo> list = transactionBillService.selectSmTransactionBillList(dto);
if (CollectionUtils.isEmpty(list)) {
log.info("没有支付中的订单");
return;
}
log.info("查询到{}个正在支付的订单", list.size());
for (TransactionBillVo bill : list) {
try {
transactionBillService.refreshPayResultBeforeExpire(bill.getBillNo(), 20, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("加入延迟队列异常:{} ", bill.getBillNo());
}
}
}
}

View File

@ -1,7 +1,7 @@
package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.wxPay.service.IWxPayService;
import com.wechat.pay.java.core.exception.ValidationException;
import io.swagger.annotations.Api;
@ -27,7 +27,7 @@ public class AppPayController {
private IWxPayService wxPayService;
@Autowired
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
@ApiOperation("微信支付")
@GetMapping("/wx/{billNo}")

View File

@ -9,15 +9,15 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.domain.bo.SmTransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.bo.TransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import com.ruoyi.ss.dashboard.BillCountVo;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
import com.ruoyi.web.core.annotation.UserTypePermission;
@ -46,7 +46,7 @@ import java.util.Objects;
public class AppTransactionBillController extends BaseController
{
@Autowired
private ISmTransactionBillService smTransactionBillService;
private TransactionBillService smTransactionBillService;
@Autowired
private TransactionAssembler transactionAssembler;
@ -60,12 +60,12 @@ public class AppTransactionBillController extends BaseController
@ApiOperation("查询本人订单列表")
@GetMapping("/rechargeList")
@JsonView(JsonViewProfile.App.class)
public TableDataInfo rechargeList(SmTransactionBillQuery smTransactionBill)
public TableDataInfo rechargeList(TransactionBillQuery smTransactionBill)
{
smTransactionBill.setUserId(getUserId());
smTransactionBill.setType(TransactionBillType.RECHARGE.getType());
startPage();
List<SmTransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
List<TransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
transactionAssembler.assembleChannelName(list);
return getDataTable(list);
}
@ -75,12 +75,12 @@ public class AppTransactionBillController extends BaseController
*/
@ApiOperation("查询本人提现记录列表")
@GetMapping("/withdrawList")
public TableDataInfo withdrawList(SmTransactionBillQuery smTransactionBill)
public TableDataInfo withdrawList(TransactionBillQuery smTransactionBill)
{
startPage();
smTransactionBill.setUserId(getUserId());
smTransactionBill.setType(TransactionBillType.WITHDRAW.getType());
List<SmTransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
List<TransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
return getDataTable(list);
}
@ -89,11 +89,11 @@ public class AppTransactionBillController extends BaseController
*/
@ApiOperation("查询本人收支列表")
@GetMapping("/list")
public TableDataInfo list(SmTransactionBillQuery smTransactionBill)
public TableDataInfo list(TransactionBillQuery smTransactionBill)
{
startPage();
smTransactionBill.setUserId(getUserId());
List<SmTransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
List<TransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
return getDataTable(list);
}
@ -102,7 +102,7 @@ public class AppTransactionBillController extends BaseController
@JsonView(JsonViewProfile.AppUser.class)
public AjaxResult detail(@PathVariable Long billId) {
ServiceUtil.assertion(transactionBillValidator.preGetDetailByApp(billId, getUserId()));
SmTransactionBillVo bill = smTransactionBillService.selectSmTransactionBillByBillId(billId);
TransactionBillVo bill = smTransactionBillService.selectSmTransactionBillByBillId(billId);
transactionAssembler.assembleChannelName(Collections.singletonList(bill));
return AjaxResult.success(bill);
}
@ -110,7 +110,7 @@ public class AppTransactionBillController extends BaseController
@UserTypePermission({UserType.LANDLORD})
@ApiOperation("获取房东统计信息")
@GetMapping("/landlordCount")
public AjaxResult landlordCount(@Validated({ValidGroup.Query.class}) SmTransactionBillQuery dto) {
public AjaxResult landlordCount(@Validated({ValidGroup.Query.class}) TransactionBillQuery dto) {
Date now = new Date();
if (dto.getEndDate() == null) {
dto.setEndDate(now);
@ -158,7 +158,7 @@ public class AppTransactionBillController extends BaseController
@ApiOperation("创建订单")
@PostMapping("/recharge")
public AjaxResult addRecharge(@RequestBody @Validated({ValidGroup.Recharge.class}) SmTransactionBill body) {
public AjaxResult addRecharge(@RequestBody @Validated({ValidGroup.Recharge.class}) TransactionBill body) {
body.setUserId(getUserId());
body.setChannelId(1L); // 微信支付
return AjaxResult.success("操作成功", smTransactionBillService.addOrder(body));
@ -173,7 +173,7 @@ public class AppTransactionBillController extends BaseController
@UserTypePermission({UserType.LANDLORD})
@ApiOperation("提现申请")
@PostMapping("/withdraw")
public AjaxResult withdraw(@RequestBody @Validated({ValidGroup.Withdraw.class}) SmTransactionBillBO data) {
public AjaxResult withdraw(@RequestBody @Validated({ValidGroup.Withdraw.class}) TransactionBillBO data) {
data.setUserId(getUserId());
return AjaxResult.success("操作成功", smTransactionBillService.addWithdraw(data));
}

View File

@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.user.domain.SmUserBO;
import com.ruoyi.ss.user.service.UserAssembler;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.ISmUserService;
@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.List;
/**
* 用户信息Controller
@ -34,13 +36,18 @@ public class AppUserController extends BaseController {
@Autowired
private IVerificationCodeService verificationCodeService;
@Autowired
private UserAssembler userAssembler;
@ApiOperation("获取当前登录前台用户的信息")
@GetMapping("/userInfo")
@JsonView(JsonViewProfile.App.class)
public AjaxResult userInfo() {
// 查询
SmUserVo user = userService.selectSmUserByUserId(getUserId());
userService.desensitization(Collections.singletonList(user));
List<SmUserVo> list = Collections.singletonList(user);
userService.desensitization(list);
userAssembler.assembleStoreCount(list);
return AjaxResult.success(user);
}

View File

@ -7,8 +7,8 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery;
import com.ruoyi.ss.balancePeriod.service.ISmBalancePeriodService;
import com.ruoyi.ss.businessRecord.service.ISmBusinessRecordService;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordVo;
@ -34,7 +34,7 @@ public class SmDashboardController {
@Autowired
private ISmTransactionBillService transactionBillService;
private TransactionBillService transactionBillService;
@Autowired
private ISmBalancePeriodService balancePeriodService;
@ -68,7 +68,7 @@ public class SmDashboardController {
* @return 统计数据
*/
@GetMapping("/hourBillCount")
public AjaxResult hourBillCount(@Validated(ValidGroup.Query.class) SmTransactionBillQuery dto) {
public AjaxResult hourBillCount(@Validated(ValidGroup.Query.class) TransactionBillQuery dto) {
dto.setGroupBy(TransactionBillGroupBy.create_hour.name());
dto.setStatus(TransactionBillStatus.SUCCESS.getStatus());
return AjaxResult.success(transactionBillService.selectCount(dto));

View File

@ -4,9 +4,9 @@ import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.ss.transactionBill.domain.bo.SmTransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBillVo;
import com.ruoyi.ss.transactionBill.domain.bo.TransactionBillBO;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -23,8 +23,8 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ss.transactionBill.domain.SmTransactionBill;
import com.ruoyi.ss.transactionBill.service.ISmTransactionBillService;
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@ -39,17 +39,17 @@ import com.ruoyi.common.core.page.TableDataInfo;
public class SmTransactionBillController extends BaseController
{
@Autowired
private ISmTransactionBillService smTransactionBillService;
private TransactionBillService smTransactionBillService;
/**
* 查询充值记录列表
*/
@PreAuthorize("@ss.hasPermi('system:bill:list')")
@GetMapping("/list")
public TableDataInfo list(SmTransactionBillQuery smTransactionBill)
public TableDataInfo list(TransactionBillQuery smTransactionBill)
{
startPage();
List<SmTransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
List<TransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
return getDataTable(list);
}
@ -59,10 +59,10 @@ public class SmTransactionBillController extends BaseController
@PreAuthorize("@ss.hasPermi('system:bill:export')")
@Log(title = "充值记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SmTransactionBillQuery smTransactionBill)
public void export(HttpServletResponse response, TransactionBillQuery smTransactionBill)
{
List<SmTransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
ExcelUtil<SmTransactionBillVo> util = new ExcelUtil<SmTransactionBillVo>(SmTransactionBillVo.class);
List<TransactionBillVo> list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill);
ExcelUtil<TransactionBillVo> util = new ExcelUtil<TransactionBillVo>(TransactionBillVo.class);
util.exportExcel(response, list, "充值记录数据");
}
@ -82,9 +82,9 @@ public class SmTransactionBillController extends BaseController
@PreAuthorize("@ss.hasPermi('system:bill:add')")
@Log(title = "充值记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SmTransactionBill smTransactionBill)
public AjaxResult add(@RequestBody TransactionBill transactionBill)
{
return toAjax(smTransactionBillService.insertSmTransactionBill(smTransactionBill));
return toAjax(smTransactionBillService.insertSmTransactionBill(transactionBill));
}
/**
@ -93,9 +93,9 @@ public class SmTransactionBillController extends BaseController
@PreAuthorize("@ss.hasPermi('system:bill:edit')")
@Log(title = "充值记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SmTransactionBill smTransactionBill)
public AjaxResult edit(@RequestBody TransactionBill transactionBill)
{
return toAjax(smTransactionBillService.updateSmTransactionBill(smTransactionBill));
return toAjax(smTransactionBillService.updateSmTransactionBill(transactionBill));
}
/**
@ -111,7 +111,7 @@ public class SmTransactionBillController extends BaseController
@PreAuthorize("@ss.hasPermi('system:bill:query')")
@GetMapping("/count")
public AjaxResult count(SmTransactionBillQuery dto)
public AjaxResult count(TransactionBillQuery dto)
{
return success(smTransactionBillService.selectCount(dto));
}
@ -120,7 +120,7 @@ public class SmTransactionBillController extends BaseController
@PreAuthorize("@ss.hasPermi('system:bill:approval')")
@PutMapping("/withdraw/pass")
@Log(title = "同意提现申请", businessType = BusinessType.UPDATE)
public AjaxResult passWithdraw(@RequestBody SmTransactionBillBO bo)
public AjaxResult passWithdraw(@RequestBody TransactionBillBO bo)
{
return success(smTransactionBillService.passWithdraw(bo.getBillId(), bo.getRemark()));
}
@ -129,7 +129,7 @@ public class SmTransactionBillController extends BaseController
@PreAuthorize("@ss.hasPermi('system:bill:approval')")
@PutMapping("/withdraw/reject")
@Log(title = "拒绝提现申请", businessType = BusinessType.UPDATE)
public AjaxResult rejectWithdraw(@RequestBody SmTransactionBillBO bo)
public AjaxResult rejectWithdraw(@RequestBody TransactionBillBO bo)
{
return success(smTransactionBillService.rejectWithdraw(bo.getBillId(), bo.getRemark()));
}

View File

@ -14,7 +14,7 @@ wx:
# 微信支付配置
pay:
# 微信小程序id
appId: wx3914d4d7441fb438
appId: ${wx.appid}
# 商户id
merchantId: 1656437344
# apiV3密钥

View File

@ -14,7 +14,7 @@ wx:
# 微信支付配置
pay:
# 微信小程序id
appId: wx3914d4d7441fb438
appId: ${wx.appid}
# 商户id
merchantId: 1656437344
# apiV3密钥