【九月打卡】第11天 多端全栈项目实战
课程名称:多端全栈项目实战:商业级代驾全流程落地
课程章节: 华夏代驾全栈小程序实战
课程讲师: 神思者
课程内容:
创建代驾订单,保存到mysql
课程收获:
前两天写好了预估里程,时间,费用的获取接下来需要把订单保存到数据库,除了订单还有账单。
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 明天继续~~
共同学习,写下你的评论
评论加载中...
作者其他优质文章

