|
@@ -2,6 +2,7 @@ package com.pj.tb_goods_transit;
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
@@ -24,6 +25,7 @@ import com.pj.tb_goods.TbGoods;
|
|
|
import com.pj.tb_goods.TbGoodsMapper;
|
|
|
import com.pj.tb_goods_cart.TbGoodsCart;
|
|
|
import com.pj.tb_goods_cart.TbGoodsCartMapper;
|
|
|
+import com.pj.tb_goods_cart.TbGoodsCartService;
|
|
|
import com.pj.tb_goods_transit.param.JudgeTransitParam;
|
|
|
import com.pj.tb_goods_transit.param.PurchaseLevelOneGoodsTransitParam;
|
|
|
import com.pj.tb_goods_transit.param.TransactionGoodsParam;
|
|
@@ -44,6 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -66,8 +69,13 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
/** 监管产品mapper */
|
|
|
@Autowired
|
|
|
private TbGoodsMapper tbGoodsMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private SmsRetryService smsRetryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TbGoodsCartService tbGoodsCartService;
|
|
|
+
|
|
|
/** 互市区mapper */
|
|
|
@Autowired
|
|
|
private TbTradeAreaMapper tbTradeAreaMapper;
|
|
@@ -294,15 +302,24 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
Long goodsId = tbGoodsTransit.getGoodsId();
|
|
|
TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
|
|
|
if(tbGoods == null)throw new RuntimeException("当前商品海关已不允许销售!");
|
|
|
+ //一天只能下一单
|
|
|
+ //1.查询数据库内是否有订单
|
|
|
+ LambdaQueryWrapper<TbOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(TbOrder::getBuyUserId,appLoginInfo.getFk()); //边民表主键匹配
|
|
|
+ queryWrapper.apply("DATE(create_time) = DATE({0})", new Date()); // 匹配当天的数据
|
|
|
+ queryWrapper.ne(TbOrder::getEnterpriseConfirm,2);
|
|
|
+ List<TbOrder> orderList = tbOrderMapper.selectList(queryWrapper);
|
|
|
+ if(orderList.size() != 0){
|
|
|
+ TbOrder tbOrder = orderList.get(0);
|
|
|
+ throw new ServiceException("您在 " + tbOrder.getCreateTime() + " 已下单,请勿重复下单。");
|
|
|
+ }
|
|
|
//执行采购,创建一级市场订单表 , 该方法只是设置tbOrder的属性
|
|
|
TbOrder tbOrder = methodGoodsTransitService.setTbOrderProperties(tbGoodsTransit, appLoginInfo);
|
|
|
//执行保存 todo:创建订单
|
|
|
int insert = tbOrderMapper.insert(tbOrder);
|
|
|
if(insert == 1){
|
|
|
- //将该商品被添加进的购物车的下单状态goodsIsorderStatus改成已下单
|
|
|
- List<TbGoodsCart> tbGoodsCarts = tbGoodsCartMapper.selectList(new LambdaQueryWrapper<TbGoodsCart>().eq(TbGoodsCart::getPublishGoodsId, goodsTransitId));
|
|
|
- methodGoodsTransitService.goodsCartIsOrder(tbGoodsCarts);
|
|
|
//删除购物车
|
|
|
+// boolean removeById = tbGoodsCartService.removeById(purchaseLevelOntGoodsTransitParam.getGoodsCartId());
|
|
|
tbGoodsCartMapper.deleteById(purchaseLevelOntGoodsTransitParam.getGoodsCartId());
|
|
|
//将商品信息改成已被下单
|
|
|
tbGoodsTransit.setIsOrders(1);
|