deb
This commit is contained in:
parent
e6d05506d8
commit
8447c5c0c0
|
|
@ -3,8 +3,10 @@ package com.syjiaer.clinic.server.controller.charge;
|
||||||
import com.syjiaer.clinic.server.common.api.output.OM2206A;
|
import com.syjiaer.clinic.server.common.api.output.OM2206A;
|
||||||
import com.syjiaer.clinic.server.common.api.output.OM2207A;
|
import com.syjiaer.clinic.server.common.api.output.OM2207A;
|
||||||
import com.syjiaer.clinic.server.common.util.DateUtil;
|
import com.syjiaer.clinic.server.common.util.DateUtil;
|
||||||
|
import com.syjiaer.clinic.server.common.vo.Page;
|
||||||
import com.syjiaer.clinic.server.common.vo.Result;
|
import com.syjiaer.clinic.server.common.vo.Result;
|
||||||
import com.syjiaer.clinic.server.controller.BaseController;
|
import com.syjiaer.clinic.server.controller.BaseController;
|
||||||
|
import com.syjiaer.clinic.server.entity.charge.ChargeLog;
|
||||||
import com.syjiaer.clinic.server.entity.charge.ChargeOrder;
|
import com.syjiaer.clinic.server.entity.charge.ChargeOrder;
|
||||||
import com.syjiaer.clinic.server.entity.charge.dto.ChargeQuery;
|
import com.syjiaer.clinic.server.entity.charge.dto.ChargeQuery;
|
||||||
import com.syjiaer.clinic.server.entity.charge.dto.ChargeSaveDto;
|
import com.syjiaer.clinic.server.entity.charge.dto.ChargeSaveDto;
|
||||||
|
|
@ -91,6 +93,7 @@ public class ChargeController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/getListByPatientId")
|
@RequestMapping("/getListByPatientId")
|
||||||
public Result<List<ChargeOrder>> getListByPatientId() {
|
public Result<List<ChargeOrder>> getListByPatientId() {
|
||||||
Integer patientId = parmsUtil.getInteger("patientId");
|
Integer patientId = parmsUtil.getInteger("patientId");
|
||||||
|
|
@ -98,4 +101,11 @@ public class ChargeController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/getChargeRecord")
|
||||||
|
public Result<Page<ChargeLog>> getChargeRecord() {
|
||||||
|
return success(chargeService.getChargeRecordPageList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.syjiaer.clinic.server.controller.BaseController;
|
||||||
import com.syjiaer.clinic.server.entity.goods.Goods;
|
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||||
import com.syjiaer.clinic.server.entity.statistics.PersonPayOverviewVo;
|
import com.syjiaer.clinic.server.entity.statistics.PersonPayOverviewVo;
|
||||||
import com.syjiaer.clinic.server.entity.statistics.RevenueOverviewVo;
|
import com.syjiaer.clinic.server.entity.statistics.RevenueOverviewVo;
|
||||||
|
import com.syjiaer.clinic.server.entity.statistics.SalePersonReportVo;
|
||||||
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
||||||
import com.syjiaer.clinic.server.service.inventory.InventoryService;
|
import com.syjiaer.clinic.server.service.inventory.InventoryService;
|
||||||
import com.syjiaer.clinic.server.service.statistics.StatisticsService;
|
import com.syjiaer.clinic.server.service.statistics.StatisticsService;
|
||||||
|
|
@ -49,6 +50,7 @@ public class StatisticsController extends BaseController {
|
||||||
public Result<List<Goods>> numberEarlyWarning() {
|
public Result<List<Goods>> numberEarlyWarning() {
|
||||||
QueryWrapper<Goods> goodsQuery = new QueryWrapper<>();
|
QueryWrapper<Goods> goodsQuery = new QueryWrapper<>();
|
||||||
goodsQuery.apply("inventory_whole_number <= inventory_warn_number");
|
goodsQuery.apply("inventory_whole_number <= inventory_warn_number");
|
||||||
|
goodsQuery.last("limit 20");
|
||||||
List<Goods> list = goodsService.list(goodsQuery);
|
List<Goods> list = goodsService.list(goodsQuery);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
@ -70,5 +72,12 @@ public class StatisticsController extends BaseController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/salePerson")
|
||||||
|
public Result<List<SalePersonReportVo>> salePerson() {
|
||||||
|
return success( statisticsService.salePersonReport());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,5 +75,5 @@ public class ChargeOrder implements Serializable {
|
||||||
private BigDecimal totalCost;
|
private BigDecimal totalCost;
|
||||||
|
|
||||||
@ApiModelProperty("销售人id")
|
@ApiModelProperty("销售人id")
|
||||||
private Integer salePersionId;
|
private Integer salePersonId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import java.math.BigDecimal;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class PayTypeRevenue {
|
public class PayTypeRevenue {
|
||||||
|
private Integer payType;
|
||||||
private BigDecimal totalRevenue;
|
private BigDecimal totalRevenue;
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,18 @@ import java.util.List;
|
||||||
public class RevenueOverviewVo {
|
public class RevenueOverviewVo {
|
||||||
//总营业额
|
//总营业额
|
||||||
private BigDecimal totalRevenue;
|
private BigDecimal totalRevenue;
|
||||||
//会员销售额
|
//医保销售额
|
||||||
private BigDecimal vipRevenue;
|
private BigDecimal socialRevenue;
|
||||||
//总完成单数
|
//总完成单数
|
||||||
private Long totalOrderCount;
|
private Long totalOrderCount;
|
||||||
//会员单数
|
//医保单数
|
||||||
private Long vipOrderCount;
|
private Long socialOrderCount;
|
||||||
|
|
||||||
private List<GoodsTypeRevenue> goodsTypeRevenue;
|
private List<GoodsTypeRevenue> goodsTypeRevenue;
|
||||||
|
|
||||||
private List<PayTypeRevenue> payTypeRevenue;
|
private List<PayTypeRevenue> payTypeRevenue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.syjiaer.clinic.server.entity.statistics;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SalePersonReportVo {
|
||||||
|
private Integer salePersonId;
|
||||||
|
private String salePersonName;
|
||||||
|
private BigDecimal totalIncome;
|
||||||
|
private BigDecimal wechatIncome;
|
||||||
|
private BigDecimal aliPayIncome;
|
||||||
|
private BigDecimal cashIncome;
|
||||||
|
private BigDecimal otherIncome;
|
||||||
|
private BigDecimal socialIncome;
|
||||||
|
private Long count;
|
||||||
|
|
||||||
|
public SalePersonReportVo() {
|
||||||
|
this.totalIncome = BigDecimal.ZERO;
|
||||||
|
this.wechatIncome = BigDecimal.ZERO;
|
||||||
|
this.aliPayIncome = BigDecimal.ZERO;
|
||||||
|
this.cashIncome = BigDecimal.ZERO;
|
||||||
|
this.otherIncome = BigDecimal.ZERO;
|
||||||
|
this.socialIncome = BigDecimal.ZERO;
|
||||||
|
this.count = 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,9 @@ import com.syjiaer.clinic.server.entity.charge.ChargeOrder;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -16,6 +19,7 @@ import org.apache.ibatis.annotations.Select;
|
||||||
public interface ChargeOrderMapper extends BaseMapper<ChargeOrder> {
|
public interface ChargeOrderMapper extends BaseMapper<ChargeOrder> {
|
||||||
@Select("select * from charge_order where code = #{code}")
|
@Select("select * from charge_order where code = #{code}")
|
||||||
ChargeOrder selectByCode(String code);
|
ChargeOrder selectByCode(String code);
|
||||||
|
@Select("SELECT sale_person_id,pay_type,\"sum\"(total_price) ,\"count\"(0) FROM \"public\".\"charge_order\" GROUP BY sale_person_id,pay_type")
|
||||||
|
List<Map<String, Object>> selectSaleReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public interface InventoryMapper extends BaseMapper<Inventory> {
|
||||||
@Select("SELECT" +
|
@Select("SELECT" +
|
||||||
" inventory.*,goods.expiry_warn_days,goods.unit_price,EXTRACT(EPOCH FROM AGE(expiry_date, CURRENT_DATE)) / 86400 AS remaining_days" +
|
" inventory.*,goods.expiry_warn_days,goods.unit_price,EXTRACT(EPOCH FROM AGE(expiry_date, CURRENT_DATE)) / 86400 AS remaining_days" +
|
||||||
" FROM inventory LEFT JOIN goods ON inventory.good_id = goods.id" +
|
" FROM inventory LEFT JOIN goods ON inventory.good_id = goods.id" +
|
||||||
" WHERE CURRENT_DATE + INTERVAL '1 day' * goods.expiry_warn_days >= inventory.expiry_date AND inventory.whole_number !=0")
|
" WHERE CURRENT_DATE + INTERVAL '1 day' * goods.expiry_warn_days >= inventory.expiry_date AND inventory.whole_number !=0 limit 20")
|
||||||
List<Map<String, Object>> selectExpiryWarn();
|
List<Map<String, Object>> selectExpiryWarn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,7 @@ import com.syjiaer.clinic.server.entity.patient.PatientRegistration;
|
||||||
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
import com.syjiaer.clinic.server.entity.social.SocialDirectory;
|
||||||
import com.syjiaer.clinic.server.entity.social.SocialItem;
|
import com.syjiaer.clinic.server.entity.social.SocialItem;
|
||||||
import com.syjiaer.clinic.server.entity.social.SocialUser;
|
import com.syjiaer.clinic.server.entity.social.SocialUser;
|
||||||
import com.syjiaer.clinic.server.mapper.charge.ChargeGoodsListMapper;
|
import com.syjiaer.clinic.server.mapper.charge.*;
|
||||||
import com.syjiaer.clinic.server.mapper.charge.ChargeItemListMapper;
|
|
||||||
import com.syjiaer.clinic.server.mapper.charge.ChargeLogMapper;
|
|
||||||
import com.syjiaer.clinic.server.mapper.charge.ChargeOrderMapper;
|
|
||||||
import com.syjiaer.clinic.server.mapper.diagnosis.DiagnosisMapper;
|
import com.syjiaer.clinic.server.mapper.diagnosis.DiagnosisMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.diagnosis.DiagnosisMedicalGoodsListMapper;
|
import com.syjiaer.clinic.server.mapper.diagnosis.DiagnosisMedicalGoodsListMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.diagnosis.DiagnosisMedicalItemListMapper;
|
import com.syjiaer.clinic.server.mapper.diagnosis.DiagnosisMedicalItemListMapper;
|
||||||
|
|
@ -77,6 +74,8 @@ public class ChargeService extends BaseService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ChargeLogMapper chargeLogMapper;
|
private ChargeLogMapper chargeLogMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private ChargeInventoryLogMapper chargeInventoryLogMapper;
|
||||||
|
@Autowired
|
||||||
private SocialUserMapper socialUserMapper;
|
private SocialUserMapper socialUserMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ChargeItemListMapper chargeItemListMapper;
|
private ChargeItemListMapper chargeItemListMapper;
|
||||||
|
|
@ -330,6 +329,8 @@ public class ChargeService extends BaseService {
|
||||||
updateOrder.setPayType(payType);
|
updateOrder.setPayType(payType);
|
||||||
updateOrder.setPayTime(LocalDateTime.now());
|
updateOrder.setPayTime(LocalDateTime.now());
|
||||||
chargeOrderMapper.updateById(updateOrder);
|
chargeOrderMapper.updateById(updateOrder);
|
||||||
|
|
||||||
|
order = chargeOrderMapper.selectById(id);
|
||||||
//扣除商品库存
|
//扣除商品库存
|
||||||
List<ChargeGoodsListVo> goodsLists = chargeGoodsListMapper.selectDetailByCode(order.getCode());
|
List<ChargeGoodsListVo> goodsLists = chargeGoodsListMapper.selectDetailByCode(order.getCode());
|
||||||
for (ChargeGoodsListVo goodsList : goodsLists) {
|
for (ChargeGoodsListVo goodsList : goodsLists) {
|
||||||
|
|
@ -347,10 +348,12 @@ public class ChargeService extends BaseService {
|
||||||
log.setSocialType(InventorySocialTypeEnum.INVENTORY_SURPLUS.getType());
|
log.setSocialType(InventorySocialTypeEnum.INVENTORY_SURPLUS.getType());
|
||||||
}
|
}
|
||||||
inventoryLogMapper.insert(logs);
|
inventoryLogMapper.insert(logs);
|
||||||
|
this.recordChargeInventoryLog(logs,order);
|
||||||
}
|
}
|
||||||
//记录收费日志
|
//记录收费日志
|
||||||
this.recordChargeLog(order, ChargeSourceEnum.CHARGE, ChargeTypeEnum.CHARGE);
|
this.recordChargeLog(order, ChargeSourceEnum.CHARGE, ChargeTypeEnum.CHARGE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadCostDetails(String changeOrderCode) {
|
public void uploadCostDetails(String changeOrderCode) {
|
||||||
|
|
@ -602,10 +605,10 @@ public class ChargeService extends BaseService {
|
||||||
chargeLog.setNetReceipts(chargeOrder.getTotalPrice());
|
chargeLog.setNetReceipts(chargeOrder.getTotalPrice());
|
||||||
chargeLog.setDiscount(chargeOrder.getTotalPrice().subtract(chargeOrder.getPreTotalPrice()));
|
chargeLog.setDiscount(chargeOrder.getTotalPrice().subtract(chargeOrder.getPreTotalPrice()));
|
||||||
chargeLog.setPayType(chargeOrder.getPayType());
|
chargeLog.setPayType(chargeOrder.getPayType());
|
||||||
if (chargeOrder.getSalePersionId() != null){
|
if (chargeOrder.getSalePersonId() != null){
|
||||||
OrganizationMember organizationMember = organizationMemberMapper.selectById(chargeOrder.getSalePersionId());
|
OrganizationMember organizationMember = organizationMemberMapper.selectById(chargeOrder.getSalePersonId());
|
||||||
chargeLog.setSalePersonName(organizationMember.getName());
|
chargeLog.setSalePersonName(organizationMember.getName());
|
||||||
chargeLog.setSalePersonId(chargeOrder.getSalePersionId());
|
chargeLog.setSalePersonId(chargeOrder.getSalePersonId());
|
||||||
}
|
}
|
||||||
chargeLog.setChargeTime(LocalDateTime.now());
|
chargeLog.setChargeTime(LocalDateTime.now());
|
||||||
chargeLog.setProjectCode(chargeOrder.getCode());
|
chargeLog.setProjectCode(chargeOrder.getCode());
|
||||||
|
|
@ -614,7 +617,9 @@ public class ChargeService extends BaseService {
|
||||||
/**
|
/**
|
||||||
* 销售库存变更 日志
|
* 销售库存变更 日志
|
||||||
*/
|
*/
|
||||||
public void recordChargeInventoryLog(InventoryLog log,ChargeOrder chargeOrder){
|
public void recordChargeInventoryLog(List<InventoryLog> logs,ChargeOrder chargeOrder){
|
||||||
|
List<ChargeInventoryLog> chargeInventoryLogs = new ArrayList<>();
|
||||||
|
for (InventoryLog log : logs){
|
||||||
ChargeInventoryLog chargeInventoryLog = new ChargeInventoryLog();
|
ChargeInventoryLog chargeInventoryLog = new ChargeInventoryLog();
|
||||||
chargeInventoryLog.setChargeOrderCode(chargeOrder.getCode());
|
chargeInventoryLog.setChargeOrderCode(chargeOrder.getCode());
|
||||||
chargeInventoryLog.setGoodsId(log.getGoodsId());
|
chargeInventoryLog.setGoodsId(log.getGoodsId());
|
||||||
|
|
@ -624,7 +629,7 @@ public class ChargeService extends BaseService {
|
||||||
chargeInventoryLog.setTrdnFlag(false);
|
chargeInventoryLog.setTrdnFlag(false);
|
||||||
chargeInventoryLog.setUnit(dbGoods.getPackagingUnit());
|
chargeInventoryLog.setUnit(dbGoods.getPackagingUnit());
|
||||||
chargeInventoryLog.setNumber(log.getChangeWholeNumber());
|
chargeInventoryLog.setNumber(log.getChangeWholeNumber());
|
||||||
if (log.getChangeFragmentNumber() > 0 ){
|
if (log.getChangeFragmentNumber() != 0 ){
|
||||||
chargeInventoryLog.setTrdnFlag(true);
|
chargeInventoryLog.setTrdnFlag(true);
|
||||||
chargeInventoryLog.setUnit(dbGoods.getMinPackagingUnit());
|
chargeInventoryLog.setUnit(dbGoods.getMinPackagingUnit());
|
||||||
chargeInventoryLog.setNumber(log.getChangeWholeNumber()*dbGoods.getMinPackagingNumber()+log.getChangeFragmentNumber());
|
chargeInventoryLog.setNumber(log.getChangeWholeNumber()*dbGoods.getMinPackagingNumber()+log.getChangeFragmentNumber());
|
||||||
|
|
@ -633,9 +638,26 @@ public class ChargeService extends BaseService {
|
||||||
listWrapper.eq("charge_order_code",chargeOrder.getCode());
|
listWrapper.eq("charge_order_code",chargeOrder.getCode());
|
||||||
listWrapper.eq("goods_id",log.getGoodsId());
|
listWrapper.eq("goods_id",log.getGoodsId());
|
||||||
ChargeGoodsList chargeGoodsList = chargeGoodsListMapper.selectOne(listWrapper);
|
ChargeGoodsList chargeGoodsList = chargeGoodsListMapper.selectOne(listWrapper);
|
||||||
// chargeInventoryLog.setUnitPrice(chargeGoodsList.getUnitPrice());
|
chargeInventoryLog.setFeedetlSn(chargeGoodsList.getFeedetlSn());
|
||||||
|
chargeInventoryLog.setCreateTime(LocalDateTime.now());
|
||||||
|
chargeInventoryLog.setGoodsType(chargeGoodsList.getType());
|
||||||
|
chargeInventoryLog.setUploadStatus(UploadStatusEnum.NoUpload.getStatus());
|
||||||
|
chargeInventoryLog.setType(ChargeTypeEnum.CHARGE.getChargeType());
|
||||||
|
|
||||||
|
chargeInventoryLogs.add(chargeInventoryLog);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
chargeInventoryLogMapper.insert(chargeInventoryLogs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收费记录
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Page<ChargeLog> getChargeRecordPageList() {
|
||||||
|
QueryWrapper<ChargeLog> queryWrapper = new QueryWrapper<>();
|
||||||
|
Page<ChargeLog> page = pageHelper(1, 20, queryWrapper, chargeLogMapper, "charge_time", false);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public class MedicalRecordService extends BaseService {
|
||||||
Diagnosis diagnosis = new Diagnosis();
|
Diagnosis diagnosis = new Diagnosis();
|
||||||
QueryWrapper<Diagnosis> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Diagnosis> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("registration_id", saveDto.getRegistrationId());
|
queryWrapper.eq("registration_id", saveDto.getRegistrationId());
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
Diagnosis dbDiagnosis = diagnosisMapper.selectOne(queryWrapper);
|
Diagnosis dbDiagnosis = diagnosisMapper.selectOne(queryWrapper);
|
||||||
if (dbDiagnosis!=null){
|
if (dbDiagnosis!=null){
|
||||||
diagnosis.setId(dbDiagnosis.getId());
|
diagnosis.setId(dbDiagnosis.getId());
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,11 @@ import com.syjiaer.clinic.server.common.util.DateUtil;
|
||||||
import com.syjiaer.clinic.server.entity.charge.ChargeGoodsList;
|
import com.syjiaer.clinic.server.entity.charge.ChargeGoodsList;
|
||||||
import com.syjiaer.clinic.server.entity.charge.ChargeItemList;
|
import com.syjiaer.clinic.server.entity.charge.ChargeItemList;
|
||||||
import com.syjiaer.clinic.server.entity.charge.ChargeOrder;
|
import com.syjiaer.clinic.server.entity.charge.ChargeOrder;
|
||||||
import com.syjiaer.clinic.server.entity.statistics.GoodsTypeRevenue;
|
import com.syjiaer.clinic.server.entity.organization.OrganizationMember;
|
||||||
import com.syjiaer.clinic.server.entity.statistics.PayTypeRevenue;
|
import com.syjiaer.clinic.server.entity.statistics.*;
|
||||||
import com.syjiaer.clinic.server.entity.statistics.PersonPayOverviewVo;
|
|
||||||
import com.syjiaer.clinic.server.entity.statistics.RevenueOverviewVo;
|
|
||||||
import com.syjiaer.clinic.server.mapper.charge.ChargeGoodsListMapper;
|
import com.syjiaer.clinic.server.mapper.charge.ChargeGoodsListMapper;
|
||||||
import com.syjiaer.clinic.server.mapper.charge.ChargeOrderMapper;
|
import com.syjiaer.clinic.server.mapper.charge.ChargeOrderMapper;
|
||||||
|
import com.syjiaer.clinic.server.mapper.organization.OrganizationMemberMapper;
|
||||||
import com.syjiaer.clinic.server.service.BaseService;
|
import com.syjiaer.clinic.server.service.BaseService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -29,6 +28,9 @@ public class StatisticsService extends BaseService {
|
||||||
private ChargeOrderMapper chargeOrderMapper;
|
private ChargeOrderMapper chargeOrderMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ChargeGoodsListMapper chargeGoodsListMapper;
|
private ChargeGoodsListMapper chargeGoodsListMapper;
|
||||||
|
@Autowired
|
||||||
|
private OrganizationMemberMapper organizationMemberMapper;
|
||||||
|
|
||||||
public RevenueOverviewVo getRevenueOverview(LocalDateTime begin, LocalDateTime end) {
|
public RevenueOverviewVo getRevenueOverview(LocalDateTime begin, LocalDateTime end) {
|
||||||
RevenueOverviewVo overviewVo = new RevenueOverviewVo();
|
RevenueOverviewVo overviewVo = new RevenueOverviewVo();
|
||||||
QueryWrapper<ChargeOrder> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChargeOrder> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
@ -39,11 +41,19 @@ public class StatisticsService extends BaseService {
|
||||||
Map<String, Object> map = chargeOrderMapper.selectMaps(queryWrapper).get(0);
|
Map<String, Object> map = chargeOrderMapper.selectMaps(queryWrapper).get(0);
|
||||||
overviewVo.setTotalRevenue((BigDecimal) map.getOrDefault("total_revenue", new BigDecimal(0)));
|
overviewVo.setTotalRevenue((BigDecimal) map.getOrDefault("total_revenue", new BigDecimal(0)));
|
||||||
overviewVo.setTotalOrderCount((Long) map.getOrDefault("total_order_count", new BigDecimal(0)));
|
overviewVo.setTotalOrderCount((Long) map.getOrDefault("total_order_count", new BigDecimal(0)));
|
||||||
//
|
|
||||||
// queryWrapper.isNotNull("vip_id");
|
//医保概况数据
|
||||||
// Map<String, Object> vipMap = retailOrderService.getMap(queryWrapper);
|
QueryWrapper<ChargeOrder> socialQuery = new QueryWrapper<>();
|
||||||
// overviewVo.setVipRevenue((BigDecimal) vipMap.getOrDefault("total_revenue",new BigDecimal(0)));
|
socialQuery.select("sum(total_price) as total_revenue,count(*) as total_order_count");
|
||||||
// overviewVo.setVipOrderCount((Long) vipMap.getOrDefault("total_order_count",new BigDecimal(0)));
|
socialQuery.ge("pay_time", begin);
|
||||||
|
socialQuery.le("pay_time", end);
|
||||||
|
socialQuery.eq("pay_type", RetailOrderPayTypeEnum.MEDICARE.getCode());
|
||||||
|
socialQuery.eq("status", RetailOrderStatusEnum.FINISHED.getCode());
|
||||||
|
Map<String, Object> socialMap = chargeOrderMapper.selectMaps(socialQuery).get(0);
|
||||||
|
overviewVo.setSocialRevenue((BigDecimal) socialMap.getOrDefault("total_revenue", new BigDecimal(0)));
|
||||||
|
overviewVo.setSocialOrderCount((Long) socialMap.getOrDefault("total_order_count", new BigDecimal(0)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QueryWrapper<ChargeOrder> payTypeQuery = new QueryWrapper<>();
|
QueryWrapper<ChargeOrder> payTypeQuery = new QueryWrapper<>();
|
||||||
payTypeQuery.ge("pay_time", begin);
|
payTypeQuery.ge("pay_time", begin);
|
||||||
|
|
@ -58,6 +68,7 @@ public class StatisticsService extends BaseService {
|
||||||
List<PayTypeRevenue> payTypeRevenueList = new ArrayList<>();
|
List<PayTypeRevenue> payTypeRevenueList = new ArrayList<>();
|
||||||
for (Map<String, Object> payTypeMap : payTypeMaps) {
|
for (Map<String, Object> payTypeMap : payTypeMaps) {
|
||||||
PayTypeRevenue revenue = new PayTypeRevenue();
|
PayTypeRevenue revenue = new PayTypeRevenue();
|
||||||
|
revenue.setPayType((Integer) payTypeMap.get("pay_type"));
|
||||||
revenue.setName(RetailOrderPayTypeEnum.getByCode((Integer) payTypeMap.get("pay_type")).getDesc());
|
revenue.setName(RetailOrderPayTypeEnum.getByCode((Integer) payTypeMap.get("pay_type")).getDesc());
|
||||||
revenue.setTotalRevenue((BigDecimal) payTypeMap.getOrDefault("total_revenue", new BigDecimal(0)));
|
revenue.setTotalRevenue((BigDecimal) payTypeMap.getOrDefault("total_revenue", new BigDecimal(0)));
|
||||||
payTypeRevenueList.add(revenue);
|
payTypeRevenueList.add(revenue);
|
||||||
|
|
@ -87,6 +98,7 @@ public class StatisticsService extends BaseService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return overviewVo;
|
return overviewVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,4 +142,44 @@ public class StatisticsService extends BaseService {
|
||||||
return personPayOverview;
|
return personPayOverview;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SalePersonReportVo> salePersonReport() {
|
||||||
|
List<Map<String, Object>> maps = chargeOrderMapper.selectSaleReport();
|
||||||
|
Map<Integer, SalePersonReportVo> voMaps = new HashMap<>();
|
||||||
|
for (Map<String, Object> map : maps) {
|
||||||
|
Integer salePersonId = (Integer) map.get("sale_person_id");
|
||||||
|
SalePersonReportVo vo = voMaps.getOrDefault(salePersonId, new SalePersonReportVo());
|
||||||
|
vo.setSalePersonId(salePersonId);
|
||||||
|
OrganizationMember organizationMember = organizationMemberMapper.selectById(salePersonId);
|
||||||
|
vo.setSalePersonName(organizationMember.getName());
|
||||||
|
vo.setTotalIncome(vo.getTotalIncome().add((BigDecimal) map.get("sum")));
|
||||||
|
vo.setCount(vo.getCount()+(Long) map.get("count"));
|
||||||
|
RetailOrderPayTypeEnum payType = RetailOrderPayTypeEnum.getByCode((Integer) map.get("pay_type"));
|
||||||
|
if (payType == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (payType) {
|
||||||
|
case WXPAY:
|
||||||
|
vo.setWechatIncome(vo.getWechatIncome().add((BigDecimal) map.get("sum")));
|
||||||
|
break;
|
||||||
|
case ALIPAY:
|
||||||
|
vo.setAliPayIncome(vo.getAliPayIncome().add((BigDecimal) map.get("sum")));
|
||||||
|
break;
|
||||||
|
case CASH:
|
||||||
|
vo.setCashIncome(vo.getCashIncome().add((BigDecimal) map.get("sum")));
|
||||||
|
break;
|
||||||
|
case OTHER:
|
||||||
|
vo.setOtherIncome(vo.getOtherIncome().add((BigDecimal) map.get("sum")));
|
||||||
|
break;
|
||||||
|
case MEDICARE:
|
||||||
|
vo.setSocialIncome(vo.getSocialIncome().add((BigDecimal) map.get("sum")));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
voMaps.put(salePersonId, vo);
|
||||||
|
}
|
||||||
|
List<SalePersonReportVo> result = voMaps.values().stream().toList();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue