提交 8cd1268d 作者: zhenjie

用户注册生成钱包

上级 3edc123e
package com.mmc.iuav.user.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/6/8 15:19
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class WalletUsersVO implements Serializable {
private static final long serialVersionUID = 7932918047614895003L;
@ApiModelProperty(value = "repo_account_id")
@NotNull(message = "账号id")
private Integer repoAccountId;
}
......@@ -2,6 +2,8 @@ package com.mmc.iuav.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/**
* @author:zhenjie
......@@ -12,4 +14,9 @@ public class UserApplication {
public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
}
package com.mmc.iuav.user.client;
import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.WalletUsersVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
/**
* @author: zj
* @Date: 2023/6/8 15:16
*/
@Component
public class PayClient {
@Value("${iuav.pay.uri}")
private String payAppUri;
@Autowired
private RestTemplate restTemplate;
public ResultBody createWallet(Integer userAccountId){
WalletUsersVO walletUsersVO = new WalletUsersVO();
walletUsersVO.setRepoAccountId(userAccountId);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(walletUsersVO), headers);
ResponseEntity<ResultBody> responseEntity = restTemplate.exchange(payAppUri + "/payment/repocash/walletUsers", HttpMethod.POST, entity, ResultBody.class);
return responseEntity.getBody();
}
}
......@@ -4,6 +4,7 @@ import com.mmc.iuav.group.Create;
import com.mmc.iuav.group.Update;
import com.mmc.iuav.group.UpdatePassword;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.client.PayClient;
import com.mmc.iuav.user.model.dto.BaseAccountDTO;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
......@@ -15,6 +16,7 @@ import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
......@@ -86,10 +88,13 @@ public class BackUserAccountController extends BaseController{
return userAccountService.feignAuthUserPwd(id, authPwd);
}
@Autowired
private PayClient payClient;
@ApiOperation(value = "test")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("listTest")
public ResultBody listTest(HttpServletRequest request) {
return ResultBody.success();
return ResultBody.success(payClient.createWallet(999));
}
}
......@@ -9,6 +9,7 @@ import com.mmc.iuav.http.BizException;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.auth.PwdUtil;
import com.mmc.iuav.user.client.PayClient;
import com.mmc.iuav.user.constant.WxConstant;
import com.mmc.iuav.user.dao.CompanyAuthDao;
import com.mmc.iuav.user.entity.CompanyAuthDO;
......@@ -27,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
......@@ -53,6 +55,10 @@ public class AuthServiceImpl implements AuthService {
@Autowired
private CompanyAuthDao companyAuthDao;
@Autowired
private PayClient payClient;
@Transactional
@Override
public ResultBody appletLogin(WxLoginVO wxLoginVO) {
String unionId;
......@@ -106,6 +112,7 @@ public class AuthServiceImpl implements AuthService {
userAccountDO.setSource(wxLoginVO.getSource());
userAccountService.insertUserAccount(userAccountDO);
userAccountVO = userAccountDO.buildUserAccountVO();
payClient.createWallet(userAccountDO.getId());
}else {
uid = userAccountVO.getUid();
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountVO.getId());
......
......@@ -60,3 +60,7 @@ third-party:
qcc:
app-key: 5015e664848d406ab1ca4b505c3da803
secret-key: 7C4DB8CCECC148175E46392CC0A1B410
iuav:
pay:
uri: http://payment-svc:8088
\ No newline at end of file
......@@ -32,3 +32,7 @@ third-party:
qcc:
app-key: 5015e664848d406ab1ca4b505c3da803
secret-key: 7C4DB8CCECC148175E46392CC0A1B410
iuav:
pay:
uri: http://127.0.0.1:8088
\ No newline at end of file
......@@ -60,3 +60,7 @@ third-party:
qcc:
app-key: 5015e664848d406ab1ca4b505c3da803
secret-key: 7C4DB8CCECC148175E46392CC0A1B410
iuav:
pay:
uri: http://payment-svc:8088
\ No newline at end of file
......@@ -16,3 +16,4 @@ data-filter:
- /userapp/wx/getAppletQRCode
- /userapp/wx/wxSendMessage
- /userapp/user-account/feignListUserAccountIds
- /userapp/back-user/listTest
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论