Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c3a4b82573
34 files changed
+374
-71
No files matched your search
+1
-1
@@ -191,7 +191,7 @@ public class CanteenOnlineSpuController {
|
||||
*/
|
||||
@Operation(summary = "通过ids查询", description = "通过ids查询")
|
||||
@PostMapping("/app/getSpuListByIds")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')")
|
||||
// @PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')")
|
||||
public R<List<CanteenOnlineSpuAppVO>> getByIds(@RequestBody List<Long> ids) {
|
||||
List<CanteenOnlineSpuEntity> list = canteenOnlineSpuService.list(new LambdaQueryWrapper<CanteenOnlineSpuEntity>().in(CanteenOnlineSpuEntity::getId, ids));
|
||||
List<CanteenOnlineSpuAppVO> canteenOnlineSpuAppVOS = BeanUtils.toBean(list, CanteenOnlineSpuAppVO.class);
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -70,10 +71,10 @@ public class OfflineOrder {
|
||||
private Double weight;
|
||||
|
||||
@Schema(description = "支付时间")
|
||||
private String payTime;
|
||||
private LocalDateTime payTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "购物车列表")
|
||||
private List<OfflineCar> carList;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.hard;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardOfflinePayDto {
|
||||
|
||||
private List<Long> orderIds;
|
||||
|
||||
}
|
||||
+5
@@ -48,4 +48,9 @@ public class HardOrderDto extends HardOrderEntity implements BaseIsIncludeTreeIn
|
||||
*/
|
||||
private Boolean isFindCarList = false;
|
||||
|
||||
/**
|
||||
* 退款相关
|
||||
*/
|
||||
private String afterSaleNo;
|
||||
|
||||
}
|
||||
+8
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.hard.api.feign;
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDetailDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.WaterDto;
|
||||
@@ -41,4 +42,11 @@ public interface RemoteHardThirdPayService {
|
||||
@NoToken
|
||||
@PostMapping("/hard-third-pay/water")
|
||||
PayBaseVo<List<PayWaterVo>> waterList(@RequestBody WaterDto dto, @RequestParam ThirdPaySoureBizTypeEnum soureType);
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/hard-third-pay/detail")
|
||||
PayBaseVo<PayWaterVo> orderDetail(@RequestBody PayDetailDto dto, @RequestParam ThirdPaySoureBizTypeEnum soureType);
|
||||
}
|
||||
+7
@@ -51,4 +51,11 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B
|
||||
* 预约二维码信息
|
||||
*/
|
||||
private String reserveCode;
|
||||
|
||||
/**
|
||||
* 退款相关
|
||||
*/
|
||||
private Long afterSaleId;
|
||||
|
||||
private String afterSaleNo;
|
||||
}
|
||||
+1
-1
@@ -96,7 +96,7 @@ public class HardApiController {
|
||||
|
||||
@PostMapping("/sync-offline-order")
|
||||
@Operation(summary = "同步离线订单")
|
||||
@Idempotent(expireTime = 10, info = "正在处理中,请勿重复操作")
|
||||
@Idempotent(expireTime = 1, info = "正在处理中,请勿重复操作")
|
||||
public R<List<String>> syncOfflineOrder(@Valid @RequestBody SyncOfflineReqVo dto) {
|
||||
return R.ok(hardOrderSyncService.syncOfflineOrder(dto));
|
||||
}
|
||||
|
||||
+12
-1
@@ -28,6 +28,7 @@ import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.app.HardAppCreateOrderScancode;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.CurrentUserHardTypeInfoDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HardOfflinePayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderPreferencesDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
|
||||
@@ -37,6 +38,7 @@ import com.bsd.pjcloud.hard.api.vo.order.excel.HardOrderExcelVo;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderSyncService;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
@@ -73,6 +75,7 @@ public class HardOrderController {
|
||||
|
||||
private final HardOrderService hardwareOrderService;
|
||||
private final HardManagerService hardManagerService;
|
||||
private final HardOrderSyncService hardOrderSyncService;
|
||||
|
||||
private final HardOrderMapper hardOrderMapper;
|
||||
|
||||
@@ -227,6 +230,14 @@ public class HardOrderController {
|
||||
return R.ok(hardwareOrderService.join(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "离线订单手动支付", description = "离线订单手动支付")
|
||||
@PostMapping("/offline-pay")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_offlinePay')")
|
||||
public R offlinePay(@RequestBody HardOfflinePayDto dto) {
|
||||
hardOrderSyncService.offlinePay(dto.getOrderIds());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_export')")
|
||||
public void export(HttpServletResponse response, HardOrderDto dto) throws IOException {
|
||||
@@ -246,7 +257,7 @@ public class HardOrderController {
|
||||
dto.setMchIds(mchDtoIds);
|
||||
}
|
||||
}
|
||||
List<HardOrderVo> list = hardwareOrderService.scopeList(dto);
|
||||
List<HardOrderVo> list = hardwareOrderService.scopeList(dto, DataScope.of());
|
||||
List<HardOrderExcelVo> excelList = BeanUtils.toBean(list, HardOrderExcelVo.class);
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/订单交易汇总.xlsx")).build()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
|
||||
+9
@@ -4,6 +4,7 @@ import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.hard.service.HardThirdPayService;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDetailDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.WaterDto;
|
||||
@@ -54,4 +55,12 @@ public class HardThirdPayController {
|
||||
return hardThirdPayService.waterList(dto, soureType);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@PostMapping("/detail")
|
||||
@SysLog("订单详情")
|
||||
@Operation(summary = "订单详情")
|
||||
public PayBaseVo<PayWaterVo> orderDetail(@RequestBody PayDetailDto dto, @RequestParam ThirdPaySoureBizTypeEnum soureType) {
|
||||
return hardThirdPayService.orderDetail(dto, soureType);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleLogDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleLogEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleLogVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
+17
@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardChartLatitudeVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderSumAndCountDto;
|
||||
@@ -89,12 +91,27 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
return selectJoinOne(HardOrderVo.class, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询离线订单
|
||||
*/
|
||||
default List<HardOrderEntity> getOfflineOrderList(List<Long> orderIds) {
|
||||
LambdaQueryWrapper<HardOrderEntity> wrapper = new LambdaQueryWrapper<HardOrderEntity>()
|
||||
.in(HardOrderEntity::getId, orderIds)
|
||||
.eq(HardOrderEntity::getOrderStatus, HardOrderStatusEnum.OFFLINE_CREATE.getType())
|
||||
.eq(HardOrderEntity::getIsOfflineOrder, YesNoEnum.YES.getCode())
|
||||
.orderByDesc(HardOrderEntity::getCreateTime)
|
||||
.orderByDesc(HardOrderEntity::getId);
|
||||
return selectList(wrapper);
|
||||
}
|
||||
|
||||
default List<HardOrderEntity> list(HardOrderDto dto) {
|
||||
return selectListByScope(commonWrapper(dto), DataScope.of());
|
||||
}
|
||||
|
||||
Page<HardOrderVo> scopePageList(Page page, @Param("dto") HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
List<HardOrderVo> scopeList(@Param("dto") HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
List<HardOrderSbVo> listSb(@Param("dto") HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
List<HardOrderCsVo> listCs(@Param("dto") HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
|
||||
Page<HardOrderVo> scopePageList(Page page, HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
List<HardOrderVo> scopeList(HardOrderDto dto);
|
||||
List<HardOrderVo> scopeList(HardOrderDto dto, DataScope dataScope);
|
||||
|
||||
HardOrderVo join(Long id);
|
||||
|
||||
|
||||
+4
@@ -14,4 +14,8 @@ public interface HardOrderSyncService {
|
||||
*/
|
||||
List<String> syncOfflineOrder(@Valid SyncOfflineReqVo dto);
|
||||
|
||||
/**
|
||||
* 离线订单手动支付
|
||||
*/
|
||||
void offlinePay(List<Long> orderIds);
|
||||
}
|
||||
+6
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.service;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDetailDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.WaterDto;
|
||||
@@ -28,4 +29,9 @@ public interface HardThirdPayService {
|
||||
* 获取流水
|
||||
*/
|
||||
PayBaseVo<List<PayWaterVo>> waterList(WaterDto dto, ThirdPaySoureBizTypeEnum soureType);
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
PayBaseVo<PayWaterVo> orderDetail(PayDetailDto dto, ThirdPaySoureBizTypeEnum soureType);
|
||||
}
|
||||
+1
-1
@@ -349,7 +349,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(flowDetail.getId()).flowStatus(HardDoorFlowEnum.FLOW_CALLBACK_RECOGNITION.getType()).skuCallbackVo(JSONUtil.toJsonStr(dto)).skuCallbackTime(LocalDateTime.now()).build();
|
||||
String ksFlowCode = dto.getState().getCode();
|
||||
String ksRecognitionCode = dto.getResult().getStatus().getCode();
|
||||
if (ObjectUtil.notEqual(ksFlowCode, "2") || ObjectUtil.notEqual(ksFlowCode, "5") || ObjectUtil.notEqual(ksRecognitionCode, "2")) {
|
||||
if (!List.of("2", "5").contains(ksFlowCode) || !List.of("2").contains(ksRecognitionCode)) {
|
||||
if (ObjectUtil.equals(ksFlowCode, "2") && ObjectUtil.equals(ksRecognitionCode, "3")) {
|
||||
// 未拿商品取消订单
|
||||
hardOrderService.cancelHardDoorOrder(flowDetail.getOrderId());
|
||||
|
||||
+7
-40
@@ -124,11 +124,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HardOrderVo> scopeList(HardOrderDto dto) {
|
||||
List<HardOrderEntity> list = baseMapper.list(dto);
|
||||
List<HardOrderVo> resultList = BeanUtils.toBean(list, HardOrderVo.class);
|
||||
disposeList(resultList, dto);
|
||||
return resultList;
|
||||
public List<HardOrderVo> scopeList(HardOrderDto dto, DataScope dataScope) {
|
||||
List<HardOrderVo> list = baseMapper.scopeList(dto, dataScope);
|
||||
disposeList(list, dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,40 +141,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
@Override
|
||||
public Page<HardOrderVo> scopePageList(Page page, HardOrderDto dto, DataScope dataScope) {
|
||||
Page<HardOrderVo> list = baseMapper.scopePageList(page, dto, dataScope);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
R<List<SysUser>> userList = userService.getInnerUserById(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
}
|
||||
}
|
||||
// 部门
|
||||
List<Long> deptIds = list.getRecords().stream().map(HardOrderVo::getDeptId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
}
|
||||
}
|
||||
// 商户
|
||||
List<Long> mchIds = list.getRecords().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.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId));
|
||||
}
|
||||
}
|
||||
// 购物车
|
||||
if (dto.getIsFindCarList()) {
|
||||
for (HardOrderVo v : list.getRecords()) {
|
||||
List<HardCarEntity> carList = hardCarService.getByParentCarId(v.getParentCarId());
|
||||
List<HardCarVo> carVoList = BeanUtils.toBean(carList, HardCarVo.class);
|
||||
v.setCarList(carVoList);
|
||||
}
|
||||
}
|
||||
}
|
||||
disposeList(list.getRecords(), dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -548,6 +514,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
reduceBuild.setPrice(order.getPayPrice());
|
||||
reduceBuild.setBizId(String.valueOf(order.getId()));
|
||||
reduceBuild.setBizType(WalletBizEnum.PAYMENT);
|
||||
reduceBuild.setForce(true);
|
||||
R<WalletTransactionEntity> reduceRes = walletTransactionService.reduceWalletBalance(reduceBuild);
|
||||
if (reduceRes.getCode() != 0 || ObjectUtil.isEmpty(reduceRes.getData())) {
|
||||
throw new RuntimeException("钱包扣款错误");
|
||||
@@ -858,7 +825,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 用户
|
||||
List<Long> userIds = list.stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
|
||||
R<List<SysUser>> userList = userService.getInnerUserById(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
}
|
||||
|
||||
+54
-3
@@ -5,6 +5,8 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.async.OfflineCar;
|
||||
import com.bsd.pjcloud.hard.api.dto.async.OfflineOrder;
|
||||
@@ -12,11 +14,15 @@ import com.bsd.pjcloud.hard.api.dto.async.SyncOfflineReqVo;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardCarService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderSyncService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.HardParentCarService;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
@@ -27,7 +33,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 订单同步
|
||||
@@ -40,12 +48,16 @@ public class HardOrderSyncServiceImpl implements HardOrderSyncService {
|
||||
|
||||
static private final String TAG = "订单同步";
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteWalletSettingService walletSettingService;
|
||||
private final HardCarService hardCarService;
|
||||
private final HardParentCarService hardParentCarService;
|
||||
private final HardOrderService orderService;
|
||||
|
||||
private final HardOrderMapper hardOrderMapper;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteWalletSettingService walletSettingService;
|
||||
private final RemoteWalletService walletService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<String> syncOfflineOrder(SyncOfflineReqVo body) {
|
||||
@@ -58,7 +70,7 @@ public class HardOrderSyncServiceImpl implements HardOrderSyncService {
|
||||
if (ObjectUtil.isNotEmpty(setting) && ObjectUtil.isNotEmpty(setting.getOffLineOrderApplyEnable())) {
|
||||
offLineOrderApplyEnable = ObjectUtil.equals(setting.getOffLineOrderApplyEnable(), YesNoEnum.YES.getCode());
|
||||
}
|
||||
List<String> createIdList = List.of();
|
||||
List<String> createIdList = new ArrayList<>();
|
||||
List<OfflineOrder> list = body.getList();
|
||||
for (OfflineOrder i : list) {
|
||||
if (ObjectUtil.isEmpty(i.getCarList())) {
|
||||
@@ -75,6 +87,19 @@ public class HardOrderSyncServiceImpl implements HardOrderSyncService {
|
||||
HardOrderEntity order = parseOrder(i, body.getHardwareId(), body.getMerchantId(), merchant.getDeptId());
|
||||
HardParentCarEntity parentCar = parseParentCar(i, body.getMerchantId());
|
||||
List<HardCarEntity> carList = i.getCarList().stream().map(this::parseCar).toList();
|
||||
|
||||
// 查询钱包
|
||||
WalletManageEntity wallet = null;
|
||||
if (ObjectUtil.isNotEmpty(merchant.getDefaultWalletTypeId())) {
|
||||
wallet = walletService.getWallet(order.getUserId(), WalletTypeEnum.EAT).getData();
|
||||
} else {
|
||||
wallet = walletService.getWalletByWalletTypeId(order.getUserId(), merchant.getDefaultWalletTypeId()).getData();
|
||||
}
|
||||
if (ObjectUtil.isEmpty(wallet)) {
|
||||
log.error("|{}|同步安卓机离线订单,钱包不存在order:{}", TAG, JSON.toJSONString(i));
|
||||
continue;
|
||||
}
|
||||
order.setWalletId(wallet.getId());
|
||||
if (!ObjectUtil.isAllNotEmpty(order, parentCar, carList)) {
|
||||
log.error("|{}|同步安卓机离线订单,order、parentCar、carList任意一个为空order:{}", TAG, JSON.toJSONString(i));
|
||||
continue;
|
||||
@@ -85,6 +110,31 @@ public class HardOrderSyncServiceImpl implements HardOrderSyncService {
|
||||
return createIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 离线订单手动支付
|
||||
*/
|
||||
@Override
|
||||
public void offlinePay(List<Long> orderIds) {
|
||||
// 查询离线订单
|
||||
List<HardOrderEntity> list = hardOrderMapper.getOfflineOrderList(orderIds);
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
for (HardOrderEntity v : list) {
|
||||
getSelf().offlinePay(v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 离线订单手动支付
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void offlinePay(HardOrderEntity order) {
|
||||
// 支付
|
||||
orderService.fastReduceBalance(order);
|
||||
// 标记离线支付成功
|
||||
HardOrderEntity updateObj = HardOrderEntity.builder().id(order.getId()).offlinePaySuccess(YesNoEnum.YES.getCode()).build();
|
||||
orderService.updateById(updateObj);
|
||||
}
|
||||
|
||||
// 同步安卓机单个离线订单 TODO 允许把金额扣为负数
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean createOfflineOrder(HardOrderEntity order, HardParentCarEntity parentCar, List<HardCarEntity> list, OfflineOrder offlineOrder, boolean offLineOrderApplyEnable) {
|
||||
@@ -144,6 +194,7 @@ public class HardOrderSyncServiceImpl implements HardOrderSyncService {
|
||||
HardParentCarEntity res = new HardParentCarEntity();
|
||||
res.setUserId(order.getUserCode());
|
||||
res.setMerchantId(merchantId);
|
||||
res.setHardType(order.getSysType().getType());
|
||||
res.setOrderStatus(HardOrderStatusEnum.OFFLINE_CREATE.getType());
|
||||
return res;
|
||||
}
|
||||
|
||||
+59
-4
@@ -21,7 +21,7 @@ import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleLogEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderPayTypeVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.hard.config.LbCallbackConfig;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardAfterSaleLogMapper;
|
||||
@@ -31,6 +31,7 @@ import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.HardThirdPayService;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayVoStatusEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDetailDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.WaterDto;
|
||||
@@ -66,6 +67,7 @@ public class HardThirdPayServiceImpl implements HardThirdPayService {
|
||||
private final HardOrderService hardOrderService;
|
||||
private final HardCarService hardCarService;
|
||||
private final HardAfterSaleService hardAfterSaleService;
|
||||
|
||||
private final HardAfterSaleLogMapper hardAfterSaleLogMapper;
|
||||
|
||||
private final RemoteMchService mchService;
|
||||
@@ -275,11 +277,15 @@ public class HardThirdPayServiceImpl implements HardThirdPayService {
|
||||
PayWaterVo item = new PayWaterVo();
|
||||
item.setUserId(v.getUserId());
|
||||
item.setName(v.getUsername());
|
||||
item.setSignPhone("");
|
||||
item.setSignPhone(v.getUserMobile());
|
||||
item.setPlatformOrderId(String.valueOf(v.getId()));
|
||||
item.setPlatformRefundId(String.valueOf(v.getPayRefundId()));
|
||||
if (ObjectUtil.isNotEmpty(v.getAfterSaleId())) {
|
||||
item.setPlatformRefundId(String.valueOf(v.getAfterSaleId()));
|
||||
}
|
||||
item.setThirdOrderId(v.getOrderNo());
|
||||
item.setThirdRefundId("");
|
||||
if (ObjectUtil.isNotEmpty(v.getAfterSaleNo())) {
|
||||
item.setThirdRefundId(String.valueOf(v.getAfterSaleNo()));
|
||||
}
|
||||
item.setOrderStatus(v.getOrderStatus());
|
||||
item.setOrderPrice(v.getPayPrice());
|
||||
item.setRefundPrice(v.getRefundPrice());
|
||||
@@ -298,6 +304,55 @@ public class HardThirdPayServiceImpl implements HardThirdPayService {
|
||||
return baseVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
@Override
|
||||
public PayBaseVo<PayWaterVo> orderDetail(PayDetailDto dto, ThirdPaySoureBizTypeEnum soureType) {
|
||||
// 返回值
|
||||
PayBaseVo baseVo = new PayBaseVo<PayWaterVo>();
|
||||
String orderType = getOrderType(soureType);
|
||||
HardOrderDto query = new HardOrderDto();
|
||||
query.setOrderType(orderType);
|
||||
query.setOrderNo(dto.getThirdOrderId());
|
||||
query.setAfterSaleNo(dto.getThirdRefundId());
|
||||
List<HardOrderVo> hardOrderVos = hardOrderService.scopeList(query, null);
|
||||
if (ObjectUtil.isEmpty(hardOrderVos)) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.ORDER_EXIST);
|
||||
return baseVo;
|
||||
}
|
||||
if (hardOrderVos.size() > 1) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.DETAIL_ITEM_NOT_ONE);
|
||||
return baseVo;
|
||||
}
|
||||
HardOrderVo order = hardOrderVos.get(0);
|
||||
// 组合返回参数
|
||||
PayWaterVo item = new PayWaterVo();
|
||||
item.setUserId(order.getUserId());
|
||||
item.setName(order.getUsername());
|
||||
item.setSignPhone(order.getUserMobile());
|
||||
item.setPlatformOrderId(String.valueOf(order.getId()));
|
||||
if (ObjectUtil.isNotEmpty(order.getAfterSaleId())) {
|
||||
item.setPlatformRefundId(String.valueOf(order.getAfterSaleId()));
|
||||
}
|
||||
item.setThirdOrderId(order.getOrderNo());
|
||||
if (ObjectUtil.isNotEmpty(order.getAfterSaleNo())) {
|
||||
item.setThirdRefundId(String.valueOf(order.getAfterSaleNo()));
|
||||
}
|
||||
item.setOrderStatus(order.getOrderStatus());
|
||||
item.setOrderPrice(order.getPayPrice());
|
||||
item.setRefundPrice(order.getRefundPrice());
|
||||
if (ObjectUtil.isNotEmpty(order.getPayTime())) {
|
||||
item.setPayTime(LocalDateTimeUtil.format(order.getPayTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(order.getRefundTime())) {
|
||||
item.setRefundTime(LocalDateTimeUtil.format(order.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
baseVo.set(ThirdPayVoStatusEnum.SUCCESS);
|
||||
baseVo.setData(item);
|
||||
return baseVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询美好生活默认商户信息
|
||||
*/
|
||||
|
||||
+22
-2
@@ -82,6 +82,9 @@
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = '0'
|
||||
<if test="dto.orderNo != null and dto.orderNo != '' ">
|
||||
and a.order_no = #{dto.orderNo}
|
||||
</if>
|
||||
<if test="dto.orderStatus != null and dto.orderStatus != '' ">
|
||||
and a.order_status = #{dto.orderStatus}
|
||||
</if>
|
||||
@@ -100,6 +103,9 @@
|
||||
<if test="dto.merchantId != null">
|
||||
and a.merchant_id = #{dto.merchantId}
|
||||
</if>
|
||||
<if test="dto.isOfflineOrder != null">
|
||||
and a.is_offline_order = #{dto.isOfflineOrder}
|
||||
</if>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
|
||||
<choose>
|
||||
<when test="dto.isInclude != null and dto.isInclude == true">
|
||||
@@ -176,13 +182,16 @@
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderVo">
|
||||
<sql id="pageList">
|
||||
<include refid="selectA"/>
|
||||
m.name as hardName,
|
||||
m.type as hardType,
|
||||
m.dept_id as hardTypeDeptId
|
||||
m.dept_id as hardTypeDeptId,
|
||||
s.id as afterSaleId,
|
||||
s.no as afterSaleNo
|
||||
from hard_order a
|
||||
left join hard_manager m on m.id = a.hard_id
|
||||
left join hard_after_sale s on s.order_id = a.id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
<if test="dto.hardTypeCode != null and dto.hardTypeCode != '' ">
|
||||
@@ -194,8 +203,19 @@
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.afterSaleNo != null and dto.afterSaleNo != ''">
|
||||
and s.no = #{dto.afterSaleNo}
|
||||
</if>
|
||||
</where>
|
||||
order by a.create_time desc, a.user_id desc
|
||||
</sql>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderVo">
|
||||
<include refid="pageList"/>
|
||||
</select>
|
||||
|
||||
<select id="scopeList" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderVo">
|
||||
<include refid="pageList"/>
|
||||
</select>
|
||||
|
||||
<select id="listSb" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo">
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ public enum ThirdPayApiBizTypeEnum {
|
||||
REFUND("20", "退款"),
|
||||
WALLET_INFO("30", "钱包详情"),
|
||||
WATER("40", "流水"),
|
||||
DETAIL("50", "订单详情"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
|
||||
+2
@@ -19,9 +19,11 @@ public enum ThirdPayVoStatusEnum {
|
||||
USER_EXIST(501, "用户不存在"),
|
||||
ORDER_EXIST(502, "订单不存在"),
|
||||
MCH_EXIST(503, "第三方商户未配置"),
|
||||
ORDER_REFUND_EXIST(504, "订单未退款"),
|
||||
BALANCE_NOT_ENOUGH(505, "用户余额不足"),
|
||||
ORDER_HAVE_PAY(506, "订单已支付"),
|
||||
ORDER_HAVE_REFUND(507, "订单已退款"),
|
||||
DETAIL_ITEM_NOT_ONE(508, "查询详情条目不为一"),
|
||||
UNKNOWN_ERROR(599, "未知错误,请联系管理员"),
|
||||
;
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PayDetailDto {
|
||||
|
||||
/**
|
||||
* 第三方订单id(thirdOrderId、thirdRefundId二选一)
|
||||
*/
|
||||
private String thirdOrderId;
|
||||
|
||||
/**
|
||||
* 第三方退款(thirdOrderId、thirdRefundId二选一,有退款操作才能查询到数据,否则返回null)
|
||||
*/
|
||||
private String thirdRefundId;
|
||||
|
||||
}
|
||||
+8
@@ -62,5 +62,13 @@ public class ThirdPayApiController {
|
||||
return thirdPayApiService.water(body, headers);
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@Operation(summary = "订单详情", description = "订单详情")
|
||||
@PostMapping("/detail")
|
||||
public PayBaseVo<PayWaterVo> detail(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
|
||||
String body = httpEntity.getBody();
|
||||
return thirdPayApiService.detail(body, headers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+5
@@ -30,4 +30,9 @@ public interface ThirdPayApiService {
|
||||
* 流水查询
|
||||
*/
|
||||
PayBaseVo<List<PayWaterVo>> water(String json, Map<String, String> headers);
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
PayBaseVo<PayWaterVo> detail(String json, Map<String, String> headers);
|
||||
}
|
||||
+63
-4
@@ -7,10 +7,7 @@ import com.bsd.pjcloud.hard.api.feign.RemoteHardThirdPayService;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayApiBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPaySoureBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayVoStatusEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayGetWalletInfoDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.WaterDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.*;
|
||||
import com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdKeyManageService;
|
||||
@@ -253,6 +250,10 @@ public class ThirdPayApiServiceImpl implements ThirdPayApiService {
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
// 加密一下手机号
|
||||
for (PayWaterVo item : pageList.getData()) {
|
||||
item.setSignPhone(LbRetailSignUtils.sm4Encrypt(item.getSignPhone(), keySetting.getFieldKey()));
|
||||
}
|
||||
return pageList;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|流水查询,json|{}|headers|{}|", TAG, json, headers, e);
|
||||
@@ -264,4 +265,62 @@ public class ThirdPayApiServiceImpl implements ThirdPayApiService {
|
||||
return baseVo;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
@Override
|
||||
public PayBaseVo<PayWaterVo> detail(String json, Map<String, String> headers) {
|
||||
// 日志
|
||||
long startTime = System.currentTimeMillis();
|
||||
ThirdPayLogEntity logObj = ThirdPayLogEntity.builder().apiUrl("/third/third-pay-api/detail").bizType(ThirdPayApiBizTypeEnum.DETAIL.getType()).req(json).paySourceType(ThirdPaySoureBizTypeEnum.LB.getType()).build();
|
||||
// 开始处理
|
||||
PayBaseVo baseVo = new PayBaseVo<PayWaterVo>();
|
||||
ThirdKeyManageEntity keySetting = keyManageService.checkSignAndReturnConfig(json, headers);
|
||||
if (ObjectUtil.isEmpty(keySetting)) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.SIGN_ERROR);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
PayDetailDto dto = JSONUtil.toBean(json, PayDetailDto.class);
|
||||
if (ObjectUtil.isAllEmpty(dto.getThirdOrderId(), dto.getThirdRefundId())) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.PARAMS_ERROR);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
try {
|
||||
PayBaseVo<PayWaterVo> orderDetail = hardThirdPayService.orderDetail(dto, ThirdPaySoureBizTypeEnum.valueOfByType(keySetting.getBizType()));
|
||||
if (ObjectUtil.isEmpty(orderDetail)) {
|
||||
baseVo.set(ThirdPayVoStatusEnum.UNKNOWN_ERROR);
|
||||
baseVo.setData(orderDetail);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
// 加密一下手机号
|
||||
if (ObjectUtil.isNotEmpty(orderDetail.getData())) {
|
||||
PayWaterVo data = orderDetail.getData();
|
||||
if (ObjectUtil.isNotEmpty(data.getSignPhone())) {
|
||||
data.setSignPhone(LbRetailSignUtils.sm4Encrypt(data.getSignPhone(), keySetting.getFieldKey()));
|
||||
}
|
||||
}
|
||||
return orderDetail;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|订单详情,json|{}|headers|{}|", TAG, json, headers, e);
|
||||
baseVo.set(ThirdPayVoStatusEnum.UNKNOWN_ERROR);
|
||||
// 日志
|
||||
logObj.setRes(JSONUtil.toJsonStr(baseVo));
|
||||
logObj.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
payLogService.save(logObj);
|
||||
return baseVo;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -89,8 +89,8 @@ zy:
|
||||
# callback-recognition-url: /third/third-ks/callback/recognition
|
||||
# callback-sku-url: /third/third-ks/callback/sku
|
||||
lb:
|
||||
# base-url: https://elss-sit.nbcb.com.cn
|
||||
base-url: https://elss-sit.nbcb.com.cn/h5/thirdApp
|
||||
base-url: https://elss-sit.nbcb.com.cn
|
||||
# base-url: https://elss-sit.nbcb.com.cn/h5/thirdApp
|
||||
app-id: 7da62b1a9ade473c917f573c5748081e
|
||||
app-secret: 8ffl6b+OKTmdVAt9Qo+2F/HQQMdt/d8GFia0zUOt9l=
|
||||
company-number: 202504673472
|
||||
|
||||
Binary file not shown.
+29
@@ -5,9 +5,12 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.thirdparty.ThirdPartyApp;
|
||||
import com.bsd.pjcloud.thirdparty.constant.ThirdKeyTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.lb.LbH5LoginDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.ThirdKeyManageEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdKeyManageService;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.lb.ThirdLbApiServiceImpl;
|
||||
import com.bsd.pjcloud.thirdparty.utils.lb.tool.LbRetailSignUtils;
|
||||
import com.bsd.pjcloud.thirdparty.vo.lb.LbH5LoginVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayBaseVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayWalletInfoVo;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -36,9 +39,22 @@ public class PayTest {
|
||||
|
||||
private final String waterUrl = "/third/third-pay-api/water";
|
||||
|
||||
private final String detailUrl = "/third/third-pay-api/detail";
|
||||
|
||||
@Resource
|
||||
private ThirdKeyManageService keyManageService;
|
||||
|
||||
@Resource
|
||||
private ThirdLbApiServiceImpl thirdLbApiService;
|
||||
|
||||
// 宁波银行H5登录
|
||||
@Test
|
||||
public void lbH5login() throws Exception {
|
||||
LbH5LoginDto dto = new LbH5LoginDto();
|
||||
dto.setPhone("17683843144");
|
||||
LbH5LoginVo loginVo = thirdLbApiService.h5Login(dto);
|
||||
}
|
||||
|
||||
// 查询钱包信息
|
||||
@Test
|
||||
public void walletInfo() throws Exception {
|
||||
@@ -129,6 +145,19 @@ public class PayTest {
|
||||
log.info(res);
|
||||
}
|
||||
|
||||
// 查询订单详情
|
||||
@Test
|
||||
public void detail() throws Exception {
|
||||
ThirdKeyManageEntity config = getLbConfig();
|
||||
Map<String, Object> paramsMap = new HashMap<>();
|
||||
paramsMap.put("thirdOrderId", "");
|
||||
paramsMap.put("thirdRefundId", "10");
|
||||
String body = JSONUtil.toJsonStr(paramsMap);
|
||||
// 发送请求
|
||||
String res = HttpRequest.post(baseUrl + detailUrl).contentType("application/json").header(apiCountersign(body)).body(body).execute().body();
|
||||
log.info(res);
|
||||
}
|
||||
|
||||
private ThirdKeyManageEntity getLbConfig() {
|
||||
return keyManageService.get(ThirdKeyTypeEnum.LB);
|
||||
}
|
||||
|
||||
+3
@@ -29,4 +29,7 @@ public class WalletBalanceTransactionDto {
|
||||
@JsonProperty("bizType")
|
||||
private WalletBizEnum bizType;
|
||||
|
||||
@NotNull(message = "是否暴力消费")
|
||||
private Boolean force = false;
|
||||
|
||||
}
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class WalletTransactionController {
|
||||
@Inner
|
||||
@PostMapping("/reduce-balance")
|
||||
public R<WalletTransactionEntity> reduceWalletBalance(@Valid @RequestBody WalletBalanceTransactionDto dto) {
|
||||
WalletTransactionEntity walletTransaction = walletTransactionService.reduceWalletBalance(dto.getWalletId(), dto.getPrice(), dto.getBizId(), dto.getBizType());
|
||||
WalletTransactionEntity walletTransaction = walletTransactionService.reduceWalletBalance(dto.getWalletId(), dto.getPrice(), dto.getBizId(), dto.getBizType(), dto.getForce());
|
||||
if (ObjectUtil.isEmpty(walletTransaction)) return R.failed("扣减钱包余额");
|
||||
return R.ok(walletTransaction);
|
||||
}
|
||||
|
||||
+6
-3
@@ -60,12 +60,15 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
*
|
||||
* @param id 钱包 id
|
||||
* @param price 消费金额
|
||||
* @param force 是否强制消费(会导致扣款扣成负数)
|
||||
*/
|
||||
default int updateWhenConsumption(Long id, Integer price) {
|
||||
default int updateWhenConsumption(Long id, Integer price, Boolean force) {
|
||||
LambdaUpdateWrapper<WalletManageEntity> lambdaUpdateWrapper = new LambdaUpdateWrapper<WalletManageEntity>()
|
||||
.setSql(" balance = balance - " + price + ", total_expense = total_expense + " + price)
|
||||
.eq(WalletManageEntity::getId, id)
|
||||
.ge(WalletManageEntity::getBalance, price);
|
||||
.eq(WalletManageEntity::getId, id);
|
||||
if (ObjectUtil.isEmpty(force) || !force) {
|
||||
lambdaUpdateWrapper.ge(WalletManageEntity::getBalance, price);
|
||||
}
|
||||
return update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
|
||||
* @param bizType 业务关联分类
|
||||
* @return 钱包流水
|
||||
*/
|
||||
WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType);
|
||||
WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType, Boolean force);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -84,13 +84,14 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
// @CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
|
||||
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
|
||||
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType, Boolean force) {
|
||||
if (ObjectUtil.isEmpty(force)) force = false;
|
||||
WalletManageEntity wallet = walletManageService.getById(walletId);
|
||||
if (ObjectUtil.isEmpty(wallet)) {
|
||||
log.error("|{}|,用户钱包id({})不存在.", TAG, walletId);
|
||||
throw new RuntimeException("扣款失败,用户钱包不存在");
|
||||
}
|
||||
int updateCounts = walletManageMapper.updateWhenConsumption(wallet.getId(), price);
|
||||
int updateCounts = walletManageMapper.updateWhenConsumption(wallet.getId(), price, force);
|
||||
if (updateCounts == 0) {
|
||||
log.error("|{}|,用户钱包id({})余额不足.", TAG, walletId);
|
||||
throw new RuntimeException("钱包余额不足");
|
||||
|
||||
+2
-2
@@ -92,7 +92,7 @@ public class WalletRuleTransactionServiceImpl extends ServiceImpl<WalletRuleTran
|
||||
entity.setIsRefund(YesNoEnum.NO.getCode());
|
||||
baseMapper.insert(entity);
|
||||
// 源头钱包扣减
|
||||
walletTransactionService.reduceWalletBalance(userConfig.getSourceWalletId(), body.getBalance(), String.valueOf(entity.getId()), WalletBizEnum.TRANSFER_ACCOUNTS);
|
||||
walletTransactionService.reduceWalletBalance(userConfig.getSourceWalletId(), body.getBalance(), String.valueOf(entity.getId()), WalletBizEnum.TRANSFER_ACCOUNTS, Boolean.FALSE);
|
||||
// 目标钱包增加
|
||||
walletTransactionService.addWalletBalance(userConfig.getTargetWalletId(), body.getBalance(), String.valueOf(entity.getId()), WalletBizEnum.TRANSFER_ACCOUNTS);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class WalletRuleTransactionServiceImpl extends ServiceImpl<WalletRuleTran
|
||||
// 源头钱包增加
|
||||
walletTransactionService.addWalletBalance(detail.getSourceWalletId(), detail.getBalance(), String.valueOf(detail.getId()), WalletBizEnum.TRANSFER_ACCOUNTS_REFUND);
|
||||
// 目标钱包扣减
|
||||
walletTransactionService.reduceWalletBalance(detail.getTargetWalletId(), detail.getBalance(), String.valueOf(detail.getId()), WalletBizEnum.TRANSFER_ACCOUNTS_REFUND);
|
||||
walletTransactionService.reduceWalletBalance(detail.getTargetWalletId(), detail.getBalance(), String.valueOf(detail.getId()), WalletBizEnum.TRANSFER_ACCOUNTS_REFUND, Boolean.FALSE);
|
||||
// 改状态
|
||||
WalletRuleTransactionEntity updateObj = new WalletRuleTransactionEntity();
|
||||
updateObj.setId(id);
|
||||
|
||||
Reference in new issue
Block a user