增加打票机打印增加取单号上去
This commit is contained in:
parent
cb7976df29
commit
3bef30e502
@ -103,9 +103,9 @@ public class StateCode {
|
||||
public static final int PRODUCT_VERIFY_WAITING = 3002; //审核中
|
||||
|
||||
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_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_WAIT_SHIPPING = 2030; //待发货
|
||||
public static final int ORDER_STATE_SHIPPED = 2040; //已发货
|
||||
|
||||
@ -195,4 +195,6 @@ public class ShopOrderInfo implements Serializable {
|
||||
@ApiModelProperty(value = "服务类型(ENUM):1001-到店服务;1002-上门服务;1003-试驾模板; 针对虚拟产品")
|
||||
private Integer order_valid_type;
|
||||
|
||||
@ApiModelProperty(value = "取单号,根据每个店铺每天已支付的订单累加+1")
|
||||
private Long order_pickup_num;
|
||||
}
|
||||
|
||||
@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -21,14 +23,26 @@ import java.util.Date;
|
||||
* @since 2024-10-28
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("shop_store_printer")
|
||||
@ApiModel(value = "ShopStorePrinter对象", description = "门店打票机表")
|
||||
@TableName("shop_store_printer_log")
|
||||
@ApiModel(value = "ShopStorePrinterLog", description = "门店打票机打印日志表")
|
||||
public class ShopStorePrinterLog implements Serializable {
|
||||
|
||||
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")
|
||||
@TableId(value = "log_id", type = IdType.INPUT)
|
||||
private Long log_id;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -64,8 +64,14 @@ public class OrderPayedListener {
|
||||
flag = shopOrderBaseService.setPaidYes(Collections.singletonList(orderId));
|
||||
}
|
||||
|
||||
// 小票打印
|
||||
// 生成取单号和打印小票
|
||||
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);
|
||||
}
|
||||
|
||||
@ -24,4 +24,11 @@ public interface ShopOrderInfoService extends IBaseService<ShopOrderInfo> {
|
||||
|
||||
List<String> getAutoFinishOrderId();
|
||||
|
||||
/**
|
||||
* 获取店铺今日的取货单
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
Long genTodayPickupNum(Integer storeId);
|
||||
|
||||
}
|
||||
|
||||
@ -342,7 +342,6 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
@Autowired
|
||||
private ShopActivityCutpriceService shopActivityCutpriceService;
|
||||
|
||||
//
|
||||
private Logger logger = LoggerFactory.getLogger(ShopOrderBaseServiceImpl.class);
|
||||
|
||||
@Override
|
||||
@ -8233,23 +8232,24 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
|
||||
@Override
|
||||
public Map getOrderPrintInfo(@Param("orderId") String orderId, Integer payState) {
|
||||
if(StrUtil.isBlank(orderId)){
|
||||
if (StrUtil.isBlank(orderId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map m = shopOrderBaseMapper.getOrderPrintInfo(orderId, payState);
|
||||
if(m==null){
|
||||
if (m == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ShopStoreOrderProductPrintVO> orderItems = shopOrderItemService.selectOrderItemPrintInfo(orderId);
|
||||
if(CollUtil.isEmpty(orderItems)){
|
||||
if (CollUtil.isEmpty(orderItems)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
m.put("seller_message","");//卖家留言
|
||||
m.put("order_items",orderItems);//订单商品列表
|
||||
m.put("order_items_count",orderItems.size());//商品数量
|
||||
m.put("order_pickup_num_str", String.format("%07d", m.get("order_pickup_num"))); // 取单号左补0,共7位数
|
||||
m.put("seller_message", "");//卖家留言
|
||||
m.put("order_items", orderItems);//订单商品列表
|
||||
m.put("order_items_count", orderItems.size());//商品数量
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -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.ShopProductCommentService;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
@ -94,9 +97,12 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
|
||||
@Autowired
|
||||
private ShopOrderInvoiceService shopOrderInvoiceService;
|
||||
|
||||
@Autowired
|
||||
private ThreadPoolExecutor executor;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(ShopOrderInfoServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public Map dashboard() {
|
||||
|
||||
@ -177,6 +183,32 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
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 优化多次远程查询
|
||||
private Map dashboardPlantform() {
|
||||
List<Integer> order_state = Arrays.asList(
|
||||
|
||||
@ -21,6 +21,7 @@ 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.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.service.ShopStorePrinterLogService;
|
||||
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
||||
@ -55,6 +56,8 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
||||
|
||||
@Autowired
|
||||
private ShopStorePrinterLogService shopStorePrinterLogService;
|
||||
@Autowired
|
||||
private ShopOrderInfoServiceImpl shopOrderInfoServiceImpl;
|
||||
|
||||
@Override
|
||||
public IPage<Map> shopStorePrinterPageList(String keyword, Integer pageNum, Integer pageSize) {
|
||||
@ -331,7 +334,9 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
||||
public Boolean printShopStoreOrder(String orderId) {
|
||||
// 获取订单,包含所有所需的字段,参考实体类:ShopStoreOrderPrintVO 和 ShopStoreOrderProductPrintVO
|
||||
|
||||
if(StrUtil.isBlank(orderId)) {
|
||||
// long cntt = shopOrderInfoServiceImpl.genTodayPickupNum(3);
|
||||
|
||||
if (StrUtil.isBlank(orderId)) {
|
||||
logger.info("订单为空,无法打印小票。");
|
||||
return false;
|
||||
}
|
||||
@ -362,7 +367,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
||||
|
||||
// 特殊处理,订单商品详情,由于有逻辑判断,无法模版化,所以直接生成模版的字符串
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@ -383,14 +388,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
|
||||
}
|
||||
|
||||
// 打印成功,新增打印日志记录,以备下次查看和打印
|
||||
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);
|
||||
ShopStorePrinterLog shopStorePrinterLog = new ShopStorePrinterLog(template.getCategory(), storeId, orderId, template.getTemplate_id(), template.getTemplate_value(), JsonUtil.object2json(binding), printContent);
|
||||
shopStorePrinterLogService.insertShopStorePrinterLog(shopStorePrinterLog);
|
||||
|
||||
return true;
|
||||
|
||||
@ -100,7 +100,7 @@ public class FeieUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.error(reps.getMsg());
|
||||
logger.error("飞鹅添加打印机操作失败:{}", reps.getMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ public class FeieUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.error(reps.getMsg());
|
||||
logger.error("飞鹅删除打印机操作失败:{}", reps.getMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ public class FeieUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.error(reps.getMsg());
|
||||
logger.error("飞鹅打印操作失败:{}", reps.getMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public class FeieUtil {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("发送飞鹅接口请求失败:{}", e.getMessage());
|
||||
} finally {
|
||||
close(response, post, httpClient);
|
||||
}
|
||||
@ -266,17 +266,6 @@ public class FeieUtil {
|
||||
// 标题刚刚等于指定的长度(字节数)
|
||||
resultStr += "<L>" + title + "</L>" + otherStr;
|
||||
} 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);
|
||||
|
||||
@ -400,13 +389,15 @@ public class FeieUtil {
|
||||
* 分析标题能分几行显示,
|
||||
*
|
||||
* @param str
|
||||
* @param wordCnt 英文数字或中文的字数
|
||||
* @param wordCnt 英文数字或中文的字数,中文2个字节,英文数字1个字节
|
||||
* @return
|
||||
*/
|
||||
public List<String> getStrList(String str, int wordCnt) {
|
||||
// 分几行?
|
||||
int linesCnt = str.length() / wordCnt;
|
||||
if (str.length() % wordCnt != 0) {
|
||||
// 计算标题 wordCnt个字能分多少行?
|
||||
int len = str.length();
|
||||
// int len =asciiByteLen(str);
|
||||
int linesCnt = len / wordCnt;
|
||||
if (len % wordCnt != 0) {
|
||||
linesCnt += 1;
|
||||
}
|
||||
|
||||
@ -430,11 +421,6 @@ public class FeieUtil {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
// private static boolean isChineseChar(char c) {
|
||||
// return c >= 0x4E00 && c <= 0x9FFF;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
|
||||
@ -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,
|
||||
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,
|
||||
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
|
||||
from shop_order_base a
|
||||
inner join shop_order_info b on a.order_id=b.order_id
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
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,
|
||||
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>
|
||||
|
||||
</mapper>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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,
|
||||
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,
|
||||
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
|
||||
from shop_order_base a
|
||||
inner join shop_order_info b on a.order_id=b.order_id
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
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,
|
||||
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>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user