From 75b0e681f967d82f971eb40d6356c697b4ed9ad6 Mon Sep 17 00:00:00 2001 From: fengb Date: Wed, 20 Sep 2023 19:27:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=AC=A0=E6=AC=BE=E7=9A=84?= =?UTF-8?q?=E4=BA=A4=E6=98=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengb --- .../mall/controller/CustomerController.java | 44 ++++++++++++++++++- .../mall/controller/PurchaseController.java | 22 ++++++++++ .../hiver/mall/dao/mapper/CustomerMapper.java | 3 ++ .../hiver/mall/dao/mapper/PurchaseMapper.java | 4 ++ .../cc/hiver/mall/pojo/dto/DebtCustomer.java | 25 +++++++++++ .../cc/hiver/mall/pojo/dto/DebtSupplier.java | 25 +++++++++++ .../mall/service/mybatis/CustomerService.java | 4 ++ .../mall/service/mybatis/PurchaseService.java | 4 ++ .../mybatis/CustomerServiceImpl.java | 13 ++++++ .../mybatis/PurchaseServiceImpl.java | 12 +++++ .../main/resources/mapper/CustomerMapper.xml | 16 +++++++ .../main/resources/mapper/PurchaseMapper.xml | 34 ++++++++++---- 12 files changed, 196 insertions(+), 10 deletions(-) create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtCustomer.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtSupplier.java diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java index d143d765..c8ca9c7d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java @@ -1,19 +1,30 @@ package cc.hiver.mall.controller; +import cc.hiver.core.common.utils.PageUtil; import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.StringUtils; +import cc.hiver.core.common.vo.PageVo; import cc.hiver.core.common.vo.Result; +import cc.hiver.core.entity.Role; import cc.hiver.core.entity.User; +import cc.hiver.core.entity.UserRole; +import cc.hiver.core.service.RoleService; +import cc.hiver.core.service.UserRoleService; import cc.hiver.core.service.UserService; import cc.hiver.mall.entity.Customer; +import cc.hiver.mall.pojo.dto.DebtCustomer; import cc.hiver.mall.service.mybatis.CustomerService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -32,10 +43,23 @@ public class CustomerController { @Autowired private UserService userService; + @Autowired + private UserRoleService userRoleService; + + @Autowired + private RoleService roleService; + @RequestMapping(value = "/save", method = RequestMethod.POST) @ApiOperation(value = "新增客户") + @Transactional public Result save(Customer customer) { + boolean result =true; + User byUsername = userService.findByUsername(customer.getUserName()); + User byMobile = userService.findByMobile(customer.getPhone()); + if (!ObjectUtils.isEmpty(byUsername) || !ObjectUtils.isEmpty(byMobile)){ + return ResultUtil.error("该账号或手机号已存在。"); + } String encryptPass = new BCryptPasswordEncoder().encode("123456");//默认密码 User user = new User(); user.setUsername(customer.getUserName()); @@ -47,8 +71,17 @@ public class CustomerController { user.setPassword(encryptPass); User saveUser = userService.save(user); customer.setUserId(saveUser.getId()); - boolean result = customerService.save(customer); - + result = customerService.save(customer); + UserRole userRole = new UserRole(); + PageVo pageVo = new PageVo(); + pageVo.setPageNumber(1); + pageVo.setPageSize(1); + Page rolePage = roleService.findByCondition("ROLE_CUSTOMER", PageUtil.initPage(pageVo)); + Role role = rolePage.getContent().get(0); + userRole.setRoleId(role.getId());//客户角色 + userRole.setRoleName("客户"); + userRole.setUserId(saveUser.getId()); + userRoleService.save(userRole); if(result) { return ResultUtil.success("添加成功"); } else { @@ -111,4 +144,11 @@ public class CustomerController { } + @RequestMapping(value = "/debt", method = RequestMethod.GET) + @ApiOperation(value = "查询欠款客户列表") + public Result debt(String shopId) { + List list = customerService.debt(shopId); + return new ResultUtil>().setData(list); + } + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java index f095b789..30301000 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PurchaseController.java @@ -5,6 +5,7 @@ import cc.hiver.core.common.utils.StringUtils; import cc.hiver.core.common.vo.Result; import cc.hiver.mall.entity.Purchase; import cc.hiver.mall.entity.PurchaseDetail; +import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.service.mybatis.PurchaseDetailService; import cc.hiver.mall.service.mybatis.PurchaseService; @@ -94,4 +95,25 @@ public class PurchaseController { return new ResultUtil>().setData(list); } + + @RequestMapping(value = "/debt", method = RequestMethod.GET) + @ApiOperation(value = "根据商铺id查询上游欠款供应商列表") + public Result debt(String shopId) { + List list = purchaseService.getDebtByShopId(shopId); + return new ResultUtil>().setData(list); + } + + @RequestMapping(value = "/debtPurchase", method = RequestMethod.GET) + @ApiOperation(value = "查询供应商的欠款采购单列表") + public Result list(String supplierId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.ge("no_pay",0); + queryWrapper.eq("supplier_id",supplierId); + List list = purchaseService.list(queryWrapper); + return new ResultUtil>().setData(list); + } + + + + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java index 7f39cbc7..55ff7d8f 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/CustomerMapper.java @@ -2,6 +2,7 @@ package cc.hiver.mall.dao.mapper; import cc.hiver.mall.entity.Customer; import cc.hiver.mall.entity.CustomerExample; +import cc.hiver.mall.pojo.dto.DebtCustomer; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -31,4 +32,6 @@ public interface CustomerMapper extends BaseMapper { int updateByPrimaryKeySelective(Customer record); int updateByPrimaryKey(Customer record); + + List selectDebtByShopId(String shopId); } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java index b0585885..f1a3db82 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/PurchaseMapper.java @@ -2,6 +2,7 @@ package cc.hiver.mall.dao.mapper; import cc.hiver.mall.entity.Purchase; import cc.hiver.mall.entity.PurchaseExample; +import cc.hiver.mall.pojo.dto.DebtSupplier; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -30,4 +31,7 @@ public interface PurchaseMapper extends BaseMapper { int updateByPrimaryKeySelective(Purchase record); int updateByPrimaryKey(Purchase record); + + List selectDebtByShopId(String shopId); + } \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtCustomer.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtCustomer.java new file mode 100644 index 00000000..1b275b05 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtCustomer.java @@ -0,0 +1,25 @@ +package cc.hiver.mall.pojo.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @类描述 + * @作者 冯彬 + * @时间 2023/9/19-下午10:05 + */ +@Data +public class DebtCustomer { + + @ApiModelProperty(value = "用户ID") + private String userId; + + @ApiModelProperty(value = "用户名称") + private String nickname; + + @ApiModelProperty(value = "欠款金额") + private BigDecimal no_earn; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtSupplier.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtSupplier.java new file mode 100644 index 00000000..350db324 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/DebtSupplier.java @@ -0,0 +1,25 @@ +package cc.hiver.mall.pojo.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @类描述 + * @作者 冯彬 + * @时间 2023/9/19-下午10:05 + */ +@Data +public class DebtSupplier { + + @ApiModelProperty(value = "供应商ID") + private String supplierId; + + @ApiModelProperty(value = "供应商名称") + private String consigneeName; + + @ApiModelProperty(value = "欠款金额") + private BigDecimal noPay; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java index f2dd7749..2997f38e 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java @@ -2,7 +2,11 @@ package cc.hiver.mall.service.mybatis; import cc.hiver.mall.entity.Customer; import cc.hiver.mall.entity.Product; +import cc.hiver.mall.pojo.dto.DebtCustomer; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + public interface CustomerService extends IService { + List debt(String shopId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java index 7f84defe..e7c5ce6e 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/PurchaseService.java @@ -2,7 +2,11 @@ package cc.hiver.mall.service.mybatis; import cc.hiver.mall.entity.ProductAttribute; import cc.hiver.mall.entity.Purchase; +import cc.hiver.mall.pojo.dto.DebtSupplier; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + public interface PurchaseService extends IService { + List getDebtByShopId(String shopId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java index 21029f67..68f7d726 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java @@ -4,11 +4,24 @@ import cc.hiver.mall.dao.mapper.CustomerMapper; import cc.hiver.mall.dao.mapper.ProductMapper; import cc.hiver.mall.entity.Customer; import cc.hiver.mall.entity.Product; +import cc.hiver.mall.pojo.dto.DebtCustomer; import cc.hiver.mall.service.mybatis.CustomerService; import cc.hiver.mall.service.mybatis.ProductService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class CustomerServiceImpl extends ServiceImpl implements CustomerService { + + @Autowired + private CustomerMapper customerMapper; + + @Override + public List debt(String shopId) { + List list = customerMapper.selectDebtByShopId(shopId); + return list; + } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java index 03c0912e..491017f6 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/PurchaseServiceImpl.java @@ -4,11 +4,23 @@ import cc.hiver.mall.dao.mapper.ProductMapper; import cc.hiver.mall.dao.mapper.PurchaseMapper; import cc.hiver.mall.entity.Product; import cc.hiver.mall.entity.Purchase; +import cc.hiver.mall.pojo.dto.DebtSupplier; import cc.hiver.mall.service.mybatis.ProductService; import cc.hiver.mall.service.mybatis.PurchaseService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class PurchaseServiceImpl extends ServiceImpl implements PurchaseService { + + @Autowired + private PurchaseMapper purchaseMapper; + + @Override + public List getDebtByShopId(String shopId) { + return purchaseMapper.selectDebtByShopId(shopId); + } } diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml index 174e9cfb..6f628122 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml @@ -18,6 +18,11 @@ + + + + + @@ -365,4 +370,15 @@ user_id = #{userId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} + + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml index dc3d1f63..0bdcf2d9 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/PurchaseMapper.xml @@ -15,6 +15,13 @@ + + + + + + + @@ -74,7 +81,7 @@ - id, create_by, create_time, del_flag, update_by, update_time, supplier_id, shop_id, + id, create_by, create_time, del_flag, update_by, update_time, supplier_id, shop_id, total_amount, should_pay, already_pay, no_pay + select a.supplier_id,b.consignee_name,sum(a.no_pay) no_pay + from t_purchase a + left join t_supplier b on a.supplier_id = b.id + where 1=1 + and no_pay > 0 + and shop_id = #{shopId,jdbcType=VARCHAR} + group by a.supplier_id,b.consignee_name + + + \ No newline at end of file