照片打印,基础

This commit is contained in:
2025-05-21 15:27:53 +08:00
parent 570267fd83
commit aaddbab2ab
7 changed files with 58 additions and 0 deletions

View File

@ -69,4 +69,19 @@ public class AppPrinterController {
printerService.setPhotoCropped(JwtTokenUtil.getWorker().getUserId(), scenicId, id, url);
return ApiResponse.success(url);
}
@PostMapping("/setQuantity/{scenicId}/{id}")
public ApiResponse<?> setQuantity(@PathVariable("scenicId") Long scenicId, @PathVariable("id") Long id, @RequestParam("quantity") Integer quantity) {
if (quantity == null) {
return ApiResponse.fail("请输入数量");
}
if (quantity < 0) {
return ApiResponse.fail("数量不能小于0");
}
printerService.setPhotoQuantity(JwtTokenUtil.getWorker().getUserId(), scenicId, id, quantity);
return ApiResponse.success(null);
}
@GetMapping("/price/{scenicId}")
public ApiResponse<?> queryPrice(@PathVariable("scenicId") Long scenicId) {
return ApiResponse.success(printerService.queryPrice(JwtTokenUtil.getWorker().getUserId(), scenicId));
}
}

View File

@ -40,4 +40,6 @@ public interface PrinterMapper {
MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id);
int setPhotoCropped(Long memberId, Long scenicId, Long id, String url);
int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity);
}

View File

@ -129,6 +129,12 @@ public class OrderServiceImpl implements OrderService {
item.setOrderType("未知商品");
}
}
} else if (Integer.valueOf(1).equals(item.getType())) {
item.setGoodsName("多项商品");
item.setOrderType("打包购买");
} else if (Integer.valueOf(3).equals(item.getType())) {
item.setGoodsName("打印照片");
item.setOrderType("照片打印");
}
});
PageInfo<OrderRespVO> pageInfo = new PageInfo<>(list);

View File

@ -51,6 +51,8 @@ public class PriceConfigServiceImpl extends ServiceImpl<PriceConfigMapper, Price
public void fillGoodsName(PriceConfigRespVO item) {
if (Integer.valueOf(-1).equals(item.getType())) {
item.setGoodsNames("景区内所有售卖商品");
} else if (Integer.valueOf(3).equals(item.getType())) {
item.setGoodsNames("打印照片");
} else if (StringUtils.isNotBlank(item.getGoodsIds())) {
List<String> goodsNames = new ArrayList<>();
for (String s : item.getGoodsIds().split(",")) {

View File

@ -1,5 +1,6 @@
package com.ycwl.basic.service.printer;
import com.ycwl.basic.model.mobile.order.PriceObj;
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.PrinterResp;
@ -38,4 +39,8 @@ public interface PrinterService {
MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id);
int setPhotoCropped(Long memberId, Long scenicId, Long id, String url);
int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity);
PriceObj queryPrice(Long memberId, Long scenicId);
}

View File

@ -1,6 +1,8 @@
package com.ycwl.basic.service.printer.impl;
import com.ycwl.basic.mapper.PrinterMapper;
import com.ycwl.basic.model.mobile.order.PriceObj;
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.PrinterEntity;
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
@ -8,12 +10,14 @@ import com.ycwl.basic.model.pc.printer.resp.PrinterResp;
import com.ycwl.basic.model.printer.req.PrinterSyncReq;
import com.ycwl.basic.model.printer.req.WorkerAuthReqVo;
import com.ycwl.basic.model.printer.resp.PrintTaskResp;
import com.ycwl.basic.repository.PriceRepository;
import com.ycwl.basic.service.printer.PrinterService;
import com.ycwl.basic.utils.ApiResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
@ -21,6 +25,8 @@ import java.util.List;
public class PrinterServiceImpl implements PrinterService {
@Autowired
private PrinterMapper printerMapper;
@Autowired
private PriceRepository priceRepository;
@Override
public List<PrinterResp> listByScenicId(Long scenicId) {
@ -146,4 +152,23 @@ public class PrinterServiceImpl implements PrinterService {
public int setPhotoCropped(Long memberId, Long scenicId, Long id, String url) {
return printerMapper.setPhotoCropped(memberId, scenicId, id, url);
}
@Override
public int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity) {
return printerMapper.setPhotoQuantity(memberId, scenicId, id, quantity);
}
@Override
public PriceObj queryPrice(Long memberId, Long scenicId) {
List<MemberPrintResp> userPhotoList = getUserPhotoList(memberId, scenicId);
// 判断几张
PriceConfigEntity priceConfig = priceRepository.getPriceConfigByScenicTypeGoods(scenicId, 3, null);
PriceObj obj = new PriceObj();
obj.setPrice(priceConfig.getPrice().multiply(BigDecimal.valueOf(userPhotoList.size())));
obj.setSlashPrice(priceConfig.getSlashPrice().multiply(BigDecimal.valueOf(userPhotoList.size())));
obj.setGoodsType(3);
obj.setFree(false);
obj.setScenicId(scenicId);
return obj;
}
}

View File

@ -118,6 +118,9 @@
<update id="setPhotoCropped">
UPDATE member_print SET crop_url = #{url}, update_time = NOW() WHERE id = #{id}
</update>
<update id="setPhotoQuantity">
UPDATE member_print SET quantity = #{quantity}, update_time = NOW() WHERE id = #{id}
</update>
<!-- 删除 -->
<delete id="deleteById">