Procházet zdrojové kódy

修改电子卡和合并用户信息逻辑

jk-GitHub-coder před 4 roky
rodič
revize
b46a437bef

+ 33 - 94
YijiaRestful/src/main/java/com/platform/yijia/controller/AppUserInfoController.java

@@ -485,100 +485,39 @@ public class AppUserInfoController {
             }
 
             if(request.getUserType()!=null){
-//                String userType = request.getUserType();
-//                appUserInfo.setUserType(userType);
-//                switch (userType){
-//                    case "1":   //1-微信公众号
-//                        appUserInfo.setBlogOpenid(request.getOpenId());
-//                        appUserInfo.setUnionId(request.getUnionId());
-//                        AppUserInfo a = new AppUserInfo();
-//                        a.setUnionId(request.getUnionId());
-//                        a.setUserType("2");
-//                        a.setStationId(request.getStationId());
-//                        List<AppUserInfo> userInfo = appUserInfoService.getUserInfo(a);
-//                        if(userInfo !=null && userInfo.size() ==1){
-//                            //如果有说明存在小程序用户信息,则将公众号的用户信息更新到小程序信息上,且删除公众号信息;
-//                            appUserInfo.setUserType("2");
-//                            appUserInfoService.updateAppUserInfo(appUserInfo);
-//                            AppUserInfo b = new AppUserInfo();
-//                            b.setUnionId(request.getUnionId());
-//                            b.setStationId(request.getStationId());
-//                            b.setUserType("1");
-//                            //删除公众号信息
-//                            //appUserInfoService.delUserInfo(b);
-//                        }else {
-//                            //如果没有小程序用户信息,则插入公众号信息
-//                            appUserInfo.setUserType("1");
-//                            appUserInfoService.AddAppUserInfo(appUserInfo);
-//                        }
-//
-//                        break;
-//                    case "2":   //2-微信小程序
-//                        appUserInfo.setMinaOpenid(request.getOpenId());
-//                        appUserInfo.setUnionId(request.getUnionId());
-//                        appUserInfo.setMobilePhone(request.getMobilePhone());
-
-
-
-//                        AppUserInfo b = new AppUserInfo();
-//                        b.setStationId(request.getStationId());
-//                        b.setUnionId(request.getUnionId());
-//                        b.setUserType("2");
-//                        List<AppUserInfo> userInfo1 = appUserInfoService.getUserInfo(b);
-//                        if(userInfo1 !=null && userInfo1.size() ==1){
-//                            //则说明存在小程序用户信息
-//                            //appUserInfoService.updateAppUserInfo(appUserInfo);
-//                            AppUserInfo c = new AppUserInfo();
-//                            c.setStationId(request.getStationId());
-//                            c.setUserType("3");
-//                            c.setMobilePhone(request.getMobilePhone());
-//                            //查看当前数据库是否已存在支付宝小程序用户信息
-//                            AppUserInfo appUserInfo1 = appUserInfoService.selectAppUserInfoByMobilePhoneAndStationId(c);
-//                            if(appUserInfo1 !=null){
-//                                appUserInfoService.updateAppUserInfo(appUserInfo);
-//                            }else {
-//                                appUserInfoService.updateAppUserInfo(appUserInfo);
-//                            }
-//                        }else {
-//                            appUserInfoService.AddAppUserInfo(appUserInfo);
-//                        }
-//                        break;
-//                    case "3":   //3-支付宝公众号
-//                        appUserInfo.setALiId(request.getOpenId());
-//                        AppUserInfo d = new AppUserInfo();
-//                        d.setStationId(request.getStationId());
-//                        d.setALiId(request.getOpenId());
-//                        d.setUserType("4");
-//                        AppUserInfo appUserInfo1 = appUserInfoService.getAppUserInfo(d);
-//                        if(appUserInfo1 !=null){
-//                            appUserInfoService.updateAppUserInfo(appUserInfo);
-//                        }else {
-//                            appUserInfoService.AddAppUserInfo(appUserInfo);
-//                        }
-//                        break;
-//                    case "4":   //4-支付宝小程序
-//                        appUserInfo.setALiId(request.getOpenId());
-//                        appUserInfo.setMobilePhone(request.getMobilePhone());
-//                        AppUserInfo u = new AppUserInfo();
-//                        //u.setMobilePhone(request.getMobilePhone());
-//                        u.setALiId(request.getOpenId());
-//                        u.setStationId(request.getStationId());
-//                        AppUserInfo appUserInfo3 = appUserInfoService.getAppUserInfo(u);
-//                        if(appUserInfo3 !=null){
-//                            appUserInfoService.updateAppUserInfo(appUserInfo);
-//                        }else {
-//                            AppUserInfo f = new AppUserInfo();
-//                            f.setMobilePhone(request.getMobilePhone());
-//                            f.setStationId(request.getStationId());
-//                            AppUserInfo appUserInfo2 = appUserInfoService.selectAppUserInfoByMobilePhoneAndStationId(f);
-//                            if(appUserInfo2 !=null){
-//                                appUserInfoService.updateAppUserInfo(appUserInfo);
-//                            }else {
-//                                appUserInfoService.AddAppUserInfo(appUserInfo);
-//                            }
-//                        }
-//                        break;
-//                }
+                String userType = request.getUserType();
+                appUserInfo.setUserType(userType);
+                switch (userType){
+                    case "1":
+                        AppUserInfo wxInfo = new AppUserInfo();
+                        wxInfo.setUnionId(request.getUnionId());
+                        wxInfo.setStationId(request.getStationId());
+                        AppUserInfo wxInfoResult = appUserInfoService.getAppUserInfo(wxInfo);
+                        if(wxInfoResult !=null){
+                            //如果存在微信用户
+                            appUserInfoService.updateAppUserInfo(appUserInfo);
+                        }else {
+                            //如果不存在微信用户
+                            appUserInfoService.AddAppUserInfo(appUserInfo);
+                        }
+                        break;
+                    case "2":
+                        AppUserInfo aLiInfo  =new AppUserInfo();
+                        aLiInfo.setStationId(request.getStationId());
+                        aLiInfo.setALiId(request.getUnionId());
+                        AppUserInfo aLiInfoResult = appUserInfoService.getAppUserInfo(aLiInfo);
+                        if(aLiInfoResult !=null){
+                            //如果存在支付宝用户信息
+                            appUserInfo.setALiId(request.getALiId());
+                            appUserInfoService.updateAppUserInfo(appUserInfo);
+
+                        }else {
+                            appUserInfo.setALiId(request.getALiId());
+                            appUserInfoService.AddAppUserInfo(appUserInfo);
+                        }
+                        break;
+                }
+
 
                 //1-微信公众号
                 if(request.getUserType().equals("1") &&StringUtils.isNotBlank(request.getOpenId())){

+ 62 - 42
YijiaRestful/src/main/java/com/platform/yijia/controller/ElectronicMembershipCardController.java

@@ -61,6 +61,8 @@ public class ElectronicMembershipCardController {
     private StationOilGunService stationOilGunService;
     @Resource
     private SysDictDataService sysDictDataService;
+    @Resource
+    private AppUserInfoService appUserInfoService;
     @Value("${yijia.path.global-prefix}")
     private String globalPrefix;
 
@@ -93,48 +95,66 @@ public class ElectronicMembershipCardController {
             stationInfo.setStationId(stationId);
             StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
             if(stationInfos.getCardEnabledFlag().equals("1")){
-                //1.获取当前油站所开启的电子卡种类
-                CustomerCardSetting customerCardSetting = new CustomerCardSetting();
-                customerCardSetting.setStationId(stationId);
-                if(stationInfos.getCardRuleFlag().equals("1")){
-                    //集团下油站共享充值规则
-                    customerCardSetting.setStationId(stationInfos.getGroupId());
-                }
-                List<CustomerCardSetting> cardRechargeSettingList = electronicMembershipCardService.getCardRechargeSettingList(customerCardSetting);
-                if(cardRechargeSettingList !=null && cardRechargeSettingList.size() >0){
-                    //2.获取油站开卡的种类
-                    String cardOilsType = cardRechargeSettingList.get(0).getCardOilsType();
-                    String[] cardOilsTypeArray = cardOilsType.split(",");
-
-                    //2.1查询客户现已拥有的电子卡
-                    CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard();
-                    customerElectronicCard.setStationId(customerCardSetting.getStationId());
-                    customerElectronicCard.setUnionId(unionId);
-                    String[] cardTypesArray = {};
-                    List<String> hasCard = Arrays.asList(cardTypesArray);
-                    List<CustomerElectronicCard> electronicCardList = electronicMembershipCardService.getElectronicCardList(customerElectronicCard);
-                    for(CustomerElectronicCard c : electronicCardList){
-                        hasCard.add(c.getCardOilsType());
-                    }
-                    List<String> cardOilsTypeArrayList = Arrays.asList(cardOilsTypeArray);
-                    //2.2获取客户要新增的电子卡
-                    for (int i=0; i<cardOilsTypeArrayList.size(); i++){
-                        for (int y=0; y< hasCard.size(); y++){
-                            if(cardOilsTypeArrayList.get(i).equals(hasCard.get(y))){
-                                cardOilsTypeArrayList.remove(i);
-                            }
-                        }
-                    }
-                    //3.依次生成该用户的电子卡
-                    System.out.println(cardOilsTypeArrayList);
-                    List<CustomerElectronicCard> listParam = new ArrayList<>();
-                    for(int i =0; i<cardOilsTypeArrayList.size(); i++){
-                        CustomerElectronicCard c = new CustomerElectronicCard();
-                        listParam.add(c);
-                    }
-                    //3.1批量插入
-
-                }
+//                //1.获取当前油站所开启的电子卡种类
+//                CustomerCardSetting customerCardSetting = new CustomerCardSetting();
+//                customerCardSetting.setStationId(stationId);
+//                if(stationInfos.getCardRuleFlag().equals("1")){
+//                    //集团下油站共享充值规则
+//                    customerCardSetting.setStationId(stationInfos.getGroupId());
+//                }
+//                List<CustomerCardSetting> cardRechargeSettingList = electronicMembershipCardService.getCardRechargeSettingList(customerCardSetting);
+//                if(cardRechargeSettingList !=null && cardRechargeSettingList.size() >0){
+//                    //2.获取油站开卡的种类
+//                    String cardOilsType = cardRechargeSettingList.get(0).getCardOilsType();
+//                    String[] cardOilsTypeArray = cardOilsType.split(",");
+//
+//                    //2.1查询客户现已拥有的电子卡
+//                    CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard();
+//                    customerElectronicCard.setStationId(customerCardSetting.getStationId());
+//                    customerElectronicCard.setUnionId(unionId);
+//                    String[] cardTypesArray = {};
+//                    List<String> hasCard = Arrays.asList(cardTypesArray);
+//                    List<CustomerElectronicCard> electronicCardList = electronicMembershipCardService.getElectronicCardList(customerElectronicCard);
+//                    for(CustomerElectronicCard c : electronicCardList){
+//                        hasCard.add(c.getCardOilsType());
+//                    }
+//                    List<String> cardOilsTypeArrayList = Arrays.asList(cardOilsTypeArray);
+//                    //2.2获取客户要新增的电子卡
+//                    for (int i=0; i<cardOilsTypeArrayList.size(); i++){
+//                        for (int y=0; y< hasCard.size(); y++){
+//                            if(cardOilsTypeArrayList.get(i).equals(hasCard.get(y))){
+//                                cardOilsTypeArrayList.remove(i);
+//                            }
+//                        }
+//                    }
+//                    //3.依次生成该用户的电子卡
+//                    System.out.println(cardOilsTypeArrayList);
+//                    AppUserInfo appUserInfo = new AppUserInfo();
+//                    appUserInfo.setStationId(stationId);
+//                    appUserInfo.setUnionId(unionId);
+//
+//                    List<AppUserInfo> userInfo = appUserInfoService.getUserInfo(appUserInfo);
+//                    if(userInfo !=null  ){
+//
+//                    }
+//                    List<CustomerElectronicCard> listParam = new ArrayList<>();
+//                    for(int i =0; i<cardOilsTypeArrayList.size(); i++){
+//                        CustomerElectronicCard c = new CustomerElectronicCard();
+//                        c.setStationId(stationId);
+//                        c.setUnionId(unionId);
+//                        c.setCreateTime(new Date());
+//                        c.setAmt(new BigDecimal(0));
+//                        c.setCardOilsType(cardOilsTypeArrayList.get(i));
+//                        //c.setBlogOpenid();
+//                        //c.setCustomerNo();
+//                        //c.setMobilePhone();
+//                        //c.setMinaOpenid();
+//                        listParam.add(c);
+//                    }
+//                    //3.1批量插入
+//
+//
+//                }
 
 
                 CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard();

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/param/request/AppUserInfoRequest.java

@@ -25,5 +25,6 @@ public class AppUserInfoRequest {
     private String unionId;          //微信用户unionId
     private Integer stationId;          //油站Id
     private String stationName;          //油站名称
+    private String aLiId;               //支付宝ID
 
 }

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

@@ -32,7 +32,7 @@
             oil_name                    AS oilName
         FROM markert_plan
         <where>
-            status ="1"
+            status ="0"
             <if test="stationId != null and stationId != ''">
                 AND station_id = #{stationId}
             </if>
@@ -60,7 +60,7 @@
     <where>
         del_flag ="0"
       <if test="stationId != null and stationId != ''">
-          station_id = #{stationId}
+          AND station_id = #{stationId}
       </if>
       <if test="oilName != null and oilName != ''">
         AND oil_name = #{oilName}
@@ -106,8 +106,9 @@
         LEFT JOIN customer_manage 			AS T2   ON T1.mobile_phone = T2.phone_number
         LEFT JOIN customer_grade_setting 	AS T3   ON T2.station_id = T3.station_id AND T2.oil_name = T3.oil_name AND T3.id = T2.member_grade
         <where>
+                T3.del_flag ="0"
             <if test="mobilePhone != null and mobilePhone !=''">
-                T1.mobile_phone = #{mobilePhone}
+                AND T1.mobile_phone = #{mobilePhone}
             </if>
             <if test="userType != null and userType !=''">
                 AND T1.user_type = #{userType}

+ 2 - 1
YijiaRestful/src/main/resources/mapper/ElectronicMembershipCardMapper.xml

@@ -96,8 +96,9 @@
         FROM
             customer_card_setting AS T1 LEFT JOIN customer_card_setting_detail AS T2 ON T1.id = T2.parent_id
         <where>
+                T2.del_flag ="0"
             <if test="stationId !=null">
-                T1.station_id = #{stationId}
+                AND T1.station_id = #{stationId}
             </if>
             <if test="cardOilsType !=null">
                 AND FIND_IN_SET(#{cardOilsType}, T1.card_oils_type)