jk-GitHub-coder vor 4 Jahren
Ursprung
Commit
661575789b

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

@@ -4,11 +4,9 @@ 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.service.AppUserInfoService;
-import com.platform.yijia.service.CustomerPointsService;
-import com.platform.yijia.service.PayOrderService;
-import com.platform.yijia.service.StationService;
+import com.platform.yijia.service.*;
 import com.platform.yijia.utils.CodeMsg;
 import com.platform.yijia.utils.ResultData;
 import com.platform.yijia.utils.redis.RedisCacheUtil;
@@ -24,8 +22,12 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
@@ -43,6 +45,8 @@ public class AppUserInfoController {
     private CustomerPointsService customerPointsService;
     @Resource
     private RedisCacheUtil redisCacheUtil;
+    @Resource
+    private ElectronicMembershipCardService electronicMembershipCardService;
 
 //    String appId = "wxe1135cd390b38a54";        //微信小程序appID
 //    String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb";      //微信小程序密钥
@@ -119,14 +123,15 @@ public class AppUserInfoController {
                 }
             }
             String string1 = "jsapi_ticket="+jsapiTicket + "&noncestr=" +noncestr +"&timestamp=" +timestamp +"&url=" +url;
+            logger.info("签名参数拼接:"+ string1);
             //sha1加密
             String signature = DigestUtils.sha1Hex(string1);
+            //String signature = this.sha1(string1);
             resultData = ResultData.success(signature);
         }
         return gson.toJson(resultData);
     }
 
-
     /*
      * 判断使用小程序支付的用户是否关注公众号
      * @param unionId
@@ -266,6 +271,7 @@ public class AppUserInfoController {
             logger.info("前端传入参数:" +request.toString());
             AppUserInfo appUserInfo =new AppUserInfo();
             CustomerPoints customerPoints =  new CustomerPoints();
+            CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard();   //客户电子卡
             String openId = "";     //此参数用于查询该用户是否已注册过
             if(request.getUserType()!=null){
                 //1-微信公众号
@@ -275,6 +281,7 @@ public class AppUserInfoController {
                     openId = request.getOpenId();
                     appUserInfo.setBlogOpenid(openId);
                     customerPoints.setBlogOpenId(openId);
+                    customerElectronicCard.setBlogOpenid(openId);
                  //2-微信小程序
                 }else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getOpenId())){
                     appUserInfo.setUserType(request.getUserType());
@@ -282,15 +289,18 @@ public class AppUserInfoController {
                     openId = request.getOpenId();
                     appUserInfo.setMinaOpenid(openId);
                     customerPoints.setMinaOpenId(openId);
+                    customerElectronicCard.setMinaOpenid(openId);
                 }
             }
             if(StringUtils.isNotBlank(request.getBlogNickName())){
                 appUserInfo.setBlogNickName(request.getBlogNickName());
                 customerPoints.setCustomerName(request.getBlogNickName());
+                customerElectronicCard.setCustomerName(request.getBlogNickName());
             }
             if(StringUtils.isNotBlank(request.getMobilePhone())){
                 appUserInfo.setMobilePhone(request.getMobilePhone());
                 customerPoints.setMobilePhone(request.getMobilePhone());
+                customerElectronicCard.setMobilePhone(request.getMobilePhone());
             }
             if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
                 appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
@@ -298,6 +308,7 @@ public class AppUserInfoController {
             if(StringUtils.isNotBlank(request.getUnionId())){
                 appUserInfo.setUnionId(request.getUnionId());
                 customerPoints.setUnionId(request.getUnionId());
+                customerElectronicCard.setUnionId(request.getUnionId());
             }
 
             appUserInfo.setRegisteDate(new Date());
@@ -312,6 +323,10 @@ public class AppUserInfoController {
             customerPoints.setStationId(request.getStationId());
             customerPoints.setStationName(request.getStationName());
 
+            customerElectronicCard.setCreateTime(new Date());
+            customerElectronicCard.setStationId(request.getStationId());
+            customerElectronicCard.setStationName(request.getStationName());
+
             if(StringUtils.isNotBlank(request.getSexFlag())){
                 appUserInfo.setSexFlag(request.getSexFlag());
             }
@@ -322,16 +337,14 @@ public class AppUserInfoController {
             //判断该用户是否已存在
             int count = appUserInfoService.isExistAppUser(params);
             if(count > 0){
-                //此处是为初期没使用unionid,以作更新前期用户unionId
-                String userUnionId = appUserInfoService.getUserUnionId(appUserInfo);
-                if(!StringUtils.isNotBlank(userUnionId)){
-                    appUserInfoService.updateUnionId(appUserInfo);
-                }
+                appUserInfoService.updateAppUserInfo(appUserInfo);
                 this.upDateCustomerPointsInfo(customerPoints, request);
-                resultData = ResultData.error(CodeMsg.USER_EXSIST);
+                this.upDateCustomerElectronicCard(customerElectronicCard, request);
+                resultData = ResultData.error(CodeMsg.SUCCESS);
             }else {
                 appUserInfoService.AddAppUserInfo(appUserInfo);
                 this.upDateCustomerPointsInfo(customerPoints, request);
+                this.upDateCustomerElectronicCard(customerElectronicCard, request);
                 resultData = ResultData.success(CodeMsg.SUCCESS);
             }
         }catch (Exception e){
@@ -358,8 +371,32 @@ public class AppUserInfoController {
             c.setStationId(request.getStationId());
             c.setStationName(request.getStationName());
             c.setMobilePhone(request.getMobilePhone());
+            c.setStationId(request.getStationId());
+            c.setStationName(request.getStationName());
             customerPointsService.updateCustomerPointsInfo(c);
         }
     }
 
+    //客户电子会员卡表操作
+    public void upDateCustomerElectronicCard(CustomerElectronicCard customerElectronicCard, AppUserInfoRequest request){
+        List<CustomerElectronicCard> electronicCardList = electronicMembershipCardService.getElectronicCardList(customerElectronicCard);
+        if(electronicCardList !=null && electronicCardList.size() ==2){
+            electronicMembershipCardService.updateElectronicCardInfoByUnionId(customerElectronicCard);
+        }else {
+            //当前时间戳
+            String currentTime = String.valueOf(System.currentTimeMillis());
+            String customerNo = request.getStationId() + currentTime;
+            customerElectronicCard.setCustomerNo(customerNo);
+            customerElectronicCard.setAmt(new BigDecimal(0));
+            customerElectronicCard.setCardOilsType("1");
+            electronicMembershipCardService.insetElectronicCard(customerElectronicCard);
+            customerElectronicCard.setCardOilsType("2");
+            String currentTime1 = String.valueOf(System.currentTimeMillis());
+            String customerNo1 = request.getStationId() + currentTime1;
+            customerElectronicCard.setCustomerNo(customerNo1);
+            electronicMembershipCardService.insetElectronicCard(customerElectronicCard);
+        }
+
+    }
+
 }

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralShoppingMallController.java

@@ -132,6 +132,7 @@ public class IntegralShoppingMallController {
         }
         if(request.getStationId() != null){
             integralOrder.setStationId(request.getStationId());
+            customerPoints.setStationId(request.getStationId());
             customerPointsRecord.setStationId(request.getStationId());
         }
         if(request.getWaresId() !=null){

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -691,6 +691,7 @@ public class PayController {
                                 customerPoints.setCustomerName(infoMap.get("consumer").toString());
                                 customerPoints.setMobilePhone(infoMap.get("mobilePhone").toString());   //存入手机号
                                 customerPoints.setStationName(infoMap.get("stationName").toString());
+                                customerPoints.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
 
                                 customerPointsRecord.setCustomerName(infoMap.get("consumer").toString());       //客户名称
                                 customerPointsRecord.setRecordType("+");            // "+"表示增加积分

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

@@ -111,7 +111,7 @@ public interface AppUserInfoMapper {
     int updateByPrimaryKey(AppUserInfo record);
 
     //更新unionID
-    void updateUnionId(AppUserInfo appUserInfo);
+    void updateAppUserInfo(AppUserInfo appUserInfo);
 
     //查询客户UnionId
     String getUserUnionId(AppUserInfo appUserInfo);

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/ElectronicMembershipCardMapper.java

@@ -38,4 +38,10 @@ public interface ElectronicMembershipCardMapper {
 
     //查询油站的会员卡启用标识 (1、启动 2,停用)
     String getStationCardEnabledFlag(Integer stationId);
+
+    //根据unionId获取用户用要充值电子会员卡(储蓄卡)信息
+    CustomerElectronicCard getElectronicCardInfoByUnionId(CustomerElectronicCard customerElectronicCard);
+
+    //插入电子会员卡
+    void insetElectronicCard(CustomerElectronicCard customerElectronicCard);
 }

+ 4 - 2
YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerElectronicCard.java

@@ -12,10 +12,12 @@ import java.util.Date;
 public class CustomerElectronicCard {
     private Integer id;     //主键
     private String unionId;     //微信用户唯一标识
-    private String blogOpenid;      //公众号openId
+    private String blogOpenid;      //公众号用户openId
+    private String minaOpenid;      //小程序用户openId
     private String customerNo;      //会员编号
     private String customerName;    //客户名称
-    private BigDecimal amt;     //客户余额
+    private String mobilePhone;     //用户手机号
+    private BigDecimal amt;         //客户余额
     private String cardOilsType;        //电子会员卡类型:1,柴油;2.汽油
     private Integer stationId;      //油站ID
     private String stationName;     //油站

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

@@ -20,7 +20,7 @@ public interface AppUserInfoService {
     boolean selectAppUserInfo(String token, String userType);
 
     //更新unionID
-    void updateUnionId(AppUserInfo appUserInfo);
+    void updateAppUserInfo(AppUserInfo appUserInfo);
 
     //查询客户UnionId
     String getUserUnionId(AppUserInfo appUserInfo);

+ 8 - 2
YijiaRestful/src/main/java/com/platform/yijia/service/ElectronicMembershipCardService.java

@@ -11,7 +11,7 @@ public interface ElectronicMembershipCardService {
     //获取用户储蓄卡列表
     List<CustomerElectronicCard> getElectronicCardList(CustomerElectronicCard customerElectronicCard);
 
-    //获取用要充值电子会员卡的信息
+    //获取用要充值电子会员卡的信息
     CustomerElectronicCard getElectronicCardInfo(CustomerElectronicCard customerElectronicCard);
 
     //更新电子会员卡信息
@@ -26,7 +26,7 @@ public interface ElectronicMembershipCardService {
     //根据订单号查询电子会员卡的充值记录信息
     CustomerCardUseRecord getCardRecordByOrderNo(CustomerCardUseRecord customerCardUseRecord);
 
-    //根据unionId更新客户余额
+    //根据unionId和油站更新客户余额
     void updateElectronicCardInfoByUnionId(CustomerElectronicCard customerElectronicCard);
 
     //根据订单号更新用户充值记录的状态
@@ -38,4 +38,10 @@ public interface ElectronicMembershipCardService {
     //查询油站的会员卡启用标识 (1、启动 2,停用)
     String getStationCardEnabledFlag(Integer stationId);
 
+    //根据unionId和油站ID获取用户用要充值电子会员卡(储蓄卡)信息
+    CustomerElectronicCard getElectronicCardInfoByUnionId(CustomerElectronicCard customerElectronicCard);
+
+    //插入电子会员卡
+    void insetElectronicCard(CustomerElectronicCard customerElectronicCard);
+
 }

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

@@ -74,8 +74,8 @@ public class AppUserInfoServiceImpl implements AppUserInfoService {
 
     //更新unionID
     @Override
-    public void updateUnionId(AppUserInfo appUserInfo) {
-        appUserInfoMapper.updateUnionId(appUserInfo);
+    public void updateAppUserInfo(AppUserInfo appUserInfo) {
+        appUserInfoMapper.updateAppUserInfo(appUserInfo);
     }
 
     @Override

+ 12 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/ElectronicMembershipCardServiceImpl.java

@@ -18,6 +18,18 @@ public class ElectronicMembershipCardServiceImpl implements ElectronicMembership
     @Resource
     private ElectronicMembershipCardMapper electronicMembershipCardMapper;
 
+    //插入电子会员卡
+    @Override
+    public void insetElectronicCard(CustomerElectronicCard customerElectronicCard) {
+        electronicMembershipCardMapper.insetElectronicCard(customerElectronicCard);
+    }
+
+    //根据unionId和油品类型获取用户用要充值电子会员卡(储蓄卡)信息
+    @Override
+    public CustomerElectronicCard getElectronicCardInfoByUnionId(CustomerElectronicCard customerElectronicCard) {
+        return electronicMembershipCardMapper.getElectronicCardInfoByUnionId(customerElectronicCard);
+    }
+
     //查询油站电子会员卡(储蓄卡)充值设置规则
     @Override
     public List<CustomerCardSetting> getCardRechargeSettingList(CustomerCardSetting customerCardSetting) {

+ 35 - 2
YijiaRestful/src/main/resources/mapper/AppUserInfoMapper.xml

@@ -437,10 +437,43 @@
     </where>
   </select>
 
-  <!--更新UnionId-->
-  <update id="updateUnionId" parameterType="com.platform.yijia.pojo.AppUserInfo">
+  <!--更新用户信息-->
+  <update id="updateAppUserInfo" parameterType="com.platform.yijia.pojo.AppUserInfo">
     UPDATE app_user_info
     <set>
+      <if test="userType != null">
+        user_type = #{userType},
+      </if>
+      <if test="blogOpenid != null">
+        blog_openid = #{blogOpenid},
+      </if>
+      <if test="minaOpenid != null">
+        mina_openid = #{minaOpenid},
+      </if>
+      <if test="mobilePhone != null">
+        mobile_phone = #{mobilePhone},
+      </if>
+      <if test="blogNickName != null">
+        blog_nick_name = #{blogNickName},
+      </if>
+      <if test="sexFlag != null">
+        sex_flag = #{sexFlag},
+      </if>
+      <if test="registeDate != null">
+        registe_date = #{registeDate},
+      </if>
+      <if test="blogToken != null">
+        blog_token = #{blogToken},
+      </if>
+      <if test="minaToken != null">
+        mina_token = #{minaToken},
+      </if>
+      <if test="blogProfilePhoto != null">
+        blog_profile_photo = #{blogProfilePhoto},
+      </if>
+      <if test="updateDate != null">
+        update_date = #{updateDate},
+      </if>
       <if test="unionId !=null">
         union_id = #{unionId}
       </if>

+ 6 - 0
YijiaRestful/src/main/resources/mapper/CustomerPointsMapper.xml

@@ -173,6 +173,9 @@
       <if test="unionId !=null and unionId !=''">
         union_id = #{unionId}
       </if>
+      <if test="stationId !='' and stationId != null" >
+        AND station_id = #{stationId}
+      </if>
     </where>
   </update>
 
@@ -186,6 +189,9 @@
       <if test="unionId !=null and unionId !=''">
         union_id = #{unionId}
       </if>
+      <if test="stationId !='' and stationId != null" >
+        AND station_id = #{stationId}
+      </if>
     </where>
   </select>
 

+ 149 - 0
YijiaRestful/src/main/resources/mapper/ElectronicMembershipCardMapper.xml

@@ -6,8 +6,10 @@
       <id     column="id"                      jdbcType="INTEGER"   property="id" />
       <result column="union_id"                jdbcType="VARCHAR"   property="unionId" />
       <result column="blog_openid"             jdbcType="VARCHAR"   property="blogOpenid" />
+      <result column="mina_openid"             jdbcType="VARCHAR"   property="minaOpenid" />
       <result column="customer_no"             jdbcType="VARCHAR"   property="customerNo" />
       <result column="customer_name"           jdbcType="VARCHAR"   property="customerName" />
+      <result column="mobile_phone"           jdbcType="VARCHAR"   property="mobilePhone" />
       <result column="amt"                     jdbcType="DECIMAL"   property="amt" />
       <result column="card_oils_type"          jdbcType="VARCHAR"   property="cardOilsType" />
       <result column="station_id"              jdbcType="INTEGER"   property="stationId" />
@@ -252,6 +254,7 @@
             id,
             union_id,
             blog_openid,
+            mina_openid,
             customer_no,
             customer_name,
             amt,
@@ -275,12 +278,125 @@
         </where>
     </select>
 
+    <!--插入用户电子会员卡-->
+    <insert id="insetElectronicCard" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
+        INSERT INTO
+            customer_electronic_card
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="unionId !=null">
+                union_id,
+            </if>
+            <if test="blogOpenid !=null">
+                blog_openid,
+            </if>
+            <if test="minaOpenid !=null">
+                mina_openid,
+            </if>
+            <if test="customerNo !=null">
+                customer_no,
+            </if>
+            <if test="customerName !=null">
+                customer_name,
+            </if>
+            <if test="mobilePhone !=null">
+                mobile_phone,
+            </if>
+            <if test="amt !=null">
+                amt,
+            </if>
+            <if test="cardOilsType !=null">
+                card_oils_type,
+            </if>
+            <if test="stationId !=null">
+                station_id,
+            </if>
+            <if test="stationName !=null">
+                station_name,
+            </if>
+            <if test="createTime !=null">
+                create_time,
+            </if>
+            <if test="recentlyTime !=null">
+                recently_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="unionId !=null">
+                #{unionId},
+            </if>
+            <if test="blogOpenid !=null">
+                #{blogOpenid},
+            </if>
+            <if test="minaOpenid !=null">
+                #{minaOpenid},
+            </if>
+            <if test="customerNo !=null">
+                #{customerNo},
+            </if>
+            <if test="customerName !=null">
+                #{customerName},
+            </if>
+            <if test="mobilePhone !=null">
+                #{mobilePhone},
+            </if>
+            <if test="amt !=null">
+                #{amt},
+            </if>
+            <if test="cardOilsType !=null">
+                #{cardOilsType},
+            </if>
+            <if test="stationId !=null">
+                #{stationId},
+            </if>
+            <if test="stationName !=null">
+                #{stationName},
+            </if>
+            <if test="createTime !=null">
+                #{createTime},
+            </if>
+            <if test="recentlyTime !=null">
+                #{recentlyTime},
+            </if>
+        </trim>
+    </insert>
+
+    <!--根据unionId获取用户用要充值电子会员卡(储蓄卡)信息-->
+    <select id="getElectronicCardInfoByUnionId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
+        SELECT
+            id,
+            union_id,
+            blog_openid,
+            mina_openid,
+            customer_no,
+            customer_name,
+            amt,
+            card_oils_type,
+            station_id,
+            station_name,
+            create_time,
+            recently_time
+        FROM
+            customer_electronic_card
+        <where>
+            <if test="unionId !=null and unionId !=''">
+                union_id = #{unionId}
+            </if>
+            <if test="cardOilsType !=null and cardOilsType !=''">
+                AND card_oils_type = #{cardOilsType}
+            </if>
+            <if test="stationId !='' and stationId != null" >
+                AND station_id = #{stationId}
+            </if>
+        </where>
+    </select>
+
     <!--获取用户用要充值电子会员卡(储蓄卡)信息-->
     <select id="getElectronicCardInfo" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
         SELECT
             id,
             union_id,
             blog_openid,
+            mina_openid,
             customer_no,
             customer_name,
             amt,
@@ -321,9 +437,39 @@
     <update id="updateElectronicCardInfoByUnionId" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
         UPDATE customer_electronic_card
         <set>
+            <if test="unionId !=null">
+                union_id = #{unionId},
+            </if>
+            <if test="blogOpenid !=null">
+                blog_openid ={blogOpenid},
+            </if>
+            <if test="minaOpenid !=null">
+                mina_openid = #{minaOpenid},
+            </if>
+            <if test="customerNo !=null">
+                customer_no = #{customerNo},
+            </if>
+            <if test="customerName !=null">
+                customer_name = #{customerName},
+            </if>
+            <if test="mobilePhone !=null">
+                mobile_phone = #{mobilePhone},
+            </if>
             <if test="amt !=null">
                 amt = #{amt},
             </if>
+            <if test="cardOilsType !=null">
+                card_oils_type = #{cardOilsType},
+            </if>
+            <if test="stationId !=null">
+                station_id = #{stationId},
+            </if>
+            <if test="stationName !=null">
+                station_name = #{stationName},
+            </if>
+            <if test="createTime !=null">
+                create_time = #{createTime},
+            </if>
             <if test="recentlyTime !=null">
                 recently_time = #{recentlyTime}
             </if>
@@ -332,6 +478,9 @@
             <if test="unionId !=null and unionId != ''">
                 union_id = #{unionId}
             </if>
+            <if test="stationId !='' and stationId != null" >
+                AND station_id = #{stationId}
+            </if>
         </where>
     </update>