jk-GitHub-coder 4 năm trước cách đây
mục cha
commit
40ecde1c18

+ 9 - 4
YijiaRestful/src/main/java/com/platform/yijia/controller/AppUserInfoController.java

@@ -3,10 +3,7 @@ package com.platform.yijia.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.platform.yijia.param.request.AppUserInfoRequest;
-import com.platform.yijia.pojo.AppUserInfo;
-import com.platform.yijia.pojo.CustomerElectronicCard;
-import com.platform.yijia.pojo.CustomerPoints;
-import com.platform.yijia.pojo.StationPayManage;
+import com.platform.yijia.pojo.*;
 import com.platform.yijia.service.*;
 import com.platform.yijia.utils.CodeMsg;
 import com.platform.yijia.utils.ResultData;
@@ -418,6 +415,14 @@ public class AppUserInfoController {
             customerElectronicCard.setCreateTime(new Date());
             customerElectronicCard.setStationId(request.getStationId());
             customerElectronicCard.setStationName(request.getStationName());
+            StationInfo stationInfo = new StationInfo();
+            stationInfo.setStationId(request.getStationId());
+            //获取油站名称
+            StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
+            if(stationInfos !=null && stationInfos.getStationName() !=null){
+                customerPoints.setStationName(stationInfos.getStationName());
+                customerElectronicCard.setStationName(stationInfos.getStationName());
+            }
 
             if(StringUtils.isNotBlank(request.getSexFlag())){
                 appUserInfo.setSexFlag(request.getSexFlag());

+ 7 - 5
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -658,9 +658,9 @@ public class PayController {
         customerManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));    //油站ID
         customerManage.setOilName(infoMap.get("oilName").toString());    //油品名称
         customerManage.setStationName(infoMap.get("stationName").toString());   //存入油站名称
-        //已存在用户信息 existCustomer
-        CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
-        logger.info("查询出客户是否存在数据 null表示没有" + existCustomer);
+
+        CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);         //已存在用户信息 existCustomer
+        logger.info("查询出客户是否存在数据 null表示没有: " + existCustomer);
 
         //获取该油站的优惠方式
         String discountPlanType = stationService.getStationDiscountWay(infoMap.get("stationId").toString());
@@ -695,7 +695,8 @@ public class PayController {
                 }
                 logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
             }
-            payOrderService.updateCustomer(customerManage); //存在 更新
+            customerManagerService.updateCustomerInfo(customerManage);
+            //payOrderService.updateCustomer(customerManage); //存在 更新
         }else{  //该客户不存在时插入
             if(discountPlanType !=null && discountPlanType.equals("1")){
                 //直降时存入等级名称和等级ID
@@ -712,7 +713,8 @@ public class PayController {
                 customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
             }
             logger.info("不存在客户 新增时参数: " + customerManage.toString());
-            payOrderService.insertCustomer(customerManage);//不存在 新增
+            customerManagerService.insertCustomerInfo(customerManage);
+            //payOrderService.insertCustomer(customerManage);//不存在 新增
         }
         return customerManage;
     }

+ 8 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/CustomerManagerMapper.java

@@ -1,5 +1,7 @@
 package com.platform.yijia.dao;
 
+import com.platform.yijia.param.request.CustomerGrade;
+import com.platform.yijia.pojo.CustomerGroup;
 import com.platform.yijia.pojo.CustomerManage;
 
 public interface CustomerManagerMapper {
@@ -11,4 +13,10 @@ public interface CustomerManagerMapper {
 
     //插入客户信息
     void insertCustomerInfo(CustomerManage customerManage);
+
+    //查询客户集团
+    CustomerGroup selectCustomerGroup(CustomerGroup customerGroup);
+
+    //插入集团客户表
+    void insertCustomerGroup(CustomerGroup customerGroup);
 }

+ 6 - 1
YijiaRestful/src/main/java/com/platform/yijia/dao/SysDeptMapper.java

@@ -1,11 +1,16 @@
 package com.platform.yijia.dao;
 
+import com.platform.yijia.pojo.StationInfo;
 import com.platform.yijia.pojo.SysDept;
 import com.platform.yijia.pojo.SysDeptExample;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
 public interface SysDeptMapper {
+
+    //根据油站ID获取油站所属部门信息
+    SysDept selectDeptInfo(StationInfo stationInfo);
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table sys_dept
@@ -93,4 +98,4 @@ public interface SysDeptMapper {
      * @mbg.generated
      */
     int updateByPrimaryKey(SysDept record);
-}
+}

+ 15 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerGroup.java

@@ -0,0 +1,15 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+/***
+ * 客户集团信息
+ */
+@Data
+public class CustomerGroup {
+    private String customerId;      //客户id
+    private String unionId;         //微信用户唯一标识
+    private String phoneNumber;     //手机号
+    private Integer groupId;        //集团
+
+}

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerManage.java

@@ -38,5 +38,6 @@ public class CustomerManage {
     private BigDecimal liters; //总升数
     private BigDecimal amt; //总金额
     private String unionId; //用户unionId  union_id
+    private Integer groupId;  //所属集团ID,
 
 }

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/SysDeptService.java

@@ -1,9 +1,15 @@
 package com.platform.yijia.service;
 
+import com.platform.yijia.pojo.StationInfo;
 import com.platform.yijia.pojo.SysDept;
 
 import java.util.List;
 
 public interface SysDeptService {
+
+    //根据油站ID获取油站所属部门信息
+    SysDept selectDeptInfo(StationInfo stationInfo);
+
+
     List<SysDept> getDeptList(Long parentId);
 }

+ 7 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/SysDeptServiceImpl.java

@@ -1,6 +1,7 @@
 package com.platform.yijia.service.impl;
 
 import com.platform.yijia.dao.SysDeptMapper;
+import com.platform.yijia.pojo.StationInfo;
 import com.platform.yijia.pojo.SysDept;
 import com.platform.yijia.pojo.SysDeptExample;
 import com.platform.yijia.service.SysDeptService;
@@ -15,6 +16,12 @@ public class SysDeptServiceImpl implements SysDeptService {
     @Resource
     private SysDeptMapper sysDeptMapper;
 
+    //根据油站ID获取油站所属部门信息
+    @Override
+    public SysDept selectDeptInfo(StationInfo stationInfo) {
+        return sysDeptMapper.selectDeptInfo(stationInfo);
+    }
+
     /**
      * 根据parentId查询dept信息
      * @param parentId

+ 77 - 53
YijiaRestful/src/main/resources/mapper/CustomerManagerMapper.xml

@@ -31,18 +31,80 @@
       <result column="liters"                   jdbcType="DECIMAL"      property="liters" />
       <result column="amt"                      jdbcType="DECIMAL"      property="amt" />
       <result column="union_id"                 jdbcType="VARCHAR"      property="unionId" />
+      <result column="group_id"                 jdbcType="INTEGER"      property="groupId" />
   </resultMap>
 
+    <!--集团客户信息返回结果-->
+    <resultMap id="customerGroupBaseResultMap" type="com.platform.yijia.pojo.CustomerGroup">
+        <result column="customer_id"              jdbcType="VARCHAR"      property="customerId" />
+        <result column="union_id"                 jdbcType="VARCHAR"      property="unionId" />
+        <result column="phone_number"             jdbcType="VARCHAR"      property="phoneNumber" />
+        <result column="group_id"                 jdbcType="INTEGER"      property="groupId" />
+    </resultMap>
 
+    <!--查询集团客户列-->
+    <sql id="Base_Column_List_CustomerGroup">
+        customer_id, union_id, phone_number, group_id
+    </sql>
 
-
-    <!--查询列-->
+    <!--查询-->
     <sql id="Base_Column_List">
         id, member_id, customer_name, commend_man, member_grade, phone_number, car_number, balance,
         integral, special_car_type, regtime, station_id, station_name, cy_grade, qy_grade, cy_liters,
         qy_liters, cy_amt, qy_amt, blog_openid, mina_openid, blog_user_id, mina_user_id, oil_name, grade,
-        liters, amt, union_id
-   </sql>
+        liters, amt, union_id, group_id
+    </sql>
+
+    <!--查询集团下客户信息-->
+    <select id="selectCustomerGroup" parameterType="com.platform.yijia.pojo.CustomerGroup" resultMap="customerGroupBaseResultMap">
+        SELECT
+            <include refid="Base_Column_List_CustomerGroup"/>
+        FROM
+            customer_group
+        <where>
+            <if test="unionId !=null and unionId !=''">
+                union_id = #{unionId}
+            </if>
+            <if test="groupId !=null">
+                AND group_id = #{groupId}
+            </if>
+        </where>
+    </select>
+
+    <!--插入集团客户信息-->
+    <insert id="insertCustomerGroup" parameterType="com.platform.yijia.pojo.CustomerGroup">
+        INSERT
+            customer_group
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="customerId !=null">
+                customer_id,
+            </if>
+            <if test="unionId !=null">
+                union_id,
+            </if>
+            <if test="phoneNumber !=null">
+                phone_number,
+            </if>
+            <if test="groupId !=null">
+                group_id,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="customerId !=null">
+                #{customerId},
+            </if>
+            <if test="unionId !=null">
+                #{unionId},
+            </if>
+            <if test="phoneNumber !=null">
+                #{phoneNumber},
+            </if>
+            <if test="groupId !=null">
+                #{groupId},
+            </if>
+        </trim>
+    </insert>
+
 
   <!--查询油站客户信息-->
   <select id="getCustomerManageInfo" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.CustomerManage">
@@ -101,6 +163,9 @@
             <if test="grade !=null ">
                 grade = #{grade},
             </if>
+            <if test="groupId !=null ">
+                group_id = #{groupId},
+            </if>
         </set>
         <where>
             <if test="stationId != null and stationId !='' ">
@@ -191,9 +256,11 @@
                 grade,
             </if>
             <if test="unionId !=null and unionId !=''">
-                union_id
+                union_id,
+            </if>
+            <if test="groupId !=null and groupId !=''">
+                group_id
             </if>
-
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
 
@@ -268,55 +335,12 @@
                 #{grade, jdbcType=VARCHAR},
             </if>
             <if test="unionId !=null and unionId !=''">
-                #{unionId, jdbcType=VARCHAR}
+                #{unionId, jdbcType=VARCHAR},
+            </if>
+            <if test="groupId !=null and groupId !=''">
+                #{groupId, jdbcType=INTEGER}
             </if>
         </trim>
     </insert>
 
-    <!-- 根据手机号更新客户表 -->
-    <update id="updateCustomerInfoByPhoneNumber" parameterType="com.platform.yijia.pojo.CustomerManage">
-        UPDATE
-        customer_manage
-        <set>
-            <if test="customerName !=null ">
-                customer_name = #{customerName},
-            </if>
-            <if test="phoneNumber !=null ">
-                phone_number = #{phoneNumber},
-            </if>
-            <if test="regtime !=null ">
-                regtime = #{regtime},
-            </if>
-            <if test="stationName !=null ">
-                station_name = #{stationName},
-            </if>
-            <if test="stationId !=null ">
-                station_id = #{stationId},
-            </if>
-            <if test="blogUserId !=null ">
-                blog_user_id = #{blogUserId},
-            </if>
-            <if test="minaUserId !=null ">
-                mina_user_id = #{minaUserId},
-            </if>
-            <if test="oilName !=null ">
-                oil_name = #{oilName},
-            </if>
-            <if test="liters !=null ">
-                liters = #{liters},
-            </if>
-            <if test="amt !=null ">
-                amt = #{amt},
-            </if>
-            <if test="unionId !=null and unionId !=null">
-                union_id = #{unionId},
-            </if>
-        </set>
-        <where>
-            <if test="phoneNumber !=null and phoneNumber !='' ">
-                phone_number = #{phoneNumber}
-            </if>
-        </where>
-    </update>
-
 </mapper>

+ 6 - 4
YijiaRestful/src/main/resources/mapper/PayOrderMapper.xml

@@ -844,7 +844,6 @@
     SELECT
         A.order_no				AS orderNo,
         A.consumer              AS consumer,
-        A.station_name 			AS stationName,
         A.station_id		    AS stationId,
         A.status 				AS status,
         A.pay_way				AS payWay,
@@ -864,10 +863,13 @@
         B.blog_openid           AS blogOpenid,
         B.mina_openid           AS minaOpenid,
         B.union_id              AS unionId,
-        B.mobile_phone			AS mobilePhone
+        B.mobile_phone			AS mobilePhone,
+        C.dept_name 			AS stationName,
+        C.parent_id             AS groupId
     FROM
-         pay_order              AS A
-    LEFT JOIN app_user_info     AS B ON A.consumer_id = B.user_id
+                pay_order       AS A
+    LEFT JOIN   app_user_info   AS B ON A.consumer_id = B.user_id
+    LEFT JOIN   sys_dept        AS C ON A.station_id = C.dept_id
     WHERE
         A.order_no = #{orderNo}
   </select>

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

@@ -26,6 +26,8 @@
     -->
     <result column="station_pic" jdbcType="LONGVARBINARY" property="stationPic" />
   </resultMap>
+
+
   <!--获取油站信息-->
   <select id="selectStationInfo" parameterType="com.platform.yijia.pojo.StationInfo" resultMap="BaseResultMap">
     SELECT

+ 22 - 11
YijiaRestful/src/main/resources/mapper/SysDeptMapper.xml

@@ -21,6 +21,17 @@
     <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
+
+  <!--根据油站ID获取油站所属部门信息-->
+  <select id="selectDeptInfo" parameterType="com.platform.yijia.pojo.StationInfo" resultMap="BaseResultMap">
+        SELECT
+            <include refid="Base_Column_List"/>
+        FROM
+            sys_dept
+        WHERE
+            dept_id =(SELECT parent_id FROM sys_dept WHERE dept_id =#{stationId})
+  </select>
+
   <sql id="Example_Where_Clause">
     <!--
       WARNING - @mbg.generated
@@ -92,7 +103,7 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    dept_id, parent_id, ancestors, dept_name, order_num, leader, phone, email, status, 
+    dept_id, parent_id, ancestors, dept_name, order_num, leader, phone, email, status,
     del_flag, create_by, create_time, update_by, update_time
   </sql>
   <select id="selectByExample" parameterType="com.platform.yijia.pojo.SysDeptExample" resultMap="BaseResultMap">
@@ -118,7 +129,7 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    select 
+    select
     <include refid="Base_Column_List" />
     from sys_dept
     where dept_id = #{deptId,jdbcType=BIGINT}
@@ -146,15 +157,15 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    insert into sys_dept (dept_id, parent_id, ancestors, 
-      dept_name, order_num, leader, 
-      phone, email, status, 
-      del_flag, create_by, create_time, 
+    insert into sys_dept (dept_id, parent_id, ancestors,
+      dept_name, order_num, leader,
+      phone, email, status,
+      del_flag, create_by, create_time,
       update_by, update_time)
-    values (#{deptId,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, #{ancestors,jdbcType=VARCHAR}, 
-      #{deptName,jdbcType=VARCHAR}, #{orderNum,jdbcType=INTEGER}, #{leader,jdbcType=VARCHAR}, 
-      #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, 
-      #{delFlag,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+    values (#{deptId,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, #{ancestors,jdbcType=VARCHAR},
+      #{deptName,jdbcType=VARCHAR}, #{orderNum,jdbcType=INTEGER}, #{leader,jdbcType=VARCHAR},
+      #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{status,jdbcType=CHAR},
+      #{delFlag,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
       #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.platform.yijia.pojo.SysDept">
@@ -410,4 +421,4 @@
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where dept_id = #{deptId,jdbcType=BIGINT}
   </update>
-</mapper>
+</mapper>