You've already forked FrameTour-BE
feat(printer): 添加 faceId 参数支持照片打印功能
- 在多个接口中新增 faceId 请求参数,用于关联人脸识别信息 - 修改 getUserPhotoList 方法支持按 faceId 过滤照片列表 - 更新 addUserPhoto 和 addUserPhotoFromSource 方法保存 faceId信息 - 调整 queryPrice 和 createOrder 方法支持 faceId 查询条件- 新增 listRelationByFaceId Mapper 方法实现按 faceId 查询照片 - 在 MemberPrintEntity 和 MemberPrintResp 中添加 faceId 字段- 更新数据库插入语句,添加 face_id 字段写入支持
This commit is contained in:
@@ -37,9 +37,9 @@ public class AppPrinterController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getListFor/{scenicId}")
|
@GetMapping("/getListFor/{scenicId}")
|
||||||
public ApiResponse<List<MemberPrintResp>> getListFor(@PathVariable("scenicId") Long scenicId) {
|
public ApiResponse<List<MemberPrintResp>> getListFor(@PathVariable("scenicId") Long scenicId, @RequestParam(required = false) Long faceId) {
|
||||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||||
return ApiResponse.success(printerService.getUserPhotoList(worker.getUserId(), scenicId));
|
return ApiResponse.success(printerService.getUserPhotoList(worker.getUserId(), scenicId, faceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getItem/{scenicId}/{id}")
|
@GetMapping("/getItem/{scenicId}/{id}")
|
||||||
@@ -53,24 +53,26 @@ public class AppPrinterController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/deleteFrom/{scenicId}/{id}")
|
@PostMapping("/deleteFrom/{scenicId}/{id}")
|
||||||
public ApiResponse<?> deleteFrom(@PathVariable("scenicId") Long scenicId, @PathVariable("id") Long id) throws IOException {
|
public ApiResponse<?> deleteFrom(@PathVariable("scenicId") Long scenicId, @PathVariable("id") Long id) {
|
||||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||||
printerService.deleteUserPhoto(worker.getUserId(), scenicId, id);
|
printerService.deleteUserPhoto(worker.getUserId(), scenicId, id);
|
||||||
return ApiResponse.success(null);
|
return ApiResponse.success(null);
|
||||||
}
|
}
|
||||||
@PostMapping("/uploadTo/{scenicId}")
|
@PostMapping("/uploadTo/{scenicId}")
|
||||||
public ApiResponse<?> upload(@PathVariable("scenicId") Long scenicId, @RequestParam(value = "file") MultipartFile file) throws IOException {
|
public ApiResponse<?> upload(@PathVariable("scenicId") Long scenicId,
|
||||||
|
@RequestParam(value = "file") MultipartFile file,
|
||||||
|
@RequestParam(value = "faceId", required = false) Long faceId) {
|
||||||
String[] split = file.getOriginalFilename().split("\\.");
|
String[] split = file.getOriginalFilename().split("\\.");
|
||||||
String ext = split[split.length - 1];
|
String ext = split[split.length - 1];
|
||||||
String url = StorageFactory.use().uploadFile(file, "printer", UUID.randomUUID() + "." + ext);
|
String url = StorageFactory.use().uploadFile(file, "printer", UUID.randomUUID() + "." + ext);
|
||||||
Integer id = printerService.addUserPhoto(JwtTokenUtil.getWorker().getUserId(), scenicId, url);
|
Integer id = printerService.addUserPhoto(JwtTokenUtil.getWorker().getUserId(), scenicId, url, faceId);
|
||||||
return ApiResponse.success(id);
|
return ApiResponse.success(id);
|
||||||
}
|
}
|
||||||
@PostMapping(value = "/uploadTo/{scenicId}/cropped/{id}", consumes = "multipart/form-data")
|
@PostMapping(value = "/uploadTo/{scenicId}/cropped/{id}", consumes = "multipart/form-data")
|
||||||
public ApiResponse<?> uploadReplace(@PathVariable("scenicId") Long scenicId,
|
public ApiResponse<?> uploadReplace(@PathVariable("scenicId") Long scenicId,
|
||||||
@PathVariable("id") Long id,
|
@PathVariable("id") Long id,
|
||||||
@RequestPart(value = "crop", required = false) String crop,
|
@RequestPart(value = "crop", required = false) String crop,
|
||||||
@RequestPart(value = "file") MultipartFile file) throws IOException {
|
@RequestPart(value = "file") MultipartFile file) {
|
||||||
String[] split = file.getOriginalFilename().split("\\.");
|
String[] split = file.getOriginalFilename().split("\\.");
|
||||||
String ext = split[split.length - 1];
|
String ext = split[split.length - 1];
|
||||||
String url = StorageFactory.use().uploadFile(file, "printer", UUID.randomUUID() + "." + ext);
|
String url = StorageFactory.use().uploadFile(file, "printer", UUID.randomUUID() + "." + ext);
|
||||||
@@ -78,8 +80,10 @@ public class AppPrinterController {
|
|||||||
return ApiResponse.success(url);
|
return ApiResponse.success(url);
|
||||||
}
|
}
|
||||||
@PostMapping("/uploadTo/{scenicId}/formSource")
|
@PostMapping("/uploadTo/{scenicId}/formSource")
|
||||||
public ApiResponse<?> uploadFromSource(@PathVariable("scenicId") Long scenicId, @RequestBody FromSourceReq req) throws IOException {
|
public ApiResponse<?> uploadFromSource(@PathVariable("scenicId") Long scenicId,
|
||||||
List<Integer> list = printerService.addUserPhotoFromSource(JwtTokenUtil.getWorker().getUserId(), scenicId, req);
|
@RequestBody FromSourceReq req,
|
||||||
|
@RequestParam(value = "faceId", required = false) Long faceId) {
|
||||||
|
List<Integer> list = printerService.addUserPhotoFromSource(JwtTokenUtil.getWorker().getUserId(), scenicId, req, faceId);
|
||||||
return ApiResponse.success(list);
|
return ApiResponse.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,16 +99,20 @@ public class AppPrinterController {
|
|||||||
return ApiResponse.success(null);
|
return ApiResponse.success(null);
|
||||||
}
|
}
|
||||||
@GetMapping("/price/{scenicId}")
|
@GetMapping("/price/{scenicId}")
|
||||||
public ApiResponse<?> queryPrice(@PathVariable("scenicId") Long scenicId) {
|
public ApiResponse<?> queryPrice(@PathVariable("scenicId") Long scenicId,
|
||||||
return ApiResponse.success(printerService.queryPrice(JwtTokenUtil.getWorker().getUserId(), scenicId));
|
@RequestParam(value = "faceId", required = false) Long faceId) {
|
||||||
|
return ApiResponse.success(printerService.queryPrice(JwtTokenUtil.getWorker().getUserId(), scenicId, faceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/order/{scenicId}")
|
@PostMapping("/order/{scenicId}")
|
||||||
public ApiResponse<Map<String, Object>> createOrder(@PathVariable("scenicId") Long scenicId) {
|
public ApiResponse<Map<String, Object>> createOrder(@PathVariable("scenicId") Long scenicId,
|
||||||
return ApiResponse.success(printerService.createOrder(JwtTokenUtil.getWorker().getUserId(), scenicId, null));
|
@RequestParam(value = "faceId", required = false) Long faceId) {
|
||||||
|
return ApiResponse.success(printerService.createOrder(JwtTokenUtil.getWorker().getUserId(), scenicId, null, faceId));
|
||||||
}
|
}
|
||||||
@PostMapping("/order/{scenicId}/toPrinter/{printerId}")
|
@PostMapping("/order/{scenicId}/toPrinter/{printerId}")
|
||||||
public ApiResponse<Map<String, Object>> createOrderToPrinter(@PathVariable("scenicId") Long scenicId, @PathVariable("printerId") Integer printerId) {
|
public ApiResponse<Map<String, Object>> createOrderToPrinter(@PathVariable("scenicId") Long scenicId,
|
||||||
return ApiResponse.success(printerService.createOrder(JwtTokenUtil.getWorker().getUserId(), scenicId, printerId));
|
@PathVariable("printerId") Integer printerId,
|
||||||
|
@RequestParam(value = "faceId", required = false) Long faceId) {
|
||||||
|
return ApiResponse.success(printerService.createOrder(JwtTokenUtil.getWorker().getUserId(), scenicId, printerId, faceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public interface PrinterMapper {
|
|||||||
List<PrinterResp> listByScenicId(@Param("scenicId") Long scenicId);
|
List<PrinterResp> listByScenicId(@Param("scenicId") Long scenicId);
|
||||||
|
|
||||||
List<MemberPrintResp> listRelation(@Param("memberId") Long memberId, @Param("scenicId") Long scenicId);
|
List<MemberPrintResp> listRelation(@Param("memberId") Long memberId, @Param("scenicId") Long scenicId);
|
||||||
|
List<MemberPrintResp> listRelationByFaceId(Long memberId, Long scenicId, Long faceId);
|
||||||
|
|
||||||
int deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
|
int deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class MemberPrintEntity {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
private Long scenicId;
|
private Long scenicId;
|
||||||
private Long memberId;
|
private Long memberId;
|
||||||
|
private Long faceId;
|
||||||
private String origUrl;
|
private String origUrl;
|
||||||
private String cropUrl;
|
private String cropUrl;
|
||||||
private String printUrl;
|
private String printUrl;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class MemberPrintResp {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
private Long scenicId;
|
private Long scenicId;
|
||||||
private String scenicName;
|
private String scenicName;
|
||||||
|
private Long faceId;
|
||||||
private Long memberId;
|
private Long memberId;
|
||||||
private String origUrl;
|
private String origUrl;
|
||||||
private String cropUrl;
|
private String cropUrl;
|
||||||
|
|||||||
@@ -1239,7 +1239,7 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
// 10. 批量添加到打印列表
|
// 10. 批量添加到打印列表
|
||||||
for (SourceEntity source : sourcesToAdd) {
|
for (SourceEntity source : sourcesToAdd) {
|
||||||
try {
|
try {
|
||||||
printerService.addUserPhoto(memberId, scenicId, source.getUrl());
|
printerService.addUserPhoto(memberId, scenicId, source.getUrl(), faceId);
|
||||||
totalAdded++;
|
totalAdded++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("添加照片到打印列表失败: sourceId={}, url={}, error={}",
|
log.warn("添加照片到打印列表失败: sourceId={}, url={}, error={}",
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ public interface PrinterService {
|
|||||||
|
|
||||||
void taskFail(Integer taskId, WorkerAuthReqVo req);
|
void taskFail(Integer taskId, WorkerAuthReqVo req);
|
||||||
|
|
||||||
List<MemberPrintResp> getUserPhotoList(Long userId, Long scenicId);
|
List<MemberPrintResp> getUserPhotoList(Long userId, Long scenicId, Long faceId);
|
||||||
|
|
||||||
List<MemberPrintResp> getUserPhotoListByOrderId(Long orderId);
|
List<MemberPrintResp> getUserPhotoListByOrderId(Long orderId);
|
||||||
|
|
||||||
boolean deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
|
boolean deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
|
||||||
|
|
||||||
Integer addUserPhoto(Long memberId, Long scenicId, String url);
|
Integer addUserPhoto(Long memberId, Long scenicId, String url, Long faceId);
|
||||||
|
|
||||||
MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id);
|
MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id);
|
||||||
|
|
||||||
@@ -46,11 +46,11 @@ public interface PrinterService {
|
|||||||
|
|
||||||
int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity);
|
int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity);
|
||||||
|
|
||||||
PriceObj queryPrice(Long memberId, Long scenicId);
|
PriceObj queryPrice(Long memberId, Long scenicId, Long faceId);
|
||||||
|
|
||||||
List<Integer> addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req);
|
List<Integer> addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req, Long faceId);
|
||||||
|
|
||||||
Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId);
|
Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId, Long faceId);
|
||||||
|
|
||||||
void batchSetUserPhotoListToPrinter(Long memberId, Long scenicId, Integer printerId);
|
void batchSetUserPhotoListToPrinter(Long memberId, Long scenicId, Integer printerId);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.ycwl.basic.exception.BaseException;
|
|||||||
import com.ycwl.basic.image.watermark.ImageWatermarkFactory;
|
import com.ycwl.basic.image.watermark.ImageWatermarkFactory;
|
||||||
import com.ycwl.basic.image.watermark.entity.WatermarkInfo;
|
import com.ycwl.basic.image.watermark.entity.WatermarkInfo;
|
||||||
import com.ycwl.basic.image.watermark.enums.ImageWatermarkOperatorEnum;
|
import com.ycwl.basic.image.watermark.enums.ImageWatermarkOperatorEnum;
|
||||||
import com.ycwl.basic.image.watermark.exception.ImageWatermarkException;
|
|
||||||
import com.ycwl.basic.image.watermark.operator.IOperator;
|
import com.ycwl.basic.image.watermark.operator.IOperator;
|
||||||
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
||||||
import com.ycwl.basic.mapper.MemberMapper;
|
import com.ycwl.basic.mapper.MemberMapper;
|
||||||
@@ -21,7 +20,6 @@ import com.ycwl.basic.model.mobile.order.PriceObj;
|
|||||||
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
|
import com.ycwl.basic.model.pc.member.resp.MemberRespVO;
|
||||||
import com.ycwl.basic.model.pc.order.entity.OrderEntity;
|
import com.ycwl.basic.model.pc.order.entity.OrderEntity;
|
||||||
import com.ycwl.basic.model.pc.order.entity.OrderItemEntity;
|
import com.ycwl.basic.model.pc.order.entity.OrderItemEntity;
|
||||||
import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity;
|
|
||||||
import com.ycwl.basic.pricing.dto.PriceCalculationRequest;
|
import com.ycwl.basic.pricing.dto.PriceCalculationRequest;
|
||||||
import com.ycwl.basic.pricing.dto.PriceCalculationResult;
|
import com.ycwl.basic.pricing.dto.PriceCalculationResult;
|
||||||
import com.ycwl.basic.pricing.dto.ProductItem;
|
import com.ycwl.basic.pricing.dto.ProductItem;
|
||||||
@@ -38,7 +36,6 @@ import com.ycwl.basic.model.printer.req.PrinterSyncReq;
|
|||||||
import com.ycwl.basic.model.printer.req.WorkerAuthReqVo;
|
import com.ycwl.basic.model.printer.req.WorkerAuthReqVo;
|
||||||
import com.ycwl.basic.model.printer.resp.PrintTaskResp;
|
import com.ycwl.basic.model.printer.resp.PrintTaskResp;
|
||||||
import com.ycwl.basic.model.wx.WXPayOrderReqVO;
|
import com.ycwl.basic.model.wx.WXPayOrderReqVO;
|
||||||
import com.ycwl.basic.repository.PriceRepository;
|
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.service.mobile.WxPayService;
|
import com.ycwl.basic.service.mobile.WxPayService;
|
||||||
import com.ycwl.basic.service.printer.PrinterService;
|
import com.ycwl.basic.service.printer.PrinterService;
|
||||||
@@ -216,11 +213,14 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MemberPrintResp> getUserPhotoList(Long userId, Long scenicId) {
|
public List<MemberPrintResp> getUserPhotoList(Long userId, Long scenicId, Long faceId) {
|
||||||
List<MemberPrintResp> list = printerMapper.listRelation(userId, scenicId);
|
if (faceId != null) {
|
||||||
if (list.isEmpty()) {
|
List<MemberPrintResp> list = printerMapper.listRelation(userId, scenicId);
|
||||||
// 额外逻辑
|
return list.stream()
|
||||||
|
.filter(item -> Objects.nonNull(item.getFaceId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
List<MemberPrintResp> list = printerMapper.listRelationByFaceId(userId, scenicId, faceId);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,10 +236,11 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer addUserPhoto(Long memberId, Long scenicId, String url) {
|
public Integer addUserPhoto(Long memberId, Long scenicId, String url, Long faceId) {
|
||||||
MemberPrintEntity entity = new MemberPrintEntity();
|
MemberPrintEntity entity = new MemberPrintEntity();
|
||||||
entity.setMemberId(memberId);
|
entity.setMemberId(memberId);
|
||||||
entity.setScenicId(scenicId);
|
entity.setScenicId(scenicId);
|
||||||
|
entity.setFaceId(faceId);
|
||||||
entity.setOrigUrl(url);
|
entity.setOrigUrl(url);
|
||||||
|
|
||||||
// 获取打印尺寸
|
// 获取打印尺寸
|
||||||
@@ -314,31 +315,30 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PriceObj queryPrice(Long memberId, Long scenicId) {
|
public PriceObj queryPrice(Long memberId, Long scenicId, Long faceId) {
|
||||||
List<MemberPrintResp> userPhotoList = getUserPhotoList(memberId, scenicId);
|
List<MemberPrintResp> userPhotoList = getUserPhotoList(memberId, scenicId, faceId);
|
||||||
|
|
||||||
// 计算照片总数量
|
// 计算照片总数量
|
||||||
long count = userPhotoList.stream()
|
long count = userPhotoList.stream()
|
||||||
.filter(item -> Objects.nonNull(item.getQuantity()))
|
.filter(item -> Objects.nonNull(item.getQuantity()))
|
||||||
.mapToInt(MemberPrintResp::getQuantity)
|
.mapToInt(MemberPrintResp::getQuantity)
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
PriceObj obj = new PriceObj();
|
PriceObj obj = new PriceObj();
|
||||||
|
obj.setScenicId(scenicId);
|
||||||
|
obj.setGoodsId(faceId);
|
||||||
|
obj.setFaceId(faceId);
|
||||||
|
obj.setGoodsType(3);
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
// 如果没有照片,返回零价格
|
// 如果没有照片,返回零价格
|
||||||
obj.setPrice(BigDecimal.ZERO);
|
obj.setPrice(BigDecimal.ZERO);
|
||||||
obj.setSlashPrice(BigDecimal.ZERO);
|
obj.setSlashPrice(BigDecimal.ZERO);
|
||||||
obj.setGoodsType(3);
|
|
||||||
obj.setFree(false);
|
obj.setFree(false);
|
||||||
obj.setScenicId(scenicId);
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建价格计算请求
|
// 构建价格计算请求
|
||||||
PriceCalculationRequest request = new PriceCalculationRequest();
|
PriceCalculationRequest request = new PriceCalculationRequest();
|
||||||
request.setUserId(memberId);
|
request.setUserId(memberId);
|
||||||
request.setScenicId(scenicId);
|
|
||||||
|
|
||||||
// 创建照片打印商品项
|
// 创建照片打印商品项
|
||||||
ProductItem photoItem = new ProductItem();
|
ProductItem photoItem = new ProductItem();
|
||||||
photoItem.setProductType(ProductType.PHOTO_PRINT);
|
photoItem.setProductType(ProductType.PHOTO_PRINT);
|
||||||
@@ -346,24 +346,22 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
photoItem.setQuantity(Long.valueOf(count).intValue());
|
photoItem.setQuantity(Long.valueOf(count).intValue());
|
||||||
photoItem.setPurchaseCount(1);
|
photoItem.setPurchaseCount(1);
|
||||||
photoItem.setScenicId(scenicId.toString());
|
photoItem.setScenicId(scenicId.toString());
|
||||||
|
|
||||||
request.setProducts(Collections.singletonList(photoItem));
|
request.setProducts(Collections.singletonList(photoItem));
|
||||||
|
|
||||||
// 使用统一价格计算服务
|
// 使用统一价格计算服务
|
||||||
PriceCalculationResult result = priceCalculationService.calculatePrice(request);
|
PriceCalculationResult result = priceCalculationService.calculatePrice(request);
|
||||||
|
|
||||||
// 转换为原有的 PriceObj 格式
|
// 转换为原有的 PriceObj 格式
|
||||||
obj.setPrice(result.getFinalAmount());
|
obj.setPrice(result.getFinalAmount());
|
||||||
obj.setSlashPrice(result.getOriginalAmount());
|
obj.setSlashPrice(result.getOriginalAmount());
|
||||||
obj.setGoodsType(3);
|
|
||||||
obj.setFree(result.getFinalAmount().compareTo(BigDecimal.ZERO) == 0);
|
obj.setFree(result.getFinalAmount().compareTo(BigDecimal.ZERO) == 0);
|
||||||
obj.setScenicId(scenicId);
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req) {
|
public List<Integer> addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req, Long faceId) {
|
||||||
List<Integer> resultIds = new ArrayList<>();
|
List<Integer> resultIds = new ArrayList<>();
|
||||||
req.getIds().forEach(id -> {
|
req.getIds().forEach(id -> {
|
||||||
SourceRespVO byId = sourceMapper.getById(id);
|
SourceRespVO byId = sourceMapper.getById(id);
|
||||||
@@ -374,10 +372,11 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
MemberPrintEntity entity = new MemberPrintEntity();
|
MemberPrintEntity entity = new MemberPrintEntity();
|
||||||
entity.setMemberId(memberId);
|
entity.setMemberId(memberId);
|
||||||
entity.setScenicId(scenicId);
|
entity.setScenicId(scenicId);
|
||||||
|
entity.setFaceId(faceId);
|
||||||
entity.setOrigUrl(byId.getUrl());
|
entity.setOrigUrl(byId.getUrl());
|
||||||
entity.setCropUrl(byId.getUrl());
|
entity.setCropUrl(byId.getUrl());
|
||||||
entity.setStatus(0);
|
entity.setStatus(0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int rows = printerMapper.addUserPhoto(entity);
|
int rows = printerMapper.addUserPhoto(entity);
|
||||||
if (rows > 0 && entity.getId() != null) {
|
if (rows > 0 && entity.getId() != null) {
|
||||||
@@ -394,7 +393,7 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId) {
|
public Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId, Long faceId) {
|
||||||
if (printerId == null) {
|
if (printerId == null) {
|
||||||
List<PrinterResp> printerList = printerMapper.listByScenicId(scenicId);
|
List<PrinterResp> printerList = printerMapper.listByScenicId(scenicId);
|
||||||
if (printerList.size() != 1) {
|
if (printerList.size() != 1) {
|
||||||
@@ -415,7 +414,7 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 验证照片数量
|
// 验证照片数量
|
||||||
List<MemberPrintResp> userPhotoList = getUserPhotoList(memberId, scenicId);
|
List<MemberPrintResp> userPhotoList = getUserPhotoList(memberId, scenicId, faceId);
|
||||||
long count = userPhotoList.stream().filter(item -> Objects.nonNull(item.getQuantity())).mapToInt(MemberPrintResp::getQuantity).sum();
|
long count = userPhotoList.stream().filter(item -> Objects.nonNull(item.getQuantity())).mapToInt(MemberPrintResp::getQuantity).sum();
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
throw new BaseException("没有可打印的照片");
|
throw new BaseException("没有可打印的照片");
|
||||||
@@ -425,13 +424,12 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
Long orderId = SnowFlakeUtil.getLongId();
|
Long orderId = SnowFlakeUtil.getLongId();
|
||||||
order.setId(orderId);
|
order.setId(orderId);
|
||||||
order.setMemberId(memberId);
|
order.setMemberId(memberId);
|
||||||
|
order.setFaceId(faceId);
|
||||||
MemberRespVO member = memberMapper.getById(memberId);
|
MemberRespVO member = memberMapper.getById(memberId);
|
||||||
order.setOpenId(member.getOpenId());
|
order.setOpenId(member.getOpenId());
|
||||||
order.setScenicId(scenicId);
|
order.setScenicId(scenicId);
|
||||||
order.setType(3); // 照片打印类型
|
order.setType(3); // 照片打印类型
|
||||||
batchSetUserPhotoListToPrinter(memberId, scenicId, printerId);
|
batchSetUserPhotoListToPrinter(memberId, scenicId, printerId);
|
||||||
// 重新获取照片列表(包含打印机信息)
|
|
||||||
userPhotoList = getUserPhotoList(memberId, scenicId);
|
|
||||||
List<OrderItemEntity> orderItems = userPhotoList.stream().map(goods -> {
|
List<OrderItemEntity> orderItems = userPhotoList.stream().map(goods -> {
|
||||||
OrderItemEntity orderItem = new OrderItemEntity();
|
OrderItemEntity orderItem = new OrderItemEntity();
|
||||||
orderItem.setOrderId(orderId);
|
orderItem.setOrderId(orderId);
|
||||||
@@ -462,7 +460,7 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
order.setPrice(priceResult.getFinalAmount());
|
order.setPrice(priceResult.getFinalAmount());
|
||||||
order.setSlashPrice(priceResult.getOriginalAmount());
|
order.setSlashPrice(priceResult.getOriginalAmount());
|
||||||
order.setPayPrice(priceResult.getFinalAmount());
|
order.setPayPrice(priceResult.getFinalAmount());
|
||||||
// order.setFaceId();
|
order.setFaceId(faceId);
|
||||||
if (order.getPayPrice().equals(BigDecimal.ZERO)) {
|
if (order.getPayPrice().equals(BigDecimal.ZERO)) {
|
||||||
order.setStatus(OrderStateEnum.PAID.getState());
|
order.setStatus(OrderStateEnum.PAID.getState());
|
||||||
order.setPayAt(new Date());
|
order.setPayAt(new Date());
|
||||||
|
|||||||
@@ -42,6 +42,11 @@
|
|||||||
FROM member_print p
|
FROM member_print p
|
||||||
WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} AND p.status = 0
|
WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} AND p.status = 0
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listRelationByFaceId" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
||||||
|
SELECT p.*
|
||||||
|
FROM member_print p
|
||||||
|
WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} AND p.face_id = #{faceId} AND p.status = 0
|
||||||
|
</select>
|
||||||
<select id="getUserPhoto" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
<select id="getUserPhoto" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
||||||
SELECT p.*
|
SELECT p.*
|
||||||
FROM member_print p
|
FROM member_print p
|
||||||
@@ -96,6 +101,7 @@
|
|||||||
INSERT INTO member_print (
|
INSERT INTO member_print (
|
||||||
member_id,
|
member_id,
|
||||||
scenic_id,
|
scenic_id,
|
||||||
|
face_id,
|
||||||
orig_url,
|
orig_url,
|
||||||
crop_url,
|
crop_url,
|
||||||
quantity,
|
quantity,
|
||||||
@@ -105,6 +111,7 @@
|
|||||||
) VALUES (
|
) VALUES (
|
||||||
#{memberId},
|
#{memberId},
|
||||||
#{scenicId},
|
#{scenicId},
|
||||||
|
#{faceId},
|
||||||
#{origUrl},
|
#{origUrl},
|
||||||
#{cropUrl},
|
#{cropUrl},
|
||||||
1,
|
1,
|
||||||
|
|||||||
Reference in New Issue
Block a user