From b0c5d432ec041221dcbe81ca5ae3aa20fe3bddc6 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Mon, 22 Mar 2021 20:17:58 +0800 Subject: [PATCH] Merge branch 'score_shop' of http://120.27.238.55:7000/r/beauty-erp into score_shop --- zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java | 80 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 0 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java new file mode 100644 index 0000000..f099fdc --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java @@ -0,0 +1,80 @@ +package com.matrix.system.shopXcx.mqTask; + + +import com.matrix.biz.service.BizUserService; +import com.matrix.core.tools.LogUtil; +import com.matrix.system.score.entity.ScoreVipDetail; +import com.matrix.system.score.service.ScoreVipDetailService; +import com.matrix.system.shopXcx.bean.ShopOrder; +import com.matrix.system.shopXcx.bean.ShopOrderDetails; +import com.matrix.system.shopXcx.dao.ShopOrderDao; +import com.matrix.system.shopXcx.dao.ShopOrderDetailsDao; +import com.rabbitmq.client.DeliverCallback; +import com.rabbitmq.client.Delivery; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.List; + +/** + * 订单创建积分事件处理 + */ +@Component +public class ScoreOrderTask implements DeliverCallback { + + + @Autowired + ShopOrderDao shopOrderDao; + @Autowired + ShopOrderDetailsDao shopOrderDetailsDao; + + @Autowired + BizUserService bizUserService; + + @Autowired + ScoreVipDetailService scoreVipDetailService; + + + + @Override + public void handle(String consumerTag, Delivery message) throws IOException { + + String orderId = new String(message.getBody(), "UTF-8"); + LogUtil.debug("收到订单积分任务orderId={}", orderId); + //获取订单信息 + ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); + //获取订单详情 + List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId)); + order.setDetails(orderDetails); + //扣除积分 + if(order.getScorePay()!=null&&order.getScorePay()>0){ + scoreVipDetailService.deductionScore(order.getUserId(),null,Long.parseLong(order.getStoreId()+""),order.getScorePay(),Long.parseLong(order.getId()+""), ScoreVipDetail.SCORE_VIP_TYPE_CASH,"商城积分抵扣"); + }else{ + //消费获得积分 + int addScore=0; + for(ShopOrderDetails shopOrderDetail : orderDetails) { + if(shopOrderDetail.getPayType()==ShopOrderDetails.PAYTYPE_MICRO){ + Integer xfkdScore= shopOrderDetail.getShopSku().getScore(); + if(xfkdScore!=null && xfkdScore>0){ + addScore+=xfkdScore; + } + } + } + if(addScore>0){ + //插入新的积分 + scoreVipDetailService.addScore( + order.getUserId(),null, + null, + Long.parseLong(order.getStoreId()+""), + addScore, + Long.parseLong(orderId+""), + ScoreVipDetail.SCORE_VIP_TYPE_CASH, + "微商城消费"); + } + } + + + } + +} -- Gitblit v1.9.1