ct 1 周之前
父節點
當前提交
0a00ae4245

+ 33 - 0
fs-service/src/main/java/com/fs/his/dto/PackageOrderDTO.java

@@ -0,0 +1,33 @@
+package com.fs.his.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class PackageOrderDTO {
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间")
+    private Date payTime;
+
+    private Date createTime;
+
+    /** 套餐名称 */
+    @Excel(name = "套餐名称")
+    private String packageName;
+
+    /** 用户ID */
+    @Excel(name = "用户ID")
+    private Long userId;
+
+    /** 订单号 */
+    @Excel(name = "订单号")
+    private String orderSn;
+
+    private String fsUserName;
+
+
+}

+ 3 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPackageOrderMapper.java

@@ -5,6 +5,7 @@ import java.util.List;
 import com.fs.his.domain.FsPackage;
 import com.fs.his.domain.FsPackageOrder;
 import com.fs.his.domain.FsStorePayment;
+import com.fs.his.dto.PackageOrderDTO;
 import com.fs.his.param.FsPackageOrderListUParam;
 import com.fs.his.param.FsPackageOrderParam;
 import com.fs.his.vo.FsPackageOrderExcelVO;
@@ -219,4 +220,6 @@ public interface FsPackageOrderMapper
     Long selectFsPackageOrderExcelListVOCount(FsPackageOrderParam fsPackageOrder);
 
     FsPackage selectFsPackageByOrderId(Long packageOrderId);
+
+    List<PackageOrderDTO> getNewOrder();
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/service/IFsPackageOrderService.java

@@ -6,6 +6,7 @@ import com.fs.common.core.domain.R;
 import com.fs.his.domain.FsPackage;
 import com.fs.his.domain.FsPackageOrder;
 import com.fs.his.domain.FsStorePayment;
+import com.fs.his.dto.PackageOrderDTO;
 import com.fs.his.param.*;
 import com.fs.his.vo.FsPackageOrderExcelVO;
 import com.fs.his.vo.FsPackageOrderListUVO;
@@ -117,4 +118,6 @@ public interface IFsPackageOrderService
     void exportData(FsPackageOrderParam fsPackageOrder);
 
     FsPackage selectFsPackageByOrderId(Long packageOrderId);
+
+    List<PackageOrderDTO> getNewOrder();
 }

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsDoctorServiceImpl.java

@@ -111,7 +111,7 @@ public class FsDoctorServiceImpl implements IFsDoctorService
 
         fsDoctor.setCreateTime(DateUtils.getNowDate());
         int i = fsDoctorMapper.insertFsDoctor(fsDoctor);
-        if (fsDoctor.getIsPrescribeDoctor()==1){
+        if (fsDoctor.getIsPrescribeDoctor() != null && fsDoctor.getIsPrescribeDoctor()==1){
             fsDoctor.setPrescribeDoctorId(fsDoctor.getDoctorId());
             fsDoctorMapper.updateFsDoctor(fsDoctor);
         }

+ 6 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -37,6 +37,7 @@ import com.fs.event.TemplateListenEnum;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.PackageConfigDTO;
+import com.fs.his.dto.PackageOrderDTO;
 import com.fs.his.dto.PayConfigDTO;
 import com.fs.his.dto.StoreOrderProductDTO;
 import com.fs.his.enums.FsPackageOrderStatusEnum;
@@ -1397,6 +1398,11 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         return fsPackageOrderMapper.selectFsPackageByOrderId(packageOrderId);
     }
 
+    @Override
+    public List<PackageOrderDTO> getNewOrder() {
+        return fsPackageOrderMapper.getNewOrder();
+    }
+
     @Override
     public R addPackageOrder(FsPackageOrderAddParam param) {
         FsPatient patient=null;

+ 4 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsPackageServiceImpl.java

@@ -77,7 +77,7 @@ public class FsPackageServiceImpl implements IFsPackageService {
     public int insertFsPackage(FsPackage fsPackage) {
 
         fsPackage.setCreateTime(DateUtils.getNowDate());
-        if (fsPackage.getPackageSubType() != 1) {
+//        if (fsPackage.getPackageSubType() != 1) {
             if (fsPackage.getProductJson() != null) {
                 JSONArray objects = JSONUtil.parseArray(fsPackage.getProductJson());
                 List<FsPackagePruductDTO> products = JSONUtil.toList(objects, FsPackagePruductDTO.class);
@@ -93,7 +93,7 @@ public class FsPackageServiceImpl implements IFsPackageService {
                 fsPackage.setInquiryCostPrice(in);
                 fsPackage.setTotalCostPrice(toal.add(in));
             }
-        }
+//        }
         return fsPackageMapper.insertFsPackage(fsPackage);
     }
 
@@ -106,7 +106,7 @@ public class FsPackageServiceImpl implements IFsPackageService {
     @Override
     public int updateFsPackage(FsPackage fsPackage) {
         fsPackage.setUpdateTime(DateUtils.getNowDate());
-        if (fsPackage.getPackageSubType() != null && fsPackage.getPackageSubType() != 1) {
+//        if (fsPackage.getPackageSubType() != null && fsPackage.getPackageSubType() != 1) {
             if (fsPackage.getProductJson() != null) {
                 JSONArray objects = JSONUtil.parseArray(fsPackage.getProductJson());
                 List<FsPackagePruductDTO> products = JSONUtil.toList(objects, FsPackagePruductDTO.class);
@@ -119,7 +119,7 @@ public class FsPackageServiceImpl implements IFsPackageService {
                 fsPackage.setInquiryCostPrice(in);
                 fsPackage.setTotalCostPrice(toal.add(in));
             }
-        }
+//        }
         return fsPackageMapper.updateFsPackage(fsPackage);
     }
 

+ 8 - 0
fs-service/src/main/resources/mapper/his/FsPackageOrderMapper.xml

@@ -309,4 +309,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectFsPackageByOrderId" resultType="com.fs.his.domain.FsPackage">
         SELECT fp.* FROM fs_package_order fpo LEFT JOIN fs_package fp ON fpo.package_id = fp.package_id WHERE fpo.order_id = #{packageOrderId}
     </select>
+    <select id="getNewOrder" resultType="com.fs.his.dto.PackageOrderDTO">
+        SELECT O.pay_time AS payTime, O.create_time AS createTime , O.order_sn AS orderSn , O.user_id AS userId ,
+               U.nick_name AS fsUserName , P.package_name AS packageName
+        FROM fs_barrage_package_order O
+            LEFT JOIN fs_user U ON O.user_id = U.user_id
+            LEFT JOIN fs_package P ON O.package_id = P.package_id
+        where O.is_pay = 1 ORDER BY RAND() desc LIMIT 20
+    </select>
 </mapper>

+ 3 - 1
fs-user-app/src/main/java/com/fs/app/controller/PackageController.java

@@ -86,6 +86,7 @@ public class PackageController extends AppBaseController {
             }
         } else {
             log.info("zyp \n【套餐包不存在】:{}", packageId);
+            return R.error("套餐包不存在");
         }
 
         FsPackageDetailVO vo = new FsPackageDetailVO();
@@ -98,7 +99,8 @@ public class PackageController extends AppBaseController {
                     fsPackage.setImgUrl(s);
                 }
             } catch (Exception e) {
-                throw new RuntimeException(e);
+//                throw new RuntimeException(e);
+                log.error(e.getMessage());
             }
 
         }

+ 36 - 0
fs-user-app/src/main/java/com/fs/app/controller/PackageOrderController.java

@@ -11,6 +11,7 @@ import com.fs.common.utils.StringUtils;
 import com.fs.his.domain.*;
 import com.fs.his.dto.FsInquiryOrderPatientDTO;
 import com.fs.his.dto.FsStoreOrderAddressDTO;
+import com.fs.his.dto.PackageOrderDTO;
 import com.fs.his.param.*;
 import com.fs.his.service.*;
 import com.fs.his.vo.*;
@@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
+import java.util.concurrent.ThreadLocalRandom;
 
 
 @Api("套餐订单接口")
@@ -198,4 +200,38 @@ public class PackageOrderController extends  AppBaseController {
         return R.ok().put("count",count);
     }
 
+    @ApiOperation("/根据套餐id查询最新的20条订单")
+    @GetMapping("/getNewOrderByPackageId")
+    public R getNewOrderByPackageId(@RequestParam("packageId") Long packageId){
+        List<PackageOrderDTO> newOrderByPackageId = packageOrderService.getNewOrder();
+
+        // 当前时间 和 10分钟前
+        long nowMillis = System.currentTimeMillis();
+        long tenMinutesAgoMillis = nowMillis - 10 * 60 * 1000;
+
+        for (PackageOrderDTO dto : newOrderByPackageId) {
+            // 在10分钟内随机一个时间戳
+            long randomMillis = ThreadLocalRandom.current().nextLong(tenMinutesAgoMillis, nowMillis);
+            dto.setPayTime(new Date(randomMillis));
+            //用户名脱敏
+            // 脱敏 fsUserName 字段(保留首尾)
+            String fsUserName = dto.getFsUserName();
+            if (fsUserName != null && fsUserName.length() > 2) {
+                StringBuilder sb = new StringBuilder();
+                sb.append(fsUserName.charAt(0)); // 第一个字符
+                for (int i = 1; i < fsUserName.length() - 1; i++) {
+                    sb.append("*"); // 中间全部 *
+                }
+                sb.append(fsUserName.charAt(fsUserName.length() - 1)); // 最后一个字符
+                dto.setFsUserName(sb.toString());
+            }
+            // 如果只有 2 个字符,不需要加星
+            else if (fsUserName != null && fsUserName.length() == 2) {
+                dto.setFsUserName(fsUserName);
+            }
+        }
+
+        return R.ok().put("data", newOrderByPackageId);
+    }
+
 }