提交 64f4033f authored 作者: Whispa's avatar Whispa

commit commit

上级 55f9c13d
......@@ -429,12 +429,12 @@ public class AuthController extends Controller {
try {
List<TbCfCoupon> couponVailList = couponRepository.findAllByCouponVaild(1);
//获取当前时间的时分秒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");//设置日期格式
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");//设置日期格式
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, +7);
Date time = c.getTime();
Date startDate = sdf.parse(sdf.format(new Date()));
Date endDate = sdf.parse(sdf.format(time));
Date startDate = new Date();
c.setTime(startDate);
c.add(Calendar.DATE, 7);
Date endDate = c.getTime();
for (TbCfCoupon tbCfCoupon : couponVailList) {
TbCfToicoupon toi = new TbCfToicoupon();
//把上面获取到的值,赋值到实体类中
......
......@@ -57,6 +57,7 @@ public class OrderController extends Controller {
TbCfCartRecordR record = new TbCfCartRecordR();
record.setItemNum(itemNum);
record.setItemId(item.getItemId());
record.setCartRecordId(IdUtil.createIdbyUUID());
......@@ -119,7 +120,7 @@ public class OrderController extends Controller {
}
order.getItemOrderListFromCartList(list);
order.getItemOrderListFromCartList(list,itemRepository);
return new Result<>(order);
}
......@@ -151,7 +152,7 @@ public class OrderController extends Controller {
}
order.getItemOrderListFromCartList(allByUserId);
order.getItemOrderListFromCartList(allByUserId,itemRepository);
return new Result<>(order);
......@@ -257,7 +258,7 @@ public class OrderController extends Controller {
}
order.getItemOrderListFromCartList(allByUserId);
order.getItemOrderListFromCartList(allByUserId,itemRepository);
TbCfOrder save = repository.save(order);
......@@ -385,7 +386,7 @@ public class OrderController extends Controller {
}
@GetMapping("details/{orderId}")
@GetMapping("/details/{orderId}")
public Result getOrderDetails(@PathVariable("orderId") String orderId){
Optional<TbCfOrder> optionalTbCfOrder = repository.findById(orderId);
return optionalTbCfOrder.map(order -> new Result<>(order, "Order found !")).orElseGet(() -> new Result<>(ResultCodeEnum.VALIDATE_ERROR.getCode(), "Order not found"));
......
......@@ -75,6 +75,7 @@ public class TbCfCartRecordR {
@ManyToOne
private TbCfExpressTemplate template;
/**
* 状态 0:已删除 1:加入购物车 2:直接支付(预留)
*/
......
......@@ -2,6 +2,7 @@ package com.example.afrishop_v3.models;
import com.example.afrishop_v3.base.StateConstant;
import com.example.afrishop_v3.enums.OrderStatusEnum;
import com.example.afrishop_v3.repository.TbCfStationItemRepository;
import com.example.afrishop_v3.util.IdUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
......@@ -12,10 +13,7 @@ import javax.persistence.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -219,9 +217,9 @@ public class TbCfOrder {
return itemOrderList;
}
public void getItemOrderListFromCartList(List<TbCfCartRecordR> cartList) {
public void getItemOrderListFromCartList(List<TbCfCartRecordR> cartList, TbCfStationItemRepository itemRepository) {
itemOrderList = cartList.stream().map(f -> f.getOrderItem(orderId)).collect(Collectors.toList());
doSomeCalculations();
doSomeCalculations(itemRepository);
setOrderTime(new Date());
setDealTime(new Date());
setOrderNo(String.valueOf(IdUtil.createLongIdByDate()));
......@@ -232,7 +230,7 @@ public class TbCfOrder {
this.defaultTemplate = defaultTemplate;
}
private void doSomeCalculations() {
private void doSomeCalculations(TbCfStationItemRepository itemRepository) {
itemsPrice = itemsPrice == null ? new BigDecimal(0.0) : itemsPrice;
expressCost = expressCost == null ? new BigDecimal(0.0) : expressCost;
fee = fee == null ? new BigDecimal(0.0) : fee;
......@@ -246,6 +244,16 @@ public class TbCfOrder {
System.out.println(template.getHandlingFee());
System.out.println(template.getTariff());
}
Optional<TbCfStationItem> optionalTbCfStationItem = itemRepository.findById(item.getItemId());
if( optionalTbCfStationItem.isPresent() ){
TbCfStationItem stationItem = optionalTbCfStationItem.get();
if( stationItem.getExpress() != null ){
template = stationItem.getExpress();
}
}
template = template == null ? defaultTemplate : template;
itemsPrice = itemsPrice.add(itemPrice);
tax = tax.add(calculateDutyFee(itemPrice, template));
......
......@@ -80,12 +80,12 @@ public class TbCfToicoupon {
@JsonProperty
public Date validStartTime(){
return coupon == null ? null : coupon.getValidStartTime();
return startTime;
}
@JsonProperty
public Date validEndTime(){
return coupon == null ? null : coupon.getValidEndTime();
return endTime;
}
@JsonProperty
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论