Merge branch 'jihan_0920_护理服务、商城、积分兑换、在线问诊功能分支' of http://182.92.166.109:3000/jihan/xinelu-api into jihan_0920_护理服务、商城、积分兑换、在线问诊功能分支

This commit is contained in:
mengkuiliang 2023-11-09 08:37:16 +08:00
commit 3e28c16035
8 changed files with 153 additions and 83 deletions

View File

@ -249,8 +249,8 @@ xss:
# 家医配置
fd:
dz: http://8.131.93.145:54089/fd/mp
dy: http://8.131.93.145:54089/fd/mp
dz: http://8.131.93.145:54007/fd/mp
dy: http://8.131.93.145:54008/fd/mp
# 签约附近的机构多少公里内 <=0时不限制
distance: 0
@ -281,15 +281,15 @@ applet-page-config:
# 首页跳转路径
page-url: pages/startup/startup
# 个人中心-优惠券页面跳转路径
coupon-page-url: pages/coupon/coupon
coupon-page-url: pagesB/coupon/coupon
# 商品订单页面跳转路径
goods-order-page-url: pages/CommodityOrder/CommodityOrder
goods-order-page-url: pagesB/CommodityOrder/CommodityOrder
# 预约订单页面跳转路径
appoint-order-page-url: pages/Nursingstationserviceorder/Nursingstationserviceorder
appoint-order-page-url: pagesB/Nursingstationserviceorder/Nursingstationserviceorder
# 积分页面跳转路径
integral-page-url: pages/integral/integral
integral-page-url: pagesB/integral/integral
# 护理结构详情页面跳转路径
nursestation-details-page-url: pages/nursestation/nursestation
nursestation-details-page-url: pagesB/nursestation/nursestation
# 新医路微信商户号配置参数
xyl-we-chat-config:

View File

@ -212,7 +212,7 @@ public class Constants {
/**
* 微信小程序ACCESS_TOKEN前缀
*/
public static final String NURSE_STATION_APPLET_ACCESS_TOKEN = "NURSE_STATION_APPLET_ACCESS_TOKEN";
public static final String NURSE_STATION_APPLET_ACCESS_TOKEN = "NURSE_STATION_APPLET_ACCESS_TOKEN_XYL_";
/**
* 护理员微信小程序ACCESS_TOKEN前缀
@ -259,34 +259,34 @@ public class Constants {
*/
public static final String ATTRIBUTE_PICTURE_URL = "attributePitureUrl";
/**
* 筛查预约条码图片地址
*/
public static final String APPLY_BARCODE_PICTURE_URL = "applyBarcodePitureUrl";
/**
* 筛查预约条码图片地址
*/
public static final String APPLY_BARCODE_PICTURE_URL = "applyBarcodePitureUrl";
/**
* 筛查预约条码图片地址
*/
public static final String REGISTER_BARCODE_PICTURE_URL = "registerBarcodePitureUrl";
/**
* 筛查预约条码图片地址
*/
public static final String REGISTER_BARCODE_PICTURE_URL = "registerBarcodePitureUrl";
/**
* 血小板筛查图片地址
*/
public static final String PLATELET_PICTURE_URL = "plateletPitureUrl";
/**
* 血小板筛查图片地址
*/
public static final String PLATELET_PICTURE_URL = "plateletPitureUrl";
/**
* 眼底病变筛查左眼图片地址
*/
public static final String LEFT_EYE_PICTURE_URL = "leftEyePitureUrl";
/**
* 眼底病变筛查右眼图片地址
*/
public static final String RIGHT_EYE_PICTURE_URL = "rightEyePitureUrl";
/**
* 眼底病变筛查左眼图片地址
*/
public static final String LEFT_EYE_PICTURE_URL = "leftEyePitureUrl";
/**
* 眼底病变筛查右眼图片地址
*/
public static final String RIGHT_EYE_PICTURE_URL = "rightEyePitureUrl";
/**
* 阿尔兹海默症结果文件地址
*/
public static final String ALZHEIMER_FILE_URL = "alzheimerFileUrl";
/**
* 阿尔兹海默症结果文件地址
*/
public static final String ALZHEIMER_FILE_URL = "alzheimerFileUrl";
/**
* 护理站模板信息下载
*/

View File

@ -39,20 +39,10 @@ import java.util.concurrent.TimeUnit;
@Component
public class AppletChatUtil {
private static RedisTemplate<String, Object> redisTemplate;
private static AppletChatConfig appletChatConfig;
@Resource
public void redisTemplate(RedisTemplate<String, Object> redisTemplate) {
AppletChatUtil.redisTemplate = redisTemplate;
}
private RedisTemplate<String, Object> redisTemplate;
@Resource
public void appletChatConfig(AppletChatConfig appletChatConfig) {
AppletChatUtil.appletChatConfig = appletChatConfig;
}
private AppletChatConfig appletChatConfig;
/**
* 返回成功状态码
@ -164,7 +154,7 @@ public class AppletChatUtil {
* @param filePathWeChatCodeUrl 文件保存路径
* @return java.lang.String 二维码地址
*/
public static String createAppletCode(Long weChatCodeId, boolean failFlag, String fileName, String appletPageUrl, String filePathWeChatCodeUrl) {
public String createAppletCode(Long weChatCodeId, boolean failFlag, String fileName, String appletPageUrl, String filePathWeChatCodeUrl) {
if (BooleanUtils.isTrue(failFlag)) {
//删除原有Redis中的key值
String accessTokenKey = Constants.NURSE_STATION_APPLET_ACCESS_TOKEN + "accessToken";
@ -250,7 +240,7 @@ public class AppletChatUtil {
*
* @return 小程序的AccessToken
*/
public static String getAppletAccessToken() {
public String getAppletAccessToken() {
String accessToken;
String accessTokenKey = Constants.NURSE_STATION_APPLET_ACCESS_TOKEN + "accessToken";
//从Redis中取出accessToken

View File

@ -4,36 +4,39 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.xinelu.common.config.AppletChatConfig;
import com.xinelu.common.entity.AppletPhoneVO;
import com.xinelu.common.enums.CouponReceiveTypeEnum;
import com.xinelu.common.enums.CouponUseStatusEnum;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.common.utils.http.HttpService;
import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.common.utils.http.SslUtils;
import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.common.utils.uuid.IdUtils;
import com.xinelu.familydoctor.applet.mapper.ResidentPatientInfoMapper;
import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
import com.xinelu.familydoctor.applet.pojo.query.PatientInfoQuery;
import com.xinelu.familydoctor.applet.pojo.vo.SignInfoDetailVo;
import com.xinelu.familydoctor.applet.service.IResidentPatientInfoService;
import com.xinelu.familydoctor.applet.utils.AppletAccessTokenUtils;
import com.xinelu.manage.domain.coupon.Coupon;
import com.xinelu.manage.domain.patientcouponreceive.PatientCouponReceive;
import com.xinelu.manage.domain.receiveAddressInfo.ReceiveAddressInfo;
import com.xinelu.manage.mapper.coupon.CouponMapper;
import com.xinelu.manage.mapper.patientcouponreceive.PatientCouponReceiveMapper;
import com.xinelu.manage.mapper.receiveAddressInfo.ReceiveAddressInfoMapper;
import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -58,6 +61,10 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
private RedisTemplate<String, Object> redisTemplate;
@Resource
private ReceiveAddressInfoMapper receiveAddressInfoMapper;
@Resource
private PatientCouponReceiveMapper patientCouponReceiveMapper;
@Resource
private CouponMapper couponMapper;
/**
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
@ -192,10 +199,9 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
} else {
patientInfo.setDisease("0");
}
patientInfo.setLoginFlag(Long.valueOf(1));
patientInfo.setLoginFlag(1L);
patientInfo.setBindOpenid(body.getOpenid());
updatePatientInfo(patientInfo);
// 新增
} else {
patientInfo = residentPatientInfoMapper.isRegisterByCardNo(body.getCardNo());
@ -216,7 +222,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
patientInfo.setUpdateBy(body.getCardNo());
patientInfo.setHeadPictureUrl(body.getHeadPictureUrl());
patientInfo.setDelFlag(0);
patientInfo.setLoginFlag(Long.valueOf(1));
patientInfo.setLoginFlag(1L);
if (body.getDiseaseList() != null) {
patientInfo.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(",")));
} else {
@ -249,7 +255,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
entity.setIsChecked("0");
entity.setCreateTime(new Date());
entity.setCreateBy(body.getCardNo());
entity.setLoginFlag(Long.valueOf(1));
entity.setLoginFlag(1L);
entity.setDelFlag(0);
entity.setBindOpenid(body.getOpenid());
residentPatientInfoMapper.insertPatientInfo(entity);
@ -268,6 +274,15 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
}
this.insertReceiveAddress(patientInfo);
}
PatientInfo patient = residentPatientInfoMapper.getLoginByOpenId(body.getOpenid());
//判断是否是第一次完善如果是则发放新人优惠券信息
PatientCouponReceive patientCouponReceive = new PatientCouponReceive();
patientCouponReceive.setReceiveSource(CouponReceiveTypeEnum.NEW_PEOPLE_WELFARE.getInfo());
patientCouponReceive.setPatientId(patient.getId());
int couponReceiveCount = patientCouponReceiveMapper.getCouponReceiveByReceiveSource(patient.getId(), CouponReceiveTypeEnum.NEW_PEOPLE_WELFARE.getInfo());
if (Objects.nonNull(patient.getLoginFlag()) && patient.getLoginFlag() ==1 && couponReceiveCount <= 0) {
issueCoupons(patient);
}
}
/** 新增收货人地址信息 */
@ -454,4 +469,50 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
HashMap.put("cityCode", cityCode);
return HashMap;
}
/**
* 发放优惠券方法胡
*
* @param patient 会员信息
*/
public void issueCoupons(PatientInfo patient ) {
PatientCouponReceiveInfoVO receiveInfoVO = new PatientCouponReceiveInfoVO();
//查询新人福利的优惠券列表信息
Coupon coupon = new Coupon();
Long patientId = patient.getId();
coupon.setReceiveType(CouponReceiveTypeEnum.NEW_PEOPLE_WELFARE.getInfo());
List<Coupon> couponList = couponMapper.selectCouponList(coupon);
if (CollectionUtils.isEmpty(couponList)) {
return ;
}
//组装优惠券信息
List<PatientCouponReceive> couponReceiveList = Lists.newArrayList();
for (Coupon couponInfo : couponList) {
if (Objects.isNull(couponInfo.getId())) {
continue;
}
PatientCouponReceive couponReceive = new PatientCouponReceive();
couponReceive.setPatientId(patientId);
couponReceive.setCouponId(couponInfo.getId());
couponReceive.setReceiveSource(CouponReceiveTypeEnum.NEW_PEOPLE_WELFARE.getInfo());
couponReceive.setUseStatus(CouponUseStatusEnum.NOT_USED.getInfo());
couponReceive.setExpirationStartTime(LocalDateTime.now());
couponReceive.setExpirationEndTime(LocalDate.now().plusDays(Objects.isNull(couponInfo.getCouponReductionDays()) ? 0 : couponInfo.getCouponReductionDays()).atTime(23, 59, 59));
couponReceive.setReceiveTime(LocalDateTime.now());
couponReceive.setCouponReductionDays(Objects.isNull(couponInfo.getCouponReductionDays()) ? 0 : couponInfo.getCouponReductionDays());
couponReceive.setCreateTime(LocalDateTime.now());
couponReceive.setCouponTitle(StringUtils.isBlank(couponInfo.getCouponTitle()) ? "" : couponInfo.getCouponTitle());
couponReceive.setCouponPrice(Objects.isNull(couponInfo.getCouponPrice()) ? BigDecimal.ZERO : couponInfo.getCouponPrice());
couponReceive.setCouponConsumePrice(Objects.isNull(couponInfo.getCouponConsumePrice()) ? BigDecimal.ZERO : couponInfo.getCouponConsumePrice());
couponReceive.setCouponDescription(StringUtils.isBlank(couponInfo.getCouponDescription()) ? "" : couponInfo.getCouponDescription());
couponReceiveList.add(couponReceive);
}
if (CollectionUtils.isNotEmpty(couponReceiveList)) {
int insertCount = patientCouponReceiveMapper.insertBatchPatientReceive(couponReceiveList);
if (insertCount <= 0) {
log.error("完善用户信息接口-新人送券执行失败,输入参数[{}]", couponReceiveList);
throw new ServiceException("完善用户信息失败,请联系管理员!");
}
}
}
}

View File

@ -6,7 +6,6 @@ import com.xinelu.applet.dto.patientcenter.PatientCenterCouponDTO;
import com.xinelu.applet.mapper.nurseapplogin.NurseAppLoginMapper;
import com.xinelu.applet.mapper.nursingstationgoods.NursingStationGoodsMapper;
import com.xinelu.applet.mapper.patientcenter.PatientCenterMapper;
import com.xinelu.manage.service.messagepush.MessagePushService;
import com.xinelu.applet.service.patientcenter.PatientCenterService;
import com.xinelu.applet.vo.coupon.CouponVO;
import com.xinelu.applet.vo.patientcenter.PatientCenterCouponVO;
@ -43,6 +42,7 @@ import com.xinelu.manage.mapper.patientintegralchange.PatientIntegralChangeMappe
import com.xinelu.manage.mapper.patientsignininfo.PatientSignInInfoMapper;
import com.xinelu.manage.mapper.subscribemessagerecord.SubscribeMessageRecordMapper;
import com.xinelu.manage.mapper.systemsettingsinfo.SystemSettingsInfoMapper;
import com.xinelu.manage.service.messagepush.MessagePushService;
import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO;
import com.xinelu.manage.vo.patientinfo.PatientInfoVO;
import lombok.extern.slf4j.Slf4j;
@ -108,7 +108,8 @@ public class PatientCenterServiceImpl implements PatientCenterService {
private SubscribeMessageRecordMapper subscribeMessageRecordMapper;
@Resource
private MessagePushService messagePushService;
@Resource
private AppletChatUtil appletChatUtil;
/**
* 用户第一次签到次数
*/
@ -262,10 +263,10 @@ public class PatientCenterServiceImpl implements PatientCenterService {
String appletPageUrl = appletPageConfig.getPageUrl();
//邀请人二维码存放路径
String filePathWeChatCodeUrl = xinYiLuConfig.getPersonalWeChatCodeUrl();
String appletCodePicture = AppletChatUtil.createAppletCode(inviteId, false, fileName, appletPageUrl, filePathWeChatCodeUrl);
String appletCodePicture = appletChatUtil.createAppletCode(inviteId, false, fileName, appletPageUrl, filePathWeChatCodeUrl);
if (StringUtils.isNotBlank(appletCodePicture) && StringUtils.equals(FAIL, appletCodePicture)) {
//第一次调用获取小程序二维码信息失败重新递归调用一次第二次失败直接返回提示信息
appletCodePicture = AppletChatUtil.createAppletCode(inviteId, true, fileName, appletPageUrl, filePathWeChatCodeUrl);
appletCodePicture = appletChatUtil.createAppletCode(inviteId, true, fileName, appletPageUrl, filePathWeChatCodeUrl);
if (StringUtils.isNotBlank(appletCodePicture) && StringUtils.equals(FAIL, appletCodePicture)) {
return AjaxResult.error("获取小程序二维码信息失败,请联系管理员!");
}

View File

@ -127,4 +127,12 @@ public interface PatientCouponReceiveMapper {
* @return 会员用户优惠券领取记录
*/
PatientCouponReceiveInfoVO selectPatientCouponReceive(@Param("patientId") Long patientId, @Param("couponId") Long couponId);
/**
*
* @param patientId 用户id
* @param receiveSource 优惠券状态
* @return int
*/
int getCouponReceiveByReceiveSource(@Param("patientId") Long patientId, @Param("receiveSource") String receiveSource);
}

View File

@ -69,6 +69,8 @@ public class NurseStationServiceImpl implements INurseStationService {
private AppletPageConfig appletPageConfig;
@Resource
private XinELuConfig xinYiLuConfig;
@Resource
private AppletChatUtil appletChatUtil;
/**
* 护理站营业时间默认值
@ -457,18 +459,18 @@ public class NurseStationServiceImpl implements INurseStationService {
case Constants.PERSON_CERTIFICATE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getPersonCertificateUrl();
break;
case Constants.PLATELET_PICTURE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getPlateletPitureUrl();
break;
case Constants.LEFT_EYE_PICTURE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getLeftEyePitureUrl();
break;
case Constants.RIGHT_EYE_PICTURE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getRightEyePitureUrl();
break;
case Constants.ALZHEIMER_FILE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getAlzheimerFileUrl();
break;
case Constants.PLATELET_PICTURE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getPlateletPitureUrl();
break;
case Constants.LEFT_EYE_PICTURE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getLeftEyePitureUrl();
break;
case Constants.RIGHT_EYE_PICTURE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getRightEyePitureUrl();
break;
case Constants.ALZHEIMER_FILE_URL:
uploadPathUrl = XinELuConfig.getProfile() + xinELuConfig.getAlzheimerFileUrl();
break;
default:
break;
}
@ -476,12 +478,12 @@ public class NurseStationServiceImpl implements INurseStationService {
return AjaxResult.success();
}
//上传
String pictureName = "";
if (StringUtils.isNotBlank(type) && StringUtils.equals(type, Constants.ALZHEIMER_FILE_URL)) {
pictureName = FileUploadUtils.uploadNurseStationPath(uploadPathUrl, multipartFile, MimeTypeUtils.FILE_EXTENSION);
} else {
pictureName = FileUploadUtils.uploadNurseStationPath(uploadPathUrl, multipartFile, MimeTypeUtils.IMAGE_EXTENSION);
}
String pictureName = "";
if (StringUtils.isNotBlank(type) && StringUtils.equals(type, Constants.ALZHEIMER_FILE_URL)) {
pictureName = FileUploadUtils.uploadNurseStationPath(uploadPathUrl, multipartFile, MimeTypeUtils.FILE_EXTENSION);
} else {
pictureName = FileUploadUtils.uploadNurseStationPath(uploadPathUrl, multipartFile, MimeTypeUtils.IMAGE_EXTENSION);
}
if (StringUtils.isBlank(pictureName)) {
throw new ServiceException("图片上传失败,请联系管理员!");
@ -617,10 +619,10 @@ public class NurseStationServiceImpl implements INurseStationService {
String appletPageUrl = appletPageConfig.getNurseStationDetailsPageUrl();
//机构二维码存放路径
String filePathWeChatCodeUrl = xinYiLuConfig.getStationWechatCodeUrl();
String appletCodePicture = AppletChatUtil.createAppletCode(nurseStationId, false, fileName, appletPageUrl, filePathWeChatCodeUrl);
String appletCodePicture = appletChatUtil.createAppletCode(nurseStationId, false, fileName, appletPageUrl, filePathWeChatCodeUrl);
if (StringUtils.isNotBlank(appletCodePicture) && StringUtils.equals(FAIL, appletCodePicture)) {
//第一次调用获取小程序二维码信息失败重新递归调用一次第二次失败直接返回提示信息
appletCodePicture = AppletChatUtil.createAppletCode(nurseStationId, true, fileName, appletPageUrl, filePathWeChatCodeUrl);
appletCodePicture = appletChatUtil.createAppletCode(nurseStationId, true, fileName, appletPageUrl, filePathWeChatCodeUrl);
if (StringUtils.isNotBlank(appletCodePicture) && StringUtils.equals(FAIL, appletCodePicture)) {
return AjaxResult.error("获取小程序二维码信息失败,请联系管理员!");
}

View File

@ -363,4 +363,12 @@
where pcr.patient_id = #{patientId}
and pcr.coupon_id = #{couponId}
</select>
<select id="getCouponReceiveByReceiveSource" resultType="java.lang.Integer">
select
count(1)
where
patient_id = #{patientId}
and receive_source = #{receiveSource}
</select>
</mapper>