|
@@ -4,11 +4,9 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.platform.yijia.param.request.AppUserInfoRequest;
|
|
|
import com.platform.yijia.pojo.AppUserInfo;
|
|
|
+import com.platform.yijia.pojo.CustomerElectronicCard;
|
|
|
import com.platform.yijia.pojo.CustomerPoints;
|
|
|
-import com.platform.yijia.service.AppUserInfoService;
|
|
|
-import com.platform.yijia.service.CustomerPointsService;
|
|
|
-import com.platform.yijia.service.PayOrderService;
|
|
|
-import com.platform.yijia.service.StationService;
|
|
|
+import com.platform.yijia.service.*;
|
|
|
import com.platform.yijia.utils.CodeMsg;
|
|
|
import com.platform.yijia.utils.ResultData;
|
|
|
import com.platform.yijia.utils.redis.RedisCacheUtil;
|
|
@@ -24,8 +22,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.security.MessageDigest;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -43,6 +45,8 @@ public class AppUserInfoController {
|
|
|
private CustomerPointsService customerPointsService;
|
|
|
@Resource
|
|
|
private RedisCacheUtil redisCacheUtil;
|
|
|
+ @Resource
|
|
|
+ private ElectronicMembershipCardService electronicMembershipCardService;
|
|
|
|
|
|
// String appId = "wxe1135cd390b38a54"; //微信小程序appID
|
|
|
// String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb"; //微信小程序密钥
|
|
@@ -119,14 +123,15 @@ public class AppUserInfoController {
|
|
|
}
|
|
|
}
|
|
|
String string1 = "jsapi_ticket="+jsapiTicket + "&noncestr=" +noncestr +"×tamp=" +timestamp +"&url=" +url;
|
|
|
+ logger.info("签名参数拼接:"+ string1);
|
|
|
//sha1加密
|
|
|
String signature = DigestUtils.sha1Hex(string1);
|
|
|
+ //String signature = this.sha1(string1);
|
|
|
resultData = ResultData.success(signature);
|
|
|
}
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/*
|
|
|
* 判断使用小程序支付的用户是否关注公众号
|
|
|
* @param unionId
|
|
@@ -266,6 +271,7 @@ public class AppUserInfoController {
|
|
|
logger.info("前端传入参数:" +request.toString());
|
|
|
AppUserInfo appUserInfo =new AppUserInfo();
|
|
|
CustomerPoints customerPoints = new CustomerPoints();
|
|
|
+ CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard(); //客户电子卡
|
|
|
String openId = ""; //此参数用于查询该用户是否已注册过
|
|
|
if(request.getUserType()!=null){
|
|
|
//1-微信公众号
|
|
@@ -275,6 +281,7 @@ public class AppUserInfoController {
|
|
|
openId = request.getOpenId();
|
|
|
appUserInfo.setBlogOpenid(openId);
|
|
|
customerPoints.setBlogOpenId(openId);
|
|
|
+ customerElectronicCard.setBlogOpenid(openId);
|
|
|
//2-微信小程序
|
|
|
}else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getOpenId())){
|
|
|
appUserInfo.setUserType(request.getUserType());
|
|
@@ -282,15 +289,18 @@ public class AppUserInfoController {
|
|
|
openId = request.getOpenId();
|
|
|
appUserInfo.setMinaOpenid(openId);
|
|
|
customerPoints.setMinaOpenId(openId);
|
|
|
+ customerElectronicCard.setMinaOpenid(openId);
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(request.getBlogNickName())){
|
|
|
appUserInfo.setBlogNickName(request.getBlogNickName());
|
|
|
customerPoints.setCustomerName(request.getBlogNickName());
|
|
|
+ customerElectronicCard.setCustomerName(request.getBlogNickName());
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(request.getMobilePhone())){
|
|
|
appUserInfo.setMobilePhone(request.getMobilePhone());
|
|
|
customerPoints.setMobilePhone(request.getMobilePhone());
|
|
|
+ customerElectronicCard.setMobilePhone(request.getMobilePhone());
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
|
|
|
appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
|
|
@@ -298,6 +308,7 @@ public class AppUserInfoController {
|
|
|
if(StringUtils.isNotBlank(request.getUnionId())){
|
|
|
appUserInfo.setUnionId(request.getUnionId());
|
|
|
customerPoints.setUnionId(request.getUnionId());
|
|
|
+ customerElectronicCard.setUnionId(request.getUnionId());
|
|
|
}
|
|
|
|
|
|
appUserInfo.setRegisteDate(new Date());
|
|
@@ -312,6 +323,10 @@ public class AppUserInfoController {
|
|
|
customerPoints.setStationId(request.getStationId());
|
|
|
customerPoints.setStationName(request.getStationName());
|
|
|
|
|
|
+ customerElectronicCard.setCreateTime(new Date());
|
|
|
+ customerElectronicCard.setStationId(request.getStationId());
|
|
|
+ customerElectronicCard.setStationName(request.getStationName());
|
|
|
+
|
|
|
if(StringUtils.isNotBlank(request.getSexFlag())){
|
|
|
appUserInfo.setSexFlag(request.getSexFlag());
|
|
|
}
|
|
@@ -322,16 +337,14 @@ public class AppUserInfoController {
|
|
|
//判断该用户是否已存在
|
|
|
int count = appUserInfoService.isExistAppUser(params);
|
|
|
if(count > 0){
|
|
|
- //此处是为初期没使用unionid,以作更新前期用户unionId
|
|
|
- String userUnionId = appUserInfoService.getUserUnionId(appUserInfo);
|
|
|
- if(!StringUtils.isNotBlank(userUnionId)){
|
|
|
- appUserInfoService.updateUnionId(appUserInfo);
|
|
|
- }
|
|
|
+ appUserInfoService.updateAppUserInfo(appUserInfo);
|
|
|
this.upDateCustomerPointsInfo(customerPoints, request);
|
|
|
- resultData = ResultData.error(CodeMsg.USER_EXSIST);
|
|
|
+ this.upDateCustomerElectronicCard(customerElectronicCard, request);
|
|
|
+ resultData = ResultData.error(CodeMsg.SUCCESS);
|
|
|
}else {
|
|
|
appUserInfoService.AddAppUserInfo(appUserInfo);
|
|
|
this.upDateCustomerPointsInfo(customerPoints, request);
|
|
|
+ this.upDateCustomerElectronicCard(customerElectronicCard, request);
|
|
|
resultData = ResultData.success(CodeMsg.SUCCESS);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
@@ -358,8 +371,32 @@ public class AppUserInfoController {
|
|
|
c.setStationId(request.getStationId());
|
|
|
c.setStationName(request.getStationName());
|
|
|
c.setMobilePhone(request.getMobilePhone());
|
|
|
+ c.setStationId(request.getStationId());
|
|
|
+ c.setStationName(request.getStationName());
|
|
|
customerPointsService.updateCustomerPointsInfo(c);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //客户电子会员卡表操作
|
|
|
+ public void upDateCustomerElectronicCard(CustomerElectronicCard customerElectronicCard, AppUserInfoRequest request){
|
|
|
+ List<CustomerElectronicCard> electronicCardList = electronicMembershipCardService.getElectronicCardList(customerElectronicCard);
|
|
|
+ if(electronicCardList !=null && electronicCardList.size() ==2){
|
|
|
+ electronicMembershipCardService.updateElectronicCardInfoByUnionId(customerElectronicCard);
|
|
|
+ }else {
|
|
|
+ //当前时间戳
|
|
|
+ String currentTime = String.valueOf(System.currentTimeMillis());
|
|
|
+ String customerNo = request.getStationId() + currentTime;
|
|
|
+ customerElectronicCard.setCustomerNo(customerNo);
|
|
|
+ customerElectronicCard.setAmt(new BigDecimal(0));
|
|
|
+ customerElectronicCard.setCardOilsType("1");
|
|
|
+ electronicMembershipCardService.insetElectronicCard(customerElectronicCard);
|
|
|
+ customerElectronicCard.setCardOilsType("2");
|
|
|
+ String currentTime1 = String.valueOf(System.currentTimeMillis());
|
|
|
+ String customerNo1 = request.getStationId() + currentTime1;
|
|
|
+ customerElectronicCard.setCustomerNo(customerNo1);
|
|
|
+ electronicMembershipCardService.insetElectronicCard(customerElectronicCard);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|