소스 검색

Merge remote-tracking branch 'origin/master'

ct 22 시간 전
부모
커밋
bb286d2f1b

+ 2 - 0
fs-service-system/src/main/java/com/fs/course/domain/FsCourseRedPacketLog.java

@@ -63,4 +63,6 @@ public class FsCourseRedPacketLog extends BaseEntity
 
     private String batchId;//微信批次单号
 
+    private String appId;//小程序appId
+
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/course/param/FsUserCourseVideoFinishUParam.java

@@ -21,4 +21,5 @@ public class FsUserCourseVideoFinishUParam implements Serializable {
     private Integer linkType;
     private Integer isRoom;
     private Long periodId;
+    private Integer projectId;
 }

+ 1 - 7
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -612,13 +612,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             // 处理 UUID 为空的情况
             if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
                 // 直接插入或更新
-//                logger.error("zyp \n【插入或更新流量】:{}",trafficLog);
-//                if(ObjectUtils.isNotNull(trafficLog.getCourseId())) {
-//                    FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(trafficLog.getCourseId());
-//                    if(ObjectUtils.isNotNull(course)){
-//                        trafficLog.setProject(course.getProject());
-//                    }
-//                }
                 fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
             }
         } catch (Exception e) {
@@ -878,6 +871,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
                 redPacketLog.setAmount(amount);
                 redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
                 redPacketLog.setPeriodId(param.getPeriodId());
+                redPacketLog.setAppId(param.getAppId());
 
                 redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
 

+ 35 - 19
fs-service-system/src/main/java/com/fs/store/service/impl/FsStorePaymentServiceImpl.java

@@ -489,6 +489,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
             try {
                 WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
                 openId = session.getOpenid();
+                logger.info("修改或新增openId:{},userId:{},appId:{}",session.getOpenid(),param.getUser().getUserId(),param.getAppId());
                 handleFsUserWx(param.getUser(),param.getAppId(),session);
             } catch (WxErrorException e){
                 return R.error("openId获取失败," + e.getMessage());
@@ -519,26 +520,41 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 
     private void handleFsUserWx(FsUser user,String appId,WxMaJscode2SessionResult session) {
         // 尝试更新
-        boolean updated = fsUserWxService.lambdaUpdate()
-                .eq(FsUserWx::getFsUserId, user.getUserId())
-                .eq(FsUserWx::getAppId,appId )
-                .eq(FsUserWx::getOpenId, session.getOpenid())
-                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
-                .set(FsUserWx::getUpdateTime, new Date())
-                .update();
-
-        // 如果更新失败(记录不存在),则插入
-        if (!updated) {
-            FsUserWx fsUserWx = new FsUserWx();
-            fsUserWx.setType(1);
-            fsUserWx.setFsUserId(user.getUserId());
-            fsUserWx.setAppId(appId);
-            fsUserWx.setOpenId(session.getOpenid());
-            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
-            fsUserWx.setCreateTime(new Date());
-            fsUserWx.setUpdateTime(new Date());
-            fsUserWxService.save(fsUserWx);
+        FsUserWx userWx = fsUserWxService.selectByAppIdAndUserId(appId,user.getUserId(),1);
+        if (userWx!=null && !userWx.getOpenId().equals(session.getOpenid())){
+            userWx.setOpenId(session.getOpenid());
+            fsUserWxService.updateById(userWx);
+        }else {
+            userWx = new FsUserWx();
+            userWx.setType(1);
+            userWx.setFsUserId(user.getUserId());
+            userWx.setAppId(appId);
+            userWx.setOpenId(session.getOpenid());
+            userWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
+            userWx.setCreateTime(new Date());
+            userWx.setUpdateTime(new Date());
+            fsUserWxService.save(userWx);
         }
+//        boolean updated = fsUserWxService.lambdaUpdate()
+//                .eq(FsUserWx::getFsUserId, user.getUserId())
+//                .eq(FsUserWx::getAppId,appId )
+//                .eq(FsUserWx::getOpenId, session.getOpenid())
+//                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
+//                .set(FsUserWx::getUpdateTime, new Date())
+//                .update();
+//
+//        // 如果更新失败(记录不存在),则插入
+//        if (!updated) {
+//            FsUserWx fsUserWx = new FsUserWx();
+//            fsUserWx.setType(1);
+//            fsUserWx.setFsUserId(user.getUserId());
+//            fsUserWx.setAppId(appId);
+//            fsUserWx.setOpenId(session.getOpenid());
+//            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
+//            fsUserWx.setCreateTime(new Date());
+//            fsUserWx.setUpdateTime(new Date());
+//            fsUserWxService.save(fsUserWx);
+//        }
     }
 
 

+ 2 - 2
fs-service-system/src/main/resources/application-config-zkzh.yml

@@ -76,8 +76,8 @@ wx:
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON
-      - appid: wx414427b10866c04e   #凯逸轩服装店C
-        secret: 4a56cc02f53859e1e9582c15d840c4af
+      - appid: wxcc9096b6f468e39d   #中康智慧坊E
+        secret: 32a33ddcda01b95f5fd3abddf1d4a2fc
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON

+ 5 - 2
fs-service-system/src/main/resources/mapper/course/FsCourseRedPacketLogMapper.xml

@@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="remark"    column="remark"    />
         <result property="result"    column="result"    />
         <result property="batchId"    column="batch_id"    />
+        <result property="appId"    column="app_id"    />
     </resultMap>
 
     <sql id="selectFsCourseRedPacketLogVo">
-        select log_id,watch_log_id,result, remark,out_batch_no,status,update_time,course_id, user_id, video_id, company_user_id, company_id, amount, create_time, qw_user_id from fs_course_red_packet_log
+        select log_id,watch_log_id,result,app_id, remark,out_batch_no,status,update_time,course_id, user_id, video_id, company_user_id, company_id, amount, create_time, qw_user_id from fs_course_red_packet_log
     </sql>
 
     <select id="selectFsCourseRedPacketLogList" parameterType="FsCourseRedPacketLog" resultMap="FsCourseRedPacketLogResult">
@@ -115,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">period_id,</if>
             <if test="result != null">result,</if>
             <if test="batchId != null">batch_id,</if>
-
+            <if test="appId != null">app_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="courseId != null">#{courseId},</if>
@@ -134,6 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">#{periodId},</if>
             <if test="result != null">#{result},</if>
             <if test="batchId != null">#{batchId},</if>
+            <if test="appId != null">#{appId},</if>
          </trim>
     </insert>
 
@@ -156,6 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">period_id = #{periodId},</if>
             <if test="result != null">result = #{result},</if>
             <if test="batchId != null">batch_id = #{batchId},</if>
+            <if test="appId != null">app_id = #{appId},</if>
         </trim>
         where log_id = #{logId}
     </update>