| | |
| | | <select id="amountSum" resultType="com.ruoyi.system.vo.AmountSumVO"> |
| | | select |
| | | COUNT(id) AS orderCount, |
| | | SUM(orderMoney) AS saleAmount, |
| | | SUM(payMoney) AS payAmount, |
| | | SUM(orderMoney - payMoney) AS obligation |
| | | IFNULL(SUM(orderMoney),0) AS saleAmount, |
| | | IFNULL(SUM(payMoney),0) AS payAmount, |
| | | IFNULL(SUM(orderMoney - IFNULL(payMoney,0)),0) AS obligation |
| | | from t_order_sale |
| | | <where> |
| | | <if test="query.orderNum != null and query.orderNum != ''"> |
| | |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND isCover = 1 |
| | | AND status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="exportOrderSale" resultType="com.ruoyi.system.vo.TOrderSaleVO"> |
| | | select id, orderTime, remark, createTime, updateTime, disabled, createBy, updateBy, orderNum, status,orderMoney,payMoney,shopId |
| | | select id, orderTime, remark, createTime, updateTime, disabled, createBy, updateBy, orderNum, status,orderMoney,payMoney,shopId,payType |
| | | from t_order_sale |
| | | <where> |
| | | <if test="query.orderNum != null and query.orderNum != ''"> |
| | |
| | | AND shopId = #{query.shopId} |
| | | </if> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (createTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | AND (orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND isCover = 1 |
| | | AND status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="getDataGeneratorSaleDetail" resultType="java.util.Map"> |
| | |
| | | and tdg.orderType = 2 |
| | | </where> |
| | | </select> |
| | | <select id="profitDetails" resultType="com.ruoyi.system.vo.GoodsProfitVO"> |
| | | SELECT |
| | | tomg.goodsName, |
| | | (select typeName from t_goods_type where id = tomg.typeId) AS typeName, |
| | | IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.thisSalePrice ),0) AS goodsSaleAmount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.goodsCostPrice ),0) AS goodsCostAmount, |
| | | IFNULL(SUM(tomg.goodsCount *(tomg.thisSalePrice - tomg.goodsCostPrice)),0) AS goodsProfitAmount |
| | | FROM t_order_sale_goods tomg |
| | | LEFT JOIN t_order_sale tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | | </if> |
| | | <if test="query.typeId != null and query.typeId != ''"> |
| | | AND tomg.typeId = #{query.typeId} |
| | | </if> |
| | | <if test="query.shopId != null"> |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName |
| | | </select> |
| | | <select id="profitDetailsStatistics" resultType="java.util.Map"> |
| | | SELECT |
| | | IFNULL(SUM(a.goodsSaleAmount),0) AS totalSales, |
| | | IFNULL(SUM(a.goodsCostAmount),0) AS totalCosts, |
| | | IFNULL(SUM(a.goodsProfitAmount),0) AS totalProfits |
| | | FROM ( |
| | | SELECT |
| | | tomg.goodsName, |
| | | IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.thisSalePrice ),0) AS goodsSaleAmount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.goodsCostPrice ),0) AS goodsCostAmount, |
| | | IFNULL(SUM(tomg.goodsCount * (tomg.thisSalePrice - tomg.goodsCostPrice)),0) AS goodsProfitAmount |
| | | FROM t_order_sale_goods tomg |
| | | LEFT JOIN t_order_sale tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | | </if> |
| | | <if test="query.typeId != null and query.typeId != ''"> |
| | | AND tomg.typeId = #{query.typeId} |
| | | </if> |
| | | <if test="query.shopId != null"> |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName) a |
| | | </select> |
| | | <select id="profitDetailsExport" resultType="com.ruoyi.system.vo.GoodsProfitVO"> |
| | | SELECT |
| | | tomg.goodsName, |
| | | (select typeName from t_goods_type where id = tomg.typeId) AS typeName, |
| | | IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.thisSalePrice ),0) AS goodsSaleAmount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.goodsCostPrice ),0) AS goodsCostAmount, |
| | | IFNULL(SUM(tomg.goodsCount *(tomg.thisSalePrice - tomg.goodsCostPrice)),0) AS goodsProfitAmount |
| | | FROM t_order_sale_goods tomg |
| | | LEFT JOIN t_order_sale tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | | </if> |
| | | <if test="query.typeId != null and query.typeId != ''"> |
| | | AND tomg.typeId = #{query.typeId} |
| | | </if> |
| | | <if test="query.shopId != null"> |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName |
| | | </select> |
| | | |
| | | </mapper> |