|
@@ -18,14 +18,20 @@ import com.zhongshu.payment.client.model.payment.CreateResponseModel;
|
|
|
import com.zhongshu.payment.client.type.JobFlowMap;
|
|
|
import com.zhongshu.payment.client.type.TransferOwner;
|
|
|
import com.zhongshu.payment.client.type.TransferType;
|
|
|
+import com.zswl.cloud.shop.client.dto.study.GoodsBuyStatistiDto;
|
|
|
+import com.zswl.cloud.shop.client.service.GoodsReserveService;
|
|
|
import com.zswl.cloud.shop.client.service.GoodsService;
|
|
|
import com.zswl.cloud.shop.client.service.ShopService;
|
|
|
+import com.zswl.cloud.shop.client.utils.DateUtils;
|
|
|
import com.zswl.cloud.shop.client.vo.life.GoodsInfoVo;
|
|
|
import com.zswl.cloud.shop.client.vo.life.ShopDetailVo;
|
|
|
+import com.zswl.cloud.shop.client.vo.study.GoodsBuyStatistiListVo;
|
|
|
import com.zswl.cloud.springBtach.server.core.service.impl.OrderServiceImpl;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -35,6 +41,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Log4j2
|
|
@@ -43,16 +51,10 @@ import java.util.List;
|
|
|
public class StudyOrderController {
|
|
|
|
|
|
@Autowired
|
|
|
- OrderServiceImpl orderServiceImp;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- GoodsService goodsService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ShopService shopService;
|
|
|
+ OrderController orderController;
|
|
|
|
|
|
@Autowired
|
|
|
- OrderController orderController;
|
|
|
+ GoodsReserveService goodsReserveService;
|
|
|
|
|
|
@SneakyThrows
|
|
|
@ApiOperation("创建订单")
|
|
@@ -62,8 +64,39 @@ public class StudyOrderController {
|
|
|
AddOrderParamModel paramModel = new AddOrderParamModel();
|
|
|
BeanUtils.copyProperties(param, paramModel);
|
|
|
List<String> goodsList = param.getGoodsList();
|
|
|
+ if (ObjectUtils.isEmpty(goodsList)) {
|
|
|
+ return ResultContent.build(ResultState.Fail, "商品ID不能为空");
|
|
|
+ }
|
|
|
// 验证研学商品可以提交不todo
|
|
|
-
|
|
|
+ GoodsBuyStatistiDto dto = new GoodsBuyStatistiDto();
|
|
|
+ // 预约时间 2024-08-28
|
|
|
+ String reserveTime = param.getReserveTime();
|
|
|
+ if (StringUtils.isEmpty(reserveTime)) {
|
|
|
+ return ResultContent.build(ResultState.Fail, "reserveTime不能为空");
|
|
|
+ }
|
|
|
+ reserveTime = reserveTime.substring(0, 10);
|
|
|
+ Date date1 = DateUtils.parseStr2Date(reserveTime, DateUtils.pattern);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date1);
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ int month = date1.getMonth() + 1;
|
|
|
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ dto.setYear(year);
|
|
|
+ dto.setMonth(month);
|
|
|
+ dto.setGoodsId(goodsList.get(0));
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<List<GoodsBuyStatistiListVo>> resultContent = goodsReserveService.goodsBuyStatistic(dto);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.build(ResultState.Fail, resultContent.getMsg());
|
|
|
+ }
|
|
|
+ List<GoodsBuyStatistiListVo> list = resultContent.getContent();
|
|
|
+ for (GoodsBuyStatistiListVo vo : list) {
|
|
|
+ if (vo.getYear() == year && vo.getMonth() == month
|
|
|
+ && vo.getDay() == day) {
|
|
|
+ if (vo.getIsOpenSeal() == null || !vo.getIsOpenSeal()) {
|
|
|
+ return ResultContent.build(ResultState.Fail, String.format("[%s]不可购买", reserveTime));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return orderController.creat(paramModel);
|
|
|
}
|
|
|
}
|