增加打票机打印增加取单号上去

This commit is contained in:
Jack 2024-11-09 16:48:37 +08:00
parent cb7976df29
commit 3bef30e502
19 changed files with 94 additions and 49 deletions

View File

@ -103,9 +103,9 @@ public class StateCode {
public static final int PRODUCT_VERIFY_WAITING = 3002; //审核中 public static final int PRODUCT_VERIFY_WAITING = 3002; //审核中
public static final int ORDER_STATE_WAIT_PAY = 2010; //待付款 - 虚拟映射 public static final int ORDER_STATE_WAIT_PAY = 2010; //待付款 - 虚拟映射
public static final int ORDER_STATE_WAIT_PAID = 2016; //已经付款 - 虚拟映射
public static final int ORDER_STATE_WAIT_REVIEW = 2011; //待订单审核 public static final int ORDER_STATE_WAIT_REVIEW = 2011; //待订单审核
public static final int ORDER_STATE_WAIT_FINANCE_REVIEW = 2013; //待财务审核 public static final int ORDER_STATE_WAIT_FINANCE_REVIEW = 2013; //待财务审核
public static final int ORDER_STATE_WAIT_PAID = 2016; //已经付款 - 虚拟映射
public static final int ORDER_STATE_PICKING = 2020; //待配货 public static final int ORDER_STATE_PICKING = 2020; //待配货
public static final int ORDER_STATE_WAIT_SHIPPING = 2030; //待发货 public static final int ORDER_STATE_WAIT_SHIPPING = 2030; //待发货
public static final int ORDER_STATE_SHIPPED = 2040; //已发货 public static final int ORDER_STATE_SHIPPED = 2040; //已发货

View File

@ -195,4 +195,6 @@ public class ShopOrderInfo implements Serializable {
@ApiModelProperty(value = "服务类型(ENUM):1001-到店服务;1002-上门服务;1003-试驾模板; 针对虚拟产品") @ApiModelProperty(value = "服务类型(ENUM):1001-到店服务;1002-上门服务;1003-试驾模板; 针对虚拟产品")
private Integer order_valid_type; private Integer order_valid_type;
@ApiModelProperty(value = "取单号,根据每个店铺每天已支付的订单累加+1")
private Long order_pickup_num;
} }

View File

@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
@ -21,14 +23,26 @@ import java.util.Date;
* @since 2024-10-28 * @since 2024-10-28
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("shop_store_printer") @TableName("shop_store_printer_log")
@ApiModel(value = "ShopStorePrinter对象", description = "门店打票机") @ApiModel(value = "ShopStorePrinterLog", description = "门店打票机打印日志")
public class ShopStorePrinterLog implements Serializable { public class ShopStorePrinterLog implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public ShopStorePrinterLog(Integer category,Integer storeId,String orderId,Long templateId,String templateValue, String templateData,String printContent) {
this.category = category;
this.store_id = storeId;
this.order_id = orderId;
this.template_id = templateId;
this.template_data = templateData;
this.template_value = templateValue;
this.print_content = printContent;
}
@ApiModelProperty(value = "日志自增ID") @ApiModelProperty(value = "日志自增ID")
@TableId(value = "log_id", type = IdType.INPUT) @TableId(value = "log_id", type = IdType.INPUT)
private Long log_id; private Long log_id;

View File

@ -64,8 +64,14 @@ public class OrderPayedListener {
flag = shopOrderBaseService.setPaidYes(Collections.singletonList(orderId)); flag = shopOrderBaseService.setPaidYes(Collections.singletonList(orderId));
} }
// 小票打印 // 生成取单号和打印小票
if(flag) { if(flag) {
ShopOrderInfo orderInfo = new ShopOrderInfo();
orderInfo.setOrder_id(orderId);
// 生成取单号写入order_info
orderInfo.setOrder_pickup_num(shopOrderInfoService.genTodayPickupNum(orderInfoOld.getStore_id()));
shopOrderInfoService.edit(orderInfo);
// 订单状态处理成功之后打印小票 // 订单状态处理成功之后打印小票
shopStorePrinterService.printShopStoreOrder(orderId); shopStorePrinterService.printShopStoreOrder(orderId);
} }

View File

@ -24,4 +24,11 @@ public interface ShopOrderInfoService extends IBaseService<ShopOrderInfo> {
List<String> getAutoFinishOrderId(); List<String> getAutoFinishOrderId();
/**
* 获取店铺今日的取货单
* @param storeId
* @return
*/
Long genTodayPickupNum(Integer storeId);
} }

View File

@ -342,7 +342,6 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
@Autowired @Autowired
private ShopActivityCutpriceService shopActivityCutpriceService; private ShopActivityCutpriceService shopActivityCutpriceService;
//
private Logger logger = LoggerFactory.getLogger(ShopOrderBaseServiceImpl.class); private Logger logger = LoggerFactory.getLogger(ShopOrderBaseServiceImpl.class);
@Override @Override
@ -8247,6 +8246,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
return null; return null;
} }
m.put("order_pickup_num_str", String.format("%07d", m.get("order_pickup_num"))); // 取单号左补0共7位数
m.put("seller_message", "");//卖家留言 m.put("seller_message", "");//卖家留言
m.put("order_items", orderItems);//订单商品列表 m.put("order_items", orderItems);//订单商品列表
m.put("order_items_count", orderItems.size());//商品数量 m.put("order_items_count", orderItems.size());//商品数量

View File

@ -29,6 +29,9 @@ import com.suisung.mall.shop.plantform.service.ShopPlantformFeedbackService;
import com.suisung.mall.shop.product.service.ShopProductBaseService; import com.suisung.mall.shop.product.service.ShopProductBaseService;
import com.suisung.mall.shop.product.service.ShopProductCommentService; import com.suisung.mall.shop.product.service.ShopProductCommentService;
import com.suisung.mall.shop.store.service.ShopStoreBaseService; import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.sun.jna.platform.win32.WinDef;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
@ -94,9 +97,12 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
@Autowired @Autowired
private ShopOrderInvoiceService shopOrderInvoiceService; private ShopOrderInvoiceService shopOrderInvoiceService;
@Autowired @Autowired
private ThreadPoolExecutor executor; private ThreadPoolExecutor executor;
private Logger logger = LoggerFactory.getLogger(ShopOrderInfoServiceImpl.class);
@Override @Override
public Map dashboard() { public Map dashboard() {
@ -177,6 +183,32 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
return Convert.toList(String.class, findKey(queryWrapper)); return Convert.toList(String.class, findKey(queryWrapper));
} }
@Override
public Long genTodayPickupNum(Integer storeId) {
try {
// 获取今天零时的时间戳
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.HOUR_OF_DAY, 0);
// calendar.set(2024,10,5,0,0,0);
QueryWrapper<ShopOrderInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", storeId);
queryWrapper.ge("order_time", calendar.getTimeInMillis());
queryWrapper.lt("order_time", calendar.getTimeInMillis() + 86400000); // 加24小时的毫秒值
queryWrapper.ge("order_state_id", StateCode.ORDER_STATE_WAIT_PAID);
long cnt = count(queryWrapper);
return cnt <= 0 ? 1L : cnt + 1;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return 1L;
}
}
// todo 优化多次远程查询 // todo 优化多次远程查询
private Map dashboardPlantform() { private Map dashboardPlantform() {
List<Integer> order_state = Arrays.asList( List<Integer> order_state = Arrays.asList(

View File

@ -21,6 +21,7 @@ import com.suisung.mall.common.utils.FreeMakerUtils;
import com.suisung.mall.common.utils.JsonUtil; 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.order.service.impl.ShopOrderInfoServiceImpl;
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.ShopStorePrinterLogService;
import com.suisung.mall.shop.store.service.ShopStorePrinterService; import com.suisung.mall.shop.store.service.ShopStorePrinterService;
@ -55,6 +56,8 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
@Autowired @Autowired
private ShopStorePrinterLogService shopStorePrinterLogService; private ShopStorePrinterLogService shopStorePrinterLogService;
@Autowired
private ShopOrderInfoServiceImpl shopOrderInfoServiceImpl;
@Override @Override
public IPage<Map> shopStorePrinterPageList(String keyword, Integer pageNum, Integer pageSize) { public IPage<Map> shopStorePrinterPageList(String keyword, Integer pageNum, Integer pageSize) {
@ -331,6 +334,8 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
public Boolean printShopStoreOrder(String orderId) { public Boolean printShopStoreOrder(String orderId) {
// 获取订单包含所有所需的字段参考实体类ShopStoreOrderPrintVO ShopStoreOrderProductPrintVO // 获取订单包含所有所需的字段参考实体类ShopStoreOrderPrintVO ShopStoreOrderProductPrintVO
// long cntt = shopOrderInfoServiceImpl.genTodayPickupNum(3);
if (StrUtil.isBlank(orderId)) { if (StrUtil.isBlank(orderId)) {
logger.info("订单为空,无法打印小票。"); logger.info("订单为空,无法打印小票。");
return false; return false;
@ -383,14 +388,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
} }
// 打印成功新增打印日志记录以备下次查看和打印 // 打印成功新增打印日志记录以备下次查看和打印
ShopStorePrinterLog shopStorePrinterLog = new ShopStorePrinterLog(); ShopStorePrinterLog shopStorePrinterLog = new ShopStorePrinterLog(template.getCategory(), storeId, orderId, template.getTemplate_id(), template.getTemplate_value(), JsonUtil.object2json(binding), printContent);
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); shopStorePrinterLogService.insertShopStorePrinterLog(shopStorePrinterLog);
return true; return true;

View File

@ -100,7 +100,7 @@ public class FeieUtil {
return true; return true;
} }
logger.error(reps.getMsg()); logger.error("飞鹅添加打印机操作失败:{}", reps.getMsg());
return false; return false;
} }
@ -119,7 +119,7 @@ public class FeieUtil {
return true; return true;
} }
logger.error(reps.getMsg()); logger.error("飞鹅删除打印机操作失败:{}", reps.getMsg());
return false; return false;
} }
@ -140,7 +140,7 @@ public class FeieUtil {
return true; return true;
} }
logger.error(reps.getMsg()); logger.error("飞鹅打印操作失败:{}", reps.getMsg());
return false; return false;
} }
@ -220,7 +220,7 @@ public class FeieUtil {
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error("发送飞鹅接口请求失败:{}", e.getMessage());
} finally { } finally {
close(response, post, httpClient); close(response, post, httpClient);
} }
@ -266,17 +266,6 @@ public class FeieUtil {
// 标题刚刚等于指定的长度字节数 // 标题刚刚等于指定的长度字节数
resultStr += "<L>" + title + "</L>" + otherStr; resultStr += "<L>" + title + "</L>" + otherStr;
} else { } else {
// List<String> list = segmentString(title, titleLen);
// int cnt = list.size();
// if (cnt <= 0) {
// resultStr += StrUtil.repeat(' ', titleLen - 1) + otherStr;
// }
//
// for (i = 0; i < cnt; i++) {
// resultStr += i == 0 ? list.get(i) + otherStr : list.get(i) + "<BR>";
// }
// 标题大于指定的长度字节数需要截断再组合 // 标题大于指定的长度字节数需要截断再组合
List<String> list = containEn(title) ? getStrList(title, titleLen) : getStrList(title, titleLen / 2); List<String> list = containEn(title) ? getStrList(title, titleLen) : getStrList(title, titleLen / 2);
@ -400,13 +389,15 @@ public class FeieUtil {
* 分析标题能分几行显示 * 分析标题能分几行显示
* *
* @param str * @param str
* @param wordCnt 英文数字或中文的字数 * @param wordCnt 英文数字或中文的字数中文2个字节英文数字1个字节
* @return * @return
*/ */
public List<String> getStrList(String str, int wordCnt) { public List<String> getStrList(String str, int wordCnt) {
// 分几行 // 计算标题 wordCnt个字能分多少行
int linesCnt = str.length() / wordCnt; int len = str.length();
if (str.length() % wordCnt != 0) { // int len =asciiByteLen(str);
int linesCnt = len / wordCnt;
if (len % wordCnt != 0) {
linesCnt += 1; linesCnt += 1;
} }
@ -430,11 +421,6 @@ public class FeieUtil {
return list; return list;
} }
// private static boolean isChineseChar(char c) {
// return c >= 0x4E00 && c <= 0x9FFF;
// }
/** /**
* 截取字符串 * 截取字符串
* *

View File

@ -524,7 +524,7 @@
a.order_id,a.store_id,a.store_name,a.buyer_user_id, a.buyer_user_name,a.order_time,a.order_payment_amount,a.order_product_amount, a.order_id,a.store_id,a.store_name,a.buyer_user_id, a.buyer_user_name,a.order_time,a.order_payment_amount,a.order_product_amount,
b.order_title, b.delivery_type_id, b.payment_type_id, b.payment_time, b.order_title, b.delivery_type_id, b.payment_type_id, b.payment_time,
c.order_message, c.order_item_amount, c.order_shipping_fee,c.delivery_time, c.order_message, c.order_item_amount, c.order_shipping_fee,c.delivery_time,
e.store_tel, e.store_tel, e.order_pickup_num,
f.da_province,f.da_city,f.da_address,f.da_mobile, f.order_id f.da_province,f.da_city,f.da_address,f.da_mobile, f.order_id
from shop_order_base a from shop_order_base a
inner join shop_order_info b on a.order_id=b.order_id inner join shop_order_info b on a.order_id=b.order_id

View File

@ -11,7 +11,7 @@
order_is_received, chain_id, delivery_type_id, order_is_offline, cart_type_id, order_express_print, activity_id, order_is_received, chain_id, delivery_type_id, order_is_offline, cart_type_id, order_express_print, activity_id,
activity_type_id, salesperson_id, order_is_sync, store_is_selfsupport, store_type, order_erp_id, activity_type_id, salesperson_id, order_is_sync, store_is_selfsupport, store_type, order_erp_id,
distributor_user_id, order_is_cb, order_is_cb_sync, src_order_id, order_is_transfer, order_is_transfer_note, distributor_user_id, order_is_cb, order_is_cb_sync, src_order_id, order_is_transfer, order_is_transfer_note,
order_fx_is_settlemented, order_fx_settlement_time order_fx_is_settlemented, order_fx_settlement_time, order_pickup_num
</sql> </sql>
</mapper> </mapper>

View File

@ -524,7 +524,7 @@
a.order_id,a.store_id,a.store_name,a.buyer_user_id, a.buyer_user_name,a.order_time,a.order_payment_amount,a.order_product_amount, a.order_id,a.store_id,a.store_name,a.buyer_user_id, a.buyer_user_name,a.order_time,a.order_payment_amount,a.order_product_amount,
b.order_title, b.delivery_type_id, b.payment_type_id, b.payment_time, b.order_title, b.delivery_type_id, b.payment_type_id, b.payment_time,
c.order_message, c.order_item_amount, c.order_shipping_fee,c.delivery_time, c.order_message, c.order_item_amount, c.order_shipping_fee,c.delivery_time,
e.store_tel, e.store_tel, e.order_pickup_num,
f.da_province,f.da_city,f.da_address,f.da_mobile, f.order_id f.da_province,f.da_city,f.da_address,f.da_mobile, f.order_id
from shop_order_base a from shop_order_base a
inner join shop_order_info b on a.order_id=b.order_id inner join shop_order_info b on a.order_id=b.order_id

View File

@ -11,7 +11,7 @@
order_is_received, chain_id, delivery_type_id, order_is_offline, cart_type_id, order_express_print, activity_id, order_is_received, chain_id, delivery_type_id, order_is_offline, cart_type_id, order_express_print, activity_id,
activity_type_id, salesperson_id, order_is_sync, store_is_selfsupport, store_type, order_erp_id, activity_type_id, salesperson_id, order_is_sync, store_is_selfsupport, store_type, order_erp_id,
distributor_user_id, order_is_cb, order_is_cb_sync, src_order_id, order_is_transfer, order_is_transfer_note, distributor_user_id, order_is_cb, order_is_cb_sync, src_order_id, order_is_transfer, order_is_transfer_note,
order_fx_is_settlemented, order_fx_settlement_time order_fx_is_settlemented, order_fx_settlement_time, order_pickup_num
</sql> </sql>
</mapper> </mapper>