feat:发票添加申请人
feat:添加微信小程序的用户入口
This commit is contained in:
1 parent
d84b294966
commit
f1d6e2f2f6
26 files changed
+550
-77
No files matched your search
@@ -115,6 +115,12 @@
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.40.251.ALL</version>
|
||||
</dependency>
|
||||
<!-- 微信登录(小程序) -->
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
|
||||
<version>4.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.bsd.pjcloud.app.config;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(MiniWechatConf.class)
|
||||
public class MinWechatConfiguration {
|
||||
|
||||
private final MiniWechatConf properties;
|
||||
|
||||
@Autowired
|
||||
public MinWechatConfiguration(MiniWechatConf properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public WxMaService wxMaService() {
|
||||
|
||||
WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
|
||||
wxMaDefaultConfig.setAppid(properties.getAppId());
|
||||
wxMaDefaultConfig.setSecret(properties.getAppSecret());
|
||||
wxMaDefaultConfig.setMsgDataFormat("JSON");
|
||||
|
||||
WxMaService maService = new WxMaServiceImpl();
|
||||
maService.setWxMaConfig(wxMaDefaultConfig);
|
||||
return maService;
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.app.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 微信小程序配置
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "mini-wechat-pay")
|
||||
public class MiniWechatConf {
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
private String appSecret;
|
||||
}
|
||||
+10
-7
@@ -24,6 +24,7 @@ import com.bsd.pjcloud.admin.api.dto.UserTokenDTO;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteTokenService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.app.api.dto.AppUserDTO;
|
||||
import com.bsd.pjcloud.app.service.AppUserService;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteCanteenSpuService;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteDailyMenuService;
|
||||
@@ -33,6 +34,7 @@ import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.vo.app.CanteenOnlineSpuAppVO;
|
||||
import com.bsd.pjcloud.canteen.vo.app.DailyMenuAppVO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdPartyAuthService;
|
||||
import com.bsd.pjcloud.thirdparty.dto.SHJNSSODTO;
|
||||
@@ -387,12 +389,13 @@ public class AppUserAutoLoginController {
|
||||
// return appUserService.importUser(excelVOList, bindingResult);
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "注册app用户表", description = "注册app用户表")
|
||||
// @SysLog("注册app用户表")
|
||||
// @Inner(value = false)
|
||||
// @PostMapping("/register")
|
||||
// public R register(@RequestBody AppUserDTO appUser) {
|
||||
// return appUserService.registerAppUser(appUser);
|
||||
// }
|
||||
|
||||
//@Operation(summary = "注册app用户表", description = "注册app用户表")
|
||||
//@SysLog("注册app用户表")
|
||||
//@Inner(value = false)
|
||||
//@PostMapping("/register")
|
||||
//public R register(@RequestBody AppUserDTO appUser) {
|
||||
// return appUserService.registerAppUser(appUser);
|
||||
//}
|
||||
|
||||
}
|
||||
+25
-30
@@ -17,18 +17,15 @@
|
||||
|
||||
package com.bsd.pjcloud.app.handler;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bsd.pjcloud.app.api.constant.AppUserTypeEnum;
|
||||
import com.bsd.pjcloud.app.api.dto.AppUserInfo;
|
||||
import com.bsd.pjcloud.app.api.entity.AppSocialDetails;
|
||||
import com.bsd.pjcloud.app.api.entity.AppUser;
|
||||
import com.bsd.pjcloud.app.mapper.AppSocialDetailsMapper;
|
||||
import com.bsd.pjcloud.app.service.AppUserService;
|
||||
import com.bsd.pjcloud.common.core.constant.SecurityConstants;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.LoginTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.exception.CheckedException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -47,6 +44,8 @@ public class MiniWechatLoginHandler extends AbstractLoginHandler {
|
||||
|
||||
private final AppSocialDetailsMapper appSocialDetailsMapper;
|
||||
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
/**
|
||||
* 小程序登录传入code
|
||||
* <p>
|
||||
@@ -57,20 +56,16 @@ public class MiniWechatLoginHandler extends AbstractLoginHandler {
|
||||
*/
|
||||
@Override
|
||||
public String identify(String code) {
|
||||
AppSocialDetails condition = new AppSocialDetails();
|
||||
condition.setType(LoginTypeEnum.MINI_APP.getType());
|
||||
AppSocialDetails socialDetails = appSocialDetailsMapper.selectOne(new QueryWrapper<>(condition));
|
||||
|
||||
String url = String.format(SecurityConstants.MINI_APP_AUTHORIZATION_CODE_URL, socialDetails.getAppId(),
|
||||
socialDetails.getAppSecret(), code);
|
||||
String result = HttpUtil.get(url);
|
||||
log.debug("微信小程序响应报文:{}", result);
|
||||
|
||||
if (JSONUtil.parseObj(result).containsKey("openid")) {
|
||||
return JSONUtil.parseObj(result).get("openid").toString();
|
||||
} else {
|
||||
log.error("微信小程序登录失败:{}", result);
|
||||
throw new CheckedException("微信小程序登录失败");
|
||||
try {
|
||||
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
||||
if (ObjectUtil.isNotEmpty(session) && ObjectUtil.isNotEmpty(session.getOpenid())) {
|
||||
return session.getOpenid();
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("微信小程序登录失败:{}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,22 +78,22 @@ public class MiniWechatLoginHandler extends AbstractLoginHandler {
|
||||
@Override
|
||||
public AppUserInfo info(String openId) {
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>query().lambda().eq(AppUser::getOpenid, openId));
|
||||
|
||||
// 未注册用户自动注册
|
||||
if (Objects.isNull(user)) {
|
||||
log.info("微信小程序未绑定:{},创建新的用户", openId);
|
||||
if (ObjectUtil.isEmpty(user)) {
|
||||
log.info("微信小程序openId:{},创建新的用户", openId);
|
||||
String name = "微信游客-" + openId;
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setOpenid(openId);
|
||||
appUser.setUsername(openId);
|
||||
appUser.setUserType(AppUserTypeEnum.MINI_ALIPAY.getType());
|
||||
appUser.setUsername(name);
|
||||
appUser.setName(name);
|
||||
appUser.setCreateBy(openId);
|
||||
appUser.setUpdateBy(openId);
|
||||
appUserService.saveOrUpdate(appUser);
|
||||
|
||||
AppUserInfo appUserDTO = new AppUserInfo();
|
||||
appUserDTO.setAppUser(appUser);
|
||||
return appUserDTO;
|
||||
return appUserService.findUserInfo(user);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(user.getLoginExtJson())) {
|
||||
|
||||
}
|
||||
return appUserService.findUserInfo(user);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,3 +24,7 @@ mini-ali-pay:
|
||||
alipay-public-key: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqnCB+N172m5gxf1Rolfx5LErSiVwQCh0XQdDrVy6aTuVF5EtdqahSHtADyEPsBWudMBhzCfqpoZvfnvH7a+PED6uZ3DoXt7ETh8TmNM5yc+WTnD8pSphQvuHDJ3zMks489KNxiX6sXag71k9H1MXklJGPOUaljHqy/QlRn2ZLT7pFgaFH9LEcVoQBPIOurUn95078h848RFD30jZFW3fakxUGAGVVZaHH62z5OEWOmcA+CwxsEDMa1XMt02RGXgAAq4WOj+BqOGiFmhM8rnrUMchTyvx4umOzGvbF2Y9irN3aBZ5lfg+bzYcJpIOMzlM/V00LnEWzCblJzXNyH4hJQIDAQAB
|
||||
callback-url: https://rj4jv5rwqs.by.takin.cc/hard/hard-ali-pay/callback
|
||||
# callback-url: https://stgl.pj.gov.cn/api/hard/hard-ali-pay/callback
|
||||
|
||||
mini-wechat-pay:
|
||||
app-id: wx95481f43b14565e5
|
||||
app-secret: 0aee1289b5ae14c0c69b8f5e9a4e518e
|
||||
+3
-2
@@ -7,14 +7,15 @@ import lombok.Getter;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方面密类型
|
||||
* 第三方免密支付状态
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardThirdMiStatusEnum {
|
||||
|
||||
CREATE_ORDER("10", "创建订单"),
|
||||
PAY("20", "支付订单"),
|
||||
PAY_SUCCESS("20", "支付成功"),
|
||||
PAY_ERROR("21", "支付失败"),
|
||||
REFUND("30", "取消/退款"),
|
||||
;
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方面密类型
|
||||
* 第三方免密类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.hard.api.dto;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class HardThirdMiOrderDto extends HardThirdMiOrderEntity {
|
||||
|
||||
/**
|
||||
* 创建订单时间
|
||||
*/
|
||||
private LocalDateTime[] createOrderTimeList;
|
||||
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
private LocalDateTime[] payOrderTimeList;
|
||||
|
||||
/**
|
||||
* 退款时间
|
||||
*/
|
||||
private LocalDateTime[] refundOrderTimeList;
|
||||
|
||||
}
|
||||
+18
-1
@@ -19,7 +19,6 @@ import java.time.LocalDateTime;
|
||||
@Schema(description = "硬件商品免密订单")
|
||||
public class HardThirdMiOrderEntity extends Model<HardThirdMiOrderEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@@ -63,6 +62,18 @@ public class HardThirdMiOrderEntity extends Model<HardThirdMiOrderEntity> {
|
||||
@Schema(description = "订单id")
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 退款id
|
||||
*/
|
||||
@Schema(description = "退款id")
|
||||
private Long refundId;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@Schema(description = "设备id")
|
||||
private Long hardId;
|
||||
|
||||
/**
|
||||
* 外部订单号
|
||||
*/
|
||||
@@ -117,6 +128,12 @@ public class HardThirdMiOrderEntity extends Model<HardThirdMiOrderEntity> {
|
||||
@Schema(description = "支付金额")
|
||||
private int payPrice;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
@Schema(description = "退款金额")
|
||||
private int refundPrice;
|
||||
|
||||
/**
|
||||
* 原始 sign json 数据
|
||||
*/
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.bsd.pjcloud.hard.api.vo;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardThirdMiOrderVo extends HardThirdMiOrderEntity implements BaseHardInterface {
|
||||
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
private String username;
|
||||
|
||||
private String userMobile;
|
||||
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 设备相关
|
||||
*/
|
||||
private String hardName;
|
||||
|
||||
private String hardType;
|
||||
|
||||
private List<String> hardTypeCodes;
|
||||
|
||||
}
|
||||
+13
-3
@@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiPayDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardThirdMiOrderVo;
|
||||
import com.bsd.pjcloud.hard.service.HardThirdMiOrderService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
@@ -55,6 +57,15 @@ public class HardThirdMiOrderController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
@Operation(summary = "退款", description = "退款")
|
||||
@GetMapping("/refund")
|
||||
public R refund(@RequestParam("id") Long id) {
|
||||
hardThirdMiOrderService.refund(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
@@ -62,9 +73,8 @@ public class HardThirdMiOrderController {
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('thirdmi_hardThirdMiOrder_view')")
|
||||
public R getHardThirdMiOrderPage(@ParameterObject Page page, @ParameterObject HardThirdMiOrderEntity hardThirdMiOrder) {
|
||||
LambdaQueryWrapper<HardThirdMiOrderEntity> wrapper = Wrappers.lambdaQuery();
|
||||
return R.ok(hardThirdMiOrderService.page(page, wrapper));
|
||||
public R<Page<HardThirdMiOrderVo>> getHardThirdMiOrderPage(@ParameterObject Page page, @ParameterObject HardThirdMiOrderDto dto) {
|
||||
return R.ok(hardThirdMiOrderService.scopePageJoin(page, dto, null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
@@ -1,9 +1,14 @@
|
||||
package com.bsd.pjcloud.hard.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardThirdMiOrderVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface HardThirdMiOrderMapper extends PjcloudBaseMapper<HardThirdMiOrderEntity> {
|
||||
@@ -19,4 +24,6 @@ public interface HardThirdMiOrderMapper extends PjcloudBaseMapper<HardThirdMiOrd
|
||||
.eq(HardThirdMiOrderEntity::getOrderId, orderId)
|
||||
);
|
||||
}
|
||||
|
||||
Page<HardThirdMiOrderVo> scopePageJoin(Page page, @Param("dto") HardThirdMiOrderDto dto, DataScope dataScope);
|
||||
}
|
||||
+15
-2
@@ -1,22 +1,35 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiPayDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardThirdMiOrderVo;
|
||||
|
||||
public interface HardThirdMiOrderService extends IService<HardThirdMiOrderEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
Page<HardThirdMiOrderVo> scopePageJoin(Page page, HardThirdMiOrderDto dto, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 刷新订单
|
||||
*/
|
||||
void refresh(Long id);
|
||||
HardThirdMiOrderEntity refresh(Long id);
|
||||
|
||||
/**
|
||||
* 后台支付
|
||||
*/
|
||||
void adminPay(HardThirdMiPayDto dto);
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
void refund(Long id);
|
||||
|
||||
/**
|
||||
* 根据授权id查询授权订单
|
||||
*/
|
||||
|
||||
+6
-1
@@ -17,6 +17,11 @@ public interface MiniAlipayService {
|
||||
*/
|
||||
String miDynamicSign(Long userId, UserTypeEnum userType, Long authId);
|
||||
|
||||
/**
|
||||
* 免密授权(需要押金)
|
||||
*/
|
||||
ZhimaCreditPayafteruseCreditbizorderCreateResponse miDynamicCreate(Long userId, UserTypeEnum userType, Long authId);
|
||||
|
||||
/**
|
||||
* 查询免密授权
|
||||
*/
|
||||
@@ -45,6 +50,6 @@ public interface MiniAlipayService {
|
||||
/**
|
||||
* 支付宝免密(取消/退款)
|
||||
*/
|
||||
AlipayTradeRefundResponse miCancelOrRefund(String authId, String refundId, int price);
|
||||
AlipayTradeRefundResponse miCancelOrRefund(HardThirdMiOrderEntity thirdOrder);
|
||||
|
||||
}
|
||||
+1
-1
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alipay.api.response.AlipayTradeCreateResponse;
|
||||
import com.alipay.api.response.ZhimaCreditPayafteruseCreditbizorderCreateResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -150,7 +151,6 @@ public class HardAuthServiceImpl extends ServiceImpl<HardAuthMapper, HardAuthEnt
|
||||
|
||||
HardAppCreateThirdDoorOrderVo res = new HardAppCreateThirdDoorOrderVo();
|
||||
|
||||
// AlipayTradeCreateResponse alipayRes = miniAlipayService.miCreateOrder(appUser.getOpenid(), authEntity.getId(), dto.getUserId(), dto.getUserType());
|
||||
AlipayTradeCreateResponse alipayRes = miniAlipayService.miCreateOrder(appUser.getOpenid(), authEntity.getId(), dto.getUserId(), dto.getUserType());
|
||||
if (ObjectUtil.isEmpty(alipayRes)) {
|
||||
throw new RuntimeException("创建支付宝免密订单失败");
|
||||
|
||||
+1
@@ -269,6 +269,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
updateMiOrderObj.setOrderId(orderId);
|
||||
updateMiOrderObj.setFlowId(flowDetail.getId());
|
||||
updateMiOrderObj.setOutOrderNo(String.valueOf(orderId));
|
||||
updateMiOrderObj.setHardId(flowDetail.getHardId());
|
||||
hardThirdMiOrderMapper.updateById(updateMiOrderObj);
|
||||
// 微信免密支付
|
||||
if (ObjectUtil.equals(thirdOrder.getBizType(), HardThirdMiTypeEnum.MI_WECHAT.getType())) {
|
||||
|
||||
+101
-4
@@ -3,18 +3,35 @@ package com.bsd.pjcloud.hard.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alipay.api.response.ZhimaCreditPayafteruseCreditbizorderQueryResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.vo.UserVO;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardThirdMiStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardThirdMiTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardThirdMiPayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardThirdMiOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardThirdMiOrderVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardThirdMiOrderMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardThirdMiOrderService;
|
||||
import com.bsd.pjcloud.hard.service.MiniAlipayService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* 硬件商品免密订单
|
||||
@@ -23,13 +40,27 @@ import java.math.BigDecimal;
|
||||
@AllArgsConstructor
|
||||
public class HardThirdMiOrderServiceImpl extends ServiceImpl<HardThirdMiOrderMapper, HardThirdMiOrderEntity> implements HardThirdMiOrderService {
|
||||
|
||||
private final HardManagerMapper hardManagerMapper;
|
||||
|
||||
private final MiniAlipayService miniAlipayService;
|
||||
|
||||
private final RemoteUserService userService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Override
|
||||
public Page<HardThirdMiOrderVo> scopePageJoin(Page page, HardThirdMiOrderDto dto, DataScope dataScope) {
|
||||
Page<HardThirdMiOrderVo> pageList = baseMapper.scopePageJoin(page, dto, dataScope);
|
||||
disposeList(pageList.getRecords());
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新订单
|
||||
*/
|
||||
@Override
|
||||
public void refresh(Long id) {
|
||||
public HardThirdMiOrderEntity refresh(Long id) {
|
||||
HardThirdMiOrderEntity order = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(order)) {
|
||||
throw new RuntimeException("订单不存在");
|
||||
@@ -37,7 +68,7 @@ public class HardThirdMiOrderServiceImpl extends ServiceImpl<HardThirdMiOrderMap
|
||||
// 微信免密支付
|
||||
if (ObjectUtil.equals(order.getBizType(), HardThirdMiTypeEnum.MI_WECHAT.getType())) {
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
// 支付宝-芝麻先享
|
||||
if (ObjectUtil.equals(order.getBizType(), HardThirdMiTypeEnum.MI_ALIPAY.getType())) {
|
||||
@@ -67,13 +98,14 @@ public class HardThirdMiOrderServiceImpl extends ServiceImpl<HardThirdMiOrderMap
|
||||
break;
|
||||
// 扣款成功状态
|
||||
case "TRADE_FINISHED":
|
||||
updateObj.setOrderStatus(HardThirdMiStatusEnum.PAY.getType());
|
||||
updateObj.setOrderStatus(HardThirdMiStatusEnum.PAY_SUCCESS.getType());
|
||||
break;
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(updateObj);
|
||||
return;
|
||||
return baseMapper.selectById(order.getId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,6 +134,33 @@ public class HardThirdMiOrderServiceImpl extends ServiceImpl<HardThirdMiOrderMap
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
@Override
|
||||
public void refund(Long id) {
|
||||
HardThirdMiOrderEntity order = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(order) || ObjectUtil.isNotEmpty(order.getOrderId())) {
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
order = refresh(id);
|
||||
// 微信免密支付
|
||||
if (ObjectUtil.equals(order.getBizType(), HardThirdMiTypeEnum.MI_WECHAT.getType())) {
|
||||
|
||||
return;
|
||||
}
|
||||
// 支付宝-芝麻先享
|
||||
if (ObjectUtil.equals(order.getBizType(), HardThirdMiTypeEnum.MI_ALIPAY.getType())) {
|
||||
if (ObjectUtil.equals(order.getOrderStatus(), HardThirdMiStatusEnum.REFUND.getType())) {
|
||||
throw new RuntimeException("支付宝-芝麻先享,此订单已退款");
|
||||
}
|
||||
if (ObjectUtil.notEqual(order.getOrderStatus(), HardThirdMiStatusEnum.PAY_SUCCESS.getType())) {
|
||||
throw new RuntimeException("支付宝-芝麻先享,此订单未支付");
|
||||
}
|
||||
miniAlipayService.miCancelOrRefund(order);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据授权id查询授权订单
|
||||
*/
|
||||
@@ -111,4 +170,42 @@ public class HardThirdMiOrderServiceImpl extends ServiceImpl<HardThirdMiOrderMap
|
||||
.eq(HardThirdMiOrderEntity::getAuthId, authId)
|
||||
);
|
||||
}
|
||||
|
||||
private void disposeList(List<HardThirdMiOrderVo> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
// 用户部门
|
||||
CompletableFuture<Void> userFuture = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
List<Long> userIds = list.stream().map(HardThirdMiOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
List<UserVO> userList = userService.getUserDeptByIds(userIds).getData();
|
||||
if (ObjectUtil.isNotEmpty(userList)) {
|
||||
Map<Long, UserVO> map = CollectionUtils.convertMap(userList, UserVO::getUserId);
|
||||
for (HardThirdMiOrderVo item : list) {
|
||||
UserVO userVO = map.get(item.getUserId());
|
||||
if (ObjectUtil.isEmpty(userVO)) continue;
|
||||
item.setUsername(userVO.getName());
|
||||
item.setUserMobile(userVO.getPhone());
|
||||
item.setUserAvatar(userVO.getAvatar());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设备
|
||||
CompletableFuture<Void> deviceFuture = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
List<Long> hardIds = list.stream().map(HardThirdMiOrderVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(hardIds)) {
|
||||
HardManagerDto hardManagerDto = new HardManagerDto();
|
||||
hardManagerDto.setIds(hardIds);
|
||||
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
|
||||
if (ObjectUtil.isNotEmpty(hardList)) {
|
||||
HardUtil.convertHardList(list, CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
|
||||
}
|
||||
}
|
||||
});
|
||||
CompletableFuture.allOf(userFuture, deviceFuture).join();
|
||||
}
|
||||
|
||||
}
|
||||
+57
-11
@@ -126,6 +126,51 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 免密授权(需要押金)
|
||||
*/
|
||||
@Override
|
||||
public ZhimaCreditPayafteruseCreditbizorderCreateResponse miDynamicCreate(Long userId, UserTypeEnum userType, Long authId) {
|
||||
int depositPricePrice = 300;
|
||||
|
||||
HardThirdMiOrderEntity thirdOrder = new HardThirdMiOrderEntity();
|
||||
thirdOrder.setBizType(HardThirdMiTypeEnum.MI_ALIPAY.getType());
|
||||
thirdOrder.setAuthId(authId);
|
||||
thirdOrder.setUserId(userId);
|
||||
thirdOrder.setDepositPrice(depositPricePrice);
|
||||
thirdOrder.setUserType(userType.getStatus());
|
||||
thirdOrder.setCreateOrderTime(LocalDateTime.now());
|
||||
thirdOrder.setOrderStatus(HardThirdMiStatusEnum.CREATE_ORDER.getType());
|
||||
|
||||
ZhimaCreditPayafteruseCreditbizorderCreateRequest request = new ZhimaCreditPayafteruseCreditbizorderCreateRequest();
|
||||
ZhimaCreditPayafteruseCreditbizorderCreateModel model = new ZhimaCreditPayafteruseCreditbizorderCreateModel();
|
||||
model.setOutOrderNo(String.valueOf(authId));
|
||||
model.setAmountType("RISK_AMOUNT");
|
||||
model.setZmServiceId(conf.getZmServiceId());
|
||||
model.setCategoryId("credit_pay_after_use");
|
||||
model.setOrderAmount(new BigDecimal(depositPricePrice).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
||||
model.setProductCode("CREDIT_PAY_AFTER_USE");
|
||||
model.setSubject("浦江智能柜芝麻先享");
|
||||
model.setBody("浦江智能柜芝麻先享");
|
||||
request.setBizModel(model);
|
||||
|
||||
System.out.println(JSONUtil.toJsonStr(model));
|
||||
try {
|
||||
ZhimaCreditPayafteruseCreditbizorderCreateResponse response = getClient().sdkExecute(request);
|
||||
if (!response.isSuccess()) {
|
||||
log.error("|免密授权(需要押金)|失败,json|{}", response.getBody());
|
||||
return null;
|
||||
}
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|免密授权(需要押金)|异常", e);
|
||||
return null;
|
||||
} finally {
|
||||
hardThirdMiOrderMapper.insert(thirdOrder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询面密授权
|
||||
*/
|
||||
@@ -209,7 +254,6 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
|
||||
// 一般是芝麻信用评估不通过、未开通等
|
||||
if (List.of("ZHIMA_CHECK_NO_PASS", "ZHIMA_EVALUATE_NO_PASS", "CREDIT_AGREEMENT_INVALID").contains(response.getCode())) {
|
||||
miDynamicCreate(authId, orderId);
|
||||
}
|
||||
|
||||
response.getCode();
|
||||
@@ -256,10 +300,13 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
*/
|
||||
@Override
|
||||
public AlipayTradeCreateResponse miCreateOrder(String openId, Long authId, Long userId, UserTypeEnum userType) {
|
||||
int depositPricePrice = 10;
|
||||
|
||||
HardThirdMiOrderEntity thirdOrder = new HardThirdMiOrderEntity();
|
||||
thirdOrder.setBizType(HardThirdMiTypeEnum.MI_ALIPAY.getType());
|
||||
thirdOrder.setAuthId(authId);
|
||||
thirdOrder.setUserId(userId);
|
||||
thirdOrder.setDepositPrice(depositPricePrice);
|
||||
thirdOrder.setUserType(userType.getStatus());
|
||||
thirdOrder.setCreateOrderTime(LocalDateTime.now());
|
||||
thirdOrder.setOrderStatus(HardThirdMiStatusEnum.CREATE_ORDER.getType());
|
||||
@@ -273,7 +320,7 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
// 设置订单附加信息
|
||||
bizContent.putOnce("body", "浦江智能柜芝麻先享");
|
||||
// 设置订单金额
|
||||
bizContent.putOnce("total_amount", 0.01);
|
||||
bizContent.putOnce("total_amount", new BigDecimal(depositPricePrice).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
||||
// 固定
|
||||
bizContent.putOnce("product_code", "JSAPI_PAY");
|
||||
// 用户登录id
|
||||
@@ -344,11 +391,12 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
updateObj.setPayOrderTime(LocalDateTime.now());
|
||||
updateObj.setOrderPrice(totalPrice);
|
||||
updateObj.setPayPrice(totalPrice);
|
||||
updateObj.setOrderStatus(HardThirdMiStatusEnum.PAY_ERROR.getType());
|
||||
|
||||
AlipayTradeOrderPayRequest request = new AlipayTradeOrderPayRequest();
|
||||
AlipayTradeOrderPayModel model = new AlipayTradeOrderPayModel();
|
||||
model.setOutRequestNo(String.valueOf(thirdOrder.getOrderId()));
|
||||
model.setTradeNo(thirdOrder.getOutOrderNo());
|
||||
model.setTradeNo(thirdOrder.getThirdOrderNo());
|
||||
model.setFulfillmentAmount(new BigDecimal(totalPrice).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).toString());
|
||||
model.setOrderPayMode("CREDIT_FULFILLMENT_ZM");
|
||||
try {
|
||||
@@ -360,7 +408,7 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
}
|
||||
log.info("|支付宝免密扣款|成功,json|{}", response.getBody());
|
||||
if (ObjectUtil.equals(response.getCode(), "10000")) {
|
||||
updateObj.setOrderStatus(HardThirdMiStatusEnum.PAY.getType());
|
||||
updateObj.setOrderStatus(HardThirdMiStatusEnum.PAY_SUCCESS.getType());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -369,9 +417,7 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
log.error("|支付宝免密扣款|异常", e);
|
||||
return false;
|
||||
} finally {
|
||||
if (ObjectUtil.isNotEmpty(updateObj.getOrderStatus())) {
|
||||
hardThirdMiOrderMapper.updateById(updateObj);
|
||||
}
|
||||
hardThirdMiOrderMapper.updateById(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,15 +425,15 @@ public class MiniAlipayServiceImpl implements MiniAlipayService {
|
||||
* 支付宝免密(取消/退款)
|
||||
*/
|
||||
@Override
|
||||
public AlipayTradeRefundResponse miCancelOrRefund(String authId, String refundId, int price) {
|
||||
public AlipayTradeRefundResponse miCancelOrRefund(HardThirdMiOrderEntity thirdOrder) {
|
||||
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
|
||||
JSONObject bizContent = new JSONObject();
|
||||
|
||||
// 订单总金额
|
||||
bizContent.putOnce("refund_amount", new BigDecimal(price).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
|
||||
bizContent.putOnce("refund_amount", new BigDecimal(thirdOrder.getRefundId()).divide(BigDecimal.valueOf(thirdOrder.getRefundPrice()), 2, RoundingMode.HALF_UP));
|
||||
// 商家订单唯一号
|
||||
bizContent.putOnce("out_trade_no", authId);
|
||||
bizContent.putOnce("out_request_no", refundId);
|
||||
bizContent.putOnce("out_trade_no", String.valueOf(thirdOrder.getAuthId()));
|
||||
bizContent.putOnce("out_request_no", String.valueOf(thirdOrder.getRefundId()));
|
||||
//扩展参数
|
||||
JSONObject extendParam = new JSONObject();
|
||||
extendParam.putOnce("is_fulfilled", "true");
|
||||
|
||||
-8
@@ -976,14 +976,6 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (isPay) {
|
||||
// 更新订单状态
|
||||
getSelf().orderSuccess(dto, false);
|
||||
// 更新第三方订单
|
||||
HardThirdMiOrderEntity thirdOrderObj = new HardThirdMiOrderEntity();
|
||||
thirdOrderObj.setId(thirdOrder.getId());
|
||||
thirdOrderObj.setOrderPrice(totalPrice);
|
||||
thirdOrderObj.setPayPrice(totalPrice);
|
||||
thirdOrderObj.setPayOrderTime(LocalDateTime.now());
|
||||
thirdOrderObj.setOrderStatus(HardThirdMiStatusEnum.PAY.getType());
|
||||
hardThirdMiOrderMapper.updateById(thirdOrderObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+67
@@ -3,4 +3,71 @@
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.hard.mapper.HardThirdMiOrderMapper">
|
||||
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.biz_type,
|
||||
a.user_id,
|
||||
a.user_type,
|
||||
a.auth_id,
|
||||
a.flow_id,
|
||||
a.order_id,
|
||||
a.refund_id,
|
||||
a.hard_id,
|
||||
a.out_order_no,
|
||||
a.third_order_no,
|
||||
a.create_order_time,
|
||||
a.pay_order_time,
|
||||
a.refund_order_time,
|
||||
a.order_status,
|
||||
a.deposit_price,
|
||||
a.order_price,
|
||||
a.pay_price,
|
||||
a.refund_price,
|
||||
a.org_sign_json,
|
||||
a.org_order_json,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.del_flag,
|
||||
a.tenant_id
|
||||
</sql>
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = '0'
|
||||
<if test="dto.bizType != null and dto.bizType != '' ">
|
||||
and a.biz_type = #{dto.bizType}
|
||||
</if>
|
||||
<if test="dto.userId != null ">
|
||||
and a.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.hardId != null ">
|
||||
and a.hard_id = #{dto.hardId}
|
||||
</if>
|
||||
<if test="dto.userType != null and dto.userType != '' ">
|
||||
and a.user_type = #{dto.userType}
|
||||
</if>
|
||||
<if test="dto.orderStatus != null and dto.orderStatus != '' ">
|
||||
and a.order_status = #{dto.orderStatus}
|
||||
</if>
|
||||
<if test="dto.createOrderTimeList != null and dto.createOrderTimeList.length == 2">
|
||||
and a.create_order_time between #{dto.createOrderTimeList[0]} and #{dto.createOrderTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.payOrderTimeList != null and dto.payOrderTimeList.length == 2">
|
||||
and a.pay_order_time between #{dto.payOrderTimeList[0]} and #{dto.payOrderTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.refundOrderTimeList != null and dto.refundOrderTimeList.length == 2">
|
||||
and a.refund_order_time between #{dto.refundOrderTimeList[0]} and #{dto.refundOrderTimeList[1]}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="scopePageJoin" resultType="com.bsd.pjcloud.hard.api.vo.HardThirdMiOrderVo">
|
||||
<include refid="selectA"/>
|
||||
from hard_third_mi_order a
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
order by a.create_order_time desc , a.id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+14
-6
@@ -26,12 +26,12 @@ public class RegisterController {
|
||||
|
||||
private final SysUserService userService;
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
*
|
||||
* @param userDto 用户信息
|
||||
* @return success/false
|
||||
*/
|
||||
// /**
|
||||
// * 注册用户
|
||||
// *
|
||||
// * @param userDto 用户信息
|
||||
// * @return success/false
|
||||
// */
|
||||
// @SysLog("注册用户")
|
||||
// @PostMapping("/user")
|
||||
// @ConditionalOnProperty(name = "register.user", matchIfMissing = true)
|
||||
@@ -39,6 +39,14 @@ public class RegisterController {
|
||||
// return userService.registerUser(userDto);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 注册普通用户
|
||||
*/
|
||||
@SysLog("注册用户")
|
||||
@PostMapping("/default-user")
|
||||
public R<Boolean> registerDefaultUser(@RequestBody UserDTO userDto) {
|
||||
return userService.registerDefaultUser(userDto);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+5
@@ -136,6 +136,11 @@ public interface SysUserService extends IService<SysUser> {
|
||||
*/
|
||||
R<Boolean> registerUser(UserDTO userDto);
|
||||
|
||||
/**
|
||||
* 注册普通用户
|
||||
*/
|
||||
R<Boolean> registerDefaultUser(UserDTO userDto);
|
||||
|
||||
/**
|
||||
* 锁定用户
|
||||
*
|
||||
|
||||
+65
@@ -753,6 +753,71 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户 赋予用户默认角色
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<Boolean> registerDefaultUser(UserDTO userDto) {
|
||||
userDto.setPhone(userDto.getUsername());
|
||||
// 判断用户名是否存在
|
||||
boolean usernameExists = this.exists(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, userDto.getUsername()));
|
||||
if (usernameExists) {
|
||||
String message = MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, userDto.getUsername());
|
||||
return R.failed(message);
|
||||
}
|
||||
// 判断手机号是否存在
|
||||
boolean phoneExists = this.exists(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getPhone, userDto.getPhone()));
|
||||
if (phoneExists) {
|
||||
String message = MsgUtils.getMessage(ErrorCodes.SYS_USER_PHONE_EXISTING, userDto.getPhone());
|
||||
return R.failed(message);
|
||||
}
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
|
||||
sysUser.setLockFlag(UserStateEnum.NORMAL.getCode());
|
||||
sysUser.setCreateBy(userDto.getUsername());
|
||||
sysUser.setUpdateBy(userDto.getUsername());
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
sysUser.setPasswordModifyTime(LocalDateTime.now());
|
||||
sysUser.setProcessStatus(TaskCheckStatusEnum.RESULT.getCode());
|
||||
sysUser.setProcessTime(LocalDateTime.now());
|
||||
sysUser.setStaffingType(UserStaffingTypeEnum.NONE_STAFFING.getType());
|
||||
baseMapper.insert(sysUser);
|
||||
|
||||
// 如果角色为空,赋默认角色
|
||||
if (CollUtil.isEmpty(userDto.getRole())) {
|
||||
// 获取默认角色编码
|
||||
String defaultRole = ParamResolver.getStr("USER_DEFAULT_ROLE");
|
||||
// 默认角色
|
||||
SysRole sysRole = sysRoleService.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, defaultRole));
|
||||
userDto.setRole(Collections.singletonList(sysRole.getRoleId()));
|
||||
}
|
||||
|
||||
// 插入用户角色关系表
|
||||
userDto.getRole().stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).forEach(sysUserRoleMapper::insert);
|
||||
|
||||
// 创建用户默认钱包、保证线程header
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
// 创建钱包
|
||||
remoteWalletService.createWallet(sysUser.getUserId());
|
||||
// 通知钱包
|
||||
remoteWalletService.userChange(sysUser.getUserId(), Boolean.FALSE);
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|创建用户钱包失败error:|{}|", TAG, e.getMessage());
|
||||
}
|
||||
});
|
||||
return R.ok(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 锁定用户
|
||||
*
|
||||
|
||||
+5
@@ -7,6 +7,11 @@ import lombok.Data;
|
||||
@Data
|
||||
public class WalletRechargeInvoiceVo extends WalletRechargeInvoiceEntity {
|
||||
|
||||
/**
|
||||
* 申请人相关
|
||||
*/
|
||||
private String applyUsername;
|
||||
|
||||
private String totalPriceCnStr;
|
||||
|
||||
private Boolean isCheckUser;
|
||||
|
||||
+14
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteFileService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
@@ -567,5 +568,18 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
}
|
||||
}
|
||||
}
|
||||
// 申请人相关
|
||||
List<Long> applyUserIds = list.stream().map(WalletRechargeInvoiceVo::getApplyUserId).distinct().filter(ObjectUtil::isNotEmpty).toList();
|
||||
if (ObjectUtil.isNotEmpty(applyUserIds)) {
|
||||
List<SysUser> userData = remoteUserService.getInnerUserById(applyUserIds).getData();
|
||||
if (ObjectUtil.isNotEmpty(userData)) {
|
||||
Map<Long, SysUser> userMap = CollectionUtils.convertMap(userData, SysUser::getUserId);
|
||||
for (WalletRechargeInvoiceVo v : list) {
|
||||
SysUser target = userMap.get(v.getApplyUserId());
|
||||
if (ObjectUtil.isEmpty(target)) continue;
|
||||
v.setApplyUsername(target.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user