Commit 7f9113ed authored by hezhen's avatar hezhen

修改分账

parent 14c8338d
...@@ -96,7 +96,7 @@ public class CompanyWalletDetailDTO{ ...@@ -96,7 +96,7 @@ public class CompanyWalletDetailDTO{
public BigDecimal getOrderComssion(){ public BigDecimal getOrderComssion(){
return getViolateAmount().multiply(orderExtract).setScale(2, BigDecimal.ROUND_HALF_UP); return getVehicleAmount().multiply(orderExtract).setScale(2, BigDecimal.ROUND_HALF_UP);
} }
...@@ -105,7 +105,7 @@ public class CompanyWalletDetailDTO{ ...@@ -105,7 +105,7 @@ public class CompanyWalletDetailDTO{
public BigDecimal getPlatformComssion(){ public BigDecimal getPlatformComssion(){
return getViolateAmount().multiply(platformExtract).setScale(2, BigDecimal.ROUND_HALF_UP); return getVehicleAmount().multiply(platformExtract).setScale(2, BigDecimal.ROUND_HALF_UP);
} }
......
...@@ -82,7 +82,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C ...@@ -82,7 +82,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C
walletDetailDTO.setDeposit(vehicleDetail.getDeposit()); walletDetailDTO.setDeposit(vehicleDetail.getDeposit());
walletDetailDTO.setViolateAmount(baseOrder.getViolateAmount()); walletDetailDTO.setViolateAmount(baseOrder.getViolateAmount());
walletDetailDTO.setBreakRulesRegulation(vehicleDetail.getViolateTrafficAmount()); walletDetailDTO.setBreakRulesRegulation(vehicleDetail.getViolateTrafficAmount());
walletDetailDTO.setLossSpecifiedAmount(baseOrder.getViolateAmount()); walletDetailDTO.setLossSpecifiedAmount(baseOrder.getDamagesAmount());
//获取门店钱包信息 //获取门店钱包信息
CompanyWallet endCompany=companyWalletBiz.selectById(vehicleDetail.getActualEndCompanyId()); CompanyWallet endCompany=companyWalletBiz.selectById(vehicleDetail.getActualEndCompanyId());
...@@ -142,10 +142,10 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C ...@@ -142,10 +142,10 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C
}if (walletDetailDTO.getOrderAmount() != null && walletDetailDTO.getOrderAmount().compareTo(BigDecimal.ZERO)>0){ }if (walletDetailDTO.getOrderAmount() != null && walletDetailDTO.getOrderAmount().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getStartCompanyId()); BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getStartCompanyId());
startCompanyAmount=startCompanyAmount.add(walletDetailDTO.getOrderAmount()); startCompanyAmount=startCompanyAmount.add(walletDetailDTO.getOrderAmount());
companyWalletDetail.setAmount(walletDetailDTO.getOrderAmount()); companyWalletDetail.setAmount(walletDetailDTO.getOrderComssion());
companyWalletDetail.setCompanyId(vehicleDetail.getStartCompanyId()); companyWalletDetail.setCompanyId(vehicleDetail.getStartCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getStartBranchId()); companyWalletDetail.setBranchId(vehicleDetail.getStartBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getOrderAmount().add(amount)); companyWalletDetail.setSAmount(walletDetailDTO.getOrderComssion().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.ORDER_COMSSION.getCode()); companyWalletDetail.setSource(CompanyWalletSourceEnum.ORDER_COMSSION.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.VEHICLE.getCode()); companyWalletDetail.setItype(CompanyWalletITypeEnum.VEHICLE.getCode());
companyWalletDetail.setId(null); companyWalletDetail.setId(null);
......
...@@ -22,6 +22,10 @@ public class RabbitOrderConfig extends RabbitCommonConfig { ...@@ -22,6 +22,10 @@ public class RabbitOrderConfig extends RabbitCommonConfig {
public static final String ORDER_DEPOSIT_REFUND_QUEUE = "order.deposit.refund.queue"; public static final String ORDER_DEPOSIT_REFUND_QUEUE = "order.deposit.refund.queue";
public static final String ORDER_DEPOSIT_FINISH_QUEUE = "order.deposit.finish.queue";
//同步企业信息 //同步企业信息
public static final String ORDER_CORPORATION_UPD_QUEUE = "order.corporation:upd.queue"; public static final String ORDER_CORPORATION_UPD_QUEUE = "order.corporation:upd.queue";
...@@ -31,6 +35,8 @@ public class RabbitOrderConfig extends RabbitCommonConfig { ...@@ -31,6 +35,8 @@ public class RabbitOrderConfig extends RabbitCommonConfig {
static { static {
myQueue = new ArrayList<BindDTO>(){{ myQueue = new ArrayList<BindDTO>(){{
add(new BindDTO(ORDER_DEPOSIT_REFUND_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH)); add(new BindDTO(ORDER_DEPOSIT_REFUND_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
add(new BindDTO(ORDER_DEPOSIT_FINISH_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
//企业 //企业
add(new BindDTO(ORDER_CORPORATION_UPD_QUEUE, VEHICLE_TOPIC, KEY_CORPORATION_UPD)); add(new BindDTO(ORDER_CORPORATION_UPD_QUEUE, VEHICLE_TOPIC, KEY_CORPORATION_UPD));
//门店 //门店
......
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.OrderAccountBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;
import java.io.IOException;
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;
@Component
@Slf4j
public class OrderExtractMQHandler {
@Autowired
CompanyWalletDetailBiz companyWalletDetailBiz;
/**
* 退款
* @param
*/
@RabbitListener(queues = ORDER_DEPOSIT_FINISH_QUEUE)
public void integralHandler(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);
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);
}
}
});
}
}
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