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

commit

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