2025-08-15 14:36:39 +08:00
|
|
|
package org.dromara.app;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2025-09-18 16:12:22 +08:00
|
|
|
import com.wzj.soopin.member.business.IMemberBusiness;
|
2025-08-15 17:05:59 +08:00
|
|
|
import com.wzj.soopin.member.convert.AccountBillConvert;
|
2025-08-15 14:36:39 +08:00
|
|
|
import com.wzj.soopin.member.convert.MemberAccountConvert;
|
2025-08-16 10:05:51 +08:00
|
|
|
import com.wzj.soopin.member.convert.MemberBankConvert;
|
2025-08-15 14:36:39 +08:00
|
|
|
import com.wzj.soopin.member.convert.MemberConvert;
|
2025-08-15 17:05:59 +08:00
|
|
|
import com.wzj.soopin.member.domain.bo.AccountBillBO;
|
2025-09-18 16:12:22 +08:00
|
|
|
import com.wzj.soopin.member.domain.bo.MemberBO;
|
2025-08-16 10:05:51 +08:00
|
|
|
import com.wzj.soopin.member.domain.bo.MemberBankBO;
|
2025-08-15 17:05:59 +08:00
|
|
|
import com.wzj.soopin.member.domain.po.AccountBill;
|
2025-08-16 10:05:51 +08:00
|
|
|
import com.wzj.soopin.member.domain.po.Member;
|
|
|
|
import com.wzj.soopin.member.domain.po.MemberAccount;
|
|
|
|
import com.wzj.soopin.member.domain.po.MemberBank;
|
2025-08-15 17:05:59 +08:00
|
|
|
import com.wzj.soopin.member.domain.vo.AccountBillVO;
|
2025-08-15 14:36:39 +08:00
|
|
|
import com.wzj.soopin.member.domain.vo.MemberAccountVO;
|
2025-08-16 10:05:51 +08:00
|
|
|
import com.wzj.soopin.member.domain.vo.MemberBankVO;
|
2025-08-15 14:36:39 +08:00
|
|
|
import com.wzj.soopin.member.domain.vo.MemberVO;
|
|
|
|
import com.wzj.soopin.member.service.IMemberAccountService;
|
2025-08-16 10:05:51 +08:00
|
|
|
import com.wzj.soopin.member.service.IMemberBankService;
|
2025-08-15 14:36:39 +08:00
|
|
|
import com.wzj.soopin.member.service.IMemberService;
|
2025-08-21 15:47:21 +08:00
|
|
|
import com.wzj.soopin.transaction.convert.ChargeConvert;
|
|
|
|
import com.wzj.soopin.transaction.convert.WithdrawConvert;
|
|
|
|
import com.wzj.soopin.transaction.domain.bo.ChargeBO;
|
|
|
|
import com.wzj.soopin.transaction.domain.bo.WithdrawBO;
|
2025-09-26 09:54:02 +08:00
|
|
|
import com.wzj.soopin.transaction.domain.entity.InitiateBatchTransferResponseNew;
|
2025-09-26 12:58:41 +08:00
|
|
|
import com.wzj.soopin.transaction.domain.entity.WxAuthResponse;
|
2025-09-23 16:55:04 +08:00
|
|
|
import com.wzj.soopin.transaction.domain.po.Withdraw;
|
2025-08-21 15:47:21 +08:00
|
|
|
import com.wzj.soopin.transaction.enums.WithdrawType;
|
2025-09-19 17:32:27 +08:00
|
|
|
import com.wzj.soopin.transaction.service.IAccountBillService;
|
2025-08-21 15:47:21 +08:00
|
|
|
import com.wzj.soopin.transaction.service.IChargeService;
|
|
|
|
import com.wzj.soopin.transaction.service.IWithdrawService;
|
2025-09-26 12:58:41 +08:00
|
|
|
import com.wzj.soopin.transaction.service.impl.WxAuthService;
|
|
|
|
import com.wzj.soopin.transaction.service.impl.WxPayService;
|
2025-09-19 17:32:27 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2025-08-15 14:36:39 +08:00
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
2025-08-16 10:05:51 +08:00
|
|
|
import me.zhyd.oauth.model.AuthResponse;
|
2025-08-16 11:17:18 +08:00
|
|
|
import me.zhyd.oauth.model.AuthToken;
|
2025-08-16 10:05:51 +08:00
|
|
|
import me.zhyd.oauth.model.AuthUser;
|
2025-08-15 14:36:39 +08:00
|
|
|
import org.dromara.common.core.domain.R;
|
2025-08-16 10:05:51 +08:00
|
|
|
import org.dromara.common.core.domain.model.LoginUser;
|
|
|
|
import org.dromara.common.core.domain.model.SocialLoginBody;
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
import org.dromara.common.core.utils.ValidatorUtils;
|
2025-08-21 15:47:21 +08:00
|
|
|
import org.dromara.common.log.annotation.Log;
|
|
|
|
import org.dromara.common.log.enums.BusinessType;
|
2025-09-20 18:01:58 +08:00
|
|
|
import org.dromara.common.ratelimiter.annotation.RateLimiter;
|
2025-08-16 10:05:51 +08:00
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
import org.dromara.common.social.config.properties.SocialProperties;
|
|
|
|
import org.dromara.common.social.utils.SocialUtils;
|
2025-08-15 14:36:39 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
2025-09-23 16:55:04 +08:00
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
2025-08-15 14:36:39 +08:00
|
|
|
@RestController
|
|
|
|
@RequestMapping("/app/member")
|
|
|
|
@Tag(name = "会员管理")
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
public class AppMemberController {
|
2025-09-18 16:12:22 +08:00
|
|
|
private final IMemberBusiness memberBusiness;
|
2025-08-15 14:36:39 +08:00
|
|
|
|
|
|
|
private final IMemberService service;
|
|
|
|
|
|
|
|
private final MemberConvert convert;
|
|
|
|
|
|
|
|
private final MemberAccountConvert accountConvert;
|
|
|
|
|
|
|
|
private final IMemberAccountService accountService;
|
|
|
|
|
2025-08-15 17:05:59 +08:00
|
|
|
private final IAccountBillService accountBillService;
|
2025-08-15 14:36:39 +08:00
|
|
|
|
2025-08-15 17:05:59 +08:00
|
|
|
private final AccountBillConvert accountBillConvert;
|
2025-08-16 10:05:51 +08:00
|
|
|
private final SocialProperties socialProperties;
|
2025-08-15 14:36:39 +08:00
|
|
|
|
2025-08-16 10:05:51 +08:00
|
|
|
private final IMemberBankService memberBankService;
|
|
|
|
private final MemberBankConvert memberBankConvert;
|
2025-08-21 15:47:21 +08:00
|
|
|
private final IChargeService chargeService;
|
|
|
|
private final ChargeConvert chargeConvert;
|
2025-08-15 14:36:39 +08:00
|
|
|
|
2025-08-21 15:47:21 +08:00
|
|
|
private final IWithdrawService withdrawService;
|
|
|
|
private final WithdrawConvert withdrawConvert;
|
2025-08-15 14:36:39 +08:00
|
|
|
|
2025-09-26 12:58:41 +08:00
|
|
|
private final WxAuthService wxAuthService;
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "获取会员账户信息详细信息")
|
2025-08-16 10:05:51 +08:00
|
|
|
@GetMapping(value = "/info")
|
2025-09-17 10:01:34 +08:00
|
|
|
public R<MemberVO> getInfo(Long memberId) {
|
2025-08-16 10:05:51 +08:00
|
|
|
//获取用户信息
|
2025-09-17 10:01:34 +08:00
|
|
|
if(memberId==null){
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
|
|
|
throw new ServiceException("用户未登录");
|
|
|
|
}
|
|
|
|
memberId = loginUser.getUserId();
|
2025-08-16 10:05:51 +08:00
|
|
|
}
|
2025-09-24 12:05:00 +08:00
|
|
|
return R.ok(memberBusiness.info(memberId));
|
2025-08-15 14:36:39 +08:00
|
|
|
}
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "获取会员账户表详细信息")
|
2025-08-16 10:05:51 +08:00
|
|
|
@GetMapping(value = "/account")
|
|
|
|
public R<MemberAccountVO> accountInfo() {
|
|
|
|
//获取用户信息
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
|
|
|
throw new ServiceException("用户未登录");
|
|
|
|
}
|
|
|
|
return R.ok(accountConvert.toVO(accountService.getMemberAccount(loginUser.getUserId())));
|
|
|
|
}
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "查询账单")
|
2025-08-16 10:05:51 +08:00
|
|
|
@PostMapping("/bank")
|
|
|
|
public R<Page<MemberBankVO>> list(@RequestBody MemberBankBO bo,
|
|
|
|
@RequestBody Page<MemberBank> page) {
|
|
|
|
//获取用户信息
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
|
|
|
throw new ServiceException("用户未登录");
|
|
|
|
}
|
|
|
|
Long memberId = loginUser.getUserId();
|
|
|
|
bo.setMemberId(memberId);
|
|
|
|
Page<MemberBank> memberPage = memberBankService.page(page, bo.toWrapper());
|
|
|
|
return R.ok(memberBankConvert.toVO(memberPage));
|
2025-08-15 14:36:39 +08:00
|
|
|
}
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "查询账单")
|
2025-08-15 17:05:59 +08:00
|
|
|
@PostMapping("/bills")
|
|
|
|
public R<Page<AccountBillVO>> list(@RequestBody AccountBillBO bo,
|
2025-08-16 10:05:51 +08:00
|
|
|
@RequestBody Page<AccountBill> page) {
|
|
|
|
//获取用户信息
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
|
|
|
throw new ServiceException("用户未登录");
|
|
|
|
}
|
|
|
|
Long memberId = loginUser.getUserId();
|
|
|
|
//根据会员获取账户信息
|
|
|
|
MemberAccount memberAccount = accountService.getMemberAccount(memberId);
|
|
|
|
if (memberAccount == null) {
|
|
|
|
throw new ServiceException("用户未绑定账户");
|
|
|
|
}
|
|
|
|
bo.setAccountId(memberAccount.getId());
|
|
|
|
Page<AccountBill> memberPage = accountBillService.page(page, bo.toWrapper());
|
2025-08-15 17:05:59 +08:00
|
|
|
return R.ok(accountBillConvert.toVO(memberPage));
|
2025-08-15 14:36:39 +08:00
|
|
|
}
|
2025-08-15 17:05:59 +08:00
|
|
|
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "绑定推广人")
|
2025-09-13 16:58:31 +08:00
|
|
|
@PostMapping("/bind/spread")
|
2025-09-18 16:12:22 +08:00
|
|
|
public R<AuthToken> bindSpread(@RequestBody MemberBO bo) {
|
2025-09-13 16:58:31 +08:00
|
|
|
|
2025-09-18 16:12:22 +08:00
|
|
|
memberBusiness.bindSpread(bo);
|
2025-09-13 16:58:31 +08:00
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "绑定微信")
|
2025-08-16 10:05:51 +08:00
|
|
|
@PostMapping("/bind/wechat")
|
2025-08-16 11:17:18 +08:00
|
|
|
public R<AuthToken> bindWechat(@RequestBody SocialLoginBody loginBody) {
|
2025-08-16 10:05:51 +08:00
|
|
|
|
|
|
|
//获取用户信息
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
|
|
|
throw new ServiceException("用户未登录");
|
|
|
|
}
|
|
|
|
Long memberId = loginUser.getUserId();
|
2025-09-26 12:58:41 +08:00
|
|
|
//
|
2025-08-16 10:05:51 +08:00
|
|
|
ValidatorUtils.validate(loginBody);
|
|
|
|
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
|
|
|
loginBody.getSource(), loginBody.getSocialCode(),
|
|
|
|
loginBody.getSocialState(), socialProperties);
|
|
|
|
if (!response.ok()) {
|
|
|
|
throw new ServiceException(response.getMsg());
|
|
|
|
}
|
|
|
|
|
|
|
|
AuthUser authUserData = response.getData();
|
|
|
|
|
2025-09-26 12:58:41 +08:00
|
|
|
// WxAuthResponse response1 = wxAuthService.getAccessTokenByCode(loginBody.getSocialCode());
|
|
|
|
// String OpenId=response1.getOpenid();
|
|
|
|
Member member = Member.builder().id(memberId).openId(authUserData.getUuid()).build();
|
2025-08-16 11:17:18 +08:00
|
|
|
service.updateById(member);
|
2025-08-16 10:05:51 +08:00
|
|
|
// 更新用户的微信信息
|
|
|
|
// 返回给前端
|
2025-08-16 11:17:18 +08:00
|
|
|
return R.ok(authUserData.getToken());
|
2025-08-16 10:05:51 +08:00
|
|
|
}
|
|
|
|
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "充值")
|
2025-08-21 15:47:21 +08:00
|
|
|
@Log(title = "新增 ", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping("/charge")
|
|
|
|
public R charge(@RequestBody ChargeBO bo) {
|
|
|
|
|
|
|
|
//获取用户信息
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
|
|
|
throw new ServiceException("用户未登录");
|
|
|
|
}
|
|
|
|
Long memberId = loginUser.getUserId();
|
|
|
|
bo.setMemberId(memberId);
|
|
|
|
|
|
|
|
return R.ok(chargeService.charge(chargeConvert.toPo(bo)));
|
|
|
|
}
|
2025-09-19 17:32:27 +08:00
|
|
|
@Operation(summary = "提现")
|
2025-08-21 15:47:21 +08:00
|
|
|
@Log(title = "提现 ", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping("/withdraw")
|
|
|
|
public R withdraw(@RequestBody WithdrawBO bo) {
|
|
|
|
//获取用户信息
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
if (loginUser == null) {
|
2025-09-26 10:26:26 +08:00
|
|
|
return R.notLogin();
|
2025-08-21 15:47:21 +08:00
|
|
|
}
|
|
|
|
Long memberId = loginUser.getUserId();
|
|
|
|
bo.setMemberId(memberId);
|
|
|
|
bo.setType(WithdrawType.WALLET.getCode());
|
2025-09-23 16:55:04 +08:00
|
|
|
Withdraw withdraw=withdrawConvert.toPo(bo);
|
2025-09-26 09:54:02 +08:00
|
|
|
InitiateBatchTransferResponseNew responseNew= withdrawService.withdraw(withdraw);
|
|
|
|
return R.ok(responseNew);
|
2025-08-21 15:47:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-09-20 18:01:58 +08:00
|
|
|
|
|
|
|
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
|
|
|
@GetMapping("/sms/code")
|
|
|
|
@Operation(summary = "给当前登录会员的手机号发送短信验证码")
|
|
|
|
public R smsCode(@RequestParam String templateId) {
|
|
|
|
service.smsCode(templateId);
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "用户注销")
|
|
|
|
@Log(title = "用户注销 ", businessType = BusinessType.UPDATE)
|
|
|
|
@PostMapping("/revoked")
|
|
|
|
public R revoked(@RequestParam String smsCode) {
|
|
|
|
service.revoked(smsCode);
|
|
|
|
return R.ok();
|
|
|
|
}
|
|
|
|
|
2025-08-15 14:36:39 +08:00
|
|
|
}
|