Andru
2023-12-27 96f9b33c5377febc8fc1fd686bcd870e0cc1b452
划扣填充订单关联信息
3个文件已修改
56 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/OrderInfoMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/platform/OrderInfoMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/deduction/impl/DeductionSingleServiceImpl.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/OrderInfoMapper.java
@@ -32,4 +32,6 @@
    int deleteWhere(SqlSentence sqlSentence);
    /**删除,返回删除数量*/
    int deleteById(Object object);
    /**查询,返回实体类没有大数据的*/
    OrderInfo selectOneByOrderId(Object object);
}
phi_platform_common/src/main/resources/mapper/platform/OrderInfoMapper.xml
@@ -86,5 +86,9 @@
    <delete id="deleteById"  parameterType="java.lang.Object">
        delete from orders_info WHERE id = #{value}
    </delete>
    <select id="selectOneByOrderId" resultType="com.hx.phiappt.model.order.OrderInfo" parameterType="java.lang.Object" >
        select * from orders_info WHERE orderId = #{value}
    </select>
    
</mapper>
phi_platform_user/src/main/java/com/hx/phip/service/deduction/impl/DeductionSingleServiceImpl.java
@@ -25,14 +25,14 @@
import com.hx.phiappt.model.coupon.CouponReleaseRecordItem;
import com.hx.phiappt.model.deduction.*;
import com.hx.phiappt.model.giving.TurnAddItem;
import com.hx.phiappt.model.order.OrderInfo;
import com.hx.phiappt.model.order.OrderItem;
import com.hx.phiappt.model.order.OrderItemSon;
import com.hx.phiappt.model.order.OrdersTotal;
import com.hx.phiappt.model.project.ProjectInfo;
import com.hx.phiappt.model.treat.TreatProjectDoctor;
import com.hx.phiappt.model.treat.TreatSingle;
import com.hx.phiappt.model.user.UserProject;
import com.hx.phiappt.model.user.UserProjectItem;
import com.hx.phiappt.model.user.UserProjectTurn;
import com.hx.phiappt.model.user.UserProjectUsed;
import com.hx.phiappt.model.user.*;
import com.hx.phiappt.model.userMoney.UserMoneyUnclaimed;
import com.hx.phiappt.model.userStatus.UserStatusLog;
import com.hx.phiappt.model.warehouse.ShopWarehouse;
@@ -95,6 +95,8 @@
    private CommonService commonService;
    @Resource
    private CustomParameter customParameter;
    @Resource
    private OrderInfoMapper orderInfoMapper;
    @Resource
    private TurnAddItemMapper turnAddItemMapper;
    @Resource
@@ -631,6 +633,9 @@
                deductionSingle.setUserStatus(user.getUserStatus());
                // 划扣默认类型
                deductionSingle.setType(deductionDto.getType());
                // 添加关联信息
                this.getRelationInfo(deductionSingle, userProjectItem);
                // 添加划扣记录
                int count = deductionSingleMapper.insert(deductionSingle);
                if (count != 1) {
                    throw new TipsException("新增失败!");
@@ -4800,4 +4805,41 @@
            logger.error("作废划扣发通知给护士长出错:", e);
        }
    }
    /**
     * 获取订单关联信息
     * @param deductionSingle 划扣对象
     * @param userProjectItem 用户项目
     */
    private void getRelationInfo(DeductionSingle deductionSingle, UserProjectItem userProjectItem) {
        String orderId = null;
        if (OrderSourceConstans.TYPE_RETAIL.equals(userProjectItem.getCommonType())) {
            // 二级查一级值订单,用户卡包所关联的订单
            if (!StringUtils.isEmpty(userProjectItem.getCommonId())) {
                OrderItemSon orderItemSon = commonService.selectOneByKey(OrderItemSonMapper.class, userProjectItem.getCommonId());
                if (orderItemSon != null) {
                    OrderItem orderItem = commonService.selectOneByKey(OrderItemMapper.class, orderItemSon.getOrderItemId());
                    if (orderItem != null && OrderItemConstants.CARD_BAG.equals(orderItem.getType()) && !StringUtils.isEmpty(orderItem.getUserCardId())) {
                        UserCard userCard = commonService.selectOneByKey(UserCardMapper.class, orderItem.getUserCardId());
                        if (userCard != null) {
                            orderId = userCard.getOrderId();
                        }
                    }
                }
            }
        } else {
            // 一级直接那订单id
            orderId = userProjectItem.getOrdersTotalId();
        }
        // 获取关联信息
        if (!StringUtils.isEmpty(orderId)) {
            OrderInfo orderInfo = orderInfoMapper.selectOneByOrderId(orderId);
            if (orderInfo != null) {
                // 填充关联关系
                deductionSingle.setRelationType(orderInfo.getRelationType());
                deductionSingle.setRelationId(orderInfo.getRelationId());
                deductionSingle.setRelationName(orderInfo.getRelationName());
            }
        }
    }
}