system-card/src/main/java/cn/com/tenlion/systemcard/service/UserService.java

68 lines
2.8 KiB
Java
Raw Normal View History

2021-09-02 10:33:27 +08:00
package cn.com.tenlion.systemcard.service;
import cn.com.tenlion.systemcard.pojo.dtos.account.AccountDTO;
import cn.com.tenlion.systemcard.pojo.vos.account.AccountVO;
import cn.com.tenlion.systemcard.service.account.IAccountService;
import cn.com.tenlion.systemcard.service.cardcharge.ICardChargeService;
import cn.com.tenlion.systemcard.util.BaiDuUtil;
import ink.wgink.common.base.DefaultBaseService;
2021-09-02 10:33:27 +08:00
import ink.wgink.module.wechat.pojo.pay.v3.PayNoticeCiphertext;
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
2021-09-02 10:33:27 +08:00
import ink.wgink.module.wechat.service.miniapp.IMiniappUserCreateHandleService;
import ink.wgink.module.wechat.service.miniapp.IMiniappUserService;
2021-09-02 10:33:27 +08:00
import ink.wgink.module.wechat.service.pay.v3.IPayNoticeService;
import ink.wgink.service.user.pojo.pos.UserPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
2021-09-02 10:33:27 +08:00
@Service
@Primary
public class UserService extends DefaultBaseService implements IMiniappUserCreateHandleService {
2021-09-02 10:33:27 +08:00
@Autowired
private IAccountService iAccountService;
@Autowired
private IMiniappUserService iMiniappUserService;
private String getRemortIP() throws Exception {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ip = "";
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
}else{
ip = request.getHeader("x-forwarded-for");
}
return ip;
}
2021-09-02 10:33:27 +08:00
@Override
public void handle(UserPO userPO, String s) throws Exception {
/**
* 查询是否已经创建 , 如果创建则不执行
*/
String ip = "116.113.1.245";
String city = BaiDuUtil.getIpPosition(ip).getName();
LOG.info(userPO.getUserId() + "、IP:" + ip + "、地址:" + city);
2021-09-02 10:33:27 +08:00
AccountDTO accountDTO = iAccountService.get(userPO.getUserId());
MiniappUserPO miniappUserPO = iMiniappUserService.getPO(userPO.getUserId());
2021-09-02 10:33:27 +08:00
if(accountDTO == null) {
AccountVO accountVO = new AccountVO();
accountVO.setAccountMoney(0);
accountVO.setAccountIntegral(0);
accountVO.setAccountNumber(miniappUserPO.getUserCode());
2021-09-02 10:33:27 +08:00
accountVO.setAccountPassword("");
accountVO.setAccountStatus("1");
accountVO.setAccountUserId(userPO.getUserId());
accountVO.setAccountCity(city);
accountVO.setAccountIp(ip);
2021-09-02 10:33:27 +08:00
iAccountService.saveAccount(userPO.getUserId(), accountVO);
}
}
}