技师数据统一

This commit is contained in:
曹磊 2024-07-11 14:14:44 +08:00
parent b41a463684
commit 26ac9c5538
7 changed files with 92 additions and 20 deletions

View File

@ -22,4 +22,6 @@ public interface UserMoneyDetailsDao extends BaseMapper<UserMoneyDetails> {
IPage<UserMoneyDetails> findUserMontyDetailPage(Page<UserMoneyDetails> page, @Param("userId") Long userId);
List<UserMoneyDetails> selectArtificerQianbao(Long userId, String startTime, String endTime);
BigDecimal selectArtificerMoney(Long userId,String startTime,String endTime);
}

View File

@ -26,4 +26,6 @@ public interface UserMoneyDetailsService extends IService<UserMoneyDetails> {
int insert(UserMoneyDetails userMoneyDetails);
Result selectArtificerQianbao(Long artificerId, String startTime, String endTime,Integer page, Integer limit);
BigDecimal selectArtificerMoney(Long userId, @Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@ -20,6 +20,7 @@ import com.sqx.modules.artificer.service.ArtificerService;
import com.sqx.modules.artificer.service.ArtificerTimeService;
import com.sqx.modules.common.service.CommonInfoService;
import jodd.util.StringUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -400,4 +401,8 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
return Result.success(map);
}
@Override
public BigDecimal selectArtificerMoney(Long userId, @Param("startTime") String startTime, @Param("endTime") String endTime){
return baseMapper.selectArtificerMoney(userId,startTime,endTime);
}
}

View File

@ -41,7 +41,7 @@ public interface OrdersDao extends BaseMapper<Orders> {
BigDecimal selectOrdersMoney(String time, Integer type,Integer status);
BigDecimal selectSumMoney(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime);
BigDecimal selectSumOrdersMoney(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime);
BigDecimal selectSumMoneyMonth(Long userId,@Param("time") String time);

View File

@ -1465,7 +1465,12 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
orders.setOldMassageDuration(oldOrders.getDuration());
orders.setOldArtificerMoney(oldOrders.getArtificerMoney());
orders.setArtificerTaxiMoney(oldOrders.getArtificerTaxiMoney());
orders.setOldProjectBenefits(oldOrders.getProjectBenefits());
if(oldOrders.getIsSupplement().equals(1)){
BigDecimal projectBenefits = oldOrders.getProjectBenefits().add(oldOrders.getOldProjectBenefits());
orders.setOldProjectBenefits(projectBenefits);
}else{
orders.setOldProjectBenefits(oldOrders.getProjectBenefits());
}
//获取用户VIP的优惠信息
BigDecimal vipRate = new BigDecimal(100);
@ -6127,15 +6132,16 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
Artificer artificer = artificerService.getById(artificerId);
Map<String, Object> result = new HashMap<String, Object>();
//总收益
BigDecimal sumMoney = ordersDao.selectSumMoney(artificerId, startTime, endTime);
BigDecimal sumMoney = userMoneyDetailsService.selectArtificerMoney(artificer.getUserId(), startTime, endTime);
//总销量 有关这个技师的订单销售数量的累计
int countOrderNum = ordersDao.selectCountOrderNum(artificerId, startTime, endTime);
//评价分数
Double countTakingByUserId = orderTakingCommentDao.selectCountTakingByUserId(artificerId, startTime, endTime);
//订单收入
BigDecimal orderMoney = sumMoney;
BigDecimal orderMoney = ordersDao.selectSumOrdersMoney(artificerId, startTime, endTime);
//总订单数
int countOrder = ordersDao.selectCountOrder(artificerId, null, startTime, endTime);
String countOrderStr = ordersDao.selectOrdersArtificerIntegral(artificerId, endTime, startTime );
Integer countOrder = Integer.valueOf(countOrderStr);
//退款金额
BigDecimal sumRefund = userMoneyDetailsService.selectSumRefund(artificer.getUserId(), startTime, endTime);
//访客人数

View File

@ -136,4 +136,20 @@
</if>
GROUP BY type
</select>
<select id="selectArtificerMoney" resultType="java.math.BigDecimal">
select sum(money)
from user_money_details
where user_id=#{userId}
and type = 1
and state = 2
and bl_role = 2
<if test="startTime!=null and startTime!=''">
and date_format(create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
</select>
</mapper>

View File

@ -569,14 +569,50 @@
</if>
</select>
<select id="selectSumMoney" resultType="java.math.BigDecimal">
select ifnull(sum(sum_artificer_money), 0) from orders where artificer_id = #{userId} and status in (3,5)
<if test="startTime!=null and startTime!=''">
and date_format(pay_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
<!-- 数据统计-技师订单总收益-->
<select id="selectSumOrdersMoney" resultType="java.math.BigDecimal">
select IFNULL(SUM(artificer_money_total),0) AS currentEarnings
from (
select (case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total
from orders o
left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o.artificer_id = #{userId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startTime!=null and startTime!=''">
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
and o.status in (3,5)
union all
select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
from orders o
where o.artificer_id = #{userId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startTime!=null and startTime!=''">
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
and o.status in (3,5)
) t
</select>
<select id="selectSumMoneyMonth" resultType="java.math.BigDecimal">
@ -601,10 +637,10 @@
<select id="selectCountOrderNum" resultType="int">
select ifnull(sum(massage_num), 0) as num from orders where artificer_id = #{userId} and status in (2,3,5,6,7,8,9,10)
<if test="startTime!=null and startTime!=''">
and date_format(pay_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
and date_format(end_times,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
</select>
@ -1217,10 +1253,10 @@
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startDate},'%Y-%m-%d')
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') &lt;= #{endDate}
and date_format(o.end_times,'%Y-%m-%d') &lt;= date_format(#{endDate},'%Y-%m-%d')
</if>
and o.status in (3,5)
union all
@ -1239,14 +1275,13 @@
and status != 4
)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate}
and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startDate},'%Y-%m-%d')
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') &lt;= #{endDate}
and date_format(o.end_times,'%Y-%m-%d') &lt;= date_format(#{endDate},'%Y-%m-%d')
</if>
and o.status in (3,5)
) t
</select>
<!-- 加钟率-->
<select id="selectOrdersArtificerIntegraladdNum" resultType="java.lang.String">
@ -1564,6 +1599,11 @@
select t.*,price_total AS jifen
from (
select o.*,
(case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) +
ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total,
(
(case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
@ -1587,6 +1627,7 @@
and o.status in (3,5)
union all
select o.*,
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total,
o.price + ifnull(o.add_price,0) as price_total
from orders o
left join orders_massage om on om.orders_id=o.orders_id