From cf17c2f7012fc4351f66c71d66a4aa3a9fe9e34a Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期四, 30 四月 2026 15:24:17 +0800
Subject: [PATCH] 代码生成
---
server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java | 151 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 132 insertions(+), 19 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
index f087f1c..04cd73b 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
@@ -1,15 +1,19 @@
package com.doumee.service.business.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.doumee.biz.system.AreasBiz;
+import com.doumee.config.xyy.XyyConfig;
+import com.doumee.config.xyy.dto.PrintRequest;
import com.doumee.biz.system.OperationConfigBiz;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.config.wx.WxMiniConfig;
import com.doumee.config.wx.WxPayProperties;
import com.doumee.config.wx.WxPayV3Service;
+import com.doumee.core.utils.jpush.JPushUtil;
import com.wechat.pay.java.service.refund.model.Refund;
import com.doumee.core.constants.Constants;
import com.doumee.core.constants.ResponseStatus;
@@ -55,6 +59,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
+import java.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
/**
@@ -129,6 +134,9 @@
private AreasService areasService;
@Autowired
+ private AreasMapper aareasMapper;
+
+ @Autowired
private NoticeService noticeService;
@Autowired
@@ -139,6 +147,12 @@
@Autowired
private WxPayProperties wxPayProperties;
+
+ @Autowired
+ private XyyConfig xyyConfig;
+
+ @Autowired
+ private PrintService printService;
@Override
public Integer create(Orders orders) {
@@ -216,7 +230,6 @@
.leftJoin("shop_info s2 on s2.id = t.TAKE_SHOP_ID");
;
Utils.MP.blankToNull(pageWrap.getModel());
- pageWrap.getModel().setDeleted(Constants.ZERO);
queryWrapper.eq(pageWrap.getModel().getDeleted() != null, Orders::getDeleted, pageWrap.getModel().getDeleted());
queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCode()), Orders::getCode, pageWrap.getModel().getCode());
queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getDepositShopName()), "s1.name", pageWrap.getModel().getDepositShopName());
@@ -234,13 +247,7 @@
queryWrapper.eq(pageWrap.getModel().getAcceptDriver() != null, Orders::getAcceptDriver, pageWrap.getModel().getAcceptDriver());
queryWrapper.and(pageWrap.getModel().getShopId() != null, i -> i.eq(Orders::getDepositShopId, pageWrap.getModel().getShopId())
.or().eq(Orders::getTakeShopId, pageWrap.getModel().getShopId()));
- for (PageWrap.SortData sortData : pageWrap.getSorts()) {
- if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
- queryWrapper.orderByDesc(sortData.getProperty());
- } else {
- queryWrapper.orderByAsc(sortData.getProperty());
- }
- }
+ queryWrapper.orderByDesc(Orders::getId);
PageData<Orders> pageData = PageData.from(ordersMapper.selectJoinPage(page, Orders.class, queryWrapper));
for (Orders o : pageData.getRecords()) {
if (o.getStatus() != null) {
@@ -368,7 +375,7 @@
for (Category c : categories) {
categoryNameMap.put(c.getId(), c.getName());
categoryDetailMap.put(c.getId(), c.getDetail());
- categoryOtherFieldMap.put(c.getId(),c.getOtherField());
+ categoryOtherFieldMap.put(c.getId(),c.getRemark());
}
// 璁$畻姣忛」鐗╁搧璐圭敤锛氬皬璁� = 鍗曚环 脳 鏁伴噺 脳 澶╂暟
@@ -490,7 +497,7 @@
for (Category c : categories) {
categoryNameMap.put(c.getId(), c.getName());
categoryDetailMap.put(c.getId(), c.getDetail());
- categoryOtherFieldMap.put(c.getId(),c.getOtherField());
+ categoryOtherFieldMap.put(c.getId(),c.getRemark());
}
// 3. 閫愰」璁$畻杩愯垂锛氳捣姝ヤ环 + 瓒呭嚭閮ㄥ垎闃舵浠�
@@ -1600,12 +1607,13 @@
// 闂ㄥ簵寰呭鐞嗚鍗曪細鎸変笟鍔$幆鑺傚尯鍒嗛棬搴楄鑹�
if (combinedStatus != null && Constants.equalsInteger(combinedStatus, Constants.SEVEN)) {
wrapper.and(w -> w
- .and(w1 -> w1.eq(Orders::getDepositShopId, shopId)
+ .and(w1 -> w1.eq(Orders::getType, Constants.ZERO).eq(Orders::getDepositShopId, shopId)
.in(Orders::getStatus, Constants.OrderStatus.waitDeposit.getStatus(),
- Constants.OrderStatus.deposited.getStatus()))
- .or(w2 -> w2.eq(Orders::getTakeShopId, shopId)
- .in(Orders::getStatus, Constants.OrderStatus.delivering.getStatus(),
- Constants.OrderStatus.arrived.getStatus()))
+ Constants.OrderStatus.arrived.getStatus())
+ .or(w3-> w3.eq(Orders::getType, Constants.ONE).eq(Orders::getDepositShopId, shopId)
+ .eq(Orders::getStatus, Constants.OrderStatus.waitDeposit.getStatus()))
+ .or(w2 -> w2.eq(Orders::getType, Constants.ONE).eq(Orders::getTakeShopId, shopId)
+ .eq(Orders::getStatus, Constants.OrderStatus.arrived.getStatus())))
);
} else {
wrapper.and(w -> w.eq(Orders::getDepositShopId, shopId).or().eq(Orders::getTakeShopId, shopId));
@@ -2414,13 +2422,13 @@
// 6. 鎶奸噾鏀粯瀹屾垚鍚庯紝鑻ュ煄甯傛湭寮�閫氬垯鑷姩寮�閫�
if (shopInfo.getAreaId() != null) {
- Areas shopArea = areasService.getById(shopInfo.getAreaId());
+ Areas shopArea = aareasMapper.selectById(shopInfo.getAreaId());
if (shopArea != null && shopArea.getParentId() != null) {
- Areas cityArea = areasService.getById(shopArea.getParentId());
+ Areas cityArea = aareasMapper.selectById(shopArea.getParentId());
if (cityArea != null && !Constants.equalsInteger(cityArea.getStatus(), Constants.ONE)) {
cityArea.setStatus(Constants.ONE);
cityArea.setEditDate(now);
- areasService.updateById(cityArea);
+ aareasMapper.updateById(cityArea);
areasService.cacheData();
}
}
@@ -2758,6 +2766,8 @@
// 寮傚湴瀵勫瓨 鈫� 寰呮姠鍗�
sendOrderNotice(order.getMemberId(), Constants.MemberOrderNotify.WAIT_GRAB, order.getId(),
"orderNo", order.getCode());
+ // 鎺ㄩ�侀�氱煡鍙告満
+ pushDriverNewOrder(order);
} else {
// 灏卞湴瀵勫瓨 鈫� 寰呭彇浠舵彁閱�
sendOrderNotice(order.getMemberId(), Constants.MemberOrderNotify.WAIT_PICKUP_REMIND, order.getId(),
@@ -2917,6 +2927,8 @@
// 寮傚湴瀵勫瓨 鈫� 寰呮姠鍗�
sendOrderNotice(order.getMemberId(), Constants.MemberOrderNotify.WAIT_GRAB, order.getId(),
"orderNo", order.getCode());
+ // 鎺ㄩ�侀�氱煡鍙告満
+ pushDriverNewOrder(order);
} else {
// 灏卞湴瀵勫瓨 鈫� 寰呭彇浠舵彁閱�
sendOrderNotice(order.getMemberId(), Constants.MemberOrderNotify.WAIT_PICKUP_REMIND, order.getId(),
@@ -3580,7 +3592,10 @@
* 渚涘垎椤电瓑宸叉煡璇㈡槑缁嗙殑涓氬姟鍦烘櫙澶嶇敤锛岄伩鍏嶉噸澶嶆煡璇�
*/
private OverdueFeeVO calculateOverdueFeeInternal(Orders order, List<OrdersDetail> details) {
- if (CollectionUtils.isEmpty(details)) {
+ if (CollectionUtils.isEmpty(details)||
+ Constants.equalsInteger(order.getStatus(),Constants.ZERO)
+ || Constants.equalsInteger(order.getStatus(),Constants.ONE)
+ ) {
OverdueFeeVO vo = new OverdueFeeVO();
vo.setOverdue(false);
vo.setOverdueDays(0);
@@ -4107,4 +4122,102 @@
}
}
+ @Override
+ public void printOrderLabel(Integer orderId, Integer shopId) {
+ Orders orders = ordersMapper.selectById(orderId);
+ if (orders == null) {
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "璁㈠崟涓嶅瓨鍦�");
+ }
+ if (!Constants.equalsInteger(orders.getDepositShopId(), shopId)) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠闂ㄥ簵涓嶆槸璇ヨ鍗曠殑瀛樹欢闂ㄥ簵");
+ }
+ if (orders.getStatus() < 2 || orders.getStatus() > 5) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠璁㈠崟鐘舵�佷笉鍏佽鎵撳嵃");
+ }
+ ShopInfo shop = shopInfoMapper.selectById(shopId);
+ if (shop == null) {
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀛樹欢闂ㄥ簵涓嶅瓨鍦�");
+ }
+ if (StringUtils.isBlank(shop.getPrinterSn())) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀛樹欢闂ㄥ簵鏈粦瀹氭墦鍗版満");
+ }
+ List<OrdersDetail> detailList = ordersDetailMapper.selectList(
+ new QueryWrapper<OrdersDetail>().lambda().eq(OrdersDetail::getOrderId, orderId));
+ // 鎷兼帴瀹㈡埛淇℃伅
+ String userInfo = "";
+ if (StringUtils.isNotBlank(orders.getTakeUser())) {
+ String phone = orders.getTakePhone();
+ userInfo = orders.getTakeUser();
+ if (StringUtils.isNotBlank(phone) && phone.length() >= 4) {
+ userInfo += "锛�" + phone.substring(phone.length() - 4) + "锛�";
+ }
+ }
+ String content = printService.getPrintContent(shop.getName(), detailList, userInfo, orders.getCode(), orders.getRemark(),
+ orders.getTakeLocationRemark(),
+ orders.getPayTime() != null ? new SimpleDateFormat("yyyy-MM-dd HH:mm").format(orders.getPayTime()) : "",
+ orders.getExpectedTakeTime() != null ? new SimpleDateFormat("yyyy-MM-dd HH:mm").format(orders.getExpectedTakeTime()) : "");
+ if (StringUtils.isBlank(content)) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鎵撳嵃鍐呭涓虹┖");
+ }
+ PrintRequest request = new PrintRequest();
+ xyyConfig.createRequestHeader(request);
+ request.setSn(shop.getPrinterSn());
+ request.setContent(content);
+ request.setCopies(1);
+ request.setVoice(2);
+ request.setMode(0);
+ com.doumee.config.xyy.vo.ObjectRestResponse<String> resp = printService.printLabel(request);
+ if (resp.getCode() != 0) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鎵撳嵃澶辫触锛�" + resp.getMsg());
+ }
+ log.info("璁㈠崟鏍囩鎵撳嵃鎴愬姛: orderId={}, orderIndex={}", orderId, resp.getData());
+ }
+
+ /**
+ * 寮傚湴璁㈠崟瀵勫瓨鎴愬姛鍚庢帹閫侀�氱煡缁欏徃鏈�
+ * 1銆佹湭鍔犳�ワ細鎺ㄩ�佸悓鍩庝笖闂ㄥ簵閰嶉�佽寖鍥村唴鎺ュ崟涓殑鍙告満
+ * 2銆佸姞鎬ワ細鎺ㄩ�佸悓鍩庢墍鏈夋帴鍗曚腑鐨勫徃鏈�
+ * 鍩庡競鍖归厤锛氬徃鏈篈REA_ID鍏宠仈areas琛紝閫愮骇parent_id鎵惧埌鍩庡競绾э紝涓庤鍗昪ityId鍖归厤
+ */
+ private void pushDriverNewOrder(Orders order) {
+ ShopInfo shop = shopInfoMapper.selectById(order.getDepositShopId());
+ if (shop == null || shop.getLongitude() == null || shop.getLatitude() == null) {
+ return;
+ }
+ String orderCityId = order.getCityId();
+ if (StringUtils.isBlank(orderCityId)) {
+ return;
+ }
+ String distSql = "(ST_Distance_Sphere(POINT(t.LONGITUDE, t.LATITUDE), POINT(" + shop.getLongitude() + ", " + shop.getLatitude() + ")) / 1000)";
+ // MPJ鍏宠仈鏌ヨ锛氬徃鏈� 鈫� areas(鍖哄幙) 鈫� areas_city(鍩庡競)锛屽尮閰嶈鍗昪ityId
+ MPJLambdaWrapper<DriverInfo> wrapper = new MPJLambdaWrapper<>();
+ wrapper.selectAll(DriverInfo.class)
+ .leftJoin(Areas.class,Areas::getId,DriverInfo::getAreaId)
+ .eq(DriverInfo::getAcceptingStatus, Constants.ONE)
+ .eq(DriverInfo::getStatus, Constants.ZERO)
+ .eq(DriverInfo::getDeleted, Constants.ZERO)
+ .eq(DriverInfo::getAuditStatus, Constants.THREE)
+ .eq(Areas::getParentId, orderCityId);
+ if (!Constants.equalsInteger(order.getIsUrgent(), Constants.ONE)) {
+ // 鏈姞鎬ワ細闂ㄥ簵閰嶉�佽寖鍥村唴
+ double rangeKm = shop.getDeliveryArea() != null ? shop.getDeliveryArea().doubleValue() : 5.0;
+ wrapper.apply(distSql + " <= {0}", rangeKm);
+ }
+ List<DriverInfo> drivers = driverInfoMapper.selectJoinList(DriverInfo.class, wrapper);
+ if (drivers.isEmpty()) {
+ return;
+ }
+ List<String> aliases = new ArrayList<>();
+ for (DriverInfo d : drivers) {
+ aliases.add(org.springframework.util.DigestUtils.md5DigestAsHex(d.getTelephone().getBytes()));
+ }
+ String title = Constants.equalsInteger(order.getIsUrgent(), Constants.ONE) ? "鏂板姞鎬ヨ鍗�" : "鏂拌鍗�";
+ String content = "璁㈠崟鍙凤細" + order.getCode();
+ java.util.Map<String, String> extras = new java.util.HashMap<>();
+ extras.put("orderId", String.valueOf(order.getId()));
+ extras.put("orderCode", order.getCode());
+ extras.put("type", "new_order");
+ JPushUtil.sendByAliases(aliases, title, content, extras);
+ }
+
}
--
Gitblit v1.9.3