feat:商户结账完成

This commit is contained in:
dzc committed 2025-05-09 14:39:35 +08:00
1 parent bcef424570
commit d622e8cd90
18 files changed
+191 -8

No files matched your search

@@ -29,6 +29,8 @@ public class HardInvoiceVo extends HardInvoiceEntity implements BaseDeptInterfac
private String logoPic;
private String merchantType;
/**
* 订单相关
*/
@@ -20,6 +20,8 @@ public class HardManagerVo extends HardManagerEntity implements BaseDeptInterfac
private String logoPic;
private String merchantType;
/**
* 分类相关
*/
@@ -31,6 +31,9 @@ public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
@Schema(description = "商户id")
private Long merchantId;
@Schema(description = "商户类型")
private String merchantType;
@Schema(description = "总消费金额")
private BigDecimal totalPayPrice;
@@ -30,6 +30,9 @@ public class HardOrderSbVo implements BaseMchInterface, BaseHardInterface {
@Schema(description = "商户名称")
private String merchantName;
@Schema(description = "商户类型")
private String merchantType;
@Schema(description = "商户logo")
private String logoPic;
@@ -16,4 +16,6 @@ public class HardSpuCategoryVo extends HardSpuCategoryEntity implements BaseMchI
private String logoPic;
private String merchantType;
}
@@ -34,6 +34,8 @@ public class HardSpuRepertoryVo extends HardSpuRepertoryEntity implements BaseMc
private String logoPic;
private String merchantType;
/**
* 用户相关
*/
@@ -41,5 +41,5 @@ public interface BaseUserDeptInterface {
*/
String getUserDeptName();
void setUserDeptName(String deptName);
void setUserDeptName(String userDeptName);
}
@@ -3,6 +3,14 @@ package com.bsd.pjcloud.wallet.api.dto.mch;
import com.bsd.pjcloud.wallet.api.entity.mch.MchCheckoutEntity;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
public class MchCheckoutDto extends MchCheckoutEntity {
private LocalDate[] checkoutTimeList;
private LocalDate[] createTimeList;
}
@@ -24,6 +24,7 @@ public class WalletDataUtil {
if (ObjectUtil.isEmpty(vo)) return v;
v.setMerchantName(vo.getName());
v.setLogoPic(vo.getLogoPic());
v.setMerchantType(vo.getTypes());
return v;
}
@@ -43,4 +43,6 @@ public class WalletActiveVo extends WalletActiveEntity implements BaseUserInterf
private String walletTypeIcon;
private String isRule;
private String merchantType;
}
@@ -23,5 +23,12 @@ public interface BaseMchInterface {
void setLogoPic(String logoPic);
/**
* 商户类型
*/
String getMerchantType();
void setMerchantType(String merchantType);
}
@@ -1,8 +1,41 @@
package com.bsd.pjcloud.wallet.api.vo.mch;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserDeptInterface;
import com.bsd.pjcloud.wallet.api.entity.mch.MchCheckoutEntity;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
public class MchCheckoutVo extends MchCheckoutEntity {
public class MchCheckoutVo extends MchCheckoutEntity implements BaseMchInterface, BaseUserDeptInterface {
/**
* 店铺相关
*/
private Long merchantId;
private String merchantName;
private String logoPic;
/**
* 用户部门相关
*/
private Long userId;
private String username;
private String userMobile;
private String userAvatar;
private Long userDeptId;
private String userDeptName;
private String merchantType;
}
@@ -17,6 +17,8 @@ public class MchDeptVo extends MchDeptEntity implements BaseMchInterface, BaseDe
private String logoPic;
private String merchantType;
/**
* 部门相关
*/
@@ -6,9 +6,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.dto.mch.MchCheckoutDto;
import com.bsd.pjcloud.wallet.api.entity.mch.MchCheckoutEntity;
import com.bsd.pjcloud.wallet.api.vo.mch.MchCheckoutVo;
import com.bsd.pjcloud.wallet.service.MchCheckoutService;
import lombok.Data;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -35,11 +41,11 @@ public class MchCheckoutController {
private final MchCheckoutService mchCheckoutService;
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PostMapping("/page-join")
@PreAuthorize("@pms.hasPermission('wallet_mchCheckout_view')")
public R getMchCheckoutPage(@ParameterObject Page page, @ParameterObject MchCheckoutEntity mchCheckout) {
LambdaQueryWrapper<MchCheckoutEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(mchCheckoutService.page(page, wrapper));
public R<Page<MchCheckoutVo>> getMchCheckoutPage(@ParameterObject Page page, @RequestBody MchCheckoutDto dto) {
DataScope dataScope = DataScope.of();
return R.ok(mchCheckoutService.scopPageList(page, dto, dataScope));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@@ -54,7 +60,8 @@ public class MchCheckoutController {
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_mchCheckout_add')")
public R save(@RequestBody MchCheckoutEntity mchCheckout) {
return R.ok(mchCheckoutService.save(mchCheckout));
PjcloudUser user = SecurityUtils.getUser();
return R.ok(mchCheckoutService.create(mchCheckout, user));
}
@Operation(summary = "修改商户结账", description = "修改商户结账")
@@ -1,11 +1,16 @@
package com.bsd.pjcloud.wallet.mapper.mch;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.mch.MchCheckoutDto;
import com.bsd.pjcloud.wallet.api.entity.mch.MchCheckoutEntity;
import com.bsd.pjcloud.wallet.api.vo.mch.MchCheckoutVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface MchCheckoutMapper extends PjcloudBaseMapper<MchCheckoutEntity> {
Page<MchCheckoutVo> scopPageList(Page page, @Param("dto") MchCheckoutDto dto, DataScope dataScope);
}
@@ -1,8 +1,16 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.wallet.api.dto.mch.MchCheckoutDto;
import com.bsd.pjcloud.wallet.api.entity.mch.MchCheckoutEntity;
import com.bsd.pjcloud.wallet.api.vo.mch.MchCheckoutVo;
public interface MchCheckoutService extends IService<MchCheckoutEntity> {
Page<MchCheckoutVo> scopPageList(Page page, MchCheckoutDto dto, DataScope dataScope);
Long create(MchCheckoutEntity mchCheckout, PjcloudUser user);
}
@@ -1,13 +1,62 @@
package com.bsd.pjcloud.wallet.service.impl.mch;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.admin.api.vo.UserVO;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.wallet.api.dto.mch.MchCheckoutDto;
import com.bsd.pjcloud.wallet.api.entity.mch.MchCheckoutEntity;
import com.bsd.pjcloud.wallet.api.vo.mch.MchCheckoutVo;
import com.bsd.pjcloud.wallet.mapper.mch.MchCheckoutMapper;
import com.bsd.pjcloud.wallet.service.MchCheckoutService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.util.Objects;
/**
* 商户结账
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class MchCheckoutServiceImpl extends ServiceImpl<MchCheckoutMapper, MchCheckoutEntity> implements MchCheckoutService {
private final RemoteUserService remoteUserService;
@Override
public Page<MchCheckoutVo> scopPageList(Page page, MchCheckoutDto dto, DataScope dataScope) {
Page<MchCheckoutVo> pageList = baseMapper.scopPageList(page, dto, dataScope);
disposeList(pageList.getRecords(), dto);
return pageList;
}
@Override
public Long create(MchCheckoutEntity mchCheckout, PjcloudUser user) {
mchCheckout.setCheckoutUserId(user.getId());
baseMapper.insert(mchCheckout);
return mchCheckout.getId();
}
private void disposeList(List<MchCheckoutVo> list, MchCheckoutDto dto) {
if (ObjectUtil.isEmpty(list)) return;
// 用户部门
list.forEach(v -> v.setUserId(v.getCheckoutUserId()));
List<Long> userIds = list.stream().map(MchCheckoutVo::getCheckoutUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(userIds)) {
List<UserVO> userDeptList = remoteUserService.getUserDeptByIds(userIds).getData();
if (ObjectUtil.isNotEmpty(userDeptList)) {
DataUtil.convertUserDeptList(list, CollectionUtils.convertMap(userDeptList, UserVO::getUserId));
}
}
}
}
@@ -17,4 +17,51 @@
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<sql id="selectA">
select a.id,
a.checkout_time,
a.checkout_user_id,
a.merchant_id,
a.price,
a.pic,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id,
</sql>
<sql id="whereA">
<if test="dto.id != null">
and a.id = #{dto.id}
</if>
<if test="dto.checkoutUserId != null">
and a.checkout_user_id = #{dto.checkoutUserId}
</if>
<if test="dto.merchantId != null">
and a.merchant_id = #{dto.merchantId}
</if>
<if test="dto.merchantId != null">
and a.merchant_id = #{dto.merchantId}
</if>
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
<if test="dto.checkoutTimeList != null and dto.checkoutTimeList.length == 2">
and a.checkout_time between #{dto.checkoutTimeList[0]} and #{dto.checkoutTimeList[1]}
</if>
</sql>
<select id="scopPageList" resultType="com.bsd.pjcloud.wallet.api.vo.mch.MchCheckoutVo">
<include refid="selectA"/>
m.id as merchantId,
m.name as merchantName,
m.logo_pic as logoPic
from mch_checkout a
left join mch_manage m on a.merchant_id = m.id
<where>
<include refid="whereA"/>
</where>
group by a.create_time,a.id
</select>
</mapper>