update:
1.change category attribution
This commit is contained in:
@@ -28,10 +28,13 @@ package org.springblade.modules.kiosk.pojo.entity;
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.tenant.mp.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
@@ -84,11 +87,56 @@ public class OrderDetailEntity extends TenantEntity {
|
||||
*/
|
||||
@Schema(description = "形状")
|
||||
private String shape;
|
||||
/**
|
||||
* 风格
|
||||
*/
|
||||
@Schema(description = "风格")
|
||||
private String style;
|
||||
/**
|
||||
* 快照地址
|
||||
*/
|
||||
@Schema(description = "快照地址")
|
||||
private String snapshotLink;
|
||||
/**
|
||||
* 背面打印
|
||||
*/
|
||||
@Schema(description = "背面打印")
|
||||
private String backPrint;
|
||||
/**
|
||||
* 背面打印字体
|
||||
*/
|
||||
@Schema(description = "背面打印字体")
|
||||
private String backPrintFont;
|
||||
/**
|
||||
* 背面打印尺寸
|
||||
*/
|
||||
@Schema(description = "背面打印尺寸")
|
||||
private Integer backPrintSize;
|
||||
/**
|
||||
* 背面打印粗体
|
||||
*/
|
||||
@Schema(description = "背面打印粗体")
|
||||
private Integer backPrintBold;
|
||||
/**
|
||||
* 背面打印斜体
|
||||
*/
|
||||
@Schema(description = "背面打印斜体")
|
||||
private Integer backPrintItalic;
|
||||
/**
|
||||
* 尺寸升级
|
||||
*/
|
||||
@Schema(description = "尺寸升级")
|
||||
private Integer sizeUpgrade;
|
||||
/**
|
||||
* 材质升级
|
||||
*/
|
||||
@Schema(description = "材质升级")
|
||||
private Integer materialUpgrade;
|
||||
/**
|
||||
* 支架
|
||||
*/
|
||||
@Schema(description = "支架")
|
||||
private Integer stand;
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
|
||||
@@ -62,19 +62,19 @@ public class PriceListApiVO implements Serializable {
|
||||
|
||||
private BigDecimal actualPrice;
|
||||
|
||||
private Integer backPrint;
|
||||
private Boolean backPrint;
|
||||
|
||||
private BigDecimal backPrintPrice;
|
||||
|
||||
private Integer sizeUpgrade;
|
||||
private Boolean sizeUpgrade;
|
||||
|
||||
private BigDecimal sizeUpgradePrice;
|
||||
|
||||
private Integer materialUpgrade;
|
||||
private Boolean materialUpgrade;
|
||||
|
||||
private BigDecimal materialUpgradePrice;
|
||||
|
||||
private Integer stand;
|
||||
private Boolean stand;
|
||||
|
||||
private BigDecimal standPrice;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.thymeleaf.ITemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -76,6 +77,7 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
private static final String autoCleanKey = "kiosk.default.autoCleanSeconds";
|
||||
|
||||
private static final Integer taxPercent = 15;
|
||||
private final ITemplateEngine iTemplateEngine;
|
||||
|
||||
@Override
|
||||
public List<DictBizApiVO> categoryType() {
|
||||
@@ -184,8 +186,10 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
order.setRemarks(request.getRemarks());
|
||||
orderService.save(order);
|
||||
|
||||
List<BigDecimal> totalAmount = new ArrayList<>();
|
||||
request.getData().forEach(item -> {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
for (OrderApiRequest.Item item : request.getData()) {
|
||||
BigDecimal detailAmount = BigDecimal.ZERO;
|
||||
|
||||
OrderDetailEntity orderDetail = new OrderDetailEntity();
|
||||
orderDetail.setOrderId(order.getId());
|
||||
|
||||
@@ -221,6 +225,36 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
}
|
||||
orderDetail.setShape(shapeTypeValue);
|
||||
|
||||
String styleTypeValue = dictService.getValue(styleType, String.valueOf(priceList.getStyle()));
|
||||
if (StringUtil.isBlank(styleTypeValue)) {
|
||||
throw new ServiceException("Invalid shape.");
|
||||
}
|
||||
orderDetail.setStyle(styleTypeValue);
|
||||
|
||||
if (item.getPrintBack() != null && StringUtil.isNotBlank(item.getPrintBack().getContent())) {
|
||||
orderDetail.setBackPrint(item.getPrintBack().getContent());
|
||||
orderDetail.setBackPrintFont(item.getPrintBack().getFont());
|
||||
orderDetail.setBackPrintSize(item.getPrintBack().getSize());
|
||||
orderDetail.setBackPrintBold(item.getPrintBack().getBold() ? 1 : 2);
|
||||
orderDetail.setBackPrintItalic(item.getPrintBack().getItalic() ? 1 : 2);
|
||||
detailAmount = detailAmount.add(priceList.getBackPrintPrice());
|
||||
}
|
||||
|
||||
if (item.getSizeUp()) {
|
||||
orderDetail.setSizeUpgrade(1);
|
||||
detailAmount = detailAmount.add(priceList.getSizeUpgradePrice());
|
||||
}
|
||||
|
||||
if (item.getMaterialUp()) {
|
||||
orderDetail.setMaterialUpgrade(1);
|
||||
detailAmount = detailAmount.add(priceList.getMaterialUpgradePrice());
|
||||
}
|
||||
|
||||
if (item.getExtraStand()) {
|
||||
orderDetail.setStand(1);
|
||||
detailAmount = detailAmount.add(priceList.getStandPrice());
|
||||
}
|
||||
|
||||
PhotoAttachmentEntity snapshotPhoto = photoAttachmentService.getById(item.getSnapshot());
|
||||
if (snapshotPhoto == null) {
|
||||
throw new ServiceException("Invalid snapshot.");
|
||||
@@ -228,13 +262,13 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
orderDetail.setSnapshotLink(snapshotPhoto.getLink());
|
||||
|
||||
|
||||
orderDetail.setTotalAmount(priceList.getActualPrice());
|
||||
totalAmount.add(priceList.getActualPrice());
|
||||
orderDetail.setTotalAmount(detailAmount.add(priceList.getActualPrice()));
|
||||
totalAmount = totalAmount.add(priceList.getActualPrice());
|
||||
orderDetailService.save(orderDetail);
|
||||
|
||||
item.getPhotos().forEach(photo -> photoAttachmentService.createPhotoDetail(photo, orderDetail.getId()));
|
||||
});
|
||||
order.setSubAmount(totalAmount.stream().reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
order.setSubAmount(totalAmount);
|
||||
order.setTaxPercent(BigDecimal.valueOf(taxPercent).setScale(2, RoundingMode.HALF_UP));
|
||||
order.setTaxAmount(order.getSubAmount().multiply(BigDecimal.valueOf(taxPercent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP));
|
||||
order.setTotalAmount(order.getSubAmount().add(order.getTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
||||
@@ -333,13 +367,13 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
vo.setCurrency(p.getCurrency());
|
||||
vo.setOriginalPrice(p.getOriginalPrice());
|
||||
vo.setActualPrice(p.getActualPrice());
|
||||
vo.setBackPrint(p.getBackPrint());
|
||||
vo.setBackPrint(p.getBackPrint() == 1 ? Boolean.TRUE : Boolean.FALSE);
|
||||
vo.setBackPrintPrice(p.getBackPrintPrice());
|
||||
vo.setSizeUpgrade(p.getSizeUpgrade());
|
||||
vo.setSizeUpgrade(p.getSizeUpgrade() == 1 ? Boolean.TRUE : Boolean.FALSE);
|
||||
vo.setSizeUpgradePrice(p.getSizeUpgradePrice());
|
||||
vo.setMaterialUpgrade(p.getMaterialUpgrade());
|
||||
vo.setMaterialUpgrade(p.getMaterialUpgrade() == 1 ? Boolean.TRUE : Boolean.FALSE);
|
||||
vo.setMaterialUpgradePrice(p.getMaterialUpgradePrice());
|
||||
vo.setStand(p.getStand());
|
||||
vo.setStand(p.getStand() == 1 ? Boolean.TRUE : Boolean.FALSE);
|
||||
vo.setStandPrice(p.getStandPrice());
|
||||
return vo;
|
||||
}).toList();
|
||||
|
||||
Reference in New Issue
Block a user