jk-GitHub-coder il y a 4 ans
Parent
commit
6ab8111095
23 fichiers modifiés avec 924 ajouts et 3 suppressions
  1. 120 0
      YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralOrderController.java
  2. 89 3
      YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java
  3. 18 0
      YijiaRestful/src/main/java/com/platform/yijia/dao/CustomerPointsMapper.java
  4. 14 0
      YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralOrderMapper.java
  5. 11 0
      YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralRuleMapper.java
  6. 11 0
      YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralWaresMapper.java
  7. 27 0
      YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerPoints.java
  8. 23 0
      YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralOrder.java
  9. 30 0
      YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralRule.java
  10. 27 0
      YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralWares.java
  11. 19 0
      YijiaRestful/src/main/java/com/platform/yijia/service/CustomerPointsService.java
  12. 13 0
      YijiaRestful/src/main/java/com/platform/yijia/service/IntegralOrderService.java
  13. 14 0
      YijiaRestful/src/main/java/com/platform/yijia/service/IntegralRuleService.java
  14. 13 0
      YijiaRestful/src/main/java/com/platform/yijia/service/IntegralWaresService.java
  15. 42 0
      YijiaRestful/src/main/java/com/platform/yijia/service/impl/CustomerPointsServiceImpl.java
  16. 32 0
      YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralOrderServiceImpl.java
  17. 19 0
      YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralRuleServiceImpl.java
  18. 20 0
      YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralWaresServiceImpl.java
  19. 185 0
      YijiaRestful/src/main/resources/mapper/CustomerPointsMapper.xml
  20. 106 0
      YijiaRestful/src/main/resources/mapper/IntegralOrderMapper.xml
  21. 48 0
      YijiaRestful/src/main/resources/mapper/IntegralRuleMapper.xml
  22. 41 0
      YijiaRestful/src/main/resources/mapper/IntegralWaresMapper.xml
  23. 2 0
      YijiaRestful/src/main/resources/mapper/PayOrderMapper.xml

+ 120 - 0
YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralOrderController.java

@@ -0,0 +1,120 @@
+package com.platform.yijia.controller;
+
+import com.google.gson.Gson;
+import com.platform.yijia.pojo.*;
+import com.platform.yijia.service.*;
+import com.platform.yijia.utils.CodeMsg;
+import com.platform.yijia.utils.ResultData;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
+/*
+ * <Title> IntegralWaresController </Title>
+ * <Description> 油站积分商城 </Description>
+ * @Author JK
+ * @Date 2021年2月24日
+ */
+@Controller
+@RequestMapping("/api")
+public class IntegralOrderController {
+    @Resource
+    private IntegralWaresService integralWaresService;
+    @Resource
+    private IntegralOrderService integralOrderService;
+    @Resource
+    private CustomerPointsService customerPointsService;
+
+    //获取油站积分商品信息
+    @RequestMapping(value = "/getIntegralWaresInfoList", method = RequestMethod.GET)
+    @ResponseBody
+    public String getIntegralWaresInfoList(@RequestParam Integer stationId){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        if(stationId !=null){
+            IntegralWares integralWares = new IntegralWares();
+            integralWares.setStationId(stationId);
+            List<IntegralWares> integralWaresInfoList = integralWaresService.getIntegralWaresInfoList(integralWares);
+            resultData=ResultData.success(integralWaresInfoList);
+        }else{
+            resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
+
+    //生成积分订单
+    @RequestMapping(value = "/insertIntegralOrder", method = RequestMethod.GET)
+    @ResponseBody
+    public String insertIntegralOrder(@RequestParam IntegralOrder request){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        IntegralOrder integralOrder = new IntegralOrder();
+        if(StringUtils.isNotBlank(request.getCustomerName())){
+            integralOrder.setCustomerName(request.getCustomerName());
+        }
+        if(StringUtils.isNotBlank(request.getWaresName())){
+            integralOrder.setWaresName(request.getWaresName());
+        }
+        if(request.getExchangeNum() != null){
+            integralOrder.setExchangeNum(request.getExchangeNum());
+        }
+        if(StringUtils.isNotBlank(request.getUnionId())){
+            integralOrder.setUnionId(request.getUnionId());
+        }
+        //订单规则 时间+6位随机数
+        Random random = new Random();
+        String str="";
+        for(int i=0; i<6; i++){
+            str+=random.nextInt(10);
+        }
+        integralOrder.setIntegralOrderNo(Integer.valueOf(System.nanoTime()+str));
+        integralOrder.setExchangeTime(new Date());
+
+        //更新用户积分
+        CustomerPoints customerPoints = new CustomerPoints();
+        customerPoints.setUnionId(request.getUnionId());
+        CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
+        //用户剩余积分
+        BigDecimal points = new BigDecimal(customerPointsInfo.getPoints()).subtract(new BigDecimal(request.getIntegral()));
+        customerPoints.setPoints(Integer.valueOf(points.toString()));
+        //用户已消费积分累积
+        BigDecimal consumptionPoints = new BigDecimal(customerPointsInfo.getConsumptionPoints()).add(new BigDecimal(request.getIntegral()));
+        customerPoints.setConsumptionPoints(Integer.valueOf(consumptionPoints.toString()));
+        customerPointsService.updateCustomerPointsInfo(customerPoints);
+
+        boolean b = integralOrderService.insertIntegralOrder(integralOrder);
+        if (b){
+            resultData=ResultData.success(CodeMsg.SUCCESS);
+        }else {
+            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
+
+    //获取用户订单列表
+    @RequestMapping(value = "/getUserIntegralOrderList", method = RequestMethod.GET)
+    @ResponseBody
+    public String getUserIntegralOrderList(@RequestParam String unionId){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        if(unionId !=null){
+            IntegralOrder integralOrder = new IntegralOrder();
+            integralOrder.setUnionId(unionId);
+            List<IntegralOrder> integralOrderList = integralOrderService.getUserIntegralOrderList(integralOrder);
+            resultData=ResultData.success(integralOrderList);
+        }else {
+            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
+
+}

+ 89 - 3
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -4,9 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.parser.Feature;
 import com.google.gson.Gson;
 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.utils.*;
 import org.apache.commons.lang3.StringUtils;
@@ -16,6 +14,7 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -34,6 +33,10 @@ public class PayController {
     private CustomerGradeServices customerGradeServices;
     @Resource
     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);   //获取该订单手机号、加油升数、实收金额、油站名称
                         //手机号必须有
                         if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
+
                             //存放客户信息
                             CustomerManage customerManage = new CustomerManage();
                             //存放查询用户信息
@@ -639,7 +643,89 @@ public class PayController {
                                 logger.info("不存在客户 新增时参数: " + customerManage.toString());
                                 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 content2;

+ 18 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/CustomerPointsMapper.java

@@ -0,0 +1,18 @@
+package com.platform.yijia.dao;
+
+
+import com.platform.yijia.pojo.CustomerPoints;
+
+public interface CustomerPointsMapper {
+    //获取用户积分信息
+    CustomerPoints getCustomerPointsInfo(CustomerPoints customerPoints);
+
+    //插入用户积分信息
+    void insertCustomerPointsInfo(CustomerPoints customerPoints);
+
+    //更新用户积分信息
+    void updateCustomerPointsInfo(CustomerPoints customerPoints);
+
+    //判断该用户是否存在积分表
+    int isExistCustomerPointsInfo(CustomerPoints customerPoints);
+}

+ 14 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralOrderMapper.java

@@ -0,0 +1,14 @@
+package com.platform.yijia.dao;
+
+import com.platform.yijia.pojo.IntegralOrder;
+
+import java.util.List;
+
+public interface IntegralOrderMapper {
+
+    //生成积分订单
+    int insertIntegralOrder(IntegralOrder integralOrder);
+
+    //获取个人积分订单
+    List<IntegralOrder> getUserIntegralOrderList(IntegralOrder integralOrder);
+}

+ 11 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralRuleMapper.java

@@ -0,0 +1,11 @@
+package com.platform.yijia.dao;
+
+import com.platform.yijia.pojo.IntegralRule;
+
+import java.util.List;
+
+public interface IntegralRuleMapper {
+
+    //获取油站油品积分规则
+    List<IntegralRule> getIntegralRule(IntegralRule integralRule);
+}

+ 11 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralWaresMapper.java

@@ -0,0 +1,11 @@
+package com.platform.yijia.dao;
+
+
+import com.platform.yijia.pojo.IntegralWares;
+
+import java.util.List;
+
+public interface IntegralWaresMapper {
+    //获取油站积分商品信息
+    List<IntegralWares> getIntegralWaresInfoList(IntegralWares integralWares);
+}

+ 27 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerPoints.java

@@ -0,0 +1,27 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/***
+ * 用户积分表实体类
+ */
+
+@Data
+public class CustomerPoints {
+    private Integer id;                          //主键
+    private String unionId;                      //微信用户UnionId
+    private String blogOpenId;                   //公众号的openID
+    private String minaOpenId;                   //小程序的openID
+    private String customerName;                  //会员名字
+    private String mobilePhone;                  //用户手机号
+    private Integer points;                      //用户余额积分
+    private Integer consumptionPoints;           //用户消费累计积分
+    private Integer accumulatePoints;            //用户累计积分
+    private Integer invalidPoints;               //用户失效累计积分
+    private Date recentConsumptionDate;          //用户最近消费积分时间
+    private Integer stationId;                   //油站ID
+    private String stationName;                  //油站名称
+
+}

+ 23 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralOrder.java

@@ -0,0 +1,23 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 积分订单实体类
+ */
+@Data
+public class IntegralOrder {
+    private  Integer id;                 //'积分订单id',
+    private  Integer integralOrderNo;    //'积分订单号',
+    private  String waresType;           //'商品类型',
+    private  String waresName;           //'商品名称',
+    private  String unionId;             //'微信唯一标识',
+    private  String customerName;        //'会员名称',
+    private  Integer exchangeNum;        //'兑换数量',
+    private  Date exchangeTime;          //'兑换时间',
+    private  String status;              //'订单状态(1已完成,2已取消)',
+    private Integer integral;           //订单消耗积分
+    private Integer stationId;          //油站ID
+}

+ 30 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralRule.java

@@ -0,0 +1,30 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/***
+ * 积分规则实体类
+ */
+@Data
+public class IntegralRule {
+    private Integer id;                     //'主键id',
+    private Integer stationId;              //'油站id',
+    private String stationName;             //'油站名称',
+    private String ruleType;                //'订单积分计算规则类型(1以订单实付累计 2以订单应付累计)',
+    private BigDecimal ruleAmt;             //'规则满多少钱起累计金额',
+    private String gread;                   //'会员等级',
+    private String oilName;                 //'油品名称',
+    private BigDecimal saleAmt;             //'每消费金额',
+    private BigDecimal integral;            //'兑换积分',
+    private String termDateManage;          //'有效期设置',
+    private Date emptyDate;                 //'清空积分时间',
+    private String expirationReminder;      //'到期提醒设置',
+    private Date remindDate;                //'提醒时间设置',
+    private String integralActivity;        //'积分活动设置',
+    private String datePicker;              //'日期选择',
+    private String integralProportion;      //'积分比例',
+    private String integralDeductionOil;    //'积分抵扣油品规则',
+}

+ 27 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralWares.java

@@ -0,0 +1,27 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/***
+ * 积分商品
+ */
+@Data
+public class IntegralWares {
+    private Integer id;                 //'商品主键id',
+    private String waresType;           //'商品类别',
+    private String waresName;           //'商品名称',
+    private BigDecimal saleIntegral;    //'消费积分',
+    private String waresPic;            //'商品图片',
+    private String waresDetail;         //'商品详情',
+    private String waresStatus;         //'商品状态(1上架,2下架)',
+    private Date createTime;            //'创建时间',
+    private String createBy;            //'创建人id',
+    private String createName;          //'创建人名称',
+    private Date updateTime;            //'更新时间',
+    private String updateBy;            //'更新人id',
+    private Date updateName;            //'更新人名称',
+    private Integer stationId;          //'油站ID',
+}

+ 19 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/CustomerPointsService.java

@@ -0,0 +1,19 @@
+package com.platform.yijia.service;
+
+
+import com.platform.yijia.pojo.CustomerPoints;
+
+public interface CustomerPointsService {
+
+    //获取用户积分信息
+    CustomerPoints getCustomerPointsInfo(CustomerPoints customerPoints);
+
+    //插入用户积分信息
+    void insertCustomerPointsInfo(CustomerPoints customerPoints);
+
+    //更新用户积分信息
+    void updateCustomerPointsInfo(CustomerPoints customerPoints);
+
+    //判断该用户是否存在积分表
+    boolean isExistCustomerPointsInfo(CustomerPoints customerPoints);
+}

+ 13 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/IntegralOrderService.java

@@ -0,0 +1,13 @@
+package com.platform.yijia.service;
+import com.platform.yijia.pojo.IntegralOrder;
+import java.util.List;
+
+public interface IntegralOrderService {
+
+    //生成积分订单
+    boolean insertIntegralOrder(IntegralOrder integralOrder);
+
+    //获取个人积分订单
+    List<IntegralOrder> getUserIntegralOrderList(IntegralOrder integralOrder);
+
+}

+ 14 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/IntegralRuleService.java

@@ -0,0 +1,14 @@
+package com.platform.yijia.service;
+
+
+import com.platform.yijia.pojo.IntegralRule;
+import com.platform.yijia.pojo.IntegralWares;
+
+import java.util.List;
+
+public interface IntegralRuleService {
+
+    //获取油站积分规则
+    List<IntegralRule> getIntegralRule(IntegralRule integralRule);
+
+}

+ 13 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/IntegralWaresService.java

@@ -0,0 +1,13 @@
+package com.platform.yijia.service;
+
+
+import com.platform.yijia.pojo.IntegralWares;
+
+import java.util.List;
+
+public interface IntegralWaresService {
+
+    //获取油站积分商品信息
+    List<IntegralWares> getIntegralWaresInfoList(IntegralWares integralWares);
+
+}

+ 42 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/CustomerPointsServiceImpl.java

@@ -0,0 +1,42 @@
+package com.platform.yijia.service.impl;
+import com.platform.yijia.dao.CustomerPointsMapper;
+import com.platform.yijia.pojo.CustomerPoints;
+import com.platform.yijia.service.CustomerPointsService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service("customerPointsService")
+public class CustomerPointsServiceImpl implements CustomerPointsService {
+    @Resource
+    private CustomerPointsMapper customerPointsMapper;
+
+    //获取用户积分信息
+    @Override
+    public CustomerPoints getCustomerPointsInfo(CustomerPoints customerPoints) {
+        return customerPointsMapper.getCustomerPointsInfo(customerPoints);
+    }
+
+    //插入用户积分信息
+    @Override
+    public void insertCustomerPointsInfo(CustomerPoints customerPoints) {
+        customerPointsMapper.insertCustomerPointsInfo(customerPoints);
+    }
+
+    //更新用户积分信息
+    @Override
+    public void updateCustomerPointsInfo(CustomerPoints customerPoints) {
+        customerPointsMapper.updateCustomerPointsInfo(customerPoints);
+    }
+
+    //判断该用户是否存在积分表
+    @Override
+    public boolean isExistCustomerPointsInfo(CustomerPoints customerPoints) {
+        boolean boo = false;
+        int i = customerPointsMapper.isExistCustomerPointsInfo(customerPoints);
+        if(i >= 1){
+            boo = true;
+        }
+        return boo;
+    }
+}

+ 32 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralOrderServiceImpl.java

@@ -0,0 +1,32 @@
+package com.platform.yijia.service.impl;
+
+import com.platform.yijia.dao.IntegralOrderMapper;
+import com.platform.yijia.pojo.IntegralOrder;
+import com.platform.yijia.service.IntegralOrderService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service("integralOrderService")
+public class IntegralOrderServiceImpl implements IntegralOrderService {
+    @Resource
+    private IntegralOrderMapper integralOrderMapper;
+
+    //新增积分订单
+    @Override
+    public boolean insertIntegralOrder(IntegralOrder integralOrder) {
+        boolean boo = false;
+        int i = integralOrderMapper.insertIntegralOrder(integralOrder);
+        if(i == 1){
+            boo = true;
+        }
+        return boo;
+    }
+
+    //查询个人积分订单信息
+    @Override
+    public List<IntegralOrder> getUserIntegralOrderList(IntegralOrder integralOrder) {
+        return integralOrderMapper.getUserIntegralOrderList(integralOrder);
+    }
+}

+ 19 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralRuleServiceImpl.java

@@ -0,0 +1,19 @@
+package com.platform.yijia.service.impl;
+import com.platform.yijia.dao.IntegralRuleMapper;
+import com.platform.yijia.pojo.IntegralRule;
+import com.platform.yijia.service.IntegralRuleService;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service("integralRuleService")
+public class IntegralRuleServiceImpl implements IntegralRuleService {
+    @Resource
+    private IntegralRuleMapper integralRuleMapper;
+
+    //获取油站积分规则
+    @Override
+    public List<IntegralRule> getIntegralRule(IntegralRule integralRule) {
+        return integralRuleMapper.getIntegralRule(integralRule);
+    }
+}

+ 20 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralWaresServiceImpl.java

@@ -0,0 +1,20 @@
+package com.platform.yijia.service.impl;
+import com.platform.yijia.dao.IntegralWaresMapper;
+import com.platform.yijia.pojo.IntegralWares;
+import com.platform.yijia.service.IntegralWaresService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service("integralWaresService")
+public class IntegralWaresServiceImpl implements IntegralWaresService {
+    @Resource
+    private IntegralWaresMapper integralWaresMapper;
+
+    //获取油站积分商品信息
+    @Override
+    public List<IntegralWares> getIntegralWaresInfoList(IntegralWares integralWares) {
+        return integralWaresMapper.getIntegralWaresInfoList(integralWares);
+    }
+}

+ 185 - 0
YijiaRestful/src/main/resources/mapper/CustomerPointsMapper.xml

@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.platform.yijia.dao.CustomerPointsMapper">
+  <!--返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.CustomerPoints">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="union_id" jdbcType="VARCHAR" property="unionId" />
+    <result column="blog_openid" jdbcType="VARCHAR" property="blogOpenId" />
+    <result column="mina_openid" jdbcType="VARCHAR" property="minaOpenId" />
+    <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
+    <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
+    <result column="points" jdbcType="INTEGER" property="points" />
+    <result column="consumption_points" jdbcType="INTEGER" property="consumptionPoints" />
+    <result column="accumulate_points" jdbcType="INTEGER" property="accumulatePoints" />
+    <result column="invalid_points" jdbcType="INTEGER" property="invalidPoints" />
+    <result column="recent_consumption_date" jdbcType="DATE" property="recentConsumptionDate" />
+    <result column="station_id" jdbcType="INTEGER" property="stationId" />
+    <result column="station_name" jdbcType="VARCHAR" property="stationName" />
+  </resultMap>
+
+  <!--查询列-->
+  <sql id="Base_Column_List">
+    id, union_id, blog_openid, mina_openid, mobile_phone, customer_name, points, consumption_points, accumulate_points, invalid_points,
+    recent_consumption_date, station_id, station_name
+  </sql>
+
+  <!--查询客户积分信息-->
+  <select id="getCustomerPointsInfo" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.CustomerPoints">
+    SELECT
+        <include refid="Base_Column_List" />
+    FROM customer_points
+    <where>
+        <if test="unionId !=null and unionId !=''">
+          union_id = #{unionId}
+        </if>
+      <if test="stationId !=null and stationId !=''">
+        AND station_id = #{stationId}
+      </if>
+    </where>
+  </select>
+
+  <!--插入客户积分表-->
+  <insert id="insertCustomerPointsInfo" parameterType="com.platform.yijia.pojo.CustomerPoints">
+    INSERT INTO customer_points
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="unionId !=null">
+        union_id,
+      </if>
+      <if test="blogOpenId !=null">
+        blog_openid,
+      </if>
+      <if test="minaOpenId !=null">
+        mina_openid,
+      </if>
+      <if test="mobilePhone !=null">
+        mobile_phone,
+      </if>
+      <if test="customerName !=null">
+        customer_name,
+      </if>
+      <if test="points !=null">
+        points,
+      </if>
+      <if test="consumptionPoints !=null">
+        consumption_points,
+      </if>
+      <if test="accumulatePoints !=null">
+        accumulate_points,
+      </if>
+      <if test="invalidPoints !=null">
+        invalid_points,
+      </if>
+      <if test="recentConsumptionDate !=null">
+        recent_consumption_date,
+      </if>
+      <if test="stationId !=null">
+        station_id,
+      </if>
+      <if test="stationName !=null">
+        station_name,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="unionId !=null">
+        #{unionId},
+      </if>
+      <if test="blogOpenId !=null">
+        #{blogOpenId},
+      </if>
+      <if test="minaOpenId !=null">
+        #{minaOpenId},
+      </if>
+      <if test="mobilePhone !=null">
+        #{mobilePhone},
+      </if>
+      <if test="customerName !=null">
+        #{customerName},
+      </if>
+      <if test="points !=null">
+        #{points},
+      </if>
+      <if test="consumptionPoints !=null">
+        #{consumptionPoints},
+      </if>
+      <if test="accumulatePoints !=null">
+        #{accumulatePoints},
+      </if>
+      <if test="invalidPoints !=null">
+        #{invalidPoints},
+      </if>
+      <if test="recentConsumptionDate !=null">
+        #{recentConsumptionDate},
+      </if>
+      <if test="stationId !=null">
+        #{stationId},
+      </if>
+      <if test="stationName !=null">
+        #{stationName},
+      </if>
+    </trim>
+  </insert>
+
+  <!--更新客户积分表-->
+  <update id="updateCustomerPointsInfo" parameterType="com.platform.yijia.pojo.CustomerPoints">
+    UPDATE
+        customer_points
+    <set>
+      <if test="unionId !=null">
+        union_id =#{unionId},
+      </if>
+      <if test="blogOpenId !=null">
+        blog_openid =#{blogOpenId},
+      </if>
+      <if test="minaOpenId !=null">
+        mina_openid =#{minaOpenId},
+      </if>
+      <if test="mobilePhone !=null">
+        mobile_phone=#{mobilePhone},
+      </if>
+      <if test="customerName !=null">
+        customer_name =#{customerName},
+      </if>
+      <if test="points !=null">
+        points =#{points},
+      </if>
+      <if test="consumptionPoints !=null">
+        consumption_points =#{consumptionPoints},
+      </if>
+      <if test="accumulatePoints !=null">
+        accumulate_points =#{accumulatePoints},
+      </if>
+      <if test="invalidPoints !=null">
+        invalid_points =#{invalidPoints},
+      </if>
+      <if test="recentConsumptionDate !=null">
+        recent_consumption_date =#{recentConsumptionDate},
+      </if>
+      <if test="stationId !=null">
+        station_id =#{stationId},
+      </if>
+      <if test="stationName !=null">
+        station_name =#{stationName}
+      </if>
+    </set>
+    <where>
+      <if test="unionId !=null">
+        union_id = #{unionId}
+      </if>
+    </where>
+  </update>
+
+  <!--判断是否存在-->
+  <select id="isExistCustomerPointsInfo" resultType="int" parameterType="com.platform.yijia.pojo.CustomerPoints">
+    SELECT
+        COUNT (id)
+    FROM
+        customer_points
+    <where>
+      <if test="unionId !=null">
+        union_id = #{unionId}
+      </if>
+    </where>
+  </select>
+
+</mapper>

+ 106 - 0
YijiaRestful/src/main/resources/mapper/IntegralOrderMapper.xml

@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.platform.yijia.dao.IntegralOrderMapper">
+  <!--返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.IntegralOrder">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="integral_order_no" jdbcType="INTEGER" property="integralOrderNo" />
+    <result column="wares_type" jdbcType="VARCHAR" property="waresType" />
+    <result column="wares_name" jdbcType="VARCHAR" property="waresName" />
+    <result column="union_id" jdbcType="VARCHAR" property="unionId" />
+    <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
+    <result column="exchange_num" jdbcType="INTEGER" property="exchangeNum" />
+    <result column="exchange_time" jdbcType="DATE" property="exchangeTime" />
+    <result column="status" jdbcType="VARCHAR" property="status" />
+    <result column="integral" jdbcType="INTEGER" property="integral" />
+    <result column="station_id" jdbcType="INTEGER" property="stationId" />
+  </resultMap>
+
+  <!--查询列-->
+  <sql id="Base_Column_List">
+    id, integral_order_no, wares_type, wares_name, wares_name, union_id, customer_name, exchange_num, exchange_time,
+    status, integral, station_id
+  </sql>
+
+  <!--查询个人积分订单信息-->
+  <select id="getUserIntegralOrderList" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.IntegralOrder">
+    SELECT
+        <include refid="Base_Column_List" />
+    FROM integral_order
+    <where>
+      <if test="unionId !=null and unionId !=''">
+        union_id = #{unionId}
+      </if>
+    </where>
+  </select>
+
+  <!--新增积分订单-->
+  <insert id="insertIntegralOrder" parameterType="com.platform.yijia.pojo.IntegralOrder">
+    INSERT INTO integral_order
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="integralOrderNo !=null">
+        integral_order_no,
+      </if>
+      <if test="waresType !=null">
+        wares_type,
+      </if>
+      <if test="waresName !=null">
+        wares_name,
+      </if>
+      <if test="unionId !=null">
+        union_id,
+      </if>
+      <if test="customerName !=null">
+        customer_name,
+      </if>
+      <if test="exchangeNum !=null">
+        exchange_num,
+      </if>
+      <if test="exchangeTime !=null">
+        exchange_time,
+      </if>
+      <if test="status !=null">
+        status,
+      </if>
+      <if test="integral !=null">
+        integral,
+      </if>
+      <if test="stationId !=null">
+        station_id,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="integralOrderNo !=null">
+        #{integralOrderNo},
+      </if>
+      <if test="waresType !=null">
+        #{waresType},
+      </if>
+      <if test="waresName !=null">
+        #{waresName},
+      </if>
+      <if test="unionId !=null">
+        #{unionId},
+      </if>
+      <if test="customerName !=null">
+        #{customerName},
+      </if>
+      <if test="exchangeNum !=null">
+        #{exchangeNum},
+      </if>
+      <if test="exchangeTime !=null">
+        #{exchangeTime},
+      </if>
+      <if test="status !=null">
+        #{status},
+      </if>
+      <if test="integral !=null">
+        #{integral},
+      </if>
+      <if test="stationId !=null">
+        #{stationId},
+      </if>
+    </trim>
+  </insert>
+
+</mapper>

+ 48 - 0
YijiaRestful/src/main/resources/mapper/IntegralRuleMapper.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.platform.yijia.dao.IntegralRuleMapper">
+  <!--返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.IntegralRule">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="station_id" jdbcType="INTEGER" property="stationId" />
+    <result column="station_name" jdbcType="VARCHAR" property="stationName" />
+    <result column="rule_type" jdbcType="VARCHAR" property="ruleType" />
+    <result column="rule_amt" jdbcType="DECIMAL" property="ruleAmt" />
+    <result column="gread" jdbcType="VARCHAR" property="gread" />
+    <result column="oil_name" jdbcType="VARCHAR" property="oilName" />
+    <result column="sale_amt" jdbcType="DECIMAL" property="saleAmt" />
+    <result column="integral" jdbcType="DECIMAL" property="integral" />
+    <result column="term_date_manage" jdbcType="VARCHAR" property="termDateManage" />
+    <result column="empty_date" jdbcType="DATE" property="emptyDate" />
+    <result column="expiration_reminder" jdbcType="VARCHAR" property="expirationReminder" />
+    <result column="remind_date" jdbcType="DATE" property="remindDate" />
+    <result column="integral_activity" jdbcType="VARCHAR" property="integralActivity" />
+    <result column="date_picker" jdbcType="VARCHAR" property="datePicker" />
+    <result column="integral_proportion" jdbcType="VARCHAR" property="integralProportion" />
+    <result column="integral_deduction_oil" jdbcType="VARCHAR" property="integralDeductionOil" />
+  </resultMap>
+
+  <!--查询列-->
+  <sql id="Base_Column_List">
+    id, station_id, station_name, rule_type, rule_amt, gread, oil_name, sale_amt, integral,
+    term_date_manage, empty_date, expiration_reminder, remind_date, integral_activity, date_picker,
+    integral_proportion, integral_deduction_oil
+  </sql>
+
+  <!--查询油站积分规则信息-->
+  <select id="getIntegralRule" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.IntegralRule">
+    SELECT
+        <include refid="Base_Column_List" />
+    FROM integral_rule
+    <where>
+      <if test="stationId !=null and stationId !=''">
+         station_id = #{stationId}
+      </if>
+      <if test="oilName !=null and oilName !=''">
+        AND oil_name = #{oilName}
+      </if>
+    </where>
+  </select>
+
+
+</mapper>

+ 41 - 0
YijiaRestful/src/main/resources/mapper/IntegralWaresMapper.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.platform.yijia.dao.IntegralWaresMapper">
+  <!--返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.IntegralWares">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="wares_type" jdbcType="VARCHAR" property="waresType" />
+    <result column="wares_name" jdbcType="VARCHAR" property="waresName" />
+    <result column="sale_integral" jdbcType="DECIMAL" property="saleIntegral" />
+    <result column="wares_pic" jdbcType="VARCHAR" property="waresPic" />
+    <result column="wares_detail" jdbcType="VARCHAR" property="waresDetail" />
+    <result column="wares_status" jdbcType="VARCHAR" property="waresStatus" />
+    <result column="create_time" jdbcType="DATE" property="createTime" />
+    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
+    <result column="create_name" jdbcType="VARCHAR" property="createName" />
+    <result column="update_time" jdbcType="DATE" property="updateTime" />
+    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
+    <result column="update_name" jdbcType="VARCHAR" property="updateName" />
+<!--    <result column="station_id" jdbcType="INTEGER" property="stationId" />-->
+  </resultMap>
+
+  <!--查询列-->
+  <sql id="Base_Column_List">
+    id, union_id, wares_type, wares_name, sale_integral, wares_pic, wares_detail, wares_status, create_time,
+    create_by, create_name, update_time, update_by, update_name
+  </sql>
+
+  <!--查询油站商品信息-->
+  <select id="getIntegralWaresInfoList" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.IntegralWares">
+    SELECT
+        <include refid="Base_Column_List" />
+    FROM integral_wares
+    <where>
+      <if test="stationId !=null and stationId !=''">
+         station_id = #{stationId}
+      </if>
+    </where>
+  </select>
+
+
+</mapper>

+ 2 - 0
YijiaRestful/src/main/resources/mapper/PayOrderMapper.xml

@@ -770,6 +770,8 @@
         A.discount_amt          AS discountAmt,
         A.created_date          AS createdDate,
         B.user_type 			AS userType,
+        B.blog_openid           AS blogOpenid,
+        B.mina_openid           AS minaOpenid,
         B.mobile_phone			AS mobilePhone
     FROM
         pay_order AS A