jk-GitHub-coder %!s(int64=4) %!d(string=hai) anos
pai
achega
9b3c370e1e

+ 11 - 13
YijiaRestful/src/main/java/com/platform/yijia/controller/AppUserInfoController.java

@@ -7,6 +7,7 @@ import com.platform.yijia.pojo.AppUserInfo;
 import com.platform.yijia.pojo.CustomerManage;
 import com.platform.yijia.service.AppUserInfoService;
 import com.platform.yijia.service.PayOrderService;
+import com.platform.yijia.service.StationService;
 import com.platform.yijia.utils.CodeMsg;
 import com.platform.yijia.utils.ResultData;
 import com.platform.yijia.utils.weixinapp.AesDecryptUtil;
@@ -32,17 +33,27 @@ public class AppUserInfoController {
     private PayOrderService payOrderService;
     @Autowired
     private AppUserInfoService appUserInfoService;
+    @Resource
+    private StationService stationService;
     String appId = "wxe1135cd390b38a54";        //微信小程序appID
     String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb";      //微信小程序密钥
 
     /*
      * 微信小程序根据code获取用户openId和sessionKey
      * @param code
+     * , @RequestParam("stationId") String stationId
      * @return
      */
     @ResponseBody
     @RequestMapping(value = "/getSessionKeyAndOpenID")
     public Map<String, Object> getSessionKeyAndOpenID(@RequestParam("code") String code){
+//        String appId = "";        //微信小程序appID
+//        String appSecret = "";      //微信小程序密钥
+//        if(stationId !=null && stationId !=""){
+//            Map<String, String> map = stationService.getStationAppIdAndAppSecret(stationId);
+//            appId = map.get("appId");        //微信小程序appID
+//            appSecret = map.get("appSecret");      //微信小程序密钥
+//        }
         //获取session_key 和 openid
         return WeiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code);
     }
@@ -73,7 +84,6 @@ public class AppUserInfoController {
         ResultData resultData=null;
         try{
             AppUserInfo appUserInfo =new AppUserInfo();
-            //CustomerManage customerManage = new CustomerManage();
             String openId = "";     //此参数用于查询该用户是否已注册过
             //String token ="";       //用户token
             if(request.getUserType()!=null){
@@ -84,7 +94,6 @@ public class AppUserInfoController {
                     appUserInfo.setBlogToken(request.getBlogToken());
                     openId = request.getBlogOpenid();
                     appUserInfo.setBlogOpenid(openId);
-                    //customerManage.setBlogOpenid(openId);
                  //2-微信小程序
                 }else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getMinaOpenid())){
                     appUserInfo.setUserType(request.getUserType());
@@ -92,16 +101,13 @@ public class AppUserInfoController {
                     appUserInfo.setMinaToken(request.getMinaToken());
                     openId = request.getMinaOpenid();
                     appUserInfo.setMinaOpenid(openId);
-                    //customerManage.setMinaOpenid(openId);
                 }
             }
             if(StringUtils.isNotBlank(request.getBlogNickName())){
                 appUserInfo.setBlogNickName(request.getBlogNickName());
-                //customerManage.setCustomerName(request.getBlogNickName());
             }
             if(StringUtils.isNotBlank(request.getMobilePhone())){
                 appUserInfo.setMobilePhone(request.getMobilePhone());
-                //customerManage.setPhoneNumber(request.getMobilePhone());
             }
             if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
                 appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
@@ -109,14 +115,11 @@ public class AppUserInfoController {
 
             appUserInfo.setRegisteDate(new Date());
             appUserInfo.setUpdateDate(new Date());
-            //customerManage.setRegtime(appUserInfo.getRegisteDate());
 
             if(StringUtils.isNotBlank(request.getSexFlag())){
                 appUserInfo.setSexFlag(request.getSexFlag());
             }
 
-//            customerManage.setLiters(new BigDecimal(0));
-//            customerManage.setAmt(new BigDecimal(0));
             Map<String, Object> params = new HashMap<>();
             params.put("openId", openId);                   //注册用户openId
             //params.put("token", token);                     //用户登录凭证
@@ -127,11 +130,6 @@ public class AppUserInfoController {
                 resultData = ResultData.error(CodeMsg.USER_EXSIST);
             }else {
                 appUserInfoService.AddAppUserInfo(appUserInfo);
-                //向客户表中插入数据 判断该客户是否存在
-//                CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
-//                if(existCustomer ==null){
-//                    payOrderService.insertCustomer(customerManage);
-//                }
                 resultData = ResultData.success(CodeMsg.SUCCESS);
             }
         }catch (Exception e){

+ 12 - 2
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -556,23 +556,28 @@ public class PayController {
 
                                 //用户等级设置 说明:每个油站只存在一种优惠方案。 立减满减在另一张表故作次条件判断,如果该油站没有设置优惠方案则不去存会员等级
                                 List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
+                                logger.info("该站直降等级信息:"+ customerGradeInfo);
                                 if(customerGradeInfo != null && customerGradeInfo.size() >0){
                                     for (Map m: customerGradeInfo){
                                         if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString()) && Double.valueOf(customerManage.getAmt().toString()) < Double.valueOf(m.get("memberConditEnd").toString())){
+
                                             customerManage.setGrade(m.get("grade").toString());     //存入等级名称
                                             customerManage.setMemberGrade(m.get("id").toString());     //存入等级ID
                                         }
+                                        logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
                                         break;
                                     }
                                 }else {
                                     //立减满减
                                     List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(infoMap);
+                                    logger.info("该站优惠等级信息:"+ customerMarkertPlanList);
                                     if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){
                                         for(Map m: customerMarkertPlanList){
                                             if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("discountAmt").toString())){
                                                 customerManage.setGrade(m.get("grade").toString());     //存入等级名称
                                                 customerManage.setMemberGrade(m.get("id").toString());     //存入等级ID
                                             }
+                                            logger.info("优惠等级信息是否存入客户表:"+ "优惠ID:"+ customerManage.getMemberGrade()+ "优惠名称: "+customerManage.getGrade());
                                             break;
                                         }
                                     }
@@ -581,25 +586,30 @@ public class PayController {
                                 //存在 更新
                                 payOrderService.updateCustomer(customerManage);
                             }else{          //该客户不存在时插入
+
                                 //用户等级设置 说明:每个油站只存在一种优惠方案。立减满减在另一张表故作此条件判断,如果该油站没有设置优惠方案则不去存会员等级
                                 List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
+                                logger.info("该站直降等级信息:"+ customerGradeInfo);
                                 if(customerGradeInfo != null && customerGradeInfo.size() >0){
                                     for (Map m: customerGradeInfo){
                                         if(Double.valueOf(infoMap.get("amt").toString()) >= Double.valueOf(m.get("memberConditStart").toString()) && Double.valueOf(infoMap.get("amt").toString()) < Double.valueOf(m.get("memberConditEnd").toString())){
                                             customerManage.setGrade(m.get("grade").toString());     //存入等级名称
-                                            customerManage.setMemberId(m.get("id").toString());     //存入等级ID
+                                            customerManage.setMemberGrade(m.get("id").toString());     //存入等级ID
                                         }
+                                        logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
                                         break;
                                     }
                                 }else {
                                     //立减满减
                                     List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(infoMap);
+                                    logger.info("该站优惠等级信息:"+ customerMarkertPlanList);
                                     if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){
                                         for(Map m: customerMarkertPlanList){
                                             if(Double.valueOf(infoMap.get("amt").toString()) >= Double.valueOf(m.get("discountAmt").toString())){
                                                 customerManage.setGrade(m.get("grade").toString());     //存入等级名称
-                                                customerManage.setMemberId(m.get("id").toString());     //存入等级ID
+                                                customerManage.setMemberGrade(m.get("id").toString());     //存入等级ID
                                             }
+                                            logger.info("优惠等级信息是否存入客户表:"+ "优惠ID:"+ customerManage.getMemberGrade()+ "优惠名称: "+customerManage.getGrade());
                                             break;
                                         }
                                     }

+ 3 - 2
YijiaRestful/src/main/java/com/platform/yijia/controller/StationController.java

@@ -39,7 +39,7 @@ public class StationController {
      */
     @RequestMapping(value = "/getStationInfoList", method = RequestMethod.GET)
     @ResponseBody
-     public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize, String appId){
+     public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize){
         Gson gson =new Gson();
         //返回结果集
         ResultData resultData=null;
@@ -50,7 +50,8 @@ public class StationController {
                 stationRequest.setStationLongitude(stationLongitude);
                 stationRequest.setPageNum(pageNum);
                 stationRequest.setPageSize(pageSize);
-                stationRequest.setAppId(appId);
+//                , String appId
+//                stationRequest.setAppId(appId);
                 //调用接口 根据坐标筛选距离最近的加油站
                 StationInfoVo stationInfoVo = stationService.stationInfoList(stationRequest);
                  resultData=ResultData.success(stationInfoVo);

+ 5 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/StationInfoMapper.java

@@ -3,6 +3,8 @@ package com.platform.yijia.dao;
 import com.platform.yijia.pojo.StationInfo;
 import com.platform.yijia.pojo.StationInfoExample;
 import java.util.List;
+import java.util.Map;
+
 import org.apache.ibatis.annotations.Param;
 
 public interface StationInfoMapper {
@@ -10,6 +12,9 @@ public interface StationInfoMapper {
     //获取该油站的优惠方式
     String getStationDiscountWay(String stationId);
 
+    //获取小程序APPID和APPSECRET
+    Map<String, String> getStationAppIdAndAppSecret(String stationId);
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table station_info

+ 4 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/StationService.java

@@ -6,6 +6,7 @@ import com.platform.yijia.param.response.StationInfoVo;
 import com.platform.yijia.pojo.StationInfo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface StationService {
 
@@ -22,4 +23,7 @@ public interface StationService {
 
     //获取该油站的优惠方式
     String getStationDiscountWay(String stationId);
+
+    //获取小程序APPID和APPSECRET
+    Map<String, String> getStationAppIdAndAppSecret(String stationId);
 }

+ 10 - 3
YijiaRestful/src/main/java/com/platform/yijia/service/impl/StationServiceImpl.java

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @Service("stationService")
 public class StationServiceImpl implements StationService {
@@ -29,9 +30,9 @@ public class StationServiceImpl implements StationService {
             example.or().andStationNameLike(stationRequest.getStationName());
 
         }
-        if(StringUtils.isNotBlank(stationRequest.getAppId())){
-            example.or().andAppIdEqualTo(stationRequest.getAppId());
-        }
+//        if(StringUtils.isNotBlank(stationRequest.getAppId())){
+//            example.or().andAppIdEqualTo(stationRequest.getAppId());
+//        }
         // 数据库查询门店数据
         List<StationInfo> stationInfolist = stationInfoMapper.selectByExample(example);
         // 入参坐标拼接
@@ -167,4 +168,10 @@ public class StationServiceImpl implements StationService {
         return stationInfoMapper.getStationDiscountWay(stationId);
     }
 
+    //获取小程序APPID和APPSECRET
+    @Override
+    public Map<String, String> getStationAppIdAndAppSecret(String stationId) {
+        return stationInfoMapper.getStationAppIdAndAppSecret(stationId);
+    }
+
 }

+ 3 - 2
YijiaRestful/src/main/resources/mapper/CustomerGradeMapper.xml

@@ -24,12 +24,13 @@
             grade                       AS grade,
             discount_term               AS discountTerm,
             discount_amt                AS discountAmt,
-            member_condit               AS memberCondit,
             station_id                  AS stationId,
+            vip_discounty_plus          AS vipDiscountyPlus,
+            coupon_plus                 AS couponPlus,
             discount_plan_type          AS discountPlanType,
             station_name                AS stationName,
             oil_name                    AS oilName
-        FROM customer_grade_setting
+        FROM markert_plan
         <where>
             <if test="stationId != null and stationId != ''">
                 station_id = #{stationId}

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

@@ -859,6 +859,9 @@
     UPDATE
         customer_manage
     <set>
+        <if test="memberGrade !=null ">
+          member_grade = #{memberGrade},
+        </if>
         <if test="customerName !=null ">
           customer_name = #{customerName},
         </if>
@@ -880,6 +883,9 @@
         <if test="amt !=null ">
           amt = #{amt},
         </if>
+      <if test="grade !=null ">
+        grade = #{grade},
+      </if>
     </set>
     <where>
       <if test="stationId != null and stationId !='' ">
@@ -964,7 +970,10 @@
             blog_user_id,
           </if>
           <if test="minaUserId !=null ">
-            mina_user_id
+            mina_user_id,
+          </if>
+          <if test="grade !=null ">
+            grade
           </if>
 
         </trim>
@@ -1035,7 +1044,10 @@
             #{blogUserId, jdbcType=INTEGER},
           </if>
           <if test="minaUserId !=null ">
-            #{minaUserId, jdbcType=INTEGER}
+            #{minaUserId, jdbcType=INTEGER},
+          </if>
+          <if test="grade !=null ">
+            #{grade, jdbcType=VARCHAR}
           </if>
         </trim>
   </insert>

+ 14 - 0
YijiaRestful/src/main/resources/mapper/StationInfoMapper.xml

@@ -472,4 +472,18 @@
     </where>
   </select>
 
+  <!--查询油站小程序AppId和AppSecret-->
+  <select id="getStationAppIdAndAppSecret" parameterType="String" resultType="Map">
+    SELECT
+        app_id          AS appId,
+        app_secret      AS appSecret
+    FROM
+        station_info
+    <where>
+      <if test="stationId !='' and stationId != null" >
+        station_id = #{stationId}
+      </if>
+    </where>
+  </select>
+
 </mapper>