照片打印

This commit is contained in:
2025-05-22 10:43:26 +08:00
parent 9b00b34a68
commit 937c2b33d3
12 changed files with 306 additions and 7 deletions

View File

@ -32,8 +32,10 @@ import com.ycwl.basic.repository.SourceRepository;
import com.ycwl.basic.repository.TemplateRepository; import com.ycwl.basic.repository.TemplateRepository;
import com.ycwl.basic.repository.VideoRepository; import com.ycwl.basic.repository.VideoRepository;
import com.ycwl.basic.repository.VideoTaskRepository; import com.ycwl.basic.repository.VideoTaskRepository;
import com.ycwl.basic.service.printer.PrinterService;
import com.ycwl.basic.utils.ApiResponse; import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -74,6 +76,9 @@ public class OrderBiz {
private BrokerBiz brokerBiz; private BrokerBiz brokerBiz;
@Autowired @Autowired
private CouponBiz couponBiz; private CouponBiz couponBiz;
@Autowired
@Lazy
private PrinterService printerService;
public PriceObj queryPrice(Long scenicId, int goodsType, Long goodsId) { public PriceObj queryPrice(Long scenicId, int goodsType, Long goodsId) {
PriceObj priceObj = new PriceObj(); PriceObj priceObj = new PriceObj();
@ -237,6 +242,8 @@ public class OrderBiz {
case 1: // 视频原素材 case 1: // 视频原素材
case 2: // 照片原素材 case 2: // 照片原素材
sourceRepository.setUserIsBuyItem(order.getMemberId(), item.getGoodsType(), item.getGoodsId(), order.getId()); sourceRepository.setUserIsBuyItem(order.getMemberId(), item.getGoodsType(), item.getGoodsId(), order.getId());
case 3:
printerService.setUserIsBuyItem(order.getMemberId(), item.getGoodsId(), order.getId());
} }
}); });
orderRepository.clearOrderCache(orderId); // 更新完了,清理下 orderRepository.clearOrderCache(orderId); // 更新完了,清理下

View File

@ -3,6 +3,7 @@ package com.ycwl.basic.controller.mobile;
import com.ycwl.basic.annotation.IgnoreToken; import com.ycwl.basic.annotation.IgnoreToken;
import com.ycwl.basic.model.jwt.JwtInfo; import com.ycwl.basic.model.jwt.JwtInfo;
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp; import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
import com.ycwl.basic.model.printer.req.FromSourceReq;
import com.ycwl.basic.service.printer.PrinterService; import com.ycwl.basic.service.printer.PrinterService;
import com.ycwl.basic.storage.StorageFactory; import com.ycwl.basic.storage.StorageFactory;
import com.ycwl.basic.utils.ApiResponse; import com.ycwl.basic.utils.ApiResponse;
@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -18,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
@RestController @RestController
@ -69,6 +72,12 @@ public class AppPrinterController {
printerService.setPhotoCropped(JwtTokenUtil.getWorker().getUserId(), scenicId, id, url); printerService.setPhotoCropped(JwtTokenUtil.getWorker().getUserId(), scenicId, id, url);
return ApiResponse.success(url); return ApiResponse.success(url);
} }
@PostMapping("/uploadTo/{scenicId}/formSource")
public ApiResponse<?> uploadFromSource(@PathVariable("scenicId") Long scenicId, @RequestBody FromSourceReq req) throws IOException {
printerService.addUserPhotoFromSource(JwtTokenUtil.getWorker().getUserId(), scenicId, req);
return ApiResponse.success(null);
}
@PostMapping("/setQuantity/{scenicId}/{id}") @PostMapping("/setQuantity/{scenicId}/{id}")
public ApiResponse<?> setQuantity(@PathVariable("scenicId") Long scenicId, @PathVariable("id") Long id, @RequestParam("quantity") Integer quantity) { public ApiResponse<?> setQuantity(@PathVariable("scenicId") Long scenicId, @PathVariable("id") Long id, @RequestParam("quantity") Integer quantity) {
if (quantity == null) { if (quantity == null) {
@ -84,4 +93,13 @@ public class AppPrinterController {
public ApiResponse<?> queryPrice(@PathVariable("scenicId") Long scenicId) { public ApiResponse<?> queryPrice(@PathVariable("scenicId") Long scenicId) {
return ApiResponse.success(printerService.queryPrice(JwtTokenUtil.getWorker().getUserId(), scenicId)); return ApiResponse.success(printerService.queryPrice(JwtTokenUtil.getWorker().getUserId(), scenicId));
} }
@PostMapping("/order/{scenicId}")
public ApiResponse<Map<String, Object>> createOrder(@PathVariable("scenicId") Long scenicId) {
return ApiResponse.success(printerService.createOrder(JwtTokenUtil.getWorker().getUserId(), scenicId, null));
}
@PostMapping("/order/{scenicId}/toPrinter/{printerId}")
public ApiResponse<Map<String, Object>> createOrderToPrinter(@PathVariable("scenicId") Long scenicId, @PathVariable("printerId") Integer printerId) {
return ApiResponse.success(printerService.createOrder(JwtTokenUtil.getWorker().getUserId(), scenicId, printerId));
}
} }

View File

@ -0,0 +1,10 @@
package com.ycwl.basic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PrintTaskMapper extends BaseMapper<PrintTaskEntity> {
int insertTask(PrintTaskEntity entity);
}

View File

@ -42,4 +42,12 @@ public interface PrinterMapper {
int setPhotoCropped(Long memberId, Long scenicId, Long id, String url); int setPhotoCropped(Long memberId, Long scenicId, Long id, String url);
int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity); int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity);
List<MemberPrintResp> getUserPhotoByIds(List<Long> ids);
int setUserIsBuyItem(Long memberId, Long id, Long orderId);
void updateUserPhotoListToPrinter(Long memberId, Long scenicId, Integer printerId);
List<MemberPrintResp> listRelationByOrderId(Long orderId);
} }

View File

@ -13,6 +13,7 @@ public class MemberPrintResp {
private String origUrl; private String origUrl;
private String cropUrl; private String cropUrl;
private Integer quantity; private Integer quantity;
private Integer printerId;
private Long orderId; private Long orderId;
private Integer status; private Integer status;
private Date createTime; private Date createTime;

View File

@ -0,0 +1,10 @@
package com.ycwl.basic.model.printer.req;
import lombok.Data;
import java.util.List;
@Data
public class FromSourceReq {
List<Long> ids;
}

View File

@ -32,6 +32,7 @@ import com.ycwl.basic.model.pc.order.resp.OrderRespVO;
import com.ycwl.basic.model.pc.orderOp.entity.OrderOperationEntity; import com.ycwl.basic.model.pc.orderOp.entity.OrderOperationEntity;
import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity; import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity;
import com.ycwl.basic.model.pc.price.resp.GoodsListRespVO; import com.ycwl.basic.model.pc.price.resp.GoodsListRespVO;
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
import com.ycwl.basic.model.pc.source.entity.SourceEntity; import com.ycwl.basic.model.pc.source.entity.SourceEntity;
import com.ycwl.basic.model.pc.task.entity.TaskEntity; import com.ycwl.basic.model.pc.task.entity.TaskEntity;
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO; import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
@ -101,6 +102,8 @@ public class OrderServiceImpl implements OrderService {
private TemplateRepository templateRepository; private TemplateRepository templateRepository;
@Autowired @Autowired
private TaskTaskServiceImpl taskTaskService; private TaskTaskServiceImpl taskTaskService;
@Autowired
private PrinterMapper printerMapper;
@Override @Override
public ApiResponse<PageInfo<OrderRespVO>> pageQuery(OrderReqQuery query) { public ApiResponse<PageInfo<OrderRespVO>> pageQuery(OrderReqQuery query) {
@ -204,6 +207,26 @@ public class OrderServiceImpl implements OrderService {
item.setShootingTime(memberVideoEntityList.get(0).getCreateTime()); item.setShootingTime(memberVideoEntityList.get(0).getCreateTime());
} }
} }
} else if (Integer.valueOf(3).equals(item.getGoodsType())) { // 打印照片 goodsId就是memberPrintId
List<MemberPrintResp> list = printerMapper.getUserPhotoByIds(orderItemList.stream().map(OrderItemVO::getGoodsId).collect(Collectors.toList()));
item.setCoverList(orderItemList.stream().map(OrderItemVO::getCoverUrl).collect(Collectors.toList()));
if (!_f.contains(3)) {
_f.add(3);
if (!list.isEmpty()) {
for (MemberPrintResp sourceEntity : list) {
GoodsDetailVO goods = new GoodsDetailVO();
goods.setGoodsId(Long.valueOf(sourceEntity.getId()));
goods.setGoodsName("打印照片("+sourceEntity.getQuantity()+"张)");
goods.setUrl(sourceEntity.getCropUrl());
goods.setGoodsType(3);
goods.setScenicId(sourceEntity.getScenicId());
goods.setTemplateCoverUrl(sourceEntity.getCropUrl());
goods.setScenicId(sourceEntity.getScenicId());
goods.setCreateTime(sourceEntity.getCreateTime());
goodsList.add(goods);
}
}
}
} else { } else {
item.setCoverList(Collections.singletonList(item.getCoverUrl())); item.setCoverList(Collections.singletonList(item.getCoverUrl()));
VideoEntity videoMapperById = videoRepository.getVideo(item.getGoodsId()); VideoEntity videoMapperById = videoRepository.getVideo(item.getGoodsId());
@ -342,12 +365,16 @@ public class OrderServiceImpl implements OrderService {
if (!memberVideoEntityList.isEmpty()) { if (!memberVideoEntityList.isEmpty()) {
item.setShootingTime(memberVideoEntityList.get(0).getCreateTime()); item.setShootingTime(memberVideoEntityList.get(0).getCreateTime());
} }
} else { } else if (Integer.valueOf(0).equals(item.getGoodsType())) {
item.setCoverList(Collections.singletonList(item.getCoverUrl())); item.setCoverList(Collections.singletonList(item.getCoverUrl()));
VideoEntity video = videoRepository.getVideo(item.getGoodsId()); VideoEntity video = videoRepository.getVideo(item.getGoodsId());
if (video != null) { if (video != null) {
item.setShootingTime(videoTaskRepository.getTaskShotDate(video.getTaskId())); item.setShootingTime(videoTaskRepository.getTaskShotDate(video.getTaskId()));
} }
} else if (Integer.valueOf(3).equals(item.getGoodsType())) {
// 打印订单
List<MemberPrintResp> photo = printerMapper.getUserPhotoByIds(orderItemList.stream().map(OrderItemVO::getGoodsId).collect(Collectors.toList()));
item.setCoverList(photo.stream().map(MemberPrintResp::getCropUrl).collect(Collectors.toList()));
} }
}); });
}); });

View File

@ -4,12 +4,14 @@ import com.ycwl.basic.model.mobile.order.PriceObj;
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity; import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp; import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
import com.ycwl.basic.model.pc.printer.resp.PrinterResp; import com.ycwl.basic.model.pc.printer.resp.PrinterResp;
import com.ycwl.basic.model.printer.req.FromSourceReq;
import com.ycwl.basic.model.printer.req.PrinterSyncReq; import com.ycwl.basic.model.printer.req.PrinterSyncReq;
import com.ycwl.basic.model.printer.resp.PrintTaskResp; import com.ycwl.basic.model.printer.resp.PrintTaskResp;
import com.ycwl.basic.model.printer.req.WorkerAuthReqVo; import com.ycwl.basic.model.printer.req.WorkerAuthReqVo;
import com.ycwl.basic.utils.ApiResponse; import com.ycwl.basic.utils.ApiResponse;
import java.util.List; import java.util.List;
import java.util.Map;
public interface PrinterService { public interface PrinterService {
List<PrinterResp> listByScenicId(Long scenicId); List<PrinterResp> listByScenicId(Long scenicId);
@ -32,6 +34,8 @@ public interface PrinterService {
List<MemberPrintResp> getUserPhotoList(Long userId, Long scenicId); List<MemberPrintResp> getUserPhotoList(Long userId, Long scenicId);
List<MemberPrintResp> getUserPhotoListByOrderId(Long orderId);
boolean deleteUserPhoto(Long memberId, Long scenicId, Long relationId); boolean deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
boolean addUserPhoto(Long memberId, Long scenicId, String url); boolean addUserPhoto(Long memberId, Long scenicId, String url);
@ -43,4 +47,12 @@ 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);
boolean addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req);
Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId);
void batchSetUserPhotoListToPrinter(Long memberId, Long scenicId, Integer printerId);
void setUserIsBuyItem(Long memberId, Long id, Long orderId);
} }

View File

@ -1,32 +1,70 @@
package com.ycwl.basic.service.printer.impl; package com.ycwl.basic.service.printer.impl;
import com.ycwl.basic.biz.OrderBiz;
import com.ycwl.basic.constant.NumberConstant;
import com.ycwl.basic.enums.OrderStateEnum;
import com.ycwl.basic.exception.BaseException;
import com.ycwl.basic.mapper.MemberMapper;
import com.ycwl.basic.mapper.OrderMapper;
import com.ycwl.basic.mapper.PrintTaskMapper;
import com.ycwl.basic.mapper.PrinterMapper; import com.ycwl.basic.mapper.PrinterMapper;
import com.ycwl.basic.mapper.SourceMapper;
import com.ycwl.basic.model.mobile.order.PriceObj; import com.ycwl.basic.model.mobile.order.PriceObj;
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.OrderItemEntity;
import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity; import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity;
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity; import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity; import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp; import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
import com.ycwl.basic.model.pc.printer.resp.PrinterResp; import com.ycwl.basic.model.pc.printer.resp.PrinterResp;
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
import com.ycwl.basic.model.printer.req.FromSourceReq;
import com.ycwl.basic.model.printer.req.PrinterSyncReq; 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.repository.PriceRepository; import com.ycwl.basic.repository.PriceRepository;
import com.ycwl.basic.service.mobile.WxPayService;
import com.ycwl.basic.service.printer.PrinterService; import com.ycwl.basic.service.printer.PrinterService;
import com.ycwl.basic.utils.ApiResponse; import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.SnowFlakeUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Slf4j
@Service @Service
public class PrinterServiceImpl implements PrinterService { public class PrinterServiceImpl implements PrinterService {
@Autowired @Autowired
private PrinterMapper printerMapper; private PrinterMapper printerMapper;
@Autowired @Autowired
private PriceRepository priceRepository; private PriceRepository priceRepository;
@Autowired
private SourceMapper sourceMapper;
@Autowired
private MemberMapper memberMapper;
@Autowired
private OrderMapper orderMapper;
@Autowired
@Lazy
private OrderBiz orderBiz;
@Autowired
private WxPayService wxPayService;
@Autowired
private PrintTaskMapper printTaskMapper;
@Override @Override
public List<PrinterResp> listByScenicId(Long scenicId) { public List<PrinterResp> listByScenicId(Long scenicId) {
@ -131,6 +169,11 @@ public class PrinterServiceImpl implements PrinterService {
return list; return list;
} }
@Override
public List<MemberPrintResp> getUserPhotoListByOrderId(Long orderId) {
return printerMapper.listRelationByOrderId(orderId);
}
@Override @Override
public boolean deleteUserPhoto(Long memberId, Long scenicId, Long relationId) { public boolean deleteUserPhoto(Long memberId, Long scenicId, Long relationId) {
int record = printerMapper.deleteUserPhoto(memberId, scenicId, relationId); int record = printerMapper.deleteUserPhoto(memberId, scenicId, relationId);
@ -164,11 +207,133 @@ public class PrinterServiceImpl implements PrinterService {
// 判断几张 // 判断几张
PriceConfigEntity priceConfig = priceRepository.getPriceConfigByScenicTypeGoods(scenicId, 3, null); PriceConfigEntity priceConfig = priceRepository.getPriceConfigByScenicTypeGoods(scenicId, 3, null);
PriceObj obj = new PriceObj(); PriceObj obj = new PriceObj();
obj.setPrice(priceConfig.getPrice().multiply(BigDecimal.valueOf(userPhotoList.size()))); long count = userPhotoList.stream().filter(item -> Objects.nonNull(item.getQuantity())).mapToInt(MemberPrintResp::getQuantity).sum();
obj.setSlashPrice(priceConfig.getSlashPrice().multiply(BigDecimal.valueOf(userPhotoList.size()))); obj.setPrice(priceConfig.getPrice().multiply(BigDecimal.valueOf(count)));
obj.setSlashPrice(priceConfig.getSlashPrice().multiply(BigDecimal.valueOf(count)));
obj.setGoodsType(3); obj.setGoodsType(3);
obj.setFree(false); obj.setFree(false);
obj.setScenicId(scenicId); obj.setScenicId(scenicId);
return obj; return obj;
} }
@Override
public boolean addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req) {
req.getIds().forEach(id -> {
SourceRespVO byId = sourceMapper.getById(id);
if (byId == null) {
return;
}
printerMapper.addUserPhoto(memberId, scenicId, byId.getUrl());
});
return false;
}
@Override
public Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId) {
if (printerId == null) {
List<PrinterResp> printerList = printerMapper.listByScenicId(scenicId);
if (printerList.size() != 1) {
throw new BaseException("请选择打印机");
} else {
printerId = printerList.get(0).getId();
}
} else {
PrinterEntity printer = printerMapper.getById(printerId);
if (printer == null) {
throw new BaseException("打印机不存在");
}
if (printer.getStatus() != 1) {
throw new BaseException("打印机已停用");
}
if (!printer.getScenicId().equals(scenicId)) {
throw new BaseException("打印机不属于该景区");
}
}
PriceConfigEntity priceConfig = priceRepository.getPriceConfigByScenicTypeGoods(scenicId, 3, null);
if (priceConfig == null) {
throw new BaseException("该套餐暂未开放购买");
}
log.info("创建打印订单,价格配置:{}", priceConfig);
OrderEntity order = new OrderEntity();
Long orderId = SnowFlakeUtil.getLongId();
order.setId(orderId);
order.setMemberId(memberId);
MemberRespVO member = memberMapper.getById(memberId);
order.setOpenId(member.getOpenId());
order.setScenicId(scenicId);
order.setType(priceConfig.getType());
batchSetUserPhotoListToPrinter(memberId, scenicId, printerId);
List<MemberPrintResp> userPhotoList = getUserPhotoList(memberId, scenicId);
List<OrderItemEntity> orderItems = userPhotoList.stream().map(goods -> {
OrderItemEntity orderItem = new OrderItemEntity();
orderItem.setOrderId(orderId);
// member_print
orderItem.setGoodsId(Long.valueOf(goods.getId()));
orderItem.setGoodsType(3);
return orderItem;
}).collect(Collectors.toList());
long count = userPhotoList.stream().filter(item -> Objects.nonNull(item.getQuantity())).mapToInt(MemberPrintResp::getQuantity).sum();
order.setPrice(priceConfig.getPrice().multiply(BigDecimal.valueOf(count)));
order.setSlashPrice(priceConfig.getSlashPrice().multiply(BigDecimal.valueOf(count)));
order.setPayPrice(priceConfig.getPrice().multiply(BigDecimal.valueOf(count)));
// order.setFaceId();
if (order.getPayPrice().equals(BigDecimal.ZERO)) {
order.setStatus(OrderStateEnum.PAID.getState());
order.setPayAt(new Date());
} else {
order.setStatus(OrderStateEnum.UNPAID.getState());
}
orderMapper.add(order);
int addOrderItems = orderMapper.addOrderItems(orderItems);
if (addOrderItems == NumberConstant.ZERO) {
log.error("订单明细添加失败");
throw new BaseException("订单添加失败");
}
Map<String, Object> data = new HashMap<>();
if (order.getPayPrice().equals(BigDecimal.ZERO)) {
orderBiz.paidOrder(order.getId());
data.put("needPay", false);
return data;
} else {
WXPayOrderReqVO wxPayOrderReqVO = new WXPayOrderReqVO();
wxPayOrderReqVO.setOpenId(order.getOpenId())
.setMemberId(order.getMemberId())
.setOrderSn(order.getId())
.setTotalPrice(order.getPayPrice().setScale(2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).intValueExact())
.setGoodsName("照片打印")
.setDescription("照片打印");
try {
data = wxPayService.createOrder(order.getScenicId(), wxPayOrderReqVO);
} catch (Exception e) {
throw new BaseException(e);
}
data.put("orderId", orderId);
return data;
}
}
@Override
public void batchSetUserPhotoListToPrinter(Long memberId, Long scenicId, Integer printerId) {
printerMapper.updateUserPhotoListToPrinter(memberId, scenicId, printerId);
}
@Override
public void setUserIsBuyItem(Long memberId, Long id, Long orderId) {
printerMapper.setUserIsBuyItem(memberId, id, orderId);
// 创建打印任务
List<MemberPrintResp> userPhotoListByOrderId = getUserPhotoListByOrderId(orderId);
userPhotoListByOrderId.forEach(item -> {
PrinterEntity printer = printerMapper.getById(item.getPrinterId());
PrintTaskEntity task = new PrintTaskEntity();
task.setPrinterId(printer.getId());
task.setStatus(0);
task.setUrl(item.getCropUrl());
task.setPrinterName(printer.getUsePrinter());
task.setHeight(printer.getPreferH());
task.setWidth(printer.getPreferW());
task.setCreateTime(new Date());
task.setUpdateTime(new Date());
printTaskMapper.insertTask(task);
});
}
} }

View File

@ -99,7 +99,11 @@
FROM member_source ms FROM member_source ms
LEFT JOIN face f ON ms.face_id = f.id LEFT JOIN face f ON ms.face_id = f.id
LEFT JOIN source s ON ms.source_id = s.id LEFT JOIN source s ON ms.source_id = s.id
) ),
member_photo_data AS (
SELECT mp.member_id, 3 as type, mp.id, mp.crop_url as url, mp.quantity, mp.status, mp.create_time
FROM member_print mp
)
SELECT SELECT
oi.id AS oiId, oi.id AS oiId,
oi.order_id AS orderId, oi.order_id AS orderId,
@ -109,12 +113,14 @@
sc.name AS scenic_name, sc.name AS scenic_name,
CASE oi.goods_type CASE oi.goods_type
WHEN '0' THEN mvd.cover_url WHEN '0' THEN mvd.cover_url
WHEN '3' THEN mpd.url
END AS coverUrl, END AS coverUrl,
oi.goods_type, oi.goods_type,
CASE oi.goods_type CASE oi.goods_type
WHEN '0' THEN mvd.name WHEN '0' THEN mvd.name
WHEN '1' THEN '录像集' WHEN '1' THEN '录像集'
WHEN '2' THEN '照片集' WHEN '2' THEN '照片集'
WHEN '3' THEN '照片打印'
ELSE '其他' ELSE '其他'
END AS goods_name, END AS goods_name,
CASE oi.goods_type CASE oi.goods_type
@ -134,12 +140,14 @@
CASE oi.goods_type CASE oi.goods_type
WHEN '1' THEN msd.url WHEN '1' THEN msd.url
WHEN '2' THEN msd.url WHEN '2' THEN msd.url
WHEN '3' THEN mpd.url
END AS imgUrl END AS imgUrl
FROM order_item oi FROM order_item oi
LEFT JOIN `order` o ON oi.order_id = o.id LEFT JOIN `order` o ON oi.order_id = o.id
LEFT JOIN scenic sc ON o.scenic_id = sc.id LEFT JOIN scenic sc ON o.scenic_id = sc.id
LEFT JOIN member_video_data mvd ON o.face_id = mvd.face_id AND oi.goods_id = mvd.video_id LEFT JOIN member_video_data mvd ON o.face_id = mvd.face_id AND oi.goods_id = mvd.video_id
LEFT JOIN member_source_data msd ON o.face_id = msd.face_id AND oi.goods_id = msd.face_id AND msd.type = oi.goods_type LEFT JOIN member_source_data msd ON o.face_id = msd.face_id AND oi.goods_id = msd.face_id AND msd.type = oi.goods_type
LEFT JOIN member_photo_data mpd ON oi.goods_id = mpd.id AND mpd.type = oi.goods_type
WHERE oi.order_id = #{id}; WHERE oi.order_id = #{id};
</select> </select>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ycwl.basic.mapper.PrintTaskMapper">
<insert id="insertTask">
insert into print_task(printer_id, status, printer_name, url, width, height, create_time)
values (#{printerId}, 0, #{printerName}, #{url}, #{width}, #{height}, NOW())
</insert>
</mapper>

View File

@ -41,19 +41,38 @@
<select id="listRelation" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp"> <select id="listRelation" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id as scenicId, s.name as scenicName, p.member_id as memberId, SELECT p.id, p.scenic_id as scenicId, s.name as scenicName, p.member_id as memberId,
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity, p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime p.status, p.create_time as createTime, p.printer_id
FROM member_print p FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} AND p.status = 0
</select> </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.id, p.scenic_id, s.name as scenicName, p.member_id as memberId, SELECT p.id, p.scenic_id, s.name as scenicName, p.member_id as memberId,
p.member_id, p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity, p.member_id, p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime p.status, p.create_time as createTime, p.printer_id
FROM member_print p FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.id = #{id} AND p.member_id = #{memberId} AND p.scenic_id = #{scenicId} WHERE p.id = #{id} AND p.member_id = #{memberId} AND p.scenic_id = #{scenicId}
</select> </select>
<select id="getUserPhotoByIds" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id, s.name as scenicName, p.member_id as memberId,
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime, p.printer_id
FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="listRelationByOrderId" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id as scenicId, s.name as scenicName, p.member_id as memberId,
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime, p.printer_id
FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.id in (select order_item.goods_id from order_item where order_item.order_id = #{orderId} and order_item.goods_type = 3)
</select>
<!-- 新增 --> <!-- 新增 -->
<insert id="add"> <insert id="add">
@ -121,6 +140,12 @@
<update id="setPhotoQuantity"> <update id="setPhotoQuantity">
UPDATE member_print SET quantity = #{quantity}, update_time = NOW() WHERE id = #{id} UPDATE member_print SET quantity = #{quantity}, update_time = NOW() WHERE id = #{id}
</update> </update>
<update id="setUserIsBuyItem">
UPDATE member_print SET order_id = #{orderId}, status = 1, update_time = NOW() WHERE member_id = #{memberId} AND id = #{id}
</update>
<update id="updateUserPhotoListToPrinter">
UPDATE member_print SET printer_id = #{printerId}, update_time = NOW() WHERE member_id = #{memberId} AND scenic_id = #{scenicId} AND status = 0 AND printer_id is null
</update>
<!-- 删除 --> <!-- 删除 -->
<delete id="deleteById"> <delete id="deleteById">