提交 85e2e979 authored 作者: Whispa's avatar Whispa

commit

上级 ec7aa83a
...@@ -170,6 +170,16 @@ public class CartController extends Controller { ...@@ -170,6 +170,16 @@ public class CartController extends Controller {
if (expressTemplate != null) { if (expressTemplate != null) {
tbCfItemDetail.setItemCategory(expressTemplate.getTemplateId()); tbCfItemDetail.setItemCategory(expressTemplate.getTemplateId());
tbCfItemDetail.setTemplate(expressTemplate); tbCfItemDetail.setTemplate(expressTemplate);
}else{
// For crawling products
Optional<TbCfExpressTemplate> templateOptional = templateRepository.findFirstByIsDefault(1);
if ( templateOptional.isPresent() ){
TbCfExpressTemplate template = templateOptional.get();
tbCfItemDetail.setItemCategory(template.getTemplateId());
tbCfItemDetail.setTemplate(template);
}
} }
//} //}
} }
......
...@@ -36,14 +36,16 @@ public class OrderController extends Controller { ...@@ -36,14 +36,16 @@ public class OrderController extends Controller {
private final TbCfToicouponRepository toicouponRepository; private final TbCfToicouponRepository toicouponRepository;
private final TbCfStationItemRepository itemRepository; private final TbCfStationItemRepository itemRepository;
private final TbCfItemCommentRepository commentRepository; private final TbCfItemCommentRepository commentRepository;
private final TbCfExpressTemplateRepository templateRepository;
private final AuthenticationUser user; private final AuthenticationUser user;
public OrderController(TbCfOrderRepository repository, TbCfCartRecordRRepository cartRepository, TbCfToicouponRepository toicouponRepository, TbCfStationItemRepository itemRepository, TbCfItemCommentRepository commentRepository, AuthenticationUser user) { public OrderController(TbCfOrderRepository repository, TbCfCartRecordRRepository cartRepository, TbCfToicouponRepository toicouponRepository, TbCfStationItemRepository itemRepository, TbCfItemCommentRepository commentRepository, TbCfExpressTemplateRepository templateRepository, AuthenticationUser user) {
this.repository = repository; this.repository = repository;
this.cartRepository = cartRepository; this.cartRepository = cartRepository;
this.toicouponRepository = toicouponRepository; this.toicouponRepository = toicouponRepository;
this.itemRepository = itemRepository; this.itemRepository = itemRepository;
this.commentRepository = commentRepository; this.commentRepository = commentRepository;
this.templateRepository = templateRepository;
this.user = user; this.user = user;
} }
...@@ -72,6 +74,9 @@ public class OrderController extends Controller { ...@@ -72,6 +74,9 @@ public class OrderController extends Controller {
@RequestParam(value = "toitableId", required = false) String toitableId) { @RequestParam(value = "toitableId", required = false) String toitableId) {
TbCfOrder order = new TbCfOrder(); TbCfOrder order = new TbCfOrder();
Optional<TbCfExpressTemplate> templateOptional = templateRepository.findFirstByIsDefault(1);
templateOptional.ifPresent(order::setDefaultTemplate);
if (StringUtils.isBlank(itemId) || itemNum == null || itemNum <= 0 || itemPrice == null || itemPrice <= 0) if (StringUtils.isBlank(itemId) || itemNum == null || itemNum <= 0 || itemPrice == null || itemPrice <= 0)
return new Result<>(ResultCodeEnum.SERVICE_ERROR.getCode(), "Missing information !"); return new Result<>(ResultCodeEnum.SERVICE_ERROR.getCode(), "Missing information !");
...@@ -114,6 +119,8 @@ public class OrderController extends Controller { ...@@ -114,6 +119,8 @@ public class OrderController extends Controller {
TbCfOrder order = new TbCfOrder(); TbCfOrder order = new TbCfOrder();
Optional<TbCfExpressTemplate> templateOptional = templateRepository.findFirstByIsDefault(1);
templateOptional.ifPresent(order::setDefaultTemplate);
order.setCouponId(toitableId); order.setCouponId(toitableId);
...@@ -184,6 +191,10 @@ public class OrderController extends Controller { ...@@ -184,6 +191,10 @@ public class OrderController extends Controller {
TbCfOrder order = new TbCfOrder(); TbCfOrder order = new TbCfOrder();
Optional<TbCfExpressTemplate> templateOptional = templateRepository.findFirstByIsDefault(1);
templateOptional.ifPresent(order::setDefaultTemplate);
order.setOrderId(IdUtil.createIdbyUUID()); order.setOrderId(IdUtil.createIdbyUUID());
......
...@@ -149,6 +149,8 @@ public class TbCfOrder { ...@@ -149,6 +149,8 @@ public class TbCfOrder {
*/ */
private String remarkInfo; private String remarkInfo;
private TbCfExpressTemplate defaultTemplate;
public TbCfOrder() { public TbCfOrder() {
this.orderStatus = OrderStatusEnum.PENDING_PAY.getValue(); this.orderStatus = OrderStatusEnum.PENDING_PAY.getValue();
this.enableFlag = StateConstant.VALID; this.enableFlag = StateConstant.VALID;
...@@ -202,6 +204,11 @@ public class TbCfOrder { ...@@ -202,6 +204,11 @@ public class TbCfOrder {
setOrderNo(String.valueOf(IdUtil.createLongIdByDate())); setOrderNo(String.valueOf(IdUtil.createLongIdByDate()));
} }
public void setDefaultTemplate(TbCfExpressTemplate defaultTemplate) {
this.defaultTemplate = defaultTemplate;
}
private void doSomeCalculations() { private void doSomeCalculations() {
itemsPrice = itemsPrice == null ? new BigDecimal(0.0) : itemsPrice; itemsPrice = itemsPrice == null ? new BigDecimal(0.0) : itemsPrice;
expressCost = expressCost == null ? new BigDecimal(0.0) : expressCost; expressCost = expressCost == null ? new BigDecimal(0.0) : expressCost;
...@@ -212,6 +219,7 @@ public class TbCfOrder { ...@@ -212,6 +219,7 @@ public class TbCfOrder {
itemOrderList.forEach(item -> { itemOrderList.forEach(item -> {
BigDecimal itemPrice = item.getItemPriceTotal(); BigDecimal itemPrice = item.getItemPriceTotal();
TbCfExpressTemplate template = item.getTemplate(); TbCfExpressTemplate template = item.getTemplate();
template = template == null ? defaultTemplate : template;
itemsPrice = itemsPrice.add(itemPrice); itemsPrice = itemsPrice.add(itemPrice);
tax = tax.add(calculateDutyFee(itemPrice, template)); tax = tax.add(calculateDutyFee(itemPrice, template));
fee = fee.add(calculateHandlingFee(itemPrice, template)); fee = fee.add(calculateHandlingFee(itemPrice, template));
......
...@@ -6,12 +6,13 @@ import org.springframework.data.repository.PagingAndSortingRepository; ...@@ -6,12 +6,13 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
import java.util.Optional;
public interface TbCfExpressTemplateRepository extends PagingAndSortingRepository<TbCfExpressTemplate,String> { public interface TbCfExpressTemplateRepository extends PagingAndSortingRepository<TbCfExpressTemplate,String> {
@Query(value = "select distinct t2 from TbCfExpTemKeyword t1 left join #{#entityName} t2 on t1.templateId=t2.templateId" + @Query(value = "select distinct t2 from TbCfExpTemKeyword t1 left join #{#entityName} t2 on t1.templateId=t2.templateId" +
" where t1.keyword LIKE concat('%',:keyword,'%') or t1.enkeyword LIKE concat('%',:keyword,'%')") " where t1.keyword LIKE concat('%',:keyword,'%') or t1.enkeyword LIKE concat('%',:keyword,'%')")
List<TbCfExpressTemplate> getTemplateByKeyword(@Param("keyword") String keyword); List<TbCfExpressTemplate> getTemplateByKeyword(@Param("keyword") String keyword);
TbCfExpressTemplate findFirstByOrderByTemplateIdAsc(); Optional<TbCfExpressTemplate> findFirstByIsDefault(Integer isDefault);
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论