修改小程序注册用券

dev-discount
袁野 2 years ago
parent 7cdc44424f
commit 93beb185cf
  1. 4
      hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java
  2. 12
      hai-cweb/src/main/java/com/cweb/controller/WechatController.java
  3. 33
      hai-service/src/main/java/com/hai/common/utils/RequestUtils.java
  4. 2
      hai-service/src/main/java/com/hai/service/CommonService.java
  5. 2
      hai-service/src/main/java/com/hai/service/HighUserService.java
  6. 18
      hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java
  7. 16
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  8. 2
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
  9. 8
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java

@ -88,7 +88,7 @@ public class HighUserCommonController {
// 2:需要填写手机号
user.setInfoCompleteStatus(1);
highUserService.insertUser(user , popularizeUserId , regionId);
highUserService.insertUser(user , popularizeUserId);
} else {
user.setOpenIdH5(openId);
highUserService.updateUser(user);
@ -146,7 +146,7 @@ public class HighUserCommonController {
// 1:需要填写用户信息
// 2:需要填写手机号
user.setInfoCompleteStatus(1);
highUserService.insertUser(user , popularizeUserId , regionId);
highUserService.insertUser(user , popularizeUserId);
} else {
user.setUnionOpenId(token.getJSONObject("params").getString("openId"));
user.setUnionUnionId(token.getJSONObject("params").getString("unionId"));

@ -88,12 +88,6 @@ public class WechatController {
HttpServletRequest request, HttpServletResponse response) {
try {
// 记录登录信息
String requestIp = RequestUtils.getIpAddress(request);
JSONObject object =BaiduUtils.ipLocation(requestIp);
log.error("origin encryptedData:" + encryptedData + ";iv:" + iv);
//校验openId不能为空
//encryptedData,iv与unionId不能同时为空
@ -134,7 +128,7 @@ public class WechatController {
// 1:需要填写用户信息
// 2:需要填写手机号
user.setInfoCompleteStatus(1);
highUserService.insertUser(user , popularizeUserId , regionId);
highUserService.insertUser(user , popularizeUserId);
} else {
if (session.getOpenid() == null) {
user.setOpenId(session.getOpenid());
@ -281,7 +275,7 @@ public class WechatController {
// 1:需要填写用户信息
// 2:需要填写手机号
user.setInfoCompleteStatus(1);
highUserService.insertUser(user , popularizeUserId , regionId);
highUserService.insertUser(user , popularizeUserId);
}
// 定义个人所有数据
HighUserModel highUserModel = new HighUserModel();
@ -320,7 +314,7 @@ public class WechatController {
// 1:需要填写用户信息
// 2:需要填写手机号
user.setInfoCompleteStatus(1);
highUserService.insertUser(user , null , null);
highUserService.insertUser(user , null);
}
// 定义个人所有数据

@ -1,4 +1,7 @@
package com.hai.common.utils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import javax.servlet.http.HttpServletRequest;
public class RequestUtils {
@ -18,4 +21,34 @@ public class RequestUtils {
return ip;
}
/**
* 获取请求的ip
*/
public static String getRequestIp() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// 从获取RequestAttributes中获取HttpServletRequest的信息
HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST);
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
}

@ -295,5 +295,7 @@ public interface CommonService {
*/
ApiCity findCityByName(String name);
ApiCity findCityByProvinceName(String provinceName);
}

@ -110,7 +110,7 @@ public interface HighUserService {
* @param: [highUser] 用户信息
* @return: com.hai.entity.HighUser
*/
void insertUser(HighUser highUser , Long popularizeUserId , String regionId);
void insertUser(HighUser highUser , Long popularizeUserId);
/**
* @Author 胡锐

@ -1,7 +1,9 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.BaiduUtils;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.RequestUtils;
import com.hai.common.utils.TelApiUtil;
import com.hai.dao.BsDistributionRebateMapper;
import com.hai.dao.BsDistributionUserRelMapper;
@ -43,7 +45,7 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe
private HighUserMapper highUserMapper;
@Override
public void insertDistributionRebate(Long userId, Long popularizeUserId , String regionId) {
public void insertDistributionRebate(Long userId, Long popularizeUserId , String requestIp) {
HighUser user = highUserService.findByUserId(userId);
@ -85,12 +87,15 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe
try {
if (regionId != null) {
SecRegion region = commonService.getParentByRegion(Long.valueOf(regionId));
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
JSONObject object = BaiduUtils.ipLocation(requestIp);
if (object.getInteger("status") == 0) {
String province = object.getJSONObject("content").getJSONObject("address_detail").getString("province");
ApiCity apiCity = commonService.findCityByProvinceName(province);
BsCompany company = bsCompanyService.selectCompanyByRegion(apiCity.getProvinceCode());
// 查询注册有礼优惠券包
HighDiscountPackage discountPackage = highDiscountPackageService.getCallExclusive(3 , bsCompany.getId().intValue());
HighDiscountPackage discountPackage = highDiscountPackageService.getCallExclusive(3 , company.getId().intValue());
Map<String, Object> freeMap = new HashMap<>();
freeMap.put("discountPackageId", discountPackage.getId());
freeMap.put("userId", userId);
@ -99,7 +104,7 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe
if (pUser != null && pUser.getIsAgent() == null) {
// 查询推广有礼优惠券包
HighDiscountPackage promoteDiscountPackage = highDiscountPackageService.getCallExclusive(4 , bsCompany.getId().intValue());
HighDiscountPackage promoteDiscountPackage = highDiscountPackageService.getCallExclusive(4 , company.getId().intValue());
Map<String, Object> freeMap1 = new HashMap<>();
freeMap1.put("discountPackageId", promoteDiscountPackage.getId());
freeMap1.put("userId", pUser.getId());
@ -108,6 +113,7 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe
}
}
} catch (Exception e) {
e.printStackTrace();
}

@ -638,7 +638,21 @@ public class CommonServiceImpl implements CommonService {
return null;
}
// 清空支付方式配置
@Override
public ApiCity findCityByProvinceName(String provinceName) {
ApiCityExample example = new ApiCityExample();
example.createCriteria().andProvinceNameEqualTo(provinceName);
List<ApiCity> list = apiCityMapper.selectByExample(example);
if (list.size()>0) {
return list.get(0);
}
return null;
}
// 清空支付方式配置
private void deletePayType(Long sourceId) {
if (sourceId == null) {

@ -402,7 +402,7 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
user.setGold(0);
user.setStatus(1);
user.setInfoCompleteStatus(1); // 用户信息完整状态 0:完整 1:需要填写用户信息 2:需要填写手机号
highUserService.insertUser(user , null , null);
highUserService.insertUser(user , null);
// 赠送卷包
Map<String, Object> freeMap = new HashMap<>();

@ -7,6 +7,7 @@ import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.RequestUtils;
import com.hai.dao.HighGoldRecMapper;
import com.hai.dao.HighUserMapper;
import com.hai.entity.*;
@ -227,7 +228,7 @@ public class HighUserServiceImpl implements HighUserService {
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertUser(HighUser highUser , Long popularizeUserId , String regionId) {
public void insertUser(HighUser highUser , Long popularizeUserId) {
highUserMapper.insert(highUser);
if (highUser.getPhone() != null) {
@ -236,9 +237,10 @@ public class HighUserServiceImpl implements HighUserService {
highUserCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), highUser.getId());
}
}
// 记录登录信息
String requestIp = RequestUtils.getRequestIp();
// 绑定推广关联关系
distributionUserRelService.insertDistributionRebate(highUser.getId() , popularizeUserId , regionId);
distributionUserRelService.insertDistributionRebate(highUser.getId() , popularizeUserId , requestIp);
}
@Override

Loading…
Cancel
Save