更新分成逻辑
This commit is contained in:
parent
06adee38b8
commit
cbbaf0a2e7
|
@ -149,4 +149,11 @@ public interface BonusMapper
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
BigDecimal selectSumOfWaitAmount(@Param("query") BonusQuery query);
|
BigDecimal selectSumOfWaitAmount(@Param("query") BonusQuery query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据业务类型和业务ID,将分成更新为待分成状态
|
||||||
|
* @param bstType 业务类型
|
||||||
|
* @param bstId 业务ID
|
||||||
|
*/
|
||||||
|
int validByBst(@Param("bstType") String bstType, @Param("bstId") Long bstId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,12 +256,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- validByBst -->
|
||||||
|
|
||||||
|
<update id="validByBst">
|
||||||
|
update bst_bonus bb
|
||||||
|
set bb.status = 'WAIT_DIVIDE',
|
||||||
|
bb.wait_amount = bb.wait_amount + bb.invalid_amount,
|
||||||
|
bb.invalid_amount = 0
|
||||||
|
where bb.bst_type = #{bstType}
|
||||||
|
and bb.bst_id = #{bstId}
|
||||||
|
and bb.status = 'INVALID'
|
||||||
|
and <include refid="checkAmount"/>
|
||||||
|
</update>
|
||||||
|
|
||||||
<update id="prepay">
|
<update id="prepay">
|
||||||
update bst_bonus bb
|
update bst_bonus bb
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
bb.wait_amount = bb.wait_amount + bb.invalid_amount,
|
|
||||||
bb.invalid_amount = 0,
|
|
||||||
bb.status = 'WAIT_DIVIDE',
|
|
||||||
<foreach open="bb.pre_pay_time = CASE id" collection="list" item="item" close="END,">
|
<foreach open="bb.pre_pay_time = CASE id" collection="list" item="item" close="END,">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="item.prePayTime != null">
|
<when test="item.prePayTime != null">
|
||||||
|
@ -278,7 +288,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{item.id}
|
#{item.id}
|
||||||
</foreach>
|
</foreach>
|
||||||
and <include refid="checkAmount"/>
|
and <include refid="checkAmount"/>
|
||||||
and bb.status = 'INVALID'
|
and bb.status = 'WAIT_DIVIDE'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="pay">
|
<update id="pay">
|
||||||
|
|
|
@ -83,6 +83,14 @@ public interface BonusService
|
||||||
*/
|
*/
|
||||||
public int batchInsert(List<? extends Bonus> list);
|
public int batchInsert(List<? extends Bonus> list);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据业务类型和业务ID,将分成更新为待分成状态
|
||||||
|
* @param bstType 业务类型
|
||||||
|
* @param bstId 业务ID
|
||||||
|
*/
|
||||||
|
public boolean validByBst(BonusBstType bstType, Long bstId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预分成
|
* 预分成
|
||||||
* @param bstType 业务类型
|
* @param bstType 业务类型
|
||||||
|
|
|
@ -178,6 +178,15 @@ public class BonusServiceImpl implements BonusService
|
||||||
return bonusMapper.batchInsert(list);
|
return bonusMapper.batchInsert(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validByBst(BonusBstType bstType, Long bstId) {
|
||||||
|
if (bstType == null || bstId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bonusMapper.validByBst(bstType.getType(), bstId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean prepayByBst(BonusBstType bstType, Long bstId) {
|
public boolean prepayByBst(BonusBstType bstType, Long bstId) {
|
||||||
if (bstType == null || bstId == null) {
|
if (bstType == null || bstId == null) {
|
||||||
|
|
|
@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
|
import com.ruoyi.bst.bonus.domain.enums.BonusBstType;
|
||||||
|
import com.ruoyi.bst.bonus.service.BonusService;
|
||||||
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
||||||
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
||||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||||
|
@ -41,6 +43,9 @@ public class OrderPayHandlerImpl implements PayHandler {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceIotService deviceIotService;
|
private DeviceIotService deviceIotService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BonusService bonusService;
|
||||||
|
|
||||||
// 支付成功后操作
|
// 支付成功后操作
|
||||||
@Override
|
@Override
|
||||||
public boolean onPaySuccess(PayVO pay) {
|
public boolean onPaySuccess(PayVO pay) {
|
||||||
|
@ -71,10 +76,15 @@ public class OrderPayHandlerImpl implements PayHandler {
|
||||||
int rows = orderMapper.updateByQuery(data, query);
|
int rows = orderMapper.updateByQuery(data, query);
|
||||||
ServiceUtil.assertion(rows != 1, "更新ID为%s的订单失败", order.getId());
|
ServiceUtil.assertion(rows != 1, "更新ID为%s的订单失败", order.getId());
|
||||||
|
|
||||||
|
// 分成更新为待分成状态
|
||||||
|
boolean valid = bonusService.validByBst(BonusBstType.ORDER, order.getId());
|
||||||
|
ServiceUtil.assertion(!valid, "更新ID为%s的订单分成失败", order.getId());
|
||||||
|
|
||||||
// 开始使用订单设备
|
// 开始使用订单设备
|
||||||
int start = orderDeviceService.start(orderDevice);
|
int start = orderDeviceService.start(orderDevice);
|
||||||
ServiceUtil.assertion(start != 1, "开始使用ID为%s的订单设备失败", orderDevice.getId());
|
ServiceUtil.assertion(start != 1, "开始使用ID为%s的订单设备失败", orderDevice.getId());
|
||||||
|
|
||||||
|
// 解锁设备
|
||||||
DeviceIotVO unlock = deviceIotService.unlock(orderDevice.getDeviceId(), DeviceUnLockType.USER, "订单支付成功开锁:" + order.getNo(), false);
|
DeviceIotVO unlock = deviceIotService.unlock(orderDevice.getDeviceId(), DeviceUnLockType.USER, "订单支付成功开锁:" + order.getNo(), false);
|
||||||
ServiceUtil.assertion(unlock.getDb() <= 0, "ID为%s的设备解锁失败", orderDevice.getDeviceId());
|
ServiceUtil.assertion(unlock.getDb() <= 0, "ID为%s的设备解锁失败", orderDevice.getDeviceId());
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.aliyun.core.utils.StringUtils;
|
||||||
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
|
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
|
||||||
import com.ruoyi.bst.order.domain.OrderQuery;
|
import com.ruoyi.bst.order.domain.OrderQuery;
|
||||||
import com.ruoyi.bst.order.domain.OrderVO;
|
import com.ruoyi.bst.order.domain.OrderVO;
|
||||||
|
@ -130,8 +131,12 @@ public class OrderController extends BaseController
|
||||||
if (!orderValidator.canOperate(dto.getOrderId())) {
|
if (!orderValidator.canOperate(dto.getOrderId())) {
|
||||||
return error("您无权退款ID为" + dto.getOrderId() + "的订单");
|
return error("您无权退款ID为" + dto.getOrderId() + "的订单");
|
||||||
}
|
}
|
||||||
|
String userName = getNickName();
|
||||||
dto.setUserId(getUserId());
|
dto.setUserId(getUserId());
|
||||||
dto.setUserName(getNickName());
|
dto.setUserName(userName);
|
||||||
|
if (StringUtils.isBlank(dto.getReason())) {
|
||||||
|
dto.setReason("管理员【" + userName + "】退款");
|
||||||
|
}
|
||||||
return toAjax(orderService.refund(dto));
|
return toAjax(orderService.refund(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user