fix:超市购物卡支付、选择钱包、称重商品小数精度不够的问题
This commit is contained in:
1 parent
b738fdc654
commit
8b5f776f1a
12 files changed
+125
-53
No files matched your search
+5
-2
@@ -28,6 +28,7 @@ public enum HardPayTypeEnum {
|
||||
ALI_SELF_QR_CODE_PAY("11", "支付宝付款码支付"),
|
||||
ZYY("12", "中医院"),
|
||||
RMYY("13", "人民医院"),
|
||||
CSXFK("14", "超市消费卡"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
@@ -42,7 +43,8 @@ public enum HardPayTypeEnum {
|
||||
WECHANT_SELF_QR_CODE_PAY,
|
||||
ALI_SELF_QR_CODE_PAY,
|
||||
ZYY,
|
||||
RMYY
|
||||
RMYY,
|
||||
CSXFK
|
||||
);
|
||||
|
||||
public static final List<HardPayTypeEnum> isNotWalletPay = List.of(
|
||||
@@ -62,7 +64,8 @@ public enum HardPayTypeEnum {
|
||||
public static final List<HardPayTypeEnum> isOffline = List.of(
|
||||
CASH,
|
||||
ZYY,
|
||||
RMYY
|
||||
RMYY,
|
||||
CSXFK
|
||||
);
|
||||
|
||||
public static HardPayTypeEnum valueOfByType(String type) {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class Drawing2D {
|
||||
* static const mm80_Old = 500;
|
||||
* static const mm80 = 570;
|
||||
*/
|
||||
private final int canvasWidth = 340;
|
||||
private final int canvasWidth = 365;
|
||||
private final int canvasHeight = 200;
|
||||
|
||||
private int currentWidth = canvasWidth;
|
||||
|
||||
+8
@@ -4,6 +4,8 @@ import com.bsd.pjcloud.admin.api.vo.base.BaseUserDeptInterface;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
|
||||
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
|
||||
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletInterface;
|
||||
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -61,4 +63,10 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserDeptInterfac
|
||||
private Long afterSaleId;
|
||||
|
||||
private String afterSaleNo;
|
||||
|
||||
/**
|
||||
* 钱包相关
|
||||
*/
|
||||
private String walletTypeUniqueCode;
|
||||
|
||||
}
|
||||
-12
@@ -13,31 +13,21 @@ public interface HardInvoiceService extends IService<HardInvoiceEntity> {
|
||||
|
||||
/**
|
||||
* 生成发票
|
||||
* @param order
|
||||
* @return 订单详情
|
||||
*/
|
||||
String generateInvoice(HardOrderEntity order);
|
||||
|
||||
/**
|
||||
* 生成发票
|
||||
* @param order 订单详情
|
||||
* @param code 取消码
|
||||
* @return
|
||||
*/
|
||||
String generateInvoice(HardOrderEntity order, String code);
|
||||
|
||||
/**
|
||||
* 生成发票图片
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
HardInvoiceVo generateInvoice(Long orderId);
|
||||
|
||||
/**
|
||||
* 打印成功通知
|
||||
* @param orderId
|
||||
* @param historyId
|
||||
* @return
|
||||
*/
|
||||
Boolean printInvoice(Long orderId, Long historyId);
|
||||
|
||||
@@ -45,8 +35,6 @@ public interface HardInvoiceService extends IService<HardInvoiceEntity> {
|
||||
|
||||
/**
|
||||
* 根据订单信息打印
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
Boolean printByOrder(HardOrderEntity order);
|
||||
}
|
||||
+23
-2
@@ -39,9 +39,12 @@ import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.mqtt.api.feign.RemoteMqttEventService;
|
||||
import com.bsd.pjcloud.mqtt.dto.hard.HardPrintMsg;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
@@ -83,6 +86,7 @@ public class HardInvoiceServiceImpl extends ServiceImpl<HardInvoiceMapper, HardI
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteDeptService deptService;
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteWalletService walletService;
|
||||
private final RemoteFileService fileService;
|
||||
private final RemoteMqttEventService mqttEventService;
|
||||
|
||||
@@ -152,6 +156,20 @@ public class HardInvoiceServiceImpl extends ServiceImpl<HardInvoiceMapper, HardI
|
||||
if (ObjectUtil.isNotEmpty(sysTypeEnum)) {
|
||||
hardwareName = sysTypeEnum.getDescription();
|
||||
}
|
||||
// 钱包类型
|
||||
String walletTypeName = "";
|
||||
WalletManageVo wallet = walletService.getWalletById(order.getWalletId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(wallet) && ObjectUtil.isNotEmpty(wallet.getWalletTypeUniqueCode())) {
|
||||
try {
|
||||
WalletTypeEnum walletTypeEnum = WalletTypeEnum.valueOfByCode(wallet.getWalletTypeUniqueCode());
|
||||
if (ObjectUtil.isNotEmpty(walletTypeEnum)) {
|
||||
walletTypeName = walletTypeEnum.getDesc();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|{}|钱包类型错误", TAG, e);
|
||||
}
|
||||
}
|
||||
Drawing2D drawing = new Drawing2D();
|
||||
drawing.setTitleTextStyle()
|
||||
.drawingCenterText(String.format("智慧%s", hardwareName))
|
||||
@@ -162,8 +180,11 @@ public class HardInvoiceServiceImpl extends ServiceImpl<HardInvoiceMapper, HardI
|
||||
.drawingRowText("订单号", order.getId().toString())
|
||||
.drawingRowText("订单类型", orderType)
|
||||
.drawingRowText("用户", username)
|
||||
.drawingRowText("手机号", userPhone)
|
||||
.drawingRowText("商户", mch.getName())
|
||||
.drawingRowText("手机号", userPhone);
|
||||
if (ObjectUtil.isNotEmpty(walletTypeName)) {
|
||||
drawing.drawingRowText("钱包类型", walletTypeName);
|
||||
}
|
||||
drawing.drawingRowText("商户", mch.getName())
|
||||
.drawingRowText("部门", mch.getDeptName())
|
||||
.drawingRowText("下单时间", createTime);
|
||||
if (ObjectUtil.isNotEmpty(payTime)) {
|
||||
|
||||
+64
-30
@@ -70,6 +70,7 @@ 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 com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -79,6 +80,8 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -88,6 +91,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
@@ -223,17 +227,22 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 默认使用该商户的钱包如果没有就用饭卡钱包
|
||||
WalletManageEntity wallet = null;
|
||||
if (isWalletPay) {
|
||||
if (ObjectUtil.isEmpty(mch.getDefaultWalletTypeId())) {
|
||||
if (dto.getSysType().equals(HardTypeEnum.CANTEEN)) {
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
if (ObjectUtil.isNotEmpty(dto.getWalletId()) && ObjectUtil.equals(dto.getSysType(), HardTypeEnum.SUPERMARKET)) {
|
||||
R<WalletManageVo> walletResult = remoteWalletService.getWalletById(dto.getWalletId());
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
} else {
|
||||
if (ObjectUtil.isEmpty(mch.getDefaultWalletTypeId())) {
|
||||
if (dto.getSysType().equals(HardTypeEnum.CANTEEN)) {
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
} else {
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.PAY);
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
}
|
||||
} else {
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.PAY);
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), mch.getDefaultWalletTypeId());
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
}
|
||||
} else {
|
||||
R<WalletManageEntity> walletResult = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), mch.getDefaultWalletTypeId());
|
||||
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
|
||||
}
|
||||
if (ObjectUtil.isEmpty(wallet)) {
|
||||
throw new RuntimeException("用户钱包不存在");
|
||||
@@ -300,7 +309,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 现金支付
|
||||
if (isOffline) {
|
||||
// 更改为支付成功
|
||||
getSelf().orderSuccess(orderObj, Boolean.TRUE);
|
||||
getSelf().orderSuccess(orderObj, Boolean.FALSE);
|
||||
}
|
||||
// 微信支付
|
||||
if (isWeChatPay) {
|
||||
@@ -970,7 +979,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
*/
|
||||
@Override
|
||||
public boolean isPay(HardOrderTypeEnum type, HardPayTypeEnum payType) {
|
||||
if (ObjectUtil.equals(type, HardOrderTypeEnum.BELOW) && ObjectUtil.equals(payType, HardPayTypeEnum.CASH)) {
|
||||
if (ObjectUtil.equals(type, HardOrderTypeEnum.BELOW) && HardPayTypeEnum.isOffline.contains(payType)) {
|
||||
return false;
|
||||
}
|
||||
if (!HardOrderTypeEnum.isPay(type)) {
|
||||
@@ -1064,32 +1073,56 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
|
||||
private void disposeList(List<HardOrderVo> list, HardOrderDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
// 用户部门
|
||||
List<Long> userIds = list.stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
List<UserVO> userList = userService.getUserDeptByIds(new ArrayList<>(userIds)).getData();
|
||||
if (ObjectUtil.isNotEmpty(userList)) {
|
||||
DataUtil.convertUserDeptList(list, CollectionUtils.convertMap(userList, UserVO::getUserId));
|
||||
CompletableFuture<Void> deptFuture = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
List<Long> userIds = list.stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
List<UserVO> userList = userService.getUserDeptByIds(new ArrayList<>(userIds)).getData();
|
||||
if (ObjectUtil.isNotEmpty(userList)) {
|
||||
DataUtil.convertUserDeptList(list, CollectionUtils.convertMap(userList, UserVO::getUserId));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 商户
|
||||
List<Long> mchIds = list.stream().map(HardOrderVo::getMerchantId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(mchIds)) {
|
||||
R<List<MchManageVo>> mchList = remoteMchService.getByIds(mchIds);
|
||||
if (ObjectUtil.isNotEmpty(mchList.getData())) {
|
||||
WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId));
|
||||
CompletableFuture<Void> mchFuture = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
List<Long> mchIds = list.stream().map(HardOrderVo::getMerchantId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(mchIds)) {
|
||||
R<List<MchManageVo>> mchList = remoteMchService.getByIds(mchIds);
|
||||
if (ObjectUtil.isNotEmpty(mchList.getData())) {
|
||||
WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设备
|
||||
List<Long> hardIds = list.stream().map(HardOrderVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(mchIds)) {
|
||||
HardManagerDto hardManagerDto = new HardManagerDto();
|
||||
hardManagerDto.setIds(hardIds);
|
||||
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
|
||||
if (ObjectUtil.isNotEmpty(hardList)) {
|
||||
HardUtil.convertHardList(list, CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
|
||||
CompletableFuture<Void> deviceFuture = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
List<Long> hardIds = list.stream().map(HardOrderVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(hardIds)) {
|
||||
HardManagerDto hardManagerDto = new HardManagerDto();
|
||||
hardManagerDto.setIds(hardIds);
|
||||
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
|
||||
if (ObjectUtil.isNotEmpty(hardList)) {
|
||||
HardUtil.convertHardList(list, CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 钱包
|
||||
CompletableFuture<Void> walletFuture = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
List<Long> walletIds = list.stream().map(HardOrderVo::getWalletId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(walletIds)) {
|
||||
List<WalletManageVo> walletList = remoteWalletService.getWalletByIds(walletIds).getData();
|
||||
Map<Long, WalletManageVo> walletMap = CollectionUtils.convertMap(walletList, WalletManageVo::getId);
|
||||
for (HardOrderVo v : list) {
|
||||
WalletManageVo target = walletMap.get(v.getWalletId());
|
||||
if (ObjectUtil.isEmpty(target)) continue;
|
||||
v.setWalletTypeUniqueCode(target.getWalletTypeUniqueCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
// 购物车
|
||||
if (dto.getIsFindCarList()) {
|
||||
for (HardOrderVo v : list) {
|
||||
@@ -1098,5 +1131,6 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
v.setCarList(carVoList);
|
||||
}
|
||||
}
|
||||
CompletableFuture.allOf(deptFuture, mchFuture, deviceFuture, walletFuture).join();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -33,8 +33,8 @@ public class HardSyncServiceImpl implements HardSyncService {
|
||||
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("当前登录用户错误");
|
||||
Long deptId = user.getDeptId();
|
||||
// 查询该用户属于的超市
|
||||
MchManageVo targetMch = remoteMchService.getFirstMchByDeptId(deptId, MerchantTypeEnum.CANTEEN).getData();
|
||||
if (ObjectUtil.isEmpty(targetMch) || ObjectUtil.notEqual(targetMch.getTypes(), MerchantTypeEnum.CANTEEN.getType())) {
|
||||
MchManageVo targetMch = remoteMchService.getFirstMchByDeptId(deptId, MerchantTypeEnum.SELF_SUPERMARKET).getData();
|
||||
if (ObjectUtil.isEmpty(targetMch) || ObjectUtil.notEqual(targetMch.getTypes(), MerchantTypeEnum.SELF_SUPERMARKET.getType())) {
|
||||
throw new RuntimeException("您不是超市用户,无法操作");
|
||||
}
|
||||
mqttEventService.sendSupermarket(List.of(deptId));
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public interface RemoteMqttEventService {
|
||||
R<Boolean> sendSupermarketClassifyChangeMsg(@RequestParam Long deptId);
|
||||
|
||||
/**
|
||||
* 超市分类变化
|
||||
* 超市同步
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/mqtt/send-supermarket")
|
||||
|
||||
+6
-3
@@ -102,15 +102,18 @@ public class MqttEventController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 超市分类变化
|
||||
* 超市同步
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/send-supermarket")
|
||||
public R<Boolean> sendSupermarket(@RequestParam List<Long> deptIdList) {
|
||||
if (ObjectUtil.isNotEmpty(deptIdList)) return R.failed(false);
|
||||
if (ObjectUtil.isEmpty(deptIdList)) return R.failed(false);
|
||||
for (Long v : deptIdList) {
|
||||
MqttBaseDto dto = new MqttBaseDto<>();
|
||||
if (ObjectUtil.isNotEmpty(v)) dto.setMerchantDeptId(v);
|
||||
if (ObjectUtil.isNotEmpty(v)) {
|
||||
mqttEventService.getTopicParamsByUserDeptId(dto, v);
|
||||
dto.setMerchantDeptId(v);
|
||||
}
|
||||
dto.setAction(MqttActionEnum.SUPERMARKET);
|
||||
mqttEventService.defaultAction(dto);
|
||||
}
|
||||
|
||||
+1
@@ -121,6 +121,7 @@ public class WalletManageEntity extends Model<WalletManageEntity> {
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
|
||||
+4
@@ -32,6 +32,10 @@ public interface RemoteWalletService {
|
||||
@GetMapping("/wallet-manage/get-wallet-by-id")
|
||||
R<WalletManageVo> getWalletById(@RequestParam Long walletId);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/wallet-manage/get-wallet-by-ids")
|
||||
R<List<WalletManageVo>> getWalletByIds(@RequestParam List<Long> walletIds);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/wallet-manage/get-wallet-by-phone")
|
||||
R<WalletManageVo> getWalletByUserPhone(@RequestParam String phone, @RequestParam WalletTypeEnum walletTypeCode);
|
||||
|
||||
+10
@@ -108,6 +108,16 @@ public class WalletManageController {
|
||||
return R.ok(wallet);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/get-wallet-by-ids")
|
||||
public R<List<WalletManageVo>> getWalletByIds(@RequestParam List<Long> walletIds) {
|
||||
WalletManageDto dto = new WalletManageDto();
|
||||
dto.setWalletIds(walletIds);
|
||||
List<WalletManageVo> wallet = walletManageService.scopeList(dto, null);
|
||||
if (ObjectUtil.isEmpty(wallet)) return R.failed("钱包不存在");
|
||||
return R.ok(wallet);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/get-wallet-by-phone")
|
||||
public R<WalletManageVo> getWalletByUserPhone(@RequestParam String phone, @RequestParam WalletTypeEnum walletTypeCode) {
|
||||
|
||||
Reference in new issue
Block a user