jk-GitHub-coder há 4 anos atrás
pai
commit
eb0495a7b8

+ 64 - 3
YijiaRestful/src/main/java/com/platform/yijia/controller/PayOrderController.java

@@ -46,6 +46,10 @@ public class PayOrderController {
     private CustomerPointsService customerPointsService;
     @Resource
     private CustomerPointsRecordService customerPointsRecordService;
+    @Resource
+    private GzhNewsTemplateService gzhNewsTemplateService;
+    @Resource
+    private CustomerManagerService customerManagerService;
 
     //一键支付,生成订单
     @RequestMapping(value = "/AddPayOrderInfo", consumes = "application/json", method = RequestMethod.POST)
@@ -271,6 +275,56 @@ public class PayOrderController {
                     electronicMembershipCardService.updateElectronicCardInfoByUnionId(c);
                     payOrder.setStatus("1");
                     payOrderMapper.insertSelective(payOrder);
+                    //更新客户表
+                    CustomerManage customerManage = new CustomerManage();
+                    customerManage.setStationId(payOrderRequest.getStationId());
+                    customerManage.setMinaOpenid(payOrderRequest.getOpenId());
+                    customerManage.setOilName(payOrderRequest.getOilName());
+                    Map<String, Object> params_1 = new HashMap<>();
+                    params_1.put("stationId", payOrderRequest.getStationId().toString());
+                    params_1.put("oilName", payOrderRequest.getOilName());
+                    //获取该油站的优惠方式
+                    String discountPlanType = stationService.getStationDiscountWay(payOrderRequest.getStationId().toString());
+                    logger.info("油站优惠方式:"+discountPlanType);
+                    CustomerManage customerManageInfo = customerManagerService.getCustomerManageInfo(customerManage);
+                    if(customerManageInfo !=null){
+                        customerManage.setPhoneNumber(appUserInfoList.get(0).getMobilePhone());
+                        customerManage.setAmt(customerManageInfo.getAmt().add(new BigDecimal(resultMap.get("amt").toString())));
+                        customerManage.setLiters(customerManageInfo.getLiters().add(new BigDecimal(resultMap.get("oilLiters").toString())));
+                        if(discountPlanType !=null && discountPlanType.equals("1")){
+                            List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(params_1);  //直降
+                            logger.info("该站直降等级信息:"+ customerGradeInfo);
+                            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
+                                    break;
+                                }
+                            }
+                            logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
+                        }
+                        customerManagerService.updateCustomerInfo(customerManage);
+                    }else {
+                        customerManage.setCommendMan(payOrder.getConsumer());
+                        customerManage.setStationName(payOrder.getStationName());
+                        customerManage.setLiters(new BigDecimal(resultMap.get("oilLiters").toString()));
+                        customerManage.setAmt(new BigDecimal(resultMap.get("amt").toString()));
+                        customerManage.setPhoneNumber(appUserInfoList.get(0).getMobilePhone());
+                        customerManage.setMinaUserId(appUserInfoList.get(0).getUserId());
+                        customerManage.setUnionId(appUserInfoList.get(0).getUnionId());
+                        if(discountPlanType !=null && discountPlanType.equals("1")){
+                            List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(params_1);  //直降
+                            logger.info("该站直降等级信息:"+ customerGradeInfo);
+                            if(customerGradeInfo !=null && customerGradeInfo.size() >0){
+                                customerManage.setGrade(customerGradeInfo.get(0).get("grade").toString());     //存入等级名称
+                                customerManage.setMemberGrade(customerGradeInfo.get(0).get("id").toString());     //存入等级ID
+                            }
+                            logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
+                        }
+                        customerManagerService.insertCustomerInfo(customerManage);
+                    }
+
+
                     //计算积分
                     CalculateIntegral calculateIntegral = new CalculateIntegral();
                     calculateIntegral.setAmt(new BigDecimal(payOrder.getAmt()));
@@ -281,7 +335,7 @@ public class PayOrderController {
                     calculateIntegral.setStationId(payOrder.getStationId());
                     calculateIntegral.setOpenId(payOrderRequest.getOpenId());   //小程序openId
                     //计算积分且推送积分
-                    CustomerManage customerManage = new CustomerManage();
+                    //CustomerManage customerManage = new CustomerManage();
                     this.calculateIntegralAndPushIntegral(calculateIntegral, customerManage);
                     resultMap.put("ordNo", ordNo);
                     resultData = ResultData.success(resultMap);
@@ -763,8 +817,15 @@ public class PayOrderController {
                     wxMpTemplate.add(new WxMpTemplateData("From", stationName));
                     wxMpTemplate.add(new WxMpTemplateData("remark",
                             "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+surplusIntegral.toString()+" 分"));
-                    String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板
-                    wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, blogOpenId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo
+                    //String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板
+                    //wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, blogOpenId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo
+                    GzhNewsTemplate gzhNewsTemplate = new GzhNewsTemplate();
+                    gzhNewsTemplate.setStationId(stationId);
+                    gzhNewsTemplate.setTemplateType("1");
+                    GzhNewsTemplate gzhNewsTemplateInfo = gzhNewsTemplateService.getGzhNewsTemplate(gzhNewsTemplate);
+                    if(gzhNewsTemplateInfo !=null && gzhNewsTemplateInfo.getTemplateId() !=null){
+                        wxPushUtil.push(gzhAppId, gzhAppSecret, gzhNewsTemplateInfo.getTemplateId(), blogOpenId, wxMpTemplate);
+                    }
                 }
 
             }

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

@@ -114,5 +114,5 @@ public interface AppUserInfoMapper {
     void updateAppUserInfo(AppUserInfo appUserInfo);
 
     //查询客户UnionId
-    String getUserUnionId(AppUserInfo appUserInfo);
+    AppUserInfo getUserInfo(AppUserInfo appUserInfo);
 }

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

@@ -0,0 +1,14 @@
+package com.platform.yijia.dao;
+
+import com.platform.yijia.pojo.CustomerManage;
+
+public interface CustomerManagerMapper {
+    //查询油站客户信息
+    CustomerManage getCustomerManageInfo(CustomerManage customerManage);
+
+    //更新客户信息
+    void updateCustomerInfo(CustomerManage customerManage);
+
+    //插入客户信息
+    void insertCustomerInfo(CustomerManage customerManage);
+}

+ 1 - 1
YijiaRestful/src/main/java/com/platform/yijia/service/AppUserInfoService.java

@@ -23,7 +23,7 @@ public interface AppUserInfoService {
     void updateAppUserInfo(AppUserInfo appUserInfo);
 
     //查询客户UnionId
-    String getUserUnionId(AppUserInfo appUserInfo);
+    AppUserInfo getUserInfo(AppUserInfo appUserInfo);
 
     /**
      * 判断使用小程序支付的用户是否关注公众号

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

@@ -0,0 +1,20 @@
+package com.platform.yijia.service;
+
+
+import com.platform.yijia.pojo.CustomerManage;
+import com.platform.yijia.pojo.IntegralRule;
+
+import java.util.List;
+
+public interface CustomerManagerService {
+
+    //查询油站客户信息
+    CustomerManage getCustomerManageInfo(CustomerManage customerManage);
+
+    //更新客户信息
+    void updateCustomerInfo(CustomerManage customerManage);
+
+    //插入客户信息
+    void insertCustomerInfo(CustomerManage customerManage);
+
+}

+ 3 - 2
YijiaRestful/src/main/java/com/platform/yijia/service/impl/AppUserInfoServiceImpl.java

@@ -78,9 +78,10 @@ public class AppUserInfoServiceImpl implements AppUserInfoService {
         appUserInfoMapper.updateAppUserInfo(appUserInfo);
     }
 
+    //获取用户信息
     @Override
-    public String getUserUnionId(AppUserInfo appUserInfo) {
-        return appUserInfoMapper.getUserUnionId(appUserInfo);
+    public AppUserInfo getUserInfo(AppUserInfo appUserInfo) {
+        return appUserInfoMapper.getUserInfo(appUserInfo);
     }
 
 

+ 31 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/CustomerManagerServiceImpl.java

@@ -0,0 +1,31 @@
+package com.platform.yijia.service.impl;
+
+import com.platform.yijia.pojo.CustomerManage;
+import com.platform.yijia.service.CustomerManagerService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service("customerManagerService")
+public class CustomerManagerServiceImpl implements CustomerManagerService {
+    @Resource
+    private CustomerManagerService customerManagerService;
+
+    //更新客户信息
+    @Override
+    public void updateCustomerInfo(CustomerManage customerManage) {
+        customerManagerService.updateCustomerInfo(customerManage);
+    }
+
+    //插入客户信息
+    @Override
+    public void insertCustomerInfo(CustomerManage customerManage) {
+        customerManagerService.insertCustomerInfo(customerManage);
+    }
+
+    //获取客户信息
+    @Override
+    public CustomerManage getCustomerManageInfo(CustomerManage customerManage) {
+        return customerManagerService.getCustomerManageInfo(customerManage);
+    }
+}

+ 3 - 3
YijiaRestful/src/main/resources/mapper/AppUserInfoMapper.xml

@@ -416,10 +416,10 @@
 
 
   <!--查询客户unionId-->
-  <select id="getUserUnionId" parameterType="com.platform.yijia.pojo.AppUserInfo" resultType="String">
+  <select id="getUserInfo" parameterType="com.platform.yijia.pojo.AppUserInfo" resultMap="BaseResultMap">
     SELECT
-        union_id AS unionId
-    from app_user_info
+        <include refid="Base_Column_List" />
+    FROM app_user_info
     <where>
       <if test="userType !=null and userType !=''">
         user_type = #{userType}

+ 338 - 0
YijiaRestful/src/main/resources/mapper/CustomerManagerMapper.xml

@@ -0,0 +1,338 @@
+<?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.CustomerManageMapper">
+  <!--客户信息返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.CustomerManage">
+      <id     column="id"                       jdbcType="INTEGER"      property="id" />
+      <result column="member_id"                jdbcType="VARCHAR"      property="memberId" />
+      <result column="customer_name"            jdbcType="VARCHAR"      property="customerName" />
+      <result column="commend_man"              jdbcType="VARCHAR"      property="commendMan" />
+      <result column="member_grade"             jdbcType="VARCHAR"      property="memberGrade" />
+      <result column="phone_number"             jdbcType="VARCHAR"      property="phoneNumber" />
+      <result column="car_number"               jdbcType="VARCHAR"      property="carNumber" />
+      <result column="balance"                  jdbcType="DECIMAL"      property="balance" />
+      <result column="integral"                 jdbcType="INTEGER"      property="integral" />
+      <result column="special_car_type"         jdbcType="VARCHAR"      property="specialCarType" />
+      <result column="regtime"                  jdbcType="TIMESTAMP"    property="regtime" />
+      <result column="station_id"               jdbcType="INTEGER"      property="stationId" />
+      <result column="station_name"             jdbcType="VARCHAR"      property="stationName"/>
+      <result column="cy_grade"                 jdbcType="VARCHAR"      property="cyGrade" />
+      <result column="qy_grade"                 jdbcType="VARCHAR"      property="qyGrade" />
+      <result column="cy_liters"                jdbcType="DECIMAL"      property="cyLiters"/>
+      <result column="qy_liters"                jdbcType="DECIMAL"      property="qyLiters" />
+      <result column="cy_amt"                   jdbcType="DECIMAL"      property="cyAmt" />
+      <result column="qy_amt"                   jdbcType="DECIMAL"      property="qyAmt" />
+      <result column="blog_openid"              jdbcType="VARCHAR"      property="blogOpenid" />
+      <result column="mina_openid"              jdbcType="VARCHAR"      property="minaOpenid" />
+      <result column="blog_user_id"             jdbcType="INTEGER"      property="blogUserId" />
+      <result column="mina_user_id"             jdbcType="INTEGER"      property="minaUserId"/>
+      <result column="oil_name"                 jdbcType="VARCHAR"      property="oilName" />
+      <result column="grade"                    jdbcType="VARCHAR"      property="grade" />
+      <result column="liters"                   jdbcType="DECIMAL"      property="liters" />
+      <result column="amt"                      jdbcType="DECIMAL"      property="amt" />
+      <result column="union_id"                 jdbcType="VARCHAR"      property="unionId" />
+  </resultMap>
+
+
+
+
+    <!--查询列-->
+    <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>
+
+  <!--查询油站客户信息-->
+  <select id="getCustomerManageInfo" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.CustomerManage">
+    SELECT
+      <include refid="Base_Column_List" />
+    FROM
+        customer_manage
+    <where>
+          <if test="stationId !=null and stationId !=''">
+             station_id = #{stationId}
+          </if>
+          <if test="oilName !=null and oilName !=''">
+            AND oil_name = #{oilName}
+          </if>
+          <if test="minaOpenid !=null and minaOpenid !=''">
+            AND mina_openid = #{minaOpenid}
+          </if>
+          <if test="unionId !=null and unionId !=''">
+            AND union_id = #{unionId}
+          </if>
+    </where>
+  </select>
+
+    <!-- 判断客户表是否已存在-->
+    <select id="isExistCustomerInfo" parameterType="com.platform.yijia.pojo.CustomerManage" resultType="com.platform.yijia.pojo.CustomerManage">
+        SELECT
+            <include refid="Base_Column_List" />
+        FROM
+            customer_manage
+        <where>
+            <if test="phoneNumber !=null and phoneNumber !='' ">
+                phone_number = #{phoneNumber}
+            </if>
+            <if test="stationId !=null and stationId !='' ">
+                AND station_id = #{stationId}
+            </if>
+            <if test="oilName !=null and oilName !='' ">
+                AND oil_name = #{oilName}
+            </if>
+        </where>
+    </select>
+
+    <!-- 更新客户表 -->
+    <update id="updateCustomerInfo" parameterType="com.platform.yijia.pojo.CustomerManage">
+        UPDATE
+        customer_manage
+        <set>
+            <if test="memberGrade !=null ">
+                member_grade = #{memberGrade},
+            </if>
+            <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="oilName !=null ">
+                oil_name = #{oilName},
+            </if>
+            <if test="liters !=null ">
+                liters = #{liters},
+            </if>
+            <if test="amt !=null ">
+                amt = #{amt},
+            </if>
+            <if test="grade !=null ">
+                grade = #{grade},
+            </if>
+        </set>
+        <where>
+            <if test="stationId != null and stationId !='' ">
+                station_id = #{stationId}
+            </if>
+            <if test="phoneNumber !=null and phoneNumber !='' ">
+                AND phone_number = #{phoneNumber}
+            </if>
+            <if test="oilName !=null and oilName !='' ">
+                AND oil_name = #{oilName}
+            </if>
+        </where>
+    </update>
+
+    <!-- 插入客户表 -->
+    <insert id="insertCustomerInfo" parameterType="com.platform.yijia.pojo.CustomerManage">
+        INSERT INTO customer_manage
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="memberId !=null ">
+                member_id,
+            </if>
+            <if test="customerName !=null ">
+                customer_name,
+            </if>
+            <if test="commendMan !=null ">
+                commend_man,
+            </if>
+            <if test="memberGrade !=null ">
+                member_grade,
+            </if>
+            <if test="phoneNumber !=null ">
+                phone_number,
+            </if>
+
+            <if test="carNumber !=null ">
+                car_number,
+            </if>
+            <if test="balance !=null ">
+                balance,
+            </if>
+            <if test="integral !=null ">
+                integral,
+            </if>
+            <if test="specialCarType !=null ">
+                specialCarType,
+            </if>
+
+            <if test="regtime !=null ">
+                regtime,
+            </if>
+            <if test="stationId !=null ">
+                station_id,
+            </if>
+            <if test="stationName !=null ">
+                station_name,
+            </if>
+
+            <if test="oilName !=null ">
+                oil_name,
+            </if>
+            <if test="liters !=null ">
+                liters,
+            </if>
+            <if test="amt !=null ">
+                amt,
+            </if>
+
+            <if test="cyGrade !=null ">
+                cy_grade,
+            </if>
+            <if test="qyGrade !=null ">
+                qy_grade,
+            </if>
+
+            <if test="blogOpenid !=null ">
+                blog_openid,
+            </if>
+            <if test="minaOpenid !=null ">
+                mina_openid,
+            </if>
+            <if test="blogUserId !=null ">
+                blog_user_id,
+            </if>
+            <if test="minaUserId !=null ">
+                mina_user_id,
+            </if>
+            <if test="grade !=null ">
+                grade,
+            </if>
+            <if test="unionId !=null and unionId !=''">
+                union_id
+            </if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+
+            <if test="memberId !=null ">
+                #{memberId},
+            </if>
+            <if test="customerName !=null ">
+                #{customerName},
+            </if>
+            <if test="commendMan !=null ">
+                #{commendMan},
+            </if>
+            <if test="memberGrade !=null ">
+                #{memberGrade},
+            </if>
+            <if test="phoneNumber !=null ">
+                #{phoneNumber},
+            </if>
+            <if test="carNumber !=null ">
+                #{carNumber},
+            </if>
+            <if test="balance !=null ">
+                #{balance},
+            </if>
+            <if test="integral !=null ">
+                #{integral},
+            </if>
+            <if test="specialCarType !=null ">
+                #{specialCarType},
+            </if>
+
+            <if test="regtime !=null ">
+                #{regtime},
+            </if>
+            <if test="stationId !=null ">
+                #{stationId, jdbcType=INTEGER},
+            </if>
+            <if test="stationName !=null ">
+                #{stationName, jdbcType=VARCHAR},
+            </if>
+
+            <if test="oilName !=null ">
+                #{oilName},
+            </if>
+            <if test="liters !=null ">
+                #{liters},
+            </if>
+            <if test="amt !=null ">
+                #{amt},
+            </if>
+
+            <if test="cyGrade !=null ">
+                #{cyGrade},
+            </if>
+            <if test="qyGrade !=null ">
+                #{qyGrade},
+            </if>
+
+            <if test="blogOpenid !=null ">
+                #{blogOpenid},
+            </if>
+            <if test="minaOpenid !=null ">
+                #{minaOpenid, jdbcType=VARCHAR},
+            </if>
+            <if test="blogUserId !=null ">
+                #{blogUserId, jdbcType=INTEGER},
+            </if>
+            <if test="minaUserId !=null ">
+                #{minaUserId, jdbcType=INTEGER},
+            </if>
+            <if test="grade !=null ">
+                #{grade, jdbcType=VARCHAR},
+            </if>
+            <if test="unionId !=null and unionId !=''">
+                #{unionId, jdbcType=VARCHAR}
+            </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>

+ 13 - 4
YijiaRestful/src/main/resources/mapper/CustomerPointsMapper.xml

@@ -184,13 +184,22 @@
       <if test="createTime !=null">
         create_time =#{createTime},
       </if>
-    </set>
-    <where>
       <if test="unionId !=null and unionId !=''">
-        union_id = #{unionId}
+        union_id = #{unionId},
       </if>
+    </set>
+    <where>
       <if test="stationId !='' and stationId != null" >
-        AND station_id = #{stationId}
+        station_id = #{stationId}
+      </if>
+<!--      <if test="unionId !=null and unionId !=''">-->
+<!--        AND union_id = #{unionId}-->
+<!--      </if>-->
+      <if test="blogOpenId !=null and blogOpenId !=''">
+        AND blog_openid = #{blogOpenId}
+      </if>
+      <if test="minaOpenId !=null and minaOpenId !=''">
+        AND mina_openid = #{minaOpenId}
       </if>
     </where>
   </update>