<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.PointFinancialDataMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.PointFinancialDataDO">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="point_id" jdbcType="BIGINT" property="pointId" />
    <result column="equipment_cost" jdbcType="DECIMAL" property="equipmentCost" />
    <result column="decoration_cost" jdbcType="DECIMAL" property="decorationCost" />
    <result column="franchise_fee" jdbcType="DECIMAL" property="franchiseFee" />
    <result column="management_fee" jdbcType="DECIMAL" property="managementFee" />
    <result column="design_fee" jdbcType="DECIMAL" property="designFee" />
    <result column="first_inventory_cost" jdbcType="DECIMAL" property="firstInventoryCost" />
    <result column="deposit" jdbcType="DECIMAL" property="deposit" />
    <result column="initial_investment" jdbcType="DECIMAL" property="initialInvestment" />
    <result column="avg_daily_orders" jdbcType="INTEGER" property="avgDailyOrders" />
    <result column="avg_order_price" jdbcType="DECIMAL" property="avgOrderPrice" />
    <result column="operating_days_per_year" jdbcType="INTEGER" property="operatingDaysPerYear" />
    <result column="daily_sales" jdbcType="DECIMAL" property="dailySales" />
    <result column="annual_gmv" jdbcType="DECIMAL" property="annualGmv" />
    <result column="monthly_sales" jdbcType="DECIMAL" property="monthlySales" />
    <result column="gross_margin_rate" jdbcType="DECIMAL" property="grossMarginRate" />
    <result column="annual_income" jdbcType="DECIMAL" property="annualIncome" />
    <result column="material_cost_annual" jdbcType="DECIMAL" property="materialCostAnnual" />
    <result column="material_cost_monthly" jdbcType="DECIMAL" property="materialCostMonthly" />
    <result column="material_cost_rate" jdbcType="DECIMAL" property="materialCostRate" />
    <result column="staff_count" jdbcType="INTEGER" property="staffCount" />
    <result column="avg_salary" jdbcType="DECIMAL" property="avgSalary" />
    <result column="staff_cost_annual" jdbcType="DECIMAL" property="staffCostAnnual" />
    <result column="staff_cost_rate" jdbcType="DECIMAL" property="staffCostRate" />
    <result column="rent_cost_annual" jdbcType="DECIMAL" property="rentCostAnnual" />
    <result column="rent_cost_rate" jdbcType="DECIMAL" property="rentCostRate" />
    <result column="takeaway_rate" jdbcType="DECIMAL" property="takeawayRate" />
    <result column="platform_commission_rate" jdbcType="DECIMAL" property="platformCommissionRate" />
    <result column="platform_commission" jdbcType="DECIMAL" property="platformCommission" />
    <result column="utility_cost" jdbcType="DECIMAL" property="utilityCost" />
    <result column="utility_cost_rate" jdbcType="DECIMAL" property="utilityCostRate" />
    <result column="other_cost" jdbcType="DECIMAL" property="otherCost" />
    <result column="other_cost_rate" jdbcType="DECIMAL" property="otherCostRate" />
    <result column="operating_profit" jdbcType="DECIMAL" property="operatingProfit" />
    <result column="operating_profit_rate" jdbcType="DECIMAL" property="operatingProfitRate" />
    <result column="payback_period_years" jdbcType="DECIMAL" property="paybackPeriodYears" />
    <result column="payback_period_months" jdbcType="DECIMAL" property="paybackPeriodMonths" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
    <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
  </resultMap>

  <!-- 新增点位财务数据 -->
<insert id="insertPointFinancialData" parameterType="com.cool.store.entity.PointFinancialDataDO">
  INSERT INTO zxjp_point_financial_data
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="pointId != null">point_id,</if>
    <if test="equipmentCost != null">equipment_cost,</if>
    <if test="decorationCost != null">decoration_cost,</if>
    <if test="franchiseFee != null">franchise_fee,</if>
    <if test="managementFee != null">management_fee,</if>
    <if test="designFee != null">design_fee,</if>
    <if test="firstInventoryCost != null">first_inventory_cost,</if>
    <if test="deposit != null">deposit,</if>
    <if test="initialInvestment != null">initial_investment,</if>
    <if test="avgDailyOrders != null">avg_daily_orders,</if>
    <if test="avgOrderPrice != null">avg_order_price,</if>
    <if test="operatingDaysPerYear != null">operating_days_per_year,</if>
    <if test="dailySales != null">daily_sales,</if>
    <if test="annualGmv != null">annual_gmv,</if>
    <if test="monthlySales != null">monthly_sales,</if>
    <if test="grossMarginRate != null">gross_margin_rate,</if>
    <if test="annualIncome != null">annual_income,</if>
    <if test="materialCostAnnual != null">material_cost_annual,</if>
    <if test="materialCostMonthly != null">material_cost_monthly,</if>
    <if test="materialCostRate != null">material_cost_rate,</if>
    <if test="staffCount != null">staff_count,</if>
    <if test="avgSalary != null">avg_salary,</if>
    <if test="staffCostAnnual != null">staff_cost_annual,</if>
    <if test="staffCostRate != null">staff_cost_rate,</if>
    <if test="rentCostAnnual != null">rent_cost_annual,</if>
    <if test="rentCostRate != null">rent_cost_rate,</if>
    <if test="takeawayRate != null">takeaway_rate,</if>
    <if test="platformCommissionRate != null">platform_commission_rate,</if>
    <if test="platformCommission != null">platform_commission,</if>
    <if test="utilityCost != null">utility_cost,</if>
    <if test="utilityCostRate != null">utility_cost_rate,</if>
    <if test="otherCost != null">other_cost,</if>
    <if test="otherCostRate != null">other_cost_rate,</if>
    <if test="operatingProfit != null">operating_profit,</if>
    <if test="operatingProfitRate != null">operating_profit_rate,</if>
    <if test="paybackPeriodYears != null">payback_period_years,</if>
    <if test="paybackPeriodMonths != null">payback_period_months,</if>
    <if test="createTime != null">create_time,</if>
    <if test="createUserId != null">create_user_id,</if>
    <if test="updateTime != null">update_time,</if>
    <if test="updateUserId != null">update_user_id,</if>
  </trim>
  <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
    <if test="pointId != null">#{pointId,jdbcType=BIGINT},</if>
    <if test="equipmentCost != null">#{equipmentCost,jdbcType=DECIMAL},</if>
    <if test="decorationCost != null">#{decorationCost,jdbcType=DECIMAL},</if>
    <if test="franchiseFee != null">#{franchiseFee,jdbcType=DECIMAL},</if>
    <if test="managementFee != null">#{managementFee,jdbcType=DECIMAL},</if>
    <if test="designFee != null">#{designFee,jdbcType=DECIMAL},</if>
    <if test="firstInventoryCost != null">#{firstInventoryCost,jdbcType=DECIMAL},</if>
    <if test="deposit != null">#{deposit,jdbcType=DECIMAL},</if>
    <if test="initialInvestment != null">#{initialInvestment,jdbcType=DECIMAL},</if>
    <if test="avgDailyOrders != null">#{avgDailyOrders,jdbcType=INTEGER},</if>
    <if test="avgOrderPrice != null">#{avgOrderPrice,jdbcType=DECIMAL},</if>
    <if test="operatingDaysPerYear != null">#{operatingDaysPerYear,jdbcType=INTEGER},</if>
    <if test="dailySales != null">#{dailySales,jdbcType=DECIMAL},</if>
    <if test="annualGmv != null">#{annualGmv,jdbcType=DECIMAL},</if>
    <if test="monthlySales != null">#{monthlySales,jdbcType=DECIMAL},</if>
    <if test="grossMarginRate != null">#{grossMarginRate,jdbcType=DECIMAL},</if>
    <if test="annualIncome != null">#{annualIncome,jdbcType=DECIMAL},</if>
    <if test="materialCostAnnual != null">#{materialCostAnnual,jdbcType=DECIMAL},</if>
    <if test="materialCostMonthly != null">#{materialCostMonthly,jdbcType=DECIMAL},</if>
    <if test="materialCostRate != null">#{materialCostRate,jdbcType=DECIMAL},</if>
    <if test="staffCount != null">#{staffCount,jdbcType=INTEGER},</if>
    <if test="avgSalary != null">#{avgSalary,jdbcType=DECIMAL},</if>
    <if test="staffCostAnnual != null">#{staffCostAnnual,jdbcType=DECIMAL},</if>
    <if test="staffCostRate != null">#{staffCostRate,jdbcType=DECIMAL},</if>
    <if test="rentCostAnnual != null">#{rentCostAnnual,jdbcType=DECIMAL},</if>
    <if test="rentCostRate != null">#{rentCostRate,jdbcType=DECIMAL},</if>
    <if test="takeawayRate != null">#{takeawayRate,jdbcType=DECIMAL},</if>
    <if test="platformCommissionRate != null">#{platformCommissionRate,jdbcType=DECIMAL},</if>
    <if test="platformCommission != null">#{platformCommission,jdbcType=DECIMAL},</if>
    <if test="utilityCost != null">#{utilityCost,jdbcType=DECIMAL},</if>
    <if test="utilityCostRate != null">#{utilityCostRate,jdbcType=DECIMAL},</if>
    <if test="otherCost != null">#{otherCost,jdbcType=DECIMAL},</if>
    <if test="otherCostRate != null">#{otherCostRate,jdbcType=DECIMAL},</if>
    <if test="operatingProfit != null">#{operatingProfit,jdbcType=DECIMAL},</if>
    <if test="operatingProfitRate != null">#{operatingProfitRate,jdbcType=DECIMAL},</if>
    <if test="paybackPeriodYears != null">#{paybackPeriodYears,jdbcType=DECIMAL},</if>
    <if test="paybackPeriodMonths != null">#{paybackPeriodMonths,jdbcType=DECIMAL},</if>
    <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    <if test="createUserId != null">#{createUserId,jdbcType=VARCHAR},</if>
    <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    <if test="updateUserId != null">#{updateUserId,jdbcType=VARCHAR},</if>
  </trim>
</insert>

<!-- 修改点位财务数据 -->
<update id="updatePointFinancialData" parameterType="com.cool.store.entity.PointFinancialDataDO">
  UPDATE zxjp_point_financial_data
  <set>
    <if test="pointId != null">point_id = #{pointId,jdbcType=BIGINT},</if>
    <if test="equipmentCost != null">equipment_cost = #{equipmentCost,jdbcType=DECIMAL},</if>
    <if test="decorationCost != null">decoration_cost = #{decorationCost,jdbcType=DECIMAL},</if>
    <if test="franchiseFee != null">franchise_fee = #{franchiseFee,jdbcType=DECIMAL},</if>
    <if test="managementFee != null">management_fee = #{managementFee,jdbcType=DECIMAL},</if>
    <if test="designFee != null">design_fee = #{designFee,jdbcType=DECIMAL},</if>
    <if test="firstInventoryCost != null">first_inventory_cost = #{firstInventoryCost,jdbcType=DECIMAL},</if>
    <if test="deposit != null">deposit = #{deposit,jdbcType=DECIMAL},</if>
    <if test="initialInvestment != null">initial_investment = #{initialInvestment,jdbcType=DECIMAL},</if>
    <if test="avgDailyOrders != null">avg_daily_orders = #{avgDailyOrders,jdbcType=INTEGER},</if>
    <if test="avgOrderPrice != null">avg_order_price = #{avgOrderPrice,jdbcType=DECIMAL},</if>
    <if test="operatingDaysPerYear != null">operating_days_per_year = #{operatingDaysPerYear,jdbcType=INTEGER},</if>
    <if test="dailySales != null">daily_sales = #{dailySales,jdbcType=DECIMAL},</if>
    <if test="annualGmv != null">annual_gmv = #{annualGmv,jdbcType=DECIMAL},</if>
    <if test="monthlySales != null">monthly_sales = #{monthlySales,jdbcType=DECIMAL},</if>
    <if test="grossMarginRate != null">gross_margin_rate = #{grossMarginRate,jdbcType=DECIMAL},</if>
    <if test="annualIncome != null">annual_income = #{annualIncome,jdbcType=DECIMAL},</if>
    <if test="materialCostAnnual != null">material_cost_annual = #{materialCostAnnual,jdbcType=DECIMAL},</if>
    <if test="materialCostMonthly != null">material_cost_monthly = #{materialCostMonthly,jdbcType=DECIMAL},</if>
    <if test="materialCostRate != null">material_cost_rate = #{materialCostRate,jdbcType=DECIMAL},</if>
    <if test="staffCount != null">staff_count = #{staffCount,jdbcType=INTEGER},</if>
    <if test="avgSalary != null">avg_salary = #{avgSalary,jdbcType=DECIMAL},</if>
    <if test="staffCostAnnual != null">staff_cost_annual = #{staffCostAnnual,jdbcType=DECIMAL},</if>
    <if test="staffCostRate != null">staff_cost_rate = #{staffCostRate,jdbcType=DECIMAL},</if>
    <if test="rentCostAnnual != null">rent_cost_annual = #{rentCostAnnual,jdbcType=DECIMAL},</if>
    <if test="rentCostRate != null">rent_cost_rate = #{rentCostRate,jdbcType=DECIMAL},</if>
    <if test="takeawayRate != null">takeaway_rate = #{takeawayRate,jdbcType=DECIMAL},</if>
    <if test="platformCommissionRate != null">platform_commission_rate = #{platformCommissionRate,jdbcType=DECIMAL},</if>
    <if test="platformCommission != null">platform_commission = #{platformCommission,jdbcType=DECIMAL},</if>
    <if test="utilityCost != null">utility_cost = #{utilityCost,jdbcType=DECIMAL},</if>
    <if test="utilityCostRate != null">utility_cost_rate = #{utilityCostRate,jdbcType=DECIMAL},</if>
    <if test="otherCost != null">other_cost = #{otherCost,jdbcType=DECIMAL},</if>
    <if test="otherCostRate != null">other_cost_rate = #{otherCostRate,jdbcType=DECIMAL},</if>
    <if test="operatingProfit != null">operating_profit = #{operatingProfit,jdbcType=DECIMAL},</if>
    <if test="operatingProfitRate != null">operating_profit_rate = #{operatingProfitRate,jdbcType=DECIMAL},</if>
    <if test="paybackPeriodYears != null">payback_period_years = #{paybackPeriodYears,jdbcType=DECIMAL},</if>
    <if test="paybackPeriodMonths != null">payback_period_months = #{paybackPeriodMonths,jdbcType=DECIMAL},</if>
    <if test="updateTime != null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if>
    <if test="updateUserId != null">update_user_id = #{updateUserId,jdbcType=VARCHAR},</if>
  </set>
  WHERE id = #{id,jdbcType=BIGINT}
</update>

<!-- 根据点位ID查询 -->
<select id="selectByPointId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  SELECT
  *
  FROM zxjp_point_financial_data
  WHERE point_id = #{pointId,jdbcType=BIGINT}
</select>


</mapper>