935090232@qq.com
2021-04-03 00efd2e4db8157ece4116c956c314803ed073042
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.matrix.system.shopXcx.mqTask;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.matrix.core.tools.LogUtil;
import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao;
import com.matrix.system.fenxiao.entity.ShopSalesmanOrder;
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.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;
 
/**
 * 分销订单退款
 */
@Component
public class SalesOrderRefundTask implements DeliverCallback {
 
 
    @Autowired
    private ShopSalesmanOrderDao shopSalesmanOrderDao;
 
    @Autowired
        private ShopOrderDao shopOrderDao;
 
    @Autowired
    private ScoreVipDetailService scoreVipDetailService;
 
    @Autowired
    ShopOrderDetailsDao shopOrderDetailsDao;
 
 
    @Override
    public void handle(String consumerTag, Delivery message) throws IOException {
 
        String orderId = new String(message.getBody(), "UTF-8");
        LogUtil.debug("收到分销订单退款任务orderId={}", orderId);
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("order_id",orderId);
        ShopSalesmanOrder shopSalesmanOrder = shopSalesmanOrderDao.selectOne(queryWrapper);
        if(shopSalesmanOrder!=null){
            shopSalesmanOrder.setOrderStatus(ShopSalesmanOrder.STATUS_YTK);
            shopSalesmanOrderDao.updateById(shopSalesmanOrder);
        }else{
            LogUtil.debug("改订单为生成分销订单={}", orderId);
        }
        ShopOrder order=shopOrderDao.selectById(Integer.parseInt(orderId));
 
        //如果是积分支付则需要返还积分
        if(order.getScorePay()!=null && order.getScorePay()>0){
            LogUtil.debug("处理积分退款={}", orderId);
            scoreVipDetailService.refundScore(order.getUserId(),null,order.getScorePay(),Long.parseLong(order.getId()+""), ScoreVipDetail.SCORE_VIP_TYPE_CASH);
        }
 
        //消费获得积分返还,如果本订单获得了积分则要扣除获得积分
        scoreVipDetailService.removeByBusinessId(order.getUserId(),null,Long.parseLong(order.getId()+""));
 
 
    }
 
}