Commit 2fe5156d authored by hezhen's avatar hezhen

123

parent 8b8f707c
......@@ -31,6 +31,7 @@ import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
......@@ -80,9 +81,13 @@ public class CompanyWalletDetailV2Biz extends BaseBiz<CompanyWalletDetailMapper,
throw new BaseException("订单详情不存在",ResultCode.FAILED_CODE);
}
List<Integer> types=new ArrayList<>();
if (type == 2 ){
types.add(204);
}else {
types.add(201);
types.add(202);
types.add(203);
}
OrderAccountDetail accountDetail = getAccountDetail(types, baseOrder.getId());
if (accountDetail == null ){
throw new BaseException("费用明细不存在",ResultCode.FAILED_CODE);
......@@ -126,14 +131,17 @@ public class CompanyWalletDetailV2Biz extends BaseBiz<CompanyWalletDetailMapper,
BigDecimal safeAmount = BigDecimal.ZERO;//不计免赔费
BigDecimal rentVehicleAmount = BigDecimal.ZERO;//车辆租赁费
BigDecimal orderComssion = BigDecimal.ZERO;//订单抽成
BigDecimal platformComssion;//平台抽成
BigDecimal platformComssion= BigDecimal.ZERO;//平台抽成
BigDecimal lossSpecifiedAmount = BigDecimal.ZERO;//定损费
BigDecimal breakRulesRegulation= BigDecimal.ZERO;//违章费
BigDecimal violateAmount;//违约金
BigDecimal violateAmount= BigDecimal.ZERO;//违约金
if (walletDetailDTO.getIsCanelOrder() != null && walletDetailDTO.getIsCanelOrder() == 1){
violateAmount = walletDetailDTO.getViolateAmount();
platformComssion=violateAmount.multiply(walletDetailDTO.getOrderExtract()).setScale(2, BigDecimal.ROUND_HALF_UP);
violateAmount=violateAmount.subtract(platformComssion);
}else {
if (type == 2){
breakRulesRegulation=walletDetailDTO.getBreakRulesRegulation();
}else {
closedVehicleAmout=walletDetailDTO.getClosedVehicleAmout() == null ? BigDecimal.ZERO : walletDetailDTO.getClosedVehicleAmout();
safeAmount=walletDetailDTO.getDamageSafeAmount() == null ? BigDecimal.ZERO : walletDetailDTO.getDamageSafeAmount();
......@@ -143,8 +151,6 @@ public class CompanyWalletDetailV2Biz extends BaseBiz<CompanyWalletDetailMapper,
rentVehicleAmount=walletDetailDTO.getRentVehicleAmount();
lossSpecifiedAmount=walletDetailDTO.getLossSpecifiedAmount();
violateAmount=walletDetailDTO.getViolateAmount();
if (type == 2){
breakRulesRegulation=walletDetailDTO.getBreakRulesRegulation();
}
......@@ -348,22 +354,22 @@ public class CompanyWalletDetailV2Biz extends BaseBiz<CompanyWalletDetailMapper,
for (OrderAccountDeduction orderAccountDeduction:deductions){
Integer type=orderAccountDeduction.getType() == null ? 0 : orderAccountDeduction.getType();
BigDecimal amount=orderAccountDeduction.getAmount() == null ?BigDecimal.ZERO : orderAccountDeduction.getAmount();
if (type == DeductionTypeEnum.VIOLATE_CANCEL.getCode()){
if (Objects.equals(DeductionTypeEnum.VIOLATE_CANCEL.getCode(),type)){
walletDetailV2DTO.setIsCanelOrder(1);
walletDetailV2DTO.setViolateAmount(amount);
}else {
walletDetailV2DTO.setIsCanelOrder(0);
if (type == DeductionTypeEnum.VIOLATE_ADVANCE.getCode() || type == DeductionTypeEnum.VIOLATE_DELAY.getCode()){
if (Objects.equals(DeductionTypeEnum.VIOLATE_ADVANCE.getCode(),type) || Objects.equals(DeductionTypeEnum.VIOLATE_DELAY.getCode(),type)){
walletDetailV2DTO.setViolateAmount(amount);
}else if (type == DeductionTypeEnum.VIOLATE_CHANGE_C.getCode()){
}else if (Objects.equals(DeductionTypeEnum.VIOLATE_CHANGE_C.getCode(),type)){
walletDetailV2DTO.setChageAmount(amount);
}else if (type == DeductionTypeEnum.CONSUME.getCode()){
}else if (Objects.equals(DeductionTypeEnum.CONSUME.getCode(),type)){
walletDetailV2DTO.setOrderAmount(amount);
}else if (type == DeductionTypeEnum.DAMAGES.getCode()){
}else if (Objects.equals(DeductionTypeEnum.DAMAGES.getCode(),type)){
walletDetailV2DTO.setLossSpecifiedAmount(amount);
}else if (type == DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getCode()){
}else if (Objects.equals(DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getCode(),type)){
walletDetailV2DTO.setBreakRulesRegulation(amount);
}else if (type == DeductionTypeEnum.OTHER_DELAY_SAFE.getCode()){
}else if (Objects.equals(DeductionTypeEnum.OTHER_DELAY_SAFE.getCode(),type)){
walletDetailV2DTO.setDamageSafeAmount2(amount);
}
}
......
......@@ -4,6 +4,7 @@ package com.xxfc.platform.order.mqhandler;
import cn.hutool.json.JSONUtil;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.order.biz.CompanyWalletDetailBiz;
import com.xxfc.platform.order.biz.CompanyWalletDetailV2Biz;
import com.xxfc.platform.order.biz.OrderAccountBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
......@@ -22,15 +23,14 @@ import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.xxfc.platform.order.config.RabbitOrderConfig.ORDER_DEPOSIT_FINISH_QUEUE;
import static com.xxfc.platform.order.config.RabbitOrderConfig.ORDER_DEPOSIT_REFUND_QUEUE;
import static com.xxfc.platform.order.config.RabbitOrderConfig.*;
@Component
@Slf4j
public class OrderExtractMQHandler {
@Autowired
CompanyWalletDetailBiz companyWalletDetailBiz;
CompanyWalletDetailV2Biz companyWalletDetailBiz;
......@@ -55,7 +55,47 @@ public class OrderExtractMQHandler {
OrderMQDTO orderMQDTO = JSONUtil.toBean(msg, OrderMQDTO.class);
CompanyWalletDetail companyWalletDetail=new CompanyWalletDetail();
companyWalletDetail.setCono(orderMQDTO.getNo());
companyWalletDetailBiz.addOrUpd(companyWalletDetail);
companyWalletDetailBiz.addOrUpd(companyWalletDetail,1);
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.info("接收到的消息失败");
try {
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
} catch (IOException i) {
log.error(e.getMessage(), i);
}
log.error(e.getMessage(), e);
}
}
});
}
/**
* 退款
* @param
*/
@RabbitListener(queues = ORDER_DEPOSIT_END2_QUEUE)
public void orderHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
try {
Thread.sleep(5000L);
}catch (Exception e) {
log.error(e.getMessage(), e);
}
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
OrderMQDTO orderMQDTO = JSONUtil.toBean(msg, OrderMQDTO.class);
CompanyWalletDetail companyWalletDetail=new CompanyWalletDetail();
companyWalletDetail.setCono(orderMQDTO.getNo());
companyWalletDetailBiz.addOrUpd(companyWalletDetail,2);
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
......
......@@ -4,6 +4,7 @@ package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.order.biz.CompanyWalletDetailBiz;
import com.xxfc.platform.order.biz.CompanyWalletDetailV2Biz;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -12,12 +13,12 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("wallet/detail")
public class CompanyWalletDetailController extends BaseController<CompanyWalletDetailBiz, CompanyWalletDetail> {
public class CompanyWalletDetailController extends BaseController<CompanyWalletDetailV2Biz, CompanyWalletDetail> {
@RequestMapping(value = "upd", method = RequestMethod.POST)
public ObjectRestResponse refundAmount(@RequestBody CompanyWalletDetail companyWalletDetail) {
baseBiz.addOrUpd(companyWalletDetail);
baseBiz.addOrUpd(companyWalletDetail,2);
return ObjectRestResponse.succ();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment