|
@@ -566,6 +566,9 @@ public class PayController {
|
|
}else if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("2")){
|
|
}else if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("2")){
|
|
calculateIntegral.setOilType(infoMap.get("orderType").toString());
|
|
calculateIntegral.setOilType(infoMap.get("orderType").toString());
|
|
}
|
|
}
|
|
|
|
+ calculateIntegral.setUnionId(infoMap.get("unionId").toString());
|
|
|
|
+ calculateIntegral.setNickName(infoMap.get("consumer").toString());
|
|
|
|
+ calculateIntegral.setMobilePhone(infoMap.get("mobilePhone").toString());
|
|
calculateIntegral.setReceivableAmt(new BigDecimal(infoMap.get("receivableAmt").toString()));
|
|
calculateIntegral.setReceivableAmt(new BigDecimal(infoMap.get("receivableAmt").toString()));
|
|
//计算积分并推送
|
|
//计算积分并推送
|
|
this.calculateIntegralAndPushIntegral(calculateIntegral, customerManage);
|
|
this.calculateIntegralAndPushIntegral(calculateIntegral, customerManage);
|
|
@@ -1045,23 +1048,30 @@ public class PayController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.pushIntegral(calculateIntegral.getStationId(), integral, calculateIntegral.getOpenId());
|
|
|
|
|
|
+ calculateIntegral.setIntegral(integral);
|
|
|
|
+ this.pushIntegral(calculateIntegral);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * 公众号推送积分
|
|
|
|
|
|
+ * 更新积分并公众号推送积分
|
|
* @param stationId 油站ID
|
|
* @param stationId 油站ID
|
|
* @param integral 本次所得积分
|
|
* @param integral 本次所得积分
|
|
* @param openId 小程序用户openID
|
|
* @param openId 小程序用户openID
|
|
*/
|
|
*/
|
|
- public void pushIntegral(Integer stationId, int integral, String openId){
|
|
|
|
|
|
+ public void pushIntegral(CalculateIntegral calculateIntegral){
|
|
String gzhAppId ="";
|
|
String gzhAppId ="";
|
|
String gzhAppSecret ="";
|
|
String gzhAppSecret ="";
|
|
String stationName = ""; //油站名称
|
|
String stationName = ""; //油站名称
|
|
BigDecimal surplusIntegral=null;
|
|
BigDecimal surplusIntegral=null;
|
|
- String customerName =null;
|
|
|
|
- if(StringUtils.isNotBlank(openId)){
|
|
|
|
|
|
+ String customerName =calculateIntegral.getNickName(); //客户昵称
|
|
|
|
+ String openId = calculateIntegral.getOpenId(); //客户小程序ID
|
|
|
|
+ Integer stationId = calculateIntegral.getStationId(); //油站ID
|
|
|
|
+ int integral = calculateIntegral.getIntegral(); //当前加油积分
|
|
|
|
+ String unionId = calculateIntegral.getUnionId();
|
|
|
|
+ String mobilePhone = calculateIntegral.getMobilePhone();
|
|
|
|
+ logger.info("客户小程序openId:" + openId);
|
|
|
|
+ if(StringUtils.isNotBlank(calculateIntegral.getOpenId())){
|
|
Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
|
|
Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
|
|
if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
|
|
if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
|
|
stationName = m.get("stationName");
|
|
stationName = m.get("stationName");
|
|
@@ -1069,10 +1079,13 @@ public class PayController {
|
|
gzhAppSecret = m.get("gzhAppSecret");
|
|
gzhAppSecret = m.get("gzhAppSecret");
|
|
}
|
|
}
|
|
CustomerPoints customerPoints = new CustomerPoints();
|
|
CustomerPoints customerPoints = new CustomerPoints();
|
|
- customerPoints.setStationId(stationId);
|
|
|
|
|
|
+ customerPoints.setStationId(calculateIntegral.getStationId());
|
|
customerPoints.setMinaOpenId(openId);
|
|
customerPoints.setMinaOpenId(openId);
|
|
|
|
+ customerPoints.setUnionId(calculateIntegral.getUnionId());
|
|
CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfoByMinaOpenId(customerPoints);
|
|
CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfoByMinaOpenId(customerPoints);
|
|
if(customerPointsInfo !=null){
|
|
if(customerPointsInfo !=null){
|
|
|
|
+ logger.info("当前存在客户:"+ customerPointsInfo.getMinaOpenId());
|
|
|
|
+ logger.info("当前客户原有剩余积分:"+ customerPointsInfo.getPoints().toString());
|
|
customerName =customerPointsInfo.getCustomerName();
|
|
customerName =customerPointsInfo.getCustomerName();
|
|
surplusIntegral =new BigDecimal(customerPointsInfo.getPoints()).add(new BigDecimal(integral));
|
|
surplusIntegral =new BigDecimal(customerPointsInfo.getPoints()).add(new BigDecimal(integral));
|
|
CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();
|
|
CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();
|
|
@@ -1084,10 +1097,15 @@ public class PayController {
|
|
customerPointsRecord.setUnionId(customerPointsInfo.getUnionId());
|
|
customerPointsRecord.setUnionId(customerPointsInfo.getUnionId());
|
|
customerPointsRecord.setIntegral(integral);
|
|
customerPointsRecord.setIntegral(integral);
|
|
customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord);
|
|
customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord);
|
|
- customerPoints.setUnionId(customerPointsInfo.getUnionId());
|
|
|
|
|
|
+ //customerPoints.setUnionId(customerPointsInfo.getUnionId());
|
|
customerPoints.setPoints(surplusIntegral.intValue());
|
|
customerPoints.setPoints(surplusIntegral.intValue());
|
|
|
|
+ logger.info("本次加油后客户应有总积分:"+ customerPoints.getPoints().toString());
|
|
|
|
+ //用户已累积积分
|
|
|
|
+ BigDecimal add = new BigDecimal(customerPointsInfo.getAccumulatePoints()).add(new BigDecimal(integral));
|
|
|
|
+ customerPoints.setAccumulatePoints(add.intValue());
|
|
//更新客户积分
|
|
//更新客户积分
|
|
customerPointsService.updateCustomerPointsInfo(customerPoints);
|
|
customerPointsService.updateCustomerPointsInfo(customerPoints);
|
|
|
|
+ logger.info("更新客户积分信息成功!");
|
|
String blogOpenId = customerPointsInfo.getBlogOpenId(); //公众号openId
|
|
String blogOpenId = customerPointsInfo.getBlogOpenId(); //公众号openId
|
|
if(blogOpenId !=null){
|
|
if(blogOpenId !=null){
|
|
//推送模板
|
|
//推送模板
|
|
@@ -1099,8 +1117,6 @@ public class PayController {
|
|
wxMpTemplate.add(new WxMpTemplateData("From", stationName));
|
|
wxMpTemplate.add(new WxMpTemplateData("From", stationName));
|
|
wxMpTemplate.add(new WxMpTemplateData("remark",
|
|
wxMpTemplate.add(new WxMpTemplateData("remark",
|
|
"截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+surplusIntegral.toString()+" 分"));
|
|
"截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+surplusIntegral.toString()+" 分"));
|
|
-// String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc"; //积分兑换成功通知模板
|
|
|
|
-// wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, blogOpenId, wxMpTemplate); //oJR5R6r4EJhaORFcPap70r_mtFZo
|
|
|
|
GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
|
|
GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
|
|
gzhNewsTemplate.setStationId(stationId);
|
|
gzhNewsTemplate.setStationId(stationId);
|
|
gzhNewsTemplate.setTemplateType("1");
|
|
gzhNewsTemplate.setTemplateType("1");
|
|
@@ -1110,6 +1126,33 @@ public class PayController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ }else {
|
|
|
|
+ logger.info("当前系统不存在该客户积分信息");
|
|
|
|
+ //customerName =userName;
|
|
|
|
+ surplusIntegral =new BigDecimal(integral);
|
|
|
|
+ CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();
|
|
|
|
+ customerPointsRecord.setCreateTime(new Date());
|
|
|
|
+ customerPointsRecord.setCustomerName(customerName);
|
|
|
|
+ customerPointsRecord.setStationName(stationName);
|
|
|
|
+ customerPointsRecord.setStationId(stationId);
|
|
|
|
+ customerPointsRecord.setRecordType("+");
|
|
|
|
+ customerPointsRecord.setUnionId(unionId);
|
|
|
|
+ customerPointsRecord.setIntegral(integral);
|
|
|
|
+ customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord);
|
|
|
|
+
|
|
|
|
+ customerPoints.setUnionId(unionId);
|
|
|
|
+ customerPoints.setPoints(surplusIntegral.intValue());
|
|
|
|
+ customerPoints.setPoints(integral);
|
|
|
|
+ customerPoints.setConsumptionPoints(0);
|
|
|
|
+ customerPoints.setMobilePhone(mobilePhone);
|
|
|
|
+ customerPoints.setCustomerName(customerName);
|
|
|
|
+ customerPoints.setStationName(stationName);
|
|
|
|
+ customerPoints.setAccumulatePoints(integral);
|
|
|
|
+ customerPoints.setInvalidPoints(0);
|
|
|
|
+ customerPoints.setCreateTime(new Date());
|
|
|
|
+ //新增客户积分
|
|
|
|
+ customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
|
+ logger.info("新增客户积分信息成功!");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|