提交部署

This commit is contained in:
墨大叔 2024-07-22 17:07:09 +08:00
parent eaa86d0ec3
commit 76f2bb2150
20 changed files with 775 additions and 36 deletions

View File

@ -115,6 +115,18 @@
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="onSortChange">
<el-table-column type="selection" width="55" align="center" />
<template v-for="column of showColumns">
<el-table-column
:key="column.key"
:label="column.label"
:prop="column.key"
:align="column.align"
:min-width="column.minWidth"
:sort-orders="orderSorts"
:sortable="column.sortable"
:show-overflow-tooltip="column.overflow"
>
<template slot-scope="d">
#foreach($column in $columns)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
@ -123,30 +135,30 @@
#else
#set($comment=$column.columnComment)
#end
#if($column.pk)
<el-table-column label="${comment}" align="center" prop="${javaField}" sortable="custom" :sort-orders="orderSorts"/>
#elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180" sortable="custom" :sort-orders="orderSorts"/>
#elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template>
</el-table-column>
#elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}" sortable="custom" :sort-orders="orderSorts">
<template slot-scope="scope">
#if($column.htmlType == "checkbox")
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
#else
<dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/>
#end
</template>
</el-table-column>
#elseif($column.list && "" != $javaField)
<el-table-column label="${comment}" align="center" prop="${javaField}" sortable="custom" :sort-orders="orderSorts"/>
#end
#if($column.pk)
<template v-if="column.key === '${javaField}'">
{{d.row[column.key]}}
</template>
#elseif($column.list && $column.htmlType == "imageUpload")
<template v-else-if="column.key === '${javaField}'">
<image-preview :src="d.row[column.key]" :width="50" :height="50"/>
</template>
#elseif($column.list && "" != $column.dictType)
<template v-else-if="column.key === '${javaField}'">
#if($column.htmlType == "checkbox")
<dict-tag :options="dict.type.${column.dictType}" :value="d.row[column.key] ? d.row[column.key].split(',') : []"/>
#else
<dict-tag :options="dict.type.${column.dictType}" :value="d.row[column.key]"/>
#end
</template>
#end
#end
<template v-else>
{{d.row[column.key]}}
</template>
</template>
</el-table-column>
</template>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -350,6 +362,7 @@
<script>
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
import { $showColumns } from '@/utils/mixins';
// 默认排序字段
const defaultSort = {
@ -359,18 +372,24 @@ const defaultSort = {
export default {
name: "${BusinessName}",
mixins: [$showColumns],
#if(${dicts} != '')
dicts: [${dicts}],
#end
data() {
return {
#foreach($column in $columns)
// 字段列表
columns: [
{key: '${column.javaField}', visible: true, label: '${column.columnComment}'},
],
#foreach($column in $columns)
#if($column.pk)
{key: '${column.javaField}', visible: true, label: '${column.columnComment}', minWidth: null, sortable: true, overflow: false, align: 'center'},
#elseif($column.list && $column.htmlType == "datetime")
{key: '${column.javaField}', visible: true, label: '${column.columnComment}', minWidth: "180", sortable: false, overflow: false, align: 'center'},
#elseif($column.list && "" != $javaField)
{key: '${column.javaField}', visible: true, label: '${column.columnComment}', minWidth: null, sortable: true, overflow: false, align: 'center'},
#end
#end
],
// 排序方式
orderSorts: ['ascending', 'descending', null],
// 遮罩层

View File

@ -1,5 +1,6 @@
package com.ruoyi.ss.device.domain.dto;
import com.ruoyi.common.validRule.modelExist.ModelExist;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@ -18,4 +19,7 @@ public class DeviceRegisterDTO {
@NotBlank(message = "SN不允许为空")
private String sn;
@ModelExist(message = "型号不存在")
private Long modelId;
}

View File

@ -294,6 +294,7 @@ public class DeviceServiceImpl implements DeviceService
device.setDeviceName("未命名");
device.setMac(dto.getMac());
device.setDeviceNo(dto.getSn());
device.setModelId(dto.getModelId());
return this.insertSmDevice(device);
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.ss.receiveBill.domain;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 应收账单对象 ss_receive_bill
*
* @author ruoyi
* @date 2024-07-22
*/
@Data
public class ReceiveBill extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 账单ID */
private Long billId;
/** 用户ID */
@Excel(name = "用户ID")
private Long userId;
/** 账单类型 */
@Excel(name = "账单类型")
private String type;
/** 账单状态 */
@Excel(name = "账单状态")
private String status;
/** 出账时间 */
@Excel(name = "出账时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime billTime;
/** 账单金额 */
@Excel(name = "账单金额")
private BigDecimal amount;
/** 账单描述 */
@Excel(name = "账单描述")
private String description;
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.ss.receiveBill.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wjh
* 2024/7/22
*/
@Data
public class ReceiveBillQuery extends ReceiveBill{
@ApiModelProperty("年份")
private Integer billYear;
@ApiModelProperty("月份")
private Integer billMonth;
}

View File

@ -0,0 +1,11 @@
package com.ruoyi.ss.receiveBill.domain;
import lombok.Data;
/**
* @author wjh
* 2024/7/22
*/
@Data
public class ReceiveBillVO extends ReceiveBill{
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.ss.receiveBill.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wjh
* 2024/7/22
*/
@Getter
@AllArgsConstructor
public enum ReceiveBillStatus {
WAIT_PAY("1", "待支付"),
PAYING("2", "支付中"),
PAID("3", "已支付"),
;
private final String status;
private final String msg;
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.ss.receiveBill.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wjh
* 2024/7/22
*/
@Getter
@AllArgsConstructor
public enum ReceiveBillType {
MONTH("1", "月费");
private final String type;
private final String msg;
}

View File

@ -0,0 +1,69 @@
package com.ruoyi.ss.receiveBill.mapper;
import java.util.List;
import com.ruoyi.ss.receiveBill.domain.ReceiveBill;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillVO;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
import org.apache.ibatis.annotations.Param;
/**
* 应收账单Mapper接口
*
* @author ruoyi
* @date 2024-07-22
*/
public interface ReceiveBillMapper
{
/**
* 查询应收账单
*
* @param billId 应收账单主键
* @return 应收账单
*/
public ReceiveBillVO selectReceiveBillByBillId(Long billId);
/**
* 查询应收账单列表
*
* @param receiveBill 应收账单
* @return 应收账单集合
*/
public List<ReceiveBillVO> selectReceiveBillList(@Param("query")ReceiveBillQuery receiveBill);
/**
* 新增应收账单
*
* @param receiveBill 应收账单
* @return 结果
*/
public int insertReceiveBill(ReceiveBill receiveBill);
/**
* 修改应收账单
*
* @param receiveBill 应收账单
* @return 结果
*/
public int updateReceiveBill(@Param("data") ReceiveBill receiveBill);
/**
* 删除应收账单
*
* @param billId 应收账单主键
* @return 结果
*/
public int deleteReceiveBillByBillId(Long billId);
/**
* 批量删除应收账单
*
* @param billIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteReceiveBillByBillIds(Long[] billIds);
/**
* 查询数量
*/
int selectCount(ReceiveBillQuery query);
}

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.ss.receiveBill.mapper.ReceiveBillMapper">
<resultMap type="ReceiveBillVO" id="ReceiveBillResult" autoMapping="true"/>
<sql id="selectReceiveBillVo">
select
srb.bill_id,
srb.user_id,
srb.type,
srb.status,
srb.bill_time,
srb.amount,
srb.description,
srb.create_time
from <include refid="selectTables"/>
</sql>
<sql id="selectTables">
ss_receive_bill srb
</sql>
<sql id="searchCondition">
<if test="query.billId != null "> and srb.bill_id = #{query.billId}</if>
<if test="query.userId != null "> and srb.user_id = #{query.userId}</if>
<if test="query.billYear != null "> and year(srb.bill_time) = #{query.billYear}</if>
<if test="query.billMonth != null "> and month(srb.bill_time) = #{query.billMonth}</if>
<if test="query.type != null and query.type != ''"> and srb.type = #{query.type}</if>
<if test="query.status != null and query.status != ''"> and srb.status = #{query.status}</if>
<if test="query.description != null and query.description != ''"> and srb.description like concat('%', #{query.description}, '%')</if>
</sql>
<select id="selectReceiveBillList" parameterType="ReceiveBillQuery" resultMap="ReceiveBillResult">
<include refid="selectReceiveBillVo"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<select id="selectReceiveBillByBillId" parameterType="Long" resultMap="ReceiveBillResult">
<include refid="selectReceiveBillVo"/>
where srb.bill_id = #{billId}
</select>
<select id="selectCount" resultType="java.lang.Integer">
select count(srb.bill_id)
from <include refid="selectTables"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertReceiveBill" parameterType="ReceiveBill" useGeneratedKeys="true" keyProperty="billId">
insert into ss_receive_bill
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="type != null and type != ''">type,</if>
<if test="status != null and status != ''">`status`,</if>
<if test="billTime != null">bill_time,</if>
<if test="amount != null">amount,</if>
<if test="description != null and description != ''">`description`,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="billTime != null">#{billTime},</if>
<if test="amount != null">#{amount},</if>
<if test="description != null and description != ''">#{description},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateReceiveBill" parameterType="ReceiveBill">
update ss_receive_bill
<trim prefix="SET" suffixOverrides=",">
<if test="data.userId != null">user_id = #{data.userId},</if>
<if test="data.type != null and data.type != ''">type = #{data.type},</if>
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
<if test="data.billTime != null">bill_time = #{data.billTime},</if>
<if test="data.amount != null">amount = #{data.amount},</if>
<if test="data.description != null and data.description != ''">`description` = #{data.description},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
</trim>
where bill_id = #{billId}
</update>
<delete id="deleteReceiveBillByBillId" parameterType="Long">
delete from ss_receive_bill where bill_id = #{billId}
</delete>
<delete id="deleteReceiveBillByBillIds" parameterType="String">
delete from ss_receive_bill where bill_id in
<foreach item="billId" collection="array" open="(" separator="," close=")">
#{billId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,78 @@
package com.ruoyi.ss.receiveBill.service;
import java.time.YearMonth;
import java.util.List;
import com.ruoyi.ss.receiveBill.domain.ReceiveBill;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillVO;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
import com.ruoyi.ss.user.domain.SmUserVo;
/**
* 应收账单Service接口
*
* @author ruoyi
* @date 2024-07-22
*/
public interface ReceiveBillService
{
/**
* 查询应收账单
*
* @param billId 应收账单主键
* @return 应收账单
*/
public ReceiveBillVO selectReceiveBillByBillId(Long billId);
/**
* 查询应收账单列表
*
* @param receiveBill 应收账单
* @return 应收账单集合
*/
public List<ReceiveBillVO> selectReceiveBillList(ReceiveBillQuery receiveBill);
/**
* 新增应收账单
*
* @param receiveBill 应收账单
* @return 结果
*/
public int insertReceiveBill(ReceiveBill receiveBill);
/**
* 修改应收账单
*
* @param receiveBill 应收账单
* @return 结果
*/
public int updateReceiveBill(ReceiveBill receiveBill);
/**
* 批量删除应收账单
*
* @param billIds 需要删除的应收账单主键集合
* @return 结果
*/
public int deleteReceiveBillByBillIds(Long[] billIds);
/**
* 删除应收账单信息
*
* @param billId 应收账单主键
* @return 结果
*/
public int deleteReceiveBillByBillId(Long billId);
/**
* 月费商户出账
*
* @param user 用户ID
* @param billMonth 出账日期
*/
int genBillByMonth(SmUserVo user, YearMonth billMonth);
/**
* 查询数量
*/
int selectCount(ReceiveBillQuery query);
}

View File

@ -0,0 +1,141 @@
package com.ruoyi.ss.receiveBill.service.impl;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.YearMonth;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillStatus;
import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillType;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.ISmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ss.receiveBill.mapper.ReceiveBillMapper;
import com.ruoyi.ss.receiveBill.domain.ReceiveBill;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillVO;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
import com.ruoyi.ss.receiveBill.service.ReceiveBillService;
/**
* 应收账单Service业务层处理
*
* @author ruoyi
* @date 2024-07-22
*/
@Service
public class ReceiveBillServiceImpl implements ReceiveBillService
{
@Autowired
private ReceiveBillMapper receiveBillMapper;
@Autowired
private ISmUserService userService;
/**
* 查询应收账单
*
* @param billId 应收账单主键
* @return 应收账单
*/
@Override
public ReceiveBillVO selectReceiveBillByBillId(Long billId)
{
return receiveBillMapper.selectReceiveBillByBillId(billId);
}
/**
* 查询应收账单列表
*
* @param receiveBill 应收账单
* @return 应收账单
*/
@Override
public List<ReceiveBillVO> selectReceiveBillList(ReceiveBillQuery receiveBill)
{
return receiveBillMapper.selectReceiveBillList(receiveBill);
}
/**
* 新增应收账单
*
* @param receiveBill 应收账单
* @return 结果
*/
@Override
public int insertReceiveBill(ReceiveBill receiveBill)
{
receiveBill.setCreateTime(DateUtils.getNowDate());
return receiveBillMapper.insertReceiveBill(receiveBill);
}
/**
* 修改应收账单
*
* @param receiveBill 应收账单
* @return 结果
*/
@Override
public int updateReceiveBill(ReceiveBill receiveBill)
{
return receiveBillMapper.updateReceiveBill(receiveBill);
}
/**
* 批量删除应收账单
*
* @param billIds 需要删除的应收账单主键
* @return 结果
*/
@Override
public int deleteReceiveBillByBillIds(Long[] billIds)
{
return receiveBillMapper.deleteReceiveBillByBillIds(billIds);
}
/**
* 删除应收账单信息
*
* @param billId 应收账单主键
* @return 结果
*/
@Override
public int deleteReceiveBillByBillId(Long billId)
{
return receiveBillMapper.deleteReceiveBillByBillId(billId);
}
@Override
public int genBillByMonth(SmUserVo user, YearMonth billMonth) {
ServiceUtil.assertion(user == null || user.getUserId() == null, "用户不存在");
ServiceUtil.assertion(billMonth == null, "请指定一个月份");
// 查询指定月份是否已出账
ReceiveBillQuery query = new ReceiveBillQuery();
query.setBillYear(billMonth.getYear());
query.setBillMonth(billMonth.getMonthValue());
query.setType(ReceiveBillType.MONTH.getType());
query.setUserId(user.getUserId());
int count = this.selectCount(query);
if ( count > 0) {
return count;
}
// 若未出账则生成账单
ReceiveBill bill = new ReceiveBill();
bill.setUserId(user.getUserId());
bill.setType(ReceiveBillType.MONTH.getType());
bill.setStatus(ReceiveBillStatus.WAIT_PAY.getStatus());
bill.setBillTime(LocalDateTime.of(LocalDate.of(billMonth.getYear(), billMonth.getMonthValue(), 1), LocalTime.MIN));
bill.setAmount(user.getServiceRate());
bill.setDescription(String.format("%s年%s月-月费", billMonth.getYear(), billMonth.getMonthValue()));
return this.insertReceiveBill(bill);
}
@Override
public int selectCount(ReceiveBillQuery query) {
return receiveBillMapper.selectCount(query);
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.ss.recordBalance.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@ -8,4 +9,8 @@ import lombok.Data;
*/
@Data
public class RecordBalanceQuery extends RecordBalance{
@ApiModelProperty("用户名称")
private String userName;
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.ss.recordBalance.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@ -8,4 +9,8 @@ import lombok.Data;
*/
@Data
public class RecordBalanceVO extends RecordBalance{
@ApiModelProperty("用户名称")
private String userName;
}

View File

@ -14,14 +14,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
srb.after_balance,
srb.reason,
srb.create_time,
srb.amount
srb.amount,
su.user_name as user_name
from ss_record_balance srb
left join sm_user su on su.user_id = srb.user_id
</sql>
<sql id="searchCondition">
<if test="query.id != null "> and srb.id = #{query.id}</if>
<if test="query.userId != null "> and srb.user_id = #{query.userId}</if>
<if test="query.reason != null and query.reason != ''"> and srb.reason like concat('%', #{query.reason}, '%')</if>
<if test="query.userName != null and query.userName != ''"> and su.user_name like concat('%', #{query.userName}, '%')</if>
</sql>
<select id="selectRecordBalanceList" parameterType="RecordBalanceQuery" resultMap="RecordBalanceResult">

View File

@ -247,8 +247,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</trim>
where suit_id in
<foreach collection="list" open="(" close=")" item="i" separator=",">
#{i}
<foreach collection="list" open="(" close=")" item="item" separator=",">
#{item.suitId}
</foreach>
</update>

View File

@ -13,6 +13,7 @@ import com.ruoyi.ss.channel.service.ISmChannelService;
import com.ruoyi.ss.dashboard.BillCountVo;
import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.receiveBill.service.ReceiveBillService;
import com.ruoyi.ss.record.time.service.IRecordTimeService;
import com.ruoyi.ss.record.time.service.RecordTimeConverter;
import com.ruoyi.ss.refund.domain.Refund;
@ -33,6 +34,7 @@ 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.domain.enums.UserServiceType;
import com.ruoyi.ss.user.mapper.SmUserMapper;
import com.ruoyi.ss.user.service.ISmUserService;
import com.ruoyi.ss.wxPay.service.IWxPayService;
@ -50,7 +52,9 @@ import org.springframework.transaction.support.TransactionTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ -126,6 +130,9 @@ public class TransactionBillServiceImpl implements TransactionBillService {
@Autowired
private RefundConverter refundConverter;
@Autowired
private ReceiveBillService receiveBillService;
/**
* 查询充值记录
*
@ -216,6 +223,10 @@ public class TransactionBillServiceImpl implements TransactionBillService {
public String addOrder(TransactionBill data) {
// 下单
TransactionBill order = parseToOrder(data);
// 服务费处理
this.handleService(order);
ServiceUtil.assertion(this.insertSmTransactionBill(order) != 1, "下单失败");
// 加入延时队列超时取消
@ -224,6 +235,29 @@ public class TransactionBillServiceImpl implements TransactionBillService {
return order.getBillNo();
}
// 处理服务费
private void handleService(TransactionBill order) {
SmUserVo mch = userService.selectSmUserByUserId(order.getMchId());
ServiceUtil.assertion(mch == null, "商户不存在,不允许下单");
BigDecimal serviceCharge = BigDecimal.ZERO; // 订单服务费
BigDecimal arrivalAmount = order.getMoney();// 订单商户到账金额
// 月费商户才出账
// if (UserServiceType.MONTH.getType().equals(mch.getServiceType())) {
// int count = receiveBillService.genBillByMonth(mch, YearMonth.now());
// ServiceUtil.assertion(count == 0, "商户出账失败,请刷新后重试");
// }
// // 其他一律为收取服务费
// else {
BigDecimal serviceRate = this.getServiceRate(order.getDeviceId(), order.getChannelId());
serviceCharge = serviceRate.multiply(order.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); // 服务费
arrivalAmount = order.getMoney().subtract(serviceCharge); // 商户最终到账的金额 = 交易金额 - 服务费
// }
order.setArrivalAmount(arrivalAmount);
order.setServiceCharge(serviceCharge);
}
// 转换为订单所需的数据
private TransactionBill parseToOrder(TransactionBill data) {
// 校验
@ -267,14 +301,9 @@ public class TransactionBillServiceImpl implements TransactionBillService {
long expireTime = TimeUnit.MILLISECONDS.convert(Constants.BILL_UNPAID_TIMEOUT, Constants.BILL_UNPAID_TIMEUNIT) + System.currentTimeMillis();
order.setExpireTime(new Date(expireTime));
// 渠道价格计算
// 渠道费用计算
SmChannel channel = channelService.selectSmChannelByChannelId(order.getChannelId());
BigDecimal serviceRate = this.getServiceRate(order.getDeviceId(), order.getChannelId());
BigDecimal serviceCharge = serviceRate.multiply(order.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); // 服务费
BigDecimal arrivalAmount = order.getMoney().subtract(serviceCharge); // 商户最终到账的金额 = 交易金额 - 服务费
order.setChannelCost(channel.getCostRate().multiply(order.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
order.setArrivalAmount(arrivalAmount);
order.setServiceCharge(serviceCharge);
return order;
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.ss.user.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 用户服务费收取类型
* @author wjh
* 2024/7/22
*/
@Getter
@AllArgsConstructor
public enum UserServiceType {
PERCENT("1", "百分比抽成"),
MONTH("2", "月费");
private final String type;
private final String msg;
}

View File

@ -0,0 +1,32 @@
package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ss.model.domain.SmModelQuery;
import com.ruoyi.ss.model.service.ModelService;
import com.ruoyi.web.core.annotation.DeviceAdminRequired;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author wjh
* 2024/7/22
*/
@RestController
@RequestMapping("/app/model")
public class AppModelController extends BaseController {
@Autowired
private ModelService modelService;
@ApiOperation("获取全部型号列表")
@DeviceAdminRequired
@GetMapping("/all")
public AjaxResult getAllModel(SmModelQuery query) {
return success(modelService.selectSmModelList(query));
}
}

View File

@ -0,0 +1,107 @@
package com.ruoyi.web.controller.ss;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.receiveBill.domain.ReceiveBill;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillVO;
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
import com.ruoyi.ss.receiveBill.service.ReceiveBillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 应收账单Controller
*
* @author ruoyi
* @date 2024-07-22
*/
@RestController
@RequestMapping("/ss/receiveBill")
public class ReceiveBillController extends BaseController
{
@Autowired
private ReceiveBillService receiveBillService;
/**
* 查询应收账单列表
*/
@PreAuthorize("@ss.hasPermi('ss:receiveBill:list')")
@GetMapping("/list")
public TableDataInfo list(ReceiveBillQuery query)
{
startPage();
startOrderBy();
List<ReceiveBillVO> list = receiveBillService.selectReceiveBillList(query);
return getDataTable(list);
}
/**
* 导出应收账单列表
*/
@PreAuthorize("@ss.hasPermi('ss:receiveBill:export')")
@Log(title = "应收账单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ReceiveBillQuery query)
{
List<ReceiveBillVO> list = receiveBillService.selectReceiveBillList(query);
ExcelUtil<ReceiveBillVO> util = new ExcelUtil<ReceiveBillVO>(ReceiveBillVO.class);
util.exportExcel(response, list, "应收账单数据");
}
/**
* 获取应收账单详细信息
*/
@PreAuthorize("@ss.hasPermi('ss:receiveBill:query')")
@GetMapping(value = "/{billId}")
public AjaxResult getInfo(@PathVariable("billId") Long billId)
{
return success(receiveBillService.selectReceiveBillByBillId(billId));
}
/**
* 新增应收账单
*/
@PreAuthorize("@ss.hasPermi('ss:receiveBill:add')")
@Log(title = "应收账单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ReceiveBill receiveBill)
{
return toAjax(receiveBillService.insertReceiveBill(receiveBill));
}
/**
* 修改应收账单
*/
@PreAuthorize("@ss.hasPermi('ss:receiveBill:edit')")
@Log(title = "应收账单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ReceiveBill receiveBill)
{
return toAjax(receiveBillService.updateReceiveBill(receiveBill));
}
/**
* 删除应收账单
*/
@PreAuthorize("@ss.hasPermi('ss:receiveBill:remove')")
@Log(title = "应收账单", businessType = BusinessType.DELETE)
@DeleteMapping("/{billIds}")
public AjaxResult remove(@PathVariable Long[] billIds)
{
return toAjax(receiveBillService.deleteReceiveBillByBillIds(billIds));
}
}