修改账号请求逻辑

master
wujingtao 3 years ago
parent dba2daeffb
commit aa58da1714

@ -26,7 +26,7 @@ public class RequestCore {
* @param pageable
* @return
*/
public CommonResult<Object> getParentAccount(@RequestParam(value = "sellerNick") String sellerNick, Pageable pageable) {
public CommonResult<Object> getParentAccount(String sellerNick, Pageable pageable) {
String reqUrl = url + API_PREFIX + "/account/parentAccounts" + "?" + "sellerNick=" + sellerNick + "&pageNumber=" + pageable.getPageNumber() + "&pageSize=" + pageable.getPageSize();
return requestApi(reqUrl);
}
@ -49,20 +49,19 @@ public class RequestCore {
* @param payTemplateId
* @return
*/
CommonResult<Object> authorizeChildrenAccount(@RequestParam(value = "childrenAccountId") Long childrenAccountId, @RequestParam(value = "payTemplateId") Long payTemplateId) {
public CommonResult<Object> authorizeChildrenAccount(Long childrenAccountId, @RequestParam(value = "payTemplateId") Long payTemplateId) {
String reqUrl = url + API_PREFIX + "/account/authorize" + "?" + "childrenAccountId=" + childrenAccountId + "&payTemplateId=" + payTemplateId;
return requestApi(reqUrl);
}
private CommonResult<Object> requestApi(String url) {
JSONObject results;
String getResult = HttpUtil
.createGet(url)
.execute()
.charset("utf-8")
.body();
JSONObject o = JSONUtil.parseObj(getResult);
results = o.getJSONObject("data");
return new CommonResult<>().success(results);
return new CommonResult<>().success(JSONUtil.toJsonStr(o));
}
}

@ -50,20 +50,20 @@ public class AccountInfoController {
public CommonResult<Object> getParentAccount(@RequestParam(value = "sellerNick") String sellerNick, Pageable pageable) {
return requestCore.getParentAccount(sellerNick, pageable);
}
//
// @GetMapping("/pay/template")
// @ApiOperation("查询套餐")
// public CommonResult<Object> getPayTemplate() {
// return aliPayClient.getPayTemplate();
// }
//
// @GetMapping("/account/authorize")
// @ApiOperation("对子账号授权")
// public CommonResult<Object> authorizeChildrenAccount(Long childrenAccountId, Long payTemplateId) {
// if (childrenAccountId == DefaultNumberConstants.ZERO_NUMBER || payTemplateId == DefaultNumberConstants.ZERO_NUMBER) {
// return new CommonResult<>().validateFailed("参数错误");
// }
// return aliPayClient.authorizeChildrenAccount(childrenAccountId, payTemplateId);
// }
@GetMapping("/pay/template")
@ApiOperation("查询套餐")
public CommonResult<Object> getPayTemplate() {
return requestCore.getPayTemplate();
}
@GetMapping("/account/authorize")
@ApiOperation("对子账号授权")
public CommonResult<Object> authorizeChildrenAccount(Long childrenAccountId, Long payTemplateId) {
if (childrenAccountId == DefaultNumberConstants.ZERO_NUMBER || payTemplateId == DefaultNumberConstants.ZERO_NUMBER) {
return new CommonResult<>().validateFailed("参数错误");
}
return requestCore.authorizeChildrenAccount(childrenAccountId, payTemplateId);
}
}

@ -98,6 +98,7 @@ public class AuthorizationController {
onlineUserService.save(jwtUserDto, token);
// 返回 token 与 用户信息
Map<String, Object> authInfo = ImmutableMap.of("token", properties.getTokenStartWith(), "user", jwtUserDto);
log.info(String.valueOf(authInfo));
return ResponseEntity.ok(authInfo);
}

@ -82,6 +82,7 @@ public class SellerAccountController {
@GetMapping("/parentAccounts")
@ApiOperation("分页查询主账号")
public CommonResult<Page<SellerAccount>> getParentAccount(@RequestParam("sellerNick") String sellerNick, Pageable pageable) {
log.info("sellerNick=={}", sellerNick);
return sellerAccountService.getParentAccount(sellerNick, pageable);
}

@ -342,18 +342,21 @@ public class SellerAccountServiceImpl implements SellerAccountService {
@Override
public CommonResult<Page<SellerAccount>> getParentAccount(String sellerNick, Pageable pageable) {
AccountSearchVo accountSearchVo = new AccountSearchVo();
if (StrUtil.isNotEmpty(sellerNick)) {
if (!Objects.equals(sellerNick, "") && sellerNick != null) {
accountSearchVo.setNickname(sellerNick);
}
accountSearchVo.setParentId((long) DefaultNumberConstants.ZERO_NUMBER);
log.info("accountSearchVo ==" + accountSearchVo);
Page<SellerAccount> sellerAccounts = sellerAccountRepository.findAll(
((root, criteriaQuery, cb) ->
QueryHelp.getPredicate(root, accountSearchVo, cb)), pageable);
log.info("sellerAccounts =======" + sellerAccounts);
return new CommonResult<Page<SellerAccount>>().success(
PageUtil.toPage(sellerAccounts.getContent(), sellerAccounts.getTotalElements()));
}
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult<Object> authorizeChildrenAccount(Long childrenAccountId, Long payTemplateId) {
//验证是否为子账号
SellerAccount sellerAccount = sellerAccountRepository.findSellerAccountById(childrenAccountId);

@ -37,10 +37,6 @@ public class BasePayTemplate implements Serializable {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
private Date updateTime;
@Column(name = "template_code")
@ApiModelProperty("套餐code")
private String templateCode;
@Column(name = "package_name")
@ApiModelProperty("套餐名")
private String packageName;

Loading…
Cancel
Save