Commit b42315dc authored by zhengyi's avatar zhengyi

Merge branch 'dev' into order-update

# Conflicts:
#	yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/vo/order/OrderBackPageVO.java
parents 84198cec dc5d6b48
-- ----------------------------
-- Table structure for ecw_customer_competitor
-- ----------------------------
DROP TABLE IF EXISTS `ecw_customer_competitor`;
CREATE TABLE `ecw_customer_competitor` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`name` varchar(512) NOT NULL COMMENT '名称',
`creator` varchar(32) NOT NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL COMMENT '创建时间',
`updater` varchar(32) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL COMMENT '更新时间',
`deleted` bit DEFAULT false COMMENT '是否删除',
PRIMARY KEY (`id`),
KEY (`create_time`)
) COMMENT='客户竞争对手表';
-- 添加新字段
alter table `ecw_customer` add column `first_deal_time` datetime default null COMMENT '首次成交时间';
alter table `ecw_customer` add column `get_method` Integer default null COMMENT '获取方式';
alter table `ecw_customer` add column `create_from` Integer default null COMMENT '创建入口';
alter table `ecw_customer` add column `customer_service_confirmed_time` datetime default null COMMENT '确认接收时间';
alter table `ecw_customer` add column `busi_country_ids` varchar(100) default null COMMENT '业务国家ids';
alter table `ecw_customer` add column `roles` varchar(100) default null COMMENT '客户角色';
alter table `ecw_customer` add column `competitor_ids` varchar(100) default null COMMENT '竞争对手ids';
alter table `ecw_customer` add column `weight_yearly` decimal(15, 2) DEFAULT 0 COMMENT '年度发货量';
alter table `ecw_customer` add column `num_yearly` int DEFAULT 0 COMMENT '年度发货次数';
alter table `ecw_customer` add column `default_billing` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否默认开票';
-- 更新表
alter table `ecw_customer`
change column `pickup_point` `pickup_points` varchar(100) DEFAULT NULL COMMENT '常用提货网点ids';
alter table `ecw_customer`
change column `product_id` `product_ids` varchar(300) DEFAULT NULL COMMENT '主营产品ids';
-- 更新客户角色
update ecw_customer set roles = '2' where FIND_IN_SET(2, type) != 0 or FIND_IN_SET(3, type) != 0;
package cn.iocoder.yudao.module.customer.convert.customerCompetitor;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.customer.vo.customerCompetitor.*;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerCompetitor.CustomerCompetitorDO;
/**
* 客户竞争对手 Convert
* @author yanghao
*/
@Mapper
public interface CustomerCompetitorConvert {
/*****转换MapStruct*****/
CustomerCompetitorConvert INSTANCE = Mappers.getMapper(CustomerCompetitorConvert.class);
/***
* 创建VO转实体
* @param bean
* @return
*/
CustomerCompetitorDO convert(CustomerCompetitorCreateReqVO bean);
/***
* 修改VO转实体
* @param bean
* @return
*/
CustomerCompetitorDO convert(CustomerCompetitorUpdateReqVO bean);
/***
* 实体转返回VO
* @param bean
* @return
*/
CustomerCompetitorBackVO convert(CustomerCompetitorDO bean);
/***
* 实体列表转返回VO列表
* @param list
* @return
*/
List<CustomerCompetitorBackVO> convertList(List<CustomerCompetitorDO> list);
/***
* 实体分页转返回分页
* @param page
* @return
*/
PageResult<CustomerCompetitorBackVO> convertPage(PageResult<CustomerCompetitorDO> page);
}
......@@ -109,11 +109,11 @@ public class CustomerDO extends BaseDO {
/**
* 产品id
*/
private Long productId;
private String productIds;
/**
* 常用提货网点
*/
private Long pickupPoint;
private String pickupPoints;
/**
* 关联会员账号
*/
......@@ -366,6 +366,69 @@ public class CustomerDO extends BaseDO {
@ApiModelProperty("延期申请次数")
private int delayApprovalNum ;
// ======== 20240821 add start
/**
* 首次成交时间
*/
private Date firstDealTime;
/**
* 获取方式
* <p>
* 枚举 {@link TODO customer_get_method 字典}
*/
private Integer getMethod;
/**
* 创建入口
* <p>
* 枚举 {@link TODO customer_create_from 字典}
*/
private Integer createFrom;
/**
* 归属时间
*/
private Date customerServiceConfirmedTime;
/**
* 客户角色
* <p>
* 枚举 {@link TODO customer_role 字典}
*/
private String roles;
/**
* 业务国家 逗号分隔
*/
private String busiCountryIds;
/**
* 竞争对手ID, 关联 customer_competitor 表主键
*/
private String competitorIds;
/**
* 年度发货量
*/
private BigDecimal weightYearly;
/**
* 年度发货次数
*/
private Integer numYearly;
/**
* 默认开票,1-是,0-否
*/
private Boolean defaultBilling;
// ======== 20240821 add end
/**
* vip等级-中文
*/
......
package cn.iocoder.yudao.module.customer.dal.dataobject.customerCompetitor;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 客户竞争对手 DO
*
* @author yanghao
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("ecw_customer_competitor")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CustomerCompetitorDO extends BaseDO {
/**
* 主键ID
*/
@TableId
private Long id;
/**
* 名称
*/
private String name;
}
......@@ -75,10 +75,19 @@ public interface CustomerMapper extends BaseMapperX<CustomerDO> {
"",
"pt.title_zh as product_type_name_zh, pt.title_en as product_type_name_en,",
"",
"p.title_zh as product_name_zh, p.title_en as product_name_en,",
"(SELECT GROUP_CONCAT(title_zh) FROM ecw_product p WHERE FIND_IN_SET(p.id,(SELECT product_ids FROM ecw_customer WHERE id=c.id))) AS product_name_zh, ",
"(SELECT GROUP_CONCAT(title_en) FROM ecw_product p WHERE FIND_IN_SET(p.id,(SELECT product_ids FROM ecw_customer WHERE id=c.id))) AS product_name_en, ",
"",
"c.pickup_point,",
"n.title_zh as pickup_point_name_zh, n.title_en as pickup_point_name_en,",
"(SELECT GROUP_CONCAT(title_zh) FROM ecw_node n WHERE FIND_IN_SET(n.id,(SELECT pickup_points FROM ecw_customer WHERE id=c.id))) AS pickup_point_name_zh,",
"(SELECT GROUP_CONCAT(title_en) FROM ecw_node n WHERE FIND_IN_SET(n.id,(SELECT pickup_points FROM ecw_customer WHERE id=c.id))) AS pickup_point_name_en,",
"",
"(SELECT GROUP_CONCAT(name_zh) FROM ecw_country ct WHERE FIND_IN_SET(ct.id,(SELECT busi_country_ids FROM ecw_customer WHERE id=c.id))) AS busi_country_name_zh,",
"(SELECT GROUP_CONCAT(name_en) FROM ecw_country ct WHERE FIND_IN_SET(ct.id,(SELECT busi_country_ids FROM ecw_customer WHERE id=c.id))) AS busi_country_name_en,",
"",
"(SELECT GROUP_CONCAT(name) FROM ecw_customer_competitor ccp WHERE FIND_IN_SET(ccp.id,(SELECT competitor_ids FROM ecw_customer WHERE id=c.id))) AS competitor_names,",
"",
"uc.nickname as creator_name,",
"uu.nickname as updater_name,",
"",
"c.customer_service,",
"u.nickname as customer_service_name",
......@@ -88,9 +97,9 @@ public interface CustomerMapper extends BaseMapperX<CustomerDO> {
"left join ecw_customer_credit cc on c.credit_level = cc.id",
"left join ecw_country country on c.country = country.id",
"left join ecw_product_type pt on c.product_type = pt.id",
"left join ecw_product p on c.product_id = p.id",
"left join ecw_node n on c.pickup_point = n.id",
"left join system_user u on c.customer_service = u.id",
"left join system_user uc on c.creator = u.id",
"left join system_user uu on c.updater = u.id",
"where c.id = #{id}",
"</script>"
})
......
package cn.iocoder.yudao.module.customer.dal.mysql.customerCompetitor;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerCompetitor.CustomerCompetitorDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.customer.vo.customerCompetitor.*;
/**
* 客户竞争对手 Mapper
* @author yanghao
*/
@Mapper
public interface CustomerCompetitorMapper extends AbstractMapper<CustomerCompetitorDO> {
@Override
default PageResult<CustomerCompetitorDO> selectPage(PageVO page, Object object) {
if (object instanceof CustomerCompetitorQueryVO) {
CustomerCompetitorQueryVO vo = (CustomerCompetitorQueryVO)object;
return selectPage(page, new LambdaQuery<CustomerCompetitorDO>()
.likeIfPresent(CustomerCompetitorDO::getName, vo.getName())
.betweenIfPresent(CustomerCompetitorDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(CustomerCompetitorDO::getId));
}
return null;
}
@Override
default List<CustomerCompetitorDO> selectList(Object object) {
if (object instanceof CustomerCompetitorQueryVO) {
CustomerCompetitorQueryVO vo = (CustomerCompetitorQueryVO)object;
return selectList(new LambdaQuery<CustomerCompetitorDO>()
.likeIfPresent(CustomerCompetitorDO::getName, vo.getName())
.betweenIfPresent(CustomerCompetitorDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(CustomerCompetitorDO::getId));
}
return null;
}
}
......@@ -29,4 +29,8 @@ public interface ErrorCodeConstants {
ErrorCode BANK_NOT_EXISTS = new ErrorCode(1005001010, "客户银行账户不存在");
ErrorCode COMPETITOR_NOT_EXISTS = new ErrorCode(1005001011, "客户竞争对手不存在");
ErrorCode COMPETITOR_EXISTS = new ErrorCode(1005001012, "竞争对手名称已存在");
}
package cn.iocoder.yudao.module.customer.service.api;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.CustomerContactsDO;
import cn.iocoder.yudao.module.customer.service.customer.CustomerService;
import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContactsService;
......@@ -7,8 +8,10 @@ import cn.iocoder.yudao.module.customer.vo.customer.customerContacts.CustomerCon
import cn.iocoder.yudao.module.customer.vo.customer.vo.CustomerCreateReqVO;
import cn.iocoder.yudao.module.ecw.api.customer.CustomerApi;
import cn.iocoder.yudao.module.ecw.dal.dataobject.country.CountryDO;
import cn.iocoder.yudao.module.ecw.enums.CustomerCreateFromEnum;
import cn.iocoder.yudao.module.ecw.enums.CustomerStatusEnum;
import cn.iocoder.yudao.module.ecw.service.country.CountryService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
......@@ -84,6 +87,9 @@ public class CustomerApiImpl implements CustomerApi {
customerCreateReqVO.setCustomerOperateLogRemark("会员注册关联创建客户. 会员id:" + memberUserId + "; 电话:" + phone);
// app创建
customerCreateReqVO.setCreateFrom(CustomerCreateFromEnum.APP_REGISTER.getValue());
customerService.createCustomer(customerCreateReqVO);
}
......@@ -98,4 +104,12 @@ public class CustomerApiImpl implements CustomerApi {
public void approvalCustomerTransfer(String approveId, Integer result) {
customerService.approvalCustomerTransfer(approveId, result);
}
@Override
public void fillFirstDealTimeIfNull(Long customerId, Date firstDealTime) {
customerService.update(new LambdaUpdateWrapper<CustomerDO>()
.set(CustomerDO::getFirstDealTime, firstDealTime)
.isNull(CustomerDO::getFirstDealTime)
.eq(CustomerDO::getId, customerId));
}
}
......@@ -64,9 +64,7 @@ import cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankUpdateReqVO;
import cn.iocoder.yudao.module.customer.vo.customerDetail.CustomerOrderBackPageVO;
import cn.iocoder.yudao.module.customer.vo.customerOperateLog.CustomerOperateLogCreateReqVO;
import cn.iocoder.yudao.module.ecw.dal.dataobject.country.CountryDO;
import cn.iocoder.yudao.module.ecw.enums.CustomerOperateTypeEnum;
import cn.iocoder.yudao.module.ecw.enums.CustomerStatusEnum;
import cn.iocoder.yudao.module.ecw.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.ecw.enums.*;
import cn.iocoder.yudao.module.ecw.service.country.CountryService;
import cn.iocoder.yudao.module.ecw.service.internalMessage.InternalMessageService;
import cn.iocoder.yudao.module.ecw.service.paramValid.ParamValidatorService;
......@@ -210,8 +208,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
customerService = consignorCustomerDO.getCustomerService();
// 待分配。 若是发货人为代理和同行时,订单的收货人不同步到待分配客户
boolean isProxyConsignor = StringUtils.isNotEmpty(consignorCustomerDO.getType())
&& (consignorCustomerDO.getType().contains("2") || consignorCustomerDO.getType().contains("3"));
boolean isProxyConsignor = StringUtils.isNotEmpty(consignorCustomerDO.getRoles())
&& (consignorCustomerDO.getRoles().contains("2") || consignorCustomerDO.getRoles().contains("3"));
if (isProxyConsignor) {
log.info("若是发货人为代理和同行时,订单的收货人不同步到待分配客户");
return null;
......@@ -262,6 +260,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
customerCreateReqVO.setCustomerOperateLogRemark("管理端创建收货人时关联创建客户,进待分配列表");
customerCreateReqVO.setCustomerOperateLogOrderNo(orderNo);
customerCreateReqVO.setCreateFrom(CustomerCreateFromEnum.APP_CONSIGNOR.getValue());
Long customerId = this.createCustomer(customerCreateReqVO);
List<CustomerContactsDO> customerContactsDOS =
......@@ -319,6 +319,11 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
// 设置跟进客户经理
customer.setCustomerService(WebFrameworkUtils.getLoginUserId());
// 获取方式:自主创建
customer.setGetMethod(CustomerGetMethodEnum.CREATE.getValue());
// 归属时间:当前时间
customer.setCustomerServiceConfirmedTime(new Date());
boolean isFcl = isFcl(customer);
......@@ -532,6 +537,11 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
if (customerOld.getCustomerServiceAssignedTime() == null) {
customerNew.setCustomerServiceAssignedTime(now);
}
// 获取方式:分配/移交接收
customerNew.setGetMethod(CustomerGetMethodEnum.ASSIGN.getValue());
//老的归属时间为空,就设置归属时间
customerNew.setCustomerServiceConfirmedTime(now);
//设置预计进行公海池时间
//海运整柜 不掉入公海
if (isFcl) {
......
package cn.iocoder.yudao.module.customer.service.customerCompetitor;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.customer.vo.customerCompetitor.*;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerCompetitor.CustomerCompetitorDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 客户竞争对手 Service 接口
*
* @author yanghao
*/
public interface CustomerCompetitorService extends IService<CustomerCompetitorDO> {
/**
* 创建客户竞争对手
* @param createReqVO 创建信息
* @return 编号
*/
Long createCompetitor(@Valid CustomerCompetitorCreateReqVO createReqVO);
/**
* 更新客户竞争对手
* @param updateReqVO 更新信息
*/
void updateCompetitor(@Valid CustomerCompetitorUpdateReqVO updateReqVO);
/**
* 删除客户竞争对手
* @param id 编号
*/
void deleteCompetitor(Long id);
/**
* 获得客户竞争对手
* @param id 编号
* @return 客户竞争对手
*/
CustomerCompetitorDO getCompetitor(Long id);
/**
* 获得客户竞争对手列表
* @param ids 编号
* @return 客户竞争对手列表
*/
List<CustomerCompetitorDO> getCompetitorList(Collection<Long> ids);
List<CustomerCompetitorDO> getCompetitorList();
/**
* 获得客户竞争对手分页
* @param page 分页查询
* @param query 查询
* @return 客户竞争对手分页
*/
PageResult<CustomerCompetitorDO> getCompetitorPage(CustomerCompetitorQueryVO query, PageVO page);
/**
* 获得客户竞争对手列表, 用于 Excel 导出
* @param query 查询
* @return 客户竞争对手列表
*/
List<CustomerCompetitorDO> getCompetitorList(CustomerCompetitorQueryVO query);
}
package cn.iocoder.yudao.module.customer.service.customerCompetitor;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.customer.vo.customerCompetitor.*;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerCompetitor.CustomerCompetitorDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.customer.convert.customerCompetitor.CustomerCompetitorConvert;
import cn.iocoder.yudao.module.customer.dal.mysql.customerCompetitor.CustomerCompetitorMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.customer.enums.ErrorCodeConstants.*;
/**
* 客户竞争对手 Service 实现类
*
* @author yanghao
*/
@Service
@Validated
public class CustomerCompetitorServiceImpl extends AbstractService<CustomerCompetitorMapper, CustomerCompetitorDO> implements CustomerCompetitorService {
@Resource
private CustomerCompetitorMapper competitorMapper;
@Override
public Long createCompetitor(CustomerCompetitorCreateReqVO createReqVO) {
// 校验存在
Long count = competitorMapper.selectCount("name", createReqVO.getName());
if (count != 0) {
throw exception(COMPETITOR_EXISTS);
}
// 插入
CustomerCompetitorDO competitor = CustomerCompetitorConvert.INSTANCE.convert(createReqVO);
competitorMapper.insert(competitor);
// 返回
return competitor.getId();
}
@Override
public void updateCompetitor(CustomerCompetitorUpdateReqVO updateReqVO) {
// 校验存在
this.validateCompetitorExists(updateReqVO.getId());
// 更新
CustomerCompetitorDO updateObj = CustomerCompetitorConvert.INSTANCE.convert(updateReqVO);
competitorMapper.updateById(updateObj);
}
@Override
public void deleteCompetitor(Long id) {
// 校验存在
this.validateCompetitorExists(id);
// 删除
competitorMapper.deleteById(id);
}
private void validateCompetitorExists(Long id) {
if (competitorMapper.selectById(id) == null) {
throw exception(COMPETITOR_NOT_EXISTS);
}
}
@Override
public CustomerCompetitorDO getCompetitor(Long id) {
return competitorMapper.selectById(id);
}
@Override
public List<CustomerCompetitorDO> getCompetitorList(Collection<Long> ids) {
return competitorMapper.selectBatchIds(ids);
}
@Override
public List<CustomerCompetitorDO> getCompetitorList() {
return competitorMapper.selectList();
}
@Override
public PageResult<CustomerCompetitorDO> getCompetitorPage(CustomerCompetitorQueryVO query, PageVO page) {
return competitorMapper.selectPage(page, query);
}
@Override
public List<CustomerCompetitorDO> getCompetitorList(CustomerCompetitorQueryVO query) {
return competitorMapper.selectList(query);
}
}
......@@ -37,11 +37,14 @@ public class CustomeDetailServiceImpl implements CustomerDetailService {
}
@Override
public PageResult<CustomerOfferBackVo> getCustomerOfferPage(Long customerId, PageParam pageParam) {
public PageResult<CustomerOfferBackVo> getCustomerOfferPage(CustomerOfferQueryVo offerQueryVo, PageParam pageParam) {
IPage<CustomerOfferBackVo> mpPage = MyBatisUtils.buildPage(pageParam);
QueryWrapperX queryWrapper = new QueryWrapperX();
queryWrapper.eq("t.deleted", 0);
queryWrapper.eq("t.relation_id", customerId);
queryWrapper.eq("t.relation_id", offerQueryVo.getCustomerId());
queryWrapper.inIfPresent("dst.guojia", offerQueryVo.getDestCountryId());
queryWrapper.inIfPresent("dst.shi", offerQueryVo.getObjectiveId());
queryWrapper.inIfPresent("dst.id", offerQueryVo.getDestWarehouseId());
customerDetailMapper.selectCustomerOfferPage(mpPage, queryWrapper);
return PageResult.of(mpPage);
}
......
......@@ -22,11 +22,11 @@ public interface CustomerDetailService {
/**
* 获得客户报价分页
*
* @param customerId 客户ID
* @param offerQueryVo 客户ID
* @param pageParam 分页参数
* @return 客户级别分页
*/
PageResult<CustomerOfferBackVo> getCustomerOfferPage(Long customerId, PageParam pageParam);
PageResult<CustomerOfferBackVo> getCustomerOfferPage(CustomerOfferQueryVo offerQueryVo, PageParam pageParam);
/**
* 根据运输方式得到订单总数
......
......@@ -46,11 +46,11 @@ public class CustomerCreateReqVO extends CustomerBaseVO {
@ApiModelProperty(value = "产品类型id")
private Long productType;
@ApiModelProperty(value = "产品id")
private Long productId;
@ApiModelProperty(value = "产品ids")
private String productIds;
@ApiModelProperty(value = "常用提货网点id")
private Long pickupPoint;
@ApiModelProperty(value = "常用提货网点ids")
private String pickupPoints;
@ApiModelProperty(value = "关联会员账号id")
private Long memberId;
......@@ -153,6 +153,51 @@ public class CustomerCreateReqVO extends CustomerBaseVO {
@ApiModelProperty(value = "客户银行账户", notes = "参见CustomerBankCreateReqVO")
private List<CustomerBankCreateReqVO> customerBanks;
// ======== 20240821 add start
/**
* 客户角色
* <p>
* 枚举 {@link TODO customer_role 字典}
*/
@ApiModelProperty(value = "客户角色")
private String roles;
/**
* 业务国家 逗号分隔
*/
@ApiModelProperty(value = "业务国家ids")
private String busiCountryIds;
/**
* 竞争对手IDs, 关联 customer_competitor 表主键
*/
@ApiModelProperty(value = "竞争对手IDs")
private String competitorIds;
/**
* 年度发货量
*/
@ApiModelProperty(value = "年度发货量")
private BigDecimal weightYearly;
/**
* 年度发货次数
*/
@ApiModelProperty(value = "年度发货次数")
private Integer numYearly;
/**
* 默认开票,1-是,0-否
*/
@ApiModelProperty(value = "默认开票,1-是,0-否")
private Boolean defaultBilling;
// ======== 20240821 add end
/**
......@@ -173,6 +218,10 @@ public class CustomerCreateReqVO extends CustomerBaseVO {
private String customerOperateLogOrderNo;
@JsonIgnore
private Integer createFrom;
/**
* 是否被订单收货人同步的
......
......@@ -63,11 +63,11 @@ public class CustomerDetailRespVO extends CustomerBaseVO {
@ApiModelProperty(value = "产品类型id")
private Long productType;
@ApiModelProperty(value = "产品id")
private Long productId;
@ApiModelProperty(value = "产品ids")
private String productIds;
@ApiModelProperty(value = "常用提货网点id")
private Long pickupPoint;
@ApiModelProperty(value = "常用提货网点ids")
private String pickupPoints;
@ApiModelProperty(value = "关联会员账号id")
private Long memberId;
......@@ -96,9 +96,17 @@ public class CustomerDetailRespVO extends CustomerBaseVO {
//客户创建日期格式化
//@JsonFormat(value = "创建时间", example = "1652017501000")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY,
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND,
timezone = TIME_ZONE_DEFAULT)
private Date createTime;
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND,
timezone = TIME_ZONE_DEFAULT)
private Date updateTime;
@ApiModelProperty(value = "创建人名称")
private String creatorName;
@ApiModelProperty(value = "更新人名称")
private String updaterName;
//--------发票信息
......@@ -182,6 +190,50 @@ public class CustomerDetailRespVO extends CustomerBaseVO {
private List<CustomerBankBackVO> customerBankBackVOList;
// ======== 20240821 add start
/**
* 客户角色
* <p>
* 枚举 {@link TODO customer_role 字典}
*/
@ApiModelProperty(value = "客户角色")
private String roles;
/**
* 业务国家 逗号分隔
*/
@ApiModelProperty(value = "业务国家ids")
private String busiCountryIds;
/**
* 竞争对手IDs, 关联 customer_competitor 表主键
*/
@ApiModelProperty(value = "竞争对手IDs")
private String competitorIds;
/**
* 年度发货量
*/
@ApiModelProperty(value = "年度发货量")
private BigDecimal weightYearly;
/**
* 年度发货次数
*/
@ApiModelProperty(value = "年度发货次数")
private Integer numYearly;
/**
* 默认开票,1-是,0-否
*/
@ApiModelProperty(value = "默认开票,1-是,0-否")
private Boolean defaultBilling;
// ======== 20240821 add end
@ApiModelProperty(value = "国家中文名称")
private String countryNameZh;
......@@ -204,6 +256,22 @@ public class CustomerDetailRespVO extends CustomerBaseVO {
@ApiModelProperty(value = "常用提货点英文名称")
private String pickupPointNameEn;
@ApiModelProperty(value = "业务国家中文名称")
private String busiCountryNameZh;
@ApiModelProperty(value = "业务国家英文名称")
private String busiCountryNameEn;
/**
* 竞争对手IDs, 关联 customer_competitor 表主键
*/
@ApiModelProperty(value = "竞争对手名称")
private String competitorNames;
@ApiModelProperty(value = "付款人姓名")
private String payerName;
......
......@@ -53,11 +53,11 @@ public class CustomerUpdateReqVO extends CustomerBaseVO {
@ApiModelProperty(value = "产品类型")
private Long productType;
@ApiModelProperty(value = "产品id")
private Long productId;
@ApiModelProperty(value = "产品ids")
private String productIds;
@ApiModelProperty(value = "常用提货网点")
private Long pickupPoint;
@ApiModelProperty(value = "常用提货网点ids")
private String pickupPoints;
@ApiModelProperty(value = "关联会员账号")
private Long memberId;
......@@ -181,4 +181,49 @@ public class CustomerUpdateReqVO extends CustomerBaseVO {
@ApiModelProperty(value = "是否潜在客户")
private Boolean isPotential = false;
// ======== 20240821 add start
/**
* 客户角色
* <p>
* 枚举 {@link TODO customer_role 字典}
*/
@ApiModelProperty(value = "客户角色")
private String roles;
/**
* 业务国家 逗号分隔
*/
@ApiModelProperty(value = "业务国家ids")
private String busiCountryIds;
/**
* 竞争对手IDs, 关联 customer_competitor 表主键
*/
@ApiModelProperty(value = "竞争对手IDs")
private String competitorIds;
/**
* 年度发货量
*/
@ApiModelProperty(value = "年度发货量")
private BigDecimal weightYearly;
/**
* 年度发货次数
*/
@ApiModelProperty(value = "年度发货次数")
private Integer numYearly;
/**
* 默认开票,1-是,0-否
*/
@ApiModelProperty(value = "默认开票,1-是,0-否")
private Boolean defaultBilling;
// ======== 20240821 add end
}
package cn.iocoder.yudao.module.customer.vo.customerCompetitor;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 客户竞争对手 Response VO
* @author yanghao
*/
@Data
@ApiModel("管理后台 - 客户竞争对手 Response VO")
public class CustomerCompetitorBackVO {
@ExcelProperty("主键ID")
@ApiModelProperty(value = "主键ID", required = true)
private Long id;
@ExcelProperty("名称")
@ApiModelProperty(value = "名称", required = true)
private String name;
@ExcelProperty("创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}
package cn.iocoder.yudao.module.customer.vo.customerCompetitor;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
/**
* 客户竞争对手 Base VO,提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class CustomerCompetitorBaseVO {
@ApiModelProperty(value = "名称", required = true)
@NotNull(message = "名称不能为空")
private String name;
}
package cn.iocoder.yudao.module.customer.vo.customerCompetitor;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("管理后台 - 客户竞争对手创建 Request VO")
public class CustomerCompetitorCreateReqVO extends CustomerCompetitorBaseVO {
}
package cn.iocoder.yudao.module.customer.vo.customerCompetitor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("管理后台 - 客户竞争对手查询 VO")
public class CustomerCompetitorQueryVO {
@ApiModelProperty(value = "名称")
private String name;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}
package cn.iocoder.yudao.module.customer.vo.customerCompetitor;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 客户竞争对手更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CustomerCompetitorUpdateReqVO extends CustomerCompetitorBaseVO {
@ApiModelProperty(value = "主键ID", required = true)
@NotNull(message = "主键ID不能为空")
private Long id;
}
package cn.iocoder.yudao.module.customer.vo.customerDetail;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -8,6 +9,7 @@ import lombok.Data;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 客户基本信息客户报价 Response VO")
@Data
......@@ -21,6 +23,7 @@ public class CustomerOfferBackVo {
@ApiModelProperty(value = "客户名称")
private String consignorName;
@ApiModelProperty(value = "目的地中文")
private String objectiveName;
......@@ -30,10 +33,44 @@ public class CustomerOfferBackVo {
@ApiModelProperty(value = "取消报价:0,特价审批中:1,草稿:2, 需求确认:3,赢单:4,输单:5,报价完成:6 跟进中:7")
private Integer status;
@ApiModelProperty(value = "业务员名称")
@ApiModelProperty(value = "业务员名称-客户经理")
private String businessManagerName;
@ApiModelProperty(value = "预计结束时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private Date stopTime;
@ApiModelProperty(value = "创建时间", required = true)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date createTime;
@ExcelProperty("价格有效期开始")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private Date startTime;
@ExcelProperty("价格有效期结束")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private Date endTime;
@ExcelProperty("重要程度")
private Integer importance;
@ApiModelProperty(value = "联系人名称")
private String relationName;
@ApiModelProperty(value = "联系人区号")
private String relationAreaCode;
@ApiModelProperty(value = "联系人手机号")
private String relationPhone;
// 线路相关
@ExcelProperty("始发仓库id")
private Long startWarehouseId;
@ExcelProperty("目的仓库id")
private Long destWarehouseId;
@ExcelProperty("运输方式")
private String transportType;
}
package cn.iocoder.yudao.module.customer.vo.customerDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("管理后台 - 客户基本信息报价查询 Request VO")
@Data
public class CustomerOfferQueryVo {
@ApiModelProperty(value = "客户id")
private Long customerId;
@ApiModelProperty(value = "目的国id")
private List<Long> destCountryId ;
@ApiModelProperty(value = "目的地id")
private List<Long> objectiveId;
@ApiModelProperty(value = "目的仓ID")
private List<Long> destWarehouseId;
}
......@@ -19,11 +19,18 @@
s.title_en as objective_name_en,
t.status as status,
t.stop_time as stop_time,
u.nickname as business_manager_name
u.nickname as business_manager_name,
t.create_time, t.start_time, t.end_time, t.importance,
cc.name as relation_name, cc.area_code as relation_area_code, cc.phone_new as relation_phone,
line.start_warehouse_id, line.dest_warehouse_id, line.transport_type
from ecw_offer t
left join ecw_region s
on t.objective_id = s.id
left join ecw_region s on t.objective_id = s.id
left join system_user u on t.follow_up_salesman_id = u.id
left join ecw_customer_contacts cc on (t.relation = 1 and cc.id = t.consignor_id) or (t.relation = 2 and cc.id = t.consignee_id)
left join ecw_warehouse_line line on t.line_id = line.id
left join ecw_warehouse dst on line.dest_warehouse_id = dst.id
${ew.customSqlSegment}
</select>
<select id="selectCustomerFollowPage"
......
......@@ -788,6 +788,8 @@
a.customer_service = #{customerServiceId},
-- 分配时间
a.customer_service_assigned_time = now(),
-- 获取方式:分配/移交接收
a.get_method = 2,
-- 确认接收置为false
a.is_customer_service_confirmed = 0,
......@@ -867,6 +869,10 @@
a.is_customer_service_confirmed = 1,
-- 分配时间
a.customer_service_assigned_time = now(),
-- 归属时间
a.customer_service_confirmed_time = now(),
-- 获取方式:公海捞取
a.get_method = 3,
-- 设置捞取时间
a.catch_time = now(),
-- 报价单延期次数重置为0
......
......@@ -50,6 +50,7 @@ import cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankBackVO;
import cn.iocoder.yudao.module.customer.vo.customerBank.CustomerBankQueryVO;
import cn.iocoder.yudao.module.ecw.api.paramValid.ParamValidatorApi;
import cn.iocoder.yudao.module.ecw.enums.CustomerContactsDefaultEnum;
import cn.iocoder.yudao.module.ecw.enums.CustomerCreateFromEnum;
import cn.iocoder.yudao.module.ecw.enums.CustomerOperateTypeEnum;
import cn.iocoder.yudao.module.ecw.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.ecw.service.busiPwd.BusiPwdService;
......@@ -239,6 +240,9 @@ public class CustomerController {
}
}
// 后台创建
createReqVO.setCreateFrom(CustomerCreateFromEnum.BACKEND.getValue());
return success(customerService.createCustomer(createReqVO));
}
......
package cn.iocoder.yudao.module.customer.controller.admin.customerCompetitor;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.customer.vo.customerCompetitor.*;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerCompetitor.CustomerCompetitorDO;
import cn.iocoder.yudao.module.customer.convert.customerCompetitor.CustomerCompetitorConvert;
import cn.iocoder.yudao.module.customer.service.customerCompetitor.CustomerCompetitorService;
@Validated
@RestController
@Api(tags = "管理后台 - 客户竞争对手")
@RequestMapping("/customer/competitor")
public class CustomerCompetitorController {
@Resource
private CustomerCompetitorService competitorService;
@PostMapping("/create")
@ApiOperation("创建客户竞争对手")
// @PreAuthorize("@ss.hasPermission('customer:competitor:create')")
public CommonResult<Long> createCompetitor(@Valid @RequestBody CustomerCompetitorCreateReqVO createReqVO) {
return success(competitorService.createCompetitor(createReqVO));
}
// @PutMapping("/update")
// @ApiOperation("更新客户竞争对手")
// @PreAuthorize("@ss.hasPermission('customer:competitor:update')")
// public CommonResult<Boolean> updateCompetitor(@Valid @RequestBody CustomerCompetitorUpdateReqVO updateReqVO) {
// competitorService.updateCompetitor(updateReqVO);
// return success(true);
// }
//
// @DeleteMapping("/delete")
// @ApiOperation("删除客户竞争对手")
// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
// @PreAuthorize("@ss.hasPermission('customer:competitor:delete')")
// public CommonResult<Boolean> deleteCompetitor(@RequestParam("id") Long id) {
// competitorService.deleteCompetitor(id);
// return success(true);
// }
//
// @GetMapping("/get")
// @ApiOperation("获得客户竞争对手")
// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
// @PreAuthorize("@ss.hasPermission('customer:competitor:query')")
// public CommonResult<CustomerCompetitorBackVO> getCompetitor(@RequestParam("id") Long id) {
// CustomerCompetitorDO competitor = competitorService.getCompetitor(id);
// return success(CustomerCompetitorConvert.INSTANCE.convert(competitor));
// }
@GetMapping("/list")
@ApiOperation("获得客户竞争对手列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
// @PreAuthorize("@ss.hasPermission('customer:competitor:query')")
public CommonResult<List<CustomerCompetitorBackVO>> getCompetitorList(@RequestParam("ids") Collection<Long> ids) {
List<CustomerCompetitorDO> list = competitorService.getCompetitorList(ids);
return success(CustomerCompetitorConvert.INSTANCE.convertList(list));
}
@GetMapping("/listAll")
@ApiOperation("获得所有客户竞争对手列表")
// @PreAuthorize("@ss.hasPermission('customer:competitor:query')")
public CommonResult<List<CustomerCompetitorBackVO>> getCompetitorListAll() {
List<CustomerCompetitorDO> list = competitorService.getCompetitorList();
return success(CustomerCompetitorConvert.INSTANCE.convertList(list));
}
// @GetMapping("/page")
// @ApiOperation("获得客户竞争对手分页")
// @PreAuthorize("@ss.hasPermission('customer:competitor:query')")
// public CommonResult<PageResult<CustomerCompetitorBackVO>> getCompetitorPage(@Valid CustomerCompetitorQueryVO query, PageVO page) {
// PageResult<CustomerCompetitorDO> pageResult = competitorService.getCompetitorPage(query, page);
// return success(CustomerCompetitorConvert.INSTANCE.convertPage(pageResult));
// }
// @GetMapping("/export-excel")
// @ApiOperation("导出客户竞争对手 Excel")
// @PreAuthorize("@ss.hasPermission('customer:competitor:export')")
// @OperateLog(type = EXPORT)
// public void exportCompetitorExcel(@Valid CustomerCompetitorQueryVO query,
// HttpServletResponse response) throws IOException {
// List<CustomerCompetitorDO> list = competitorService.getCompetitorList(query);
// // 导出 Excel
// List<CustomerCompetitorBackVO> datas = CustomerCompetitorConvert.INSTANCE.convertList(list);
// ExcelUtils.write(response, "客户竞争对手.xls", "数据", CustomerCompetitorBackVO.class, datas);
// }
}
......@@ -11,3 +11,12 @@ GET {{baseUrl}}/customer/detail/infoList/creditScoreStatistic?customerId=34831
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
Content-Type: application/json
### 客户报价
GET {{baseUrl}}/customer/detail/infoList/offerPage?pageNo=1&pageSize=10&total=0&customerId=12925
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
Content-Type: application/json
\ No newline at end of file
......@@ -48,9 +48,9 @@ public class CustomerDetailController {
@GetMapping("/offerPage")
@ApiOperation("获取报价分页")
public CommonResult<PageResult<CustomerOfferBackVo>> getOfferPage(@RequestParam("customerId") Long customerId, PageParam page) {
public CommonResult<PageResult<CustomerOfferBackVo>> getOfferPage(CustomerOfferQueryVo offerQueryVo, PageParam page) {
PageResult<CustomerOfferBackVo> pageResult =
customerDetailService.getCustomerOfferPage(customerId, page);
customerDetailService.getCustomerOfferPage(offerQueryVo, page);
return success(pageResult);
}
......
package cn.iocoder.yudao.module.ecw.api.customer;
import java.util.Date;
public interface CustomerApi {
void associateCustomerAuto(String areaCode, String phone, Long userId, String newName);
void approvalCustomerDelay(String approveId, Integer result);
void approvalCustomerTransfer(String approveId, Integer result);
void fillFirstDealTimeIfNull(Long customerId, Date firstDealTime);
}
package cn.iocoder.yudao.module.ecw.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 客户创建入口类型枚举
*/
@AllArgsConstructor
@Getter
public enum CustomerCreateFromEnum {
//1、导入 2、后台用户创建 3、APP注册 4、发货人创建
IMPORT(1, "导入"),
BACKEND(2, "后台用户创建"),
APP_REGISTER(3, "APP注册"),
APP_CONSIGNOR(4, "APP发货人创建");
;
/**
* 类型
*/
private final Integer value;
/**
* 类型名
*/
private final String name;
public static String getNameByValue(Integer value) {
return Arrays.stream(CustomerCreateFromEnum.values()).filter(t -> t.getValue().equals(value)).map(CustomerCreateFromEnum::getName).findFirst().orElse("");
}
public static CustomerCreateFromEnum get(Integer value) {
return Arrays.stream(CustomerCreateFromEnum.values()).filter(t -> t.getValue().equals(value)).findFirst().orElse(null);
}
}
package cn.iocoder.yudao.module.ecw.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 客户获取方式类型枚举
*/
@AllArgsConstructor
@Getter
public enum CustomerGetMethodEnum {
CREATE(1, "自主创建"),
ASSIGN(2, "分配/移交接收"),
CATCH(3, "公海捞取");
;
/**
* 类型
*/
private final Integer value;
/**
* 类型名
*/
private final String name;
public static String getNameByValue(Integer value) {
return Arrays.stream(CustomerGetMethodEnum.values()).filter(t -> t.getValue().equals(value)).map(CustomerGetMethodEnum::getName).findFirst().orElse("");
}
public static CustomerGetMethodEnum get(Integer value) {
return Arrays.stream(CustomerGetMethodEnum.values()).filter(t -> t.getValue().equals(value)).findFirst().orElse(null);
}
}
package cn.iocoder.yudao.module.ecw.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 客户角色类型枚举
*/
@AllArgsConstructor
@Getter
public enum CustomerRoleEnum {
//0、CO 1、工程商 2、代理 6、集运
C0(0, "C0"),
CONTRACTOR(1, "工程商"),
PROXY(2, "代理"),
CONSOLIDATOR(6, "集运");
;
/**
* 类型
*/
private final Integer value;
/**
* 类型名
*/
private final String name;
public static String getNameByValue(Integer value) {
return Arrays.stream(CustomerRoleEnum.values()).filter(t -> t.getValue().equals(value)).map(CustomerRoleEnum::getName).findFirst().orElse("");
}
public static CustomerRoleEnum get(Integer value) {
return Arrays.stream(CustomerRoleEnum.values()).filter(t -> t.getValue().equals(value)).findFirst().orElse(null);
}
}
......@@ -120,8 +120,8 @@ public class MemberRegListener {
OrderConsignorDO orderConsignorByOrderId = orderConsignorService.getOrderConsignorByOrderId(orderId);
if (orderConsignorByOrderId != null && orderConsignorByOrderId.getCustomerId() != null) {
CustomerDO orderConsignorCustomer = customerService.getCustomer(orderConsignorByOrderId.getCustomerId());
if (orderConsignorCustomer != null && StringUtils.isNotEmpty(orderConsignorCustomer.getType())
&& !orderConsignorCustomer.getType().contains("2") && !orderConsignorCustomer.getType().contains("3")) {
if (orderConsignorCustomer != null && StringUtils.isNotEmpty(orderConsignorCustomer.getRoles())
&& !orderConsignorCustomer.getRoles().contains("2") && !orderConsignorCustomer.getRoles().contains("3")) {
//设置为发货人的客户经理
orderConsigneeCustomer.setCustomerService(orderConsignorCustomer.getCustomerService());
orderConsigneeCustomer.setConsigneeFirstCustomerService(orderConsignorCustomer.getCustomerService());
......
......@@ -418,9 +418,9 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
customerService.getCustomer(orderConsignorDO.getCustomerId());
// 发货人不是代理或同行
if (orderConsignorCustomer != null &&
StringUtils.isNotEmpty(orderConsignorCustomer.getType())
&& !orderConsignorCustomer.getType().contains("2") &&
!orderConsignorCustomer.getType().contains("3")) {
StringUtils.isNotEmpty(orderConsignorCustomer.getRoles())
&& !orderConsignorCustomer.getRoles().contains("2") &&
!orderConsignorCustomer.getRoles().contains("3")) {
// 收货人信息
OrderConsigneeDO orderConsigneeDO =
orderConsigneeService.getOrderConsigneeByOrderId(orderId);
......
......@@ -324,7 +324,7 @@ public class OrderBackPageVO {
@ApiModelProperty(value = "首次入仓时间")
private Date inTime;
@ApiModelProperty(value = "已装柜时间")
@ApiModelProperty(value = "已装柜时间/到仓时间")
private Date loadTime;
@ApiModelProperty(value = "已卸柜/已到仓时间")
......@@ -476,6 +476,23 @@ public class OrderBackPageVO {
private Integer lang;
// -----------start -----------
// add 20240825. 客户详情中 订单列表返回的数据
@ApiModelProperty(value = "报价单编号 多个以逗号分隔")
private String offerNumbers;
@ApiModelProperty(value = "业绩归属客户名称")
private String customerName;
@ApiModelProperty(value = "提货数量")
private Integer pickNum;
// -----------end -----------
public void setGuanLianOrderStatus(String guanLianOrderStatus) {
this.guanLianOrderStatus = guanLianOrderStatus;
if (StringUtils.isNotBlank(guanLianOrderStatus)) {
......
......@@ -1006,6 +1006,7 @@
o.is_exception,
o.create_time,
o.load_time,
o.unload_time,
(select su.nickname from system_user su where su.deleted = 0 and su.id = o.salesman_id) as salesman_name,
(select min(wi.`in_time`) from ecw_order_warehouse_in wi where wi.deleted = 0 and wi.order_id = o.order_id ) as
in_time,
......@@ -1020,8 +1021,12 @@
nee.country_code as consignee_country_code,
if(#{query.lang} = 0, channel.name_zh, channel.name_en) as channel_name,
o.update_time,
#{query.lang} as lang
#{query.lang} as lang,
(SELECT GROUP_CONCAT(t1.number) FROM ecw_offer t1 WHERE t1.order_id = o.order_id and t1.status = 4) as offer_numbers,
c.name as customer_name,
(SELECT sum(eop.pick_num) FROM ecw_order_pickup eop WHERE eop.order_id = o.order_no) AS pickNum
from ecw_order o
left join ecw_customer c on o.customer_id = c.id
left join (
SELECT
ewl.id AS line_id,
......
......@@ -74,7 +74,7 @@ tenant-id: {{adminTenentId}}
### 查询前20条
GET {{baseUrl}}/ecw/order/customer-order-page?customerDetailId=29572
GET {{baseUrl}}/ecw/order/customer-order-page?page=2&customerDetailId=12925
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
......
......@@ -139,5 +139,21 @@ public interface ReceiptService extends IService<ReceiptDO> {
ReceiptExportDto getReceiptExportByOrderId(Long orderId);
/**
* 判断当前收款单有没有达到比例
*
* @param receiptDO
* @param proportion
* @return
*/
Boolean judgingProportion(ReceiptDO receiptDO, String proportion);
/**
* 自动更新收款单的核销状态
*
* @param receiptDO
*/
void autoWriteOffReceipt(ReceiptDO receiptDO, String userId, String userName);
}
package cn.iocoder.yudao.module.wealth.service.receipt;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.OrderNumberLogEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
......@@ -101,8 +102,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
@Override
@Transactional(rollbackFor = Exception.class)
public Long createReceipt(ReceiptCreateReqVO createReqVO) {
List<ReceivableUpdateReqVO> receivableUpdateReqVOList =
createReqVO.getReceivableVOList();
List<ReceivableUpdateReqVO> receivableUpdateReqVOList = createReqVO.getReceivableVOList();
if (CollectionUtil.isEmpty(receivableUpdateReqVOList)) {
throw exception(RECEIVABLE_NOT_NULL);
......@@ -118,8 +118,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
//当自编号为空(某些预付款未装柜的订单),则校验为同一客户同意目的国,忽略自编号规则,视为同一自编号
validateSameCustomerReceivable(createReqVO.getReceivableVOList());
List<ReceiptAccountCreateReqVO> receiptAccountCreateReqVOList =
createReqVO.getReceiptAccountList();
List<ReceiptAccountCreateReqVO> receiptAccountCreateReqVOList = createReqVO.getReceiptAccountList();
if (CollectionUtil.isEmpty(receiptAccountCreateReqVOList)) {
throw exception(RECEIPT_ACCOUNT_NOT_EXISTS);
......@@ -178,11 +177,8 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
receiptMapper.updateById(update);
}
List<ReceivableDO> receivableDOList =
receivableUpdateReqVOList.stream().
filter(re -> null != re.getId()).map(re -> {
ReceivableDO receivableDO =
ReceivableConvert.INSTANCE.convert(re);
List<ReceivableDO> receivableDOList = receivableUpdateReqVOList.stream().filter(re -> null != re.getId()).map(re -> {
ReceivableDO receivableDO = ReceivableConvert.INSTANCE.convert(re);
receivableDO.setReceiptNo(receipt.getReceiptNo());
receivableDO.setReceiptId(receipt.getId());
receivableDO.setState(1);
......@@ -193,8 +189,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
receivableService.updateBatchById(receivableDOList);
List<ReceiptAccountDO> receiptAccountDOList =
receiptAccountCreateReqVOList.stream().map(re -> {
List<ReceiptAccountDO> receiptAccountDOList = receiptAccountCreateReqVOList.stream().map(re -> {
ReceiptAccountDO receivableDO = ReceiptAccountConvert.INSTANCE.convert(re);
receivableDO.setReceiptId(receipt.getId());
receivableDO.setUpdater(creator);
......@@ -438,37 +433,29 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
@Override
public PageResult<ReceiptBackVO> getReceiptPage(ReceiptQueryVO query,
PageVO page) {
public PageResult<ReceiptBackVO> getReceiptPage(ReceiptQueryVO query, PageVO page) {
page.setField("er.id");
IPage<ReceiptBackVO> mpPage = MyBatisUtils.buildPage(page);
receiptMapper.getReceiptBackPage(mpPage, query);
//添加明细状态计算列表
//MxStatus
//获取List指定字段的List
List<Long> idList = mpPage.getRecords().stream()
.map(ReceiptBackVO::getId)
.collect(Collectors.toList());
List<Long> idList = mpPage.getRecords().stream().map(ReceiptBackVO::getId).collect(Collectors.toList());
//一定要判空,不然会报错
if(CollectionUtil.isNotEmpty(idList)) {
if (CollectionUtil.isNotEmpty(idList)) {
//根据List获取本页中所有的明细信息
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper =
new LambdaQueryWrapper<>();
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(ReceiptItemDO::getReceiptId, idList);
//所有收款单的明细
List<ReceiptItemDO> listItem =
receiptItemMapper.selectList(lambdaQueryWrapper);
List<ReceiptItemDO> listItem = receiptItemMapper.selectList(lambdaQueryWrapper);
LambdaQueryWrapper<ReceiptAccountDO> lambdaQueryWrapper2 =
new LambdaQueryWrapper<>();
LambdaQueryWrapper<ReceiptAccountDO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.in(ReceiptAccountDO::getReceiptId, idList);
List<ReceiptAccountDO> ReceiptAccountList =
receiptAccountMapper.selectList(lambdaQueryWrapper2);
List<ReceiptAccountDO> ReceiptAccountList = receiptAccountMapper.selectList(lambdaQueryWrapper2);
Map<Integer, CurrencyRespDTO> currencyMap = currencyApi.getAllCurrency();
for (ReceiptBackVO r : mpPage.getRecords()
) {
for (ReceiptBackVO r : mpPage.getRecords()) {
String sR = getReceiptMxStatus(listItem, r.getId());
r.setMxStatus(sR);
......@@ -480,16 +467,14 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
r.setSsShow(s2);
//核销比例
r.setHxBiLi(getHxBili(ReceiptAccountList,
listItem, r.getId()));
r.setHxBiLi(getHxBili(ReceiptAccountList, listItem, r.getId()));
}
}
return PageResult.of(mpPage);
}
private String getPercentage(BigDecimal part, BigDecimal total) {
BigDecimal percentage = part.divide(total, 5,
BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
BigDecimal percentage = part.divide(total, 5, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
// 输出百分比
String sR = format(percentage) + "%";
return sR;
......@@ -505,24 +490,18 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
/*
获取核销比例
*/
private String getHxBili(List<ReceiptAccountDO> ReceiptAccountList,
List<ReceiptItemDO> listItemList,
long ReceiptId) {
private String getHxBili(List<ReceiptAccountDO> ReceiptAccountList, List<ReceiptItemDO> listItemList, long ReceiptId) {
String sR = "0";
if (CollectionUtil.isEmpty(ReceiptAccountList))
return sR;
if (CollectionUtil.isEmpty(ReceiptAccountList)) return sR;
if (CollectionUtil.isEmpty(listItemList)) {
return sR;
}
List<ReceiptAccountDO> ReceiptAccountList1 =
ReceiptAccountList.stream().filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.toList());
List<ReceiptAccountDO> ReceiptAccountList1 = ReceiptAccountList.stream().filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(ReceiptAccountList1)) return sR;
BigDecimal bTotal = new BigDecimal(0);
BigDecimal bPart = new BigDecimal(0);
for (ReceiptAccountDO do1 : ReceiptAccountList1
) {
for (ReceiptAccountDO do1 : ReceiptAccountList1) {
bTotal = bTotal.add(do1.getWriteOffAmount());
}
......@@ -532,16 +511,13 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
}
//已核销状态记录
List<ReceiptItemDO> list =
listItemList.stream().filter(i -> i.getReceiptId() == ReceiptId
&& i.getStatus() != 0).collect(Collectors.toList());
List<ReceiptItemDO> list = listItemList.stream().filter(i -> i.getReceiptId() == ReceiptId && i.getStatus() != 0).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
//核销金额为0 核销比例为空
return sR;
}
for (ReceiptItemDO do2 : list
) {
for (ReceiptItemDO do2 : list) {
bPart = bPart.add(do2.getWriteOffAmount());
}
//计算百分比
......@@ -552,22 +528,16 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
/*
应收款
*/
private String getYSShow(List<ReceiptAccountDO> ReceiptAccountList,
long ReceiptId,
Map<Integer, CurrencyRespDTO> currencyMap) {
private String getYSShow(List<ReceiptAccountDO> ReceiptAccountList, long ReceiptId, Map<Integer, CurrencyRespDTO> currencyMap) {
String sR = "";
if (CollectionUtil.isEmpty(ReceiptAccountList)) {
return sR;
}
List<ReceiptAccountDO> ReceiptAccountList1 =
ReceiptAccountList.stream().filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.toList());
if (CollectionUtil.isEmpty(ReceiptAccountList1))
return sR;
List<ReceiptAccountDO> ReceiptAccountList1 = ReceiptAccountList.stream().filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(ReceiptAccountList1)) return sR;
for (ReceiptAccountDO do1 : ReceiptAccountList1
) {
for (ReceiptAccountDO do1 : ReceiptAccountList1) {
BigDecimal b1 = do1.getReceivableAmount();
String s1 = b1.toString();
String s2 = "";
......@@ -585,24 +555,17 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
实收金额
*/
private String getSSShow(List<ReceiptItemDO> listItemList,
long ReceiptId,
Map<Integer, CurrencyRespDTO> currencyMap) {
private String getSSShow(List<ReceiptItemDO> listItemList, long ReceiptId, Map<Integer, CurrencyRespDTO> currencyMap) {
String sR = "";
if (CollectionUtil.isEmpty(listItemList)) {
return sR;
}
List<ReceiptItemDO> list =
listItemList.stream().filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.toList());
List<ReceiptItemDO> list = listItemList.stream().filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) return sR;
//根据币种分组求和
Map<Long, BigDecimal> dataMap =
list.stream().filter(t -> t.getCurrencyId() != null)
.collect(Collectors.groupingBy(ReceiptItemDO::getCurrencyId,
CollectorsUtil.summingBigDecimal(ReceiptItemDO::getAmount)));
Map<Long, BigDecimal> dataMap = list.stream().filter(t -> t.getCurrencyId() != null).collect(Collectors.groupingBy(ReceiptItemDO::getCurrencyId, CollectorsUtil.summingBigDecimal(ReceiptItemDO::getAmount)));
//遍历币种信息
for (Map.Entry<Long, BigDecimal> entry : dataMap.entrySet()) {
String key = entry.getKey().toString();
......@@ -633,8 +596,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
//全部审核 收款明细全部已审批 OK
String sMxStatus = "";
//计算明细总数
Long iCount = listItem.stream().filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.counting());
Long iCount = listItem.stream().filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
if (iCount == 0) {
sMxStatus = "未录入";
return sMxStatus;
......@@ -645,18 +607,10 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
//bmpStatus
//PROCESS(1, "处理中"),APPROVE(2, "通过"),
//REJECT(3, "不通过"),CANCEL(4, "已取消");
long Item0 = listItem.stream().filter(i -> i.getStatus() == 0).
filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.counting());
long Item1 = listItem.stream().filter(i -> i.getStatus() == 1).
filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.counting());
long Item2 = listItem.stream().filter(i -> i.getStatus() == 2).
filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.counting());
long Item3 = listItem.stream().filter(i -> i.getStatus() == 3).
filter(i -> i.getReceiptId() == ReceiptId).
collect(Collectors.counting());
long Item0 = listItem.stream().filter(i -> i.getStatus() == 0).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item1 = listItem.stream().filter(i -> i.getStatus() == 1).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item2 = listItem.stream().filter(i -> i.getStatus() == 2).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item3 = listItem.stream().filter(i -> i.getStatus() == 3).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
if (Item0 == iCount) {
//0待核销
......@@ -684,9 +638,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
return sMxStatus;
}
if ((Item2 + Item3) == iCount ||
(Item1 + Item3) == iCount ||
(Item2 + Item1) == iCount) {
if ((Item2 + Item3) == iCount || (Item1 + Item3) == iCount || (Item2 + Item1) == iCount) {
sMxStatus = "部分审核";
return sMxStatus;
}
......@@ -764,8 +716,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
@Override
public void createFinanceReceiptWriteOff(FinanceReceiptVo financeReceiptVo) {
ReceiptDO receiptDO =
validateReceiptBmpStatus(financeReceiptVo.getReceiptId());
ReceiptDO receiptDO = validateReceiptBmpStatus(financeReceiptVo.getReceiptId());
//判断收款单下的收款明细是不是全部核销完成
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReceiptItemDO::getReceiptId, financeReceiptVo.getReceiptId());
......@@ -775,19 +726,15 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
throw exception(RECEIPT_ITEM_WRITE_OFF_ING);
}
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper1 =
new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(ReceiptItemDO::getReceiptId,
financeReceiptVo.getReceiptId());
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(ReceiptItemDO::getReceiptId, financeReceiptVo.getReceiptId());
lambdaQueryWrapper1.eq(ReceiptItemDO::getStatus, 1);
List<ReceiptItemDO> receiptItemDOList =
receiptItemMapper.selectList(lambdaQueryWrapper1);
List<ReceiptItemDO> receiptItemDOList = receiptItemMapper.selectList(lambdaQueryWrapper1);
if (null == receiptItemDOList || receiptItemDOList.size() == 0) {
throw exception(RECEIPT_NOT_WRITE_OFF_ITEM_NOT_EXISTS);
}
BigDecimal totalAmount =
receiptItemDOList.stream().map(ReceiptItemDO::getWriteOffAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalAmount = receiptItemDOList.stream().map(ReceiptItemDO::getWriteOffAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
/* if (receiptDO.getState() != 2 && receiptDO.getState() != 3) {
......@@ -826,11 +773,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
approvalDO.setReason(financeReceiptVo.getRemark());
receiptApprovalService.save(approvalDO);
Long userId = SecurityFrameworkUtils.getLoginUserId();
String bpmId = bpmCreateServiceFactory.createBmp(userId,
approvalDO.getId(),
WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF.getKey(),
financeReceiptVo.getReceiptNo(),
financeReceiptVo.getCopyUserList());
String bpmId = bpmCreateServiceFactory.createBmp(userId, approvalDO.getId(), WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF.getKey(), financeReceiptVo.getReceiptNo(), financeReceiptVo.getCopyUserList());
approvalDO.setBmpId(bpmId);
receiptApprovalService.updateById(approvalDO);
......@@ -839,9 +782,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
update.setId(financeReceiptVo.getReceiptId());
update.setBmpStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
//计算出核销比例
BigDecimal proportion =
totalAmount.divide(receiptDO.getReceivableTotalAmount(),
8, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
BigDecimal proportion = totalAmount.divide(receiptDO.getReceivableTotalAmount(), 8, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
update.setWriteOffProportion(proportion);
update.setState(ReceiptStatusEnum.WRITE_OFF_ALL_ING.getValue());
update.setBmpId(bpmId);
......@@ -926,8 +867,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
throw exception(BMP_NOT);
}
if (receiptDO.getBmpStatus() !=
BpmProcessInstanceResultEnum.PROCESS.getResult()) {
if (receiptDO.getBmpStatus() != BpmProcessInstanceResultEnum.PROCESS.getResult()) {
throw exception(BMP_CANCEL);
}
......@@ -938,4 +878,80 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
public ReceiptExportDto getReceiptExportByOrderId(Long orderId) {
return receiptMapper.getReceiptExportByOrderId(orderId);
}
@Override
public Boolean judgingProportion(ReceiptDO receiptDO, String proportion) {
//判断收款单下的收款明细是不是全部核销
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReceiptItemDO::getReceiptId, receiptDO.getId());
lambdaQueryWrapper.in(ReceiptItemDO::getStatus, 0, 2, 3);
Long count = receiptItemMapper.selectCount(lambdaQueryWrapper);
if (count != 0) {
return Boolean.FALSE;
}
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(ReceiptItemDO::getReceiptId, receiptDO.getId());
lambdaQueryWrapper1.eq(ReceiptItemDO::getStatus, 1);
List<ReceiptItemDO> receiptItemDOList = receiptItemMapper.selectList(lambdaQueryWrapper1);
if (null == receiptItemDOList || receiptItemDOList.size() == 0) {
return Boolean.FALSE;
}
BigDecimal totalAmount = receiptItemDOList.stream().map(ReceiptItemDO::getWriteOffAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
Long currencyId = receiptDO.getCurrencyId();
if (null == currencyId) {
log.error("自动核销判断核销币种为空");
return Boolean.FALSE;
}
//计算出实际收款比例
BigDecimal sjbl = NumberUtil.div(totalAmount, receiptDO.getReceivableTotalAmount()).multiply(new BigDecimal("100"));
//实际收款比例大于规定阀值时,反回可以自己动核销
if (sjbl.compareTo(new BigDecimal(proportion)) >= 0) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void autoWriteOffReceipt(ReceiptDO receiptDO, String userId, String userName) {
ReceiptDO updateReceipt = new ReceiptDO();
// 添加订单ID的修改,不然订单ID就丢失了
updateReceipt.setOrderId(receiptDO.getOrderId());
updateReceipt.setId(receiptDO.getId());
//需要根据是否要开票变成已核销,还是已核销待开票
if (receiptDO.getOpenInvoice() == 0) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
}
if (receiptDO.getOpenInvoice() == 1) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue());
}
updateReceipt.setWriteOffAt(new Date());
updateReceipt.setWriteOffProportion(new BigDecimal("100"));//设置核销比例
updateReceipt.setRemark("自动核销,核销比例>=100%");
updateReceipt.setWriteOffId(Long.parseLong(userId));
updateReceipt.setWriteOffName(userName);
receiptMapper.updateById(updateReceipt);
//更新收该收款单下的应收为收款完成状态
LambdaUpdateWrapper<ReceivableDO> lambdaUpdateWrapper = new LambdaUpdateWrapper();
lambdaUpdateWrapper.eq(ReceivableDO::getReceiptId, receiptDO.getId());
lambdaUpdateWrapper.set(ReceivableDO::getState, 2);
receivableService.update(lambdaUpdateWrapper);
//添加订单核销日志
LambdaQueryWrapper<ReceivableDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReceivableDO::getReceiptId, receiptDO.getId());
List<ReceivableDO> orderList = receivableService.list(lambdaQueryWrapper);
List orderIds = orderList.stream().map(ReceivableDO::getOrderId).distinct().collect(Collectors.toList());
receivableService.orderReceivableWriteOffLogAdd(orderIds, receiptDO.getReceiptNo());
}
}
package cn.iocoder.yudao.module.wealth.controller.admin.job;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.enums.ReceiptStatusEnum;
import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* 收款单自动核销任务
*/
@Component
@TenantJob
@Slf4j
public class ReceiptAutoWriteOff implements JobHandler {
@Resource
ReceiptService receiptService;
@Resource
AdminUserApi adminUserApi;
@Override
public String execute(String param) throws Exception {
if (StrUtil.isBlank(param)) {
log.error("自动核销比例未配置,自动退出");
return "";
}
String[] paramArray = param.split(",");
if (paramArray.length != 2 || StrUtil.isBlank(paramArray[0]) || StrUtil.isBlank(paramArray[1])) {
log.error("自动核销比例JOB参数错误,自动退出");
return "";
}
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(Long.parseLong(paramArray[1]));
if (null == adminUserRespDTO) {
log.error("自动核销比例JOB参数错误,核销人配置错误,自动退出");
return "";
}
//查询所有收款单状态为待核销的
LambdaQueryWrapper<ReceiptDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.and(i -> i.eq(ReceiptDO::getState, ReceiptStatusEnum.WRITE_OFF_WAITING.getValue()).or().eq(ReceiptDO::getState, ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue()));
List<ReceiptDO> receiptDOList = receiptService.selectList(lambdaQueryWrapper);
for (ReceiptDO receiptDO : receiptDOList) {
try {
//判断当前收款单下的收款明细是不是全部是已核销并且核销比例要大于配置(params)
Boolean result = receiptService.judgingProportion(receiptDO, paramArray[0]);
if (result) {
receiptService.autoWriteOffReceipt(receiptDO, paramArray[1], adminUserRespDTO.getNickname());
}
} catch (Exception e) {
log.error("收款单{}自动核销出错原因:{}", receiptDO.getReceiptNo(), e.getMessage());
}
}
return "";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment