feat:商城支付

This commit is contained in:
dzc committed 2026-06-25 18:26:36 +08:00
1 parent 0f7c3c496b
commit 5e17576074
32 files changed
+774 -156

No files matched your search

@@ -6,7 +6,6 @@ import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 硬件设备类型
@@ -23,7 +22,7 @@ public enum HardTypeEnum {
MERCHANT_QR_CODE("5", "商户二维码扣款牌"),
OTHER("6", "其他支付方式(第三方接口对接)"),
MERCHANT_ACT("7", "商户活动"),
FARMER("8", "共富商城(助农)"),
SELF_APP("8", "无设备或者用户自己的手机"),
YUN_XFJ("9", "云版消费机"),
YYX_4G("10", "4G-云音响"),
YYX_WIFI("11", "wifi-云音响"),
@@ -32,7 +31,7 @@ public enum HardTypeEnum {
private final String description;
// 是否能预定
public static final List<HardTypeEnum> isReserveList = List.of(SUPERMARKET, CANTEEN, FARMER);
public static final List<HardTypeEnum> isReserveList = List.of(SUPERMARKET, CANTEEN, SELF_APP);
// 不需要创建购物车
public static final List<HardTypeEnum> isNoneCar = List.of(MERCHANT_QR_CODE);
@@ -10,21 +10,26 @@ import java.util.List;
/**
* 订单状态
* 外卖状态 100(待接单(外卖))->110(配送中(外卖))-> 200(已核销(已完成))
* 商城状态 1(创建订单未支付) -> 200(已经支付/待发货) -> 200(待收货) -> 210(待评价) ->220(已评价)
*/
@AllArgsConstructor
@Getter
public enum HardOrderStatusEnum {
CREATE("1", "创建订单(未支付)"),
OFFLINE_CREATE("2", "离线创建订单(未支付)"),
PAY("5", "已经支付"),
PAY("5", "已经支付/待发货"),
OFFLINE_PAY("6", "没有网络本地支付"),
REFUND("10", "退款"),
CANCEL("20", "已核销(已完成)"),
UNFOLLOW("30", "已取消(智能柜)"),
UNFOLLOW("30", "已取消、未支付自动取消(智能柜、商城购买)"),
TAKE_OUT_AWAIT("100", "待接单(外卖)"),
TAKE_OUT_ING("110", "配送中(外卖)"),
SHOP_WAIT_PAY_SUCCESS("200","待发货/已支付(商城购买)"),
SHOP_WAIT_RECEIVE("210","待收货(商城购买)"),
SHOP_WAIT_EVALUATE("220","订单完成/待评价(商城购买)"),
// SHOP_EVALUATED("230","已评价(商城购买)"),
;
private final String type;
private final String description;
@@ -54,4 +59,4 @@ public enum HardOrderStatusEnum {
if (ObjectUtil.isEmpty(type)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
}
}
}
@@ -19,7 +19,7 @@ public enum HardOrderTypeEnum {
STRIDE_DEPT("4", "跨单位"),
ZY("5", "正元公务餐"),
LB("6", "宁波银行(美好生活)"),
FARMER("7", "共富商城(助农)"),
FARMER("7", "共富商城(助农),现在用于商城"),
TOC_VISITOR("8", "toc访客购买(不记名用户)"),
XFJ("9", "消费机支付"),
TAKE_OUT("10", "外卖"),
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.api.constant.order;
import cn.hutool.core.util.ObjectUtil;
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -25,7 +26,9 @@ public enum HardPayTypeEnum {
CASH("8", "现金支付"),
HARD_DOOR_FREE_PAY("9", "智能柜免密支付"),
WECHANT_SELF_QR_CODE_PAY("10", "微信付款码支付"),
WECHANT_APP_PAY("100", "微信App支付"),
ALI_SELF_QR_CODE_PAY("11", "支付宝付款码支付"),
ALI_APP_PAY("110", "支付宝App支付"),
ZYY("12", "中医院"),
RMYY("13", "人民医院"),
CSXFK("14", "超市消费卡"),
@@ -53,7 +56,9 @@ public enum HardPayTypeEnum {
STRIDE_DEPT_QR_CODE,
FOREIGN_TICKET_QR_CODE,
WECHANT_SELF_QR_CODE_PAY,
ALI_SELF_QR_CODE_PAY
ALI_SELF_QR_CODE_PAY,
WECHANT_APP_PAY,
ALI_APP_PAY
);
// 可以核销的订单
@@ -77,8 +82,21 @@ public enum HardPayTypeEnum {
WALLET_CARD
);
public static HardPayTypeEnum transformHardPayTypeEnum(AppPlusPlatformTypeEnum appPlusPlatformTypeEnum) {
switch (appPlusPlatformTypeEnum) {
case WECHAT:
return HardPayTypeEnum.WECHANT_APP_PAY;
case ALI_PAY:
return HardPayTypeEnum.ALI_APP_PAY;
case ZAX_APP_WALLET:
return HardPayTypeEnum.WALLET_DEFAULT;
default:
return null;
}
}
public static HardPayTypeEnum valueOfByType(String type) {
if (ObjectUtil.isEmpty(type)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().orElse(null);
}
}
@@ -0,0 +1,21 @@
package com.bsd.pjcloud.hard.api.dto.order;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class HardShipmentDto {
/**
* 发货地址id
*/
@NotNull(message = "发货地址id不能为空")
private Long addressId;
/**
* 快递物流编号
*/
@NotNull(message = "快递物流编号不能为空")
private String shipmentNo;
}
@@ -0,0 +1,49 @@
package com.bsd.pjcloud.hard.api.dto.order.app;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class HardAppCreateShopOrderDto {
/**
* 父购物车id
*/
@NotNull(message = "父购物车id不能为空")
private Long carParentId;
/**
* 地图地址
*/
@NotNull(message = "地图地址不能为空")
private Long mapAddressId;
/**
* 支付方式
*/
@NotNull(message = "地图地址不能为空")
private String payType;
/**
* 钱包类型
*/
private Long walletTypeId;
/**
* 自动填充
*/
private HardTypeEnum hardType;
private HardOrderTypeEnum orderType;
private Long userId;
}
@@ -0,0 +1,21 @@
package com.bsd.pjcloud.hard.api.dto.order.remote;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class HardUpdateShopStatusDto {
@NotNull(message = "订单id不能为空")
private Long orderId;
@NotNull(message = "订单状态不能为空")
private HardUpdateShopStatusDto.ChangeShopStatus status;
public enum ChangeShopStatus {
// 支付成功
PAY_SUCCESS,
// 退款成功
REFUND_SUCCESS,
;
}
}
@@ -9,7 +9,7 @@ public class HardUpdateTakeOutStatusDto {
@NotNull(message = "订单id不能为空")
private Long orderId;
@NotNull(message = "订单id不能为空")
@NotNull(message = "订单状态不能为空")
private HardUpdateTakeOutStatusDto.TakeOutStatus status;
public enum TakeOutStatus {
@@ -2,11 +2,13 @@ package com.bsd.pjcloud.hard.api.entity.order;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
@@ -99,6 +101,66 @@ public class HardOrderAddressEntity extends Model<HardOrderAddressEntity> {
@Schema(description = "详细地址")
private String fullAddress;
/**
* 省
*/
@Schema(description = "省")
private String province;
/**
* 市
*/
@Schema(description = "市")
private String city;
/**
* 区
*/
@Schema(description = "区")
private String district;
/**
* 街道
*/
@Schema(description = "街道")
private String street;
/**
* 经度
*/
@Schema(description = "经度")
private BigDecimal longitude;
/**
* 纬度
*/
@Schema(description = "纬度")
private BigDecimal latitude;
/**
* 联系人
*/
@Schema(description = "联系人")
private String username;
/**
* 手机号
*/
@Schema(description = "手机号")
private String userMoblie;
/**
* tag
*/
@Schema(description = "tag")
private String tag;
/**
* 用户手动输入地址
*/
@Schema(description = "用户手动输入地址")
private String inputAddress;
/**
* 创建人
*/
@@ -140,4 +202,23 @@ public class HardOrderAddressEntity extends Model<HardOrderAddressEntity> {
*/
@Schema(description = "租户ID")
private Long tenantId;
public static HardOrderAddressEntity of(HardUserMapAddressEntity entity) {
HardOrderAddressEntity orderAddress = new HardOrderAddressEntity();
orderAddress.setUserId(entity.getUserId());
orderAddress.setAddressId(entity.getId());
orderAddress.setAddressName(entity.getAdressDetail());
orderAddress.setFullAddress(entity.getFullAddress());
orderAddress.setProvince(entity.getProvince());
orderAddress.setCity(entity.getCity());
orderAddress.setDistrict(entity.getDistrict());
orderAddress.setStreet(entity.getStreet());
orderAddress.setLongitude(entity.getLongitude());
orderAddress.setLatitude(entity.getLatitude());
orderAddress.setUsername(entity.getUsername());
orderAddress.setUserMoblie(entity.getUserMoblie());
orderAddress.setTag(entity.getTag());
orderAddress.setInputAddress(entity.getInputAddress());
return orderAddress;
}
}
@@ -36,7 +36,7 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
/**
* 订单编号
*/
@Schema(description = "订单编号 目前正元、微信支付、云消费机、支付宝支付正在使用")
@Schema(description = "订单编号 目前正元、微信支付、云消费机、微信、支付宝支付正在使用")
private String orderNo;
/**
@@ -231,12 +231,37 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
@Schema(description = "离线自动支付是否成功")
private String offlinePaySuccess;
/**
* 地址id
*/
@Schema(description = "地址id")
private Long addressId;
/**
* 收货地址
*/
@Schema(description = "收货地址")
private String addressName;
/**
* 快递单号
*/
@Schema(description = "快递单号")
private String shipmentNo;
/**
* 发货时间
* 自动收货时间=发货时间+15天
*/
@Schema(description = "发货时间")
private LocalDateTime shippedTime;
/**
* 收货时间
*/
@Schema(description = "收货时间")
private LocalDateTime deliveredTime;
/**
* 创建人
*/
@@ -5,6 +5,7 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderPreferencesDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateShopStatusDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateTakeOutStatusDto;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import org.springframework.cloud.openfeign.FeignClient;
@@ -32,4 +33,9 @@ public interface RemoteHardOrderService {
@NoToken
@PostMapping("/hard-order/update-take-out-status")
R<Boolean> updateTakeOutStatus(@RequestBody HardUpdateTakeOutStatusDto dto);
@NoToken
@PostMapping("/hard-order/update-shop-status")
R<Boolean> updateShopStatus(@RequestBody HardUpdateShopStatusDto dto);
}
@@ -0,0 +1,25 @@
package com.bsd.pjcloud.hard.api.vo.order.app;
import lombok.Data;
import java.util.Map;
@Data
public class HardAppCreateShopOrderVo {
/**
* 订单id
*/
private Long orderId;
/**
* 支付单号
*/
private String payNo;
/**
* 发起支付参数
*/
private Map<String, Object> appPlusPayParams;
}
@@ -37,9 +37,6 @@ import java.util.List;
/**
* 售后订单
*
* @author dzc
* @date 2025-01-07 17:23:08
*/
@RestController
@RequiredArgsConstructor
@@ -188,7 +185,7 @@ public class HardAfterSaleController {
public R pageJoin(@ParameterObject Page page, @ParameterObject HardAfterSaleDto dto) {
// 查询商户
MchManageDto mchManageDto = new MchManageDto();
mchManageDto.setTypesList(List.of(MerchantTypeEnum.CANTEEN.getType()));
mchManageDto.setTypesList(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.FARMER.getType()));
List<MchManageVo> mchList = remoteMchService.scopeList(mchManageDto).getData();
if (ObjectUtil.isNotEmpty(mchList) && ObjectUtil.isEmpty(dto.getMchIds())) {
dto.setMchIds(mchList.stream().map(MchManageVo::getId).toList());
@@ -50,7 +50,7 @@ public class HardOrderAddressController {
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('hard_hardOrderAddress_view')")
// @PreAuthorize("@pms.hasPermission('hard_hardOrderAddress_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(hardOrderAddressService.getById(id));
}
@@ -15,7 +15,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.canteen.constant.OrderTypeEnum;
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
@@ -37,13 +36,17 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardOfflinePayDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOnlineCanteenStatsQueryDto;
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.HardShipmentDto;
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateShopOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateTakeOutOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateShopStatusDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateTakeOutStatusDto;
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.app.HardAppCreateShopOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.app.HardTakeOutDeliveryTimeOptionVO;
import com.bsd.pjcloud.hard.api.vo.order.excel.HardOrderExcelVo;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
@@ -54,6 +57,7 @@ import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.websocket.server.PathParam;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
@@ -125,6 +129,13 @@ public class HardOrderController {
public R<Boolean> updateTakeOutStatus(@RequestBody HardUpdateTakeOutStatusDto dto) {
return R.ok(hardwareOrderService.updateTakeOutStatus(dto));
}
@Inner
@Operation(summary = "更改商城订单状态(目前只能将未支付改到已支付订单状态)", description = "更改商城订单状态(目前只能将未支付改到已支付订单状态)")
@PostMapping("/update-shop-status")
public R<Boolean> updateShopStatus(@RequestBody HardUpdateShopStatusDto dto) {
return R.ok(hardwareOrderService.updateShopStatus(dto));
}
/* ************************************* end 远程调用 ************************************* */
/* ************************************* start app start ************************************* */
@@ -151,13 +162,20 @@ public class HardOrderController {
}
@Operation(summary = "app查询订单列表", description = "app查询订单列表")
@Operation(summary = "app查询订单列表(查询食堂、商城)", description = "app查询订单列表(查询食堂、商城)")
@ApiCryptoAes
@GetMapping("/app/page-join")
public R appPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
dto.setIsFindCarList(true);
dto.setIsFindApptList(true);
dto.setMchTypeCodes(
List.of(
MerchantTypeEnum.CANTEEN.getType(),
MerchantTypeEnum.FARMER.getType()
)
);
return R.ok(hardwareOrderService.pagejoin(page, dto));
}
@@ -336,16 +354,28 @@ public class HardOrderController {
@Operation(summary = "创建共富商城预约订单", description = "app创建线上超市预定订单")
@ApiCryptoAes
@PostMapping("/app/create-farmer-order")
@Idempotent(expireTime = 3, key = "'/app/hard-order/app/create-farmer-order' + #body.getCarParentId() ", info = "正在创建订单中,请勿重复操作")
@Idempotent(expireTime = 1, key = "'/app/hard-order/app/create-farmer-order' + #body.getCarParentId() ", info = "正在创建订单中,请勿重复操作")
public R<Long> appCreateFarmerReserveOrder(@RequestBody HardAppCreateFarmerOrderDto body) {
PjcloudUser user = SecurityUtils.getUser();
body.setHardType(HardTypeEnum.FARMER);
body.setHardType(HardTypeEnum.SELF_APP);
body.setUserId(user.getId());
body.setOrderType(HardOrderTypeEnum.FARMER);
body.setPayType(HardPayTypeEnum.WALLET_DEFAULT);
return R.ok(hardwareOrderService.appCreateFarmerReserveOrder(body));
}
@Operation(summary = "app创建商城预约订单(支持所有微信、支付宝、钱包等支付方式)", description = "app创建商城预约订单(支持所有微信、支付宝、钱包等支付方式)")
@ApiCryptoAes
@PostMapping("/app/create-shop-order")
@Idempotent(expireTime = 1, key = "'/app/hard-order/app/create-shop-order' + #body.getCarParentId() ", info = "正在创建订单中,请勿重复操作")
public R<HardAppCreateShopOrderVo> appCreateShopReserveOrder(@RequestBody HardAppCreateShopOrderDto body) {
PjcloudUser user = SecurityUtils.getUser();
body.setHardType(HardTypeEnum.SELF_APP);
body.setUserId(user.getId());
body.setOrderType(HardOrderTypeEnum.FARMER);
return R.ok(hardwareOrderService.appCreateShopReserveOrder(body));
}
@Operation(summary = "app创建订单扫一扫", description = "app创建订单扫一扫")
@ApiCryptoAes
@PostMapping("/app/create-order-scan-qrcode")
@@ -386,6 +416,14 @@ public class HardOrderController {
return R.ok(hardwareOrderService.handCancelCode(body));
}
@ApiCryptoAes
@Operation(summary = "确认收货", description = "确认收货")
@PutMapping("/app/confirm-receipt/{orderId}")
public R<Boolean> confirmReceipt(@PathVariable Long orderId) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardwareOrderService.confirmReceipt(user.getId(), orderId));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "admin手动核销线上预订", description = "admin手动核销线上预订")
@@ -493,6 +531,12 @@ public class HardOrderController {
return R.ok();
}
@Operation(summary = "快递发货或者修改发货单号", description = "快递发货或者修改发货单号")
@PostMapping("/shipment")
public R<Boolean> shipment(@RequestBody HardShipmentDto dto) {
return R.ok(hardwareOrderService.shipment(dto));
}
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_export')")
public void export(HttpServletResponse response, HardOrderDto dto) throws IOException {
@@ -71,6 +71,7 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), HardOrderEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getMchIds()), HardOrderEntity::getMerchantId, dto.getMchIds())
.in(ObjectUtil.isNotEmpty(dto.getMchTypeCodes()), HardOrderEntity::getMerchantType, dto.getMchTypeCodes())
.in(ObjectUtil.isNotEmpty(dto.getOrderStatusCodes()), HardOrderEntity::getOrderStatus, dto.getOrderStatusCodes())
.in(ObjectUtil.isNotEmpty(dto.getRefundStatusCodes()), HardOrderEntity::getRefundStatus, dto.getRefundStatusCodes())
.between(
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
@@ -16,15 +16,19 @@ import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardShipmentDto;
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateShopOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateShopStatusDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateTakeOutStatusDto;
import com.bsd.pjcloud.hard.api.dto.order.xfj.HardXfjFastCreateOrderDto;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardCreateHardQrCodeScanOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppCreateShopOrderVo;
import com.bsd.pjcloud.thirdparty.dto.ks.KsRecognitionCallbackDto;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import jakarta.validation.Valid;
@@ -81,6 +85,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
*/
Boolean updateTakeOutStatus(HardUpdateTakeOutStatusDto dto);
/**
* 更改商城订单状态(目前只能将未支付改到已支付订单状态)
*/
Boolean updateShopStatus(HardUpdateShopStatusDto dto);
/**
* app创建线上超市预定订单
*/
@@ -91,6 +100,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
*/
Long appCreateFarmerReserveOrder(HardAppCreateFarmerOrderDto dto);
/**
* app创建商城预约订单(支持所有微信、支付宝、钱包等支付方式)
*/
HardAppCreateShopOrderVo appCreateShopReserveOrder(HardAppCreateShopOrderDto body);
/**
* 创建app订单
*/
@@ -174,4 +188,14 @@ public interface HardOrderService extends IService<HardOrderEntity> {
* 是否需要支付
*/
boolean isPay(HardOrderTypeEnum type, HardPayTypeEnum payType);
/**
* 快递发货或者修改发货单号
*/
Boolean shipment(HardShipmentDto dto);
/**
* 确认收货
*/
Boolean confirmReceipt(Long userId, Long orderId);
}
@@ -39,6 +39,7 @@ import com.bsd.pjcloud.hard.mapper.order.HardAfterSaleMapper;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.service.*;
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdAppPlusPayService;
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderBizTypeEnum;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdRemoterRefundDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.pay.wechat.ThirdMiniWechatRefundDto;
@@ -240,9 +241,15 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
// 是否钱包支付
boolean isWalletPay = hardOrderService.isPay(hardOrderType, hardPayType);
// 是否微信支付
boolean isWeChatPay = ObjectUtil.equals(order.getPayType(), HardPayTypeEnum.WECHANT_SELF_QR_CODE_PAY.getType());
boolean isWeChatPay = List.of(HardPayTypeEnum.WECHANT_SELF_QR_CODE_PAY.getType(), HardPayTypeEnum.WECHANT_APP_PAY.getType()).contains(order.getPayType());
// 是否支付宝支付
boolean isAliPay = ObjectUtil.equals(order.getPayType(), HardPayTypeEnum.ALI_SELF_QR_CODE_PAY.getType());
boolean isAliPay = List.of(HardPayTypeEnum.ALI_SELF_QR_CODE_PAY.getType(), HardPayTypeEnum.ALI_APP_PAY.getType()).contains(order.getPayType());
ThirdPayOrderBizTypeEnum payOrderBizType = null;
if (List.of(HardPayTypeEnum.WECHANT_SELF_QR_CODE_PAY, HardPayTypeEnum.ALI_SELF_QR_CODE_PAY).contains(hardPayType)) {
payOrderBizType = ThirdPayOrderBizTypeEnum.YXFJ_PAY;
} else if (List.of(HardPayTypeEnum.WECHANT_APP_PAY, HardPayTypeEnum.ALI_APP_PAY).contains(hardPayType)) {
payOrderBizType = ThirdPayOrderBizTypeEnum.APP_SHOP_PAY;
}
if (isWalletPay) {
WalletRechargeRefundDto hardRefundDto = WalletRechargeRefundDto.builder().walletId(order.getWalletId()).orderId(order.getId()).afterSaleId(afterSale.getId()).refundCode(refundCode).reason("订单退款").price(refundPrice).build();
R<WalletRechargeVo> walletRefundResult = walletRechargeService.refund(hardRefundDto);
@@ -262,53 +269,53 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
}
// 微信支付退款
else if (isWeChatPay) {
if (ObjectUtil.equals(order.getPayType(), HardPayTypeEnum.WECHANT_SELF_QR_CODE_PAY.getType())) {
ThirdRemoterRefundDto refundDto = new ThirdRemoterRefundDto();
refundDto.setOrderId(order.getId());
refundDto.setPrice(refundPrice);
R<String> refundRes = thirdAppPlusPayService.remoterRefund(refundDto);
if (!refundRes.isOk()) {
throw new RuntimeException("微信退款错误:" + refundRes.getMsg());
}
if (ObjectUtil.isEmpty(refundRes.getData())) {
throw new RuntimeException("微信退款错误");
}
// 售后成功
HardOrderEntity updateObj = HardOrderEntity.builder()
.id(order.getId())
.orderStatus(HardOrderStatusEnum.REFUND.getType())
.refundStatus(HardRefundStatusEnum.SUCCESS.getStatus())
.payRefundId(order.getId())
.refundPrice(order.getPayPrice())
.refundTime(LocalDateTime.now())
.build();
hardOrderService.updateById(updateObj);
ThirdRemoterRefundDto refundDto = new ThirdRemoterRefundDto();
refundDto.setOrderId(order.getId());
refundDto.setPrice(refundPrice);
refundDto.setBizType(payOrderBizType);
R<String> refundRes = thirdAppPlusPayService.remoterRefund(refundDto);
if (!refundRes.isOk()) {
throw new RuntimeException("微信退款错误:" + refundRes.getMsg());
}
if (ObjectUtil.isEmpty(refundRes.getData())) {
throw new RuntimeException("微信退款错误");
}
// 售后成功
HardOrderEntity updateObj = HardOrderEntity.builder()
.id(order.getId())
.orderStatus(HardOrderStatusEnum.REFUND.getType())
.refundStatus(HardRefundStatusEnum.SUCCESS.getStatus())
.payRefundId(order.getId())
.refundPrice(order.getPayPrice())
.refundTime(LocalDateTime.now())
.build();
hardOrderService.updateById(updateObj);
}
// 支付宝退款
else if (isAliPay) {
if (ObjectUtil.equals(order.getPayType(), HardPayTypeEnum.ALI_SELF_QR_CODE_PAY.getType())) {
ThirdRemoterRefundDto refundDto = new ThirdRemoterRefundDto();
refundDto.setOrderId(order.getId());
refundDto.setPrice(refundPrice);
R<String> refundRes = thirdAppPlusPayService.remoterRefund(refundDto);
if (!refundRes.isOk()) {
throw new RuntimeException("微信退款错误:" + refundRes.getMsg());
}
if (ObjectUtil.isEmpty(refundRes.getData())) {
throw new RuntimeException("微信退款错误");
}
// 售后成功
HardOrderEntity updateObj = HardOrderEntity.builder()
.id(order.getId())
.orderStatus(HardOrderStatusEnum.REFUND.getType())
.refundStatus(HardRefundStatusEnum.SUCCESS.getStatus())
.payRefundId(order.getId())
.refundPrice(order.getPayPrice())
.refundTime(LocalDateTime.now())
.build();
hardOrderService.updateById(updateObj);
ThirdRemoterRefundDto refundDto = new ThirdRemoterRefundDto();
refundDto.setOrderId(order.getId());
refundDto.setPrice(refundPrice);
refundDto.setBizType(payOrderBizType);
R<String> refundRes = thirdAppPlusPayService.remoterRefund(refundDto);
if (!refundRes.isOk()) {
throw new RuntimeException("微信退款错误:" + refundRes.getMsg());
}
if (ObjectUtil.isEmpty(refundRes.getData())) {
throw new RuntimeException("微信退款错误");
}
// 售后成功
HardOrderEntity updateObj = HardOrderEntity.builder()
.id(order.getId())
.orderStatus(HardOrderStatusEnum.REFUND.getType())
.refundStatus(HardRefundStatusEnum.SUCCESS.getStatus())
.payRefundId(order.getId())
.refundPrice(order.getPayPrice())
.refundTime(LocalDateTime.now())
.build();
hardOrderService.updateById(updateObj);
} else {
throw new RuntimeException("不支持的退款类型");
}
}
@@ -13,7 +13,6 @@ import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudDefaultDataScopeHandle;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
import com.bsd.pjcloud.hard.api.constant.total.DateRangeTypeEnum;
@@ -23,7 +22,6 @@ import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductByClassifyDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppProductLikeTopDto;
import com.bsd.pjcloud.hard.api.vo.order.HardCanteenProductTotalVo;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardCarTotalVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByCanteenVo;
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppProductByClassifyVo;
@@ -245,7 +245,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
}
yield doorTotalPrice.get();
}
case FARMER -> {
case SELF_APP -> {
AtomicInteger doorTotalPrice = new AtomicInteger();
List<MallProductDetailAppVo> spuList = remoteMallProductService.getSkusWithSpuBySkuIds(productIds).getData();
for (HardCreateCarDto v : list) {
@@ -458,7 +458,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
return;
}
// 共富商城
if (ObjectUtil.equals(sysType, HardTypeEnum.FARMER)) {
if (ObjectUtil.equals(sysType, HardTypeEnum.SELF_APP)) {
List<HardCarEntity> carObjectList = new ArrayList<>();
List<MallProductDetailAppVo> spuList = remoteMallProductService.getSkusWithSpuBySkuIds(productIds).getData();
for (HardCreateCarDto v : productList) {
@@ -549,7 +549,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
}
}
// 共富商城
if (ObjectUtil.equals(sysType, HardTypeEnum.FARMER)) {
if (ObjectUtil.equals(sysType, HardTypeEnum.SELF_APP)) {
List<MallProductDetailAppVo> spuList = remoteMallProductService.getSkusWithSpuBySkuIds(productIds).getData();
for (HardCreateCarDto v : list) {
spu:
@@ -5,8 +5,6 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alipay.api.response.AlipayTradeOrderPayResponse;
import com.alipay.api.response.AlipayTradePayResponse;
import com.baomidou.lock.annotation.Lock4j;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -44,8 +42,6 @@ import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
import com.bsd.pjcloud.hard.api.constant.xfj.HardXfjTypeEnum;
import com.bsd.pjcloud.hard.api.dto.ali.AliMicropayDto;
import com.bsd.pjcloud.hard.api.dto.ali.AliReverseDto;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelActCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardDoneHardQrCodeScanOrderDto;
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
@@ -53,15 +49,19 @@ import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.HardShipmentDto;
import com.bsd.pjcloud.hard.api.dto.order.act.HardCreateActOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateFarmerOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateShopOrderDto;
import com.bsd.pjcloud.hard.api.dto.order.app.HardAppTakeOutApptDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateShopStatusDto;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateTakeOutStatusDto;
import com.bsd.pjcloud.hard.api.dto.order.xfj.HardXfjFastCreateOrderDto;
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
import com.bsd.pjcloud.hard.api.entity.order.*;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
@@ -71,6 +71,7 @@ import com.bsd.pjcloud.hard.api.vo.manager.HardManagerVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCreateHardQrCodeScanOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.api.vo.order.app.HardAppCreateShopOrderVo;
import com.bsd.pjcloud.hard.util.MchJobTimeUtils;
import com.bsd.pjcloud.hard.mapper.HardThirdMiOrderMapper;
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
@@ -86,7 +87,9 @@ import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdAppPlusPayService;
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformTypeEnum;
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderBizTypeEnum;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniRemotePayDto;
import com.bsd.pjcloud.thirdparty.dto.ks.KsRecognitionCallbackDto;
import com.bsd.pjcloud.thirdparty.vo.appplus.pay.ThirdMiniAppPayVo;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
@@ -123,8 +126,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@@ -151,6 +152,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final HardSpuService hardSpuService;
private final HardApptService hardApptService;
private final HardOrderAddressService hardOrderAddressService;
private final HardUserMapAddressService hardUserMapAddressService;
private final HardTakeOutApptService hardTakeOutApptService;
private final RemoteOnlineCanteenSpuService remoteOnlineCanteenSpuService;
@@ -728,6 +730,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
addressEntity.setRoomName(dto.getAddress().getRoomName());
addressEntity.setFullAddress(dto.getAddress().getFullAddress());
hardOrderAddressService.save(addressEntity);
HardOrderEntity updateAddressObj = new HardOrderEntity();
updateAddressObj.setId(orderObj.getId());
updateAddressObj.setAddressId(addressEntity.getId());
baseMapper.updateById(updateAddressObj);
}
// 添加预约时间信息
if (ObjectUtil.isNotEmpty(dto.getAppt())) {
@@ -801,6 +807,43 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return true;
}
/**
* 更改商城订单状态(目前只能将未支付改到已支付订单状态)
*/
@Override
public Boolean updateShopStatus(HardUpdateShopStatusDto dto) {
// 查询订单
HardOrderEntity order = baseMapper.selectById(dto.getOrderId());
if (ObjectUtil.isEmpty(order)) {
throw new RuntimeException("订单不存在");
}
// 是否为商城订单
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
if (ObjectUtil.isEmpty(orderTypeEnum) || ObjectUtil.notEqual(orderTypeEnum, HardOrderTypeEnum.FARMER)) {
throw new RuntimeException("订单类型错误");
}
HardOrderEntity updateOrderObj = new HardOrderEntity();
HardOrderStatusEnum orderStatus = null;
// 待支付->已支付
if (ObjectUtil.equals(dto.getStatus(), HardUpdateShopStatusDto.ChangeShopStatus.PAY_SUCCESS)) {
if (ObjectUtil.notEqual(order.getOrderStatus(), HardOrderStatusEnum.CREATE.getType())) {
log.error("|更改商城订单状态|将订单状态从`CREATE(1)`修改到`PAY(5)`错误订单并不是`CREATE(1)`状态");
return false;
}
getSelf().orderSuccess(order, true);
}
// 退款
else if (ObjectUtil.equals(dto.getStatus(), HardUpdateShopStatusDto.ChangeShopStatus.REFUND_SUCCESS)) {
orderStatus = HardOrderStatusEnum.REFUND;
updateOrderObj.setId(order.getId());
updateOrderObj.setOrderStatus(orderStatus.getType());
updateOrderObj.setPayTime(LocalDateTime.now());
baseMapper.updateById(updateOrderObj);
}
return true;
}
/**
* app创建线上超市预定订单
*/
@@ -945,6 +988,124 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return orderObj.getId();
}
/**
* app创建商城预约订单(支持所有微信、支付宝、钱包等支付方式)
*/
@Override
public HardAppCreateShopOrderVo appCreateShopReserveOrder(HardAppCreateShopOrderDto dto) {
HardAppCreateShopOrderVo result = new HardAppCreateShopOrderVo();
// 查询用户
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
// 判断支付方式
AppPlusPlatformTypeEnum appPlusPlatformType = AppPlusPlatformTypeEnum.valueOfByType(dto.getPayType());
if (ObjectUtil.isEmpty(appPlusPlatformType)) throw new RuntimeException("不支持的支付方式");
// 把`AppPlusPlatformTypeEnum`类型的`appPlusPlatformType`转换为
HardPayTypeEnum hardPayTypeEnum = HardPayTypeEnum.transformHardPayTypeEnum(appPlusPlatformType);
if (ObjectUtil.isEmpty(hardPayTypeEnum)) throw new RuntimeException("不支持的支付方式");
// 查询父订单
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
if (ObjectUtil.isEmpty(parentCar)) throw new RuntimeException("购物车不存在");
// 查询商户
MchManageVo hardManager = remoteMchService.getById(parentCar.getMerchantId()).getData();
if (ObjectUtil.isEmpty(hardManager)) throw new RuntimeException("商户不存在");
// 查询父购物车
List<HardCarEntity> carList = hardCarService.getByParentCarId(dto.getCarParentId());
if (ObjectUtil.isEmpty(carList)) throw new RuntimeException("购物车不存在");
// 查询地址
HardUserMapAddressEntity userMapAddress = hardUserMapAddressService.getById(dto.getMapAddressId());
if (ObjectUtil.isEmpty(userMapAddress)) throw new RuntimeException("用户地址不存在");
int totalPrice = (int) carList.stream().mapToLong(HardCarEntity::getTotalPrice).sum();
// 钱包`ZAX_APP_WALLET(资安信-钱包)`支付
WalletManageEntity wallet = null;
if (ObjectUtil.equals(appPlusPlatformType, AppPlusPlatformTypeEnum.ZAX_APP_WALLET)) {
wallet = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), dto.getWalletTypeId()).getData();
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
Integer balance = wallet.getBalance();
if (balance < totalPrice) {
throw new RuntimeException("钱包余额不足");
}
}
// 获取商品描述
List<HardCreateCarDto> carListDto = carList.stream().map(v -> {
HardCreateCarDto entity = new HardCreateCarDto();
entity.setParentCarId(dto.getCarParentId());
entity.setProductId(v.getProductId());
entity.setProductWeight(v.getProductWeight());
entity.setProductCount(v.getProductCount());
return entity;
}).toList();
String subject = hardCarService.computerCarSubject(dto.getHardType(), dto.getOrderType(), carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.userId(dto.getUserId())
.userDeptId(userDetail.getSysUser().getDeptId())
.parentCarId(dto.getCarParentId())
.sysType(dto.getHardType().getType())
.orderStatus(HardOrderStatusEnum.CREATE.getType())
.merchantId(parentCar.getMerchantId())
.merchantType(hardManager.getTypes())
.merchantDeptId(hardManager.getDeptId())
.orderType(dto.getOrderType().getType())
.payType(hardPayTypeEnum.getType())
.totalPrice(totalPrice)
.extraPrice(0)
.payPrice(totalPrice)
.isOfflineOrder(YesNoEnum.NO.getCode())
.productDesc(subject)
.addressName(userMapAddress.getFullAddress())
.build();
if (ObjectUtil.equals(appPlusPlatformType, AppPlusPlatformTypeEnum.ZAX_APP_WALLET)) {
orderObj.setWalletId(wallet.getId());
}
baseMapper.insert(orderObj);
// 记录地址信息
HardOrderAddressEntity orderAddressEntity = HardOrderAddressEntity.of(userMapAddress);
orderAddressEntity.setOrderId(orderObj.getId());
hardOrderAddressService.save(orderAddressEntity);
// 如果是微信或者支付宝支付就需要创建订单
// `微信`或者`支付宝`
HardOrderEntity updateOrderObj = new HardOrderEntity();
updateOrderObj.setId(orderObj.getId());
updateOrderObj.setAddressId(orderAddressEntity.getId());
if (List.of(AppPlusPlatformTypeEnum.WECHAT, AppPlusPlatformTypeEnum.ALI_PAY).contains(appPlusPlatformType)) {
ThirdMiniRemotePayDto appPayDto = new ThirdMiniRemotePayDto();
appPayDto.setUserId(orderObj.getUserId());
appPayDto.setBizType(ThirdPayOrderBizTypeEnum.APP_SHOP_PAY);
appPayDto.setBizId(String.valueOf(orderObj.getId()));
appPayDto.setMiniPlatformType(appPlusPlatformType);
appPayDto.setAmount(totalPrice);
R<ThirdMiniAppPayVo> appPayRes = thirdAppPlusPayService.remoterAppPay(appPayDto);
if (!appPayRes.isOk()) {
throw new RuntimeException("发起app支付失败");
}
ThirdMiniAppPayVo appPayVo = appPayRes.getData();
// 更新订单订单号
updateOrderObj.setOrderNo(appPayVo.getPayNo());
result.setPayNo(appPayVo.getPayNo());
result.setAppPlusPayParams(appPayVo.getAppPlusPayParams());
// 扣减库存
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
}
// 资安信-钱包
else if (ObjectUtil.equals(appPlusPlatformType, AppPlusPlatformTypeEnum.ZAX_APP_WALLET)) {
// 钱包扣款
getSelf().fastReduceBalance(orderObj);
// 发送mq消息
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
}
baseMapper.updateById(updateOrderObj);
result.setOrderId(orderObj.getId());
return result;
}
@Override
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
@@ -1393,6 +1554,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
payPrice += order.getDeliveryPrice();
}
HardOrderEntity update = HardOrderEntity.builder().id(order.getId()).payTime(LocalDateTime.now()).orderStatus(HardOrderStatusEnum.PAY.getType()).payPrice(payPrice).build();
if (ObjectUtil.equals(order.getOrderType(), HardOrderTypeEnum.FARMER.getType())) {
update.setOrderStatus(HardOrderStatusEnum.SHOP_WAIT_PAY_SUCCESS.getType());
}
if (ObjectUtil.isNotEmpty(order.getOrderNo())) {
update.setOrderNo(order.getOrderNo());
}
@@ -1618,7 +1782,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
codeType = WalletCodeBizEnum.SUPERMARKET_RESERVE;
}
// 共富商城预定核销
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.FARMER) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.FARMER)) {
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.SELF_APP) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.FARMER)) {
codeType = WalletCodeBizEnum.FARMER_RESERVE;
}
if (ObjectUtil.isEmpty(codeType)) return;
@@ -1897,6 +2061,64 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
return true;
}
/**
* 快递发货或者修改发货单号
*/
@Override
public Boolean shipment(HardShipmentDto dto) {
HardOrderAddressEntity orderAddress = hardOrderAddressService.getById(dto.getAddressId());
if (ObjectUtil.isEmpty(orderAddress)) throw new RuntimeException("订单地址不存在");
HardOrderEntity order = baseMapper.selectById(orderAddress.getOrderId());
if (ObjectUtil.isEmpty(order)) throw new RuntimeException("订单地址不存在");
if (!List.of(HardOrderTypeEnum.FARMER.getType()).contains(order.getOrderType())) {
throw new RuntimeException("该订单类型不支持物流");
}
HardOrderEntity updateOrderObj = new HardOrderEntity();
updateOrderObj.setId(order.getId());
updateOrderObj.setShipmentNo(dto.getShipmentNo());
// 添加快递单号
if (ObjectUtil.isEmpty(order.getShipmentNo())) {
if (ObjectUtil.notEqual(HardOrderStatusEnum.SHOP_WAIT_PAY_SUCCESS.getType(), order.getOrderStatus())) {
throw new RuntimeException("该订单状态不支持物流发货");
}
updateOrderObj.setShippedTime(LocalDateTime.now());
updateOrderObj.setOrderStatus(HardOrderStatusEnum.SHOP_WAIT_RECEIVE.getType());
} else {
}
baseMapper.updateById(updateOrderObj);
return true;
}
/**
* 确认收货
*/
@Override
public Boolean confirmReceipt(Long userId, Long orderId) {
HardOrderEntity order = baseMapper.selectOne(new LambdaQueryWrapper<HardOrderEntity>()
.eq(HardOrderEntity::getUserId, userId)
.eq(HardOrderEntity::getId, orderId)
);
if (ObjectUtil.isEmpty(order)) throw new RuntimeException("订单不存在");
if (ObjectUtil.isEmpty(order.getShipmentNo())) throw new RuntimeException("快递单号不存在");
// 订单状态判断
if (!List.of(HardOrderTypeEnum.FARMER.getType()).contains(order.getOrderType())) {
throw new RuntimeException("该订单类型不支持确认收货");
}
if (ObjectUtil.notEqual(HardOrderStatusEnum.SHOP_WAIT_RECEIVE.getType(), order.getOrderStatus())) {
throw new RuntimeException("该订单状态不支持确认收货");
}
HardOrderEntity updateOrderObj = new HardOrderEntity();
updateOrderObj.setId(order.getId());
updateOrderObj.setOrderStatus(HardOrderStatusEnum.SHOP_WAIT_EVALUATE.getType());
updateOrderObj.setDeliveredTime(LocalDateTime.now());
baseMapper.updateById(updateOrderObj);
return true;
}
// 二维码类型的订单是否被核销 true被核销 false未核销
private boolean validateCodeIsCancel(HardOrderTypeEnum orderType, Long orderId) {
Boolean flag = switch (orderType) {
@@ -4,7 +4,9 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniRemotePayDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdRemoterRefundDto;
import com.bsd.pjcloud.thirdparty.vo.appplus.pay.ThirdMiniAppPayVo;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@@ -28,6 +30,12 @@ public interface RemoterThirdAppPlusPayService {
@PostMapping("/pay-remoter/micropay")
R<String> remoterMicropay(@RequestBody ThirdMicropayDto dto);
/**
* app支付
*/
@PostMapping("/pay-remoter/app-pay")
R<ThirdMiniAppPayVo> remoterAppPay(@RequestBody ThirdMiniRemotePayDto dto);
/**
* 支付退款
*/
@@ -23,7 +23,7 @@ public enum AppPlusPlatformTypeEnum {
public static AppPlusPlatformTypeEnum valueOfByType(String type) {
if (ObjectUtil.isEmpty(type)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().orElse(null);
}
}
@@ -15,6 +15,7 @@ public enum ThirdPayOrderBizTypeEnum {
MINI_APP_WALLET_RECHARGE("10", "小程序用户钱包充值"),
YXFJ_PAY("20", "云消费机付款码支付"),
APP_SHOP_PAY("30", "APP支付-购买商品(有订单)"),
;
private final String type;
@@ -0,0 +1,15 @@
package com.bsd.pjcloud.thirdparty.dto.appplus;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class ThirdMiniRemotePayDto extends ThirdMiniAppPayDto {
/**
* 用户id不能为空
*/
@NotNull(message = "用户id不能为空")
private Long userId;
}
@@ -1,5 +1,6 @@
package com.bsd.pjcloud.thirdparty.dto.appplus;
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderBizTypeEnum;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@@ -12,6 +13,12 @@ public class ThirdRemoterRefundDto {
@NotNull(message = "订单id不能为空")
private Long orderId;
/**
* 第三方支付业务类型
*/
@NotNull(message = "第三方支付业务类型不能为空")
private ThirdPayOrderBizTypeEnum bizType;
/**
* 退款金额
*/
@@ -6,6 +6,7 @@ import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformPayType;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniRemotePayDto;
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdRemoterRefundDto;
import com.bsd.pjcloud.thirdparty.service.ThirdAppPlusService;
import com.bsd.pjcloud.thirdparty.service.ThirdAppPlusWechatFzService;
@@ -51,6 +52,12 @@ public class ThirdAppPlusController {
return R.ok(thirdAppPlusService.micropay(dto));
}
@Operation(summary = "app支付")
@PostMapping("/app-pay")
public R<ThirdMiniAppPayVo> remoterAppPay(@RequestBody ThirdMiniRemotePayDto dto) {
return R.ok(thirdAppPlusService.miniPay(dto.getUserId(), dto));
}
/* ************************************* end 远程调用 end ************************************* */
@Operation(summary = "商户改动")
@@ -15,7 +15,10 @@ import com.bsd.pjcloud.app.api.constant.AppUserTypeEnum;
import com.bsd.pjcloud.app.api.dto.AppAdminSyncDto;
import com.bsd.pjcloud.app.api.dto.AppUserInfo;
import com.bsd.pjcloud.app.api.feign.RemoteAppUserService;
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.hard.api.dto.order.remote.HardUpdateShopStatusDto;
import com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService;
import com.bsd.pjcloud.thirdparty.config.AppPlusPayConfig;
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformLoginErrorEnum;
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformPayType;
@@ -77,6 +80,7 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
private final RemoteAppUserService remoteAppUserService;
private final RemoteWalletRechargePackageService remoteWalletRechargePackageService;
private final RemoteMchService remoteMchService;
private final RemoteHardOrderService remoteHardOrderService;
/**
* 小程序登录
@@ -181,9 +185,9 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
if (ObjectUtil.isEmpty(userInfo)) {
throw new RuntimeException("用户不存在");
}
MchManageVo mchManage = remoteMchService.getViewsCanteenMchByDeptId(userInfo.getSysUser().getDeptId()).getData();
MchManageVo mchManage = remoteMchService.getViewsMchByDeptId(userInfo.getSysUser().getDeptId(), List.of(MerchantTypeEnum.FARMER, MerchantTypeEnum.CANTEEN)).getData();
if (ObjectUtil.isEmpty(mchManage)) {
throw new RuntimeException("用户不属于任何食堂");
throw new RuntimeException("用户不属于任何食堂或者商城");
}
if (ObjectUtil.isEmpty(mchManage.getPaySettingList())) {
throw new RuntimeException("商户未配置支付参数");
@@ -211,61 +215,63 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
dto.setAmount(price);
}
// 不支持的类型
else {
else if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.APP_SHOP_PAY)) {
if (dto.getAmount() <= 0) {
throw new RuntimeException("支付金额不能小于等于0");
}
dto.setAmount(dto.getAmount());
} else {
throw new RuntimeException("不支持的支付类型");
}
try {
ThirdAppPlusPayDto appPlusPayDto = new ThirdAppPlusPayDto();
// 当前时间戳+10位随机字符串
String outTradeNo = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() + RandomUtil.randomString(10);
appPlusPayDto.setOutTradeNo(outTradeNo);
appPlusPayDto.setBizId(dto.getBizId());
appPlusPayDto.setBizType(dto.getBizType());
appPlusPayDto.setUserId(userId);
appPlusPayDto.setOpenid(dto.getOpenId());
appPlusPayDto.setAmount(dto.getAmount());
appPlusPayDto.setMchId(mchManage.getId());
result.setPayNo(outTradeNo);
ThirdAppPlusPayDto appPlusPayDto = new ThirdAppPlusPayDto();
// 当前时间戳+10位随机字符串
String outTradeNo = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() + RandomUtil.randomString(10);
appPlusPayDto.setOutTradeNo(outTradeNo);
appPlusPayDto.setBizId(dto.getBizId());
appPlusPayDto.setBizType(dto.getBizType());
appPlusPayDto.setUserId(userId);
appPlusPayDto.setOpenid(dto.getOpenId());
appPlusPayDto.setAmount(dto.getAmount());
appPlusPayDto.setMchId(mchManage.getId());
// 微信小程序
if (ObjectUtil.equals(dto.getMiniPlatformType().getType(), AppPlusPlatformTypeEnum.WECHAT.getType())) {
MchPaySettingVo paySetting = paySettingList.stream().filter(item -> ObjectUtil.equals(item.getPlatformType(), AppPlusPlatformPayType.WECHAT.getType())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(paySetting) || ObjectUtil.isEmpty(paySetting.getSettingJson())) {
throw new RuntimeException("商户未配置微信支付参数");
}
MchPaySettingEntity.WechatPaySetting wechatPaySetting = JSONUtil.toBean(paySetting.getSettingJson(), MchPaySettingEntity.WechatPaySetting.class);
appPlusPayDto.setSubMchid(wechatPaySetting.getSubMchid());
result.setPayNo(outTradeNo);
Map<String, Object> appPlusPayParams = thirdMiniAppWechatService.appPay(appPlusPayDto, paySetting);
if (ObjectUtil.isEmpty(appPlusPayParams)) {
throw new RuntimeException("创建微信支付错误");
}
result.setAppPlusPayParams(appPlusPayParams);
// 微信小程序
if (ObjectUtil.equals(dto.getMiniPlatformType().getType(), AppPlusPlatformTypeEnum.WECHAT.getType())) {
MchPaySettingVo paySetting = paySettingList.stream().filter(item -> ObjectUtil.equals(item.getPlatformType(), AppPlusPlatformPayType.WECHAT.getType())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(paySetting) || ObjectUtil.isEmpty(paySetting.getSettingJson())) {
throw new RuntimeException("商户未配置微信支付参数");
}
// 支付宝
else if (ObjectUtil.equals(dto.getMiniPlatformType().getType(), AppPlusPlatformTypeEnum.ALI_PAY.getType())) {
MchPaySettingVo paySetting = paySettingList.stream().filter(item -> ObjectUtil.equals(item.getPlatformType(), AppPlusPlatformPayType.ALI_PAY.getType())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(paySetting)) {
throw new RuntimeException("商户未配置微信支付参数");
}
MchPaySettingEntity.AliPaySetting aliPaySetting = JSONUtil.toBean(paySetting.getSettingJson(), MchPaySettingEntity.AliPaySetting.class);
appPlusPayDto.setSubMchid(aliPaySetting.getSubMchid());
MchPaySettingEntity.WechatPaySetting wechatPaySetting = JSONUtil.toBean(paySetting.getSettingJson(), MchPaySettingEntity.WechatPaySetting.class);
appPlusPayDto.setSubMchid(wechatPaySetting.getSubMchid());
String orderStr = thirdMiniAppAliPayService.appPay(appPlusPayDto, paySetting);
if (ObjectUtil.isEmpty(orderStr)) {
throw new RuntimeException("创建支付宝支付错误");
}
HashMap<String, Object> aliPayParams = new HashMap<String, Object>();
aliPayParams.put("orderInfo", orderStr);
result.setAppPlusPayParams(aliPayParams);
Map<String, Object> appPlusPayParams = thirdMiniAppWechatService.appPay(appPlusPayDto, paySetting);
if (ObjectUtil.isEmpty(appPlusPayParams)) {
throw new RuntimeException("创建微信支付错误");
}
// 不支持的支付类型
else {
throw new RuntimeException("不支持的支付类型");
result.setAppPlusPayParams(appPlusPayParams);
}
// 支付宝
else if (ObjectUtil.equals(dto.getMiniPlatformType().getType(), AppPlusPlatformTypeEnum.ALI_PAY.getType())) {
MchPaySettingVo paySetting = paySettingList.stream().filter(item -> ObjectUtil.equals(item.getPlatformType(), AppPlusPlatformPayType.ALI_PAY.getType())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(paySetting)) {
throw new RuntimeException("商户未配置微信支付参数");
}
} catch (Exception e) {
MchPaySettingEntity.AliPaySetting aliPaySetting = JSONUtil.toBean(paySetting.getSettingJson(), MchPaySettingEntity.AliPaySetting.class);
appPlusPayDto.setSubMchid(aliPaySetting.getSubMchid());
String orderStr = thirdMiniAppAliPayService.appPay(appPlusPayDto, paySetting);
if (ObjectUtil.isEmpty(orderStr)) {
throw new RuntimeException("创建支付宝支付错误");
}
HashMap<String, Object> aliPayParams = new HashMap<String, Object>();
aliPayParams.put("orderInfo", orderStr);
result.setAppPlusPayParams(aliPayParams);
}
// 不支持的支付类型
else {
throw new RuntimeException("不支持的支付类型");
}
return result;
}
@@ -384,7 +390,7 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
@Override
public String remoterRefund(ThirdRemoterRefundDto dto) {
// 查询详情
ThirdPayOrderEntity thirdPayOrder = thirdPayOrderService.getByBiz(ThirdPayOrderBizTypeEnum.YXFJ_PAY, String.valueOf(dto.getOrderId()));
ThirdPayOrderEntity thirdPayOrder = thirdPayOrderService.getByBiz(dto.getBizType(), String.valueOf(dto.getOrderId()));
if (ObjectUtil.isEmpty(thirdPayOrder)) {
log.error("|{}|远程退款,订单不存在dto:|{}|", TAG, JSONUtil.toJsonStr(dto));
throw new RuntimeException("订单不存在");
@@ -418,7 +424,7 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
}
/**
* 小程序支付回调
* 支付回调
*/
@Override
public String miniPayCallback(Map<String, String> params, String body, Map<String, String> headers) {
@@ -614,42 +620,64 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
if (ObjectUtil.notEqual(thirdPayOrder.getStatus(), ThirdPayOrderStatusEnum.PAY_SUCCESS.getType())) {
return true;
}
if (ObjectUtil.notEqual(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
if (ObjectUtil.equals(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
// 已经支付
try {
WalletRechargePaySuccess dto = new WalletRechargePaySuccess();
dto.setPayNo(thirdPayOrder.getPayNo());
dto.setUserId(thirdPayOrder.getUserId());
dto.setBizId(thirdPayOrder.getBizId());
dto.setBizType(thirdPayOrder.getBizType());
return remoteWalletRechargePackageService.remotePaySuccess(dto).getData();
} catch (Exception e) {
log.error("|小程序用户钱包充值|处理小程序支付成功回调异常", e);
return false;
}
} else if (ObjectUtil.equals(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.APP_SHOP_PAY.getType())) {
try {
HardUpdateShopStatusDto dto = new HardUpdateShopStatusDto();
dto.setOrderId(Long.valueOf(thirdPayOrder.getBizId()));
dto.setStatus(HardUpdateShopStatusDto.ChangeShopStatus.PAY_SUCCESS);
return remoteHardOrderService.updateShopStatus(dto).getData();
} catch (Exception e) {
log.error("|APP支付-购买商品(有订单)|处理小程序支付成功回调异常", e);
return false;
}
} else {
return true;
}
// 已经支付
try {
WalletRechargePaySuccess dto = new WalletRechargePaySuccess();
dto.setPayNo(thirdPayOrder.getPayNo());
dto.setUserId(thirdPayOrder.getUserId());
dto.setBizId(thirdPayOrder.getBizId());
dto.setBizType(thirdPayOrder.getBizType());
return remoteWalletRechargePackageService.remotePaySuccess(dto).getData();
} catch (Exception e) {
log.error("处理小程序支付成功回调异常", e);
return false;
}
}
private boolean disposeRefundSuccessAfter(ThirdPayOrderEntity thirdPayOrder) {
if (ObjectUtil.notEqual(thirdPayOrder.getStatus(), ThirdPayOrderStatusEnum.REFUND_SUCCESS.getType())) {
return true;
}
if (ObjectUtil.notEqual(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
if (ObjectUtil.equals(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
// 已退款
try {
WalletRechargeRefundSuccess dto = new WalletRechargeRefundSuccess();
dto.setRefundNo(thirdPayOrder.getRefundNo());
dto.setUserId(thirdPayOrder.getUserId());
dto.setBizId(thirdPayOrder.getBizId());
dto.setBizType(thirdPayOrder.getBizType());
return remoteWalletRechargePackageService.remoteRefundSuccess(dto).getData();
} catch (Exception e) {
log.error("|小程序用户钱包充值|处理小程序退款成功回调异常", e);
return false;
}
} else if (ObjectUtil.equals(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.APP_SHOP_PAY.getType())) {
try {
HardUpdateShopStatusDto dto = new HardUpdateShopStatusDto();
dto.setOrderId(Long.valueOf(thirdPayOrder.getBizId()));
dto.setStatus(HardUpdateShopStatusDto.ChangeShopStatus.REFUND_SUCCESS);
return remoteHardOrderService.updateShopStatus(dto).getData();
} catch (Exception e) {
log.error("|APP支付-购买商品(有订单)|处理小程序退款成功回调异常", e);
return false;
}
} else {
return true;
}
// 已退款
try {
WalletRechargeRefundSuccess dto = new WalletRechargeRefundSuccess();
dto.setRefundNo(thirdPayOrder.getRefundNo());
dto.setUserId(thirdPayOrder.getUserId());
dto.setBizId(thirdPayOrder.getBizId());
dto.setBizType(thirdPayOrder.getBizType());
return remoteWalletRechargePackageService.remoteRefundSuccess(dto).getData();
} catch (Exception e) {
log.error("处理小程序退款成功回调异常", e);
return false;
}
}
}
@@ -59,4 +59,8 @@ public interface RemoteMchService {
@NoToken
@GetMapping("/mch-manage/get-views-canteen-mch-by-dept-id")
R<MchManageVo> getViewsCanteenMchByDeptId(@RequestParam Long deptId);
@NoToken
@GetMapping("/mch-manage/get-views-mch-by-dept-id")
R<MchManageVo> getViewsMchByDeptId(@RequestParam Long deptId, @RequestParam List<MerchantTypeEnum> mchTypeList);
}
@@ -155,6 +155,14 @@ public class MchManageController {
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(mchManage);
}
@Inner
@GetMapping("/get-views-mch-by-dept-id")
public R<MchManageVo> getViewsMchByDeptId(@RequestParam Long deptId, @RequestParam List<MerchantTypeEnum> mchTypeList) {
MchManageVo mchManage = mchManageService.getViewsCanteenMch(deptId, mchTypeList);
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(mchManage);
}
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@@ -45,7 +45,6 @@ public class MchPaySettingController {
@ApiCryptoAes
@GetMapping("/app/pay-type-list")
public R<List<MchPaySettingVo>> getUserPaySettingList() {
System.out.println("getUserPaySettingList");
PjcloudUser user = SecurityUtils.getUser();
return R.ok(mchPaySettingService.getUserPaySettingList(user));
}
@@ -100,14 +100,12 @@ public class MchPaySettingServiceImpl extends ServiceImpl<MchPaySettingMapper, M
*/
@Override
public List<MchPaySettingVo> getUserPaySettingList(PjcloudUser user) {
log.error("getUserPaySettingList.user:{}", JSONUtil.toJsonStr(user));
log.warn("getUserPaySettingList.user:{}", JSONUtil.toJsonStr(user));
// 查询当前的登录用户
UserInfo userInfo = remoteUserService.getByUserId(user.getId()).getData();
if (ObjectUtil.isEmpty(userInfo)) {
throw new RuntimeException("用户不存在");
}
MchManageVo targetMch = mchManageService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), List.of(MerchantTypeEnum.CANTEEN));
MchManageVo targetMch = mchManageService.getViewsCanteenMch(userInfo.getSysUser().getDeptId(), List.of(MerchantTypeEnum.CANTEEN, MerchantTypeEnum.FARMER));
if (ObjectUtil.isEmpty(targetMch) || ObjectUtil.isEmpty(targetMch.getPaySettingList())) {
return List.of();
}