|
|
@@ -3283,4 +3283,62 @@
|
|
|
order by iac.createtime desc
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
|
|
|
+ select
|
|
|
+ IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL (ifon.no_costs_premiums,0) as "entranceAllFee",
|
|
|
+ IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0) +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
|
|
|
+ +IFNULL(no_export_supervise_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) as "exportAllFee"
|
|
|
+ from ins_area_company iac
|
|
|
+ left join ins_orders io on io.orderno = iac.orderno
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ <where>
|
|
|
+ <if test="userId !=null and userId !=''">
|
|
|
+ iac.leader_id =#{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getDistributionAllAmount" resultType="java.util.HashMap">
|
|
|
+ select
|
|
|
+ IFNULL(sum(IFNULL(first_detail_premiums,0)),0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount"
|
|
|
+ from ins_area_company iac
|
|
|
+ left join ins_orders io on io.orderno = iac.orderno
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ <where>
|
|
|
+ <if test="userId !=null and userId !=''">
|
|
|
+ ifon.first_level_user_id =#{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ group by ifon.first_level_user_id
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
|
|
|
+ ifon.two_level_user_id as "twoLevelUserId",
|
|
|
+ from ins_area_company iac
|
|
|
+ left join ins_orders io on io.orderno = iac.orderno
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ <where>
|
|
|
+ <if test="userId !=null and userId !=''">
|
|
|
+ ifon.two_level_user_id =#{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ group by ifon.two_level_user_id
|
|
|
+ ) b on b.twoLevelUserId =ifon.first_level_user_id
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
|
|
|
+ ifon.three_level_user_id as "threeLevelUserId",
|
|
|
+ from ins_area_company iac
|
|
|
+ left join ins_orders io on io.orderno = iac.orderno
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ <where>
|
|
|
+ <if test="userId !=null and userId !=''">
|
|
|
+ ifon.three_level_user_id =#{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ group by ifon.three_level_user_id
|
|
|
+ ) c on c.threeLevelUserId = ifon.first_level_user_id
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|