diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOrderController.java new file mode 100644 index 000000000..fa3355625 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOrderController.java @@ -0,0 +1,103 @@ +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.SysOrder; +import com.ruoyi.system.service.ISysOrderService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 销售订单Controller + * + * @author wonder + * @date 2020-09-22 + */ +@RestController +@RequestMapping("/system/order") +public class SysOrderController extends BaseController +{ + @Autowired + private ISysOrderService sysOrderService; + + /** + * 查询销售订单列表 + */ + @PreAuthorize("@ss.hasPermi('system:order:list')") + @GetMapping("/list") + public TableDataInfo list(SysOrder sysOrder) + { + startPage(); + List list = sysOrderService.selectSysOrderList(sysOrder); + return getDataTable(list); + } + + /** + * 导出销售订单列表 + */ + @PreAuthorize("@ss.hasPermi('system:order:export')") + @Log(title = "销售订单", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysOrder sysOrder) + { + List list = sysOrderService.selectSysOrderList(sysOrder); + ExcelUtil util = new ExcelUtil(SysOrder.class); + return util.exportExcel(list, "order"); + } + + /** + * 获取销售订单详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:order:query')") + @GetMapping(value = "/{orderId}") + public AjaxResult getInfo(@PathVariable("orderId") Long orderId) + { + return AjaxResult.success(sysOrderService.selectSysOrderById(orderId)); + } + + /** + * 新增销售订单 + */ + @PreAuthorize("@ss.hasPermi('system:order:add')") + @Log(title = "销售订单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysOrder sysOrder) + { + return toAjax(sysOrderService.insertSysOrder(sysOrder)); + } + + /** + * 修改销售订单 + */ + @PreAuthorize("@ss.hasPermi('system:order:edit')") + @Log(title = "销售订单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysOrder sysOrder) + { + return toAjax(sysOrderService.updateSysOrder(sysOrder)); + } + + /** + * 删除销售订单 + */ + @PreAuthorize("@ss.hasPermi('system:order:remove')") + @Log(title = "销售订单", businessType = BusinessType.DELETE) + @DeleteMapping("/{orderIds}") + public AjaxResult remove(@PathVariable Long[] orderIds) + { + return toAjax(sysOrderService.deleteSysOrderByIds(orderIds)); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOrder.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOrder.java new file mode 100644 index 000000000..dad7bab9a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOrder.java @@ -0,0 +1,115 @@ +package com.ruoyi.system.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 销售订单对象 sys_order + * + * @author wonder + * @date 2020-09-22 + */ +public class SysOrder extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 编号 */ + private Long orderId; + + /** 用户ID */ + @Excel(name = "用户ID") + private Long userId; + + /** 用户昵称 */ + @Excel(name = "用户昵称") + private String nickName; + + /** 金额 */ + @Excel(name = "金额") + private Long amount; + + /** 成交日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "成交日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date saleTime; + + /** 销售渠道ID */ + @Excel(name = "销售渠道ID") + private Long channelId; + + public void setOrderId(Long orderId) + { + this.orderId = orderId; + } + + public Long getOrderId() + { + return orderId; + } + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + public void setNickName(String nickName) + { + this.nickName = nickName; + } + + public String getNickName() + { + return nickName; + } + public void setAmount(Long amount) + { + this.amount = amount; + } + + public Long getAmount() + { + return amount; + } + public void setSaleTime(Date saleTime) + { + this.saleTime = saleTime; + } + + public Date getSaleTime() + { + return saleTime; + } + public void setChannelId(Long channelId) + { + this.channelId = channelId; + } + + public Long getChannelId() + { + return channelId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("orderId", getOrderId()) + .append("userId", getUserId()) + .append("nickName", getNickName()) + .append("amount", getAmount()) + .append("saleTime", getSaleTime()) + .append("channelId", getChannelId()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java new file mode 100644 index 000000000..bdb1a5b0c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysOrder; + +/** + * 销售订单Mapper接口 + * + * @author wonder + * @date 2020-09-22 + */ +public interface SysOrderMapper +{ + /** + * 查询销售订单 + * + * @param orderId 销售订单ID + * @return 销售订单 + */ + public SysOrder selectSysOrderById(Long orderId); + + /** + * 查询销售订单列表 + * + * @param sysOrder 销售订单 + * @return 销售订单集合 + */ + public List selectSysOrderList(SysOrder sysOrder); + + /** + * 新增销售订单 + * + * @param sysOrder 销售订单 + * @return 结果 + */ + public int insertSysOrder(SysOrder sysOrder); + + /** + * 修改销售订单 + * + * @param sysOrder 销售订单 + * @return 结果 + */ + public int updateSysOrder(SysOrder sysOrder); + + /** + * 删除销售订单 + * + * @param orderId 销售订单ID + * @return 结果 + */ + public int deleteSysOrderById(Long orderId); + + /** + * 批量删除销售订单 + * + * @param orderIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysOrderByIds(Long[] orderIds); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java new file mode 100644 index 000000000..495ed8070 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysOrder; + +/** + * 销售订单Service接口 + * + * @author wonder + * @date 2020-09-22 + */ +public interface ISysOrderService +{ + /** + * 查询销售订单 + * + * @param orderId 销售订单ID + * @return 销售订单 + */ + public SysOrder selectSysOrderById(Long orderId); + + /** + * 查询销售订单列表 + * + * @param sysOrder 销售订单 + * @return 销售订单集合 + */ + public List selectSysOrderList(SysOrder sysOrder); + + /** + * 新增销售订单 + * + * @param sysOrder 销售订单 + * @return 结果 + */ + public int insertSysOrder(SysOrder sysOrder); + + /** + * 修改销售订单 + * + * @param sysOrder 销售订单 + * @return 结果 + */ + public int updateSysOrder(SysOrder sysOrder); + + /** + * 批量删除销售订单 + * + * @param orderIds 需要删除的销售订单ID + * @return 结果 + */ + public int deleteSysOrderByIds(Long[] orderIds); + + /** + * 删除销售订单信息 + * + * @param orderId 销售订单ID + * @return 结果 + */ + public int deleteSysOrderById(Long orderId); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java new file mode 100644 index 000000000..f52973a43 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.SysOrderMapper; +import com.ruoyi.system.domain.SysOrder; +import com.ruoyi.system.service.ISysOrderService; + +/** + * 销售订单Service业务层处理 + * + * @author wonder + * @date 2020-09-22 + */ +@Service +public class SysOrderServiceImpl implements ISysOrderService +{ + @Autowired + private SysOrderMapper sysOrderMapper; + + /** + * 查询销售订单 + * + * @param orderId 销售订单ID + * @return 销售订单 + */ + @Override + public SysOrder selectSysOrderById(Long orderId) + { + return sysOrderMapper.selectSysOrderById(orderId); + } + + /** + * 查询销售订单列表 + * + * @param sysOrder 销售订单 + * @return 销售订单 + */ + @Override + public List selectSysOrderList(SysOrder sysOrder) + { + return sysOrderMapper.selectSysOrderList(sysOrder); + } + + /** + * 新增销售订单 + * + * @param sysOrder 销售订单 + * @return 结果 + */ + @Override + public int insertSysOrder(SysOrder sysOrder) + { + sysOrder.setCreateTime(DateUtils.getNowDate()); + return sysOrderMapper.insertSysOrder(sysOrder); + } + + /** + * 修改销售订单 + * + * @param sysOrder 销售订单 + * @return 结果 + */ + @Override + public int updateSysOrder(SysOrder sysOrder) + { + sysOrder.setUpdateTime(DateUtils.getNowDate()); + return sysOrderMapper.updateSysOrder(sysOrder); + } + + /** + * 批量删除销售订单 + * + * @param orderIds 需要删除的销售订单ID + * @return 结果 + */ + @Override + public int deleteSysOrderByIds(Long[] orderIds) + { + return sysOrderMapper.deleteSysOrderByIds(orderIds); + } + + /** + * 删除销售订单信息 + * + * @param orderId 销售订单ID + * @return 结果 + */ + @Override + public int deleteSysOrderById(Long orderId) + { + return sysOrderMapper.deleteSysOrderById(orderId); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysOrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysOrderMapper.xml new file mode 100644 index 000000000..c05cd3f59 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/SysOrderMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + select order_id, user_id, nick_name, amount, sale_time, channel_id, create_by, create_time, update_by, update_time, remark from sys_order + + + + + + + + insert into sys_order + + user_id, + nick_name, + amount, + sale_time, + channel_id, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{userId}, + #{nickName}, + #{amount}, + #{saleTime}, + #{channelId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update sys_order + + user_id = #{userId}, + nick_name = #{nickName}, + amount = #{amount}, + sale_time = #{saleTime}, + channel_id = #{channelId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where order_id = #{orderId} + + + + delete from sys_order where order_id = #{orderId} + + + + delete from sys_order where order_id in + + #{orderId} + + + + \ No newline at end of file