|
|
@@ -16,8 +16,11 @@ import com.fs.app.invitation.service.IAppInvitationCodeTagService;
|
|
|
import com.fs.app.invitation.vo.AppInvitationCodeVO;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.bean.BeanUtils;
|
|
|
+import com.fs.his.utils.qrcode.QRCodeUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -25,6 +28,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class AppInvitationCodeServiceImpl extends ServiceImpl<AppInvitationCodeMapper, AppInvitationCode> implements IAppInvitationCodeService {
|
|
|
@@ -94,6 +98,9 @@ public class AppInvitationCodeServiceImpl extends ServiceImpl<AppInvitationCodeM
|
|
|
}
|
|
|
//公司邀请码
|
|
|
else {
|
|
|
+ AppCompanyInvitationCode companyCode = this.appCompanyInvitationCodeService
|
|
|
+ .selectAppCompanyInvitationCodeById(reqData.getId());
|
|
|
+
|
|
|
this.appCompanyInvitationCodeService.lambdaUpdate()
|
|
|
.set(true, AppCompanyInvitationCode::getRemark, reqData.getRemark())
|
|
|
.set(true, AppCompanyInvitationCode::getTagIds,
|
|
|
@@ -102,6 +109,10 @@ public class AppInvitationCodeServiceImpl extends ServiceImpl<AppInvitationCodeM
|
|
|
ObjectUtil.isNotEmpty(reqData.getCustomerIds()) ? reqData.getCustomerIds().stream().map(String::valueOf).collect(Collectors.joining(",")) : null)
|
|
|
.eq(AppCompanyInvitationCode::getId, reqData.getId())
|
|
|
.update();
|
|
|
+ R qrResult = ensureCompanyInvitationQrCode(companyCode);
|
|
|
+ if (qrResult != null) {
|
|
|
+ return qrResult;
|
|
|
+ }
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
@@ -145,6 +156,7 @@ public class AppInvitationCodeServiceImpl extends ServiceImpl<AppInvitationCodeM
|
|
|
AppInvitationCodeVO vo = new AppInvitationCodeVO();
|
|
|
vo.setId(one.getId());
|
|
|
vo.setInvitationCode(one.getCompanyId() + "");
|
|
|
+ vo.setQrCode(one.getQrCode());
|
|
|
return vo;
|
|
|
}
|
|
|
AppInvitationCodeVO vo = new AppInvitationCodeVO();
|
|
|
@@ -152,4 +164,36 @@ public class AppInvitationCodeServiceImpl extends ServiceImpl<AppInvitationCodeM
|
|
|
vo.setInvitationCode(one.getCompanyId() + "");
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公司邀请码二维码:内容为公司id(邀请码)
|
|
|
+ *
|
|
|
+ * @return 成功返回 null
|
|
|
+ */
|
|
|
+ private R ensureCompanyInvitationQrCode(AppCompanyInvitationCode companyCode) {
|
|
|
+ if (companyCode == null || companyCode.getCompanyId() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(companyCode.getQrCode())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String invitationCode = String.valueOf(companyCode.getCompanyId());
|
|
|
+ R uploadResult = QRCodeUtils.createAndUpload(invitationCode);
|
|
|
+ Object url = uploadResult.get("url");
|
|
|
+ if (url == null || StringUtils.isEmpty(url.toString())) {
|
|
|
+ return R.error("二维码生成失败");
|
|
|
+ }
|
|
|
+ String qrCodeUrl = url.toString();
|
|
|
+ this.appCompanyInvitationCodeService.lambdaUpdate()
|
|
|
+ .set(AppCompanyInvitationCode::getQrCode, qrCodeUrl)
|
|
|
+ .eq(AppCompanyInvitationCode::getId, companyCode.getId())
|
|
|
+ .update();
|
|
|
+ companyCode.setQrCode(qrCodeUrl);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("公司邀请码二维码生成失败, companyId={}", companyCode.getCompanyId(), e);
|
|
|
+ return R.error("二维码生成失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|