mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
📖 CRM:code review 合同金额排行榜、回款金额排行榜
This commit is contained in:
parent
278f220cef
commit
52a68e1838
@ -3,7 +3,6 @@ GET {{baseUrl}}/bi/rank/contract-ranKing
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenentId}}
|
||||
|
||||
|
||||
### 回款金额排行榜
|
||||
GET {{baseUrl}}/bi/rank/receivables-ranKing
|
||||
Authorization: Bearer {{token}}
|
||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
// TODO @anhaohao:写了 swagger 注解,不写注释哈
|
||||
/**
|
||||
* @author anhaohao
|
||||
*/
|
||||
@ -50,4 +51,5 @@ public class BiRankingController {
|
||||
public CommonResult<List<BiReceivablesRanKingRespVO>> receivablesRanKing(BiRankReqVO biRankReqVO) {
|
||||
return success(biRankingService.receivablesRanKing(biRankReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
// TODO @anhaohao:VO 类有 swagger 注解,不写注释哈
|
||||
/**
|
||||
* 管理后台 - BI 排行榜 Response VO
|
||||
*
|
||||
@ -12,13 +13,14 @@ import lombok.Data;
|
||||
@Data
|
||||
public class BiContractRanKingRespVO {
|
||||
|
||||
// TODO @anhaohao:如果一定返回的字段,需要加 requiredMode = Schema.RequiredMode.REQUIRED, 哈
|
||||
@Schema(description = "金额", example = "1")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "姓名", example = "1")
|
||||
private String nickname;
|
||||
|
||||
|
||||
@Schema(description = "部门名称", example = "1")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// TODO @anhaohao:这个类的命名,还是保持和其它一致使用 ReqVO 结尾;例如说,CrmStatisticsCommonParamReqVO
|
||||
/**
|
||||
* @author anhaohao
|
||||
* bi参数
|
||||
@ -25,17 +26,19 @@ public class BiParams extends PageParam {
|
||||
@Schema(description = "用户IDs")
|
||||
private List<Long> userIds;
|
||||
|
||||
// TODO @anhaohao:这个字段,可以融合到 startTime、endTime 里去,交给前端计算哈;
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
|
||||
// TODO @anhaohao:还是使用 LocalDateTime
|
||||
@Schema(description = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
// TODO @anhaohao:这个字段,是不是直接只基于 deptId 和 userId 来判断即可哈?
|
||||
@Schema(description = "0 部门 1员工")
|
||||
private Integer isUser = 1;
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ public class BiRankReqVO {
|
||||
@Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long deptId;
|
||||
|
||||
// TODO @anhaohao:这个字段,参考 BiParams 的 type 建议
|
||||
@Schema(description = "分析类型(1.今天 2.昨天 3.本周 4.上周 5.本月 6.上月 7.本季度 8.上季度 9.本年 10 上年)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
// TODO @anhaohao:参考 BiContractRanKingRespVO 的建议
|
||||
/**
|
||||
* 管理后台 - BI 排行榜 Response VO
|
||||
*
|
||||
@ -20,4 +21,5 @@ public class BiReceivablesRanKingRespVO {
|
||||
|
||||
@Schema(description = "部门名称", example = "研发部")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
@ -3,5 +3,8 @@
|
||||
* 例如说:报表、图表、数据分析等等
|
||||
* <p>
|
||||
* 1. Controller URL:以 /bi/ 开头,避免和其它 Module 冲突
|
||||
*
|
||||
* TODO @anhaohao:mall 当时独立拆分一个 statistics 模块的原因,是因为 mall 拆分了多个模块,没有模块适合承接统计的能力,所以独立了。
|
||||
* TODO crm 因为没有拆分,所以可以直接放在 crm 模块下面;这样,我们可以在 controller/admin 和 service 下,新建一个 bi 包,专门放置统计的代码。
|
||||
*/
|
||||
package cn.iocoder.yudao.module.bi;
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author anhaohao
|
||||
*/
|
||||
public interface BiRankingService {
|
||||
public interface BiRankingService { // TODO @anhaohao:第一个方法,和类要有一个空行
|
||||
/**
|
||||
* 合同金额排行榜
|
||||
*
|
||||
|
@ -28,6 +28,7 @@ public class BiTimeUtil {
|
||||
// 解析时间
|
||||
BiTimeEntity biTimeEntity = analyzeTime(biParams);
|
||||
// 解析权限
|
||||
// TODO @anhaohao:涉及到数据的读取,不放在 Util 里,还是搞会到 Service 哈;
|
||||
biTimeEntity.setUserIds(analyzeAuth(biParams));
|
||||
return biTimeEntity;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO">
|
||||
SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName
|
||||
FROM crm_contract t
|
||||
<!-- TODO @anhaohao:system_users、system_dept 是不是没用到?尽量不连这 2 个表,微服务下会是独立仓库;如果显示需要,可以在 service 读取后拼接; -->
|
||||
LEFT JOIN system_users AS su ON su.id = t.owner_user_id
|
||||
LEFT JOIN system_dept AS dept ON dept.id = su.dept_id
|
||||
WHERE t.deleted = 0
|
||||
@ -17,10 +18,12 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<!-- TODO @anhaohao:在某个区间的时间,这么做有点浪费性能;一般做法是 beginTime 是开始时间(00:00:00),finalTime 是结束时间(23:59:59),这样实现的; -->
|
||||
AND DATE_FORMAT(t.order_date,'${sqlDateFormat}') between #{beginTime} and #{finalTime}
|
||||
GROUP BY t.owner_user_id
|
||||
ORDER BY price DESC
|
||||
</select>
|
||||
|
||||
<select id="receivablesRanKing"
|
||||
resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO">
|
||||
SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order;
|
||||
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSalesOrderItemDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -30,7 +29,7 @@ public class ErpSaleOrderSaveReqVO {
|
||||
private LocalDateTime orderTime;
|
||||
|
||||
@Schema(description = "销售员编号数组")
|
||||
private String salePersonIds;
|
||||
private List<Long> salePersonIds;
|
||||
|
||||
@Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "26094")
|
||||
@NotNull(message = "合计价格,单位:元不能为空")
|
||||
@ -69,6 +68,61 @@ public class ErpSaleOrderSaveReqVO {
|
||||
// private Integer status;
|
||||
|
||||
@Schema(description = "ERP 销售订单明细列表")
|
||||
private List<ErpSalesOrderItemDO> salesOrderItems;
|
||||
private List<Item> salesOrderItems;
|
||||
|
||||
@Schema(description = "管理后台 - ERP 销售订单明细新增/修改 Request VO")
|
||||
@Data
|
||||
public class Item {
|
||||
|
||||
@Schema(description = "编号", example = "20704")
|
||||
private Long id;
|
||||
|
||||
// TODO 芋艿:后面删除
|
||||
// @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30765")
|
||||
// @NotNull(message = "销售订单编号不能为空")
|
||||
// private Long orderId;
|
||||
|
||||
// @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5574")
|
||||
// @NotNull(message = "商品 SPU 编号不能为空")
|
||||
// private Long productSpuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21273")
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long productSkuId;
|
||||
|
||||
@Schema(description = "商品单位", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "商品单位不能为空")
|
||||
private String productUnit;
|
||||
|
||||
@Schema(description = "商品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "6897")
|
||||
@NotNull(message = "商品单价不能为空")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "22100")
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Integer count;
|
||||
|
||||
// TODO 芋艿:后面删除
|
||||
// @Schema(description = "总价", requiredMode = Schema.RequiredMode.REQUIRED, example = "26868")
|
||||
// @NotNull(message = "总价不能为空")
|
||||
// private BigDecimal totalPrice;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "税率,百分比", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "税率,百分比不能为空")
|
||||
private BigDecimal taxPercent;
|
||||
|
||||
@Schema(description = "税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "15791")
|
||||
@NotNull(message = "税额,单位:元不能为空")
|
||||
private BigDecimal taxPrice;
|
||||
|
||||
// TODO 芋艿:后面删除
|
||||
// @Schema(description = "支付金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "21930")
|
||||
// @NotNull(message = "支付金额,单位:元不能为空")
|
||||
// private BigDecimal payPrice;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -40,11 +40,16 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
|
||||
saleOrderMapper.insert(saleOrder);
|
||||
|
||||
// 插入子表
|
||||
createSalesOrderItemsList(saleOrder.getId(), createReqVO.getSalesOrderItems());
|
||||
// createSalesOrderItemsList(saleOrder.getId(), createReqVO.getSalesOrderItems());
|
||||
// 返回
|
||||
return saleOrder.getId();
|
||||
}
|
||||
|
||||
private void createSalesOrderItemsList(Long id, List<ErpSalesOrderItemDO> list) {
|
||||
list.forEach(o -> o.setId(id));
|
||||
salesOrderItemMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSaleOrder(ErpSaleOrderSaveReqVO updateReqVO) {
|
||||
@ -55,7 +60,13 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
|
||||
saleOrderMapper.updateById(updateObj);
|
||||
|
||||
// 更新子表
|
||||
updateSalesOrderItemsList(updateReqVO.getId(), updateReqVO.getSalesOrderItems());
|
||||
// updateSalesOrderItemsList(updateReqVO.getId(), updateReqVO.getSalesOrderItems());
|
||||
}
|
||||
|
||||
private void updateSalesOrderItemsList(Long id, List<ErpSalesOrderItemDO> list) {
|
||||
deleteSalesOrderItemsById(id);
|
||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||
createSalesOrderItemsList(id, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,17 +99,6 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
|
||||
|
||||
// ==================== 子表(ERP 销售订单明细) ====================
|
||||
|
||||
private void createSalesOrderItemsList(Long id, List<ErpSalesOrderItemDO> list) {
|
||||
list.forEach(o -> o.setId(id));
|
||||
salesOrderItemMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
private void updateSalesOrderItemsList(Long id, List<ErpSalesOrderItemDO> list) {
|
||||
deleteSalesOrderItemsById(id);
|
||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||
createSalesOrderItemsList(id, list);
|
||||
}
|
||||
|
||||
private void deleteSalesOrderItemsById(Long id) {
|
||||
salesOrderItemMapper.deleteById(id);
|
||||
}
|
||||
|
@ -46,5 +46,4 @@ public class DeptApiImpl implements DeptApi {
|
||||
return BeanUtils.toBean(childDeptList, DeptRespDTO.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user