|
|
@@ -33,15 +33,17 @@ import org.springblade.check.entity.AuditProecess;
|
|
|
import org.springblade.check.feign.ICheckClient;
|
|
|
import org.springblade.client.entity.BasicCorpsProfitChange;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
-import org.springblade.client.feign.ICorpsDescClient;
|
|
|
-import org.springblade.client.feign.ICorpsProfitChangeClient;
|
|
|
-import org.springblade.client.feign.IGoodsDescClient;
|
|
|
-import org.springblade.client.feign.ISerialClient;
|
|
|
+import org.springblade.client.entity.FeesDesc;
|
|
|
+import org.springblade.client.entity.Message;
|
|
|
+import org.springblade.client.feign.*;
|
|
|
import org.springblade.client.vo.GoodsDescVO;
|
|
|
import org.springblade.common.utils.NumToWords;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.finance.dto.ApplyDTO;
|
|
|
+import org.springblade.finance.feign.IFinanceClient;
|
|
|
+import org.springblade.finance.vojo.Items;
|
|
|
import org.springblade.purchase.sales.entity.*;
|
|
|
import org.springblade.purchase.sales.enums.OrderStatusEnum;
|
|
|
import org.springblade.purchase.sales.mapper.OrderItemsMapper;
|
|
|
@@ -51,6 +53,7 @@ import org.springblade.purchase.sales.vo.*;
|
|
|
import org.springblade.stock.entity.StockGoods;
|
|
|
import org.springblade.stock.feign.IStockGoodsClient;
|
|
|
import org.springblade.stock.vo.StockGoodsVO;
|
|
|
+import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -59,6 +62,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -85,6 +89,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
private ICorpsProfitChangeClient corpsProfitChangeClient;
|
|
|
private IStockGoodsClient stockGoodsClient;
|
|
|
private IGoodsDescClient goodsDescClient;
|
|
|
+ private final IFinanceClient financeClient;//财务
|
|
|
+ private final ISysClient sysClient;
|
|
|
+ private final IMessageClient messageClient;//消息
|
|
|
+ private final IFeesDescClient feesDescClient;//费用
|
|
|
|
|
|
@Override
|
|
|
public IPage<OrderVO> selectOrderPage(IPage<OrderVO> page, OrderVO order) {
|
|
|
@@ -838,9 +846,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}*/
|
|
|
|
|
|
|
|
|
- /**===========================End 审核通过锁定库存=============================*/
|
|
|
-
|
|
|
-
|
|
|
+ /**===========================End 审核通过生成账单 发送消息=============================*/
|
|
|
+ //todo 国内贸易销售订单审批通过自动生成账单 同时给角色为财务的用户推送消息
|
|
|
+ this.paymentApply(order,"收费","销售");
|
|
|
/**===========================start 审核通过操作返利信息=============================*/
|
|
|
//不需要计算返利
|
|
|
if ((order.getThisUsedProfit() == null || order.getThisUsedProfit().compareTo(new BigDecimal("0")) == 0) && (order.getCreateProfit() == null || order.getCreateProfit().compareTo(new BigDecimal("0")) == 0)) {
|
|
|
@@ -902,7 +910,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
throw new SecurityException("更新客户返利信息失败");
|
|
|
}
|
|
|
/**===========================End审核通过操作返利信息=============================*/
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -1226,4 +1233,139 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
baseMapper.updateById(order);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单生成账单 并且推送财务消息
|
|
|
+ * @param order 订单信息
|
|
|
+ * @param billType 货款类型: 申请 收费 付费
|
|
|
+ * @param itemType 付款类型: 采购 销售 收货 发货
|
|
|
+ */
|
|
|
+ public void paymentApply(Order order,String billType,String itemType){
|
|
|
+ //获取所属公司中文名
|
|
|
+ if (order.getBelongToCorpId() != null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(order.getBelongToCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ order.setBelongToCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取客户中文名
|
|
|
+ if (order.getCorpId() != null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(order.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ order.setCorpsName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ApplyDTO applyDTO = new ApplyDTO();
|
|
|
+ applyDTO.setBillType(billType);
|
|
|
+ applyDTO.setDc("D");
|
|
|
+ applyDTO.setBelongCompany(order.getBelongToCorpName());
|
|
|
+ applyDTO.setUrl(order.getUrl());
|
|
|
+ applyDTO.setPageStatus(order.getPageStatus());
|
|
|
+ applyDTO.setPageLabel(order.getPageLabel());
|
|
|
+ applyDTO.setCheckType(order.getCheckType());
|
|
|
+ applyDTO.setAccDate(order.getBusinesDate());
|
|
|
+ List<Items> itemsList = new ArrayList<>();
|
|
|
+ //获取订单明细信息
|
|
|
+ LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ orderItemsLambdaQueryWrapper.eq(OrderItems::getIsDeleted,0);
|
|
|
+ orderItemsLambdaQueryWrapper.eq(OrderItems::getPid,order.getId());
|
|
|
+ orderItemsLambdaQueryWrapper.eq(OrderItems::getGoodType,0);
|
|
|
+ List<OrderItems> orderItemsList = orderItemsService.list(orderItemsLambdaQueryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(orderItemsList)){
|
|
|
+ for (OrderItems orderItems : orderItemsList) {
|
|
|
+ Items items = new Items();
|
|
|
+ items.setSrcOrderno(order.getOrgOrderNo());
|
|
|
+ items.setItemType(itemType);
|
|
|
+ items.setCorpId(order.getCorpId());
|
|
|
+ items.setSrcParentId(order.getId());
|
|
|
+ items.setCurrency("CNY");
|
|
|
+ items.setExchangeRate(new BigDecimal(1));
|
|
|
+ items.setTaxRate(BigDecimal.ZERO);
|
|
|
+ items.setSrcType(1);
|
|
|
+ items.setTradeType(order.getTradeType());
|
|
|
+ items.setChargeMember(order.getChargeMember());
|
|
|
+ items.setAmount(orderItems.getAmount());
|
|
|
+ items.setQuantity(orderItems.getOrderQuantity());
|
|
|
+ items.setPrice(orderItems.getPrice());
|
|
|
+ items.setUnit(orderItems.getUnit());
|
|
|
+ items.setSrcFeesId(orderItems.getId());
|
|
|
+ //获取费用id
|
|
|
+ R<FeesDesc> fees = feesDescClient.getFeesByName("货款");
|
|
|
+ if (fees.isSuccess() && fees.getData() != null){
|
|
|
+ items.setCostType(fees.getData().getId().toString());
|
|
|
+ }
|
|
|
+ //获取商品名称
|
|
|
+ //"goodName": "浩悦四代",
|
|
|
+ R<GoodsDescVO> goodsMessage = goodsDescClient.selectGoodsMessage(orderItems.getItemId());
|
|
|
+ if (goodsMessage.isSuccess() && goodsMessage.getData() != null){
|
|
|
+ items.setGoodName(goodsMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ itemsList.add(items);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取订单收款信息
|
|
|
+ LambdaQueryWrapper<OrderFees> orderFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ orderFeesLambdaQueryWrapper.eq(OrderFees::getIsDeleted,0);
|
|
|
+ orderFeesLambdaQueryWrapper.eq(OrderFees::getPid,order.getId());
|
|
|
+ orderFeesLambdaQueryWrapper.eq(OrderFees::getFeesType,1);
|
|
|
+ List<OrderFees> orderFeesList = orderFeesService.list(orderFeesLambdaQueryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(orderFeesList)){
|
|
|
+ for (OrderFees orderFees : orderFeesList) {
|
|
|
+ Items items = new Items();
|
|
|
+ items.setSrcOrderno(order.getOrgOrderNo());
|
|
|
+ items.setItemType(itemType);
|
|
|
+ items.setCorpId(order.getCorpId());
|
|
|
+ items.setSrcParentId(order.getId());
|
|
|
+ items.setCurrency(orderFees.getCurrency());
|
|
|
+ items.setExchangeRate(orderFees.getExchangeRate());
|
|
|
+ items.setTaxRate(orderFees.getTaxRate());
|
|
|
+ items.setSrcType(2);
|
|
|
+ items.setTradeType(order.getTradeType());
|
|
|
+ items.setChargeMember(order.getChargeMember());
|
|
|
+ items.setAmount(orderFees.getAmount());
|
|
|
+ items.setQuantity(orderFees.getQuantity());
|
|
|
+ items.setPrice(orderFees.getPrice());
|
|
|
+ items.setUnit(orderFees.getUnit());
|
|
|
+ items.setSrcFeesId(orderFees.getId());
|
|
|
+ items.setCostType(orderFees.getItemId().toString());
|
|
|
+ itemsList.add(items);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ applyDTO.setItemsList(itemsList);
|
|
|
+ if (CollectionUtils.isNotEmpty(itemsList)){
|
|
|
+ //生成账单
|
|
|
+ R paymentApply = financeClient.paymentApply(applyDTO);
|
|
|
+ if (!paymentApply.isSuccess()){
|
|
|
+ throw new RuntimeException(paymentApply.getMsg());
|
|
|
+ }
|
|
|
+ //给角色为财务的人发送消息
|
|
|
+ R<String> clientDeptIds = sysClient.getRoleIds(SecureUtil.getTenantId(), "财务");
|
|
|
+ if (clientDeptIds.isSuccess() && StringUtils.isNotBlank(clientDeptIds.getData())){
|
|
|
+ R<List<User>> userList = userClient.listUserByRoleId(Long.valueOf(clientDeptIds.getData()));
|
|
|
+ if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())){
|
|
|
+ for (User datum : userList.getData()) {
|
|
|
+ //循环发送消息
|
|
|
+ Message sendMessage = new Message();
|
|
|
+ sendMessage.setParameter(String.valueOf(order.getId()));
|
|
|
+ sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
+ sendMessage.setUserId(AuthUtil.getUserId());
|
|
|
+ sendMessage.setToUserId(datum.getId());
|
|
|
+ sendMessage.setToUserName(datum.getName());
|
|
|
+ sendMessage.setMessageType(1);
|
|
|
+ sendMessage.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sendMessage.setCreateUser(AuthUtil.getUserId());
|
|
|
+ sendMessage.setCreateTime(new Date());
|
|
|
+ sendMessage.setUrl(order.getUrl());
|
|
|
+ sendMessage.setPageLabel(order.getPageLabel());
|
|
|
+ sendMessage.setPageStatus(order.getPageStatus());
|
|
|
+ sendMessage.setMessageBody(order.getBelongToCorpName()+" 您的客户:"+order.getCorpsName() + "的销售订单 "+ order.getOrderNo() +"审核通过,请查看");
|
|
|
+ R save = messageClient.save(sendMessage);
|
|
|
+ if (!save.isSuccess()) {
|
|
|
+ throw new SecurityException("发送消息失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|