|
|
@ -2,6 +2,7 @@ package cc.hiver.mall.controller; |
|
|
|
|
|
|
|
|
import cc.hiver.core.common.annotation.RateLimiter; |
|
|
import cc.hiver.core.common.annotation.RateLimiter; |
|
|
import cc.hiver.core.common.constant.CommonConstant; |
|
|
import cc.hiver.core.common.constant.CommonConstant; |
|
|
|
|
|
import cc.hiver.core.common.constant.DealingsRecordConstant; |
|
|
import cc.hiver.core.common.constant.SaleConstant; |
|
|
import cc.hiver.core.common.constant.SaleConstant; |
|
|
import cc.hiver.core.common.constant.WorkerConstant; |
|
|
import cc.hiver.core.common.constant.WorkerConstant; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
@ -16,6 +17,7 @@ import cc.hiver.core.service.LogiticsCompanyService; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.vo.WorkerQueryVO; |
|
|
import cc.hiver.core.vo.WorkerQueryVO; |
|
|
import cc.hiver.mall.common.constant.OrderConstant; |
|
|
import cc.hiver.mall.common.constant.OrderConstant; |
|
|
|
|
|
import cc.hiver.mall.debt.constant.DebtConstant; |
|
|
import cc.hiver.mall.debt.entity.Debt; |
|
|
import cc.hiver.mall.debt.entity.Debt; |
|
|
import cc.hiver.mall.debt.service.DebtService; |
|
|
import cc.hiver.mall.debt.service.DebtService; |
|
|
import cc.hiver.mall.entity.*; |
|
|
import cc.hiver.mall.entity.*; |
|
|
@ -139,12 +141,50 @@ public class SaleController { |
|
|
// 设置店铺id为缓存中的内容
|
|
|
// 设置店铺id为缓存中的内容
|
|
|
// shopId从缓存中设置
|
|
|
// shopId从缓存中设置
|
|
|
final String shopId = securityUtil.getShopId(); |
|
|
final String shopId = securityUtil.getShopId(); |
|
|
|
|
|
|
|
|
final Shop shop = shopService.get(shopId); |
|
|
final Shop shop = shopService.get(shopId); |
|
|
saleQueryDTO.getSale().setShopId(shopId); |
|
|
saleQueryDTO.getSale().setShopId(shopId); |
|
|
saleQueryDTO.getSale().setShopName(shop.getShopName()); |
|
|
saleQueryDTO.getSale().setShopName(shop.getShopName()); |
|
|
// 根据该客户的欠款信息
|
|
|
// 根据该客户的欠款信息
|
|
|
final String userId = saleQueryDTO.getSale().getUserId(); |
|
|
final String userId = saleQueryDTO.getSale().getUserId(); |
|
|
final Debt debt = debtService.selectByUserId(shopId, userId); |
|
|
final Debt debt = debtService.selectByUserId(shopId, userId); |
|
|
|
|
|
// 20240908 如果没有查询到下游客户欠款,那么就新增一条初始欠款
|
|
|
|
|
|
if (ObjectUtils.isEmpty(debt)) { |
|
|
|
|
|
final User user = securityUtil.getCurrUser(); |
|
|
|
|
|
final Debt addDebt = new Debt(); |
|
|
|
|
|
addDebt.setCreateBy(user.getId()); |
|
|
|
|
|
addDebt.setCreateTime(new Date()); |
|
|
|
|
|
addDebt.setUserId(userId); |
|
|
|
|
|
addDebt.setShopId(shopId); |
|
|
|
|
|
addDebt.setUserPhone(saleQueryDTO.getMobile()); |
|
|
|
|
|
addDebt.setUserAdress(saleQueryDTO.getSale().getReceiveAddress()); |
|
|
|
|
|
addDebt.setUserName(saleQueryDTO.getSale().getUserName()); |
|
|
|
|
|
addDebt.setAmountOwed(BigDecimal.ZERO); |
|
|
|
|
|
addDebt.setUserType(DebtConstant.USER_TYPE[0]); |
|
|
|
|
|
debtService.save(addDebt); |
|
|
|
|
|
// 新增交易记录
|
|
|
|
|
|
// 2. 新增欠款记录
|
|
|
|
|
|
final DealingsRecord dealingsRecord = new DealingsRecord(); |
|
|
|
|
|
dealingsRecord.setCreateBy(user.getId()); |
|
|
|
|
|
dealingsRecord.setCreateByName(user.getNickname()); |
|
|
|
|
|
dealingsRecord.setCreateTime(new Date()); |
|
|
|
|
|
dealingsRecord.setDealingsUserId(saleQueryDTO.getSale().getUserId()); |
|
|
|
|
|
dealingsRecord.setDealingsUserName(saleQueryDTO.getSale().getUserName()); |
|
|
|
|
|
dealingsRecord.setUserType(DealingsRecordConstant.TYPE[1]); |
|
|
|
|
|
dealingsRecord.setDealingsWay("新增客户"); |
|
|
|
|
|
dealingsRecord.setShopId(shopId); |
|
|
|
|
|
// 销售金额
|
|
|
|
|
|
dealingsRecord.setSaleAmount(BigDecimal.ZERO); |
|
|
|
|
|
// 退货金额
|
|
|
|
|
|
dealingsRecord.setReturnAmount(BigDecimal.ZERO); |
|
|
|
|
|
// 上次欠款
|
|
|
|
|
|
dealingsRecord.setLastDebtAmount(BigDecimal.ZERO); |
|
|
|
|
|
// 最新欠款
|
|
|
|
|
|
dealingsRecord.setBalanceDue(BigDecimal.ZERO); |
|
|
|
|
|
dealingsRecord.setAmount(BigDecimal.ZERO); |
|
|
|
|
|
dealingsRecord.setDealingsType(DealingsRecordConstant.DEALINGS_TYPE[3]); |
|
|
|
|
|
dealingsRecordService.save(dealingsRecord); |
|
|
|
|
|
} |
|
|
final BigDecimal amountOwed = debt.getAmountOwed(); |
|
|
final BigDecimal amountOwed = debt.getAmountOwed(); |
|
|
// 20240616 开单可能值包含退货单
|
|
|
// 20240616 开单可能值包含退货单
|
|
|
Sale sale = saleQueryDTO.getSale(); |
|
|
Sale sale = saleQueryDTO.getSale(); |
|
|
|