Merge branch 'refs/heads/gyj' into dev

This commit is contained in:
GYJ 2024-07-10 13:41:34 +08:00
commit 2efdb7d780
9 changed files with 50 additions and 34 deletions

View File

@ -1,7 +1,5 @@
package cn.ysk.cashier.controller.shop; package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.ShopSummaryDto; import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.service.SummaryService; import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.vo.TbOrderPayCountVo; import cn.ysk.cashier.vo.TbOrderPayCountVo;

View File

@ -50,6 +50,7 @@ public class TbShopUserController {
@GetMapping("queryAllShopUser") @GetMapping("queryAllShopUser")
@ApiOperation("查询商家用户") @ApiOperation("查询商家用户")
@AnonymousGetMapping
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) { public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) {
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK); return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK);
} }

View File

@ -19,19 +19,16 @@ public interface ShopUserMapper extends BaseMapper<TbShopUser> {
"FROM tb_shop_user su " + "FROM tb_shop_user su " +
"LEFT JOIN tb_user_info u ON su.user_id = u.id " + "LEFT JOIN tb_user_info u ON su.user_id = u.id " +
"<where> " + "<where> " +
"su.user_id is not null and su.user_id != ''" +
"<if test='param.shopId != null and param.shopId != &quot;&quot; and param.shopId != 1'>" + "<if test='param.shopId != null and param.shopId != &quot;&quot; and param.shopId != 1'>" +
"AND su.shop_id = #{param.shopId} " + "AND su.shop_id = #{param.shopId} " +
"</if>" + "</if>" +
"<if test='param.name != null and param.name != &quot;&quot;'>" + "<if test='param.name != null and param.name != &quot;&quot;'>" +
"AND (u.nick_name like concat('%', #{param.name}, '%') or u.telephone like concat('%', #{param.name}, '%'))" + "AND (u.nick_name like concat('%', #{param.name}, '%') or u.telephone like concat('%', #{param.name}, '%'))" +
"</if>" + "</if>" +
"<if test='param.isVip != null and param.isVip != &quot;&quot;'>" + "AND su.is_vip=#{isVip}" +
"AND su.is_vip=#{param.isVip}" +
"</if>" +
"</where>" + "</where>" +
"</script>") "</script>")
IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Page pageInfo); IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Integer isVip, Page pageInfo);
@Select("<script> " + @Select("<script> " +
"select " + "select " +

View File

@ -16,19 +16,23 @@ import java.util.Map;
*/ */
public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> { public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> {
@Select("<script>" + @Select("<script>" +
"SELECT " + "SELECT \n" +
"COUNT(*) userTotal, " + " COUNT(DISTINCT a.id) AS userTotal, \n" +
"ifnull(SUM( " + " COALESCE(SUM(flow.total_amount), 0) AS chageTotal, \n" +
"IFNULL( b.charge_amount, 0 )), 0) chageTotal\n" + " COALESCE(SUM(a.amount), 0) AS balanceTotal \n" +
"FROM\n" + "FROM \n" +
"tb_shop_user AS a\n" + " tb_shop_user AS a\n" +
"LEFT JOIN tb_user_info AS b ON a.user_id = b.id\n" + " LEFT JOIN (\n" +
"WHERE\n" + " SELECT shop_user_id, SUM(amount) AS total_amount \n" +
" a.shop_id = #{shopId}\n" + " FROM tb_shop_user_flow \n" +
" WHERE biz_code IN ('cashMemberIn','scanMemberIn') \n" +
" GROUP BY shop_user_id\n" +
" ) AS flow ON flow.shop_user_id = a.id\n" +
"WHERE \n" +
" a.shop_id = #{shopId} \n" +
"<if test=\"isVip !=null\">\n" + "<if test=\"isVip !=null\">\n" +
" and a.is_vip=#{isVip}\n" + " and a.is_vip=#{isVip}\n" +
"</if>" + "</if>" +
"</script>") "</script>")
Map<String, Object> selectUserSummary(@Param("shopId") String shopId, @Param("isVip") Integer isVip); Map<String, Object> selectUserSummary(@Param("shopId") String shopId, @Param("isVip") Integer isVip);

View File

@ -19,23 +19,26 @@ public interface TbShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
* @param shopId 店铺ID * @param shopId 店铺ID
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @param types 流水类型
* @return 用户流水总金额 * @return 用户流水总金额
*/ */
@Select("<script>" + @Select("<script>" +
"SELECT IFNULL(SUM(uf.amount), 0) FROM tb_shop_user_flow as uf " + " SELECT \n" +
"JOIN tb_shop_user su ON uf.shop_user_id = su.user_id " + " COALESCE(SUM(flow.total_amount), 0) AS chageTotal\n" +
"WHERE su.shop_id = #{shopId} " + "FROM \n" +
"AND uf.create_time BETWEEN #{startTime} AND #{endTime} " + " tb_shop_user AS a\n" +
"AND uf.biz_code IN " + " LEFT JOIN (\n" +
"<foreach collection='types' item='type' open='(' separator=',' close=')'> " + " SELECT shop_user_id, SUM(amount) AS total_amount \n" +
"#{type} " + " FROM tb_shop_user_flow \n" +
"</foreach> " + " WHERE biz_code IN ('cashMemberIn','scanMemberIn') \n" +
" AND create_time BETWEEN #{startTime} AND #{endTime} \n" +
" GROUP BY shop_user_id\n" +
" ) AS flow ON flow.shop_user_id = a.id\n" +
"WHERE \n" +
" a.shop_id = #{shopId}" +
"</script>") "</script>")
BigDecimal sumUserFlowAmountByConditions(@Param("shopId") Long shopId, BigDecimal sumUserFlowAmountByConditions(@Param("shopId") Long shopId,
@Param("startTime") String startTime, @Param("startTime") String startTime,
@Param("endTime") String endTime, @Param("endTime") String endTime);
@Param("types") List<String> types);
} }

View File

@ -12,5 +12,5 @@ import java.util.List;
*/ */
public interface TbShopUserFlowService extends IService<TbShopUserFlow> { public interface TbShopUserFlowService extends IService<TbShopUserFlow> {
BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime, List<String> types); BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime);
} }

View File

@ -15,7 +15,7 @@ import java.util.List;
@Service @Service
public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper, TbShopUserFlow> implements TbShopUserFlowService { public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper, TbShopUserFlow> implements TbShopUserFlowService {
@Override @Override
public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime, List<String> types) { public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime) {
return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime, types); return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime);
} }
} }

View File

@ -379,8 +379,7 @@ public class SummaryServiceImpl implements SummaryService {
BigDecimal recharge = tbShopUserFlowService.sumUserFlowAmountByConditions(Long.valueOf(summaryDto.getShopId()), BigDecimal recharge = tbShopUserFlowService.sumUserFlowAmountByConditions(Long.valueOf(summaryDto.getShopId()),
tbOrderPayCountByDayVo.getTradeDay() + " 00:00:00", tbOrderPayCountByDayVo.getTradeDay() + " 00:00:00",
tbOrderPayCountByDayVo.getTradeDay() + " 23:59:59", tbOrderPayCountByDayVo.getTradeDay() + " 23:59:59");
Arrays.asList("cashMemberIn", "scanMemberIn"));
tbOrderPayCountByDayVo.setRecharge(recharge); tbOrderPayCountByDayVo.setRecharge(recharge);
BigDecimal decimal = tbOrderInfoRepository.queryRefundOrderAmountByTradeDay(summaryDto.getShopId(), tbOrderPayCountByDayVo.getTradeDay()); BigDecimal decimal = tbOrderInfoRepository.queryRefundOrderAmountByTradeDay(summaryDto.getShopId(), tbOrderPayCountByDayVo.getTradeDay());

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.service.impl.shopimpl; package cn.ysk.cashier.service.impl.shopimpl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto; import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto; import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
import cn.ysk.cashier.dto.shop.TbShopUserDto; import cn.ysk.cashier.dto.shop.TbShopUserDto;
@ -49,8 +50,21 @@ public class TbShopUserServiceImpl implements TbShopUserService {
@Override @Override
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) { public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) {
IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria, IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria, criteria.getIsVip(),
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize())); new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()));
for (ShopUserInfoVo shopUserInfoVo : iPage.getRecords()) {
if (StrUtil.isBlank(shopUserInfoVo.getNickName())) {
tbShopUserRepository.findById(shopUserInfoVo.getId()).ifPresent(tbShopUser -> {
shopUserInfoVo.setNickName(tbShopUser.getName());
shopUserInfoVo.setBirthDay(tbShopUser.getBirthDay());
shopUserInfoVo.setHeadImg(tbShopUser.getHeadImg());
shopUserInfoVo.setTelephone(tbShopUser.getTelephone());
shopUserInfoVo.setTotalScore(0);
});
}
}
return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + "")); return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + ""));
} }