服务费调整、支付BUG修改
This commit is contained in:
parent
099249122f
commit
11fda9f59e
|
@ -1,10 +1,7 @@
|
|||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.valid.EnumValid;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.ruoyi.ss.record.time.service.RecordTimeConverter;
|
|||
import com.ruoyi.ss.store.domain.StoreVo;
|
||||
import com.ruoyi.ss.store.service.IStoreService;
|
||||
import com.ruoyi.ss.suit.service.SuitService;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.ss.user.domain.SmUserVo;
|
||||
|
@ -604,6 +605,9 @@ public class DeviceServiceImpl implements DeviceService
|
|||
form.setStatus(DeviceStatus.NORMAL.getStatus());
|
||||
smDeviceMapper.updateSmDevice(form);
|
||||
|
||||
// 关闭该设备未结束的所有订单
|
||||
transactionBillService.batchEndBillByDevice(deviceId);
|
||||
|
||||
// 物联网设备归零
|
||||
CommandResponse commandResponse = iotService.setTime(device.getMac(), BigDecimal.ONE);
|
||||
ServiceUtil.assertion(!commandResponse.isSuccess(), "设备归零失败,请检查设备是否在线或联系管理员");
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Suit extends BaseEntity
|
|||
|
||||
/** 设备id */
|
||||
@Excel(name = "设备id")
|
||||
@NotNull(message = "设备ID不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
|
||||
// @NotNull(message = "设备ID不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
|
||||
@JsonView(JsonViewProfile.AppMch.class)
|
||||
private Long deviceId;
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class SuitValidatorImpl extends BaseValidator implements SuitValidator {
|
|||
}
|
||||
|
||||
// 设备校验
|
||||
if (!deviceValidator.isBelong(suit.getDeviceId(), SecurityUtils.getUserId())) {
|
||||
if (suit.getDeviceId() != null && !deviceValidator.isBelong(suit.getDeviceId(), SecurityUtils.getUserId())) {
|
||||
return error("该设备不属于该用户");
|
||||
}
|
||||
|
||||
|
@ -96,10 +96,8 @@ public class SuitValidatorImpl extends BaseValidator implements SuitValidator {
|
|||
}
|
||||
|
||||
// 设备校验
|
||||
if (suit.getDeviceId() != null) {
|
||||
if (!deviceValidator.isBelong(suit.getDeviceId(), userId)) {
|
||||
return error("该设备不属于该用户");
|
||||
}
|
||||
if ( suit.getDeviceId() != null && !deviceValidator.isBelong(suit.getDeviceId(), userId)) {
|
||||
return error("该设备不属于该用户");
|
||||
}
|
||||
|
||||
return success();
|
||||
|
|
|
@ -97,6 +97,7 @@ public class TransactionBill extends BaseEntity
|
|||
private BigDecimal afterBalance;
|
||||
|
||||
@ApiModelProperty("支付成功的时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date payTime;
|
||||
|
||||
@ApiModelProperty("支付过期时间")
|
||||
|
@ -162,4 +163,13 @@ public class TransactionBill extends BaseEntity
|
|||
@JsonView(JsonViewProfile.App.class)
|
||||
private String deviceMac;
|
||||
|
||||
@ApiModelProperty("总计退款金额")
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
@ApiModelProperty("商户退款金额")
|
||||
private BigDecimal refundMchAmount;
|
||||
|
||||
@ApiModelProperty("服务费退款金额")
|
||||
private BigDecimal refundServiceAmount;
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -76,4 +77,7 @@ public class TransactionBillQuery extends TransactionBill {
|
|||
|
||||
@ApiModelProperty("是否使用中")
|
||||
private Boolean using;
|
||||
|
||||
@ApiModelProperty("套餐结束时间(结束)")
|
||||
private LocalDateTime endSuitEndTime;
|
||||
}
|
||||
|
|
|
@ -164,4 +164,9 @@ public interface TransactionBillMapper
|
|||
@Param("refundMchAmount") BigDecimal refundMchAmount,
|
||||
@Param("refundServiceAmount") BigDecimal refundServiceAmount
|
||||
);
|
||||
|
||||
/**
|
||||
* 批量更新套餐结束时间
|
||||
*/
|
||||
int batchUpdateSuitEndTime(@Param("billIds") List<Long> billIds,@Param("time") LocalDateTime time);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
stb.device_no,
|
||||
stb.suit_name,
|
||||
stb.device_mac,
|
||||
stb.refund_amount,
|
||||
stb.refund_mch_amount,
|
||||
stb.refund_service_amount,
|
||||
su.user_name as user_name,
|
||||
su1.user_name as mch_name,
|
||||
su1.phonenumber as mch_mobile
|
||||
|
@ -73,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.deviceRechargeStatus != null"> and stb.device_recharge_status = #{query.deviceRechargeStatus} </if>
|
||||
<if test="query.suitId != null"> and stb.suit_id = #{query.suitId} </if>
|
||||
<if test="query.storeId != null"> and stb.store_id = #{query.storeId} </if>
|
||||
<if test="query.endSuitEndTime != null"> and stb.suit_end_time >= #{query.endSuitEndTime}</if>
|
||||
<if test="query.using != null">
|
||||
<if test="query.using">
|
||||
and now() >= stb.suit_start_time and now() <= stb.suit_end_time and now() <= stb.suit_expire_time
|
||||
|
@ -224,6 +228,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deviceNo != null ">device_no,</if>
|
||||
<if test="suitName != null ">suit_name,</if>
|
||||
<if test="deviceMac != null ">device_mac,</if>
|
||||
<if test="refundAmount != null">refund_amount,</if>
|
||||
<if test="refundMchAmount != null">refund_mch_amount,</if>
|
||||
<if test="refundServiceAmount != null">refund_service_amount,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="billNo != null">#{billNo},</if>
|
||||
|
@ -258,6 +265,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deviceNo != null ">#{deviceNo},</if>
|
||||
<if test="suitName != null ">#{suitName},</if>
|
||||
<if test="deviceMac != null ">#{deviceMac},</if>
|
||||
<if test="refundAmount != null">#{refundAmount},</if>
|
||||
<if test="refundMchAmount != null">#{refundMchAmount},</if>
|
||||
<if test="refundServiceAmount != null">#{refundServiceAmount},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -309,6 +319,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.deviceNo != null ">device_no = #{data.deviceNo},</if>
|
||||
<if test="data.suitName != null ">suit_name = #{data.suitName},</if>
|
||||
<if test="data.deviceMac != null ">device_mac = #{data.deviceMac},</if>
|
||||
<if test="data.refundAmount != null">refund_amount = #{data.refundAmount},</if>
|
||||
<if test="data.refundMchAmount != null">refund_mch_amount = #{data.refundMchAmount},</if>
|
||||
<if test="data.refundServiceAmount != null">refund_service_amount = #{data.refundServiceAmount},</if>
|
||||
</sql>
|
||||
|
||||
<update id="updateByQuery">
|
||||
|
@ -417,4 +430,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where bill_no = #{billNo} and type = '1' and device_recharge_status = '3' and status = '2'
|
||||
</update>
|
||||
|
||||
<update id="batchUpdateSuitEndTime">
|
||||
update sm_transaction_bill
|
||||
set suit_end_time = #{time}
|
||||
where bill_id in
|
||||
<foreach collection="billIds" separator="," item="item" close=")" open="(">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -259,4 +259,14 @@ public interface TransactionBillService
|
|||
* 查询用户正在使用中的订单
|
||||
*/
|
||||
List<TransactionBillVo> selectUsingBill(Long userId);
|
||||
|
||||
/**
|
||||
* 查询正在使用中的订单
|
||||
*/
|
||||
List<TransactionBillVo> selectUsingBill(TransactionBillQuery query);
|
||||
|
||||
/**
|
||||
* 根据设备ID批量结束订单
|
||||
*/
|
||||
int batchEndBillByDevice(Long deviceId);
|
||||
}
|
||||
|
|
|
@ -581,7 +581,7 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 在设备充值成功后,更新套餐时间
|
||||
* 在设备充值成功前,更新套餐时间
|
||||
* 开始时间 = 设备过期时间 - 套餐时间,过期时间 = 设备过期时间
|
||||
*/
|
||||
private int updateSuitTimeBeforeDevice(Long billId, LocalDateTime deviceExpireTime) {
|
||||
|
@ -589,11 +589,14 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
if (bill == null) {
|
||||
return 0;
|
||||
}
|
||||
// 计算开始使用的时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime startTime = now.isAfter(deviceExpireTime) ? now : deviceExpireTime;
|
||||
|
||||
LocalDateTime endTime = deviceExpireTime.plusMinutes(bill.getSuitTime().longValue());
|
||||
LocalDateTime endTime = startTime.plusMinutes(bill.getSuitTime().longValue());
|
||||
TransactionBill data = new TransactionBill();
|
||||
data.setBillId(billId);
|
||||
data.setSuitStartTime(deviceExpireTime);
|
||||
data.setSuitStartTime(startTime);
|
||||
data.setSuitEndTime(endTime);
|
||||
data.setSuitExpireTime(endTime);
|
||||
return transactionBillMapper.updateSmTransactionBill(data);
|
||||
|
@ -958,8 +961,30 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
@Override
|
||||
public List<TransactionBillVo> selectUsingBill(Long userId) {
|
||||
TransactionBillQuery query = new TransactionBillQuery();
|
||||
query.setUserId(userId);
|
||||
return this.selectUsingBill(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TransactionBillVo> selectUsingBill(TransactionBillQuery query) {
|
||||
query.setUsing(true);
|
||||
query.setStatus(TransactionBillStatus.SUCCESS.getStatus());
|
||||
return this.selectSmTransactionBillList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchEndBillByDevice(Long deviceId) {
|
||||
if (deviceId == null) {
|
||||
return 0;
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
TransactionBillQuery query = new TransactionBillQuery();
|
||||
query.setDeviceId(deviceId);
|
||||
query.setEndSuitEndTime(now); // 套餐结束时间在这之后的,都会被关闭
|
||||
List<TransactionBillVo> billList = this.selectSmTransactionBillList(query);
|
||||
if (CollectionUtils.isNotEmptyElement(billList)) {
|
||||
return transactionBillMapper.batchUpdateSuitEndTime(billList.stream().map(TransactionBill::getBillId).collect(Collectors.toList()), now);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class UserUpdateServiceRateBO {
|
|||
private Long userId;
|
||||
|
||||
@ApiModelProperty("服务费费率")
|
||||
@Range(min = 1, max = 100, message = "服务费费率范围1-100")
|
||||
@Range(min = 0, max = 100, message = "服务费费率范围0-100")
|
||||
private BigDecimal serviceRate;
|
||||
|
||||
@ApiModelProperty("是否刷新用户所有设备的服务费")
|
||||
|
|
Loading…
Reference in New Issue
Block a user