增加模版示例

This commit is contained in:
Jack 2024-11-12 09:39:29 +08:00
parent dcc53bf15d
commit 3777caf93c
7 changed files with 74 additions and 16 deletions

View File

@ -24,7 +24,7 @@ import java.util.Date;
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(value = "ShopStoreOrderPrint显示对象", description = "门店单打印实体类") @ApiModel(value = "ShopStoreOrderPrint显示对象", description = "门店单打印实体类")
public class ShopStoreOrderPrintVO implements Serializable { public class ShopStoreOrderPrintVO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -52,6 +52,9 @@ public class ShopStoreOrderPrintVO implements Serializable {
private String fetch_no; private String fetch_no;
// 买家相关信息 // 买家相关信息
@ApiModelProperty(value = "买家用户名")
private String buyer_user_name;
@ApiModelProperty(value = "买家订单备注") @ApiModelProperty(value = "买家订单备注")
private String buyer_order_remark; private String buyer_order_remark;
@ -68,6 +71,9 @@ public class ShopStoreOrderPrintVO implements Serializable {
@ApiModelProperty(value = "配送来源") @ApiModelProperty(value = "配送来源")
private String shipper_type; private String shipper_type;
@ApiModelProperty(value = "下单时间")
private String order_time;
@ApiModelProperty(value = "付款时间") @ApiModelProperty(value = "付款时间")
private String pay_time; private String pay_time;
@ -101,7 +107,7 @@ public class ShopStoreOrderPrintVO implements Serializable {
// 订单商品详情信息 // 订单商品详情信息
@ApiModelProperty(value = "订单商品详情信息") @ApiModelProperty(value = "订单商品详情信息")
private ShopStoreOrderProductPrintVO order_item; private ShopStoreOrderProductPrintVO order_items;
@ApiModelProperty(value = "状态1-有效2-无效;") @ApiModelProperty(value = "状态1-有效2-无效;")
private Integer status; private Integer status;

View File

@ -1045,7 +1045,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
* *
* @param request * @param request
* @param response * @param response
* @param payment_channel_code * @param payment_channel_code 支付渠道码 alipay, wx_native
* @return * @return
*/ */
@Override @Override

View File

@ -10,6 +10,8 @@ import com.suisung.mall.shop.order.service.ShopOrderBaseService;
import com.suisung.mall.shop.order.service.ShopOrderInfoService; import com.suisung.mall.shop.order.service.ShopOrderInfoService;
import com.suisung.mall.shop.store.service.ShopStorePrinterService; import com.suisung.mall.shop.store.service.ShopStorePrinterService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
@ -25,15 +27,13 @@ import java.util.List;
@RabbitListener(queues = MqConstant.SHOP_PAIDYES_QUEUE, concurrency = "5-10") @RabbitListener(queues = MqConstant.SHOP_PAIDYES_QUEUE, concurrency = "5-10")
public class OrderPayedListener { public class OrderPayedListener {
private static final Logger logger = LoggerFactory.getLogger(OrderPayedListener.class);
@Autowired @Autowired
private ShopOrderBaseService shopOrderBaseService; private ShopOrderBaseService shopOrderBaseService;
@Autowired @Autowired
private ShopOrderInfoService shopOrderInfoService; private ShopOrderInfoService shopOrderInfoService;
@Autowired @Autowired
private ShopStorePrinterService shopStorePrinterService; private ShopStorePrinterService shopStorePrinterService;
@Autowired @Autowired
private MqMessageService mqMessageService; private MqMessageService mqMessageService;
@ -45,6 +45,8 @@ public class OrderPayedListener {
try { try {
boolean flag = false; boolean flag = false;
logger.info("收到微信异步通知消息data:{}-chanel:{}-message:{}", data, channel, message);
for (String orderId : order_id_row) { for (String orderId : order_id_row) {
//判断是否为线下支付订单 //判断是否为线下支付订单
ShopOrderInfo orderInfoOld = shopOrderInfoService.get(orderId); ShopOrderInfo orderInfoOld = shopOrderInfoService.get(orderId);
@ -64,8 +66,11 @@ public class OrderPayedListener {
flag = shopOrderBaseService.setPaidYes(Collections.singletonList(orderId)); flag = shopOrderBaseService.setPaidYes(Collections.singletonList(orderId));
} }
logger.info("#### 支付异步通知回调处理是否成功:{} ####", flag);
// 生成取单号和打印小票 // 生成取单号和打印小票
if(flag) { if (flag) {
logger.info("####开始生成取单号####");
ShopOrderInfo orderInfo = new ShopOrderInfo(); ShopOrderInfo orderInfo = new ShopOrderInfo();
orderInfo.setOrder_id(orderId); orderInfo.setOrder_id(orderId);
// 生成取单号写入order_info // 生成取单号写入order_info
@ -79,6 +84,7 @@ public class OrderPayedListener {
} }
if (flag) { if (flag) {
// 操作成功标记消息消费成功
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} else { } else {
log.error("消息消费失败执行setPaidYes异常当前订单编号{}", order_id_row); log.error("消息消费失败执行setPaidYes异常当前订单编号{}", order_id_row);

View File

@ -58,7 +58,7 @@ public class ShopStorePrinterModelServiceImpl extends BaseServiceImpl<ShopStoreP
@Override @Override
public CommonResult addNewShopStorePrinterModel(ShopStorePrinterModel record) { public CommonResult addNewShopStorePrinterModel(ShopStorePrinterModel record) {
//TODO 判断有没有权限删除 // 判断有没有权限删除
UserDto user = getCurrentUser(); UserDto user = getCurrentUser();
if (user==null) { if (user==null) {
return CommonResult.failed("用户信息异常!"); return CommonResult.failed("用户信息异常!");

View File

@ -258,10 +258,10 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
String sn = "922441475"; String sn = "922441475";
ShopStoreOrderProductPrintVO order1 = new ShopStoreOrderProductPrintVO("可口可乐CocaCola经典美味汽水1.25L/瓶", 110, new BigDecimal("8100.45"),"6970448170051"); ShopStoreOrderProductPrintVO order1 = new ShopStoreOrderProductPrintVO("可口可乐CocaCola经典美味汽水1.25L/瓶", 110, new BigDecimal("8100.45"), "6970448170051");
ShopStoreOrderProductPrintVO order2 = new ShopStoreOrderProductPrintVO( "排骨约350g默认砍小块", 1, new BigDecimal("150.13"),"6970448170051"); ShopStoreOrderProductPrintVO order2 = new ShopStoreOrderProductPrintVO("排骨约350g默认砍小块", 1, new BigDecimal("150.13"), "6970448170051");
ShopStoreOrderProductPrintVO order3 = new ShopStoreOrderProductPrintVO("新鲜虫草花1包约200g 韭菜1000g 鸡蛋2003克", 11, new BigDecimal("4.01"),"6970448170051"); ShopStoreOrderProductPrintVO order3 = new ShopStoreOrderProductPrintVO("新鲜虫草花1包约200g 韭菜1000g 鸡蛋2003克", 11, new BigDecimal("4.01"), "6970448170051");
ShopStoreOrderProductPrintVO order4 = new ShopStoreOrderProductPrintVO("冰红茶风味饮料", 1, new BigDecimal("13.24"),"6970448170051"); ShopStoreOrderProductPrintVO order4 = new ShopStoreOrderProductPrintVO("冰红茶风味饮料", 1, new BigDecimal("13.24"), "6970448170051");
List<ShopStoreOrderProductPrintVO> productList = new ArrayList<>(); List<ShopStoreOrderProductPrintVO> productList = new ArrayList<>();
productList.add(order1); productList.add(order1);
productList.add(order2); productList.add(order2);
@ -322,7 +322,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
binding.put("sn", "922441475"); binding.put("sn", "922441475");
String sn = "922441475"; String sn = "922441475";
String cont = freeMakerUtils.processTemplate(template.getTemplate_name(), template.getTemplate_value(), binding); String cont = FreeMakerUtils.processTemplate(template.getTemplate_name(), template.getTemplate_value(), binding);
// feieUtil.printContent(sn, cont); // feieUtil.printContent(sn, cont);
@ -332,10 +332,10 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
@Override @Override
public Boolean printShopStoreOrder(String orderId) { public Boolean printShopStoreOrder(String orderId) {
logger.info("#### 调用飞鹅打票机的打印操作开始 ####");
// 获取订单包含所有所需的字段参考实体类ShopStoreOrderPrintVO ShopStoreOrderProductPrintVO // 获取订单包含所有所需的字段参考实体类ShopStoreOrderPrintVO ShopStoreOrderProductPrintVO
// long cntt = shopOrderInfoServiceImpl.genTodayPickupNum(3); // long cntt = shopOrderInfoServiceImpl.genTodayPickupNum(3);
if (StrUtil.isBlank(orderId)) { if (StrUtil.isBlank(orderId)) {
logger.info("订单为空,无法打印小票。"); logger.info("订单为空,无法打印小票。");
return false; return false;
@ -374,7 +374,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
// binding.put("order_items_tmpl", order_items_tmpl); // binding.put("order_items_tmpl", order_items_tmpl);
// 生成打印内容暂时飞鹅打票机的内容 // 生成打印内容暂时飞鹅打票机的内容
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;
@ -391,6 +391,8 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
ShopStorePrinterLog shopStorePrinterLog = new ShopStorePrinterLog(template.getCategory(), storeId, orderId, template.getTemplate_id(), template.getTemplate_value(), JsonUtil.object2json(binding), printContent); ShopStorePrinterLog shopStorePrinterLog = new ShopStorePrinterLog(template.getCategory(), storeId, orderId, template.getTemplate_id(), template.getTemplate_value(), JsonUtil.object2json(binding), printContent);
shopStorePrinterLogService.insertShopStorePrinterLog(shopStorePrinterLog); shopStorePrinterLogService.insertShopStorePrinterLog(shopStorePrinterLog);
logger.debug("#### 调用飞鹅打票机的打印操作结束 ####");
return true; return true;
} }

View File

@ -0,0 +1,44 @@
示例格式化后的:
<CB>小发同城</CB><BR>
--------------------------------<BR>
<CB>#00019232</CB><BR>
<L>买家备注:不用敲门,放在门口旁边的外卖箱,打个电话告知送达就行,谢谢!!!</L><BR>
<BOLD>配送时间2024-10-25 14:00-14:30</BOLD><BR>
--------------------------------<BR>
订单编号ES20231026111444527685<BR>
订单来源:微信小程序<BR>
支付方式:微信支付<BR>
配送来源:顺丰同城<BR>
付款时间2024-10-25 14:00:23<BR>
申请退款时间2024-10-27 14:05:23<BR>
申请完成时间2024-10-27 14:8:23<BR>
--------------------------------<BR>
<C>******* 退款商品 ******</C><BR>
--------------------------------<BR>
<L>可口可乐CocaC</L> <L><BOLD> x110 </BOLD></L><L> 8100.45</L><BR>
<L>ola经典美味汽水1.2</L><BR>
<L>5L/瓶</L><BR>
<BOLD>6970448170051</BOLD><BR>
<L>排骨约350g默 </L><L><BOLD> 1 </BOLD></L><L> 150.13 </L><BR>
<L>认砍小块)</L><BR>
<BOLD>6970448170053</BOLD><BR>
--------------------------------<BR>
退款方式:<BOLD>仅退款</BOLD><BR>
申请金额:<BOLD>¥32.7</BOLD><BR>
退款原因:<BOLD>商家发货少了</BOLD><BR>
实付金额:<BOLD>¥428.9元</BOLD><BR>
微信退款金额:<BOLD>¥5.54(原路返回)</BOLD><BR>
余额退款金额:<BOLD>¥5退回会员余额</BOLD><BR>
--------------------------------<BR>
<BOLD>会员名称:张三</BOLD><BR>
<BOLD>会员手机13128778765</BOLD><BR>
<BOLD>会员备注本店前100名注册优质用户</BOLD><BR>
--------------------------------<BR>
操作员:李小明<BR>
格式化模版:
原模版:
<CB>${store_name}</CB><BR>--------------------------------<BR><CB>#${order_pickup_num_str}</CB><BR><L>买家备注:${order_message!'-'}</L><BR><BOLD>配送时间:${delivery_time}</BOLD><BR>--------------------------------<BR>订单编号:${order_id}<BR>订单来源:微信小程序<BR>支付方式:微信支付<BR>配送来源:顺丰同城<BR>付款时间:${payment_time}<BR>--------------------------------<BR><L>商品名称 数量 金额</L><BR>--------------------------------<BR><#list order_items as item><L>${item.s_name}</L><L><BOLD>${item.s_quantity}</BOLD></L><L>${item.s_amount}</L><BR><#if item.s_name_segs??><#list item.s_name_segs as seg><L>${seg}</L><BR></#list></#if><BOLD><#if item.product_sn?default("")?trim?length gt 1>${item.product_sn}</BOLD><BR></#if></#list>--------------------------------<BR>商品总件数:<BOLD>${order_items_count!0}</BOLD><BR>商品总额:<BOLD>¥${order_product_amount?string('0.00')}</BOLD><BR>押金:<BOLD>¥${(yajin!0)?string('0.00')}</BOLD><BR>运费:<BOLD>¥${order_shipping_fee?string('0.00')}</BOLD><BR>会员权益:<BOLD>-¥${(quanyi!0)?string('0.00')}</BOLD><BR>秒杀:<BOLD>-¥${(miaosha!0)?string('0.00')}</BOLD><BR>实付金额:<BOLD>¥${order_payment_amount?string('0.00')}</BOLD><BR><#if seller_message?default("")?trim?length gt 1>--------------------------------<BR><BOLD>商家备注:${seller_message!'---'}</BOLD><BR></#if>--------------------------------<BR><BOLD>收货人:${buyer_user_name!''}</BOLD><BR><BOLD>收货人手机:${store_tel!''}</BOLD><BR><BOLD>收货地址:${da_province!'-'}${da_city!'-'}${da_address!'-'}</BOLD><BR>--------------------------------<BR>门店:${store_name}<BR>门店电话:<BOLD>${store_tel!'-'}</BOLD><BR>收银员:${cashier!'-'}<BR>