From f2b6fdd955f8ac6e5b351e0b5e3a9f583ed6da2e Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期四, 30 四月 2026 15:26:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java |  108 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 65 insertions(+), 43 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
index cf7f782..87cd2c6 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
@@ -26,6 +26,12 @@
 import com.doumee.dao.business.model.Orders;
 import com.doumee.dao.business.model.PricingRule;
 import com.doumee.dao.business.model.ShopInfo;
+import com.doumee.config.xyy.XyyConfig;
+import com.doumee.config.xyy.dto.AddPrinterRequest;
+import com.doumee.config.xyy.dto.AddPrinterRequestItem;
+import com.doumee.config.xyy.dto.DelPrinterRequest;
+import com.doumee.config.xyy.vo.ObjectRestResponse;
+import com.doumee.config.xyy.vo.PrinterResult;
 import com.doumee.dao.dto.*;
 import com.doumee.dao.system.model.SystemDictData;
 import com.doumee.dao.system.SystemUserMapper;
@@ -93,6 +99,12 @@
 
     @Autowired
     private SmsrecordMapper smsrecordMapper;
+
+    @Autowired
+    private PrintService printService;
+
+    @Autowired
+    private XyyConfig xyyConfig;
     @Override
     public Integer create(ShopInfo shopInfo) {
         shopInfoMapper.insert(shopInfo);
@@ -870,6 +882,7 @@
         vo.setFeeStandard(shop.getFeeStandard());
         vo.setLatitude(shop.getLatitude());
         vo.setLongitude(shop.getLongitude());
+        vo.setLinkPhone(shop.getLinkPhone());
 
         // 闂ㄥご鐓� + 鍐呴儴鐓� 鍏ㄨ矾寰勯泦鍚�
         String imgPrefix = getShopPrefix();
@@ -1082,6 +1095,7 @@
         // 瀛樹欢闂ㄥ簵
         List<Orders> depositSalesOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
                 .eq(Orders::getDeleted, Constants.ZERO)
+                .notIn(Orders::getStatus,Constants.OrderStatus.cancelled.getStatus(),Constants.OrderStatus.waitPay.getStatus())
                 .ge(Orders::getCreateTime, startTime)
                 .lt(Orders::getCreateTime, endTime)
                 .eq(Orders::getDepositShopId, shopId));
@@ -1089,6 +1103,7 @@
         List<Orders> takeSalesOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
                 .eq(Orders::getDeleted, Constants.ZERO)
                 .eq(Orders::getType,Constants.ONE)
+                .notIn(Orders::getStatus,Constants.OrderStatus.cancelled.getStatus(),Constants.OrderStatus.waitPay.getStatus())
                 .ge(Orders::getCreateTime, startTime)
                 .lt(Orders::getCreateTime, endTime)
                 .eq(Orders::getTakeShopId, shopId));
@@ -1161,7 +1176,10 @@
                 .last("limit 1")
         );
         if(shop==null){
-            throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT);
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇锋牳瀵圭櫥褰曟墜鏈哄彿鏄惁姝g‘");
+        }
+        if(Constants.equalsInteger(shop.getStatus(),Constants.ONE)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闂ㄥ簵宸茬鐢紝璇疯仈绯荤鐞嗗憳");
         }
         if(!Constants.equalsInteger(shop.getAuditStatus(),Constants.THREE)){
             if(Constants.equalsInteger(shop.getAuditStatus(),Constants.ONE)){
@@ -1219,6 +1237,9 @@
                 .last("limit 1"));
         if (shop == null) {
             return null;
+        }
+        if(Constants.equalsInteger(shop.getStatus(),Constants.ONE)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闂ㄥ簵宸茬鐢紝璇疯仈绯荤鐞嗗憳");
         }
         // 鍒涘缓token锛坓enerateTokenForRedis 宸茶嚜鍔ㄦ竻闄よ鐢ㄦ埛鏃oken锛屼繚璇佸敮涓�鏈夋晥锛�
         String token = JwtTokenUtil.generateTokenForRedis(shop.getId(), Constants.TWO, JSONObject.toJSONString(shop), redisTemplate);
@@ -1418,56 +1439,57 @@
         }
     }
 
-    @Autowired
-    private com.doumee.core.utils.xpyun.XpyunPrintService xpyunPrintService;
-
     @Override
-    public void bindPrinter(com.doumee.dao.dto.PrinterBindDTO dto) {
-        ShopInfo shop = shopInfoMapper.selectById(dto.getShopId());
+    public void maintainPrinterSn(ShopPrinterDTO dto) {
+        ShopInfo shop = shopInfoMapper.selectById(dto.getId());
         if (shop == null || Constants.equalsInteger(shop.getDeleted(), Constants.ONE)) {
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        // 璋冪敤鑺儴浜戞敞鍐屾墦鍗版満
-        com.doumee.core.utils.xpyun.XpyunResponse resp = xpyunPrintService.addPrinter(
-                dto.getPrinterSn(), shop.getName());
-        if (resp.getCode() != null && resp.getCode() == 0) {
-            log.info("鑺儴浜戞墦鍗版満娉ㄥ唽鎴愬姛: sn={}", dto.getPrinterSn());
-        } else {
-            log.warn("鑺儴浜戞墦鍗版満娉ㄥ唽杩斿洖闈�0: sn={}, code={}, msg={}",
-                    dto.getPrinterSn(), resp.getCode(), resp.getMsg());
+        String oldSn = shop.getPrinterSn();
+        String newSn = dto.getPrinterSn();
+        boolean hasNewSn = StringUtils.isNotBlank(newSn);
+        boolean hasOldSn = StringUtils.isNotBlank(oldSn);
+
+        if (!hasNewSn) {
+            // 鏈紶鎵撳嵃鏈篠N 鈫� 鍒犻櫎閫昏緫
+            if (hasOldSn) {
+                delPrinterFromXyy(oldSn);
+                shop.setPrinterSn(null);
+                shopInfoMapper.updateById(shop);
+            }
+            return;
         }
-        // 鏃犺浜戠鏄惁鎴愬姛锛岄兘缁戝畾鍒伴棬搴楋紙鍙悗缁噸璇曚簯绔敞鍐岋級
-        ShopInfo update = new ShopInfo();
-        update.setId(dto.getShopId());
-        update.setPrinterSn(dto.getPrinterSn());
-        shopInfoMapper.updateById(update);
+
+        // 浼犱簡鎵撳嵃鏈篠N 鈫� 濡傛灉鏃х粦瀹氬瓨鍦紝鍏堝垹闄�
+        if (hasOldSn) {
+            delPrinterFromXyy(oldSn);
+        }
+
+        // 缁戝畾鏂版墦鍗版満
+        AddPrinterRequest addReq = new AddPrinterRequest();
+        xyyConfig.createRequestHeader(addReq);
+        addReq.setItems(new AddPrinterRequestItem[]{new AddPrinterRequestItem() {{
+            setSn(newSn);
+            setName(shop.getName());
+        }}});
+        ObjectRestResponse<PrinterResult> addResp = printService.addPrinters(addReq);
+        if (addResp.getCode() != 0) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "缁戝畾鎵撳嵃鏈哄け璐ワ細" + addResp.getMsg());
+        }
+        log.info("缁戝畾鎴愬姛锛歿}", newSn);
+        shop.setPrinterSn(newSn);
+        shopInfoMapper.updateById(shop);
     }
 
-    @Override
-    public void unbindPrinter(Integer shopId) {
-        ShopInfo shop = shopInfoMapper.selectById(shopId);
-        if (shop == null || Constants.equalsInteger(shop.getDeleted(), Constants.ONE)) {
-            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+    private void delPrinterFromXyy(String sn) {
+        DelPrinterRequest delReq = new DelPrinterRequest();
+        xyyConfig.createRequestHeader(delReq);
+        delReq.setSnlist(new String[]{sn});
+        ObjectRestResponse<PrinterResult> delResp = printService.delPrinters(delReq);
+        if (delResp.getCode() != 0) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瑙g粦鎵撳嵃鏈哄け璐ワ細" + delResp.getMsg());
         }
-        if (StringUtils.isNotBlank(shop.getPrinterSn())) {
-            xpyunPrintService.deletePrinter(shop.getPrinterSn());
-        }
-        ShopInfo update = new ShopInfo();
-        update.setId(shopId);
-        update.setPrinterSn(null);
-        shopInfoMapper.updateById(update);
-    }
-
-    @Override
-    public Object queryPrinterStatus(Integer shopId) {
-        ShopInfo shop = shopInfoMapper.selectById(shopId);
-        if (shop == null || Constants.equalsInteger(shop.getDeleted(), Constants.ONE)) {
-            throw new BusinessException(ResponseStatus.DATA_EMPTY);
-        }
-        if (StringUtils.isBlank(shop.getPrinterSn())) {
-            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "璇ラ棬搴楁湭缁戝畾鎵撳嵃鏈�");
-        }
-        return xpyunPrintService.queryPrinterStatus(shop.getPrinterSn());
+        log.info("瑙g粦鎴愬姛锛歿}", sn);
     }
 
 }

--
Gitblit v1.9.3