Helius
2021-03-09 8fe37f0f7af3667b60e0f29a1ce8188c08c35bb1
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java
@@ -8,13 +8,8 @@
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.ShoppingGoods;
import com.matrix.system.hive.bean.SysOrder;
import com.matrix.system.hive.bean.SysOrderItem;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysOrderDao;
import com.matrix.system.hive.dao.SysOrderItemDao;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.hive.bean.*;
import com.matrix.system.hive.dao.*;
import com.matrix.system.hive.service.CodeService;
import com.matrix.system.hive.service.ShoppingGoodsService;
import com.matrix.system.hive.service.SysOrderService;
@@ -27,6 +22,7 @@
import com.rabbitmq.client.DeliverCallback;
import com.rabbitmq.client.Delivery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
@@ -36,6 +32,7 @@
/**
 * 微商城订单同步到erp系统
 */
@Component
public class OrderTask implements DeliverCallback {
@@ -75,6 +72,12 @@
    @Autowired
    BusParameterSettingsDao parameterSettingsDao;
    @Autowired
    private SysOrderFlowDao sysOrderFlowDao;
    @Autowired
    private ShoppingGoodsDao shoppingGoodsDao;
    @Transactional(rollbackFor = Exception.class)
    public void createOrder(ShopOrder orderDto) {
@@ -88,6 +91,7 @@
        }
        //获取订单归属门店
        order.setCompanyId(vipInfo.getCompanyId());
        order.setShopId(Long.parseLong(orderDto.getStoreId()+""));
        //同步的订单订单编号保持一致
        order.setOrderNo(orderDto.getOrderNo());
@@ -101,7 +105,8 @@
        order.setCashPay(orderDto.getOrderMoney().doubleValue());
        order.setTotal(orderDto.getOrderMoney().doubleValue());
        order.setZkTotal(orderDto.getOrderMoney().doubleValue());
        order.setArrears(0);
        order.setPayTime(new Date());
        order.setArrears(0D);
        int i = sysOrderDao.insert(order);
        // 创建订单明细,并计算总价与折扣总价
        // 总价
@@ -133,11 +138,6 @@
            orderItem.setPrice(orderItemDto.getPrice().doubleValue());
            orderItem.setZkPrice(orderItemDto.getPrice().doubleValue());
            orderItem.setGoodsId(shoppingGoods.getId());
            if (shoppingGoods.getGoodType().equals(Dictionary.SHOPPING_GOODS_TYPE_JJCP)) {
                orderItem.setAssembleId(shoppingGoods.getAssembleGoods().get(0).getId());
            } else if (shoppingGoods.getGoodType().equals(Dictionary.SHOPPING_GOODS_TYPE_XM)) {
                orderItem.setAssembleId(shoppingGoods.getAssembleProj().get(0).getId());
            }
            // 设置对应产品的id
            switch (shoppingGoods.getGoodType()) {
@@ -193,6 +193,23 @@
        // 设置销量
        orderService.setShopSelCount(sourceOrder);
        SysOrderFlow flow = new SysOrderFlow();
        flow.setFlowNo(codeService.getFlowCode() + "-" + i);
        Long goodsId = sourceOrder.getItems().get(0).getGoodsId();
        ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId);
        flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品");
        flow.setOrderId(sourceOrder.getId());
        flow.setVipId(sourceOrder.getVipId());
        flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY);
        flow.setAmount(orderDto.getOrderMoney());
        flow.setPayMethod("微信");
        flow.setShopId(sourceOrder.getShopId());
        flow.setCompanyId(sourceOrder.getCompanyId());
        sysOrderFlowDao.insert(flow);
    }