From e2e3a5df786738c2c9620d921aa0f209a9eff21a Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Sat, 05 Mar 2022 23:27:22 +0800 Subject: [PATCH] fead:新增单据操作记录 --- zq-erp/src/main/java/com/matrix/system/common/service/OperationLogService.java | 22 ++ zq-erp/src/main/java/com/matrix/system/enums/OperationButtonEnum.java | 67 ++++++ zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java | 2 zq-erp/src/main/java/com/matrix/system/hive/action/OrderController.java | 36 ++ zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java | 81 +++++++ zq-erp/src/main/java/com/matrix/system/common/dao/OperationLogDao.java | 15 + zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java | 50 ++-- zq-erp/src/main/java/com/matrix/system/common/service/impl/OperationLogServiceImpl.java | 67 ++++++ zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java | 12 zq-erp/src/main/java/com/matrix/system/enums/OperationFunctionEnum.java | 53 +++++ zq-erp/src/main/java/com/matrix/system/common/bean/OperationLog.java | 81 ++++++++ zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 76 ++++++ 12 files changed, 511 insertions(+), 51 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java index 67a8262..10237fb 100644 --- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java +++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiOrderAction.java @@ -15,7 +15,9 @@ import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.tools.DataAuthUtil; import com.matrix.system.hive.action.util.QueryUtil; -import com.matrix.system.hive.bean.*; +import com.matrix.system.hive.bean.ShoppingGoodsCategory; +import com.matrix.system.hive.bean.SysOrder; +import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.dao.SysShopInfoDao; import com.matrix.system.hive.plugin.util.CollectionUtils; import com.matrix.system.hive.pojo.ShoppingCarItem; @@ -32,7 +34,6 @@ import org.springframework.web.bind.annotation.*; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -174,13 +175,10 @@ if (order == null) { throw new GlobleException("订单不存在"); } + sysOrderService.cancelOrder(orderId); + return AjaxResult.buildSuccessInstance("取消成功"); - int i = sysOrderService.cancelOrder(orderId); - if (i > 0) { - return AjaxResult.buildSuccessInstance("取消成功"); - } - return AjaxResult.buildFailInstance("取消失败"); } } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/common/bean/OperationLog.java b/zq-erp/src/main/java/com/matrix/system/common/bean/OperationLog.java new file mode 100644 index 0000000..cf29c4d --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/common/bean/OperationLog.java @@ -0,0 +1,81 @@ +package com.matrix.system.common.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; +import lombok.Data; + +/** + * 单据操作日志 + */ +@Data +@TableName("sys_operation_log") +@Builder +public class OperationLog { + + + /** + * 主键 + */ + @TableId(value = "id",type = IdType.AUTO) + private Long id; + + /** + *公司id + */ + private Long companyId; + + /** + *门店id + */ + private Long shopId; + + /** + *操作用户id + */ + private Long opeUserId; + + /** + * 会员id + */ + private Long vipId; + + /** + * 操作功能 + */ + private Integer opeFunction; + + /** + * 单据按钮 + */ + private Integer opeBut; + + /** + * 单据id + */ + private Long billId; + + /** + * 单据号 + */ + private String billNo; + + /** + * 操作人ip + */ + private String ip; + + /** + * 操作备注 + */ + private String note; + + /** + * 操作时间 + */ + private String createTime; + + + +} diff --git a/zq-erp/src/main/java/com/matrix/system/common/dao/OperationLogDao.java b/zq-erp/src/main/java/com/matrix/system/common/dao/OperationLogDao.java new file mode 100644 index 0000000..c02981a --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/common/dao/OperationLogDao.java @@ -0,0 +1,15 @@ +package com.matrix.system.common.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.matrix.system.common.bean.OperationLog; + +/** + * @description 单据操作记录 + * @author jyy + * @date 2021-03-10 15:22 + */ +public interface OperationLogDao extends BaseMapper<OperationLog> { + + + +} \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/common/service/OperationLogService.java b/zq-erp/src/main/java/com/matrix/system/common/service/OperationLogService.java new file mode 100644 index 0000000..1b84f3e --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/common/service/OperationLogService.java @@ -0,0 +1,22 @@ +package com.matrix.system.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.matrix.system.common.bean.OperationLog; +import com.matrix.system.enums.OperationButtonEnum; +import com.matrix.system.enums.OperationFunctionEnum; + +/** + * 单据操作日志 + */ +public interface OperationLogService extends IService<OperationLog> { + + + + void saveOperation(Long companyId, Long shopId, Long userId, OperationFunctionEnum operationFunctionEnum, OperationButtonEnum operationButtonEnum, + Long billId, String billNo, Long vipId,String note); + + void saveOperation(Long companyId, Long shopId, Long userId, OperationFunctionEnum operationFunctionEnum, OperationButtonEnum operationButtonEnum, + Long billId, String billNo, Long vipId); + + void saveOperation(Long companyId, Long shopId, Long suId, OperationFunctionEnum operationFunctionEnum, OperationButtonEnum operationButtonEnum,String note); +} diff --git a/zq-erp/src/main/java/com/matrix/system/common/service/impl/OperationLogServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/common/service/impl/OperationLogServiceImpl.java new file mode 100644 index 0000000..198aff8 --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/common/service/impl/OperationLogServiceImpl.java @@ -0,0 +1,67 @@ +package com.matrix.system.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.matrix.core.tools.WebUtil; +import com.matrix.system.common.bean.OperationLog; +import com.matrix.system.common.dao.OperationLogDao; +import com.matrix.system.common.service.OperationLogService; +import com.matrix.system.enums.OperationButtonEnum; +import com.matrix.system.enums.OperationFunctionEnum; +import org.springframework.stereotype.Service; + +/** + * 单据操作日志 + */ +@Service +public class OperationLogServiceImpl extends ServiceImpl<OperationLogDao, OperationLog> implements OperationLogService { + + @Override + public void saveOperation(Long companyId, Long shopId, Long userId, OperationFunctionEnum operationFunctionEnum, OperationButtonEnum operationButtonEnum, + Long billId, String billNo, Long vipId, String note) { + save(OperationLog.builder() + .companyId(companyId) + .shopId(shopId) + .opeUserId(userId) + .opeFunction(operationFunctionEnum.getValue()) + .opeBut(operationButtonEnum.getValue()) + .billId(billId) + .billNo(billNo) + .vipId(vipId) + .note(note) + .ip(WebUtil.getCustomerIp()).build()); + + } + + + @Override + public void saveOperation(Long companyId, Long shopId, Long userId, OperationFunctionEnum operationFunctionEnum, OperationButtonEnum operationButtonEnum, + Long billId, String billNo, Long vipId) { + save(OperationLog.builder() + .companyId(companyId) + .shopId(shopId) + .opeUserId(userId) + .opeFunction(operationFunctionEnum.getValue()) + .opeBut(operationButtonEnum.getValue()) + .billId(billId) + .billNo(billNo) + .vipId(vipId) + .ip(WebUtil.getCustomerIp()).build()); + + } + + @Override + public void saveOperation(Long companyId, Long shopId, Long userId, OperationFunctionEnum operationFunctionEnum, OperationButtonEnum operationButtonEnum + , String note) { + save(OperationLog.builder() + .companyId(companyId) + .shopId(shopId) + .opeUserId(userId) + .opeFunction(operationFunctionEnum.getValue()) + .opeBut(operationButtonEnum.getValue()) + .note(note) + .ip(WebUtil.getCustomerIp()).build()); + + } + + +} diff --git a/zq-erp/src/main/java/com/matrix/system/enums/OperationButtonEnum.java b/zq-erp/src/main/java/com/matrix/system/enums/OperationButtonEnum.java new file mode 100644 index 0000000..f3a338e --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/enums/OperationButtonEnum.java @@ -0,0 +1,67 @@ +package com.matrix.system.enums; + +import com.google.common.collect.Lists; +import com.matrix.core.enums.EnumApiShowAble; +import com.matrix.core.enums.EnumsShowVo; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 操作按钮枚举 + * @author jyy + */ +public enum OperationButtonEnum implements EnumApiShowAble { + + CREATE(1, "新增"), + UPDATE(2, "修改"), + DELETE(3, "删除"), + CANCEL(4, "取消"), + INVALID(5, "设置为无效"), + EFFECTIVE(6, "设置为有效"), + ORDER_SK(7, "订单收款"), + ORDER_TK(8, "订单退款"), + ORDER_UPDATE_TIME(9, "更新订单时间"), + EXPORT(10, "导出"), + SERVICE_ORDER_BEGIN(11, "开始服务单"), + SERVICE_ORDER_END(12, "完成服务单"), + SERVICE_ORDER_PL(13, "服务单配料"), + SERVICE_ORDER_HK(14, "划扣"), + SERVICE_ORDER_PB(15, "排班"), + SERVICE_ORDER_QRYY(16, "确认预约"), + + ; + + private Integer value; + + private String displayName; + + OperationButtonEnum(Integer value, String displayName) { + this.value = value; + this.displayName = displayName; + } + + @Override + public String getEnumCode() { + return "operationButton"; + } + + @Override + public List<EnumsShowVo> getEnumsShowVos() { + return Lists.newArrayList(values()).stream().map(item -> + EnumsShowVo.builder() + .displayName(item.getDisplayName()) + .value(item.value) + .build() + ).collect(Collectors.toList()); + } + + public Integer getValue() { + return value; + } + + public String getDisplayName() { + return displayName; + } + +} diff --git a/zq-erp/src/main/java/com/matrix/system/enums/OperationFunctionEnum.java b/zq-erp/src/main/java/com/matrix/system/enums/OperationFunctionEnum.java new file mode 100644 index 0000000..fdd2483 --- /dev/null +++ b/zq-erp/src/main/java/com/matrix/system/enums/OperationFunctionEnum.java @@ -0,0 +1,53 @@ +package com.matrix.system.enums; + +import com.google.common.collect.Lists; +import com.matrix.core.enums.EnumApiShowAble; +import com.matrix.core.enums.EnumsShowVo; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 操作功能枚举 + * @author jyy + */ +public enum OperationFunctionEnum implements EnumApiShowAble { + + ORDER(1, "订单"), + SERVICE_ORDER(2, "服务单"), + VIP_PROJECT(3, "会员套餐卡项"), + VIP_CARD(4, "会员卡"); + + private Integer value; + + private String displayName; + + OperationFunctionEnum(Integer value, String displayName) { + this.value = value; + this.displayName = displayName; + } + + @Override + public String getEnumCode() { + return "operationFunction"; + } + + @Override + public List<EnumsShowVo> getEnumsShowVos() { + return Lists.newArrayList(values()).stream().map(item -> + EnumsShowVo.builder() + .displayName(item.getDisplayName()) + .value(item.value) + .build() + ).collect(Collectors.toList()); + } + + public Integer getValue() { + return value; + } + + public String getDisplayName() { + return displayName; + } + +} diff --git a/zq-erp/src/main/java/com/matrix/system/hive/action/OrderController.java b/zq-erp/src/main/java/com/matrix/system/hive/action/OrderController.java index 9113db7..c31ba85 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/action/OrderController.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/action/OrderController.java @@ -1,9 +1,8 @@ package com.matrix.system.hive.action; import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; import com.matrix.component.asyncmessage.AsyncMessageManager; -import com.matrix.component.rabbitmq.RabiitMqTemplate; -import com.matrix.core.constance.MatrixConstance; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; @@ -18,9 +17,12 @@ import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysCompanyDao; +import com.matrix.system.common.service.OperationLogService; import com.matrix.system.common.tools.DataAuthUtil; import com.matrix.system.common.tools.ResponseHeadUtil; import com.matrix.system.constance.Dictionary; +import com.matrix.system.enums.OperationButtonEnum; +import com.matrix.system.enums.OperationFunctionEnum; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; import com.matrix.system.hive.plugin.util.CollectionUtils; @@ -28,7 +30,6 @@ import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; import com.matrix.system.wechart.templateMsg.UniformMsgParam; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.ModelMap; @@ -106,8 +107,10 @@ @Autowired private AsyncMessageManager asyncMessageManager; - @Value("${evn}") - private String evn; + + @Autowired + private OperationLogService operationLogService; + /** * 计算订单金额 @@ -233,7 +236,7 @@ SysCompanyDao companyDao; /** - * 收款 + * 打印订单 */ @RequestMapping(value = "/printOrder") public @ResponseBody @@ -266,6 +269,7 @@ */ @RequestMapping(value = "/updateOrderTime") public @ResponseBody + @Transactional(rollbackFor = Exception.class) AjaxResult updateOrderTime(SysOrder sysOrder) { sysOrderDao.updateOrderTime(sysOrder.getPayTime(), sysOrder.getId()); @@ -278,6 +282,15 @@ //更新收款流水时间 sysOrderFlowDao.updateTimeByOrderId(sysOrder.getId(), sysOrder.getPayTime()); + //保存单据日志 + sysOrder= sysOrderDao.selectById(sysOrder.getId()); + operationLogService.saveOperation(sysOrder.getCompanyId(), sysOrder.getShopId(),getMe().getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.ORDER_UPDATE_TIME, + sysOrder.getId(), + sysOrder.getOrderNo(), + sysOrder.getVipId(), + "更新参数: "+JSON.toJSONString(sysOrder)); return new AjaxResult(AjaxResult.STATUS_SUCCESS, "修改成功"); } @@ -505,8 +518,7 @@ @RequestMapping(value = "/exportExcel") public void report(ModelMap model, HttpServletRequest request, HttpServletResponse response, SysOrder sysOrder) throws Exception { - SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); - sysOrder.setShopId(sysUsers.getShopId()); + sysOrder.setShopId(getMe().getShopId()); doExportOrder(response, sysOrder); return; @@ -519,6 +531,7 @@ public void erpExportExcel(ModelMap model, HttpServletRequest request, HttpServletResponse response, SysOrder sysOrder) throws Exception { doExportOrder(response, sysOrder); + return; } @@ -532,6 +545,13 @@ * @throws IOException */ private void doExportOrder(HttpServletResponse response, SysOrder sysOrder) throws IOException { + + //保存单据日志 + operationLogService.saveOperation(getMe().getCompanyId(), getMe().getShopId(),getMe().getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.EXPORT, + String.format("导出参数:%s" , JSON.toJSONString(sysOrder))); + List<ExcelSheetPO> res = new ArrayList<>(); ExcelSheetPO orderSheet = new ExcelSheetPO(); String title = "订单记录"; diff --git a/zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java b/zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java index f8b24a4..968cd07 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java @@ -3,6 +3,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.matrix.core.anotations.RemoveRequestToken; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.exception.GlobleException; @@ -15,16 +16,18 @@ import com.matrix.core.tools.excl.ExcelSheetPO; import com.matrix.core.tools.excl.ExcelUtil; import com.matrix.core.tools.excl.ExcelVersion; -import com.matrix.system.app.dto.IdSubmitDto; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysCompanyDao; +import com.matrix.system.common.service.OperationLogService; import com.matrix.system.common.service.SysUsersService; import com.matrix.system.common.tools.DataAuthUtil; import com.matrix.system.common.tools.ResponseHeadUtil; import com.matrix.system.constance.Dictionary; +import com.matrix.system.enums.OperationButtonEnum; +import com.matrix.system.enums.OperationFunctionEnum; import com.matrix.system.hive.action.util.QueryUtil; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; @@ -35,8 +38,8 @@ import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -108,6 +111,10 @@ @Autowired SysShopInfoDao shopInfoDao; + + @Autowired + private OperationLogService operationLogService; + /** * 根据id查询服务单信息 @@ -464,6 +471,7 @@ */ @RequestMapping(value = "/updateOrderTime") public @ResponseBody + @Transactional(rollbackFor = Exception.class) AjaxResult updateOrderTime(@RequestBody ServiceOrderTimeDto serviceOrderTimeDto) { sysProjServicesDao.updateOrderTime(serviceOrderTimeDto); // 更新业绩时间 @@ -471,6 +479,15 @@ achieveNew.setServiceOrderId(serviceOrderTimeDto.getId()); achieveNew.setDatatime(serviceOrderTimeDto.getConsumeTime()); achieveNewService.modifyAchieveTime(achieveNew); + SysProjServices projServices = sysProjServicesDao.selectById(serviceOrderTimeDto.getId()); + //保存单据日志 + operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),getMe().getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.ORDER_UPDATE_TIME, + projServices.getId(), + projServices.getServiceNo(), + projServices.getVipId(), + "更新参数: "+JSON.toJSONString(serviceOrderTimeDto)); return new AjaxResult(AjaxResult.STATUS_SUCCESS, "修改成功"); } @@ -515,20 +532,7 @@ return mv; } - /** - * 根据id对服务单进行派单 - */ - @RequestMapping(value = "/paidan") - public @ResponseBody - AjaxResult paidan(Long id) { - SysProjServices services = sysProjServicesService.findById(id); - int i = sysProjServicesService.modifyPDProjServices(services); - if (i > 0) { - return new AjaxResult(AjaxResult.STATUS_SUCCESS, "派单成功"); - } else { - return new AjaxResult(AjaxResult.STATUS_FAIL, "派单失败"); - } - } + @Autowired BusParameterSettingsDao busParameterSettingsDao; @@ -660,12 +664,6 @@ } - @RequestMapping(value = "/addServiceProj") - @ResponseBody - public AjaxResult addServiceProj(SysProjServices sysProjServices) { - - return AjaxResult.buildSuccessInstance("保存成功"); - } /** * 删除服务单项目/套餐 @@ -725,6 +723,14 @@ private void doExportServiceOrder(HttpServletResponse response, SysProjServices projServices) throws IOException { + + //保存单据日志 + operationLogService.saveOperation(getMe().getCompanyId(), getMe().getShopId(),getMe().getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.EXPORT, + String.format("导出参数:%s" , JSON.toJSONString(projServices))); + + List<ExcelSheetPO> res = new ArrayList<>(); ExcelSheetPO orderSheet = new ExcelSheetPO(); String title = "服务订单明细"; diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java b/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java index 2be2912..5f21562 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/SysOrderService.java @@ -39,7 +39,7 @@ */ public int remove(List<Long> list); - public int cancelOrder(Long id); + public void cancelOrder(Long id); /** * 根据id删除SysOrder * diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java index e42eaaf..6b98538 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java @@ -20,7 +20,10 @@ import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysUsersDao; +import com.matrix.system.common.service.OperationLogService; import com.matrix.system.constance.Dictionary; +import com.matrix.system.enums.OperationButtonEnum; +import com.matrix.system.enums.OperationFunctionEnum; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; import com.matrix.system.hive.plugin.util.CollectionUtils; @@ -126,6 +129,9 @@ @Autowired private AsyncMessageManager asyncMessageManager; + @Autowired + private OperationLogService operationLogService; + @Override public int add(SysOrder sysOrder) { @@ -184,6 +190,7 @@ @Override + @Transactional(rollbackFor = Exception.class) public SysOrder checkAndSaveOrder(SysOrder sysOrder) { // 计算订单折扣金额,收款情况下 计算订单总额 @@ -233,12 +240,27 @@ //新增订单 sysOrder.setOrderNo(codeService.getOrderCode()); sysOrderDao.insert(sysOrder); + //保存单据日志 + operationLogService.saveOperation(sysOrder.getCompanyId(), sysOrder.getShopId(), user.getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.CREATE, + sysOrder.getId(), + sysOrder.getOrderNo(), + sysOrder.getVipId()); } else { //更新订单 sysOrderDao.update(sysOrder); //删除原有订单明细 orderItemDao.deleteByOrderId(sysOrder.getId()); + //保存单据日志 + operationLogService.saveOperation(sysOrder.getCompanyId(), sysOrder.getShopId(), user.getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.UPDATE, + sysOrder.getId(), + sysOrder.getOrderNo(), + sysOrder.getVipId(), + "修改订单内容"); } sysOrder.getItems().forEach(sysOrderItem -> { @@ -266,9 +288,10 @@ */ @Override @Transactional(rollbackFor = Exception.class) - public int cancelOrder(Long id) { + public void cancelOrder(Long id) { SysOrder order = sysOrderDao.selectById(id); + SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); if (order.getStatu().equals(Dictionary.ORDER_STATU_DFK)) { order.setStatu(Dictionary.ORDER_STATU_YQX); @@ -277,10 +300,17 @@ //发送微信公众号提醒 UniformMsgParam uniformMsgParam = new UniformMsgParam(order.getCompanyId(), UniformMsgParam.GZH_DDQX); uniformMsgParam.put("orderId", order.getId()); - asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); + asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG, uniformMsgParam); - return sysOrderDao.update(order); - + sysOrderDao.update(order); + //保存单据日志 + operationLogService.saveOperation(order.getCompanyId(), order.getShopId(),sysUsers.getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.CANCEL, + order.getId(), + order.getOrderNo(), + order.getVipId(), + "未付款取消订单"); } else { //一个订单只能被取消一次 @@ -377,8 +407,18 @@ // 取消订单 order.setStatu(Dictionary.ORDER_STATU_YQX); - return sysOrderDao.update(order); + sysOrderDao.update(order); + //保存单据日志 + operationLogService.saveOperation(order.getCompanyId(), order.getShopId(),sysUsers.getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.CANCEL, + order.getId(), + order.getOrderNo(), + order.getVipId(), + "已付款取消订单"); } + + } @@ -512,10 +552,12 @@ //设置会员积分 addVipScore(pageOrder); + } /** * 付款后更新订单信息 + * * @param pageOrder */ private void updateOrderInfo(SysOrder pageOrder) { @@ -542,12 +584,20 @@ double sum = flows.stream().mapToDouble(item -> item.getAmount().doubleValue()).sum(); - if(sum>0 && cardPayAmount.doubleValue()==0 && cashPayAmount.doubleValue()==0 ){ + if (sum > 0 && cardPayAmount.doubleValue() == 0 && cashPayAmount.doubleValue() == 0) { throw new GlobleException("订单更新失败,支付金额计算错误,请联系管理员"); } sysOrderDao.update(pageOrder); + + //保存单据日志 + operationLogService.saveOperation(pageOrder.getCompanyId(), pageOrder.getShopId(), user.getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.ORDER_SK, + pageOrder.getId(), + pageOrder.getOrderNo(), + pageOrder.getVipId()); } private void checkOrder(SysOrder pageOrder) { @@ -579,7 +629,7 @@ entries.forEach(entrie -> { double sum = entrie.getValue().stream().mapToDouble(AchieveNew::getGoodsCash).sum(); //todo 目前使用js计算金额可能存在精度的误差展示用0.1屏蔽 - if (Math.abs(sum- (item.getZkPrice()*item.getCount()) )>0.1) { + if (Math.abs(sum - (item.getZkPrice() * item.getCount())) > 0.1) { ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId()); throw GlobleException.instance(shopGoods.getName() + "," + entrie.getKey() + "业绩金额与收款金额不一致"); } @@ -1414,9 +1464,9 @@ boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE); if (zsConsumeAchieve) { //赠送情况下,如果收款金额大于0,就是赠送金额划扣的情况,金额即为划扣的折扣金额 - if(sysOrderItem.getZkPrice()>0){ + if (sysOrderItem.getZkPrice() > 0) { puse.setPrice(sysOrderItem.getZkPrice()); - }else{ + } else { puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice()); } } else { @@ -1640,6 +1690,14 @@ // 设置业绩 achieveNewService.addAchaeveByOrder(sysOrder); + //保存单据日志 + operationLogService.saveOperation(sysOrder.getCompanyId(), sysOrder.getShopId(), user.getSuId(), + OperationFunctionEnum.ORDER, + OperationButtonEnum.ORDER_TK, + sysOrder.getId(), + sysOrder.getOrderNo(), + sysOrder.getVipId()); + } private void addRefundOrderFlow(SysOrder sourceOrder) { diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java index 28a71f0..e370684 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java @@ -19,7 +19,10 @@ import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.common.service.BusParameterSettingService; +import com.matrix.system.common.service.OperationLogService; import com.matrix.system.constance.Dictionary; +import com.matrix.system.enums.OperationButtonEnum; +import com.matrix.system.enums.OperationFunctionEnum; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; import com.matrix.system.hive.plugin.util.MoneyUtil; @@ -61,7 +64,8 @@ @Autowired private SysProjUseDao sysProjUseDao; - + @Autowired + private OperationLogService operationLogService; @Autowired private SysOutStoreDao sysOutStoreDao; @@ -141,10 +145,10 @@ @Transactional(rollbackFor = Exception.class) @Override public SysProjServices addSysProjServices(SysProjServices sysProjServices) throws GlobleException { - + SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); //创建服务单 if (WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY) != null) { - SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); + sysProjServices.setCreateStaffId(user.getSuId()); sysProjServices.setShopId(user.getShopId()); sysProjServices.setCompanyId(user.getCompanyId()); @@ -249,6 +253,15 @@ sysProjServices.setTotalTime(totalTime); sysProjServices.setMoney(new BigDecimal(hkPrice).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue()); sysProjServicesDao.update(sysProjServices); + + //保存单据日志 + operationLogService.saveOperation(sysProjServices.getCompanyId(), sysProjServices.getShopId(),user.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.CREATE, + sysProjServices.getId(), + sysProjServices.getServiceNo(), + sysProjServices.getVipId()); + return sysProjServices; } @@ -464,6 +477,14 @@ autoBatching(projServices); } + SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + //保存单据日志 + operationLogService.saveOperation(checkProjServices.getCompanyId(), checkProjServices.getShopId(),users.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.SERVICE_ORDER_PB, + checkProjServices.getId(), + checkProjServices.getServiceNo(), + checkProjServices.getVipId()); return i; } @@ -567,6 +588,16 @@ } //删除积分 scoreVipDetailService.removeByBusinessId(checkProjServices.getVipId(), checkProjServices.getId()); + + SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + //保存单据日志 + operationLogService.saveOperation(checkProjServices.getCompanyId(), checkProjServices.getShopId(),users.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.CANCEL, + checkProjServices.getId(), + checkProjServices.getServiceNo(), + checkProjServices.getVipId()); + //更新服务单状态 return sysProjServicesDao.update(checkProjServices); @@ -722,6 +753,14 @@ asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG, uniformMsgParam); //发送划扣短信提醒 taiYanAliyunSmsService.sendHkNotice(projServices); + + //保存单据日志 + operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.SERVICE_ORDER_HK, + projServices.getId(), + projServices.getServiceNo(), + projServices.getVipId()); return result; } @@ -964,6 +1003,15 @@ // // 判断是服务超时还是服务提前结束,如果minspace大于0则是超时服务,小于0则是提前结束服务 // projServices.setIsOverTime(minspace + ""); // projServices.setState(Dictionary.SERVICE_STATU_FWWC); + //保存单据日志 + operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),sysUsers.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.SERVICE_ORDER_PL, + projServices.getId(), + projServices.getServiceNo(), + projServices.getVipId()); + + return sysProjServicesDao.update(projServices); } @@ -1020,6 +1068,14 @@ // 设置美疗师实际开始时间 checkBeauticianState.setState(Dictionary.BEATUI_STATE_SYZ); projServices.getVipId(); + //保存单据日志 + operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.SERVICE_ORDER_BEGIN, + projServices.getId(), + projServices.getServiceNo(), + projServices.getVipId()); + return beauticianStateDao.update(checkBeauticianState); } @@ -1062,7 +1118,13 @@ checkprojServices.setState(Dictionary.SERVICE_STATU_FWWC); sysProjServicesDao.update(checkprojServices); } - + //保存单据日志 + operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.SERVICE_ORDER_END, + projServices.getId(), + projServices.getServiceNo(), + projServices.getVipId()); return rerunlt; } @@ -1114,11 +1176,22 @@ @Override + @Transactional(rollbackFor = Exception.class) public int confirmServiceOrder(Long id) { + SysUsers users = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); SysProjServices services = new SysProjServices(); services.setId(id); services.setState(Dictionary.BEATUI_STATE_DYY); int i = modify(services); + SysProjServices projServices =findById(id); + //保存单据日志 + operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), + OperationFunctionEnum.SERVICE_ORDER, + OperationButtonEnum.SERVICE_ORDER_QRYY, + projServices.getId(), + projServices.getServiceNo(), + projServices.getVipId()); + if (i > 0) { //发送微信公众号提醒 services = findById(services.getId()); -- Gitblit v1.9.1