jk-GitHub-coder 4 лет назад
Родитель
Сommit
fd6f699257

+ 5 - 1
YijiaRestful/src/main/java/com/platform/yijia/controller/AppUserInfoController.java

@@ -108,7 +108,7 @@ public class AppUserInfoController {
                     map.put("nickName", unionIdInfo.get("nickname").toString());
                 }
                 if(unionIdInfo !=null && unionIdInfo.containsKey("openid")){
-                    map.put("openid", unionIdInfo.get("openid").toString());
+                    map.put("openId", unionIdInfo.get("openid").toString());
                 }
                 if(unionIdInfo !=null && unionIdInfo.containsKey("unionid")){
                     map.put("unoinId", unionIdInfo.get("unionid").toString());
@@ -168,6 +168,10 @@ public class AppUserInfoController {
             if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
                 appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
             }
+            if(StringUtils.isNotBlank(request.getUnionId())){
+                appUserInfo.setUnionId(request.getUnionId());
+                //customerPoints.setUnionId(request.getUnionId());
+            }
 
             appUserInfo.setRegisteDate(new Date());
             appUserInfo.setUpdateDate(new Date());

+ 74 - 14
YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralShoppingMallController.java

@@ -46,6 +46,8 @@ public class IntegralShoppingMallController {
     private RedisCacheUtil redisCacheUtil;
     @Resource
     private WxPushUtil wxPushUtil;
+    @Resource
+    private IntegralRuleService integralRuleService;
 
     //获取油站积分商品信息
     @RequestMapping(value = "/getIntegralWaresInfoList", method = RequestMethod.GET)
@@ -128,20 +130,20 @@ public class IntegralShoppingMallController {
             gzhAppSecret = m.get("gzhAppSecret");
             integralOrder.setStationName(stationName);
             customerPointsRecord.setStationName(stationName);
-            String accessToken ="";
-            if(!redisCacheUtil.hasKey(gzhAppId)){
-                accessToken = WeiXinUserUtil.getToken(gzhAppId, gzhAppSecret).getAccessToken();
-                redisCacheUtil.setCacheObject(gzhAppId, accessToken);
-                redisCacheUtil.expire(gzhAppId, 7200);
-            }else {
-                accessToken  = redisCacheUtil.getCacheObject(gzhAppId);
-            }
-            net.sf.json.JSONObject unionIdInfo = WeiXinUserUtil.getUnionIdInfo(accessToken, request.getOpenId());
-            if(unionIdInfo !=null && unionIdInfo.containsKey("unoinId")){
-                integralOrder.setUnionId(unionIdInfo.get("unoinId").toString());
-                customerPoints.setUnionId(unionIdInfo.get("unoinId").toString());
-                customerPointsRecord.setUnionId(unionIdInfo.get("unoinId").toString());
-            }
+//            String accessToken ="";
+//            if(!redisCacheUtil.hasKey(gzhAppId)){
+//                accessToken = WeiXinUserUtil.getToken(gzhAppId, gzhAppSecret).getAccessToken();
+//                redisCacheUtil.setCacheObject(gzhAppId, accessToken);
+//                redisCacheUtil.expire(gzhAppId, 7200);
+//            }else {
+//                accessToken  = redisCacheUtil.getCacheObject(gzhAppId);
+//            }
+//            net.sf.json.JSONObject unionIdInfo = WeiXinUserUtil.getUnionIdInfo(accessToken, request.getOpenId());
+//            if(unionIdInfo !=null && unionIdInfo.containsKey("unoinId")){
+//                integralOrder.setUnionId(unionIdInfo.get("unoinId").toString());
+//                customerPoints.setUnionId(unionIdInfo.get("unoinId").toString());
+//                customerPointsRecord.setUnionId(unionIdInfo.get("unoinId").toString());
+//            }
         }
 
         //更新用户积分
@@ -253,4 +255,62 @@ public class IntegralShoppingMallController {
         return gson.toJson(resultData);
     }
 
+    //获取油站油品积分规则信息 根据油站ID和油品名称
+    @RequestMapping(value = "/getIntegralRuleListByOilNameAndStationId", method = RequestMethod.GET)
+    @ResponseBody
+    public String getIntegralRuleList(@RequestParam Integer stationId, String oilName){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        if(stationId !=null){
+            IntegralRule integralRule = new IntegralRule();
+            integralRule.setStationId(stationId);
+            integralRule.setOilName(oilName);
+            List<IntegralRule> integralRuleList = integralRuleService.getIntegralRule(integralRule);
+
+//            String gzhAppId ="";
+//            String gzhAppSecret ="";
+//            String stationName = "";        //油站名称
+//            Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
+//            if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
+//                stationName = m.get("stationName");
+//                gzhAppId = m.get("gzhAppId");
+//                gzhAppSecret = m.get("gzhAppSecret");
+//            }
+//            List<WxMpTemplateData> wxMpTemplate = new ArrayList<>();
+//            wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+"M"+",您好:\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", "212"));
+//            wxMpTemplate.add(new WxMpTemplateData("From", "中化加油站"));
+//            wxMpTemplate.add(new WxMpTemplateData("remark",
+//                    "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 22222 分"));
+//            String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板
+//            wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, "oJR5R6r4EJhaORFcPap70r_mtFZo", wxMpTemplate);
+            resultData=ResultData.success(integralRuleList);
+        }else {
+            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
+
+    //获取油站积分规则信息 根据油站ID
+    @RequestMapping(value = "/getIntegralRuleList", method = RequestMethod.GET)
+    @ResponseBody
+    public String getIntegralRuleList(@RequestParam Integer stationId){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        if(stationId !=null){
+            IntegralRule integralRule = new IntegralRule();
+            integralRule.setStationId(stationId);
+            List<IntegralRule> integralRuleList = integralRuleService.getIntegralRule(integralRule);
+            resultData=ResultData.success(integralRuleList);
+        }else {
+            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
+
+
 }

+ 114 - 18
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -7,6 +7,10 @@ import com.platform.yijia.param.request.*;
 import com.platform.yijia.pojo.*;
 import com.platform.yijia.service.*;
 import com.platform.yijia.utils.*;
+import com.platform.yijia.utils.redis.RedisCacheUtil;
+import com.platform.yijia.utils.weixinapp.WeiXinUserUtil;
+import com.platform.yijia.utils.weixinapp.WxPushUtil;
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,6 +41,12 @@ public class PayController {
     private CustomerPointsService customerPointsService;
     @Resource
     private IntegralRuleService integralRuleService;
+    @Resource
+    private CustomerPointsRecordService customerPointsRecordService;
+    @Resource
+    private RedisCacheUtil redisCacheUtil;
+    @Resource
+    private WxPushUtil wxPushUtil;
 
     /***
      * 微信子商户支付接口
@@ -650,11 +660,22 @@ public class PayController {
                                 logger.info("不存在客户 新增时参数: " + customerManage.toString());
                                 payOrderService.insertCustomer(customerManage);
                             }
-//==========================================================================================================================================================//
+/*/==========================================================================================================================================================//
                             //客户积分
-                            /*CustomerPoints customerPoints = new CustomerPoints();
+                            CustomerPoints customerPoints = new CustomerPoints();       //客户积分实体表
+                            CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();     //客户积分记录实体表
+                            if(infoMap.containsKey("unionId")){
+                                customerPoints.setUnionId(infoMap.get("unionId").toString());
+                                customerPointsRecord.setUnionId(infoMap.get("unionId").toString());
+                            }
                             customerPoints.setCustomerName(infoMap.get("consumer").toString());
                             customerPoints.setMobilePhone(infoMap.get("mobilePhone").toString());   //存入手机号
+
+                            customerPointsRecord.setCustomerName(infoMap.get("consumer").toString());       //客户名称
+                            customerPointsRecord.setRecordType("+");            // "+"表示增加积分
+                            customerPointsRecord.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
+                            customerPointsRecord.setCreateTime(new Date());
+
                             if(infoMap.containsKey("userType") && infoMap.get("userType") !=null){
                                 switch (infoMap.get("userType").toString()){
                                     case "1":
@@ -673,38 +694,113 @@ public class PayController {
                             if(rule !=null && rule.size() > 0){
                                 //获取该用户积分信息
                                 CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
-                                if(customerPointsInfo !=null){      //已存在
-                                    String ruleType = rule.get(0).getRuleType();   //获取积分规则
+                                if(customerPointsInfo !=null){
+                                    String ruleType = rule.get(0).getRuleType();   //获取积分规则类型
+                                    String[] datePicker={};     //积分比例时间
+                                    if(rule.get(0).getDatePicker() != null && rule.get(0).getDatePicker() !=""){
+                                        datePicker = rule.get(0).getDatePicker().split(",");
+                                    }
+                                    String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
+                                    List<IntegralRuleDetail> integralRuleDetailList = rule.get(0).getIntegralRuleDetailList();  //积分规则详细计算信息
                                     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()));
+                                            BigDecimal realAmt = new BigDecimal(infoMap.get("amt").toString());  //本次消费实收金额
+                                            for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
+                                                if(realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){
+                                                    //计算积分并取整
+                                                    BigDecimal integral = realAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
+                                                    //设置积分多倍时间时
+                                                    if(datePicker !=null){
+                                                        for(String str: datePicker){
+                                                            if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
+                                                                integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
+                                                                break;
+                                                            }
+                                                        }
+                                                    }
+                                                    customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
+                                                    customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
+                                                    customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
+                                                    break;
+                                                }
                                             }
                                             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()));
+                                            for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
+                                                if(receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){
+                                                    //计算积分并取整
+                                                    BigDecimal integral = receivableAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
+                                                    //设置积分多倍时间时
+                                                    if(datePicker !=null){
+                                                        for(String str: datePicker){
+                                                            if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
+                                                                integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
+                                                                break;
+                                                            }
+                                                        }
+                                                    }
+                                                    customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
+                                                    customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
+                                                    customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
+                                                    break;
+                                                }
                                             }
                                             break;
                                         case "3":   //以加油升数
+                                            BigDecimal orderLiters = new BigDecimal(infoMap.get("orderLiters").toString());
+                                            for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
+                                                if(orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==1){
+                                                    //计算积分并取整
+                                                    BigDecimal integral = orderLiters.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
+                                                    //设置积分多倍时间时
+                                                    if(datePicker !=null){
+                                                        for(String str: datePicker){
+                                                            if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){
+                                                                integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
+                                                                break;
+                                                            }
+                                                        }
+                                                    }
+                                                    customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
+                                                    customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
+                                                    customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
+                                                    break;
+                                                }
+                                            }
                                             break;
-
                                     }
                                     //更新客户余额积分
                                     customerPointsService.updateCustomerPointsInfo(customerPoints);
+                                    //插入客户积分记录表
+                                    customerPointsRecordService.insertCustomerPointsInfo(customerPointsRecord);
+
+                                    //客户公众号积分增加通知
+                                    String gzhAppId ="";
+                                    String gzhAppSecret ="";
+                                    String stationName = "";        //油站名称
+                                    Map<String, String> m = stationService.getStationAppIdAndAppSecret(Integer.valueOf(infoMap.get("stationId").toString()));
+                                    if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
+                                        stationName = m.get("stationName");
+                                        gzhAppId = m.get("gzhAppId");
+                                        gzhAppSecret = m.get("gzhAppSecret");
+                                    }
+                                    List<WxMpTemplateData> wxMpTemplate = new ArrayList<>();
+                                    wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+infoMap.get("consumer").toString()+",您好:\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", customerPointsRecord.getIntegral().toString()));
+                                    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()+" 分"));
+                                    String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板
+                                    wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, customerPoints.getBlogOpenId(), wxMpTemplate);
                                 }
-                            }*/
-//========================================================================================================================================================//
+                            }
+
+*///========================================================================================================================================================//
                             //打印机打印小票
                             String content1;
                             String content2;

+ 15 - 18
YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralRule.java

@@ -2,29 +2,26 @@ package com.platform.yijia.pojo;
 
 import lombok.Data;
 
-import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /***
  * 积分规则实体类
  */
 @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;    //'积分抵扣油品规则',
+    private Integer id;                             //'主键id',
+    private Integer stationId;                      //'油站id',
+    private String stationName;                     //'油站名称',
+    private String ruleType;                        //'订单积分计算规则类型(1以订单实付累计 2以订单应付累计)',
+    private String termDateManage;                  //'有效期设置',
+    private Date emptyDate;                         //'清空积分时间',
+    private String expirationReminder;              //'到期提醒设置',
+    private Date remindDate;                        //'提醒时间设置',
+    private String integralActivity;                //'积分活动设置',
+    private String datePicker;                      //'日期选择',
+    private String integralProportion;              //'积分比例',
+    private String integralDeductionOil;      //'积分抵扣油品规则',
+    private List<IntegralRuleDetail> integralRuleDetailList;  //积分规则明细实体类
+    private String oilName;        //'油品名称',
 }

+ 20 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralRuleDetail.java

@@ -0,0 +1,20 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/***
+ * 积分规则明细实体类
+ */
+@Data
+public class IntegralRuleDetail {
+    private Integer integralRuleDetailId;   //'主键id',
+    private Integer parentId;               //'父级id',
+    private BigDecimal ruleTerms;           //'规则满足条件(满足多少升,多少元)',
+    private Integer greadId;                //等级主键id
+    private String gread;                   //'会员等级',
+    private String oilName;                 //'油品名称',
+    private BigDecimal saleAmt;             //'每消费金额',
+    private BigDecimal integral;            //'兑换积分',
+}

+ 20 - 4
YijiaRestful/src/main/resources/mapper/AppUserInfoMapper.xml

@@ -18,6 +18,7 @@
     <result column="mina_token" jdbcType="VARCHAR" property="minaToken" />
     <result column="blog_profile_photo" jdbcType="VARCHAR" property="blogProfilePhoto" />
     <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
+    <result column="union_id" jdbcType="VARCHAR" property="unionId" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -91,7 +92,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     user_id, user_type, blog_openid, mina_openid, mobile_phone, blog_nick_name, sex_flag,
-    registe_date, blog_token, mina_token, blog_profile_photo, update_date
+    registe_date, blog_token, mina_token, blog_profile_photo, update_date, union_id
   </sql>
 
   <!-- 判断注册账户是否已存在-->
@@ -168,12 +169,13 @@
     insert into app_user_info (user_id, user_type, blog_openid,
       mina_openid, mobile_phone, blog_nick_name,
       sex_flag, registe_date, blog_token,
-      mina_token, blog_profile_photo, update_date
+      mina_token, blog_profile_photo, update_date, union_id
       )
     values (#{userId,jdbcType=INTEGER}, #{userType,jdbcType=VARCHAR}, #{blogOpenid,jdbcType=VARCHAR},
       #{minaOpenid,jdbcType=VARCHAR}, #{mobilePhone,jdbcType=VARCHAR}, #{blogNickName,jdbcType=VARCHAR},
       #{sexFlag,jdbcType=VARCHAR}, #{registeDate,jdbcType=TIMESTAMP}, #{blogToken,jdbcType=VARCHAR},
-      #{minaToken,jdbcType=VARCHAR}, #{blogProfilePhoto,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}
+      #{minaToken,jdbcType=VARCHAR}, #{blogProfilePhoto,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP},
+      #{unionId,jdbcType=VARCHAR}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.platform.yijia.pojo.AppUserInfo">
@@ -219,6 +221,9 @@
       <if test="updateDate != null">
         update_date,
       </if>
+      <if test="unionId != null">
+        union_id,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="userId != null">
@@ -257,6 +262,9 @@
       <if test="updateDate != null">
         #{updateDate,jdbcType=TIMESTAMP},
       </if>
+      <if test="unionId != null">
+        #{unionId,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.platform.yijia.pojo.AppUserInfoExample" resultType="java.lang.Long">
@@ -312,6 +320,9 @@
       <if test="record.updateDate != null">
         update_date = #{record.updateDate,jdbcType=TIMESTAMP},
       </if>
+      <if test="record.unionId != null">
+        union_id = #{record.unionId,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -335,6 +346,7 @@
       mina_token = #{record.minaToken,jdbcType=VARCHAR},
       blog_profile_photo = #{record.blogProfilePhoto,jdbcType=VARCHAR},
       update_date = #{record.updateDate,jdbcType=TIMESTAMP}
+      union_id = #{record.unionId,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -379,6 +391,9 @@
       <if test="updateDate != null">
         update_date = #{updateDate,jdbcType=TIMESTAMP},
       </if>
+      <if test="unionId != null">
+        union_id = #{updateDate,jdbcType=VARCHAR},
+      </if>
     </set>
     where user_id = #{userId,jdbcType=INTEGER}
   </update>
@@ -398,7 +413,8 @@
       blog_token = #{blogToken,jdbcType=VARCHAR},
       mina_token = #{minaToken,jdbcType=VARCHAR},
       blog_profile_photo = #{blogProfilePhoto,jdbcType=VARCHAR},
-      update_date = #{updateDate,jdbcType=TIMESTAMP}
+      update_date = #{updateDate,jdbcType=TIMESTAMP},
+      union_id = #{unionId,jdbcType=VARCHAR}
     where user_id = #{userId,jdbcType=INTEGER}
   </update>
 </mapper>

+ 50 - 28
YijiaRestful/src/main/resources/mapper/IntegralRuleMapper.xml

@@ -1,47 +1,69 @@
 <?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" />
+      <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="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" />
+      <collection property="integralRuleDetailList" resultMap="IntegralRuleDetailResultMap"/>
   </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>
+  <!--积分规则明细表-->
+  <resultMap id="IntegralRuleDetailResultMap" type="com.platform.yijia.pojo.IntegralRuleDetail">
+      <id     column="integralRuleDetailId"   jdbcType="INTEGER" property="integralRuleDetailId" />
+      <result column="parent_id"              jdbcType="INTEGER" property="parentId"/>
+      <result column="rule_terms"             jdbcType="DECIMAL" property="ruleTerms" />
+      <result column="gread_id"               jdbcType="INTEGER" property="greadId"/>
+      <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" />
+  </resultMap>
 
   <!--查询油站积分规则信息-->
   <select id="getIntegralRule" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.IntegralRule">
     SELECT
-        <include refid="Base_Column_List" />
-    FROM integral_rule
+        T1.id,
+        T1.station_id,
+        T1.station_name,
+        T1.rule_type,
+        T1.term_date_manage,
+        T1.empty_date,
+        T1.expiration_reminder,
+        T1.remind_date,
+        T1.integral_activity,
+        T1.date_picker,
+        T1.integral_proportion,
+        T1.integral_deduction_oil,
+        T2.id                           AS      integralRuleDetailId,
+        T2.rule_terms,
+        T2.parent_id,
+        T2.gread_id,
+        T2.gread,
+        T2.oil_name,
+        T2.sale_amt,
+        T2.integral
+    FROM
+        integral_rule AS T1 LEFT JOIN integral_rule_detail AS T2 ON T1.id = T2.parent_id
     <where>
       <if test="stationId !=null and stationId !=''">
-         station_id = #{stationId}
+         T1.station_id = #{stationId}
       </if>
       <if test="oilName !=null and oilName !=''">
-        AND oil_name = #{oilName}
+        AND T2.oil_name = #{oilName}
       </if>
     </where>
+    ORDER BY T2.rule_terms DESC
   </select>
 
 

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

@@ -772,6 +772,7 @@
         B.user_type 			AS userType,
         B.blog_openid           AS blogOpenid,
         B.mina_openid           AS minaOpenid,
+        B.union_id              AS unionId,
         B.mobile_phone			AS mobilePhone
     FROM
         pay_order AS A