admin
2024-01-23 81da61b828e29b7745e1382dfbbaeb685dc083ef
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -7,8 +7,13 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.dy.DYOrder;
import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService;
import com.yeshi.fanli.util.goods.douyin.CSJCPSApiUtil;
import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail;
import org.apache.commons.beanutils.PropertyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -104,6 +109,9 @@
@Service
public class CommonOrderServiceImpl implements CommonOrderService {
    private Logger logger = LoggerFactory.getLogger(CommonOrderService.class);
    @Resource
    private CommonOrderMapper commonOrderMapper;
@@ -994,6 +1002,7 @@
            } else {
                cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
                cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
                cog.setTitle(taoBaoOrder.getTitle());
                newCommonOrder.setCommonOrderGoods(cog);
            }
            newCommonOrder.setStateWholeOrder(wholeOrderState);
@@ -1011,11 +1020,10 @@
                                        taoBaoGoods.getRootCategoryName(), taoBaoGoods.getLeafName()));
                    } catch (TaobaoGoodsDownException e) {
                        e.printStackTrace();
                        LogHelper.errorDetailInfo(e, "AUCTIONID:" + taoBaoOrder.getAuctionId(), "");
                        logger.warn("淘宝商品下架:{}", taoBaoOrder.getAuctionId(), e);
                        try {
                            taoBaoGoods = TaoBaoUtil.getSimpleGoodsBrief(taoBaoOrder.getAuctionId());
                            // 记录商品分类
                        } catch (Exception e1) {
                            CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
                                    taoBaoOrder.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO);
@@ -1029,6 +1037,8 @@
                }
                cog.setCreateTime(new Date());
                cog.setUpdateTime(new Date());
                //覆盖原来的商品ID
                cog.setGoodsId(newCommonOrder.getCommonOrderGoods().getGoodsId());
                commonOrderGoodsMapper.insertSelective(cog);
            }
            newCommonOrder.setUserInfo(new UserInfo(uid));
@@ -1313,6 +1323,47 @@
            newCommonOrder.setUserInfo(new UserInfo(uid));
            commonOrderList.add(addCommonOrder(newCommonOrder));
        }
        addConfirmMQMsg(commonOrderList);
        return commonOrderList;
    }
    @Override
    public List<CommonOrderAddResultDTO> addDYOrder(DYOrder order, Long uid) throws CommonOrderException {
        List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
            CommonOrder newCommonOrder = CommonOrderFactory.create(order);
            CommonOrderGoods cog = new CommonOrderGoods();
            cog.setGoodsId(order.getProduct_id());
            cog.setGoodsType(Constant.SOURCE_TYPE_DY);
            newCommonOrder.setCommonOrderGoods(cog);
            newCommonOrder.setStateWholeOrder(newCommonOrder.getState());
            // 订单商品插入
            List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper.listByGoodsIdAndGoodsType(cog.getGoodsId(),
                    cog.getGoodsType());
            if (commonGoodsList.size() <= 0)// 不存在就插入商品
            {
                DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(order.getProduct_id()));
                if (goods == null) {
                    goods = new DYGoodsDetail();
                    goods.setTitle(order.getProduct_name());
                    goods.setPrice(0);
                    goods.setProduct_id(Long.parseLong(order.getProduct_id()));
                    goods.setCover(order.getProduct_img());
                }
                if (goods != null) {
                    cog = CommonOrderGoodsFactory.create(goods);
                }
                cog.setCreateTime(new Date());
                cog.setUpdateTime(new Date());
                commonOrderGoodsMapper.insertSelective(cog);
            } else {
            }
            newCommonOrder.setUserInfo(new UserInfo(uid));
            commonOrderList.add(addCommonOrder(newCommonOrder));
        addConfirmMQMsg(commonOrderList);
        return commonOrderList;
    }
@@ -1905,7 +1956,13 @@
    @Override
    public List<CommonOrder> getByOrderNo(Long uid, String orderNO) {
        return commonOrderMapper.getByOrderNo(uid, orderNO);
        if(uid!=null) {
            return commonOrderMapper.getByOrderNo(uid, orderNO);
        }else{
            CommonOrderMapper.DaoQuery daoQuery=new CommonOrderMapper.DaoQuery();
            daoQuery.orderId = orderNO;
            return  commonOrderMapper.list(daoQuery,0,100);
        }
    }
@@ -2470,14 +2527,14 @@
    }
    @Override
    public List<CommonOrder> listPayStateOrder(int sourceType, Date minThirdCreateTime, Date maxThirdCreateTime) {
    public List<CommonOrder> listPayStateOrder(Integer sourceType, Date minThirdCreateTime, Date maxThirdCreateTime,int page,int pageSize) {
        CommonOrderMapper.DaoQuery daoQuery = new CommonOrderMapper.DaoQuery();
        daoQuery.minThirdCreateTime = minThirdCreateTime;
        daoQuery.maxThirdCreateTime = maxThirdCreateTime;
        daoQuery.state = CommonOrder.STATE_FK;
        daoQuery.sourceType = sourceType;
        daoQuery.sortList = Arrays.asList(new String[]{"co_third_create_time ASC"});
        return commonOrderMapper.list(daoQuery, 0, 200);
        return commonOrderMapper.list(daoQuery, (page-1)*pageSize, pageSize);
    }
}