超时扣款金额按照dept_config表的配置来扣
This commit is contained in:
parent
202eb5237a
commit
096f8ba140
|
|
@ -11,6 +11,8 @@ import com.ghy.payment.domain.OrderTimeoutRecord;
|
|||
import com.ghy.payment.mapper.OrderFineRecordMapper;
|
||||
import com.ghy.payment.service.FinancialDetailService;
|
||||
import com.ghy.quartz.service.OrderService;
|
||||
import com.ghy.system.domain.SysDeptConfig;
|
||||
import com.ghy.system.service.ISysDeptConfigService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
@ -31,14 +33,6 @@ import java.util.stream.Collectors;
|
|||
public class OrderServiceImpl implements OrderService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
|
||||
/**
|
||||
* 一小时的毫秒数
|
||||
*/
|
||||
private static final long HOUR_TIME_MILLIS = 60 * 60 * 1000L;
|
||||
/**
|
||||
* 超时罚金2元
|
||||
*/
|
||||
private static final BigDecimal TIMEOUT_MONEY = BigDecimal.valueOf(2);
|
||||
|
||||
/**
|
||||
* 需要超时扣款的订单状态
|
||||
|
|
@ -56,6 +50,8 @@ public class OrderServiceImpl implements OrderService {
|
|||
private OrderFineRecordMapper orderFineRecordMapper;
|
||||
@Resource
|
||||
private FinancialDetailService financialDetailService;
|
||||
@Resource
|
||||
private ISysDeptConfigService sysDeptConfigService;
|
||||
|
||||
@Override
|
||||
public void overTimeOrder(String orderStatus) {
|
||||
|
|
@ -74,7 +70,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
}
|
||||
} else if (timeoutOrderStatus.contains(order.getOrderStatus())) {
|
||||
// 其它状态用update_time判断超时 30min超时 4h扣款
|
||||
if (order.getUpdateTime().before(fourHour)) {
|
||||
if (fourHour.after(order.getUpdateTime())) {
|
||||
executor.execute(() -> orderTimeout(order, true));
|
||||
} else if (order.getUpdateTime().before(halfHour)) {
|
||||
executor.execute(() -> orderTimeout(order, false));
|
||||
|
|
@ -115,10 +111,35 @@ public class OrderServiceImpl implements OrderService {
|
|||
record.setFineStatus(1);
|
||||
orderFineRecordMapper.update(record);
|
||||
|
||||
FinancialDetail orderFinancial = financialDetailService.selectByOrderDetailId(order.getId());
|
||||
SysDeptConfig deptConfig = sysDeptConfigService.selectByDeptId(order.getDeptId());
|
||||
BigDecimal timeoutMoney = deptConfig.getGoingOutTime();
|
||||
// 如果扣款额为null或<0
|
||||
if (timeoutMoney == null || BigDecimal.ZERO.compareTo(timeoutMoney) > 0) {
|
||||
timeoutMoney = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal timeoutRate = deptConfig.getGoingOutTimeRate();
|
||||
// 如果扣款比例 为null 或 <0 或 >1.00
|
||||
if (timeoutRate == null || BigDecimal.ZERO.compareTo(timeoutRate) > 0 || BigDecimal.ONE.compareTo(timeoutRate) < 0) {
|
||||
timeoutRate = BigDecimal.ZERO;
|
||||
}
|
||||
timeoutMoney = orderFinancial.getPayMoney().multiply(timeoutRate).add(timeoutMoney);
|
||||
if (BigDecimal.ZERO.compareTo(timeoutMoney) == 0) {
|
||||
// 如果罚金=0时 无需扣款
|
||||
logger.info("订单[ID={}]超时无需扣款 GoingOutTime={}, GoingOutTimeRate={}", order.getId(),
|
||||
deptConfig.getGoingOutTime(), deptConfig.getGoingOutTimeRate());
|
||||
return;
|
||||
}
|
||||
if (timeoutMoney.compareTo(orderFinancial.getPayMoney()) > 0) {
|
||||
// 如果罚金大于本单金额的情况
|
||||
logger.warn("订单[ID={}]超时罚金[{}]大于订单金额[{}]!!! GoingOutTime={}, GoingOutTimeRate={}", order.getId(),
|
||||
timeoutMoney, orderFinancial.getPayMoney(), deptConfig.getGoingOutTime(), deptConfig.getGoingOutTimeRate());
|
||||
timeoutMoney = orderFinancial.getPayMoney();
|
||||
}
|
||||
|
||||
//下面是扣款逻辑
|
||||
// 从子订单对应的财务单里扣除2元
|
||||
FinancialDetail orderFinancial = financialDetailService.selectByOrderDetailId(order.getId());
|
||||
orderFinancial.setPayMoney(orderFinancial.getPayMoney().subtract(TIMEOUT_MONEY));
|
||||
orderFinancial.setPayMoney(orderFinancial.getPayMoney().subtract(timeoutMoney));
|
||||
financialDetailService.updateFinancialDetail(orderFinancial);
|
||||
|
||||
// 生成对应的扣款明细
|
||||
|
|
@ -127,7 +148,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
fineFinancial.setCode(financialDetailService.createCode());
|
||||
fineFinancial.setFinancialMasterId(orderFinancial.getFinancialMasterId());
|
||||
fineFinancial.setFinancialMasterCode(orderFinancial.getFinancialMasterCode());
|
||||
fineFinancial.setPayMoney(TIMEOUT_MONEY);
|
||||
fineFinancial.setPayMoney(timeoutMoney);
|
||||
fineFinancial.setFinancialDetailType(FinancialDetailType.FINE_FEE.getCode());
|
||||
financialDetailService.insertFinancialDetail(fineFinancial);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ public class SysDeptConfig extends BaseEntity {
|
|||
@Excel(name = "进行超时罚金", cellType = Excel.ColumnType.NUMERIC)
|
||||
private BigDecimal goingOutTime;
|
||||
|
||||
@Excel(name = "进行超时罚金比例", cellType = Excel.ColumnType.NUMERIC)
|
||||
private BigDecimal goingOutTimeRate;
|
||||
|
||||
@Excel(name = "金牌服务罚金倍数", cellType = Excel.ColumnType.NUMERIC)
|
||||
private BigDecimal goldenServer;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public interface SysDeptConfigMapper {
|
|||
* @param deptId 部门id
|
||||
* @return 部门配置
|
||||
*/
|
||||
public SysDeptConfig selectByDeptId(Long deptId);
|
||||
SysDeptConfig selectByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 获取所有商户的配置
|
||||
|
|
@ -28,7 +28,7 @@ public interface SysDeptConfigMapper {
|
|||
* @param sysDeptConfigId 分公司配置主键
|
||||
* @return 分公司配置
|
||||
*/
|
||||
public SysDeptConfig selectSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
SysDeptConfig selectSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
|
||||
/**
|
||||
* 查询分公司配置列表
|
||||
|
|
@ -36,7 +36,7 @@ public interface SysDeptConfigMapper {
|
|||
* @param sysDeptConfig 分公司配置
|
||||
* @return 分公司配置集合
|
||||
*/
|
||||
public List<SysDeptConfig> selectSysDeptConfigList(SysDeptConfig sysDeptConfig);
|
||||
List<SysDeptConfig> selectSysDeptConfigList(SysDeptConfig sysDeptConfig);
|
||||
|
||||
/**
|
||||
* 新增分公司配置
|
||||
|
|
@ -44,7 +44,7 @@ public interface SysDeptConfigMapper {
|
|||
* @param sysDeptConfig 分公司配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
int insertSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
|
||||
/**
|
||||
* 修改分公司配置
|
||||
|
|
@ -52,7 +52,7 @@ public interface SysDeptConfigMapper {
|
|||
* @param sysDeptConfig 分公司配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
int updateSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
|
||||
/**
|
||||
* 删除分公司配置
|
||||
|
|
@ -60,7 +60,7 @@ public interface SysDeptConfigMapper {
|
|||
* @param sysDeptConfigId 分公司配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
int deleteSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
|
||||
/**
|
||||
* 批量删除分公司配置
|
||||
|
|
@ -68,5 +68,5 @@ public interface SysDeptConfigMapper {
|
|||
* @param sysDeptConfigIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDeptConfigBySysDeptConfigIds(String[] sysDeptConfigIds);
|
||||
int deleteSysDeptConfigBySysDeptConfigIds(String[] sysDeptConfigIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public interface ISysDeptConfigService {
|
|||
* @param deptId 当前登陆用户的部门id
|
||||
* @return 部门配置
|
||||
*/
|
||||
public SysDeptConfig selectByDeptId(Long deptId);
|
||||
SysDeptConfig selectByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 获取所有商户的配置
|
||||
|
|
@ -27,7 +27,7 @@ public interface ISysDeptConfigService {
|
|||
* @param sysDeptConfigId 分公司配置主键
|
||||
* @return 分公司配置
|
||||
*/
|
||||
public SysDeptConfig selectSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
SysDeptConfig selectSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
|
||||
/**
|
||||
* 查询分公司配置列表
|
||||
|
|
@ -35,7 +35,7 @@ public interface ISysDeptConfigService {
|
|||
* @param sysDeptConfig 分公司配置
|
||||
* @return 分公司配置集合
|
||||
*/
|
||||
public List<SysDeptConfig> selectSysDeptConfigList(SysDeptConfig sysDeptConfig);
|
||||
List<SysDeptConfig> selectSysDeptConfigList(SysDeptConfig sysDeptConfig);
|
||||
|
||||
/**
|
||||
* 新增分公司配置
|
||||
|
|
@ -43,7 +43,7 @@ public interface ISysDeptConfigService {
|
|||
* @param sysDeptConfig 分公司配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
int insertSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
|
||||
/**
|
||||
* 修改分公司配置
|
||||
|
|
@ -51,7 +51,7 @@ public interface ISysDeptConfigService {
|
|||
* @param sysDeptConfig 分公司配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
int updateSysDeptConfig(SysDeptConfig sysDeptConfig);
|
||||
|
||||
/**
|
||||
* 批量删除分公司配置
|
||||
|
|
@ -59,7 +59,7 @@ public interface ISysDeptConfigService {
|
|||
* @param sysDeptConfigIds 需要删除的分公司配置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDeptConfigBySysDeptConfigIds(String sysDeptConfigIds);
|
||||
int deleteSysDeptConfigBySysDeptConfigIds(String sysDeptConfigIds);
|
||||
|
||||
/**
|
||||
* 删除分公司配置信息
|
||||
|
|
@ -67,6 +67,6 @@ public interface ISysDeptConfigService {
|
|||
* @param sysDeptConfigId 分公司配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
int deleteSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.ghy.system.service.impl;
|
||||
|
||||
import com.ghy.common.core.domain.entity.SysDept;
|
||||
import com.ghy.common.core.text.Convert;
|
||||
import com.ghy.common.exception.ServiceException;
|
||||
import com.ghy.common.utils.DateUtils;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.system.domain.SysDeptConfig;
|
||||
import com.ghy.system.mapper.SysDeptConfigMapper;
|
||||
import com.ghy.system.mapper.SysDeptMapper;
|
||||
|
|
@ -44,8 +41,7 @@ public class SysDeptConfigServiceImpl implements ISysDeptConfigService {
|
|||
* @return 分公司配置
|
||||
*/
|
||||
@Override
|
||||
public SysDeptConfig selectSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId)
|
||||
{
|
||||
public SysDeptConfig selectSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId) {
|
||||
return sysDeptConfigMapper.selectSysDeptConfigBySysDeptConfigId(sysDeptConfigId);
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +52,7 @@ public class SysDeptConfigServiceImpl implements ISysDeptConfigService {
|
|||
* @return 分公司配置
|
||||
*/
|
||||
@Override
|
||||
public List<SysDeptConfig> selectSysDeptConfigList(SysDeptConfig sysDeptConfig)
|
||||
{
|
||||
public List<SysDeptConfig> selectSysDeptConfigList(SysDeptConfig sysDeptConfig) {
|
||||
return sysDeptConfigMapper.selectSysDeptConfigList(sysDeptConfig);
|
||||
}
|
||||
|
||||
|
|
@ -68,8 +63,7 @@ public class SysDeptConfigServiceImpl implements ISysDeptConfigService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysDeptConfig(SysDeptConfig sysDeptConfig)
|
||||
{
|
||||
public int insertSysDeptConfig(SysDeptConfig sysDeptConfig) {
|
||||
sysDeptConfig.setCreateTime(DateUtils.getNowDate());
|
||||
return sysDeptConfigMapper.insertSysDeptConfig(sysDeptConfig);
|
||||
}
|
||||
|
|
@ -81,8 +75,7 @@ public class SysDeptConfigServiceImpl implements ISysDeptConfigService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysDeptConfig(SysDeptConfig sysDeptConfig)
|
||||
{
|
||||
public int updateSysDeptConfig(SysDeptConfig sysDeptConfig) {
|
||||
sysDeptConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysDeptConfigMapper.updateSysDeptConfig(sysDeptConfig);
|
||||
}
|
||||
|
|
@ -94,8 +87,7 @@ public class SysDeptConfigServiceImpl implements ISysDeptConfigService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDeptConfigBySysDeptConfigIds(String sysDeptConfigIds)
|
||||
{
|
||||
public int deleteSysDeptConfigBySysDeptConfigIds(String sysDeptConfigIds) {
|
||||
return sysDeptConfigMapper.deleteSysDeptConfigBySysDeptConfigIds(Convert.toStrArray(sysDeptConfigIds));
|
||||
}
|
||||
|
||||
|
|
@ -106,8 +98,7 @@ public class SysDeptConfigServiceImpl implements ISysDeptConfigService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId)
|
||||
{
|
||||
public int deleteSysDeptConfigBySysDeptConfigId(Long sysDeptConfigId) {
|
||||
return sysDeptConfigMapper.deleteSysDeptConfigBySysDeptConfigId(sysDeptConfigId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<result property="plainOutTime" column="plain_out_time" />
|
||||
<result property="goOutTime" column="go_out_time" />
|
||||
<result property="goingOutTime" column="going_out_time" />
|
||||
<result property="goingOutTimeRate" column="going_out_time_rate" />
|
||||
<result property="goldenServer" column="golden_server" />
|
||||
<result property="monthRent" column="month_rent" />
|
||||
<result property="adapayAppId" column="adapay_app_id" />
|
||||
|
|
@ -42,7 +43,11 @@
|
|||
|
||||
<sql id="selectSysDeptConfig">
|
||||
select
|
||||
sys_dept_config_id, dept_id, banner_url, single_money, single_order_pay, single_order_no_pay, area_money, area_order_pay, area_order_no_pay, city_money, city_order_pay, city_order_no_pay, worker_rate, phone, plain_out_time, go_out_time, going_out_time, golden_server, month_rent, adapay_app_id, adapay_api_key, adapay_mock_key, adapay_rsa_private_key, adapay_max_retry_times, wx_app_id, wx_secret, serv_wx_app_id, serv_wx_secret, take_rate, create_by, create_time, update_by, update_time, remark
|
||||
sys_dept_config_id, dept_id, banner_url, single_money, single_order_pay, single_order_no_pay, area_money,
|
||||
area_order_pay, area_order_no_pay, city_money, city_order_pay, city_order_no_pay, worker_rate, phone,
|
||||
plain_out_time, go_out_time, going_out_time, going_out_time_rate, golden_server, month_rent, adapay_app_id,
|
||||
adapay_api_key, adapay_mock_key, adapay_rsa_private_key, adapay_max_retry_times, wx_app_id, wx_secret,
|
||||
serv_wx_app_id, serv_wx_secret, take_rate, create_by, create_time, update_by, update_time, remark
|
||||
from
|
||||
sys_dept_config
|
||||
</sql>
|
||||
|
|
@ -94,6 +99,7 @@
|
|||
<if test="plainOutTime != null">plain_out_time,</if>
|
||||
<if test="goOutTime != null">go_out_time,</if>
|
||||
<if test="goingOutTime != null">going_out_time,</if>
|
||||
<if test="goingOutTimeRate != null">going_out_time_rate,</if>
|
||||
<if test="goldenServer != null">golden_server,</if>
|
||||
<if test="monthRent != null">month_rent,</if>
|
||||
<if test="adapayAppId != null">adapay_app_id,</if>
|
||||
|
|
@ -129,6 +135,7 @@
|
|||
<if test="plainOutTime != null">#{plainOutTime},</if>
|
||||
<if test="goOutTime != null">#{goOutTime},</if>
|
||||
<if test="goingOutTime != null">#{goingOutTime},</if>
|
||||
<if test="goingOutTimeRate != null">#{goingOutTimeRate},</if>
|
||||
<if test="goldenServer != null">#{goldenServer},</if>
|
||||
<if test="monthRent != null">#{monthRent},</if>
|
||||
<if test="adapayAppId != null">#{adapayAppId},</if>
|
||||
|
|
@ -168,6 +175,7 @@
|
|||
<if test="plainOutTime != null">plain_out_time = #{plainOutTime},</if>
|
||||
<if test="goOutTime != null">go_out_time = #{goOutTime},</if>
|
||||
<if test="goingOutTime != null">going_out_time = #{goingOutTime},</if>
|
||||
<if test="goingOutTimeRate != null">going_out_time_rate = #{goingOutTimeRate},</if>
|
||||
<if test="goldenServer != null">golden_server = #{goldenServer},</if>
|
||||
<if test="monthRent != null">month_rent = #{monthRent},</if>
|
||||
<if test="adapayAppId != null">adapay_app_id = #{adapayAppId},</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue