Просмотр исходного кода

商户列表分页,编辑接口添加

杨德宝 2 лет назад
Родитель
Сommit
18fbeafa04

+ 53 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/dto/admin/merchant/SysMerchantPageDTO.java

@@ -0,0 +1,53 @@
+package com.kxs.product.api.dto.admin.merchant;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+
+/**
+ * 商户管理-商户列表-dto
+ *
+ * @author 系统
+ * @date 2024-07-05 10:27:36
+ */
+@Data
+public class SysMerchantPageDTO {
+
+    /**
+     * 商户编号
+     */
+    @Schema(description = "商户编号")
+    private String merchantNo;
+
+
+    /**
+     * 商户名称
+     */
+    @Schema(description = "商户名称")
+    private String merchantName;
+
+
+    /**
+     * 身份证号
+     */
+    @Schema(description = "身份证号")
+    private String merchantCard;
+
+
+    /**
+     * 商户电话
+     */
+    @Schema(description = "商户电话")
+    private String merchantPhone;
+
+
+    /**
+     * 机具编号
+     */
+    @Schema(description = "机具编号")
+    private String posSn;
+
+
+
+
+}

+ 45 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/dto/admin/merchant/SysMerchantUpdateDTO.java

@@ -0,0 +1,45 @@
+package com.kxs.product.api.dto.admin.merchant;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author debao.yang
+ * @createTime 2024-07-05 11:58
+ */
+@Data
+public class SysMerchantUpdateDTO {
+
+    /**
+     * 主键ID
+     */
+    @Schema(description = "主键ID")
+    private Integer id;
+
+
+    /**
+     * 商户编号
+     */
+    @Schema(description = "商户编号")
+    private String merchantNo;
+
+
+    /**
+     * 商户名称
+     */
+    @Schema(description = "商户名称")
+    private String merchantName;
+
+
+    /**
+     * 身份证号
+     */
+    @Schema(description = "身份证号")
+    private String merchantCard;
+
+    /**
+     * 商户电话
+     */
+    @Schema(description = "商户电话")
+    private String merchantPhone;
+}

+ 34 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/vo/admin/merchant/SysMerchantPageVO.java

@@ -0,0 +1,34 @@
+package com.kxs.product.api.vo.admin.merchant;
+
+
+import com.kxs.product.api.model.KxsMerchant;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 商户管理-商户列表vo
+ *
+ * @author 系统
+ * @date 2024-07-05 10:27:36
+ */
+@Data
+@Schema(description = "商户管理-商户列表返回实体")
+public class SysMerchantPageVO extends KxsMerchant implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * 机具编号
+     */
+    @Schema(description = "机具编号")
+    private String posSn;
+
+
+	
+
+}

+ 78 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/controller/admin/SysMerchantController.java

@@ -0,0 +1,78 @@
+package com.kxs.product.biz.controller.admin;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.kxs.common.core.util.R;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantPageDTO;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantUpdateDTO;
+import com.kxs.product.api.vo.admin.merchant.SysMerchantPageVO;
+import com.kxs.product.biz.service.KxsMerchantService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 商户列表(SysMerchant)控制层
+ *
+ * @author 系统
+ * @since 2024-07-05 10:27:37
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("sysMerchant")
+public class SysMerchantController {
+
+    /**
+     * 服务对象
+     */
+    private final KxsMerchantService kxsMerchantService;
+
+
+
+    /**
+     * 商户管理-商户列表
+     *
+     * @param page 分页对象
+     * @param param 查询实体
+     * @return 商户管理-商户列表
+     */
+    @GetMapping("/page")
+    public R page(Page<SysMerchantPageVO> page, SysMerchantPageDTO param) {
+        kxsMerchantService.merchantPage(page, param);
+        return R.ok(page);
+    }
+
+
+    /**
+     * 商户管理-补全商户信息
+     *
+     * @param param 实体对象
+     * @return 商户管理-补全商户信息
+     */
+    @PutMapping("/merchantUpdate")
+    public R merchantUpdate(@RequestBody SysMerchantUpdateDTO param) {
+        kxsMerchantService.merchantUpdate(param);
+        return R.ok();
+    }
+
+
+    /**
+     * 商户管理-详情查询
+     *
+     * @param id 主键ID
+     * @return 商户管理-详情查询
+     */
+    @GetMapping("/{id}")
+    public R getMerchantDetail(@PathVariable("id") Integer id) {
+        return R.ok(kxsMerchantService.getMerchantDetail(id));
+    }
+
+
+
+
+
+}
+

+ 13 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/mapper/KxsMerchantMapper.java

@@ -2,13 +2,17 @@ package com.kxs.product.biz.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantPageDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.MerchantListDTO;
 import com.kxs.product.api.model.KxsMerchant;
+import com.kxs.product.api.vo.admin.merchant.SysMerchantPageVO;
 import com.kxs.product.api.vo.kxsapp.merchant.MerchantListVO;
 import com.kxs.product.api.vo.kxsapp.merchant.MerchantTotalVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 客小爽商户表(KxsMerchant)表数据库访问层
  *
@@ -34,5 +38,14 @@ public interface KxsMerchantMapper extends BaseMapper<KxsMerchant> {
      * @return 汇总数据激活等
      */
     MerchantTotalVO merchantTotal(@Param("brandId") Integer brandId, @Param("userId") Long userId);
+
+
+    /**
+     * 商户分页查询
+     * @param page
+     * @param param
+     * @return
+     */
+    List<SysMerchantPageVO> merchantPage(Page page,@Param("query") SysMerchantPageDTO param);
 }
 

+ 28 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/KxsMerchantService.java

@@ -3,12 +3,17 @@ package com.kxs.product.biz.service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.kxs.common.core.util.R;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantPageDTO;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantUpdateDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.MachineRatioDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.MerchantListDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.ToMerchantMakerDTO;
 import com.kxs.product.api.model.KxsMerchant;
+import com.kxs.product.api.vo.admin.merchant.SysMerchantPageVO;
 import com.kxs.product.api.vo.kxsapp.merchant.MerchantListVO;
 
+import java.util.List;
+
 /**
  * 客小爽商户表(KxsMerchant)表服务接口
  *
@@ -62,5 +67,28 @@ public interface KxsMerchantService extends IService<KxsMerchant> {
      * @return {@link R}
      */
     R changeMachineRatio(MachineRatioDTO param);
+
+
+    /**
+     * 分页查询商户列表
+     * @param page
+     * @param param
+     * @return
+     */
+    List<SysMerchantPageVO> merchantPage(Page page, SysMerchantPageDTO param);
+
+    /**
+     * 更新商户信息
+     * @param sysMerchantUpdateDTO
+     */
+    void merchantUpdate(SysMerchantUpdateDTO sysMerchantUpdateDTO);
+
+
+    /**
+     * 通过id查询商户
+     * @param id
+     * @return
+     */
+    SysMerchantPageVO getMerchantDetail(Integer id);
 }
 

+ 45 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsMerchantServiceImpl.java

@@ -16,6 +16,8 @@ import com.kxs.common.core.exception.GlobalCustomerException;
 import com.kxs.common.core.util.AssertUtil;
 import com.kxs.common.core.util.R;
 import com.kxs.common.security.util.SecurityUtils;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantPageDTO;
+import com.kxs.product.api.dto.admin.merchant.SysMerchantUpdateDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.MachineRatioDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.MerchantListDTO;
 import com.kxs.product.api.dto.kxsapp.merchant.ToMerchantMakerDTO;
@@ -24,12 +26,14 @@ import com.kxs.product.api.model.KxsMachine;
 import com.kxs.product.api.model.KxsMachineRatio;
 import com.kxs.product.api.model.KxsMerchant;
 import com.kxs.product.api.req.kxs.FeeSetReq;
+import com.kxs.product.api.vo.admin.merchant.SysMerchantPageVO;
 import com.kxs.product.api.vo.kxsapp.merchant.MerchantDetailVO;
 import com.kxs.product.biz.constant.enums.ProductErrorTypeEnum;
 import com.kxs.product.biz.mapper.KxsBrandMapper;
 import com.kxs.product.biz.mapper.KxsMachineMapper;
 import com.kxs.product.biz.mapper.KxsMachineRatioMapper;
 import com.kxs.product.biz.mapper.KxsMerchantMapper;
+import com.kxs.product.biz.service.KxsMachineService;
 import com.kxs.product.biz.service.KxsMerchantService;
 import com.kxs.system.api.feign.RemoteOldService;
 import com.kxs.user.api.feign.RemoteKxsUserService;
@@ -43,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
 import java.util.Optional;
 
 /**
@@ -61,6 +66,8 @@ public class KxsMerchantServiceImpl extends ServiceImpl<KxsMerchantMapper, KxsMe
     private final KxsMachineRatioMapper kxsMachineRatioMapper;
     private final RemoteOldService remoteOldService;
 
+    private final KxsMachineService kxsMachineService;
+
 
 
     @Override
@@ -340,6 +347,44 @@ public class KxsMerchantServiceImpl extends ServiceImpl<KxsMerchantMapper, KxsMe
         return R.ok();
     }
 
+    @Override
+    public List<SysMerchantPageVO> merchantPage(Page page, SysMerchantPageDTO param) {
+        List<SysMerchantPageVO> list = baseMapper.merchantPage(page, param);
+        if(page != null){
+            page.setRecords(list);
+        }
+        return list;
+    }
+
+    @Override
+    public void merchantUpdate(SysMerchantUpdateDTO param) {
+        Integer id = param.getId();
+        KxsMerchant kxsMerchant = getById(id);
+        if(kxsMerchant != null){
+            kxsMerchant.setMerchantNo(param.getMerchantNo());
+            kxsMerchant.setMerchantName(param.getMerchantName());
+            kxsMerchant.setMerchantCard(param.getMerchantCard());
+            kxsMerchant.setMerchantPhone(param.getMerchantPhone());
+            this.updateById(kxsMerchant);
+        }
+
+    }
+
+    @Override
+    public SysMerchantPageVO getMerchantDetail(Integer id) {
+        KxsMerchant kxsMerchant = this.getById(id);
+        SysMerchantPageVO sysMerchantPageVO = new SysMerchantPageVO();
+        if(kxsMerchant != null){
+            BeanUtil.copyProperties(kxsMerchant,sysMerchantPageVO);
+            Integer machineId = kxsMerchant.getMachineId();
+            KxsMachine kxsMachine = kxsMachineService.getById(machineId);
+            if(kxsMachine != null){
+                sysMerchantPageVO.setPosSn(kxsMachine.getPosSn());
+            }
+        }
+        return sysMerchantPageVO;
+    }
+
 
 }
 

+ 37 - 0
kxs-product/kxs-product-biz/src/main/resources/mapper/KxsMerchantMapper.xml

@@ -24,6 +24,10 @@
         <result column="remark" property="remark" />
 
     </resultMap>
+
+    <resultMap id="WebKxsMerchantMap" type="com.kxs.product.api.vo.admin.merchant.SysMerchantPageVO" extends="KxsMerchantMap">
+        <result column="pos_sn" property="posSn" />
+    </resultMap>
     <select id="merchantList" resultType="com.kxs.product.api.vo.kxsapp.merchant.MerchantListVO">
         SELECT
         kme.id,
@@ -109,4 +113,37 @@
           AND kme.brand_id = #{brandId}
           AND kme.user_id = #{userId};
      </select>
+
+
+     <select id="merchantPage" resultMap="WebKxsMerchantMap">
+         SELECT
+             kme.*,
+             kma.pos_sn
+         FROM
+             kxs_merchant kme
+                 LEFT JOIN kxs_machine kma ON kme.machine_id = kma.id
+         <where>
+             and kme.del_flag = 0
+             <if test="query.merchantNo != null and query.merchantNo != ''">
+                 <bind name="merchantNoLike" value="'%'+query.merchantNo+'%'"/>
+                 AND kme.merchant_no LIKE #{merchantNoLike}
+             </if>
+             <if test="query.merchantName != null and query.merchantName != ''">
+                 <bind name="merchantNameLike" value="'%'+query.merchantName+'%'"/>
+                 AND kme.merchant_name LIKE #{merchantNameLike}
+             </if>
+             <if test="query.merchantCard != null and query.merchantCard != ''">
+                 <bind name="merchantCardLike" value="'%'+query.merchantCard+'%'"/>
+                 AND kme.merchant_card LIKE #{merchantCardLike}
+             </if>
+             <if test="query.merchantPhone != null and query.merchantPhone != ''">
+                 <bind name="merchantPhoneLike" value="'%'+query.merchantPhone+'%'"/>
+                 AND kme.merchant_phone LIKE #{merchantPhoneLike}
+             </if>
+             <if test="query.posSn != null and query.posSn != ''">
+                 <bind name="posSnLike" value="'%'+query.posSn+'%'"/>
+                 AND kma.pos_sn LIKE #{posSnLike}
+             </if>
+         </where>
+     </select>
 </mapper>