Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-03-20 14:03:51 +08:00
commit 8693596d5f
6 files changed
+72 -28

No files matched your search

@@ -30,7 +30,7 @@ public class Drawing2D {
private final int horizontalPadding = 20;
private final String fontFamily = "SimSun";
private final String fontFamily = "黑体";
/**
* end ****************** config ****************** end
@@ -134,13 +134,13 @@ public class Drawing2D {
public Drawing2D setTitleTextStyle() {
graphics.setColor(Color.BLACK);
graphics.setFont(new Font(fontFamily, Font.BOLD, 24));
graphics.setFont(new Font(fontFamily, Font.PLAIN, 26));
return this;
}
public Drawing2D setDefaultStyle() {
graphics.setColor(Color.BLACK);
graphics.setFont(new Font(fontFamily, Font.PLAIN, 20));
graphics.setFont(new Font(fontFamily, Font.PLAIN, 22));
return this;
}
@@ -9,7 +9,6 @@ import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.excel.HardOrderExcelVo;
import jakarta.validation.Valid;
import java.util.List;
@@ -28,24 +27,16 @@ public interface HardOrderService extends IService<HardOrderEntity> {
/**
* 创建app订单
*
* @param dto 父订单id
* @return
*/
Long appCreateOrder(@Valid HardAppCreateOrderDto dto);
/**
* 快速扣款
*
* @param order 订单详情
* 快速扣款,离线订单使用
*/
void fastReduceBalance(HardOrderEntity order);
/**
* 计算额外金额
*
* @param price 购物车总价
* @return
*/
Integer computeExtraPrice(Integer price);
@@ -61,16 +52,16 @@ public interface HardOrderService extends IService<HardOrderEntity> {
/**
* 扣减库存
*
* @param isReduce true 扣件库存 false增加库存
*/
void fastenerInventory(HardOrderEntity order, YesNoEnum isReduce);
/**
* 核销硬件二维码
*
* @param dto
* @return
*/
Boolean handCancelCode(HandCancelCodeDto dto);
/**
* 创建订单后发送mq消息
*/
void createOrderAfterSendMqMsg(Long orderId);
}
@@ -31,7 +31,10 @@ public class HardApiServiceImpl implements HardApiService {
UserInfo user = userService.getByUserId(userId).getData();
if (ObjectUtil.isEmpty(user)) return null;
// 查询钱包
WalletTypeEnum walletType = ObjectUtil.equals(HardTypeEnum.CANTEEN, type) ? WalletTypeEnum.EAT : WalletTypeEnum.PAY;
// WalletTypeEnum walletType = ObjectUtil.equals(HardTypeEnum.CANTEEN, type) ? WalletTypeEnum.EAT : WalletTypeEnum.PAY;
// 默认都使用饭卡钱包
WalletTypeEnum walletType = WalletTypeEnum.EAT;
WalletManageEntity wallet = remoteWalletService.getWallet(userId, walletType).getData();
if (ObjectUtil.isEmpty(wallet)) return null;
SysUser sysUser = user.getSysUser();
@@ -34,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -165,8 +166,14 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
for (HardCreateCarDto v : list) {
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
Integer price = getSupermarket(spu);
int itemTotalPrice = v.getProductCount() * price;
supermarketTotalPrice.addAndGet(itemTotalPrice);
if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) {
int itemTotalPrice = v.getProductCount() * price;
supermarketTotalPrice.addAndGet(itemTotalPrice);
} else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
// 向上取整
int itemTotalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue();
supermarketTotalPrice.addAndGet(itemTotalPrice);
}
});
}
yield supermarketTotalPrice.get();
@@ -245,7 +252,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
item.setProductPic(spu.getPicUrl());
item.setTotalPrice((long) totalPrice);
item.setProductCount(v.getProductCount());
item.setProductWeight(new BigDecimal(0));
item.setProductWeight(v.getProductWeight());
carObjectList.add(item);
});
}
@@ -301,6 +308,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
);
}
// 获取超市商品价格
private Integer getSupermarket(SmErpUnitWithSpuVo vo) {
if (ObjectUtil.isEmpty(vo)) return 0;
if (ObjectUtil.isNotEmpty(vo.getPromotionPrice()) && !ObjectUtil.equals(vo.getPromotionPrice(), 0)) {
@@ -37,6 +37,7 @@ import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.service.HardCarService;
import com.bsd.pjcloud.hard.service.HardInvoiceService;
import com.bsd.pjcloud.hard.service.HardManagerService;
import com.bsd.pjcloud.hard.service.HardOrderService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService;
@@ -51,11 +52,12 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.feign.*;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -67,6 +69,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
/**
* 订单表
@@ -85,6 +88,8 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final HardManagerService hardManagerService;
private final HardCarService hardCarService;
private final HardParentCarServiceImpl hardParentCarServiceImpl;
@Lazy
private final HardInvoiceService hardInvoiceService;
private final RemoteMchService remoteMchService;
private final RemoteCodeUseService remoteCodeUseService;
@@ -265,10 +270,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
.build();
if (isPay) orderObj.setWalletId(wallet.getId());
baseMapper.insert(orderObj);
// 钱包扣款
if (isPay) getSelf().fastReduceBalance(orderObj);
// 扣减库存
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
// 钱包扣款
if (isPay) getSelf().fastReduceBalance(orderObj);
// 发送mq消息
getSelf().createOrderAfterSendMqMsg(orderObj.getId());
return orderObj.getId();
}
@@ -475,8 +482,15 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
List<SupermarketSpuUpdateStockReqDTO.Item> list = carList.stream().map(v -> {
SupermarketSpuUpdateStockReqDTO.Item item = new SupermarketSpuUpdateStockReqDTO.Item();
item.setId(v.getProductId());
double weight = BigDecimal.valueOf(v.getProductCount()).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
item.setIncrCount(weight);
if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) {
// 按数量
double count = BigDecimal.valueOf(v.getProductCount()).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
item.setIncrCount(count);
} else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
// 按重量
double weight = v.getProductWeight().multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
item.setIncrCount(weight);
}
return item;
}).toList();
dto.setItems(list);
@@ -490,6 +504,34 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
}
// 发送mq消息
@Override
public void createOrderAfterSendMqMsg(Long orderId) {
try {
HardOrderEntity orderdetail = baseMapper.selectById(orderId);
if (ObjectUtil.isEmpty(orderdetail)) {
log.error("|{}|发送mq消息失败,订单不存在orderId|{}|", TAG, orderId);
return;
}
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(orderdetail.getSysType());
if (ObjectUtil.isEmpty(hardTypeEnum)) {
log.error("|{}|发送mq消息失败,设备类型错误hardType不存在hardType|{}|", TAG, orderdetail.getSysType());
return;
}
switch (hardTypeEnum) {
// 超市需要打印订单
case SUPERMARKET -> {
Boolean isPrint = hardInvoiceService.printByOrder(orderdetail);
if (isPrint) {
log.info("|{}|发送mq消息成功,超市打印发票order|{}|", TAG, JSON.toJSONString(orderId));
}
}
}
} catch (Exception e) {
log.info("|{}|发送mq消息成功,意外的错误error|{}|", TAG, e.getMessage());
}
}
// 二维码类型的订单是否被核销 true被核销 false未核销
private boolean validateCodeIsCancel(HardOrderTypeEnum orderType, Long orderId) {
Boolean flag = switch (orderType) {
@@ -95,6 +95,6 @@
AND es.product_nature = #{supermarketSpuQueryDTO.productNature}
</if>
</where>
ORDER BY es.sort DESC
ORDER BY es.sort DESC,es.id DESC
</select>
</mapper>