|
@@ -59,6 +59,10 @@ public class AppUserInfoController {
|
|
|
@Resource
|
|
|
private LabelService labelService;
|
|
|
@Resource
|
|
|
+ private CustomerGradeServices customerGradeServices;
|
|
|
+ @Resource
|
|
|
+ private CustomerManagerService customerManagerService;
|
|
|
+ @Resource
|
|
|
private CardExcelImportService cardExcelImportService;
|
|
|
|
|
|
// String appId = "wxe1135cd390b38a54"; //微信小程序appID
|
|
@@ -680,7 +684,7 @@ public class AppUserInfoController {
|
|
|
}
|
|
|
//数据迁移
|
|
|
this.selectCardExcelImportInfo(request, stationInfos);
|
|
|
-
|
|
|
+ logger.info("新增用户信息接口--addAppUserInfo -- 操作成功!");
|
|
|
resultData = ResultData.success(CodeMsg.SUCCESS);
|
|
|
}catch (Exception e){
|
|
|
resultData = ResultData.error(CodeMsg.INSERT_FAIL);
|
|
@@ -721,7 +725,13 @@ public class AppUserInfoController {
|
|
|
customerElectronicCard.setCardOilsType(String.valueOf(split[i])); //卡的类型
|
|
|
List<CustomerElectronicCard> electronicCardList = electronicMembershipCardService.getElectronicCardList(customerElectronicCard);
|
|
|
if(electronicCardList !=null && electronicCardList.size() ==1){
|
|
|
- electronicMembershipCardService.updateElectronicCardInfoByUnionId(customerElectronicCard);
|
|
|
+ CustomerElectronicCard c = new CustomerElectronicCard();
|
|
|
+ c.setCardOilsType(String.valueOf(split[i]));
|
|
|
+ c.setStationId(customerElectronicCard.getStationId());
|
|
|
+ c.setUnionId(customerElectronicCard.getUnionId());
|
|
|
+ c.setCustomerName(customerElectronicCard.getCustomerName());
|
|
|
+ c.setMobilePhone(customerElectronicCard.getMobilePhone());
|
|
|
+ electronicMembershipCardService.updateElectronicCardInfoByUnionId(c);
|
|
|
}else {
|
|
|
String currentTime = String.valueOf(System.currentTimeMillis());
|
|
|
String customerNo = request.getStationId() + currentTime;
|
|
@@ -771,9 +781,9 @@ public class AppUserInfoController {
|
|
|
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())){
|
|
|
+ if(!"0.00".equals(cardExcelImportList.get(0).getBalance().toString())){
|
|
|
+ BigDecimal balance = cardExcelImportList.get(0).getBalance();
|
|
|
+ logger.info("要导入的用户信息:余额:" + balance +" ;");
|
|
|
//电子卡类型
|
|
|
String cardType = cardExcelImportList.get(0).getCardType();
|
|
|
CustomerElectronicCard c = new CustomerElectronicCard();
|
|
@@ -785,21 +795,34 @@ public class AppUserInfoController {
|
|
|
}
|
|
|
}
|
|
|
c.setMobilePhone(phoneNumber);
|
|
|
+ c.setUnionId(unionId);
|
|
|
c.setCardOilsType(cardType);
|
|
|
- CustomerElectronicCard electronicCardInfo = electronicMembershipCardService.getElectronicCardInfo(c);
|
|
|
+ logger.info("要导入电子卡的查询参数信息:卡类型:" + cardType + " ; 用户unionId:" + unionId + " ; 油站ID:" + stationId);
|
|
|
+ CustomerElectronicCard electronicCardInfo = electronicMembershipCardService.getElectronicCardInfoByUnionId(c);
|
|
|
if(electronicCardInfo !=null){
|
|
|
+ logger.info("已存在的电子卡类型信息:卡类型:" + electronicCardInfo.getCardOilsType() + " ; 用户unionId:" + electronicCardInfo.getUnionId() + " ; 油站ID:" + electronicCardInfo.getStationId());
|
|
|
//存在 表示该用户电子卡已存在,更新电子卡用户余额信息
|
|
|
BigDecimal add = electronicCardInfo.getAmt().add(balance);
|
|
|
c.setAmt(add);
|
|
|
- c.setUnionId(unionId);
|
|
|
+ //c.setUnionId(unionId);
|
|
|
electronicMembershipCardService.updateElectronicCardInfoByUnionId(c);
|
|
|
- logger.info("电子卡余额从导入表更新成功!");
|
|
|
+ logger.info("电子卡余额从导入表: 更新成功!");
|
|
|
}
|
|
|
+// else {
|
|
|
+// c.setAmt(balance);
|
|
|
+// c.setCreateTime(new Date());
|
|
|
+// String currentTime = String.valueOf(System.currentTimeMillis());
|
|
|
+// String customerNo = request.getStationId() + currentTime;
|
|
|
+// c.setCustomerNo(customerNo);
|
|
|
+// c.setCustomerName(userInfoList.get(0).getBlogNickName());
|
|
|
+// electronicMembershipCardService.insetElectronicCard(c);
|
|
|
+// logger.info("电子卡余额从导入表: 新增成功!");
|
|
|
+// }
|
|
|
}
|
|
|
//积分
|
|
|
- Integer integral = cardExcelImportList.get(0).getIntegral();
|
|
|
- logger.info("要导入的用户信息:积分:" + integral +" ;");
|
|
|
- if(!"0".equals(integral)){
|
|
|
+ if(!"0".equals(cardExcelImportList.get(0).getIntegral().toString())){
|
|
|
+ Integer integral = cardExcelImportList.get(0).getIntegral();
|
|
|
+ logger.info("要导入的用户信息:积分:" + integral +" ;");
|
|
|
CustomerPoints cusp = new CustomerPoints();
|
|
|
cusp.setStationId(stationId);
|
|
|
if(StringUtils.isNotBlank(stationInfos.getIntegralRuleFlagGroup()) && stationInfos.getIntegralRuleFlagGroup().equals("1")){
|
|
@@ -815,13 +838,25 @@ public class AppUserInfoController {
|
|
|
BigDecimal add = new BigDecimal(points.toString()).add(new BigDecimal(integral.toString()));
|
|
|
cusp.setPoints(add.intValue());
|
|
|
customerPointsService.updateCustomerPointsInfo(cusp);
|
|
|
- logger.info("积分从导入表更新成功!");
|
|
|
+ logger.info("积分从导入表: 更新成功!");
|
|
|
}
|
|
|
+// else {
|
|
|
+// cusp.setRecentlyPoints(0);
|
|
|
+// cusp.setInvalidPoints(0);
|
|
|
+// cusp.setConsumptionPoints(0);
|
|
|
+// cusp.setAccumulatePoints(integral);
|
|
|
+// cusp.setCreateTime(new Date());
|
|
|
+// cusp.setPoints(integral);
|
|
|
+// cusp.setMobilePhone(phoneNumber);
|
|
|
+// cusp.setCustomerName(userInfoList.get(0).getBlogNickName());
|
|
|
+// customerPointsService.insertCustomerPointsInfo(cusp);
|
|
|
+// logger.info("积分从导入表: 新增成功!");
|
|
|
+// }
|
|
|
}
|
|
|
//是哪个标签
|
|
|
- Integer labelId = cardExcelImportList.get(0).getLabelId();
|
|
|
- logger.info("要导入的用户信息:标签Id:" + labelId +" ;");
|
|
|
- if(labelId !=null){
|
|
|
+ if(cardExcelImportList.get(0).getLabelId() !=null){
|
|
|
+ Integer labelId = cardExcelImportList.get(0).getLabelId();
|
|
|
+ logger.info("要导入的用户信息:标签Id:" + labelId +" ;");
|
|
|
CustomerLabel cl = new CustomerLabel();
|
|
|
cl.setPhone(mobilePhone);
|
|
|
cl.setStationId(stationInfos.getStationId());
|
|
@@ -830,20 +865,64 @@ public class AppUserInfoController {
|
|
|
CustomerLabel customerLabel = labelService.getCustomerLabel(cl);
|
|
|
if(customerLabel ==null){
|
|
|
labelService.insertCustomerLabel(cl);
|
|
|
- logger.info("标签从导入表更新成功!");
|
|
|
+ logger.info("标签从导入表:导入成功!");
|
|
|
+ }else {
|
|
|
+ logger.info("标签从导入表:该用户已在此标签,无需导入!");
|
|
|
}
|
|
|
}
|
|
|
//是什么等级
|
|
|
-// String memberGrad = cardExcelImportList.get(0).getMemberGrad();
|
|
|
-// if(StringUtils.isNotBlank(memberGrad)){
|
|
|
-//
|
|
|
-// }
|
|
|
+ if(StringUtils.isNotBlank(cardExcelImportList.get(0).getMemberGrad())){
|
|
|
+ String memberGrad = cardExcelImportList.get(0).getMemberGrad();
|
|
|
+ logger.info("要导入的用户信息:等级Id:" + memberGrad +" ;");
|
|
|
+ //获取该等级的初始值
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("id", memberGrad);
|
|
|
+ Map resultMap = customerGradeServices.getCustomerGradeInfoById(map);
|
|
|
+ if(resultMap !=null && resultMap.containsKey("memberConditStart") && resultMap.containsKey("oilName")){
|
|
|
+ logger.info("当前等级所对应的油品和等级区间的初始值:" + resultMap.get("oilName").toString() + " , " + resultMap.get("memberConditStart").toString());
|
|
|
+ if(StringUtils.isNotBlank(resultMap.get("memberConditStart").toString()) && StringUtils.isNotBlank(resultMap.get("oilName").toString())){
|
|
|
+ //系统存储等级区间为前闭后开,故在前开区间值加0.01,则在该区间内;
|
|
|
+ BigDecimal memberConditStart = new BigDecimal(resultMap.get("memberConditStart").toString()).add(new BigDecimal("0.01"));
|
|
|
+ String oilName = resultMap.get("oilName").toString();
|
|
|
+ //获取当前用户是否已在
|
|
|
+ CustomerManage customerManage = new CustomerManage();
|
|
|
+ customerManage.setUnionId(unionId);
|
|
|
+ customerManage.setOilName(oilName);
|
|
|
+ customerManage.setStationId(request.getStationId());
|
|
|
+ CustomerManage customerManageInfo = customerManagerService.getCustomerManageInfo(customerManage);
|
|
|
+ logger.info("导入等级时当前是否存在客户的信息:"+ customerManageInfo.getUnionId());
|
|
|
+ if(customerManageInfo !=null){
|
|
|
+ //存在客户
|
|
|
+ BigDecimal add = memberConditStart.add(customerManageInfo.getAmt());
|
|
|
+ customerManage.setAmt(add);
|
|
|
+ customerManagerService.updateCustomerInfo(customerManage);
|
|
|
+ logger.info("等级从导入表导入:更新成功!");
|
|
|
+ }else {
|
|
|
+ //不存在客户
|
|
|
+ StationOilPrice stationOilPrice = new StationOilPrice();
|
|
|
+ stationOilPrice.setOilName(oilName);
|
|
|
+ stationOilPrice.setStationId(request.getStationId());
|
|
|
+ StationOilPrice stationOilPriceInfo = stationService.getStationOilPrice(stationOilPrice);
|
|
|
+ String oilPrice = stationOilPriceInfo.getOilPrice();
|
|
|
+ BigDecimal divide = memberConditStart.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ customerManage.setLiters(divide);
|
|
|
+ customerManage.setPhoneNumber(mobilePhone);
|
|
|
+ customerManage.setGrade(memberGrad);
|
|
|
+ customerManage.setGroupId(stationInfos.getGroupId());
|
|
|
+ customerManage.setCustomerName(userInfoList.get(0).getBlogNickName());
|
|
|
+ customerManagerService.insertCustomerInfo(customerManage);
|
|
|
+ logger.info("等级从导入表导入:新增成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//******* 3、删除该条用户信息 ********/
|
|
|
CardExcelImport cardExcelImport = cardExcelImportList.get(0);
|
|
|
cardExcelImport.setImportFlag("1");
|
|
|
cardExcelImport.setImportDate(new Date());
|
|
|
cardExcelImportService.deleteCardExcelImportByExcelId(cardExcelImport);
|
|
|
+ logger.info("该用户在导入表的数据:已导入数据完成");
|
|
|
}
|
|
|
}
|
|
|
}
|