增加打票机打印日志
This commit is contained in:
parent
3aec650d25
commit
cb7976df29
@ -0,0 +1,71 @@
|
|||||||
|
package com.suisung.mall.common.modules.store;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 门店打票机表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author panjunjie
|
||||||
|
* @since 2024-10-28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("shop_store_printer")
|
||||||
|
@ApiModel(value = "ShopStorePrinter对象", description = "门店打票机表")
|
||||||
|
public class ShopStorePrinterLog implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "日志自增ID")
|
||||||
|
@TableId(value = "log_id", type = IdType.INPUT)
|
||||||
|
private Long log_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "打印分类")
|
||||||
|
private Integer category;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "门店ID")
|
||||||
|
private Integer store_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "订单ID")
|
||||||
|
private String order_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "打印模版ID")
|
||||||
|
private Long template_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "模版字符串")
|
||||||
|
private String template_value;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "模版渲染数据值")
|
||||||
|
private String template_data;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "最终打印的内容")
|
||||||
|
private String print_content;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态:1-有效;2-无效;")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "新增用户ID")
|
||||||
|
private Integer created_by;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新用户ID")
|
||||||
|
private Integer updated_by;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "新增时间")
|
||||||
|
private Date created_at;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
private Date updated_at;
|
||||||
|
}
|
||||||
@ -48,13 +48,12 @@ public class FreeMakerUtils {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
// throw new RuntimeException(e);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (stringWriter != null) {
|
if (stringWriter != null) {
|
||||||
try {
|
try {
|
||||||
stringWriter.close();
|
stringWriter.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// throw new RuntimeException(e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package com.suisung.mall.shop.store.controller.admin;
|
|||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
||||||
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
||||||
import com.suisung.mall.shop.store.utis.FeieUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
package com.suisung.mall.shop.store.controller.admin;
|
package com.suisung.mall.shop.store.controller.admin;
|
||||||
|
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinterRegion;
|
|
||||||
import com.suisung.mall.shop.store.service.ShopStorePrinterRegionService;
|
|
||||||
import com.suisung.mall.shop.store.service.ShopStorePrinterTemplateService;
|
import com.suisung.mall.shop.store.service.ShopStorePrinterTemplateService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.suisung.mall.shop.store.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStorePrinterLog;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 店铺打票机 mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author panjunjie
|
||||||
|
* @since 2024-10-28
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ShopStorePrinterLogMapper extends BaseMapper<ShopStorePrinterLog>{
|
||||||
|
}
|
||||||
@ -1,16 +1,9 @@
|
|||||||
package com.suisung.mall.shop.store.mapper;
|
package com.suisung.mall.shop.store.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinterTemplate;
|
import com.suisung.mall.common.modules.store.ShopStorePrinterTemplate;
|
||||||
import com.suisung.mall.common.pojo.vo.ShopStorePrinterVO;
|
|
||||||
import io.lettuce.core.dynamic.annotation.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 店铺打票机 mapper 接口
|
* 店铺打票机 mapper 接口
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.suisung.mall.shop.store.service;
|
||||||
|
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStorePrinterLog;
|
||||||
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
|
|
||||||
|
public interface ShopStorePrinterLogService extends IBaseService<ShopStorePrinterLog> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增一个打票机打印日志
|
||||||
|
*
|
||||||
|
* @param record
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean insertShopStorePrinterLog(ShopStorePrinterLog record);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.suisung.mall.shop.store.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
|
import com.suisung.mall.common.api.StateCode;
|
||||||
|
import com.suisung.mall.common.constant.ConstantError;
|
||||||
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStorePrinterLog;
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStorePrinterTemplate;
|
||||||
|
import com.suisung.mall.common.pojo.vo.ShopStoreOrderProductPrintVO;
|
||||||
|
import com.suisung.mall.common.pojo.vo.ShopStorePrinterVO;
|
||||||
|
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||||
|
import com.suisung.mall.common.utils.FreeMakerUtils;
|
||||||
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
|
import com.suisung.mall.shop.order.service.ShopOrderBaseService;
|
||||||
|
import com.suisung.mall.shop.store.mapper.ShopStorePrinterLogMapper;
|
||||||
|
import com.suisung.mall.shop.store.mapper.ShopStorePrinterMapper;
|
||||||
|
import com.suisung.mall.shop.store.service.ShopStorePrinterLogService;
|
||||||
|
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
||||||
|
import com.suisung.mall.shop.store.service.ShopStorePrinterTemplateService;
|
||||||
|
import com.suisung.mall.shop.store.utis.FeieUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ShopStorePrinterLogServiceImpl extends BaseServiceImpl<ShopStorePrinterLogMapper, ShopStorePrinterLog> implements ShopStorePrinterLogService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ShopStorePrinterLogServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
private ShopStorePrinterMapper shopStorePrinterMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean insertShopStorePrinterLog(ShopStorePrinterLog record) {
|
||||||
|
if (record == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (record.getStore_id() == null ||
|
||||||
|
StrUtil.isBlank(record.getOrder_id()) ||
|
||||||
|
StrUtil.isBlank(record.getTemplate_value()) ||
|
||||||
|
StrUtil.isBlank(record.getPrint_content())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinterModel;
|
import com.suisung.mall.common.modules.store.ShopStorePrinterModel;
|
||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.store.mapper.ShopStorePrinterModelMapper;
|
import com.suisung.mall.shop.store.mapper.ShopStorePrinterModelMapper;
|
||||||
@ -14,6 +14,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStorePrinterModelMapper, ShopStorePrinterModel> implements ShopStorePrinterModelService {
|
public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStorePrinterModelMapper, ShopStorePrinterModel> implements ShopStorePrinterModelService {
|
||||||
@ -25,14 +27,14 @@ public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStoreP
|
|||||||
queryWrapper.like("model_name", keyword);
|
queryWrapper.like("model_name", keyword);
|
||||||
}
|
}
|
||||||
queryWrapper.orderByAsc("model_id");
|
queryWrapper.orderByAsc("model_id");
|
||||||
return lists(queryWrapper,pageNum,pageSize);
|
return lists(queryWrapper, pageNum, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult shopStorePrinterModelList(Integer count) {
|
public CommonResult shopStorePrinterModelList(Integer count) {
|
||||||
QueryWrapper<ShopStorePrinterModel> queryWrapper= new QueryWrapper<>();
|
QueryWrapper<ShopStorePrinterModel> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.orderByAsc("model_id");
|
queryWrapper.orderByAsc("model_id");
|
||||||
if (count != null || count > 0) {
|
if (count != null || count > 0) {
|
||||||
queryWrapper.last("limit " + count);
|
queryWrapper.last("limit " + count);
|
||||||
}
|
}
|
||||||
List<ShopStorePrinterModel> recordList = find(queryWrapper);
|
List<ShopStorePrinterModel> recordList = find(queryWrapper);
|
||||||
@ -57,18 +59,23 @@ public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStoreP
|
|||||||
@Override
|
@Override
|
||||||
public CommonResult addNewShopStorePrinterModel(ShopStorePrinterModel record) {
|
public CommonResult addNewShopStorePrinterModel(ShopStorePrinterModel record) {
|
||||||
//TODO 判断有没有权限删除
|
//TODO 判断有没有权限删除
|
||||||
|
UserDto user = getCurrentUser();
|
||||||
|
if (user==null) {
|
||||||
|
return CommonResult.failed("用户信息异常!");
|
||||||
|
}
|
||||||
|
|
||||||
|
record.setCreated_by(user.getId());
|
||||||
|
record.setUpdated_by(record.getCreated_by());
|
||||||
|
|
||||||
record.setCreated_by(1);
|
|
||||||
record.setUpdated_by(1);
|
|
||||||
// 判断打票机是否已经存在
|
// 判断打票机是否已经存在
|
||||||
QueryWrapper<ShopStorePrinterModel> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopStorePrinterModel> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("model_name", record.getModel_name());
|
queryWrapper.eq("model_name", record.getModel_name());
|
||||||
ShopStorePrinterModel existRecord = getOne(queryWrapper);
|
ShopStorePrinterModel existRecord = getOne(queryWrapper);
|
||||||
if (existRecord!=null && existRecord.getModel_id() > 0) {
|
if (existRecord != null && existRecord.getModel_id() > 0) {
|
||||||
return CommonResult.success("打票机型号已添加,请勿重复操作");
|
return CommonResult.success("打票机型号已添加,请勿重复操作");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add(record)){
|
if (add(record)) {
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,21 +85,25 @@ public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStoreP
|
|||||||
@Override
|
@Override
|
||||||
public CommonResult updateShopStorePrinterModel(ShopStorePrinterModel record) {
|
public CommonResult updateShopStorePrinterModel(ShopStorePrinterModel record) {
|
||||||
|
|
||||||
//TODO 判断有没有权限删除
|
// 判断有没有权限删除
|
||||||
|
UserDto user = getCurrentUser();
|
||||||
|
if (user==null) {
|
||||||
|
return CommonResult.failed("用户信息异常!");
|
||||||
|
}
|
||||||
|
|
||||||
if (record==null|| record.getModel_id()<=0){
|
if (record == null || record.getModel_id() <= 0) {
|
||||||
return CommonResult.failed("记录不存在!");
|
return CommonResult.failed("记录不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
record.setUpdated_by(1);
|
record.setUpdated_by(user.getId());
|
||||||
record.setUpdated_at(new Date());
|
record.setUpdated_at(new Date());
|
||||||
|
|
||||||
if(record.getModel_id()<=0 || StrUtil.isBlank(record.getModel_name())){
|
if (record.getModel_id() <= 0 || StrUtil.isBlank(record.getModel_name())) {
|
||||||
return CommonResult.failed("缺少必要参数!");
|
return CommonResult.failed("缺少必要参数!");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success =updateById(record);
|
boolean success = updateById(record);
|
||||||
if (success){
|
if (success) {
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,16 +113,19 @@ public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStoreP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult deleteShopStorePrinterModel(Long model_id) {
|
public CommonResult deleteShopStorePrinterModel(Long model_id) {
|
||||||
|
// 判断有没有权限删除
|
||||||
//TODO 判断有没有权限删除
|
UserDto user = getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
return CommonResult.failed("用户信息异常!");
|
||||||
|
}
|
||||||
|
|
||||||
ShopStorePrinterModel record = getById(model_id);
|
ShopStorePrinterModel record = getById(model_id);
|
||||||
if(record.getModel_id()<=0){
|
if (record.getModel_id() <= 0) {
|
||||||
return CommonResult.failed("记录不存在,无法删除!");
|
return CommonResult.failed("记录不存在,无法删除!");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = remove(model_id);
|
boolean success = remove(model_id);
|
||||||
if(success){
|
if (success) {
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinterRegion;
|
import com.suisung.mall.common.modules.store.ShopStorePrinterRegion;
|
||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.store.mapper.ShopStorePrinterRegionMapper;
|
import com.suisung.mall.shop.store.mapper.ShopStorePrinterRegionMapper;
|
||||||
@ -13,6 +14,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ShopStorePrinterRegionServiceImpl extends BaseServiceImpl<ShopStorePrinterRegionMapper, ShopStorePrinterRegion> implements ShopStorePrinterRegionService {
|
public class ShopStorePrinterRegionServiceImpl extends BaseServiceImpl<ShopStorePrinterRegionMapper, ShopStorePrinterRegion> implements ShopStorePrinterRegionService {
|
||||||
@ -41,10 +44,14 @@ public class ShopStorePrinterRegionServiceImpl extends BaseServiceImpl<ShopStore
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult addNewShopStorePrinterRegion(ShopStorePrinterRegion record) {
|
public CommonResult addNewShopStorePrinterRegion(ShopStorePrinterRegion record) {
|
||||||
//TODO 判断有没有权限删除
|
// 判断有没有权限删除
|
||||||
|
UserDto user = getCurrentUser();
|
||||||
|
if (user==null) {
|
||||||
|
return CommonResult.failed("用户信息异常!");
|
||||||
|
}
|
||||||
|
|
||||||
record.setCreated_by(1);
|
record.setCreated_by(user.getId());
|
||||||
record.setUpdated_by(1);
|
record.setUpdated_by(record.getCreated_by());
|
||||||
// 判断打票机是否已经存在
|
// 判断打票机是否已经存在
|
||||||
QueryWrapper<ShopStorePrinterRegion> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopStorePrinterRegion> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("region", record.getRegion());
|
queryWrapper.eq("region", record.getRegion());
|
||||||
@ -63,13 +70,18 @@ public class ShopStorePrinterRegionServiceImpl extends BaseServiceImpl<ShopStore
|
|||||||
@Override
|
@Override
|
||||||
public CommonResult updateShopStorePrinterRegion(ShopStorePrinterRegion record) {
|
public CommonResult updateShopStorePrinterRegion(ShopStorePrinterRegion record) {
|
||||||
|
|
||||||
//TODO 判断有没有权限删除
|
// 判断有没有权限删除
|
||||||
|
UserDto user = getCurrentUser();
|
||||||
|
if (user==null) {
|
||||||
|
return CommonResult.failed("用户信息异常!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (record==null|| record.getRegion_id()<=0){
|
if (record==null|| record.getRegion_id()<=0){
|
||||||
return CommonResult.failed("记录不存在!");
|
return CommonResult.failed("记录不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
record.setUpdated_by(1);
|
record.setUpdated_by(user.getId());
|
||||||
record.setUpdated_at(new Date());
|
record.setUpdated_at(new Date());
|
||||||
|
|
||||||
if(record.getRegion_id()<=0 || StrUtil.isBlank(record.getRegion())){
|
if(record.getRegion_id()<=0 || StrUtil.isBlank(record.getRegion())){
|
||||||
@ -88,7 +100,11 @@ public class ShopStorePrinterRegionServiceImpl extends BaseServiceImpl<ShopStore
|
|||||||
@Override
|
@Override
|
||||||
public CommonResult deleteShopStorePrinterRegion(Long region_id) {
|
public CommonResult deleteShopStorePrinterRegion(Long region_id) {
|
||||||
|
|
||||||
//TODO 判断有没有权限删除
|
// 判断有没有权限删除
|
||||||
|
UserDto user = getCurrentUser();
|
||||||
|
if (user==null) {
|
||||||
|
return CommonResult.failed("用户信息异常!");
|
||||||
|
}
|
||||||
|
|
||||||
ShopStorePrinterRegion record = getById(region_id);
|
ShopStorePrinterRegion record = getById(region_id);
|
||||||
if(record.getRegion_id()<=0){
|
if(record.getRegion_id()<=0){
|
||||||
|
|||||||
@ -12,14 +12,17 @@ import com.suisung.mall.common.api.StateCode;
|
|||||||
import com.suisung.mall.common.constant.ConstantError;
|
import com.suisung.mall.common.constant.ConstantError;
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
import com.suisung.mall.common.modules.store.ShopStorePrinter;
|
||||||
|
import com.suisung.mall.common.modules.store.ShopStorePrinterLog;
|
||||||
import com.suisung.mall.common.modules.store.ShopStorePrinterTemplate;
|
import com.suisung.mall.common.modules.store.ShopStorePrinterTemplate;
|
||||||
import com.suisung.mall.common.pojo.vo.ShopStoreOrderProductPrintVO;
|
import com.suisung.mall.common.pojo.vo.ShopStoreOrderProductPrintVO;
|
||||||
import com.suisung.mall.common.pojo.vo.ShopStorePrinterVO;
|
import com.suisung.mall.common.pojo.vo.ShopStorePrinterVO;
|
||||||
import com.suisung.mall.common.utils.DateTimeUtils;
|
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||||
import com.suisung.mall.common.utils.FreeMakerUtils;
|
import com.suisung.mall.common.utils.FreeMakerUtils;
|
||||||
|
import com.suisung.mall.common.utils.JsonUtil;
|
||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.order.service.ShopOrderBaseService;
|
import com.suisung.mall.shop.order.service.ShopOrderBaseService;
|
||||||
import com.suisung.mall.shop.store.mapper.ShopStorePrinterMapper;
|
import com.suisung.mall.shop.store.mapper.ShopStorePrinterMapper;
|
||||||
|
import com.suisung.mall.shop.store.service.ShopStorePrinterLogService;
|
||||||
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
||||||
import com.suisung.mall.shop.store.service.ShopStorePrinterTemplateService;
|
import com.suisung.mall.shop.store.service.ShopStorePrinterTemplateService;
|
||||||
import com.suisung.mall.shop.store.utis.FeieUtil;
|
import com.suisung.mall.shop.store.utis.FeieUtil;
|
||||||
@ -50,6 +53,9 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopOrderBaseService shopOrderBaseService;
|
private ShopOrderBaseService shopOrderBaseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ShopStorePrinterLogService shopStorePrinterLogService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Map> shopStorePrinterPageList(String keyword, Integer pageNum, Integer pageSize) {
|
public IPage<Map> shopStorePrinterPageList(String keyword, Integer pageNum, Integer pageSize) {
|
||||||
Page<ShopStorePrinterVO> page = new Page<ShopStorePrinterVO>();
|
Page<ShopStorePrinterVO> page = new Page<ShopStorePrinterVO>();
|
||||||
@ -333,7 +339,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
|||||||
// 获取打印的订单信息,判断订单支付状态:已支付
|
// 获取打印的订单信息,判断订单支付状态:已支付
|
||||||
Map<String, Object> binding = shopOrderBaseService.getOrderPrintInfo(orderId, StateCode.ORDER_PAID_STATE_YES);
|
Map<String, Object> binding = shopOrderBaseService.getOrderPrintInfo(orderId, StateCode.ORDER_PAID_STATE_YES);
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
logger.info(orderId+"订单信息无法获取,无法打印小票。");
|
logger.info("订单{}信息无法获取,无法打印小票。", orderId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +348,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
|||||||
List<ShopStorePrinter> printerList = selectPrinterList(storeId);
|
List<ShopStorePrinter> printerList = selectPrinterList(storeId);
|
||||||
if (CollUtil.isEmpty(printerList)) {
|
if (CollUtil.isEmpty(printerList)) {
|
||||||
// 店铺没有打印机,不再往下执行打印工作
|
// 店铺没有打印机,不再往下执行打印工作
|
||||||
logger.info(storeId+"店铺未添加打票机,无法打印小票。");
|
logger.info("店铺{}未添加打票机,无法打印小票。", storeId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,14 +356,14 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
|||||||
ShopStorePrinterTemplate template = shopStorePrinterTemplateService.getShopStorePrinterTemplateInner(storeId, StateCode.PRINTER_TEMP_CATE_ORDER);
|
ShopStorePrinterTemplate template = shopStorePrinterTemplateService.getShopStorePrinterTemplateInner(storeId, StateCode.PRINTER_TEMP_CATE_ORDER);
|
||||||
if (template == null || StrUtil.isBlank(template.getTemplate_name()) || StrUtil.isBlank(template.getTemplate_value())) {
|
if (template == null || StrUtil.isBlank(template.getTemplate_name()) || StrUtil.isBlank(template.getTemplate_value())) {
|
||||||
// 店铺没有打印模版,
|
// 店铺没有打印模版,
|
||||||
logger.info(storeId+"店铺未添加打票机打印模版,无法打印小票。");
|
logger.info("店铺{}未添加打票机打印模版,无法打印小票。", storeId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 特殊处理,订单商品详情,由于有逻辑判断,无法模版化,所以直接生成模版的字符串
|
// 特殊处理,订单商品详情,由于有逻辑判断,无法模版化,所以直接生成模版的字符串
|
||||||
String order_items_tmpl = feieUtil.genProductStr((List<ShopStoreOrderProductPrintVO>) binding.get("order_items"), 18, 6, 8);
|
String order_items_tmpl = feieUtil.genProductStr((List<ShopStoreOrderProductPrintVO>) binding.get("order_items"), 18, 6, 8);
|
||||||
if(StrUtil.isBlank(order_items_tmpl)) {
|
if(StrUtil.isBlank(order_items_tmpl)) {
|
||||||
logger.info(orderId+"订单详情列表模版渲染异常,无法打印小票。");
|
logger.info("订单{}详情列表模版渲染异常,无法打印小票。", orderId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
binding.put("order_items_tmpl", order_items_tmpl);
|
binding.put("order_items_tmpl", order_items_tmpl);
|
||||||
@ -365,18 +371,27 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
|||||||
// 生成打印内容(暂时飞鹅打票机的内容)
|
// 生成打印内容(暂时飞鹅打票机的内容)
|
||||||
String printContent = freeMakerUtils.processTemplate(template.getTemplate_name(), template.getTemplate_value(), binding);
|
String printContent = freeMakerUtils.processTemplate(template.getTemplate_name(), template.getTemplate_value(), binding);
|
||||||
if (StrUtil.isBlank(printContent)) {
|
if (StrUtil.isBlank(printContent)) {
|
||||||
logger.info(orderId+"订单信息模版渲染异常,无法打印小票。");
|
logger.info("订单{}信息模版渲染异常,无法打印小票。", orderId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用打票机,打印小票
|
// 调用打票机,打印小票
|
||||||
boolean success = feieUtil.printContent(printerList.get(0).getPrinter_sn(), printContent);
|
boolean success = feieUtil.printContent(printerList.get(0).getPrinter_sn(), printContent);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
logger.info(orderId+"订单信息打印,调用飞鹅打印机打印失败。");
|
logger.info("订单{}信息打印,调用飞鹅打印机打印失败。", orderId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打印成功,新增打印日志记录,以备下次查看和打印
|
// 打印成功,新增打印日志记录,以备下次查看和打印
|
||||||
|
ShopStorePrinterLog shopStorePrinterLog = new ShopStorePrinterLog();
|
||||||
|
shopStorePrinterLog.setCategory(template.getCategory());
|
||||||
|
shopStorePrinterLog.setStore_id(storeId);
|
||||||
|
shopStorePrinterLog.setOrder_id(orderId);
|
||||||
|
shopStorePrinterLog.setTemplate_id(template.getTemplate_id());
|
||||||
|
shopStorePrinterLog.setTemplate_value(template.getTemplate_value());
|
||||||
|
shopStorePrinterLog.setTemplate_data(JsonUtil.object2json(binding));
|
||||||
|
shopStorePrinterLog.setPrint_content(printContent);
|
||||||
|
shopStorePrinterLogService.insertShopStorePrinterLog(shopStorePrinterLog);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package com.suisung.mall.shop.store.utis;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.suisung.mall.common.pojo.vo.ShopStoreOrderProductPrintVO;
|
|
||||||
import com.suisung.mall.common.pojo.res.FeiePrinterApiDataRes;
|
import com.suisung.mall.common.pojo.res.FeiePrinterApiDataRes;
|
||||||
import com.suisung.mall.common.pojo.res.FeiePrinterApiRes;
|
import com.suisung.mall.common.pojo.res.FeiePrinterApiRes;
|
||||||
|
import com.suisung.mall.common.pojo.vo.ShopStoreOrderProductPrintVO;
|
||||||
import com.suisung.mall.common.utils.JsonUtil;
|
import com.suisung.mall.common.utils.JsonUtil;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user