jiangqs
2023-05-23 687dbd8e6ababc010a3da5503b95cd62cecf9f02
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -10,34 +10,25 @@
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.order.domain.dto.*;
import com.ruoyi.order.domain.pojo.goods.Goods;
import com.ruoyi.order.domain.pojo.goods.GoodsFile;
import com.ruoyi.order.domain.pojo.goods.ShopGoods;
import com.ruoyi.order.domain.pojo.order.ConsumerGoods;
import com.ruoyi.order.domain.pojo.order.Order;
import com.ruoyi.order.domain.pojo.order.OrderGoods;
import com.ruoyi.order.domain.pojo.order.ShoppingCart;
import com.ruoyi.order.domain.vo.*;
import com.ruoyi.order.service.goods.GoodsFileService;
import com.ruoyi.order.service.goods.ShopGoodsService;
import com.ruoyi.order.service.order.ConsumerGoodsService;
import com.ruoyi.order.service.order.OrderGoodsService;
import com.ruoyi.order.service.order.ShoppingCartService;
import com.ruoyi.order.util.CodeFactoryUtil;
import com.ruoyi.system.api.RemoteMemberService;
import com.ruoyi.system.api.RemoteShopService;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.system.api.domain.dto.*;
import com.ruoyi.system.api.service.*;
import com.ruoyi.system.api.constant.AppErrorConstant;
import com.ruoyi.system.api.domain.dto.AppBaseGetDto;
import com.ruoyi.system.api.domain.dto.AppMemberBindingDto;
import com.ruoyi.system.api.domain.dto.AppMemberGoodsTypeDto;
import com.ruoyi.system.api.domain.poji.goods.Goods;
import com.ruoyi.system.api.domain.poji.goods.GoodsFile;
import com.ruoyi.system.api.domain.poji.goods.ShopGoods;
import com.ruoyi.system.api.domain.poji.member.Member;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.domain.vo.AppOrderTotalVo;
import com.ruoyi.system.api.domain.vo.AppUserCouponVo;
import com.ruoyi.order.mapper.order.OrderMapper;
import com.ruoyi.order.service.goods.GoodsService;
import com.ruoyi.order.service.order.OrderService;
import com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo;
import org.springframework.stereotype.Service;
@@ -63,16 +54,7 @@
    private OrderMapper orderMapper;
    @Resource
    private GoodsService goodsService;
    @Resource
    private ShopGoodsService shopGoodsService;
    @Resource
    private RemoteMemberService remoteMemberService;
    @Resource
    private GoodsFileService goodsFileService;
    @Resource
    private OrderGoodsService orderGoodsService;
@@ -87,7 +69,11 @@
    private ConsumerGoodsService consumerGoodsService;
    @Resource
    private ShoppingCartService shoppingCartService;
    private RemoteGoodsService remoteGoodsService;
    @Resource
    private RemoteShoppingCartService remoteShoppingCartService;
    /**
     * @description: buyGoods
@@ -132,19 +118,22 @@
            goodsId = appBuyGoodsDto.getGoodsId();
            buyNum = appBuyGoodsDto.getBuyNum();
            userCouponId = appBuyGoodsDto.getUserCouponId();
            goods = goodsService.getById(goodsId);
            goods = remoteGoodsService.getGoods(goodsId).getData();
            appSureOrderGoodsVo.setGoodsId(goodsId);
            appSureOrderGoodsVo.setGoodsName(goods.getGoodsName());
            appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction());
            appSureOrderGoodsVo.setGoodsType(goods.getGoodsType());
            //商品图片
            goodsFile = goodsFileService.getGoodsPicture(goodsId);
            goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData();
            appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl());
            buyNum = appBuyGoodsDto.getBuyNum();
            appSureOrderGoodsVo.setBuyNum(buyNum);
            goodsPrice = goods.getSalesPrice();
            //商户定制价格
            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(appSureOrderDto.getShopId(),goods.getGoodsId());
            AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
            appShopGoodsGetDto.setShopId(appSureOrderDto.getShopId());
            ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
            if(shopGoods!=null){
                goodsPrice = shopGoods.getSalesPrice();
            }
@@ -250,27 +239,29 @@
        String orderNo = CodeFactoryUtil.getShopOrderNo();
        OrderGoods orderGoods;
        String orderGoodsId;
        ShoppingCart shoppingCart;
        HashSet<String> goodsTypeSet = new HashSet<>();
        for(AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList){
            appSureOrderGoodsVo = new AppSureOrderGoodsVo();
            useCoupon = 0;
            goodsId = appBuyGoodsDto.getGoodsId();
            userCouponId = appBuyGoodsDto.getUserCouponId();
            goods = goodsService.getById(goodsId);
            goods = remoteGoodsService.getGoods(goodsId).getData();
            appSureOrderGoodsVo.setGoodsId(goodsId);
            appSureOrderGoodsVo.setGoodsName(goods.getGoodsName());
            appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction());
            appSureOrderGoodsVo.setGoodsType(goods.getGoodsType());
            //商品图片
            goodsFile = goodsFileService.getGoodsPicture(goodsId);
            goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData();
            appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl());
            buyNum = appBuyGoodsDto.getBuyNum();
            appSureOrderGoodsVo.setBuyNum(buyNum);
            goodsPrice = goods.getSalesPrice();
            serviceNum = goods.getServiceNum();
            //商户定制价格
            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(appPlaceOrderDto.getShopId(),goods.getGoodsId());
            AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
            appShopGoodsGetDto.setShopId(appPlaceOrderDto.getShopId());
            ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
            if(shopGoods!=null){
                goodsPrice = shopGoods.getSalesPrice();
                serviceNum = shopGoods.getServiceNum();
@@ -335,7 +326,10 @@
            orderGoods.setGoodsType(goods.getGoodsType());
            orderGoodsService.save(orderGoods);
            //清空购物车
            shoppingCartService.deleteByUserIdAndGoodsId(userId,goodsId);
            AppShoppingCartDelDto appShoppingCartDelDto = new AppShoppingCartDelDto();
            appShoppingCartDelDto.setGoodsId(goodsId);
            appShoppingCartDelDto.setUserId(userId);
            remoteShoppingCartService.deleteShoppingCart(appShoppingCartDelDto);
            if(goods.getGoodsType()==1){
                goodsTypeSet.add("周期");
            }else if(goods.getGoodsType()==2){
@@ -714,12 +708,15 @@
        for(AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList){
            goodsId = appBuyGoodsDto.getGoodsId();
            userCouponId = appBuyGoodsDto.getUserCouponId();
            goods = goodsService.getById(goodsId);
            goods = remoteGoodsService.getGoods(goodsId).getData();
            buyNum = appBuyGoodsDto.getBuyNum();
            goodsPrice = goods.getSalesPrice();
            serviceNum = goods.getServiceNum();
            //商户定制价格
            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(merNewOrderDto.getShopId(),goods.getGoodsId());
            AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
            appShopGoodsGetDto.setShopId(merNewOrderDto.getShopId());
            ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
            if(shopGoods!=null){
                goodsPrice = shopGoods.getSalesPrice();
                serviceNum = shopGoods.getServiceNum();