|
@@ -5,6 +5,7 @@ import com.google.gson.Gson;
|
|
import com.platform.yijia.pojo.CustomerManage;
|
|
import com.platform.yijia.pojo.CustomerManage;
|
|
import com.platform.yijia.service.CustomerGradeServices;
|
|
import com.platform.yijia.service.CustomerGradeServices;
|
|
import com.platform.yijia.service.PayOrderService;
|
|
import com.platform.yijia.service.PayOrderService;
|
|
|
|
+import com.platform.yijia.service.StationService;
|
|
import com.platform.yijia.utils.CodeMsg;
|
|
import com.platform.yijia.utils.CodeMsg;
|
|
import com.platform.yijia.utils.ResultData;
|
|
import com.platform.yijia.utils.ResultData;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -31,6 +32,9 @@ public class CustomerGradeController {
|
|
@Resource
|
|
@Resource
|
|
private PayOrderService payOrderService;
|
|
private PayOrderService payOrderService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private StationService stationService;
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* 查询直降客户等级条件和优惠
|
|
* 查询直降客户等级条件和优惠
|
|
* @param stationId
|
|
* @param stationId
|
|
@@ -44,7 +48,17 @@ public class CustomerGradeController {
|
|
if(StringUtils.isNotBlank(stationId)){
|
|
if(StringUtils.isNotBlank(stationId)){
|
|
Map params = new HashMap();
|
|
Map params = new HashMap();
|
|
params.put("stationId", stationId);
|
|
params.put("stationId", stationId);
|
|
- resultData = ResultData.success(customerGradeServices.getCustomerGradeList(params));
|
|
|
|
|
|
+ String discountPlanType = stationService.getStationDiscountWay(stationId);
|
|
|
|
+ if(discountPlanType.equals("1")){
|
|
|
|
+ //直降表查询
|
|
|
|
+ List<Map> customerGradeList = customerGradeServices.getCustomerGradeList(params);
|
|
|
|
+ resultData = ResultData.success(customerGradeList);
|
|
|
|
+ }else {
|
|
|
|
+ //立减满减表查询
|
|
|
|
+ List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
|
|
+ resultData = ResultData.success(customerMarkertPlanList);
|
|
|
|
+ }
|
|
|
|
+// resultData = ResultData.success(customerGradeServices.getCustomerGradeList(params));
|
|
}else {
|
|
}else {
|
|
resultData=ResultData.error(CodeMsg.SEARCH_FAIL);
|
|
resultData=ResultData.error(CodeMsg.SEARCH_FAIL);
|
|
}
|
|
}
|
|
@@ -67,66 +81,68 @@ public class CustomerGradeController {
|
|
params.put("mobilePhone", jsonObject.get("mobilePhone"));
|
|
params.put("mobilePhone", jsonObject.get("mobilePhone"));
|
|
params.put("stationId", jsonObject.get("stationId"));
|
|
params.put("stationId", jsonObject.get("stationId"));
|
|
params.put("userType", jsonObject.get("userType"));
|
|
params.put("userType", jsonObject.get("userType"));
|
|
- params.put("discountPlanType", jsonObject.get("discountPlanType"));
|
|
|
|
- //用户类型
|
|
|
|
- switch (jsonObject.get("userType").toString()){
|
|
|
|
- case "1":
|
|
|
|
- params.put("blogOpenid", jsonObject.get("openId").toString());
|
|
|
|
- break;
|
|
|
|
- case "2":
|
|
|
|
- params.put("minaOpenid", jsonObject.get("openId").toString());
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+// //用户类型
|
|
|
|
+// switch (jsonObject.get("userType").toString()){
|
|
|
|
+// case "1":
|
|
|
|
+// params.put("blogOpenid", jsonObject.get("openId").toString());
|
|
|
|
+// break;
|
|
|
|
+// case "2":
|
|
|
|
+// params.put("minaOpenid", jsonObject.get("openId").toString());
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
logger.info("查询客户等级所传参数:"+params.toString());
|
|
logger.info("查询客户等级所传参数:"+params.toString());
|
|
-
|
|
|
|
- CustomerManage customerManage = new CustomerManage();
|
|
|
|
- customerManage.setPhoneNumber(params.get("mobilePhone").toString());
|
|
|
|
- customerManage.setPhoneNumber(params.get("oilName").toString());
|
|
|
|
- customerManage.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
|
- CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
|
|
|
|
- //如果为空则是此油品第一次下单
|
|
|
|
- if(existCustomer ==null){
|
|
|
|
- if(jsonObject.get("discountPlanType").toString().equals("直降")){
|
|
|
|
- //如果该油站使用是直降
|
|
|
|
- List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
|
|
|
|
- //只存在一种等级的时候
|
|
|
|
- if(customerGradeInfoList !=null && customerGradeInfoList.size() ==1){
|
|
|
|
- resultData = ResultData.success(customerGradeInfoList);
|
|
|
|
- }else if(customerGradeInfoList !=null && customerGradeInfoList.size() >1){
|
|
|
|
- //存在多个等级时 查询出结果升序排列取第一个即可
|
|
|
|
- resultData = ResultData.success(customerGradeInfoList.get(0));
|
|
|
|
|
|
+ //优惠方案类型
|
|
|
|
+ String discountPlanType = stationService.getStationDiscountWay(params.get("stationId").toString());
|
|
|
|
+ if(discountPlanType != null && discountPlanType !=""){
|
|
|
|
+ params.put("discountPlanType", discountPlanType);
|
|
|
|
+ CustomerManage customerManage = new CustomerManage();
|
|
|
|
+ customerManage.setPhoneNumber(params.get("mobilePhone").toString());
|
|
|
|
+ customerManage.setOilName(params.get("oilName").toString());
|
|
|
|
+ customerManage.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
|
+ CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
|
|
|
|
+ //如果为空则是此油品第一次下单
|
|
|
|
+ if(existCustomer ==null){
|
|
|
|
+ if(discountPlanType.equals("1")){
|
|
|
|
+ //如果该油站使用是直降
|
|
|
|
+ List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
|
|
|
|
+ //只存在一种等级的时候
|
|
|
|
+ if(customerGradeInfoList !=null && customerGradeInfoList.size() ==1){
|
|
|
|
+ resultData = ResultData.success(customerGradeInfoList);
|
|
|
|
+ }else if(customerGradeInfoList !=null && customerGradeInfoList.size() >1){
|
|
|
|
+ //存在多个等级时 查询出结果按优惠的油量升序排列取第一个即可
|
|
|
|
+ resultData = ResultData.success(customerGradeInfoList.get(0));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //如果该油站使用优惠或者立减
|
|
|
|
+ List<Map<String, Object>> customerGradeInfoByYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
|
|
|
|
+ //只存在一个等级时
|
|
|
|
+ if(customerGradeInfoByYouHuiList !=null && customerGradeInfoByYouHuiList.size() ==1){
|
|
|
|
+ resultData = ResultData.success(customerGradeInfoByYouHuiList);
|
|
|
|
+ }else if(customerGradeInfoByYouHuiList !=null && customerGradeInfoByYouHuiList.size() > 1){
|
|
|
|
+ //存在多个等级时 查询出结果按优惠的值升序排列取第一个即可
|
|
|
|
+ resultData = ResultData.success(customerGradeInfoByYouHuiList.get(0));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- //如果该油站使用优惠或者立减
|
|
|
|
- List<Map<String, Object>> customerGradeInfoByYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
|
|
|
|
- //只存在一个等级时
|
|
|
|
- if(customerGradeInfoByYouHuiList !=null && customerGradeInfoByYouHuiList.size() ==1){
|
|
|
|
- resultData = ResultData.success(customerGradeInfoByYouHuiList);
|
|
|
|
- }else if(customerGradeInfoByYouHuiList !=null && customerGradeInfoByYouHuiList.size() > 1){
|
|
|
|
- //存在多个等级时 查询出结果升序排列取第一个即可
|
|
|
|
- resultData = ResultData.success(customerGradeInfoByYouHuiList.get(0));
|
|
|
|
|
|
+ }else{
|
|
|
|
+ //否则该客户此油品已下过订单 存在等级
|
|
|
|
+ String memberGrade = existCustomer.getMemberGrade();
|
|
|
|
+ if(memberGrade != null && memberGrade !=""){
|
|
|
|
+ params.put("grade", memberGrade);
|
|
|
|
+ }
|
|
|
|
+ if(discountPlanType.equals("1")){
|
|
|
|
+ //如果该油站使用是直降
|
|
|
|
+ List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
|
|
|
|
+ resultData = ResultData.success(customerGradeInfoList);
|
|
}else {
|
|
}else {
|
|
- resultData = ResultData.success("该站暂无优惠");
|
|
|
|
|
|
+ //如果该油站使用优惠或者立减
|
|
|
|
+ List<Map<String, Object>> customerGradeInfoYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
|
|
|
|
+ resultData = ResultData.success(customerGradeInfoYouHuiList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- //否则该客户此油品已下过订单 存在等级
|
|
|
|
- String memberGrade = existCustomer.getMemberGrade();
|
|
|
|
- if(memberGrade != null && memberGrade !=""){
|
|
|
|
- params.put("grade", memberGrade);
|
|
|
|
- }
|
|
|
|
- if(jsonObject.get("discountPlanType").toString().equals("直降")){
|
|
|
|
- //如果该油站使用是直降
|
|
|
|
- List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
|
|
|
|
- resultData = ResultData.success(customerGradeInfoList);
|
|
|
|
- }else {
|
|
|
|
- //如果该油站使用优惠或者立减
|
|
|
|
- List<Map<String, Object>> customerGradeInfoYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
|
|
|
|
- resultData = ResultData.success(customerGradeInfoYouHuiList);
|
|
|
|
- }
|
|
|
|
|
|
+ }else {
|
|
|
|
+ resultData = ResultData.success("该油站暂无设置优惠方案");
|
|
}
|
|
}
|
|
return gson.toJson(resultData);
|
|
return gson.toJson(resultData);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|