|  | @@ -18,6 +18,7 @@ import com.fs.common.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.fs.common.utils.IPUtils;
 | 
	
		
			
				|  |  |  import com.fs.common.utils.ServletUtils;
 | 
	
		
			
				|  |  |  import com.fs.common.utils.StringUtils;
 | 
	
		
			
				|  |  | +import com.fs.company.domain.Company;
 | 
	
		
			
				|  |  |  import com.fs.company.domain.CompanyConfig;
 | 
	
		
			
				|  |  |  import com.fs.company.domain.CompanyUser;
 | 
	
		
			
				|  |  |  import com.fs.company.mapper.CompanyConfigMapper;
 | 
	
	
		
			
				|  | @@ -28,6 +29,8 @@ import com.fs.course.config.RedPacketConfig;
 | 
	
		
			
				|  |  |  import com.fs.course.domain.FsCourseRedPacketLog;
 | 
	
		
			
				|  |  |  import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 | 
	
		
			
				|  |  |  import com.fs.course.service.IFsCourseRedPacketLogService;
 | 
	
		
			
				|  |  | +import com.fs.his.domain.FsUserWx;
 | 
	
		
			
				|  |  | +import com.fs.his.service.IFsUserWxService;
 | 
	
		
			
				|  |  |  import com.fs.pay.pay.config.PayConfig;
 | 
	
		
			
				|  |  |  import com.fs.pay.pay.domain.CreateWxOrderResult;
 | 
	
		
			
				|  |  |  import com.fs.pay.pay.dto.WxJspayDTO;
 | 
	
	
		
			
				|  | @@ -486,6 +489,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
 | 
	
		
			
				|  |  |                  openId = session.getOpenid();
 | 
	
		
			
				|  |  | +                handleFsUserWx(param.getUser(),param.getAppId(),session);
 | 
	
		
			
				|  |  |              } catch (WxErrorException e){
 | 
	
		
			
				|  |  |                  return R.error("openId获取失败," + e.getMessage());
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -510,6 +514,33 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IFsUserWxService fsUserWxService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    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);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public R sendRedPacketTest(WxSendRedPacketParam param) {
 |