Просмотр исходного кода

谷养正道订单物流信息 订单修改/手表写入睡眠 体温数据

wangxy 1 неделя назад
Родитель
Сommit
cca022280b

+ 28 - 0
fs-company/src/main/java/com/fs/hisStore/controller/FsGuCoinOrderController.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.controller;
 
+import com.fs.common.annotation.DataScope;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
@@ -7,6 +8,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.framework.security.LoginUser;
+import com.fs.framework.security.SecurityUtils;
 import com.fs.framework.service.TokenService;
 import com.fs.his.domain.FsGuCoinOrder;
 import com.fs.his.param.FsGuCoinOrderManuallyParam;
@@ -19,6 +21,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Date;
 
 /**
  * 谷币商城订单Controller(销售后台)
@@ -42,6 +45,7 @@ public class FsGuCoinOrderController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('his:guCoinOrder:list')")
     @GetMapping("/list")
+    @DataScope(userAlias = "cu",deptAlias = "cu")
     public TableDataInfo list(FsGuCoinOrderParam param)
     {
         startPage();
@@ -80,9 +84,33 @@ public class FsGuCoinOrderController extends BaseController
     @PutMapping
     public AjaxResult edit(@RequestBody FsGuCoinOrder fsGuCoinOrder)
     {
+        // 签收状态变更时,写入签收状态更新人和时间
+        if (fsGuCoinOrder.getDeliveryStatus() != null) {
+            fsGuCoinOrder.setDeliveryStatusUpdateTime(new Date());
+            fsGuCoinOrder.setDeliveryStatusUpdateBy(SecurityUtils.getLoginUser().getUser().getUserName());
+        }
         return toAjax(fsGuCoinOrderService.updateFsGuCoinOrder(fsGuCoinOrder));
     }
 
+    /**
+     * 查询谷币订单物流信息
+     */
+    @PreAuthorize("@ss.hasPermi('his:guCoinOrder:express')")
+    @GetMapping(value = "/getExpress/{orderId}")
+    public R getExpress(@PathVariable("orderId") Long orderId) {
+        return R.ok().put("data", fsGuCoinOrderService.getExpress(orderId));
+    }
+
+    /**
+     * 同步谷币订单物流状态
+     */
+    @Log(title = "同步谷币订单物流", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('his:guCoinOrder:syncExpress')")
+    @GetMapping(value = "/syncExpress/{orderId}")
+    public R syncExpress(@PathVariable("orderId") Long orderId) {
+        return fsGuCoinOrderService.syncExpress(orderId);
+    }
+
     /**
      * 删除谷币订单
      */

+ 41 - 0
fs-service/src/main/java/com/fs/his/domain/FsGuCoinOrder.java

@@ -132,6 +132,47 @@ public class FsGuCoinOrder
     /** 聚水潭订单号(推送聚水潭后返回的o_id) */
     private String extendOrderId;
 
+    /** 物流状态 0暂无轨迹 1已揽收 2在途 3签收 4问题件 */
+    private Integer deliveryStatus;
+
+    /** 物流状态类型 */
+    private String deliveryType;
+
+    /** 物流更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date deliveryUpdateTime;
+
+    /** 签收状态更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date deliveryStatusUpdateTime;
+
+    /** 签收状态更新人 */
+    private String deliveryStatusUpdateBy;
+
+    /** 跟单时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date followTime;
+
+    /** 代收金额 */
+    private BigDecimal collectionPrice;
+
+    /** 退款金额 */
+    private BigDecimal refundPrice;
+
+    /** 退款日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date refundTime;
+
+    /** 拒收回退时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date rejectReturnTime;
+
+    /** 病名 */
+    private String diseaseName;
+
+    /** 是否还货 1是 2否 */
+    private Integer isReturnGoods;
+
     /** 非数据库字段 会员id集合 */
     @TableField(exist = false)
     private Long[] userIds;

+ 2 - 2
fs-service/src/main/java/com/fs/his/domain/FsThirdDeviceData.java

@@ -24,8 +24,8 @@ public class FsThirdDeviceData extends BaseEntity{
     @Excel(name = "用户id")
     private Long userId;
 
-    /** 记录类型 0:血压 1:血糖 2:心率  3尿酸 4血氧 */
-    @Excel(name = "记录类型 0:血压 1:血糖 2:心率  3尿酸 4血氧 5步数 6运动 7睡眠")
+    /** 记录类型 0:血压 1:血糖 2:心率  3尿酸 4血氧 5步数 6运动 7睡眠 8体温 */
+    @Excel(name = "记录类型 0:血压 1:血糖 2:心率  3尿酸 4血氧 5步数 6运动 7睡眠 8体温")
     private Integer recordType;
 
     /** 记录数值 */

+ 1 - 1
fs-service/src/main/java/com/fs/his/mapper/FsGuCoinOrderMapper.java

@@ -35,7 +35,7 @@ public interface FsGuCoinOrderMapper {
     public int deleteFsGuCoinOrderByOrderIds(Long[] orderIds);
 
     /** 取消订单(发货前) */
-    @Update("update fs_gu_coin_order set status = -1 where order_id = #{orderId} and status in (1,4)")
+    @Update("update fs_gu_coin_order set status = 5 where order_id = #{orderId} and status in (1,4)")
     int cancelOrder(@Param("orderId") Long orderId);
 
     /** 查询可推送到聚水潭的谷币订单(待发货且未推送) */

+ 4 - 1
fs-service/src/main/java/com/fs/his/param/FsGuCoinOrderParam.java

@@ -1,6 +1,8 @@
 package com.fs.his.param;
 
+import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 /**
  * 谷币订单查询参数
@@ -9,7 +11,8 @@ import lombok.Data;
  * @date 2026-07-17
  */
 @Data
-public class FsGuCoinOrderParam {
+@EqualsAndHashCode(callSuper = true)
+public class FsGuCoinOrderParam extends BaseEntity {
     private Long orderId;
     private String orderCode;
     private Long userId;

+ 11 - 0
fs-service/src/main/java/com/fs/his/service/IFsGuCoinOrderService.java

@@ -1,6 +1,7 @@
 package com.fs.his.service;
 
 import com.fs.common.core.domain.R;
+import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.domain.FsGuCoinOrder;
 import com.fs.his.enums.PaymentMethodEnum;
 import com.fs.his.param.FsGuCoinCartOrderCreateParam;
@@ -100,4 +101,14 @@ public interface IFsGuCoinOrderService {
      * @param deliverName  快递公司名称(express_name)
      */
     void deliveryGuCoinOrderOrder(String orderCode, String deliveryId, String deliverCode, String deliverName);
+
+    /**
+     * 查询谷币订单快递物流信息
+     */
+    ExpressInfoDTO getExpress(Long orderId);
+
+    /**
+     * 同步谷币订单物流状态
+     */
+    R syncExpress(Long orderId);
 }

+ 100 - 10
fs-service/src/main/java/com/fs/his/service/impl/FsGuCoinOrderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.his.service.impl;
 
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
@@ -23,8 +24,10 @@ import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUserAddress;
 import com.fs.his.dto.ComputeGuCoinOrderMoneyDTO;
 import com.fs.his.dto.ErpRemarkDTO;
+import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.enums.BusinessTypeEnum;
 import com.fs.his.enums.PaymentMethodEnum;
+import com.fs.his.enums.ShipperCodeEnum;
 import com.fs.his.mapper.FsGuCoinGoodsMapper;
 import com.fs.his.mapper.FsGuCoinOrderMapper;
 import com.fs.his.mapper.FsUserAddressMapper;
@@ -47,6 +50,8 @@ import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsGuCoinCartVO;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.QwUserMapper;
+import com.fs.course.domain.FsUserCompanyUser;
+import com.fs.course.mapper.FsUserCompanyUserMapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -93,6 +98,8 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
     @Autowired
     private QwUserMapper qwUserMapper;
     @Autowired
+    private FsUserCompanyUserMapper fsUserCompanyUserMapper;
+    @Autowired
     private IFsUserGuCoinLogsService fsUserGuCoinLogsService;
     @Autowired
     private IFsStorePaymentService storePaymentService;
@@ -322,13 +329,16 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
             order.setPayTime(new Date());
         }
 
-        // 关联销售信息
-        Long companyUserId = param.getCompanyUserId();
-        if (companyUserId != null) {
-            order.setCompanyUserId(companyUserId);
-            CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(companyUserId);
-            if (ObjectUtil.isNotEmpty(companyUser)) {
-                order.setCompanyId(companyUser.getCompanyId());
+        // 关联销售信息(根据userId从fs_user_company_user查询,不从前端获取)
+        FsUserCompanyUser companyUserRel = fsUserCompanyUserMapper.selectOne(new LambdaQueryWrapper<FsUserCompanyUser>()
+                .eq(FsUserCompanyUser::getUserId, user.getUserId())
+                .last("LIMIT 1"));
+        if (companyUserRel != null) {
+            if (companyUserRel.getCompanyUserId() != null) {
+                order.setCompanyUserId(companyUserRel.getCompanyUserId());
+            }
+            if (companyUserRel.getCompanyId() != null) {
+                order.setCompanyId(companyUserRel.getCompanyId());
             }
         }
         // 关联企微信息
@@ -479,17 +489,29 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
             order.setPayTime(new Date());
         }
 
-        // 关联企微信息(购物车下单无销售关联)
+        // 关联销售信息(根据userId从fs_user_company_user查询,不从前端获取)
+        FsUserCompanyUser companyUserRel = fsUserCompanyUserMapper.selectOne(new LambdaQueryWrapper<FsUserCompanyUser>()
+                .eq(FsUserCompanyUser::getUserId, user.getUserId())
+                .last("LIMIT 1"));
+        if (companyUserRel != null) {
+            if (companyUserRel.getCompanyUserId() != null) {
+                order.setCompanyUserId(companyUserRel.getCompanyUserId());
+            }
+            if (companyUserRel.getCompanyId() != null) {
+                order.setCompanyId(companyUserRel.getCompanyId());
+            }
+        }
+        // 关联企微信息
         if (ObjectUtil.isNotNull(user.getQwUserId())) {
             QwUser qwUser = qwUserMapper.selectOne(new LambdaQueryWrapper<QwUser>()
                     .select(QwUser::getId, QwUser::getCompanyId, QwUser::getCompanyUserId)
                     .eq(QwUser::getId, user.getQwUserId()));
             if (ObjectUtil.isNotNull(qwUser)) {
                 order.setQwUserId(qwUser.getId());
-                if (qwUser.getCompanyId() != null) {
+                if (order.getCompanyId() == null && qwUser.getCompanyId() != null) {
                     order.setCompanyId(qwUser.getCompanyId());
                 }
-                if (qwUser.getCompanyUserId() != null) {
+                if (order.getCompanyUserId() == null && qwUser.getCompanyUserId() != null) {
                     order.setCompanyUserId(qwUser.getCompanyUserId());
                 }
             }
@@ -964,4 +986,72 @@ public class FsGuCoinOrderServiceImpl implements IFsGuCoinOrderService
             log.error("谷币订单订阅快递鸟失败 orderCode: {}", orderCode, e);
         }
     }
+
+    @Override
+    public ExpressInfoDTO getExpress(Long orderId) {
+        FsGuCoinOrder order = fsGuCoinOrderMapper.selectFsGuCoinOrderByOrderId(orderId);
+        if (order == null) {
+            throw new RuntimeException("谷币订单不存在");
+        }
+        if (StringUtils.isBlank(order.getDeliverySn())) {
+            return null;
+        }
+        String lastFourNumber = getExpressLastFourNumber(order);
+        ExpressInfoDTO expressInfoDTO = expressService.getExpressInfo(order.getOrderCode(), order.getDeliveryCode(), order.getDeliverySn(), lastFourNumber);
+        if (expressInfoDTO != null
+                && "0".equals(expressInfoDTO.getStateEx())
+                && "0".equals(expressInfoDTO.getState())) {
+            expressInfoDTO = expressService.getExpressInfo(order.getOrderCode(), order.getDeliveryCode(), order.getDeliverySn(), getDefaultExpressLastFourNumber(order));
+        }
+        return expressInfoDTO;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R syncExpress(Long orderId) {
+        FsGuCoinOrder order = fsGuCoinOrderMapper.selectFsGuCoinOrderByOrderId(orderId);
+        if (order == null) {
+            return R.error("谷币订单不存在");
+        }
+        if (StringUtils.isBlank(order.getDeliverySn())) {
+            return R.error("快递单号为空");
+        }
+        ExpressInfoDTO dto = getExpress(orderId);
+        log.info("谷币订单快递鸟查询dto:{}", JSONUtil.toJsonStr(dto));
+        if (dto == null) {
+            return R.error("未查询到物流信息");
+        }
+        if (!dto.isSuccess()) {
+            return R.error(dto.getReason());
+        }
+        FsGuCoinOrder update = new FsGuCoinOrder();
+        update.setOrderId(order.getOrderId());
+        update.setDeliveryStatus(Integer.parseInt(dto.getState()));
+        update.setDeliveryType(dto.getStateEx());
+        update.setDeliveryUpdateTime(DateUtils.getNowDate());
+        fsGuCoinOrderMapper.updateFsGuCoinOrder(update);
+        return R.ok();
+    }
+
+    private String getExpressLastFourNumber(FsGuCoinOrder order) {
+        if (!ShipperCodeEnum.SF.getValue().equals(order.getDeliveryCode()) || StringUtils.isBlank(order.getUserPhone())) {
+            return "";
+        }
+        String phone = order.getUserPhone();
+        if (phone.length() > 11) {
+            phone = decryptPhone(phone);
+        }
+        if (phone.length() >= 4) {
+            return StrUtil.sub(phone, phone.length(), -4);
+        }
+        return "";
+    }
+
+    private String getDefaultExpressLastFourNumber(FsGuCoinOrder order) {
+        if (!ShipperCodeEnum.SF.getValue().equals(order.getDeliveryCode())) {
+            return "";
+        }
+        String phone = "19331276912";
+        return StrUtil.sub(phone, phone.length(), -4);
+    }
 }

+ 7 - 1
fs-service/src/main/java/com/fs/watch/service/impl/WatchDataServiceImpl.java

@@ -231,7 +231,13 @@ public class WatchDataServiceImpl implements WatchDataService {
                             vo.setData("");
                         }
                     } else {
-                        vo.setData("");
+                        FsThirdDeviceData data = fsThirdDeviceDataMapper.getLatest(deviceId,8);
+                        if (data != null) {
+                            vo.setDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,data.getCreateTime()));
+                            vo.setData(data.getRecordValue());
+                        } else {
+                            vo.setData("");
+                        }
                     }
 
 

+ 37 - 9
fs-service/src/main/resources/mapper/his/FsGuCoinOrderMapper.xml

@@ -35,6 +35,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="remark"          column="remark"            />
         <result property="createTime"      column="create_time"       />
         <result property="extendOrderId"   column="extend_order_id"   />
+        <result property="deliveryStatus"          column="delivery_status"            />
+        <result property="deliveryType"            column="delivery_type"              />
+        <result property="deliveryUpdateTime"      column="delivery_update_time"       />
+        <result property="deliveryStatusUpdateTime" column="delivery_status_update_time"/>
+        <result property="deliveryStatusUpdateBy"  column="delivery_status_update_by"  />
+        <result property="followTime"              column="follow_time"                />
+        <result property="collectionPrice"         column="collection_price"           />
+        <result property="refundPrice"             column="refund_price"               />
+        <result property="refundTime"              column="refund_time"                />
+        <result property="rejectReturnTime"        column="reject_return_time"         />
+        <result property="diseaseName"             column="disease_name"               />
+        <result property="isReturnGoods"           column="is_return_goods"            />
     </resultMap>
 
     <sql id="selectFsGuCoinOrderVo">
@@ -52,17 +64,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectFsGuCoinOrderList" parameterType="com.fs.his.param.FsGuCoinOrderParam" resultMap="FsGuCoinOrderResult">
-        <include refid="selectFsGuCoinOrderVo"/>
+        select o.* from fs_gu_coin_order o
+        <if test="companyUserId != null or (params != null and params.dataScope != null)">
+            LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
+        </if>
         <where>
-            <if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
-            <if test="userId != null"> and user_id = #{userId}</if>
-            <if test="userPhone != null and userPhone != ''"> and user_phone = #{userPhone}</if>
-            <if test="status != null"> and status = #{status}</if>
-            <if test="isPay != null"> and is_pay = #{isPay}</if>
-            <if test="companyId != null"> and company_id = #{companyId}</if>
-            <if test="companyUserId != null"> and company_user_id = #{companyUserId}</if>
+            <if test="orderCode != null and orderCode != ''"> and o.order_code = #{orderCode}</if>
+            <if test="userId != null"> and o.user_id = #{userId}</if>
+            <if test="userPhone != null and userPhone != ''"> and o.user_phone = #{userPhone}</if>
+            <if test="status != null"> and o.status = #{status}</if>
+            <if test="isPay != null"> and o.is_pay = #{isPay}</if>
+            <if test="companyId != null"> and o.company_id = #{companyId}</if>
+            <if test="companyUserId != null"> and o.company_user_id = #{companyUserId}</if>
+            ${params.dataScope}
         </where>
-        order by create_time desc
+        order by o.create_time desc
     </select>
 
     <select id="selectFsGuCoinOrderListU" parameterType="com.fs.his.param.FsGuCoinOrderListUParam" resultMap="FsGuCoinOrderResult">
@@ -156,6 +172,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
             <if test="remark != null">remark = #{remark},</if>
             <if test="extendOrderId != null">extend_order_id = #{extendOrderId},</if>
+            <if test="deliveryStatus != null">delivery_status = #{deliveryStatus},</if>
+            <if test="deliveryType != null">delivery_type = #{deliveryType},</if>
+            <if test="deliveryUpdateTime != null">delivery_update_time = #{deliveryUpdateTime},</if>
+            <if test="deliveryStatusUpdateTime != null">delivery_status_update_time = #{deliveryStatusUpdateTime},</if>
+            <if test="deliveryStatusUpdateBy != null">delivery_status_update_by = #{deliveryStatusUpdateBy},</if>
+            <if test="followTime != null">follow_time = #{followTime},</if>
+            <if test="collectionPrice != null">collection_price = #{collectionPrice},</if>
+            <if test="refundPrice != null">refund_price = #{refundPrice},</if>
+            <if test="refundTime != null">refund_time = #{refundTime},</if>
+            <if test="rejectReturnTime != null">reject_return_time = #{rejectReturnTime},</if>
+            <if test="diseaseName != null">disease_name = #{diseaseName},</if>
+            <if test="isReturnGoods != null">is_return_goods = #{isReturnGoods},</if>
         </trim>
         where order_id = #{orderId}
     </update>

+ 27 - 0
fs-watch/src/main/java/com/fs/app/controller/WatchController.java

@@ -1536,12 +1536,39 @@ public class WatchController extends AppBaseController {
                 case 4:
                     deviceData.setStatus(watchSpo2DataService.getStatus(Integer.parseInt(recordValue),Integer.parseInt(recordValue)));
                     break;
+                //睡眠 recordValue: {"startTime":...,"endTime":...,"status":1}
+                case 7:
+                    JSONObject sleepRecord = JSONObject.parseObject(recordValue);
+                    if (sleepRecord != null && sleepRecord.get("status") != null){
+                        deviceData.setStatus(sleepRecord.getInteger("status"));
+                    }
+                    break;
+                //体温 1正常 2低温 3高温
+                case 8:
+                    deviceData.setStatus(getTemperatureStatus(Double.valueOf(recordValue)));
+                    break;
                 default:
                     break;
             }
         }
     }
 
+    /**
+     * 体温状态标准 1正常 2低温 3高温
+     * 低温: < 35.0℃
+     * 正常: 35.0℃ ~ 37.2℃
+     * 高温: >= 37.3℃
+     */
+    private Integer getTemperatureStatus(double temp) {
+        if (temp < 35.0) {
+            return 2; //低温
+        } else if (temp >= 37.3) {
+            return 3; //高温
+        } else {
+            return 1; //正常
+        }
+    }
+
     /**
      * 查询三方设备健康数据列表
      */