68 lines
2.8 KiB
Java
68 lines
2.8 KiB
Java
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;
|
|
import ink.wgink.module.wechat.pojo.pay.v3.PayNoticeCiphertext;
|
|
import ink.wgink.module.wechat.pojo.pos.miniapp.MiniappUserPO;
|
|
import ink.wgink.module.wechat.service.miniapp.IMiniappUserCreateHandleService;
|
|
import ink.wgink.module.wechat.service.miniapp.IMiniappUserService;
|
|
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;
|
|
|
|
@Service
|
|
@Primary
|
|
public class UserService extends DefaultBaseService implements IMiniappUserCreateHandleService {
|
|
|
|
@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;
|
|
}
|
|
|
|
@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);
|
|
AccountDTO accountDTO = iAccountService.get(userPO.getUserId());
|
|
MiniappUserPO miniappUserPO = iMiniappUserService.getPO(userPO.getUserId());
|
|
if(accountDTO == null) {
|
|
AccountVO accountVO = new AccountVO();
|
|
accountVO.setAccountMoney(0);
|
|
accountVO.setAccountIntegral(0);
|
|
accountVO.setAccountNumber(miniappUserPO.getUserCode());
|
|
accountVO.setAccountPassword("");
|
|
accountVO.setAccountStatus("1");
|
|
accountVO.setAccountUserId(userPO.getUserId());
|
|
accountVO.setAccountCity(city);
|
|
accountVO.setAccountIp(ip);
|
|
iAccountService.saveAccount(userPO.getUserId(), accountVO);
|
|
}
|
|
}
|
|
}
|