| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | |
| | | import com.matrix.biz.bean.BizUser; |
| | | import com.matrix.biz.service.BizUserService; |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao; |
| | | 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; |
| | | import com.matrix.system.hive.service.SysVipInfoService; |
| | | import com.matrix.system.shopXcx.bean.ShopOrder; |
| | | import com.matrix.system.shopXcx.bean.ShopOrderDetails; |
| | | import com.matrix.system.shopXcx.bean.ShopSku; |
| | |
| | | import com.matrix.system.shopXcx.dao.ShopSkuDao; |
| | | import com.rabbitmq.client.DeliverCallback; |
| | | import com.rabbitmq.client.Delivery; |
| | | import org.apache.logging.log4j.message.Message; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 微商城订单同步到erp系统 |
| | | */ |
| | | @Component |
| | | public class OrderTask implements DeliverCallback { |
| | | public class OrderTask implements MessageHandler { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | ShopOrderDetailsDao shopOrderDetailsDao; |
| | | |
| | | @Autowired |
| | | BizUserService bizUserService; |
| | | SysVipInfoService sysVipInfoService; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private ShoppingGoodsDao shoppingGoodsDao; |
| | | |
| | | @Autowired |
| | | private ShopSalesmanOrderDao shopSalesmanOrderDao; |
| | | |
| | | @Autowired |
| | | private ShopSalesmanGradeDao shopSalesmanGradeDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createOrder(ShopOrder orderDto) { |
| | | public void synchronizationOrderToErp(ShopOrder orderDto) { |
| | | |
| | | //判断是否存在需要同步的产品,只有绑定了erp中产品的才同步 |
| | | boolean needTb=false; |
| | | for (ShopOrderDetails orderItemDto : orderDto.getDetails()) { |
| | |
| | | } |
| | | if(needTb){ |
| | | |
| | | BizUser bizUser = bizUserService.findByOpenId(orderDto.getUserId()); |
| | | SysVipInfo vipInfo = sysVipInfoService.findById(orderDto.getUserId()); |
| | | SysOrder order = new SysOrder(); |
| | | //TODO 根据公司id区分 |
| | | SysVipInfo vipInfo = vipDao.selectByPhone(bizUser.getPhoneNumber()); |
| | | if(SysVipInfo.UNDEAL_VIP==vipInfo.getIsDeal()){ |
| | | //非成交客户下单更新客户为成交客户 |
| | | vipInfo.setIsDeal(SysVipInfo.DEAL_VIP); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return "微商城订单同步到erp系统"; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.CREATE_ORDER; |
| | | } |
| | | |
| | | String orderId = new String(message.getBody(), "UTF-8"); |
| | | @Override |
| | | public void handle(Map<String,Object> param) { |
| | | |
| | | String orderId = (String) param.get("orderId"); |
| | | LogUtil.debug("收到创建订单任务orderId={}", orderId); |
| | | //获取订单信息 |
| | | ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); |
| | | //获取订单详情 |
| | | List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId)); |
| | | order.setDetails(orderDetails); |
| | | createOrder(order); |
| | | //同步订单到erp |
| | | synchronizationOrderToErp(order); |
| | | |
| | | } |
| | | |
| | | } |