Parcourir la source

益寿缘app-完善App创建商城订单接口

cgp il y a 4 jours
Parent
commit
7b114ed012

+ 51 - 0
fs-admin/src/main/java/com/fs/company/controller/PollingAssignDoctorController.java

@@ -0,0 +1,51 @@
+package com.fs.company.controller;
+
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.his.dto.AssignmentRecordQueryRequest;
+import com.fs.his.service.IPollingAssignDoctorService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * 药师分配详情Controller
+ *
+ * @author cgp
+ * @date 2026-03-06
+ */
+@RestController
+@RequestMapping("/qw/pollingAssignDoctor")
+public class PollingAssignDoctorController {
+
+    @Autowired
+    private IPollingAssignDoctorService pollingAssignDoctorService;
+
+    /**
+     * 分页查询药师分配记录
+     * @param query 查询参数
+     * @return 表格分页数据
+     */
+    @GetMapping("/records/page")
+    public TableDataInfo getRecordsByDateWithPage(@Valid AssignmentRecordQueryRequest query) {
+        // 如果没有传日期,默认使用当天
+        if (query.getQueryDate() == null || query.getQueryDate().isEmpty()) {
+            query.setQueryDate(new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date()));
+        }
+
+        // 如果传了药师ID,查询该药师的记录
+        if (query.getDoctorId() != null) {
+            return pollingAssignDoctorService.getRecordsByDoctorAndDateWithPage(
+                    query.getDoctorId(),
+                    query.getQueryDate(),
+                    query.getPageNum(),
+                    query.getPageSize());
+        }
+
+        // 否则查询当天所有记录
+        return pollingAssignDoctorService.getRecordsByDateWithPage(
+                query.getQueryDate(),
+                query.getPageNum(),
+                query.getPageSize());
+    }
+}

+ 22 - 0
fs-company/src/main/java/com/fs/company/controller/company/OpenApiFsUserInformationController.java

@@ -0,0 +1,22 @@
+package com.fs.company.controller.company;
+
+import com.fs.hisStore.service.IOpenApiFsUserInformationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/index/statistics")
+public class OpenApiFsUserInformationController {
+
+    @Autowired
+    private IOpenApiFsUserInformationService openApiFsUserInformationService;
+
+    /**
+     * 获取信息采集问题模板
+     * */
+
+    /**
+     * 提交用户采集信息
+     * */
+}

+ 35 - 0
fs-service/src/main/java/com/fs/his/dto/AssignmentRecordQueryRequest.java

@@ -0,0 +1,35 @@
+package com.fs.his.dto;
+
+import lombok.Data;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Pattern;
+
+/**
+ * 药师分配记录查询请求
+ */
+@Data
+public class AssignmentRecordQueryRequest {
+    
+    /**
+     * 页码(默认第1页)
+     */
+    @Min(value = 1, message = "页码最小为1")
+    private Integer pageNum = 1;
+    
+    /**
+     * 每页条数(默认20条)
+     */
+    @Min(value = 1, message = "每页条数最小为1")
+    private Integer pageSize = 200;
+    
+    /**
+     * 查询日期(yyyy-MM-dd,不传则默认当天)
+     */
+    @Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2}$", message = "日期格式错误,应为yyyy-MM-dd")
+    private String queryDate;
+    
+    /**
+     * 药师ID(可选)
+     */
+    private Long doctorId;
+}

+ 74 - 0
fs-service/src/main/java/com/fs/his/service/IPollingAssignDoctorService.java

@@ -0,0 +1,74 @@
+package com.fs.his.service;
+
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.his.domain.FsDoctor;
+import java.util.List;
+
+public interface IPollingAssignDoctorService {
+
+    /**
+     * 获取下一个分配的药师(轮询分配)
+     * @param prescribeCode 处方编号
+     * @return 药师对象
+     */
+    FsDoctor getNextPharmacist(String prescribeCode);
+
+    /**
+     * 获取下一个分配的药师,并关联业务ID(兼容旧方法)
+     * @param businessId 业务ID(处方编号)
+     * @return 药师对象
+     */
+    FsDoctor getNextPharmacistWithPrescribeCode(String businessId);
+
+    /**
+     * 根据处方编号查询分配的药师
+     * @param prescribeCode 处方编号
+     * @return 分配记录字符串
+     */
+    String getPharmacistByPrescribeCode(String prescribeCode);
+
+    /**
+     * 查询某天的所有分配记录
+     * @param date 日期(yyyy-MM-dd)
+     * @return 记录列表
+     */
+    List<String> getRecordsByDate(String date);
+
+    /**
+     * 查询某药师某天的分配记录
+     * @param doctorId 药师ID
+     * @param date 日期(yyyy-MM-dd)
+     * @return 记录列表
+     */
+    List<String> getRecordsByDoctorAndDate(Long doctorId, String date);
+
+    /**
+     * 重置轮询计数器
+     */
+    void resetRoundRobin();
+
+    /**
+     * 获取当前轮询索引
+     * @return 当前索引值
+     */
+    Long getCurrentIndex();
+
+    /**
+     * 分页查询分配记录
+     * @param date 日期(yyyy-MM-dd)
+     * @param pageNum 页码
+     * @param pageSize 每页条数
+     * @return 表格分页数据
+     */
+    TableDataInfo getRecordsByDateWithPage(String date, Integer pageNum, Integer pageSize);
+
+    /**
+     * 分页查询某药师的分配记录
+     * @param doctorId 药师ID
+     * @param date 日期(yyyy-MM-dd)
+     * @param pageNum 页码
+     * @param pageSize 每页条数
+     * @return 表格分页数据
+     */
+    TableDataInfo getRecordsByDoctorAndDateWithPage(Long doctorId, String date, Integer pageNum, Integer pageSize);
+}

+ 16 - 15
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -129,6 +129,9 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     @Autowired
     private IFsUserInformationCollectionService fsUserInformationCollectionService;
 
+    @Autowired
+    private IPollingAssignDoctorService pollingAssignDoctorService;
+
     @Autowired
     private ApplicationContext applicationContext;
 
@@ -804,7 +807,8 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         fsPrescribe.setUsageJson(jsonString);
 
         fsPrescribe.setUserId(packageOrder.getUserId());
-        fsPrescribe.setPrescribeCode(IdUtil.getSnowflake(0, 0).nextIdStr());
+        String prescribeCode=IdUtil.getSnowflake(0, 0).nextIdStr();
+        fsPrescribe.setPrescribeCode(prescribeCode);
         FsPackagePatientDTO patJson = JSON.parseObject(packageOrder.getPatientJson(),FsPackagePatientDTO.class);
         if (patJson.getBirthday() == null) {
             patJson.setBirthday(-285753600000L);
@@ -829,23 +833,20 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         fsPrescribe.setPrescribeDoctorSignUrl(fsDoctor.getSignUrl());
 
         //分配在线的随机药师
-        List<FsDoctor> onlineDoctors = doctorMapper.selectRandomOnlineDoctorForPackage();
         FsDoctor fsDrugDoctor = null;
+        try {
+            // 使用新写的轮询服务分配药师,传入处方编号
+            fsDrugDoctor = pollingAssignDoctorService.getNextPharmacist(prescribeCode);
 
-        if (onlineDoctors != null && !onlineDoctors.isEmpty()) {
-            // 有在线药师:应用层随机选一个
-            Collections.shuffle(onlineDoctors);
-            fsDrugDoctor = onlineDoctors.get(0);
-        } else {
-            // 兜底:无在线药师,随机选一个 type=2 的(不管是否在线)
-            fsDrugDoctor = doctorMapper.selectPackageFsDoctorType2Ids();
-            if (fsDrugDoctor == null) {
-                log.error("无法分配药师:productType={}, 无可用在线或离线药师", fsPackage.getProductType());
-                throw new CustomException("当前无可用药师,请稍后再试");
-            }
+            fsPrescribe.setDrugDoctorId(fsDrugDoctor.getDoctorId());
+            fsPrescribe.setDrugDoctorSignUrl(fsDrugDoctor.getSignUrl());
+
+            log.info("轮询分配药师成功 - 处方号:{}, 药师ID:{}, 药师姓名:{}",
+                    prescribeCode, fsDrugDoctor.getDoctorId(), fsDrugDoctor.getDoctorName());
+        } catch (Exception e) {
+            log.error("分配药师失败 - 处方号:{}", prescribeCode, e);
+            fsPrescribe.setDrugDoctorId(1L);//为了不影响主业务执行设置默认值
         }
-        fsPrescribe.setDrugDoctorId(fsDrugDoctor.getDoctorId());
-        fsPrescribe.setDrugDoctorSignUrl(fsDrugDoctor.getSignUrl());
 
         int i = fsPrescribeMapper.insertFsPrescribe(fsPrescribe);
         if(i>0){

+ 370 - 0
fs-service/src/main/java/com/fs/his/service/impl/IPollingAssignDoctorServiceImpl.java

@@ -0,0 +1,370 @@
+package com.fs.his.service.impl;
+
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
+import com.fs.his.domain.FsDoctor;
+import com.fs.his.mapper.FsDoctorMapper;
+import com.fs.his.service.IPollingAssignDoctorService;
+import com.fs.his.vo.PharmacistAssignmentVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class IPollingAssignDoctorServiceImpl implements IPollingAssignDoctorService {
+
+    @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
+    private FsDoctorMapper doctorMapper;
+
+    // 轮询计数器key
+    private static final String ROUND_ROBIN_INDEX_KEY = "pharmacist:round:index";
+
+    // 分配记录key前缀(用于后续查询)
+    private static final String ASSIGNMENT_RECORD_KEY_PREFIX = "pharmacist:assign:record:";
+
+    // 处方关联记录key前缀
+    private static final String PRESCRIBE_ASSIGN_KEY_PREFIX = "pharmacist:prescribe:";
+
+    @Override
+    public FsDoctor getNextPharmacist(String prescribeCode) {
+        // 1. 实时从数据库查询在线药师(按ID排序保证顺序)
+        List<FsDoctor> onlineDoctors = doctorMapper.selectRandomOnlineDoctorForPackage();
+
+        FsDoctor selectedDoctor;
+        boolean isOnline;
+        int onlineCount = onlineDoctors != null ? onlineDoctors.size() : 0;
+
+        if (onlineDoctors != null && !onlineDoctors.isEmpty()) {
+            // 有在线药师
+            if (onlineDoctors.size() == 1) {
+                // 只有一个在线药师,直接分配
+                selectedDoctor = onlineDoctors.get(0);
+                log.info("只有一个在线药师 - ID:{}, 姓名:{}",
+                        selectedDoctor.getDoctorId(), selectedDoctor.getDoctorName());
+            } else {
+                // 多个在线药师,轮询分配
+                selectedDoctor = roundRobinSelect(onlineDoctors);
+                log.info("轮询分配在线药师 - ID:{}, 姓名:{}, 当前在线药师数:{}",
+                        selectedDoctor.getDoctorId(), selectedDoctor.getDoctorName(), onlineCount);
+            }
+            isOnline = true;
+        } else {
+            // 无在线药师:兜底分配离线药师
+            selectedDoctor = getOfflinePharmacist();
+            isOnline = false;
+            onlineCount = 0;
+            log.info("无在线药师,分配离线药师 - ID:{}, 姓名:{}",
+                    selectedDoctor.getDoctorId(), selectedDoctor.getDoctorName());
+        }
+
+        // 2. 保存完整的分配记录(关联处方编号)
+        saveAssignmentRecord(selectedDoctor, prescribeCode, isOnline, onlineCount);
+
+        return selectedDoctor;
+    }
+
+    @Override
+    public FsDoctor getNextPharmacistWithPrescribeCode(String prescribeCode) {
+        return getNextPharmacist(prescribeCode);
+    }
+
+    /**
+     * 轮询选择药师(支持1-N个药师)
+     * @param onlineDoctors 当前在线的药师列表(实时查询的)
+     */
+    private FsDoctor roundRobinSelect(List<FsDoctor> onlineDoctors) {
+        // 如果只有1个药师,直接返回(不需要轮询)
+        if (onlineDoctors.size() == 1) {
+            return onlineDoctors.get(0);
+        }
+
+        // Redis原子自增实现轮询(2个及以上药师才需要)
+        Long index = redisCache.incr(ROUND_ROBIN_INDEX_KEY, 1L);
+
+        // 设置过期时间(7天,避免key永久存在)
+        if (index == 1) {
+            redisCache.expire(ROUND_ROBIN_INDEX_KEY, 7, TimeUnit.DAYS);
+        }
+
+        // 计算真实索引(从0开始,适配list下标从0开始)
+        int realIndex = (int)((index - 1) % onlineDoctors.size());
+
+        log.debug("轮询计数器 - 当前值:{}, 在线药师总数:{}, 选中索引:{}",
+                index, onlineDoctors.size(), realIndex);
+
+        return onlineDoctors.get(realIndex);
+    }
+
+    /**
+     * 获取离线药师(兜底)
+     */
+    private FsDoctor getOfflinePharmacist() {
+        FsDoctor doctor = doctorMapper.selectPackageFsDoctorType2Ids();
+        if (doctor == null) {
+            log.error("无可用药师");
+            throw new CustomException("当前无可用药师,请稍后再试");
+        }
+        return doctor;
+    }
+
+    /**
+     * 保存完整的分配记录(关联处方编号)
+     */
+    private void saveAssignmentRecord(FsDoctor doctor, String prescribeCode, boolean isOnline, int onlineCount) {
+        try {
+            String dateKey = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date());
+            String timeKey = new java.text.SimpleDateFormat("HH:mm:ss").format(new java.util.Date());
+
+            // 记录ID:时间戳_处方编号
+            String recordId = System.currentTimeMillis() + "_" + prescribeCode;
+
+            // 记录格式:记录ID|时间|处方编号|药师ID|药师姓名|是否在线|在线药师总数
+            String recordValue = recordId + "|" +
+                    timeKey + "|" +
+                    prescribeCode + "|" +
+                    doctor.getDoctorId() + "|" +
+                    doctor.getDoctorName() + "|" +
+                    (isOnline ? "在线" : "离线") + "|" +
+                    onlineCount;
+
+            // 1. 按日期存储的列表(用于按日期查询)
+            String dateListKey = ASSIGNMENT_RECORD_KEY_PREFIX + dateKey;
+            redisCache.setVoice(dateListKey, recordValue);
+            redisCache.expire(dateListKey, 3, TimeUnit.DAYS);
+
+            // 2. 按处方编号存储(用于通过处方号反查)
+            String prescribeKey = PRESCRIBE_ASSIGN_KEY_PREFIX + prescribeCode;
+            redisCache.setCacheObject(prescribeKey, recordValue, 3 * 24 * 60 * 60, TimeUnit.SECONDS);
+
+            // 3. 按药师ID存储的列表(用于查询某个药师的分配记录)
+            String doctorKey = ASSIGNMENT_RECORD_KEY_PREFIX + "doctor:" + doctor.getDoctorId() + ":" + dateKey;
+            redisCache.setVoice(doctorKey, recordValue);
+            redisCache.expire(doctorKey, 3, TimeUnit.DAYS);
+
+            log.debug("保存分配记录成功 - 处方号:{}, 药师:{}, 记录ID:{}",
+                    prescribeCode, doctor.getDoctorName(), recordId);
+
+        } catch (Exception e) {
+            log.error("保存分配记录失败 - 处方号:{}, 药师ID:{}", prescribeCode, doctor.getDoctorId(), e);
+            // 不影响主流程
+        }
+    }
+
+    /**
+     * 根据处方编号查询分配的药师
+     */
+    @Override
+    public String getPharmacistByPrescribeCode(String prescribeCode) {
+        try {
+            String prescribeKey = PRESCRIBE_ASSIGN_KEY_PREFIX + prescribeCode;
+            return redisCache.getCacheObject(prescribeKey);
+        } catch (Exception e) {
+            log.error("查询处方分配记录失败 - 处方号:{}", prescribeCode, e);
+            return null;
+        }
+    }
+
+    /**
+     * 查询某天的所有分配记录
+     */
+    @Override
+    public List<String> getRecordsByDate(String date) {
+        try {
+            String dateListKey = ASSIGNMENT_RECORD_KEY_PREFIX + date;
+            return redisCache.getCacheList(dateListKey);
+        } catch (Exception e) {
+            log.error("查询日期分配记录失败 - 日期:{}", date, e);
+            return null;
+        }
+    }
+
+    /**
+     * 查询某药师某天的分配记录
+     */
+    @Override
+    public List<String> getRecordsByDoctorAndDate(Long doctorId, String date) {
+        try {
+            String doctorKey = ASSIGNMENT_RECORD_KEY_PREFIX + "doctor:" + doctorId + ":" + date;
+            return redisCache.getCacheList(doctorKey);
+        } catch (Exception e) {
+            log.error("查询药师分配记录失败 - 药师ID:{}, 日期:{}", doctorId, date, e);
+            return null;
+        }
+    }
+
+    /**
+     * 重置轮询计数器(可选,一般用于测试)
+     */
+    @Override
+    public void resetRoundRobin() {
+        redisCache.deleteObject(ROUND_ROBIN_INDEX_KEY);
+        log.info("轮询计数器已重置");
+    }
+
+    /**
+     * 获取当前轮询索引(可选,用于监控)
+     */
+    @Override
+    public Long getCurrentIndex() {
+        return redisCache.getCacheObject(ROUND_ROBIN_INDEX_KEY);
+    }
+
+    // ========== 新增的分页查询方法 ==========
+
+    @Override
+    public TableDataInfo getRecordsByDateWithPage(String date, Integer pageNum, Integer pageSize) {
+        try {
+            // 1. 获取当天的所有记录
+            List<String> records = getRecordsByDate(date);
+            if (records == null || records.isEmpty()) {
+                TableDataInfo dataInfo = new TableDataInfo(new ArrayList<>(), 0);
+                dataInfo.setCode(200);
+                dataInfo.setMsg("查询成功");
+                return dataInfo;
+            }
+
+            // 2. 转换为VO并排序(最新的在前面)
+            List<PharmacistAssignmentVO> voList = convertToVOList(records, date);
+
+            // 3. 计算分页
+            int total = voList.size();
+            int fromIndex = (pageNum - 1) * pageSize;
+            int toIndex = Math.min(fromIndex + pageSize, total);
+
+            List<PharmacistAssignmentVO> pageList;
+            if (fromIndex >= total) {
+                pageList = new ArrayList<>();
+            } else {
+                pageList = voList.subList(fromIndex, toIndex);
+            }
+
+            // 4. 返回TableDataInfo
+            TableDataInfo dataInfo = new TableDataInfo(pageList, total);
+            dataInfo.setCode(200);
+            dataInfo.setMsg("查询成功");
+            return dataInfo;
+
+        } catch (Exception e) {
+            log.error("分页查询分配记录失败 - 日期:{}", date, e);
+            TableDataInfo dataInfo = new TableDataInfo(new ArrayList<>(), 0);
+            dataInfo.setCode(500);
+            dataInfo.setMsg("查询失败:" + e.getMessage());
+            return dataInfo;
+        }
+    }
+
+    @Override
+    public TableDataInfo getRecordsByDoctorAndDateWithPage(Long doctorId, String date, Integer pageNum, Integer pageSize) {
+        try {
+            // 1. 获取药师当天的记录
+            List<String> records = getRecordsByDoctorAndDate(doctorId, date);
+            if (records == null || records.isEmpty()) {
+                TableDataInfo dataInfo = new TableDataInfo(new ArrayList<>(), 0);
+                dataInfo.setCode(200);
+                dataInfo.setMsg("查询成功");
+                return dataInfo;
+            }
+
+            // 2. 转换为VO并排序
+            List<PharmacistAssignmentVO> voList = convertToVOList(records, date);
+
+            // 3. 计算分页
+            int total = voList.size();
+            int fromIndex = (pageNum - 1) * pageSize;
+            int toIndex = Math.min(fromIndex + pageSize, total);
+
+            List<PharmacistAssignmentVO> pageList;
+            if (fromIndex >= total) {
+                pageList = new ArrayList<>();
+            } else {
+                pageList = voList.subList(fromIndex, toIndex);
+            }
+
+            // 4. 返回TableDataInfo
+            TableDataInfo dataInfo = new TableDataInfo(pageList, total);
+            dataInfo.setCode(200);
+            dataInfo.setMsg("查询成功");
+            return dataInfo;
+
+        } catch (Exception e) {
+            log.error("分页查询药师分配记录失败 - 药师ID:{}, 日期:{}", doctorId, date, e);
+            TableDataInfo dataInfo = new TableDataInfo(new ArrayList<>(), 0);
+            dataInfo.setCode(500);
+            dataInfo.setMsg("查询失败:" + e.getMessage());
+            return dataInfo;
+        }
+    }
+
+    /**
+     * 将Redis记录列表转换为VO列表(按时间倒序)
+     */
+    private List<PharmacistAssignmentVO> convertToVOList(List<String> records, String date) {
+        List<PharmacistAssignmentVO> voList = new ArrayList<>();
+
+        for (String record : records) {
+            PharmacistAssignmentVO vo = parseRecordToVO(record);
+            if (vo != null) {
+                vo.setAssignDate(date);
+                voList.add(vo);
+            }
+        }
+
+        // 按recordId倒序排序(最新的在前面)
+        voList.sort((a, b) -> b.getRecordId().compareTo(a.getRecordId()));
+
+        return voList;
+    }
+
+    /**
+     * 解析单条记录为VO
+     */
+    private PharmacistAssignmentVO parseRecordToVO(String record) {
+        try {
+            String[] parts = record.split("\\|");
+            if (parts.length >= 7) {
+                PharmacistAssignmentVO vo = new PharmacistAssignmentVO();
+                vo.setRecordId(parts[0]);           // 记录ID(包含时间戳)
+                vo.setAssignTime(parts[1]);          // 分配时间
+                vo.setPrescribeCode(parts[2]);       // 处方编号
+                vo.setDoctorId(Long.parseLong(parts[3])); // 药师ID
+                vo.setDoctorName(parts[4]);           // 药师姓名
+                vo.setOnlineStatus(parts[5]);         // 在线状态
+                vo.setOnlineCount(Integer.parseInt(parts[6])); // 在线药师总数
+                return vo;
+            }
+        } catch (Exception e) {
+            log.error("解析记录失败: {}", record, e);
+        }
+        return null;
+    }
+
+    /**
+     * 获取当前药师数量情况(用于监控)
+     */
+    public java.util.Map<String, Object> getPharmacistStats() {
+        java.util.Map<String, Object> stats = new java.util.HashMap<>();
+
+        List<FsDoctor> onlineDoctors = doctorMapper.selectRandomOnlineDoctorForPackage();
+        stats.put("onlineCount", onlineDoctors != null ? onlineDoctors.size() : 0);
+        stats.put("onlineDoctors", onlineDoctors != null ?
+                onlineDoctors.stream()
+                        .map(d -> d.getDoctorId() + "-" + d.getDoctorName())
+                        .collect(Collectors.toList()) :
+                new ArrayList<>());
+
+        stats.put("currentIndex", redisCache.getCacheObject(ROUND_ROBIN_INDEX_KEY));
+        stats.put("usingRoundRobin", onlineDoctors != null && onlineDoctors.size() > 1);
+
+        return stats;
+    }
+}

+ 0 - 10
fs-service/src/main/java/com/fs/his/strategy/impl/FirstLoginProductStrategy.java

@@ -32,9 +32,6 @@ public class FirstLoginProductStrategy implements RewardStrategy {
 
     @Autowired
     private IFsStoreOrderScrmService storeOrderScrmService;
-
-    @Autowired
-    private IFsStoreProductScrmService storeProductScrmService;
     @Override
     public RewardResult process(FsUserRewards reward) {
         log.info("处理首次登录商品发放: rewardId={}", reward.getId());
@@ -110,14 +107,7 @@ public class FirstLoginProductStrategy implements RewardStrategy {
     }
 
     private FsStoreOrderCreateParamAppReward buildStoreOrderCreateParam(FsUserRewards reward, FsUser fsUser) {
-        FsStoreProductScrm fsStoreProductScrm = storeProductScrmService.selectFsStoreProductById(reward.getGoodsId());
-        if (fsStoreProductScrm == null){
-            log.error("商城商品不存在: {}", reward.getGoodsId());
-            throw new CustomException("商城商品不存在");
-        }
         FsStoreOrderCreateParamAppReward param = new FsStoreOrderCreateParamAppReward();
-        param.setCostPrice(fsStoreProductScrm.getCostPrice());
-        param.setErpType(fsStoreProductScrm.getErpType());
         param.setAppRewardFlag(1);//首次注册奖品订单标识
         param.setPayType("1");//全款
         param.setCompanyId(reward.getCompanyId());

+ 0 - 10
fs-service/src/main/java/com/fs/his/strategy/impl/WatchCourseProductStrategy.java

@@ -30,9 +30,6 @@ public class WatchCourseProductStrategy  implements RewardStrategy {
     @Autowired
     private IFsPackageOrderService packageOrderService;
 
-    @Autowired
-    private IFsStoreProductScrmService storeProductScrmService;
-
     @Autowired
     private IFsStoreOrderScrmService storeOrderScrmService;
     @Override
@@ -109,14 +106,7 @@ public class WatchCourseProductStrategy  implements RewardStrategy {
         return param;
     }
     private FsStoreOrderCreateParamAppReward buildStoreOrderCreateParam(FsUserRewards reward, FsUser fsUser) {
-        FsStoreProductScrm fsStoreProductScrm = storeProductScrmService.selectFsStoreProductById(reward.getGoodsId());
-        if (fsStoreProductScrm == null){
-            log.error("商城商品不存在: {}", reward.getGoodsId());
-            throw new CustomException("商城商品不存在");
-        }
         FsStoreOrderCreateParamAppReward param = new FsStoreOrderCreateParamAppReward();
-        param.setCostPrice(fsStoreProductScrm.getCostPrice());
-        param.setErpType(fsStoreProductScrm.getErpType());
         param.setAppRewardFlag(2);//2:看课奖品订单
         param.setPayType("1");//全款
         param.setCompanyId(reward.getCompanyId());

+ 52 - 0
fs-service/src/main/java/com/fs/his/vo/PharmacistAssignmentVO.java

@@ -0,0 +1,52 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+import java.io.Serializable;
+
+/**
+ * 药师分配记录VO(用于前端展示)
+ */
+@Data
+public class PharmacistAssignmentVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+    
+    /**
+     * 记录ID
+     */
+    private String recordId;
+    
+    /**
+     * 分配时间(HH:mm:ss)
+     */
+    private String assignTime;
+    
+    /**
+     * 处方编号
+     */
+    private String prescribeCode;
+    
+    /**
+     * 药师ID
+     */
+    private Long doctorId;
+    
+    /**
+     * 药师姓名
+     */
+    private String doctorName;
+    
+    /**
+     * 是否在线(在线/离线)
+     */
+    private String onlineStatus;
+    
+    /**
+     * 当时在线药师总数
+     */
+    private Integer onlineCount;
+    
+    /**
+     * 分配日期
+     */
+    private String assignDate;
+}

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/service/IOpenApiFsUserInformationService.java

@@ -0,0 +1,11 @@
+package com.fs.hisStore.service;
+
+public interface IOpenApiFsUserInformationService {
+    /**
+     * 获取信息采集问题模板
+     * */
+
+    /**
+     * 提交用户采集信息
+     * */
+}

+ 24 - 10
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -1021,6 +1021,23 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Override
     @Transactional
     public R createOrderScrmForAppRewards(long userId, FsStoreOrderCreateParamAppReward param) {
+        FsStoreProductScrm fsStoreProductScrm = fsStoreProductMapper.selectFsStoreProductById(param.getGoodsId());
+        if (fsStoreProductScrm == null){
+            log.error("商城商品不存在: {}", param.getGoodsId());
+            return R.error("订单创建失败");
+        }
+        if (fsStoreProductScrm.getIsShow().compareTo(BigDecimal.ZERO.intValue()) == 0) {
+            log.error("商城商品已下架: {}", param.getGoodsId());
+            return R.error("订单创建失败");
+        }
+        Long stock = fsStoreProductScrm.getStock();
+        BigDecimal stockDecimal = new BigDecimal(stock != null ? stock : 0);
+        if (stockDecimal.compareTo(BigDecimal.ZERO) <= 0) {
+            log.error("商城商品库存不足: {}", param.getGoodsId());
+            return R.error("订单创建失败");
+        }
+        param.setCostPrice(fsStoreProductScrm.getCostPrice());
+        param.setErpType(fsStoreProductScrm.getErpType());
         FsStoreOrderComputedParam computedParam = new FsStoreOrderComputedParam();
         BeanUtils.copyProperties(param, computedParam);
         FsStoreProductAttrValueScrm fsStoreProductAttrValueScrm = fsStoreProductAttrValueMapper.selectProductAttrValueByProductId(param.getGoodsId());
@@ -1108,19 +1125,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         FsStoreCartDTO fsStoreCartDTO = new FsStoreCartDTO();
         fsStoreCartDTO.setProductId(vo.getProductId());
         fsStoreCartDTO.setPrice(vo.getPrice());
-        fsStoreCartDTO.setSku(vo.getProductAttrName());
-        fsStoreCartDTO.setProductName(vo.getProductName());
+        fsStoreCartDTO.setSku("默认");
+        fsStoreCartDTO.setProductName(fsStoreProductScrm.getProductName());
         fsStoreCartDTO.setNum(vo.getCartNum());
         fsStoreCartDTO.setBarCode(vo.getBarCode());
         fsStoreCartDTO.setGroupBarCode(vo.getGroupBarCode());
-        fsStoreCartDTO.setBrokerage(vo.getBrokerage());
-        fsStoreCartDTO.setBrokerageTwo(vo.getBrokerageTwo());
-        fsStoreCartDTO.setBrokerageThree(vo.getBrokerageThree());
-        if (StringUtils.isEmpty(vo.getProductAttrImage())) {
-            fsStoreCartDTO.setImage(vo.getProductImage());
-        } else {
-            fsStoreCartDTO.setImage(vo.getProductAttrImage());
-        }
+        BigDecimal brokerage = new BigDecimal(0);//暂定默认为0
+        fsStoreCartDTO.setBrokerage(brokerage);
+        fsStoreCartDTO.setBrokerageTwo(brokerage);
+        fsStoreCartDTO.setBrokerageThree(brokerage);
+        fsStoreCartDTO.setImage(fsStoreProductScrm.getImage());
 
         FsStoreOrderItemScrm item = new FsStoreOrderItemScrm();
         item.setOrderId(storeOrder.getId());

+ 10 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/OpenApiFsUserInformationServiceImpl.java

@@ -0,0 +1,10 @@
+package com.fs.hisStore.service.impl;
+
+import com.fs.hisStore.service.IOpenApiFsUserInformationService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class OpenApiFsUserInformationServiceImpl implements IOpenApiFsUserInformationService {
+}

+ 6 - 6
fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java

@@ -77,12 +77,12 @@ public class HuiFuServiceImpl implements HuiFuService {
             // 禁用信用卡标记
             extendInfoMap.put("limit_pay_type", "NO_CREDIT");
             // 是否延迟交易 Y 为延迟 N为不延迟,不传默认N
-            if (order.getIsDelay() == 1) {
-                extendInfoMap.put("delay_acct_flag", "Y");
-            } else {
-                extendInfoMap.put("delay_acct_flag", "N");
-            }
-            //extendInfoMap.put("delay_acct_flag", "N");
+            //if (order.getIsDelay() == 1) {
+                //extendInfoMap.put("delay_acct_flag", "Y");
+            //} else {
+                //extendInfoMap.put("delay_acct_flag", "N");
+            //}
+            extendInfoMap.put("delay_acct_flag", "N");
             extendInfoMap.put("pay_scene", "02");
             // 传入分帐遇到优惠的处理规则 1: 按比例分,2: 按分账明细顺序保障,3: 只给交易商户(默认)
             extendInfoMap.put("term_div_coupon_type", "0");

+ 1 - 0
fs-service/src/main/resources/mapper/his/FsDoctorMapper.xml

@@ -134,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND d.is_audit = 1
           AND d.sign_url IS NOT NULL
           AND o.is_online = 1
+          ORDER BY d.doctor_id ASC
     </select>
 
     <insert id="insertFsDoctor" parameterType="FsDoctor" useGeneratedKeys="true" keyProperty="doctorId">