wangfukang 2 years ago
parent
commit
8b8a6565e2
  1. 16
      hiver-admin/test-output/test-report.html
  2. 2
      hiver-core/src/main/java/cc/hiver/core/common/constant/ShopConstant.java
  3. 7
      hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java
  4. 27
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java
  5. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
  6. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
  7. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java
  8. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java
  9. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java
  10. 22
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java
  11. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/mapper/DebtMapper.java
  12. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java
  13. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java
  14. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Customer.java
  15. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Shop.java
  16. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopUser.java
  17. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java
  18. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java
  19. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java
  20. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java
  21. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
  22. 24
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java
  23. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java
  24. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java
  25. 32
      hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml
  26. 18
      hiver-modules/hiver-mall/src/main/resources/mapper/DebtMapper.xml
  27. 5
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnDetailMapper.xml
  28. 13
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml
  29. 13
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml
  30. 27
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml
  31. 55
      hiver-modules/hiver-mall/src/main/resources/mapper/ShopMapper.xml

16
hiver-admin/test-output/test-report.html

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">十月 08, 2024 19:35:03</span></a>
<a href="#"><span class="badge badge-primary">十月 13, 2024 00:07:47</span></a>
</li>
</ul>
</div>
@ -84,7 +84,7 @@
<div class="test-detail">
<span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p>
<p class="text-sm"><span>19:35:03 下</span> / <span>0.015 secs</span></p>
<p class="text-sm"><span>00:07:47 上</span> / <span>0.017 secs</span></p>
</div>
<div class="test-contents d-none">
<div class="detail-head">
@ -92,9 +92,9 @@
<div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>10.08.2024 19:35:03</span>
<span class='badge badge-danger'>10.08.2024 19:35:03</span>
<span class='badge badge-default'>0.015 secs</span>
<span class='badge badge-success'>10.13.2024 00:07:47</span>
<span class='badge badge-danger'>10.13.2024 00:07:47</span>
<span class='badge badge-default'>0.017 secs</span>
</div>
<div class="m-t-10 m-l-5"></div>
</div>
@ -104,7 +104,7 @@
<tbody>
<tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td>
<td>19:35:03</td>
<td>0:07:47</td>
<td>
Test passed
</td>
@ -128,13 +128,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>十月 08, 2024 19:35:03</h3>
<h3>十月 13, 2024 00:07:47</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>十月 08, 2024 19:35:03</h3>
<h3>十月 13, 2024 00:07:47</h3>
</div></div>
</div>
<div class="col-md-3">

2
hiver-core/src/main/java/cc/hiver/core/common/constant/ShopConstant.java

@ -16,4 +16,6 @@ public interface ShopConstant {
*/
Integer SHOP_STATUS_LOCK = 0;
String[] PRINTING_METHOD = {"0","1"};
}

7
hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/AuthController.java

@ -5,10 +5,7 @@ import cc.hiver.base.vo.QRStatusVo;
import cc.hiver.base.vo.RegisterShopVo;
import cc.hiver.core.common.annotation.RateLimiter;
import cc.hiver.core.common.annotation.SystemLog;
import cc.hiver.core.common.constant.AppToBConstant;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.SecurityConstant;
import cc.hiver.core.common.constant.UserConstant;
import cc.hiver.core.common.constant.*;
import cc.hiver.core.common.enums.LogType;
import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.redis.RedisTemplateHelper;
@ -446,6 +443,8 @@ public class AuthController {
// 20240525 新增店铺,新增店铺尺码库
final String categoryId = productCategoryService.addCategoryOfShop();
shop.setAttrId(categoryId);
// 20241010 打印方式 字段默认给 0
shop.setPrintingMethod(ShopConstant.PRINTING_METHOD[0]);
shopService.save(shop);
// 20240625新增默认供应商
final Supplier supplier = new Supplier();

27
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomerController.java

@ -29,6 +29,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@ -248,5 +249,29 @@ public class CustomerController {
final List<Customer> list = customerService.findByUserPhoneAndShopId(userPhone, shopId);
return new ResultUtil<List<Customer>>().setData(list);
}
/**
* 根据productId和attributeList和customerId查询该客户购买该商品规格的总件数以及退货总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Result
*/
@RequestMapping(value = "/getCustomerBuyHistory", method = RequestMethod.POST)
@ApiOperation("根据productId和attributeList和customerId查询该客户购买该商品规格的总件数,以及退货总件数")
public Result getCustomerBuyHistory(String productId, String attributeList, String customerId) {
if(StringUtils.isEmpty(productId)){
return ResultUtil.error("商品id不能为空");
}
if(StringUtils.isEmpty(attributeList)){
return ResultUtil.error("商品规格不能为空");
}
if(StringUtils.isEmpty(customerId)){
return ResultUtil.error("客户id不能为空");
}
// shopId从缓存中设置
final Map<String, Object> map = customerService.getCustomerBuyHistory(productId, attributeList, customerId);
return new ResultUtil<Map<String, Object>>().setData(map);
}
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java

@ -304,6 +304,9 @@ public class ShopController {
if (shop.getRemark() != null) {
oldShop.setRemark(shop.getRemark());
}
if (shop.getPrintingMethod() != null) {
oldShop.setPrintingMethod(shop.getPrintingMethod());
}
shopService.update(oldShop);
return ResultUtil.success("更新成功");
}

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java

@ -139,6 +139,7 @@ public class SupplierControlller {
data.setAddress(entity.getAddress());
data.setConsigneeName(entity.getConsigneeName());
data.setConsigneeMobile(entity.getConsigneeMobile());
data.setOrderByField(entity.getOrderByField());
final Supplier supplier = supplierService.update(data);
return new ResultUtil<Supplier>().setData(supplier);
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java

@ -12,7 +12,7 @@ public interface ShopUserDao extends HiverBaseDao<ShopUser, String> {
@Query(value = "select * from t_shop_user where user_id = ? and shop_id = ?",nativeQuery = true)
ShopUser selectByUserIdAndShopId(String userId,String shopId);
@Query(value = "select * from t_shop_user t where t.shop_id in (select id from t_shop where status=? and start_time <= ? and end_time >= ?) and user_id = ?",nativeQuery = true)
@Query(value = "SELECT t_su.*, t_s.printing_method FROM t_shop_user t_su INNER JOIN t_shop t_s ON t_su.shop_id = t_s.id WHERE t_s.status = ? AND t_s.start_time <= ? AND t_s.end_time >= ? AND t_su.user_id = ?",nativeQuery = true)
List<ShopUser> selectByUserId(Integer status,String startTime,String endTime,String userId);
/**

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java

@ -82,4 +82,15 @@ public interface ReturnSaleMapper extends BaseMapper<ReturnSale> {
Page<ReturnSaleVo> getReturnSaleListByUserId(Page<ReturnSaleVo> page, @Param("returnSalePageQuery") ReturnSalePageQuery returnSalePageQuery);
void deleteBySaleId(@Param("saleId") String saleId);
/**
* 获取客户购买该商品退货总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Integer
*/
Integer getCustomerReturnHistory(@Param("productId") String productId,@Param("attributeList") String attributeList,@Param("customerId") String customerId);
}

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleDetailMapper.java

@ -51,4 +51,15 @@ public interface SaleDetailMapper extends BaseMapper<SaleDetail> {
List<SaleDetail> selectDetailListByProductIds(@Param("productIdList")List<String> productIdList,@Param("sale") Sale sale);
BigDecimal getTotalProfit(@Param("shopId") String shopId,@Param("startDate") String startDate,@Param("endDate") String endDate);
/**
* 获取客户购买该商品规格的总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Integer
*/
Integer getCustomerBuyHistory(@Param("productId") String productId,@Param("attributeList") String attributeList,@Param("customerId") String customerId);
}

22
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/controller/DebtController.java

@ -103,15 +103,31 @@ public class DebtController {
/**
* 查询指定店铺的所有欠款客户/供应商数量及欠款金额
* @author 王富康
* @date 2024/8/8
*
* @param queryDebtVo
* @return Result
*/
* @author 王富康
* @date 2024/8/8
*/
@RequestMapping(value = "/getAllDebtByShopId", method = RequestMethod.POST)
@ApiOperation("查询指定店铺的所有欠款客户/供应商数量及欠款金额")
public Result getAllDebtByShopId(@RequestBody QueryDebtVo queryDebtVo) {
final DebtOfShopVo debtByShopId = debtService.getAllDebtByShopId(queryDebtVo);
return new ResultUtil<>().setData(debtByShopId);
}
/**
* 查总余额人数和总余额
*
* @param queryDebtVo
* @return Result
* @author 王富康
* @date 2024/10/11
*/
@RequestMapping(value = "/getAllBalanceByShopId", method = RequestMethod.POST)
@ApiOperation("查总余额人数和总余额")
public Result getAllBalanceByShopId(@RequestBody QueryDebtVo queryDebtVo) {
final DebtOfShopVo debtOfShopVo = debtService.getAllBalanceByShopId(queryDebtVo);
return new ResultUtil<>().setData(debtOfShopVo);
}
}

12
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/mapper/DebtMapper.java

@ -12,9 +12,19 @@ import java.util.List;
public interface DebtMapper extends BaseMapper<Debt> {
Page<Debt> getDebtByShopId(Page<QueryDebtVo> page, @Param("queryDebtVo") QueryDebtVo queryDebtVo);
Debt selectByUserId(@Param("shopId")String shopId, @Param("userId") String userId);
Debt selectByUserId(@Param("shopId") String shopId, @Param("userId") String userId);
List<Debt> getDebtByUserIds(@Param("userIds") List<String> userIds);
DebtOfShopVo getAllDebtByShopId(@Param("queryDebtVo") QueryDebtVo queryDebtVo);
/**
* 查总余额人数和总余额
*
* @param queryDebtVo
* @return DebtOfShopVo
* @author 王富康
* @date 2024/10/11
*/
DebtOfShopVo getAllBalanceByShopId(@Param("queryDebtVo") QueryDebtVo queryDebtVo);
}

10
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/DebtService.java

@ -84,4 +84,14 @@ public interface DebtService extends IService<Debt> {
DebtOfShopVo getAllDebtByShopId(QueryDebtVo queryDebtVo);
void purchaseReturnToDebt(PurchaseReturn putOutPurchase, String type);
/**
* 查总余额人数和总余额
*
* @param queryDebtVo
* @return DebtOfShopVo
* @author 王富康
* @date 2024/10/11
*/
DebtOfShopVo getAllBalanceByShopId(QueryDebtVo queryDebtVo);
}

19
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/debt/service/impl/DebtServiceImpl.java

@ -292,11 +292,11 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
public Debt selectByUserId(String shopId, String userId) {
final Debt debt = debtMapper.selectByUserId(shopId, userId);
// 查询客户的分类id
if(debt != null){
if (debt != null) {
// 获取客户信息
final Customer customer = customerService.getById(userId);
// 可能传供应商的id,查不到,就不放了。
if(customer != null){
if (customer != null) {
debt.setCategoryId(customer.getCategoryId());
debt.setCategoryName(customer.getCategoryName());
}
@ -358,7 +358,7 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
public DebtOfShopVo getAllDebtByShopId(QueryDebtVo queryDebtVo) {
final DebtOfShopVo allDebtByShopId = debtMapper.getAllDebtByShopId(queryDebtVo);
// 供货商获取今日进货总件数
if(DebtConstant.USER_TYPE[1].equals(queryDebtVo.getUserType())){
if (DebtConstant.USER_TYPE[1].equals(queryDebtVo.getUserType())) {
final SupplierBillQueryVo supplierBillQueryVo = new SupplierBillQueryVo();
supplierBillQueryVo.setShopId(queryDebtVo.getShopId());
final String todayStr = DateUtil.COMMON.getDateText(new Date());
@ -426,4 +426,17 @@ public class DebtServiceImpl extends ServiceImpl<DebtMapper, Debt> implements De
dealingsRecordService.save(dealingsRecord);
}
/**
* 查总余额人数和总余额
*
* @param queryDebtVo
* @return DebtOfShopVo
* @author 王富康
* @date 2024/10/11
*/
@Override
public DebtOfShopVo getAllBalanceByShopId(QueryDebtVo queryDebtVo) {
return debtMapper.getAllBalanceByShopId(queryDebtVo);
}
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Customer.java

@ -85,4 +85,7 @@ public class Customer implements Serializable {
@ApiModelProperty(value = "客户分类名称")
private String categoryName;
@ApiModelProperty(value = "排序字段")
private String orderByField;
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Shop.java

@ -127,4 +127,7 @@ public class Shop extends HiverBaseEntity {
@ApiModelProperty(value = "店铺规格库分类id")
private String attrId;
@ApiModelProperty(value = "打印方式")
private String printingMethod;
}

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopUser.java

@ -50,4 +50,9 @@ public class ShopUser extends HiverBaseEntity {
@ApiModelProperty(value = "店主联系方式")
private String shopOwnerPhone;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "打印方式")
private String printingMethod;
}

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java

@ -45,6 +45,21 @@ public class Supplier extends HiverBaseEntity {
@ApiModelProperty(value = "供应商联系方式")
private String consigneeMobile;
@ApiModelProperty(value = "收货人所属区域")
private String consigneeArea;
@ApiModelProperty(value = "收货人公司")
private String consigneeCompany;
@ApiModelProperty(value = "用户id?")
private String userId;
@ApiModelProperty(value = "邮编")
private String zipCode;
@ApiModelProperty(value = "排序字段")
private String orderByField;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "欠款")

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/CustomerService.java

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
public interface CustomerService extends IService<Customer> {
Page<DebtCustomer> debt(CustomerPageQuery customerPageQuery);
@ -34,4 +35,6 @@ public interface CustomerService extends IService<Customer> {
* @return List<Customer>
*/
List<Customer> findByUserPhoneAndShopId(String userPhone, String shopId);
Map<String, Object> getCustomerBuyHistory(String productId, String attributeList, String customerId);
}

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ReturnSaleService.java

@ -50,4 +50,15 @@ public interface ReturnSaleService extends IService<ReturnSale> {
Page<ReturnSaleVo> getReturnSaleListByUserId(ReturnSalePageQuery returnSalePageQuery);
void deleteBySaleId(String saleId);
/**
* 获取客户购买该商品退货总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Integer
*/
Integer getCustomerReturnHistory(String productId, String attributeList, String customerId);
}

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/SaleDetailService.java

@ -53,4 +53,15 @@ public interface SaleDetailService extends IService<SaleDetail> {
* @return BigDecimal
*/
BigDecimal getTotalProfit(String shopId, String startTime, String endTime);
/**
* 获取客户购买该商品规格的总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Integer
*/
Integer getCustomerBuyHistory(String productId, String attributeList, String customerId);
}

13
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java

@ -65,14 +65,21 @@ public class SupplierServiceImpl implements SupplierService {
list.add(cb.equal(shopIdField, supplierOfquery.getShopId()));
list.add(cb.equal(delFlagField, supplierOfquery.getDelFlag()));
if (CharSequenceUtil.isNotBlank(supplierOfquery.getSearchStr())) {
Predicate p = cb.or(cb.like(consigneeNameField, "%" + supplierOfquery.getSearchStr() + "%"));
p = cb.or(p, cb.like(consigneeMobileField, "%" + supplierOfquery.getSearchStr() + "%"));
Predicate p = cb.or(cb.like(consigneeNameField, '%' + supplierOfquery.getSearchStr() + '%'));
p = cb.or(p, cb.like(consigneeMobileField, '%' + supplierOfquery.getSearchStr() + '%'));
list.add(p);
}
final Predicate[] arr = new Predicate[list.size()];
cq.where(list.toArray(arr));
final Expression<String> orderByExpression = root.get("orderByField");
final Expression<Object> orderCase = cb.selectCase()
.when(cb.isNull(orderByExpression), 1) // 如果是 null, 给一个较大的值
.otherwise(0); // 如果不是 null, 给一个较小的值
cq.orderBy(
cb.asc(orderCase), // 先按是否为 null 排序
cb.asc(orderByExpression) // 再按实际值排序
);
return null;
}
}, pageable);

24
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/CustomerServiceImpl.java

@ -23,6 +23,8 @@ import cc.hiver.mall.pojo.dto.DebtCustomer;
import cc.hiver.mall.pojo.query.CustomerPageQuery;
import cc.hiver.mall.service.mybatis.CustomerService;
import cc.hiver.mall.service.mybatis.DealingsRecordService;
import cc.hiver.mall.service.mybatis.ReturnSaleService;
import cc.hiver.mall.service.mybatis.SaleDetailService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@ -31,9 +33,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
@ -59,6 +59,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
@Autowired
private DealingsRecordService dealingsRecordService;
@Autowired
private SaleDetailService saleDetailService;
@Autowired
private ReturnSaleService returnSaleService;
@Override
public Page<DebtCustomer> debt(CustomerPageQuery customerPageQuery) {
final Page<DebtCustomer> page = new Page<>(customerPageQuery.getPageNum(), customerPageQuery.getPageSize());
@ -219,4 +225,16 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
public List<Customer> findByUserPhoneAndShopId(String userPhone, String shopId) {
return customerMapper.findByUserPhoneAndShopId(userPhone,shopId);
}
@Override
public Map<String, Object> getCustomerBuyHistory(String productId, String attributeList, String customerId) {
Map<String, Object> result = new HashMap<>();
// 获取客户购买该商品规格的总件数
Integer buyCount = saleDetailService.getCustomerBuyHistory(productId, attributeList, customerId);
result.put("buyCount",buyCount);
// 获取客户购买该商品退货总件数
Integer returnCount = returnSaleService.getCustomerReturnHistory(productId, attributeList, customerId);
result.put("returnCount",returnCount);
return result;
}
}

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ReturnSaleServiceImpl.java

@ -273,4 +273,18 @@ public class ReturnSaleServiceImpl extends ServiceImpl<ReturnSaleMapper, ReturnS
public void deleteBySaleId(String saleId) {
returnSaleMapper.deleteBySaleId(saleId);
}
/**
* 获取客户购买该商品退货总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Integer
*/
@Override
public Integer getCustomerReturnHistory(String productId, String attributeList, String customerId) {
return returnSaleMapper.getCustomerReturnHistory(productId, attributeList, customerId);
}
}

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/SaleDetailServiceImpl.java

@ -93,4 +93,18 @@ public class SaleDetailServiceImpl extends ServiceImpl<SaleDetailMapper, SaleDet
public BigDecimal getTotalProfit(String shopId, String startTime, String endTime) {
return saleDetailMapper.getTotalProfit(shopId, startTime, endTime);
}
/**
* 获取客户购买该商品规格的总件数
* @author 王富康
* @date 2024/10/11
* @param productId
* @param attributeList
* @param customerId
* @return Integer
*/
@Override
public Integer getCustomerBuyHistory(String productId, String attributeList, String customerId) {
return saleDetailMapper.getCustomerBuyHistory(productId, attributeList, customerId);
}
}

32
hiver-modules/hiver-mall/src/main/resources/mapper/CustomerMapper.xml

@ -19,6 +19,7 @@
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
<result column="category_name" jdbcType="VARCHAR" property="categoryName" />
<result column="order_by_field" jdbcType="INTEGER" property="orderByField" />
</resultMap>
<resultMap id="DebtResultMap" type="cc.hiver.mall.pojo.dto.DebtCustomer">
<result column="user_id" jdbcType="VARCHAR" property="userId" />
@ -85,7 +86,7 @@
</sql>
<sql id="Base_Column_List">
id, create_by, create_time, del_flag, update_by, update_time, name, sex, phone, address,
province, city, area, shop_id, user_id, category_id, category_name
province, city, area, shop_id, user_id, category_id, category_name, order_by_field
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.CustomerExample" resultMap="BaseResultMap">
select
@ -122,12 +123,12 @@
del_flag, update_by, update_time,
name, sex, phone, address,
province, city, area,
shop_id, user_id, category_id, category_name)
shop_id, user_id, category_id, category_name, order_by_field)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR},
#{shopId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR}, #{categoryName,jdbcType=VARCHAR})
#{shopId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR}, #{categoryName,jdbcType=VARCHAR},#{orderByField,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Customer">
insert into t_customer
@ -183,6 +184,9 @@
<if test="categoryName != null">
category_name,
</if>
<if test="orderByField != null">
order_by_field,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -236,6 +240,9 @@
<if test="categoryName != null">
#{categoryName,jdbcType=VARCHAR},
</if>
<if test="orderByField != null">
#{orderByField,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.CustomerExample" resultType="java.lang.Long">
@ -298,6 +305,9 @@
<if test="record.categoryName != null">
category_name = #{record.categoryName,jdbcType=VARCHAR},
</if>
<if test="record.orderByField != null">
order_by_field = #{record.orderByField,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -321,7 +331,8 @@
shop_id = #{record.shopId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
category_id = #{record.categoryId,jdbcType=VARCHAR},
category_name = #{record.categoryName,jdbcType=VARCHAR}
category_name = #{record.categoryName,jdbcType=VARCHAR},
order_by_field = #{record.orderByField,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -377,6 +388,9 @@
<if test="categoryName != null">
category_name = #{categoryName,jdbcType=VARCHAR},
</if>
<if test="orderByField != null">
order_by_field = #{orderByField,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -397,7 +411,8 @@
shop_id = #{shopId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
category_id = #{categoryId,jdbcType=VARCHAR},
category_name = #{categoryName,jdbcType=VARCHAR}
category_name = #{categoryName,jdbcType=VARCHAR},
order_by_field = #{orderByField,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
@ -418,7 +433,7 @@
<select id="getCustomerList" resultMap="BaseResultMap">
select
a.id, a.name, a.sex, a.phone, a.address,
a.province, a.city, a.area, a.shop_id, a.user_id, a.category_id, a.category_name,s.amount_owed as no_earn,t.not_buy_days
a.province, a.city, a.area, a.shop_id, a.user_id, a.category_id, a.category_name,a.order_by_field,s.amount_owed as no_earn,t.not_buy_days
from t_customer a
left join t_debt s
on a.id = s.user_id
@ -439,12 +454,17 @@
<when test="queryParams.sort!=null and queryParams.sort.trim() neq '' and queryParams.sort.trim() eq 'no_earn' ">
ORDER BY s.amount_owed desc
</when>
<when test="queryParams.sort!=null and queryParams.sort.trim() neq '' and queryParams.sort.trim() eq 'balance' ">
ORDER BY s.amount_owed asc
</when>
<when test="queryParams.sort!=null and queryParams.sort.trim() neq '' and queryParams.sort.trim() eq 'not_buy_days'">
ORDER BY t.not_buy_days desc
</when>
<otherwise>
<!-- 这里是'else'部分 -->
ORDER BY
a.order_by_field IS NULL,
a.order_by_field asc,
CASE
name
WHEN '散客' THEN

18
hiver-modules/hiver-mall/src/main/resources/mapper/DebtMapper.xml

@ -69,4 +69,22 @@
and user_id in (select id from t_customer where shop_id =#{queryDebtVo.shopId,jdbcType=VARCHAR} and del_flag = '0')
</if>
</select>
<select id="getAllBalanceByShopId" resultType="cc.hiver.mall.debt.vo.DebtOfShopVo">
select
IFNULL(sum(amount_owed),0.00) amount_owed,
count(user_id) person_count
from t_debt
where
<!-- 欠款金额大于0-->
amount_owed &lt; 0
<if test='queryDebtVo.userType == "1"'>
<!-- 该店铺的供应商-->
and user_id in (select id from t_supplier where shop_id =#{queryDebtVo.shopId,jdbcType=VARCHAR} and del_flag = '0')
</if>
<if test='queryDebtVo.userType == "0"'>
<!-- 该店铺的客户-->
and user_id in (select id from t_customer where shop_id =#{queryDebtVo.shopId,jdbcType=VARCHAR} and del_flag = '0')
</if>
</select>
</mapper>

5
hiver-modules/hiver-mall/src/main/resources/mapper/ReturnDetailMapper.xml

@ -554,10 +554,11 @@
<select id="getsaleReturnCost" resultType="java.math.BigDecimal">
select
IFNULL(sum(pd.purchase_price * trd.product_count),0.00) as saleReturnCost
from t_return_detail trd
from t_return_detail trd left join t_sale sa on trd.sale_id = sa.id
JOIN t_product pd ON trd.product_id = pd.id
where
trd.shop_id = #{shopId}
sa.status = '4'
and trd.shop_id = #{shopId}
and trd.create_time BETWEEN #{startTime} AND #{endTime}
and trd.return_sale_id in
(select id from t_return_sale where shop_id = #{shopId} and del_flag='0' and status != '02')

13
hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml

@ -695,4 +695,17 @@
delete from t_return_sale
where sale_id = #{saleId,jdbcType=VARCHAR}
</delete>
<select id="getCustomerReturnHistory" resultType="java.lang.Integer">
SELECT
sum( dd.product_count )
FROM
t_return_detail dd
LEFT JOIN t_sale ss ON dd.sale_id = ss.id
WHERE
dd.product_id = #{productId}
AND dd.attribute_list = #{attributeList}
AND ss.STATUS = 4
AND ss.user_id = #{customerId}
</select>
</mapper>

13
hiver-modules/hiver-mall/src/main/resources/mapper/SaleDetailMapper.xml

@ -585,4 +585,17 @@
)
</select>
<select id="getCustomerBuyHistory" resultType="java.lang.Integer">
SELECT
sum( dd.product_count )
FROM
t_sale_detail dd
LEFT JOIN t_sale ss ON dd.sale_id = ss.id
WHERE
dd.product_id = #{productId}
AND dd.attribute_list = #{attributeList}
AND ss.STATUS = 4
AND ss.user_id = #{customerId}
</select>
</mapper>

27
hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

@ -1369,20 +1369,29 @@ GROUP BY
<select id="buyCount" resultType="cc.hiver.mall.pojo.vo.BuyCountVo">
SELECT
tsd.product_id,
COUNT(ts.id) AS buy_count
count( aa.id ) as buy_count,
dd.product_id
FROM
t_sale ts
JOIN
t_sale_detail tsd ON ts.id = tsd.sale_id
t_sale aa,(
SELECT
sale_id,
product_id
FROM
t_sale_detail
WHERE
ts.user_id = #{customerId}
and status = '4'
AND tsd.product_id in
product_id IN
<foreach item="item" index="index" collection="productIdList" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY
tsd.product_id
sale_id,
product_id
) dd
WHERE
aa.id = dd.sale_id
AND aa.user_id = #{customerId}
AND aa.STATUS = 4
GROUP BY
dd.product_id
</select>
</mapper>

55
hiver-modules/hiver-mall/src/main/resources/mapper/ShopMapper.xml

@ -11,27 +11,37 @@
<result column="shop_name" property="shopName" jdbcType="VARCHAR" />
<result column="shop_owner_id" property="shopOwnerId" jdbcType="VARCHAR" />
<result column="shop_manger_id" property="shopMangerId" jdbcType="VARCHAR" />
<result column="region" property="region" jdbcType="VARCHAR" />
<result column="region_id" property="regionId" jdbcType="VARCHAR" />
<result column="shop_area" property="shopArea" jdbcType="VARCHAR" />
<result column="shop_area_title" property="shopAreaTitle" jdbcType="VARCHAR" />
<result column="shop_type" property="shopType" jdbcType="VARCHAR" />
<result column="shop_type_title" property="shopTypeTitle" jdbcType="VARCHAR" />
<result column="shop_address" property="shopAddress" jdbcType="VARCHAR" />
<result column="year_fee" property="yearFee" jdbcType="VARCHAR" />
<result column="charge_time" property="chargeTime" jdbcType="VARCHAR" />
<result column="start_time" property="startTime" jdbcType="VARCHAR" />
<result column="end_time" property="endTime" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
<result column="business_district_level" property="businessDistrictLevel" jdbcType="VARCHAR" />
<result column="contact_phone" property="contactPhone" jdbcType="VARCHAR" />
<result column="shop_icon" property="shopIcon" jdbcType="VARCHAR" />
<result column="defaulted" property="defaulted" jdbcType="INTEGER" />
<result column="region" property="region" jdbcType="VARCHAR" />
<result column="shop_area_title" property="shopAreaTitle" jdbcType="VARCHAR" />
<result column="ali_account" property="aliAccount" jdbcType="VARCHAR" />
<result column="ali_name" property="aliName" jdbcType="VARCHAR" />
<result column="rebate_amount" property="rebateAmount" jdbcType="VARCHAR" />
<result column="attr_id" property="attrId" jdbcType="VARCHAR" />
<result column="printing_method" property="printingMethod" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="cc.hiver.mall.entity.Shop" extends="BaseResultMap" >
<result column="remark" property="remark" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, create_by, create_time, del_flag, update_by, update_time, shop_name, shop_owner_id,
shop_manger_id, shop_area, shop_address, year_fee, charge_time, start_time, end_time,
status, business_district_level, contact_phone, shop_icon, defaulted, region, shop_area_title
id, create_by, create_time, del_flag, update_by, update_time, shop_name, shop_owner_id, shop_manger_id, region,
region_id, shop_area, shop_area_title, shop_type, shop_type_title, shop_address, year_fee, charge_time, start_time,
end_time, status, remark, business_district_level, contact_phone, shop_icon, defaulted, ali_account, ali_name,
rebate_amount, attr_id, printing_method
</sql>
<sql id="Blob_Column_List" >
remark
@ -49,22 +59,14 @@
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.Shop" >
insert into t_shop (id, create_by, create_time,
del_flag, update_by, update_time,
shop_name, shop_owner_id, shop_manger_id,
shop_area, shop_address, year_fee,
charge_time, start_time, end_time,
status, business_district_level, contact_phone,
shop_icon, defaulted, region,
shop_area_title, remark)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{shopName,jdbcType=VARCHAR}, #{shopOwnerId,jdbcType=VARCHAR}, #{shopMangerId,jdbcType=VARCHAR},
#{shopArea,jdbcType=VARCHAR}, #{shopAddress,jdbcType=VARCHAR}, #{yearFee,jdbcType=VARCHAR},
#{chargeTime,jdbcType=VARCHAR}, #{startTime,jdbcType=VARCHAR}, #{endTime,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{businessDistrictLevel,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR},
#{shopIcon,jdbcType=VARCHAR}, #{defaulted,jdbcType=INTEGER}, #{region,jdbcType=VARCHAR},
#{shopAreaTitle,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR})
insert into t_shop (id, create_by, create_time, del_flag, update_by, update_time, shop_name, shop_owner_id, shop_manger_id, region,
region_id, shop_area, shop_area_title, shop_type, shop_type_title, shop_address, year_fee, charge_time, start_time,
end_time, status, remark, business_district_level, contact_phone, shop_icon, defaulted, ali_account, ali_name,
rebate_amount, attr_id, printing_method)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{shopName,jdbcType=VARCHAR}, #{shopOwnerId,jdbcType=VARCHAR}, #{shopMangerId,jdbcType=VARCHAR}, #{region,jdbcType=VARCHAR},
#{regionId,jdbcType=VARCHAR}, #{shopArea,jdbcType=VARCHAR}, #{shopAreaTitle,jdbcType=VARCHAR}, #{shopType,jdbcType=VARCHAR}, #{shopTypeTitle,jdbcType=VARCHAR}, #{shopAddress,jdbcType=VARCHAR}, #{yearFee,jdbcType=VARCHAR}, #{chargeTime,jdbcType=VARCHAR}, #{startTime,jdbcType=VARCHAR},
#{endTime,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{remark,jdbcType=LONGVARCHAR}, #{businessDistrictLevel,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, #{shopIcon,jdbcType=VARCHAR}, #{defaulted,jdbcType=INTEGER}, #{aliAccount,jdbcType=VARCHAR}, #{aliName,jdbcType=VARCHAR},
#{rebateAmount,jdbcType=VARCHAR}, #{attrId,jdbcType=VARCHAR}, #{printingMethod,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Shop" >
insert into t_shop
@ -331,7 +333,16 @@
shop_icon = #{shopIcon,jdbcType=VARCHAR},
defaulted = #{defaulted,jdbcType=INTEGER},
region = #{region,jdbcType=VARCHAR},
shop_area_title = #{shopAreaTitle,jdbcType=VARCHAR}
shop_area_title = #{shopAreaTitle,jdbcType=VARCHAR},
remark = #{remark,jdbcType=LONGVARCHAR},
region_id = #{regionId,jdbcType=VARCHAR},
shop_type = #{shopType,jdbcType=VARCHAR},
shop_type_title = #{shopTypeTitle,jdbcType=VARCHAR},
ali_account = #{aliAccount,jdbcType=VARCHAR},
ali_name = #{aliName,jdbcType=VARCHAR},
rebate_amount = #{rebateAmount,jdbcType=DECIMAL},
attr_id = #{attrId,jdbcType=VARCHAR},
printing_method = #{printingMethod,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="findByUserId" resultType="cc.hiver.mall.entity.Shop">

Loading…
Cancel
Save