完善订单功能

This commit is contained in:
huangdeliang 2020-09-26 22:28:17 +08:00
parent 58f276922f
commit 41fb244499
11 changed files with 462 additions and 297 deletions

View File

@ -1,6 +1,14 @@
package com.ruoyi.web.controller.custom;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUserPost;
import com.ruoyi.system.domain.custom.UserPostOption;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -28,31 +36,36 @@ import com.ruoyi.common.core.page.TableDataInfo;
*/
@RestController
@RequestMapping("/custom/order")
public class SysOrderController extends BaseController
{
public class SysOrderController extends BaseController {
@Autowired
private ISysOrderService sysOrderService;
@Autowired
private ISysPostService postService;
@Autowired
private ISysUserService userService;
/**
* 查询销售订单列表
*/
@PreAuthorize("@ss.hasPermi('custom:order:list')")
@GetMapping("/list")
public TableDataInfo list(SysOrder sysOrder)
{
public TableDataInfo list(SysOrder sysOrder) {
startPage();
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
return getDataTable(list);
}
/**
* 导出销售订单列表
*/
@PreAuthorize("@ss.hasPermi('custom:order:export')")
@Log(title = "销售订单", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(SysOrder sysOrder)
{
public AjaxResult export(SysOrder sysOrder) {
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
ExcelUtil<SysOrder> util = new ExcelUtil<SysOrder>(SysOrder.class);
return util.exportExcel(list, "order");
@ -63,8 +76,7 @@ public class SysOrderController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('custom:order:query')")
@GetMapping(value = "/{orderId}")
public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
{
public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
return AjaxResult.success(sysOrderService.selectSysOrderById(orderId));
}
@ -74,8 +86,7 @@ public class SysOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('custom:order:add')")
@Log(title = "销售订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysOrder sysOrder)
{
public AjaxResult add(@RequestBody SysOrder sysOrder) {
return toAjax(sysOrderService.insertSysOrder(sysOrder));
}
@ -85,8 +96,7 @@ public class SysOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('custom:order:edit')")
@Log(title = "销售订单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysOrder sysOrder)
{
public AjaxResult edit(@RequestBody SysOrder sysOrder) {
return toAjax(sysOrderService.updateSysOrder(sysOrder));
}
@ -96,8 +106,29 @@ public class SysOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('custom:order:remove')")
@Log(title = "销售订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{orderIds}")
public AjaxResult remove(@PathVariable Long[] orderIds)
{
public AjaxResult remove(@PathVariable Long[] orderIds) {
return toAjax(sysOrderService.deleteSysOrderByIds(orderIds));
}
@GetMapping("/getOptions")
public AjaxResult getOptions() {
AjaxResult ajax = AjaxResult.success();
List<SysUserPost> userPosts = postService.selectUserPostAll();
List<UserPostOption> userPostOptions = new ArrayList<>();
for (SysUserPost userPost : userPosts) {
SysPost post = postService.selectPostById(userPost.getPostId());
SysUser user = userService.selectUserById(userPost.getUserId());
UserPostOption userPostOption = new UserPostOption();
userPostOption.setPostCode(post.getPostCode());
userPostOption.setUserId(userPost.getUserId());
userPostOption.setUserName(user.getNickName());
userPostOptions.add(userPostOption);
}
ajax.put(AjaxResult.DATA_TAG, userPostOptions);
return ajax;
}
}

View File

@ -6,9 +6,12 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# password: wonderdb
url: jdbc:mysql://47.97.194.44:3306/long_shop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
password: 9gPUnV$#2s/j(7_(
username: root
password: wonderdb
# 从库数据源
slave:
# 从数据源开关/默认关闭

View File

@ -0,0 +1,43 @@
package com.ruoyi.system.domain.custom;
public class UserPostOption {
private Long userId;
private String userName;
private String postCode;
public String getPostCode() {
return postCode;
}
public Long getUserId() {
return userId;
}
public String getUserName() {
return userName;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Override
public String toString() {
return "UserPostOption{" +
"userId=" + userId +
", userName='" + userName + '\'' +
", postCode='" + postCode + '\'' +
'}';
}
}

View File

@ -1,15 +1,16 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUserPost;
/**
* 岗位信息 数据层
*
* @author ruoyi
*/
public interface SysPostMapper
{
public interface SysPostMapper {
/**
* 查询岗位数据集合
*
@ -25,6 +26,8 @@ public interface SysPostMapper
*/
public List<SysPost> selectPostAll();
public List<SysUserPost> selectUserPostAll();
/**
* 通过岗位ID查询岗位信息
*

View File

@ -1,6 +1,7 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.SysUserPost;
/**
@ -8,8 +9,8 @@ import com.ruoyi.system.domain.SysUserPost;
*
* @author ruoyi
*/
public interface SysUserPostMapper
{
public interface SysUserPostMapper {
/**
* 通过用户ID删除用户和岗位关联
*

View File

@ -2,6 +2,7 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUserPost;
/**
* 岗位信息 服务层
@ -18,6 +19,8 @@ public interface ISysPostService
*/
public List<SysPost> selectPostList(SysPost post);
public List<SysUserPost> selectUserPostAll();
/**
* 查询所有岗位
*

View File

@ -1,6 +1,8 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.domain.SysUserPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
@ -48,6 +50,11 @@ public class SysPostServiceImpl implements ISysPostService
return postMapper.selectPostAll();
}
@Override
public List<SysUserPost> selectUserPostAll() {
return postMapper.selectUserPostAll();
}
/**
* 通过岗位ID查询岗位信息
*

View File

@ -1,20 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysPostMapper">
<resultMap type="SysPost" id="SysPostResult">
<id property="postId" column="post_id" />
<result property="postCode" column="post_code" />
<result property="postName" column="post_name" />
<result property="postSort" column="post_sort" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<id property="postId" column="post_id"/>
<result property="postCode" column="post_code"/>
<result property="postName" column="post_name"/>
<result property="postSort" column="post_sort"/>
<result property="status" column="status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<resultMap id="SysUserPostResult" type="SysUserPost">
<id property="userId" column="user_id"/>
<result property="postId" column="post_id"/>
</resultMap>
<sql id="selectPostVo">
@ -22,6 +27,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_post
</sql>
<sql id="selectUserPostVo">
select * from sys_user_post
</sql>
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
<where>
@ -41,6 +50,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectPostVo"/>
</select>
<select id="selectUserPostAll" resultMap="SysUserPostResult">
<include refid="selectUserPostVo"/>
</select>
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_id = #{postId}

View File

@ -2,10 +2,18 @@ import request from '@/utils/request'
// 查询销售订单列表
export function listOrder(query) {
const [fromOrderTime, toOrderTime] = query.orderTime || [null, null];
const params = {
...query,
fromOrderTime,
toOrderTime,
orderTime: null
}
return request({
url: '/custom/order/list',
method: 'get',
params: query
params: params
})
}
@ -51,3 +59,10 @@ export function exportOrder(query) {
params: query
})
}
export function getOptions() {
return request({
url: '/custom/order/getOptions',
method: 'get'
})
}

View File

@ -20,7 +20,7 @@ export default {
props: {
showSearch: {
type: Boolean,
default: true,
default: false,
},
},

View File

@ -14,17 +14,17 @@
</el-form-item>
</el-col>
<!-- <el-col :span="4">-->
<!-- <el-form-item label="电话" prop="phone">-->
<!-- <el-input-->
<!-- v-model="queryParams.phone"-->
<!-- placeholder="请输入电话"-->
<!-- clearable-->
<!-- size="small"-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="4">-->
<!-- <el-form-item label="电话" prop="phone">-->
<!-- <el-input-->
<!-- v-model="queryParams.phone"-->
<!-- placeholder="请输入电话"-->
<!-- clearable-->
<!-- size="small"-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="4">
<el-form-item label="收款方式" prop="payTypeId">
@ -141,14 +141,31 @@
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-col :span="4">
<el-col :span="8">
<el-form-item label="成交日期" prop="orderTime">
<el-date-picker clearable size="small" style="width: 200px"
<el-date-picker
v-model="queryParams.orderTime"
type="date"
type="daterange"
size="small"
align="right"
unlink-panels
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
placeholder="选择成交日期">
:picker-options="pickerOptions">
</el-date-picker>
<!-- <el-date-picker-->
<!-- clearable-->
<!-- size="small"-->
<!-- style="width: 200px"-->
<!-- v-model="queryParams.orderTime"-->
<!-- type="date"-->
<!-- value-format="yyyy-MM-dd"-->
<!-- placeholder="选择成交日期">>-->
<!-- </el-date-picker>-->
</el-form-item>
</el-col>
@ -432,7 +449,7 @@
</template>
<script>
import {listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder} from "@/api/custom/order";
import {listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder, getOptions} from "@/api/custom/order";
export default {
name: "Order",
@ -447,7 +464,7 @@
//
multiple: true,
//
showSearch: true,
showSearch: false,
//
total: 0,
//
@ -504,39 +521,68 @@
],
orderTime: [
{required: true, message: "成交日期不能为空", trigger: "blur"}
],
payTypeId: [
{required: true, message: "首款方式不能为空", trigger: "blur"}
],
accountId: [
{required: true, message: "账号不能为空", trigger: "blur"}
]
},
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
};
},
created() {
this.getList();
getOptions().then(response => {
console.log(response)
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [];
}
opts[cur.postCode].push({dictValue: cur.userId, dictLabel: cur.userName})
return opts;
}, {})
this.preSaleIdOptions = options['pre_sale'] || [];
this.afterSaleIdOptions = options['after_sale'] || [];
this.nutritionistIdOptions = options['nutri'] || [];
this.nutriAssisIdOptions = options['nutri_assis'] || [];
this.plannerIdOptions = options['planner'] || [];
this.plannerAssisIdOptions = options['planner_assis'] || [];
this.operatorIdOptions = options['operator'] || [];
})
this.getDicts("cus_pay_type").then(response => {
this.payTypeIdOptions = response.data;
});
this.getDicts("cus_pre_sale").then(response => {
this.preSaleIdOptions = response.data;
});
this.getDicts("cus_after_sale").then(response => {
this.afterSaleIdOptions = response.data;
});
this.getDicts("cus_nutri").then(response => {
this.nutritionistIdOptions = response.data;
});
this.getDicts("cus_nutri_assis").then(response => {
this.nutriAssisIdOptions = response.data;
});
this.getDicts("cus_planner").then(response => {
this.plannerIdOptions = response.data;
});
this.getDicts("cus_account").then(response => {
this.accountIdOptions = response.data;
});
this.getDicts("cus_planner_assis").then(response => {
this.plannerAssisIdOptions = response.data;
});
this.getDicts("cus_operator").then(response => {
this.operatorIdOptions = response.data;
});
},
methods: {
/** 查询销售订单列表 */
@ -627,33 +673,33 @@
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
this.getDicts("cus_pay_type").then(response => {
this.payTypeIdOptions = response.data;
});
this.getDicts("cus_pre_sale").then(response => {
this.preSaleIdOptions = response.data;
});
this.getDicts("cus_after_sale").then(response => {
this.afterSaleIdOptions = response.data;
});
this.getDicts("cus_nutri").then(response => {
this.nutritionistIdOptions = response.data;
});
this.getDicts("cus_nutri_assis").then(response => {
this.nutriAssisIdOptions = response.data;
});
this.getDicts("cus_planner").then(response => {
this.plannerIdOptions = response.data;
});
this.getDicts("cus_custom").then(response => {
this.accountIdOptions = response.data;
});
this.getDicts("cus_planner_assis").then(response => {
this.plannerAssisIdOptions = response.data;
});
this.getDicts("cus_operator").then(response => {
this.operatorIdOptions = response.data;
});
// this.getDicts("cus_pay_type").then(response => {
// this.payTypeIdOptions = response.data;
// });
// this.getDicts("cus_pre_sale").then(response => {
// this.preSaleIdOptions = response.data;
// });
// this.getDicts("cus_after_sale").then(response => {
// this.afterSaleIdOptions = response.data;
// });
// this.getDicts("cus_nutri").then(response => {
// this.nutritionistIdOptions = response.data;
// });
// this.getDicts("cus_nutri_assis").then(response => {
// this.nutriAssisIdOptions = response.data;
// });
// this.getDicts("cus_planner").then(response => {
// this.plannerIdOptions = response.data;
// });
// this.getDicts("cus_account").then(response => {
// this.accountIdOptions = response.data;
// });
// this.getDicts("cus_planner_assis").then(response => {
// this.plannerAssisIdOptions = response.data;
// });
// this.getDicts("cus_operator").then(response => {
// this.operatorIdOptions = response.data;
// });
},
/** 重置按钮操作 */
resetQuery() {
@ -687,7 +733,7 @@
this.$refs["form"].validate(valid => {
if (valid) {
console.log(this.form)
// console.log(this.form)
this.form.payType = this.selectDictLabel(this.payTypeIdOptions, this.form.payTypeId);
this.form.preSale = this.selectDictLabel(this.preSaleIdOptions, this.form.preSaleId);