|
@@ -56,8 +56,6 @@ public class PayController {
|
|
|
private CustomerManagerService customerManagerService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/***
|
|
|
* 微信子商户支付接口
|
|
|
* @param weChatPaySetRequest
|
|
@@ -531,6 +529,9 @@ public class PayController {
|
|
|
System.out.println(resultStr);
|
|
|
if (RSASignature.doCheck(resultStr, sign, SXFPaySign.sxfPublic)) {
|
|
|
logger.info("验签成功");
|
|
|
+ req.put("code","success");
|
|
|
+ req.put("msg","成功");
|
|
|
+ logger.info("返回随行付参数信息:"+req.toString());
|
|
|
//验签成功,修改订单状态
|
|
|
List<PayOrder> list = payOrderService.getPayOrderList(ordNo);
|
|
|
logger.info("根据订单号,查询订单"+gson.toJson(list));
|
|
@@ -548,49 +549,69 @@ public class PayController {
|
|
|
//修改订单状态
|
|
|
int count = payOrderService.getUpdatePayOrder(payOrder);
|
|
|
if(count == 1){
|
|
|
- req.put("code","success");
|
|
|
- req.put("msg","成功");
|
|
|
- logger.info(req.toString());
|
|
|
-
|
|
|
//将用户消费的信息插入顾客表: 以手机号 油品名称 油站id为条件插入且存入 加油升数、实收金额、油站名称 根据订单号查询用户手机号
|
|
|
Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder); //获取该订单手机号、加油升数、实收金额、油站名称
|
|
|
- logger.info("根据订单查询用户手机号等信息infoMap"+ infoMap.toString());
|
|
|
+ logger.info("根据订单查询用户手机号等订单信息"+ infoMap.toString());
|
|
|
//手机号必须有
|
|
|
if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
|
|
|
- //插入客户积分返回要插入客户的信息
|
|
|
- //insertCustomerGroup(infoMap);
|
|
|
- CustomerManage customerManage = insertCustomerManage(infoMap);
|
|
|
- StationPayManage stationPayManage = new StationPayManage();
|
|
|
- stationPayManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
- StationPayManage stationPayManageInfo = stationService.selectStationPayManage(stationPayManage);
|
|
|
- //是否启用积分功能
|
|
|
+ CustomerManage customerManage = this.insertCustomerManage(infoMap); //插入客户积分返回要插入客户的信息
|
|
|
+ StationInfo stationInfo = new StationInfo();
|
|
|
+ stationInfo.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
+ StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
int integral =0;
|
|
|
- if(stationPayManageInfo !=null && stationPayManageInfo.getIntegralFlag().equals("1")){
|
|
|
- //计算积分并推送
|
|
|
+ if(stationInfos !=null && stationInfos.getIntegralFlag().equals("1")){ //是否启用积分功能
|
|
|
CalculateIntegral calculateIntegral = new CalculateIntegral();
|
|
|
- calculateIntegral.setOpenId(infoMap.get("minaOpenid").toString());
|
|
|
- calculateIntegral.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
- calculateIntegral.setAmt(new BigDecimal(infoMap.get("amt").toString()));
|
|
|
- if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
|
|
|
- calculateIntegral.setOilType(infoMap.get("orderType").toString());
|
|
|
- calculateIntegral.setOilName(infoMap.get("oilName").toString());
|
|
|
- calculateIntegral.setOilLiters(new BigDecimal(infoMap.get("orderLiters").toString()));
|
|
|
- }else if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("2")){
|
|
|
- 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()));
|
|
|
- //计算积分并推送
|
|
|
- integral = calculateIntegralAndPushIntegral(calculateIntegral, customerManage);
|
|
|
+ calculateIntegral.setCustomerGrade(customerManage.getGrade()); //客户等级
|
|
|
+ calculateIntegral.setIntegralRuleFlag(stationInfos.getIntegralRuleFlag()); //是否共享积分规则
|
|
|
+ calculateIntegral.setOpenId(infoMap.get("minaOpenid").toString()); //客户小程序ID
|
|
|
+ calculateIntegral.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); //油站ID
|
|
|
+ calculateIntegral.setStationName(infoMap.get("stationName").toString()); //油站名称
|
|
|
+ calculateIntegral.setAmt(new BigDecimal(infoMap.get("amt").toString())); //实收金额
|
|
|
+ calculateIntegral.setOilType(infoMap.get("orderType").toString()); //订单类型
|
|
|
+ calculateIntegral.setOilName(infoMap.get("oilName").toString()); //油品名称
|
|
|
+ calculateIntegral.setOilLiters(new BigDecimal(infoMap.get("orderLiters").toString())); //加油升数
|
|
|
+ calculateIntegral.setUnionId(infoMap.get("unionId").toString()); //客户unionId
|
|
|
+ calculateIntegral.setNickName(infoMap.get("consumer").toString()); //客户昵称
|
|
|
+ calculateIntegral.setMobilePhone(infoMap.get("mobilePhone").toString()); //客户手机号
|
|
|
+ calculateIntegral.setReceivableAmt(new BigDecimal(infoMap.get("receivableAmt").toString())); //应收金额
|
|
|
+ //计算积分
|
|
|
+ CalculateIntegral calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
|
|
|
+ integral =calculateIntegralInfos.getIntegral();
|
|
|
+ //插入客户所得积分
|
|
|
+ CustomerPoints customerPoints = this.insertUserIntegral(calculateIntegralInfos);
|
|
|
+ //推送积分
|
|
|
+ this.pushIntegral(customerPoints);
|
|
|
}
|
|
|
- //打印小票
|
|
|
- this.printReceipt(infoMap);
|
|
|
|
|
|
- //pos机打印小票
|
|
|
- payOrder.setIntegral(String.valueOf(integral));
|
|
|
- this.posPrintReceipt(payOrder);
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("stationId", infoMap.get("stationId").toString());
|
|
|
+ map.put("oilGunNo", infoMap.get("oilGunNo").toString());
|
|
|
+ List<Map> listDevices = stationOilGunService.getPrinterSnByStationIdAndOilGunNoList(map);
|
|
|
+ if(listDevices !=null && listDevices.size() ==2){
|
|
|
+ for(Map m : listDevices){
|
|
|
+ if(m.get("deviceType").toString().equals("1")){
|
|
|
+ //打印小票
|
|
|
+ infoMap.put("sn", m.get("printerSn").toString());
|
|
|
+ infoMap.put("printSetting", m.get("printSetting").toString());
|
|
|
+ this.printReceipt(infoMap);
|
|
|
+ }else {
|
|
|
+ //pos机打印小票
|
|
|
+ payOrder.setIntegral(String.valueOf(integral));
|
|
|
+ this.posPrintReceipt(payOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(listDevices !=null && listDevices.size() ==1){
|
|
|
+ if(listDevices.get(0).get("deviceType").toString().equals("1")){
|
|
|
+ //打印小票
|
|
|
+ infoMap.put("sn", listDevices.get(0).get("printerSn").toString());
|
|
|
+ infoMap.put("printSetting", listDevices.get(0).get("printSetting").toString());
|
|
|
+ this.printReceipt(infoMap);
|
|
|
+ }else {
|
|
|
+ //POS机打印
|
|
|
+ payOrder.setIntegral(String.valueOf(integral));
|
|
|
+ this.posPrintReceipt(payOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
logger.info("该用户无手机号!");
|
|
|
}
|
|
@@ -604,11 +625,7 @@ public class PayController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /***
|
|
|
- * 插入客户信息
|
|
|
- * @param infoMap
|
|
|
- * @return
|
|
|
- */
|
|
|
+ //插入客户信息
|
|
|
public CustomerManage insertCustomerManage(Map infoMap){
|
|
|
CustomerManage customerManage = new CustomerManage(); //存放客户信息
|
|
|
customerManage.setGroupId(Integer.valueOf(infoMap.get("groupId").toString()));
|
|
@@ -658,18 +675,10 @@ public class PayController {
|
|
|
customerManage.setRegtime(blogRegTime);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
customerManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); //油站ID
|
|
|
customerManage.setOilName(infoMap.get("oilName").toString()); //油品名称
|
|
|
customerManage.setStationName(infoMap.get("stationName").toString()); //存入油站名称
|
|
|
-
|
|
|
CustomerManage existCustomer = customerManagerService.getCustomerManageInfo(customerManage); //已存在用户信息 existCustomer
|
|
|
- logger.info("查询出客户是否存在数据 null表示没有: " + existCustomer);
|
|
|
-
|
|
|
- //获取该油站的优惠方式
|
|
|
- String discountPlanType = stationService.getStationDiscountWay(infoMap.get("stationId").toString());
|
|
|
- logger.info("油站优惠方式:"+discountPlanType);
|
|
|
-
|
|
|
//判断该用户是否已存在
|
|
|
if(existCustomer != null){ //存在该用户时更新
|
|
|
if(existCustomer.getAmt() !=null){
|
|
@@ -677,7 +686,6 @@ public class PayController {
|
|
|
}else {
|
|
|
customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));
|
|
|
}
|
|
|
-
|
|
|
//此处用于更新没有会员ID的用户
|
|
|
if(!StringUtils.isNotBlank(existCustomer.getMemberId())){
|
|
|
String customerId=infoMap.get("groupId").toString()+infoMap.get("stationId").toString()+System.nanoTime();
|
|
@@ -692,42 +700,33 @@ public class PayController {
|
|
|
}
|
|
|
}
|
|
|
logger.info("存在客户 更新时手机号参数: " + customerManage.getPhoneNumber());
|
|
|
-
|
|
|
- //if(discountPlanType !=null && discountPlanType.equals("1")){
|
|
|
- //直降时存入等级名称和等级ID
|
|
|
- List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeListOrderByDesc(infoMap); //直降
|
|
|
- logger.info("该站直降等级信息:"+ customerGradeInfo);
|
|
|
- for (Map m: customerGradeInfo){
|
|
|
- // && Double.valueOf(customerManage.getAmt().toString()) < Double.valueOf(m.get("memberConditEnd").toString())
|
|
|
- if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString())){
|
|
|
- customerManage.setGrade(m.get("grade").toString()); //存入等级名称
|
|
|
- customerManage.setMemberGrade(m.get("id").toString()); //存入等级ID
|
|
|
- break;
|
|
|
- }
|
|
|
+ //直降时存入等级名称和等级ID
|
|
|
+ List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeListOrderByDesc(infoMap); //直降
|
|
|
+ logger.info("该站直降等级信息:"+ customerGradeInfo);
|
|
|
+ for (Map m: customerGradeInfo){
|
|
|
+ if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString())){
|
|
|
+ customerManage.setGrade(m.get("grade").toString()); //存入等级名称
|
|
|
+ customerManage.setMemberGrade(m.get("id").toString()); //存入等级ID
|
|
|
+ break;
|
|
|
}
|
|
|
- logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
|
|
|
- //}
|
|
|
+ }
|
|
|
+ logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
|
|
|
customerManagerService.updateCustomerInfo(customerManage);
|
|
|
- //payOrderService.updateCustomer(customerManage); //存在 更新
|
|
|
}else{ //该客户不存在时插入
|
|
|
- //if(discountPlanType !=null && discountPlanType.equals("1")){
|
|
|
- //直降时存入等级名称和等级ID
|
|
|
- List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap); //直降
|
|
|
- logger.info("该站直降等级信息:"+ customerGradeInfo);
|
|
|
- if(customerGradeInfo !=null && customerGradeInfo.size() >0){
|
|
|
- customerManage.setGrade(customerGradeInfo.get(0).get("grade").toString()); //存入等级名称
|
|
|
- customerManage.setMemberGrade(customerGradeInfo.get(0).get("id").toString()); //存入等级ID
|
|
|
- }
|
|
|
- logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
|
|
|
- //}
|
|
|
+ //直降时存入等级名称和等级ID
|
|
|
+ List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap); //直降
|
|
|
+ logger.info("该站直降等级信息:"+ customerGradeInfo);
|
|
|
+ if(customerGradeInfo !=null && customerGradeInfo.size() >0){
|
|
|
+ customerManage.setGrade(customerGradeInfo.get(0).get("grade").toString()); //存入等级名称
|
|
|
+ customerManage.setMemberGrade(customerGradeInfo.get(0).get("id").toString()); //存入等级ID
|
|
|
+ }
|
|
|
+ logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
|
|
|
customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt"))); //存入金额
|
|
|
if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")){
|
|
|
customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters"))); //存入升数
|
|
|
}
|
|
|
logger.info("不存在客户 新增时参数: " + customerManage.toString());
|
|
|
- //客户会员号
|
|
|
- String memberId=infoMap.get("groupId").toString()+infoMap.get("stationId").toString()+System.nanoTime();
|
|
|
- //客户会员号
|
|
|
+ String memberId=infoMap.get("groupId").toString()+infoMap.get("stationId").toString()+System.nanoTime(); //客户会员号
|
|
|
CustomerManage cm = new CustomerManage();
|
|
|
cm.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
cm.setPhoneNumber(infoMap.get("mobilePhone").toString());
|
|
@@ -742,7 +741,6 @@ public class PayController {
|
|
|
customerManage.setMemberId(memberId);
|
|
|
}
|
|
|
customerManagerService.insertCustomerInfo(customerManage);
|
|
|
- //payOrderService.insertCustomer(customerManage);//不存在 新增
|
|
|
}
|
|
|
return customerManage;
|
|
|
}
|
|
@@ -854,10 +852,7 @@ public class PayController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 打印小票
|
|
|
- */
|
|
|
+ //打印机打印小票
|
|
|
public void printReceipt(Map infoMap) {
|
|
|
//打印机打印小票
|
|
|
String content1;
|
|
@@ -963,108 +958,89 @@ public class PayController {
|
|
|
content2 += "<BR>";
|
|
|
//获取打印机编号
|
|
|
//sn = "921611605"; //测试打印机 sn:921611605 key:72338zma
|
|
|
- Map params =new HashMap();
|
|
|
- params.put("stationId", infoMap.get("stationId").toString());
|
|
|
- params.put("oilGunNo", infoMap.get("oilGun").toString());
|
|
|
- params.put("deviceType", "1");
|
|
|
- Map m = stationOilGunService.getPrinterSnByStationIdAndOilGunNo(params);
|
|
|
- if(m !=null && m.containsKey("printerSn") && m.get("printerSn").toString()!= null && m.get("printerSn").toString()!=""){
|
|
|
- sn = m.get("printerSn").toString();
|
|
|
- //开始打印
|
|
|
- String printInfo=""; //打印信息
|
|
|
- if(m.containsKey("printSetting") && m.get("printSetting").toString()!= null && m.get("printSetting").toString()!=""){
|
|
|
- switch (m.get("printSetting").toString()){
|
|
|
- case "1": //1 客户联
|
|
|
- printInfo = FeiEPrinterUtil.printReceipt(sn, content1);
|
|
|
- break;
|
|
|
- case "2": //2 商户联
|
|
|
- printInfo = FeiEPrinterUtil.printReceipt(sn, content2);
|
|
|
- break;
|
|
|
- case "3": //3商户联和客户联
|
|
|
- printInfo = FeiEPrinterUtil.printReceipt(sn, content1 + content2);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(printInfo);
|
|
|
- if(jsonObject != null && jsonObject.getString("msg").equals("ok")){
|
|
|
- logger.info("打印成功:" + jsonObject.toString());
|
|
|
- //如果打印成功 添加小票数量
|
|
|
- PayOrder p = new PayOrder();
|
|
|
- p.setPrintCount(1);
|
|
|
- p.setOrderNo(infoMap.get("orderNo").toString());
|
|
|
- payOrderService.getUpdatePayOrder(p);
|
|
|
+
|
|
|
+ sn = infoMap.get("printerSn").toString();
|
|
|
+ //开始打印
|
|
|
+ String printInfo=""; //打印信息
|
|
|
+ if(infoMap.containsKey("printSetting") && infoMap.get("printSetting").toString()!= null && infoMap.get("printSetting").toString()!=""){
|
|
|
+ switch (infoMap.get("printSetting").toString()){
|
|
|
+ case "1": //1 客户联
|
|
|
+ printInfo = FeiEPrinterUtil.printReceipt(sn, content1);
|
|
|
+ break;
|
|
|
+ case "2": //2 商户联
|
|
|
+ printInfo = FeiEPrinterUtil.printReceipt(sn, content2);
|
|
|
+ break;
|
|
|
+ case "3": //3商户联和客户联
|
|
|
+ printInfo = FeiEPrinterUtil.printReceipt(sn, content1 + content2);
|
|
|
+ break;
|
|
|
}
|
|
|
- }else {
|
|
|
- logger.info("请正确配置打印机");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(printInfo);
|
|
|
+ if(jsonObject != null && jsonObject.getString("msg").equals("ok")){
|
|
|
+ logger.info("打印成功:" + jsonObject.toString());
|
|
|
+ //如果打印成功 添加小票数量
|
|
|
+ PayOrder p = new PayOrder();
|
|
|
+ p.setPrintCount(1);
|
|
|
+ p.setOrderNo(infoMap.get("orderNo").toString());
|
|
|
+ payOrderService.getUpdatePayOrder(p);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 计算消费生成积分
|
|
|
- * 注释: 1.判断油站配置的优惠类型
|
|
|
- * 2.如果是等级直降则存在等级取对应等级的积分规则,否则按照其他优惠方式
|
|
|
- */
|
|
|
- public int calculateIntegralAndPushIntegral(CalculateIntegral calculateIntegral, CustomerManage customerManage){
|
|
|
+ //计算积分
|
|
|
+ public CalculateIntegral calculateIntegral(CalculateIntegral calculateIntegral){
|
|
|
int integral =0;
|
|
|
- //获取该油站的优惠方式
|
|
|
- String discountPlanType = stationService.getStationDiscountWay(calculateIntegral.getStationId().toString());
|
|
|
IntegralRule integralRule = new IntegralRule();
|
|
|
integralRule.setStationId(calculateIntegral.getStationId());
|
|
|
- integralRule.setEmptyDate(new Date());
|
|
|
integralRule.setOilName(calculateIntegral.getOilName());
|
|
|
- integralRule.setOilType(calculateIntegral.getOilType());
|
|
|
//获取该油站的积分规则
|
|
|
List<IntegralRule> integralRuleList = integralRuleService.getIntegralRule(integralRule);
|
|
|
if(integralRuleList !=null && integralRuleList.size() >0){
|
|
|
logger.info("该油站积分规则信息:" + integralRuleList.toString());
|
|
|
- List<IntegralRuleDetail> integralRuleDetailList = integralRuleList.get(0).getIntegralRuleDetailList();
|
|
|
- String currentTime = null; //当前时间
|
|
|
- String datePickerTime=null; //活动时间
|
|
|
- String[] datePickerTimeArray ={};
|
|
|
- String integralActivity = integralRuleList.get(0).getIntegralActivity();
|
|
|
- String integralProportion =null;
|
|
|
- if(integralActivity !=null && integralActivity.equals("1")){
|
|
|
- datePickerTime = integralRuleList.get(0).getDatePickerTime();
|
|
|
- integralProportion = integralRuleList.get(0).getIntegralProportion();
|
|
|
- if(datePickerTime.contains(",")){
|
|
|
- datePickerTimeArray = datePickerTime.split(",");
|
|
|
- }else {
|
|
|
- datePickerTimeArray= new String[1];
|
|
|
- datePickerTimeArray[0] = datePickerTime;
|
|
|
+ Date emptyDate = integralRuleList.get(0).getEmptyDate();
|
|
|
+ //积分规则有效时间 为null时 表示永久有效
|
|
|
+ if(emptyDate ==null || emptyDate.compareTo(new Date()) == 1 || emptyDate.compareTo(new Date()) == 0){
|
|
|
+ List<IntegralRuleDetail> integralRuleDetailList = integralRuleList.get(0).getIntegralRuleDetailList();
|
|
|
+ String currentTime = null; //当前时间
|
|
|
+ String datePickerTime=null; //活动时间
|
|
|
+ String[] datePickerTimeArray ={};
|
|
|
+ String integralActivity = integralRuleList.get(0).getIntegralActivity();
|
|
|
+ String integralProportion =null;
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1")){
|
|
|
+ datePickerTime = integralRuleList.get(0).getDatePickerTime();
|
|
|
+ integralProportion = integralRuleList.get(0).getIntegralProportion();
|
|
|
+ if(datePickerTime.contains(",")){
|
|
|
+ datePickerTimeArray = datePickerTime.split(",");
|
|
|
+ }else {
|
|
|
+ datePickerTimeArray= new String[1];
|
|
|
+ datePickerTimeArray[0] = datePickerTime;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if(integralRuleDetailList !=null && integralRuleDetailList.size() >0){
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(new Date()); //获取当前时间
|
|
|
- for (IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
|
|
|
- if(integralRuleDetail.getOilType().equals("1")){ //油品
|
|
|
- if (integralRuleDetail.getRuleType().equals("1")){ //按照实收金额
|
|
|
- if(calculateIntegral.getAmt().compareTo(integralRuleDetail.getRuleTerms()) == 1 || calculateIntegral.getAmt().compareTo(integralRuleDetail.getRuleTerms()) == 0){
|
|
|
+ if(integralRuleDetailList !=null && integralRuleDetailList.size() >0){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(new Date()); //获取当前时间
|
|
|
+ for (IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
|
|
|
+ if(!StringUtils.isNotBlank(integralRuleDetail.getRuleType()) && !StringUtils.isNotBlank(integralRuleDetail.getGread())){
|
|
|
+ //等级和规则类型null为时表示非油品, 没有按照实收,应收,加油升数
|
|
|
+ if (calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==0){
|
|
|
BigDecimal divide = null;
|
|
|
BigDecimal multiply = null;
|
|
|
- //判断油站配置的优惠类型
|
|
|
- if(discountPlanType.equals("1") && integralRuleDetail.getGread() !=null && customerManage.getGrade()!=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ //等级直降
|
|
|
- divide = calculateIntegral.getAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
- multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }else {
|
|
|
- divide = calculateIntegral.getAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
- multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }
|
|
|
- if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
- String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker(); //获取日期类型
|
|
|
switch (datePicker){
|
|
|
case "1": // 1.按周来
|
|
|
int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
currentTime = String.valueOf(day_Week);
|
|
|
break;
|
|
|
- case "2": // 2.每月的多少号
|
|
|
+ case "2": // 2.每月的 多少号
|
|
|
int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
currentTime = String.valueOf(day_month); //当前时间
|
|
|
break;
|
|
|
case "3": // 3.固定日期
|
|
|
- currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
break;
|
|
|
}
|
|
|
for (String s : datePickerTimeArray){
|
|
@@ -1074,244 +1050,311 @@ public class PayController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- integral =multiply.intValue();
|
|
|
+ integral = multiply.intValue();
|
|
|
logger.info("本次客户所得积分:" + integral);
|
|
|
break;
|
|
|
}
|
|
|
- }else if (integralRuleDetail.getRuleType().equals("2")){ //按应收金额
|
|
|
+ }else if (StringUtils.isNotBlank(integralRuleDetail.getGread()) && integralRuleDetail.getRuleType().equals("1")){ //按照实收金额
|
|
|
+ if(calculateIntegral.getAmt().compareTo(integralRuleDetail.getRuleTerms()) == 1 || calculateIntegral.getAmt().compareTo(integralRuleDetail.getRuleTerms()) == 0){
|
|
|
+ BigDecimal divide = null;
|
|
|
+ BigDecimal multiply = null;
|
|
|
+ if(integralRuleDetail.getGread().equals("0")){ //等级为0时,表示所有人
|
|
|
+ divide = calculateIntegral.getAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ switch (datePicker){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (String s : datePickerTimeArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ integral =multiply.intValue();
|
|
|
+ logger.info("本次客户所得积分:" + integral);
|
|
|
+ break;
|
|
|
+ }else if(integralRuleDetail.getGread().equals(calculateIntegral.getCustomerGrade())){ //如果等级相同
|
|
|
+ divide = calculateIntegral.getAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ switch (datePicker){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (String s : datePickerTimeArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ integral =multiply.intValue();
|
|
|
+ logger.info("本次客户所得积分:" + integral);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(StringUtils.isNotBlank(integralRuleDetail.getGread()) && integralRuleDetail.getRuleType().equals("2")){ //按应收金额
|
|
|
if(calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==0){
|
|
|
BigDecimal divide = null;
|
|
|
BigDecimal multiply = null;
|
|
|
- //判断油站配置的优惠类型
|
|
|
- if(discountPlanType.equals("1") && integralRuleDetail.getGread() !=null && customerManage.getGrade()!=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ //等级直降
|
|
|
+ if(integralRuleDetail.getGread().equals("0")){
|
|
|
divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }else {
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ switch (datePicker){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的 多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (String s : datePickerTimeArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ integral = multiply.intValue();
|
|
|
+ logger.info("本次客户所得积分:" + integral);
|
|
|
+ break;
|
|
|
+ }else if(integralRuleDetail.getGread().equals(calculateIntegral.getCustomerGrade())){
|
|
|
divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }
|
|
|
- if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
- String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
- switch (datePicker){
|
|
|
- case "1": // 1.按周来
|
|
|
- int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
- day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
- currentTime = String.valueOf(day_Week);
|
|
|
- break;
|
|
|
- case "2": // 2.每月的 多少号
|
|
|
- int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
- day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
- currentTime = String.valueOf(day_month); //当前时间
|
|
|
- break;
|
|
|
- case "3": // 3.固定日期
|
|
|
- currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
- break;
|
|
|
- }
|
|
|
- for (String s : datePickerTimeArray){
|
|
|
- if(s.equals(currentTime)){
|
|
|
- multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
- break;
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ switch (datePicker){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的 多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (String s : datePickerTimeArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ integral = multiply.intValue();
|
|
|
+ logger.info("本次客户所得积分:" + integral);
|
|
|
+ break;
|
|
|
}
|
|
|
- integral = multiply.intValue();
|
|
|
- logger.info("本次客户所得积分:" + integral);
|
|
|
- break;
|
|
|
}
|
|
|
- }else if (integralRuleDetail.getRuleType().equals("3")){ //按照加油升数
|
|
|
+ }else if(integralRuleDetail.getRuleType().equals("3")){ //按照加油升数
|
|
|
if(calculateIntegral.getOilLiters().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getOilLiters().compareTo(integralRuleDetail.getRuleTerms()) ==0){
|
|
|
BigDecimal divide = null;
|
|
|
BigDecimal multiply = null;
|
|
|
- //判断油站配置的优惠类型
|
|
|
- if(discountPlanType.equals("1") && integralRuleDetail.getGread() !=null && customerManage.getGrade()!=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ //等级直降
|
|
|
+ if(integralRuleDetail.getGread().equals("0")){
|
|
|
divide = calculateIntegral.getOilLiters().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }else {
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ switch (datePicker){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的 多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (String s : datePickerTimeArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ integral =multiply.intValue();
|
|
|
+ logger.info("本次客户所得积分:" + integral);
|
|
|
+ break;
|
|
|
+ }else if(integralRuleDetail.getGread().equals(calculateIntegral.getCustomerGrade())){
|
|
|
divide = calculateIntegral.getOilLiters().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }
|
|
|
- if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
- String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
- switch (datePicker){
|
|
|
- case "1": // 1.按周来
|
|
|
- int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
- day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
- currentTime = String.valueOf(day_Week);
|
|
|
- break;
|
|
|
- case "2": // 2.每月的 多少号
|
|
|
- int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
- day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
- currentTime = String.valueOf(day_month); //当前时间
|
|
|
- break;
|
|
|
- case "3": // 3.固定日期
|
|
|
- currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
- break;
|
|
|
- }
|
|
|
- for (String s : datePickerTimeArray){
|
|
|
- if(s.equals(currentTime)){
|
|
|
- multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
- break;
|
|
|
+ if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
+ String datePicker = integralRuleList.get(0).getDatePicker();
|
|
|
+ switch (datePicker){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的 多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (String s : datePickerTimeArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- integral =multiply.intValue();
|
|
|
- logger.info("本次客户所得积分:" + integral);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }else if (integralRuleDetail.getOilType().equals("2")){ //非油品
|
|
|
- if (calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==0){
|
|
|
- BigDecimal divide = null;
|
|
|
- BigDecimal multiply = null;
|
|
|
- //判断油站配置的优惠类型
|
|
|
- if(discountPlanType.equals("1") && integralRuleDetail.getGread() !=null && customerManage.getGrade()!=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ //等级直降
|
|
|
- divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
- multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }else {
|
|
|
- divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN);
|
|
|
- multiply = divide.multiply(integralRuleDetail.getIntegral());
|
|
|
- }
|
|
|
- if(integralActivity !=null && integralActivity.equals("1") && datePickerTimeArray !=null && integralProportion !=null){
|
|
|
- String datePicker = integralRuleList.get(0).getDatePicker(); //获取日期类型
|
|
|
- switch (datePicker){
|
|
|
- case "1": // 1.按周来
|
|
|
- int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
- day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
- currentTime = String.valueOf(day_Week);
|
|
|
- break;
|
|
|
- case "2": // 2.每月的 多少号
|
|
|
- int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
- day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
- currentTime = String.valueOf(day_month); //当前时间
|
|
|
- break;
|
|
|
- case "3": // 3.固定日期
|
|
|
- currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
- break;
|
|
|
- }
|
|
|
- for (String s : datePickerTimeArray){
|
|
|
- if(s.equals(currentTime)){
|
|
|
- multiply = multiply.multiply(new BigDecimal(integralProportion));
|
|
|
- break;
|
|
|
- }
|
|
|
+ integral =multiply.intValue();
|
|
|
+ logger.info("本次客户所得积分:" + integral);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
- integral = multiply.intValue();
|
|
|
- logger.info("本次客户所得积分:" + integral);
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
calculateIntegral.setIntegral(integral);
|
|
|
- //customerManage.setIntegral(integral);
|
|
|
- //customerManagerService.updateCustomerInfo(customerManage);
|
|
|
- this.pushIntegral(calculateIntegral);
|
|
|
}
|
|
|
- return integral;
|
|
|
+ return calculateIntegral;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * 更新积分并公众号推送积分
|
|
|
- * @param stationId 油站ID
|
|
|
- * @param integral 本次所得积分
|
|
|
- * @param openId 小程序用户openID
|
|
|
- */
|
|
|
- public void pushIntegral(CalculateIntegral calculateIntegral){
|
|
|
+ //插入用户积分信息或者更新用户积分信息
|
|
|
+ public CustomerPoints insertUserIntegral(CalculateIntegral calculateIntegral){
|
|
|
+ CustomerPoints customerPoints = new CustomerPoints();
|
|
|
+ customerPoints.setRecentlyPoints(calculateIntegral.getIntegral()); //用户当前所获得的积分
|
|
|
+ customerPoints.setStationId(calculateIntegral.getStationId()); //油站ID
|
|
|
+ customerPoints.setMinaOpenId(calculateIntegral.getOpenId()); //用户小程序ID
|
|
|
+ customerPoints.setUnionId(calculateIntegral.getUnionId()); //用户unionId
|
|
|
+ //获取客户积分信息
|
|
|
+ CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfoByUnionId(customerPoints);
|
|
|
+ if(customerPointsInfo !=null){
|
|
|
+ logger.info("当前存在客户:"+ customerPointsInfo.getMinaOpenId());
|
|
|
+ logger.info("当前客户原有剩余积分:"+ customerPointsInfo.getPoints().toString());
|
|
|
+ CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();
|
|
|
+ customerPointsRecord.setCreateTime(new Date());
|
|
|
+ customerPointsRecord.setCustomerName(customerPointsInfo.getCustomerName());
|
|
|
+ customerPointsRecord.setStationName(customerPointsInfo.getStationName());
|
|
|
+ customerPointsRecord.setStationId(customerPointsInfo.getStationId());
|
|
|
+ customerPointsRecord.setRecordType("+");
|
|
|
+ customerPointsRecord.setUnionId(customerPointsInfo.getUnionId());
|
|
|
+ customerPointsRecord.setIntegral(calculateIntegral.getIntegral());
|
|
|
+ //插入客户记录表
|
|
|
+ customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord);
|
|
|
+
|
|
|
+ //如果已存在客户则 客户余额积分= 当前客户已有积分 + 本次所得积分
|
|
|
+ BigDecimal surplusIntegral =new BigDecimal(customerPointsInfo.getPoints()).add(new BigDecimal(calculateIntegral.getIntegral()));
|
|
|
+ customerPoints.setPoints(surplusIntegral.intValue());
|
|
|
+ logger.info("本次加油后客户应有总积分:"+ customerPoints.getPoints().toString());
|
|
|
+ //用户已累积积分
|
|
|
+ BigDecimal add = new BigDecimal(customerPointsInfo.getAccumulatePoints()).add(new BigDecimal(calculateIntegral.getIntegral()));
|
|
|
+ customerPoints.setAccumulatePoints(add.intValue());
|
|
|
+ customerPoints.setRecentConsumptionDate(new Date());
|
|
|
+ //更新客户积分
|
|
|
+ customerPointsService.updateCustomerPointsInfo(customerPoints);
|
|
|
+ logger.info("更新客户积分信息成功!");
|
|
|
+ }else {
|
|
|
+ logger.info("当前系统不存在该客户积分信息");
|
|
|
+ CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();
|
|
|
+ customerPointsRecord.setCreateTime(new Date());
|
|
|
+ customerPointsRecord.setCustomerName(calculateIntegral.getNickName());
|
|
|
+ customerPointsRecord.setStationName(calculateIntegral.getStationName());
|
|
|
+ customerPointsRecord.setStationId(calculateIntegral.getStationId());
|
|
|
+ customerPointsRecord.setRecordType("+");
|
|
|
+ customerPointsRecord.setUnionId(calculateIntegral.getUnionId());
|
|
|
+ customerPointsRecord.setIntegral(calculateIntegral.getIntegral());
|
|
|
+ customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord);
|
|
|
+
|
|
|
+ customerPoints.setUnionId(calculateIntegral.getUnionId());
|
|
|
+ customerPoints.setPoints(calculateIntegral.getIntegral());
|
|
|
+ customerPoints.setConsumptionPoints(0);
|
|
|
+ customerPoints.setMobilePhone(calculateIntegral.getMobilePhone());
|
|
|
+ customerPoints.setCustomerName(calculateIntegral.getNickName());
|
|
|
+ customerPoints.setStationName(calculateIntegral.getStationName());
|
|
|
+ customerPoints.setAccumulatePoints(calculateIntegral.getIntegral());
|
|
|
+ customerPoints.setInvalidPoints(0);
|
|
|
+ customerPoints.setRecentConsumptionDate(new Date());
|
|
|
+ customerPoints.setCreateTime(new Date());
|
|
|
+ //新增客户积分
|
|
|
+ customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
+ logger.info("新增客户积分信息成功!");
|
|
|
+ }
|
|
|
+ return customerPoints;
|
|
|
+ }
|
|
|
+
|
|
|
+ //公众号推送积分
|
|
|
+ public void pushIntegral(CustomerPoints customerPoints){
|
|
|
String gzhAppId ="";
|
|
|
String gzhAppSecret ="";
|
|
|
String stationName = ""; //油站名称
|
|
|
- BigDecimal surplusIntegral=null;
|
|
|
- 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);
|
|
|
+ logger.info("客户小程序openId:" + customerPoints.getMinaOpenId());
|
|
|
+ if(customerPoints.getStationId() !=null){
|
|
|
+ Map<String, String> m = stationService.getStationAppIdAndAppSecret(customerPoints.getStationId());
|
|
|
if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
|
|
|
stationName = m.get("stationName");
|
|
|
gzhAppId = m.get("gzhAppId");
|
|
|
gzhAppSecret = m.get("gzhAppSecret");
|
|
|
}
|
|
|
- CustomerPoints customerPoints = new CustomerPoints();
|
|
|
- customerPoints.setStationId(calculateIntegral.getStationId());
|
|
|
- customerPoints.setMinaOpenId(openId);
|
|
|
- customerPoints.setUnionId(calculateIntegral.getUnionId());
|
|
|
- CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfoByUnionId(customerPoints);
|
|
|
- if(customerPointsInfo !=null){
|
|
|
- logger.info("当前存在客户:"+ customerPointsInfo.getMinaOpenId());
|
|
|
- logger.info("当前客户原有剩余积分:"+ customerPointsInfo.getPoints().toString());
|
|
|
- customerName =customerPointsInfo.getCustomerName();
|
|
|
- surplusIntegral =new BigDecimal(customerPointsInfo.getPoints()).add(new BigDecimal(integral));
|
|
|
- CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();
|
|
|
- customerPointsRecord.setCreateTime(new Date());
|
|
|
- customerPointsRecord.setCustomerName(customerName);
|
|
|
- customerPointsRecord.setStationName(stationName);
|
|
|
- customerPointsRecord.setStationId(stationId);
|
|
|
- customerPointsRecord.setRecordType("+");
|
|
|
- customerPointsRecord.setUnionId(customerPointsInfo.getUnionId());
|
|
|
- customerPointsRecord.setIntegral(integral);
|
|
|
- customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord);
|
|
|
- //customerPoints.setUnionId(customerPointsInfo.getUnionId());
|
|
|
- customerPoints.setPoints(surplusIntegral.intValue());
|
|
|
- logger.info("本次加油后客户应有总积分:"+ customerPoints.getPoints().toString());
|
|
|
- //用户已累积积分
|
|
|
- BigDecimal add = new BigDecimal(customerPointsInfo.getAccumulatePoints()).add(new BigDecimal(integral));
|
|
|
- customerPoints.setAccumulatePoints(add.intValue());
|
|
|
- customerPoints.setRecentConsumptionDate(new Date());
|
|
|
- //更新客户积分
|
|
|
- customerPointsService.updateCustomerPointsInfo(customerPoints);
|
|
|
- logger.info("更新客户积分信息成功!");
|
|
|
- String blogOpenId = customerPointsInfo.getBlogOpenId(); //公众号openId
|
|
|
- if(blogOpenId !=null){
|
|
|
- //推送模板
|
|
|
- List<WxMpTemplateData> wxMpTemplate = new ArrayList<>();
|
|
|
- wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+customerName+",您好:\n" + "您在"+stationName+"的积分最新交易信息如下"));
|
|
|
- wxMpTemplate.add(new WxMpTemplateData("time", new SimpleDateFormat("yyyy年MM月dd日HH时mm分").format(new Date())));
|
|
|
- wxMpTemplate.add(new WxMpTemplateData("type", "增加"));
|
|
|
- wxMpTemplate.add(new WxMpTemplateData("Point", String.valueOf(integral)));
|
|
|
- wxMpTemplate.add(new WxMpTemplateData("From", stationName));
|
|
|
- wxMpTemplate.add(new WxMpTemplateData("remark",
|
|
|
- "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+surplusIntegral.toString()+" 分"));
|
|
|
- GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
|
|
|
- gzhNewsTemplate.setStationId(stationId);
|
|
|
- gzhNewsTemplate.setTemplateType("1");
|
|
|
- GzhNewsTemplate gzhNewsTemplateInfo = gzhNewsTemplateService.getGzhNewsTemplate(gzhNewsTemplate);
|
|
|
- if(gzhNewsTemplateInfo !=null && gzhNewsTemplateInfo.getTemplateId() !=null){
|
|
|
- wxPushUtil.push(gzhAppId, gzhAppSecret, gzhNewsTemplateInfo.getTemplateId(), blogOpenId, wxMpTemplate);
|
|
|
- }
|
|
|
+ String blogOpenId = customerPoints.getBlogOpenId(); //公众号openId
|
|
|
+ if(blogOpenId !=null){
|
|
|
+ //推送模板
|
|
|
+ List<WxMpTemplateData> wxMpTemplate = new ArrayList<>();
|
|
|
+ wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+customerPoints.getCustomerName()+",您好:\n" + "您在"+stationName+"的积分最新交易信息如下"));
|
|
|
+ wxMpTemplate.add(new WxMpTemplateData("time", new SimpleDateFormat("yyyy年MM月dd日HH时mm分").format(new Date())));
|
|
|
+ wxMpTemplate.add(new WxMpTemplateData("type", "增加"));
|
|
|
+ wxMpTemplate.add(new WxMpTemplateData("Point", String.valueOf(customerPoints.getRecentlyPoints())));
|
|
|
+ wxMpTemplate.add(new WxMpTemplateData("From", stationName));
|
|
|
+ wxMpTemplate.add(new WxMpTemplateData("remark",
|
|
|
+ "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+customerPoints.getPoints().toString()+" 分"));
|
|
|
+ GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
|
|
|
+ gzhNewsTemplate.setStationId(customerPoints.getStationId());
|
|
|
+ gzhNewsTemplate.setTemplateType("1");
|
|
|
+ GzhNewsTemplate gzhNewsTemplateInfo = gzhNewsTemplateService.getGzhNewsTemplate(gzhNewsTemplate);
|
|
|
+ if(gzhNewsTemplateInfo !=null && gzhNewsTemplateInfo.getTemplateId() !=null){
|
|
|
+ wxPushUtil.push(gzhAppId, gzhAppSecret, gzhNewsTemplateInfo.getTemplateId(), blogOpenId, wxMpTemplate);
|
|
|
}
|
|
|
-
|
|
|
- }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.setRecentConsumptionDate(new Date());
|
|
|
- customerPoints.setCreateTime(new Date());
|
|
|
- //新增客户积分
|
|
|
- customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
- logger.info("新增客户积分信息成功!");
|
|
|
}
|
|
|
|
|
|
}
|