为了账号安全,请及时绑定邮箱和手机立即绑定

【九月打卡】第11天 多端全栈项目实战

标签:
SpringBoot

课程名称:多端全栈项目实战:商业级代驾全流程落地


课程章节:  华夏代驾全栈小程序实战


课程讲师: 神思者


课程内容: 


    创建代驾订单,保存到mysql


课程收获:

    

    https://img2.sycdn.imooc.com/6322e01b00014d2508040385.jpg


前两天写好了预估里程,时间,费用的获取接下来需要把订单保存到数据库,除了订单还有账单。


bff-customer 发起远程fegin 调用到orderController 调用 service 进行 insert 数据库 如果是订单则需要通过searchOrderIdByUUID对刚才插入的数据的uuid进行查询 因为uuid是雪花生成的(随机且唯一)。


插入成功后 返回 并封装R对象

需要传入的值分别有


uuid  订单号

customer_id 客户ID

start_place 起始地点

start_place_location 起始坐标

expects_mileage 预估里程

expects_fee 预估订单金额

favour_fee 好处费

charge_rule_id 费用规则id

car_plate 车牌号

car_type 车型

date 订单日期

<insert id="insert" parameterType="com.example.hxds.odr.db.pojo.OrderEntity">
    INSERT INTO tb_order
    SET uuid = #{uuid},
        customer_id = #{customerId},
        start_place = #{startPlace},
        start_place_location = #{startPlaceLocation},
        end_place = #{endPlace},
        end_place_location = #{endPlaceLocation},
        expects_mileage = #{expectsMileage},
        expects_fee = #{expectsFee},
        favour_fee = #{favourFee},
        charge_rule_id=#{chargeRuleId},
        car_plate=#{carPlate},
        car_type=#{carType},
        date = #{date}
</insert>

然后是通过uuid 查 id

<select id="searchOrderIdByUUID" parameterType="String" resultType="String">
    SELECT CAST(id AS CHAR) AS id
    FROM tb_order
    WHERE uuid = #{uuid}
</select>

order_id = 订单id

base_mileage = 基础公里

base_mileage_price = 里程价格

exceed_mileage_price = 超出基础里程价格

base_minute = 基础分种

exceed_minute_price = 超出基础分钟价格

base_return_mileage = 基础返程里程

exceed_return_price = 超出基础返程里程的价格

<insert id="insert" parameterType="com.example.hxds.odr.db.pojo.OrderBillEntity">
    INSERT INTO tb_order_bill
    SET order_id = #{orderId},
        base_mileage = #{baseMileage},
        base_mileage_price = #{baseMileagePrice},
        exceed_mileage_price = #{exceedMileagePrice},
        base_minute = #{baseMinute},
        exceed_minute_price = #{exceedMinutePrice},
        base_return_mileage = #{baseReturnMileage},
        exceed_return_price = #{exceedReturnPrice}
</insert>



至此就写完了 这一章需要的三个sql 明天继续~~


https://img2.sycdn.imooc.com/6322df510001a65a07830598.jpg

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
Web前端工程师
手记
粉丝
27
获赞与收藏
19

关注作者,订阅最新文章

阅读免费教程

  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消