|
@@ -4,9 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.platform.yijia.param.request.*;
|
|
import com.platform.yijia.param.request.*;
|
|
-import com.platform.yijia.pojo.AppUserInfo;
|
|
|
|
-import com.platform.yijia.pojo.CustomerManage;
|
|
|
|
-import com.platform.yijia.pojo.PayOrder;
|
|
|
|
|
|
+import com.platform.yijia.pojo.*;
|
|
import com.platform.yijia.service.*;
|
|
import com.platform.yijia.service.*;
|
|
import com.platform.yijia.utils.*;
|
|
import com.platform.yijia.utils.*;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -16,6 +14,7 @@ import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -34,6 +33,10 @@ public class PayController {
|
|
private CustomerGradeServices customerGradeServices;
|
|
private CustomerGradeServices customerGradeServices;
|
|
@Resource
|
|
@Resource
|
|
private StationService stationService;
|
|
private StationService stationService;
|
|
|
|
+ @Resource
|
|
|
|
+ private CustomerPointsService customerPointsService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IntegralRuleService integralRuleService;
|
|
|
|
|
|
/***
|
|
/***
|
|
* 微信子商户支付接口
|
|
* 微信子商户支付接口
|
|
@@ -533,6 +536,7 @@ public class PayController {
|
|
Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder); //获取该订单手机号、加油升数、实收金额、油站名称
|
|
Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder); //获取该订单手机号、加油升数、实收金额、油站名称
|
|
//手机号必须有
|
|
//手机号必须有
|
|
if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
|
|
if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
|
|
|
|
+
|
|
//存放客户信息
|
|
//存放客户信息
|
|
CustomerManage customerManage = new CustomerManage();
|
|
CustomerManage customerManage = new CustomerManage();
|
|
//存放查询用户信息
|
|
//存放查询用户信息
|
|
@@ -639,7 +643,89 @@ public class PayController {
|
|
logger.info("不存在客户 新增时参数: " + customerManage.toString());
|
|
logger.info("不存在客户 新增时参数: " + customerManage.toString());
|
|
payOrderService.insertCustomer(customerManage);
|
|
payOrderService.insertCustomer(customerManage);
|
|
}
|
|
}
|
|
|
|
+//==========================================================================================================================================================//
|
|
|
|
+ //客户积分
|
|
|
|
+ /*CustomerPoints customerPoints = new CustomerPoints();
|
|
|
|
+ customerPoints.setCustomerName(infoMap.get("consumer").toString());
|
|
|
|
+ customerPoints.setMobilePhone(infoMap.get("mobilePhone").toString()); //存入手机号
|
|
|
|
+ if(infoMap.containsKey("userType") && infoMap.get("userType") !=null){
|
|
|
|
+ switch (infoMap.get("userType").toString()){
|
|
|
|
+ case "1":
|
|
|
|
+ customerPoints.setBlogOpenId(infoMap.get("blogOpenid").toString());
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ customerPoints.setMinaOpenId(infoMap.get("minaOpenid").toString());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ IntegralRule integralRule =new IntegralRule();
|
|
|
|
+ integralRule.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
|
+ integralRule.setOilName(infoMap.get("oilName").toString());
|
|
|
|
+ //获取该油站的积分规则
|
|
|
|
+ List<IntegralRule> rule = integralRuleService.getIntegralRule(integralRule);
|
|
|
|
+ if(rule !=null && rule.size() > 0){
|
|
|
|
+ //获取该用户积分信息
|
|
|
|
+ CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
|
|
|
|
+ if(customerPointsInfo !=null){ //已存在
|
|
|
|
+ String ruleType = rule.get(0).getRuleType(); //获取积分规则
|
|
|
|
+ switch (ruleType){
|
|
|
|
+ case "1": //以订单实付累计
|
|
|
|
+ //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
|
+ BigDecimal amt1 = new BigDecimal(infoMap.get("amt").toString()); //本次消费实收金额
|
|
|
|
+ if(amt1.compareTo(rule.get(0).getRuleAmt()) ==1){
|
|
|
|
+ //计算积分并取整
|
|
|
|
+ BigDecimal integral = amt1.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "2": //以订单应付累计
|
|
|
|
+ //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
|
+ BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString()); //本次消费实收金额
|
|
|
|
+ if(receivableAmt.compareTo(rule.get(0).getRuleAmt()) ==1){
|
|
|
|
+ //计算积分并取整
|
|
|
|
+ BigDecimal integral = receivableAmt.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "3": //以加油升数
|
|
|
|
+ break;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ //更新客户余额积分
|
|
|
|
+ customerPointsService.updateCustomerPointsInfo(customerPoints);
|
|
|
|
+ }else { //不存在
|
|
|
|
+ String ruleType = rule.get(0).getRuleType(); //获取积分规则
|
|
|
|
+ switch (ruleType){
|
|
|
|
+ case "1": //以订单实付累计
|
|
|
|
+ //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
|
+ BigDecimal amt1 = new BigDecimal(infoMap.get("amt").toString()); //本次消费实收金额
|
|
|
|
+ if(amt1.compareTo(rule.get(0).getRuleAmt()) ==1){
|
|
|
|
+ //计算积分并取整
|
|
|
|
+ BigDecimal integral = amt1.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
|
+ customerPoints.setPoints(Integer.valueOf(integral.toString()));
|
|
|
|
+ customerPoints.setAccumulatePoints(Integer.valueOf(integral.toString()));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "2": //以订单应付累计
|
|
|
|
+ //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
|
+ BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString()); //本次消费实收金额
|
|
|
|
+ if(receivableAmt.compareTo(rule.get(0).getRuleAmt()) ==1){
|
|
|
|
+ //计算积分并取整
|
|
|
|
+ BigDecimal integral = receivableAmt.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
|
+ customerPoints.setPoints(Integer.valueOf(integral.toString()));
|
|
|
|
+ customerPoints.setAccumulatePoints(Integer.valueOf(integral.toString()));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "3": //以加油升数
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ customerPointsService.insertCustomerPointsInfo(customerPoints);
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+//========================================================================================================================================================//
|
|
//打印机打印小票
|
|
//打印机打印小票
|
|
String content1;
|
|
String content1;
|
|
String content2;
|
|
String content2;
|