|
@@ -653,54 +653,34 @@ public class AppUserInfoController {
|
|
|
customerPoints.setStationName(stationInfos.getStationName());
|
|
|
customerElectronicCard.setStationName(stationInfos.getStationName());
|
|
|
}
|
|
|
-// if(stationInfos.getCardRuleFlag().equals("1")){
|
|
|
-// if(stationInfos.getCardEnabledFlagGroup().equals("1")){
|
|
|
-// customerPoints.setStationId(stationInfos.getGroupId());
|
|
|
-// this.insertCustomerPointsInfo(customerPoints, request, stationInfos);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- //如果该站开启标签功能
|
|
|
-// if(stationInfos.getLabelFlag() !=null && stationInfos.getLabelFlag().equals("1")){
|
|
|
-// //如果前端传来labelId,则表示一签一码;
|
|
|
-// if(StringUtils.isNotBlank(request.getLabelId()) && StringUtils.isNotBlank(request.getMobilePhone()) && request.getStationId() !=null){
|
|
|
-// LabelRule labelRule = new LabelRule();
|
|
|
-// labelRule.setLabelId(Integer.valueOf(request.getLabelId()));
|
|
|
-// labelRule.setStationId(Integer.valueOf(request.getStationId()));
|
|
|
-// List<LabelRule> labelRuleList = labelService.getLabelRuleList(labelRule);
|
|
|
-// if(labelRuleList !=null && labelRuleList.size()>0){
|
|
|
-// CustomerLabel customerLabel = new CustomerLabel();
|
|
|
-// customerLabel.setStationId(request.getStationId());
|
|
|
-// customerLabel.setPhone(request.getMobilePhone());
|
|
|
-// if(labelRuleList.get(0).getIsAddLabel() !=null && labelRuleList.get(0).getIsAddLabel().equals("1")){
|
|
|
-// //获取该标签用户信息
|
|
|
-// CustomerLabel c = labelService.getCustomerLabel(customerLabel);
|
|
|
-// if(c !=null){
|
|
|
-// customerLabel.setLabelId(request.getLabelId());
|
|
|
-// customerLabel.setUpdateBy(request.getCreateBy());
|
|
|
-// customerLabel.setUpdateTime(new Date());
|
|
|
-// labelService.updateCustomerLabel(customerLabel);
|
|
|
-// }else {
|
|
|
-// customerLabel.setCreateBy(c.getCreateBy());
|
|
|
-// customerLabel.setCreateTime(new Date());
|
|
|
-// customerLabel.setDelFlag("0");
|
|
|
-// customerLabel.setLabelId(request.getLabelId());
|
|
|
-// labelService.insertCustomerLabel(customerLabel);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+
|
|
|
+ //
|
|
|
+ //Integer excelId = null;
|
|
|
|
|
|
//是否开起积分功能
|
|
|
if(stationInfos.getIntegralRuleFlagGroup().equals("1")){
|
|
|
customerPoints.setStationId(stationInfos.getGroupId());
|
|
|
if(stationInfos.getIntegralFlagGroup().equals("1")){
|
|
|
+// //积分导入
|
|
|
+// CardExcelImport cardExcelImport = this.selectCardExcelImportInfo(request.getMobilePhone(), customerPoints.getStationId());
|
|
|
+// if(cardExcelImport !=null && cardExcelImport.getIntegral() !=null){
|
|
|
+// excelId = cardExcelImport.getExcelId();
|
|
|
+// BigDecimal newPoints = new BigDecimal(customerPoints.getPoints().toString()).add(new BigDecimal(cardExcelImport.getIntegral().toString()));
|
|
|
+// customerPoints.setPoints(newPoints.intValue());
|
|
|
+// }
|
|
|
this.insertCustomerPointsInfo(customerPoints, request, stationInfos);
|
|
|
}
|
|
|
}else {
|
|
|
if(stationInfos.getIntegralFlag().equals("1")){
|
|
|
customerPoints.setStationId(request.getStationId());
|
|
|
+// //积分导入
|
|
|
+// CardExcelImport cardExcelImport = this.selectCardExcelImportInfo(request.getMobilePhone(), customerPoints.getStationId());
|
|
|
+// if(cardExcelImport !=null && cardExcelImport.getIntegral() !=null){
|
|
|
+// excelId = cardExcelImport.getExcelId();
|
|
|
+// BigDecimal newPoints = new BigDecimal(customerPoints.getPoints().toString()).add(new BigDecimal(cardExcelImport.getIntegral().toString()));
|
|
|
+// customerPoints.setPoints(newPoints.intValue());
|
|
|
+// }
|
|
|
+
|
|
|
this.insertCustomerPointsInfo(customerPoints, request, stationInfos);
|
|
|
}
|
|
|
|
|
@@ -773,25 +753,104 @@ public class AppUserInfoController {
|
|
|
/*
|
|
|
* 数据迁移功能:业务逻辑: SAAS系统导入Excel表格数据到临时表,用户登录小程序时根据手机号和站点Id 找寻数据插入到客户电子卡表,积分表,成功后删除此条信息
|
|
|
*/
|
|
|
- public void dataMigrationToSaas(AppUserInfoRequest request, StationInfo stationInfos){
|
|
|
- //用户手机号
|
|
|
- String mobilePhone = request.getMobilePhone();
|
|
|
- //站点Id
|
|
|
- Integer stationId = stationInfos.getStationId();
|
|
|
-
|
|
|
- //1、根据油站Id和用户手机号查询该用户已有的信息;
|
|
|
- CardExcelImport cei = new CardExcelImport();
|
|
|
- cei.setPhoneNumber(mobilePhone);
|
|
|
- cei.setStationId(stationId);
|
|
|
- List<CardExcelImport> cardExcelImportList = cardExcelImportService.getCardExcelImportList(cei);
|
|
|
- if(cardExcelImportList !=null && cardExcelImportList.size() >0){
|
|
|
- //2、更新到SAAS系统电子卡积分等信息;
|
|
|
-
|
|
|
- //3、删除该条用户信息
|
|
|
+ public void selectCardExcelImportInfo(AppUserInfoRequest request, StationInfo stationInfos){
|
|
|
+
|
|
|
+ // 更新导入数据 依据:用户手机号
|
|
|
+ if(StringUtils.isNotBlank(request.getMobilePhone())){
|
|
|
+ String mobilePhone = request.getMobilePhone();
|
|
|
+ //站点Id
|
|
|
+ Integer stationId = stationInfos.getStationId();
|
|
|
+ if(StringUtils.isNotBlank(stationInfos.getCardRuleFlagGroup()) && stationInfos.getCardRuleFlagGroup().equals("1")){
|
|
|
+ if(StringUtils.isNotBlank(stationInfos.getCardEnabledFlagGroup()) &&stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
+ stationId = stationInfos.getGroupId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ AppUserInfo a = new AppUserInfo();
|
|
|
+ a.setMobilePhone(mobilePhone);
|
|
|
+ //app_user_info 存储的为集团Id
|
|
|
+ a.setStationId(stationInfos.getGroupId());
|
|
|
+ a.setUserType("1");
|
|
|
+ //根据手机号和油站所在集团的id,获取要导入用户的unionId
|
|
|
+ List<AppUserInfo> userInfoList = appUserInfoService.getUserInfo(a);
|
|
|
+ if(StringUtils.isNotBlank(userInfoList.get(0).getUnionId())){
|
|
|
+ String unionId = userInfoList.get(0).getUnionId();
|
|
|
+ logger.info("当前要导入用户的手机号和站点所对应的unionId:" +unionId);
|
|
|
+
|
|
|
+ //******* 1、根据油站Id和用户手机号查询该用户已有的信息; *******/
|
|
|
+ CardExcelImport cei = new CardExcelImport();
|
|
|
+ cei.setPhoneNumber(mobilePhone);
|
|
|
+ cei.setStationId(stationId);
|
|
|
+ List<CardExcelImport> cardExcelImportList = cardExcelImportService.getCardExcelImportList(cei);
|
|
|
+ logger.info("当前用户是否有导入信息:" + cardExcelImportList.toString());
|
|
|
+ if(cardExcelImportList !=null && cardExcelImportList.size() >0){
|
|
|
+
|
|
|
+ //***** 2、更新电子卡余额, 积分 标签到SAAS系统电子卡积分等信息;*/
|
|
|
+ String phoneNumber = cardExcelImportList.get(0).getPhoneNumber();
|
|
|
+ Integer excelStaId = cardExcelImportList.get(0).getStationId();
|
|
|
+ if(StringUtils.isNotBlank(phoneNumber) && excelStaId !=null){
|
|
|
+ logger.info("要导入的用户信息:手机号:" + phoneNumber + " ;油站Id:" +stationId +" ;");
|
|
|
+ //电子卡余额
|
|
|
+ BigDecimal balance = cardExcelImportList.get(0).getBalance();
|
|
|
+ logger.info("要导入的用户信息:余额:" + balance +" ;");
|
|
|
+ if(!"0.00".equals(balance.toString())){
|
|
|
+ //电子卡类型
|
|
|
+ String cardType = cardExcelImportList.get(0).getCardType();
|
|
|
+ CustomerElectronicCard c = new CustomerElectronicCard();
|
|
|
+ c.setStationId(stationId);
|
|
|
+ c.setMobilePhone(phoneNumber);
|
|
|
+ c.setCardOilsType(cardType);
|
|
|
+ CustomerElectronicCard electronicCardInfo = electronicMembershipCardService.getElectronicCardInfo(c);
|
|
|
+ if(electronicCardInfo !=null){
|
|
|
+ //存在 表示该用户电子卡已存在,更新电子卡用户余额信息
|
|
|
+ BigDecimal add = electronicCardInfo.getAmt().add(balance);
|
|
|
+ c.setAmt(add);
|
|
|
+ c.setUnionId(unionId);
|
|
|
+ electronicMembershipCardService.updateElectronicCardInfoByUnionId(c);
|
|
|
+ logger.info("电子卡余额从导入表更新成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //积分
|
|
|
+ Integer integral = cardExcelImportList.get(0).getIntegral();
|
|
|
+ logger.info("要导入的用户信息:积分:" + integral +" ;");
|
|
|
+ if(!"0".equals(integral)){
|
|
|
+ CustomerPoints cusp = new CustomerPoints();
|
|
|
+ cusp.setStationId(stationId);
|
|
|
+ cusp.setUnionId(unionId);
|
|
|
+ CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(cusp);
|
|
|
+ if(customerPointsInfo !=null){
|
|
|
+ Integer points = customerPointsInfo.getPoints();
|
|
|
+ BigDecimal add = new BigDecimal(points.toString()).add(new BigDecimal(integral.toString()));
|
|
|
+ cusp.setPoints(add.intValue());
|
|
|
+ customerPointsService.updateCustomerPointsInfo(cusp);
|
|
|
+ logger.info("积分从导入表更新成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //是哪个标签
|
|
|
+ Integer labelId = cardExcelImportList.get(0).getLabelId();
|
|
|
+ logger.info("要导入的用户信息:标签Id:" + labelId +" ;");
|
|
|
+ if(labelId !=null){
|
|
|
+ CustomerLabel cl = new CustomerLabel();
|
|
|
+ cl.setPhone(mobilePhone);
|
|
|
+ cl.setStationId(stationInfos.getStationId());
|
|
|
+ cl.setDelFlag("0");
|
|
|
+ cl.setLabelId(labelId.toString());
|
|
|
+ CustomerLabel customerLabel = labelService.getCustomerLabel(cl);
|
|
|
+ if(customerLabel ==null){
|
|
|
+ labelService.insertCustomerLabel(cl);
|
|
|
+ logger.info("标签从导入表更新成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //是什么等级
|
|
|
+// String memberGrad = cardExcelImportList.get(0).getMemberGrad();
|
|
|
+// if(StringUtils.isNotBlank(memberGrad)){
|
|
|
+//
|
|
|
+// }
|
|
|
+ }
|
|
|
+ //******* 3、删除该条用户信息 ********/
|
|
|
+ CardExcelImport cardExcelImport = cardExcelImportList.get(0);
|
|
|
+ cardExcelImportService.deleteCardExcelImportByExcelId(cardExcelImport);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|