添加合作方功能
This commit is contained in:
parent
7326c487d9
commit
5fe3c85e1d
stdiet-admin/src/main/java/com/stdiet/web/controller/custom
stdiet-custom/src/main
stdiet-ui/src
@ -5,7 +5,7 @@ import com.stdiet.common.annotation.Log;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.core.domain.entity.SysUser;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
import com.stdiet.common.utils.SecurityUtils;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.custom.controller.OrderBaseController;
|
||||
@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLDecoder;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -50,6 +49,11 @@ public class SysOrderController extends OrderBaseController {
|
||||
public OrderTableDataInfo list(SysOrder sysOrder) {
|
||||
startPage();
|
||||
dealOrderType(sysOrder);
|
||||
String remark = SecurityUtils.getLoginUser().getUser().getRemark();
|
||||
if (StringUtils.isNotEmpty(remark) && remark.contains("|") && StringUtils.isEmpty(sysOrder.getAccount())) {
|
||||
sysOrder.setAccRange(remark.split("\\|"));
|
||||
}
|
||||
|
||||
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
|
||||
List<SysUser> userList = userService.selectAllUser();
|
||||
BigDecimal totalAmount = sysOrderService.selectAllOrderAmount(sysOrder);
|
||||
@ -57,30 +61,25 @@ public class SysOrderController extends OrderBaseController {
|
||||
totalAmount = new BigDecimal(0);
|
||||
}
|
||||
for (SysOrder order : list) {
|
||||
initUserNickNameAndOrderType(userList,order);
|
||||
initUserNickNameAndOrderType(userList, order);
|
||||
if (StringUtils.isNotEmpty(order.getPhone())) {
|
||||
order.setPhone(StringUtils.hiddenPhoneNumber(order.getPhone()));
|
||||
}
|
||||
/*//根据服务时长、赠送天数计算服务天数
|
||||
int month = order.getServeTimeId() != null ? order.getServeTimeId().intValue() / 30 : 0;
|
||||
if (order.getStartTime() != null && order.getServerEndTime() != null && order.getServeTimeId() != null && month > 0) {
|
||||
long serverDay = ChronoUnit.DAYS.between(DateUtils.dateToLocalDate(order.getStartTime()), DateUtils.dateToLocalDate(order.getStartTime()).plusMonths(month).plusDays(order.getGiveServeDay() == null ? 0 : order.getGiveServeDay())) + 1;
|
||||
order.setServerDay(Integer.parseInt(serverDay + ""));
|
||||
}*/
|
||||
}
|
||||
return getOrderDataTable(list, totalAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理订单类型
|
||||
*
|
||||
* @param sysOrder
|
||||
*/
|
||||
private void dealOrderType(SysOrder sysOrder) {
|
||||
if(StringUtils.isNotEmpty(sysOrder.getOrderType())){
|
||||
if (StringUtils.isNotEmpty(sysOrder.getOrderType())) {
|
||||
try {
|
||||
JSONArray array = JSONArray.parseArray(URLDecoder.decode(sysOrder.getOrderType(),"UTF-8"));
|
||||
JSONArray array = JSONArray.parseArray(URLDecoder.decode(sysOrder.getOrderType(), "UTF-8"));
|
||||
sysOrder.setSearchOrderTypeArray(array.size() > 0 ? array : null);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -96,7 +95,7 @@ public class SysOrderController extends OrderBaseController {
|
||||
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
|
||||
List<SysUser> userList = userService.selectAllUser();
|
||||
for (SysOrder order : list) {
|
||||
initUserNickNameAndOrderType(userList,order);
|
||||
initUserNickNameAndOrderType(userList, order);
|
||||
if (StringUtils.isNotEmpty(order.getPhone())) {
|
||||
order.setPhone(StringUtils.hiddenPhoneNumber(order.getPhone()));
|
||||
}
|
||||
@ -123,12 +122,12 @@ public class SysOrderController extends OrderBaseController {
|
||||
SysOrder order = sysOrderService.selectSysOrderById(orderId);
|
||||
if (order != null) {
|
||||
List<SysUser> userList = userService.selectAllUser();
|
||||
initUserNickNameAndOrderType(userList,order);
|
||||
initUserNickNameAndOrderType(userList, order);
|
||||
}
|
||||
return AjaxResult.success(order);
|
||||
}
|
||||
|
||||
private void initUserNickNameAndOrderType(List<SysUser> userList, SysOrder order){
|
||||
private void initUserNickNameAndOrderType(List<SysUser> userList, SysOrder order) {
|
||||
for (SysUser user : userList) {
|
||||
if (user.getUserId().equals(order.getPreSaleId())) {
|
||||
order.setPreSale(user.getNickName());
|
||||
|
@ -134,6 +134,8 @@ public class SysOrder extends BaseEntity {
|
||||
@Excel(name = "账号")
|
||||
private String account;
|
||||
|
||||
private String[] accRange;
|
||||
|
||||
/**
|
||||
* 策划
|
||||
*/
|
||||
|
@ -41,14 +41,14 @@
|
||||
<result property="serverEndTime" column="server_end_time"/>
|
||||
<result property="becomeFanTime" column="become_fan_time"/>
|
||||
|
||||
<result property="onSaleId" column="on_sale_id" />
|
||||
<result property="orderType" column="order_type" />
|
||||
<result property="orderCountType" column="order_count_type" />
|
||||
<result property="orderMoneyType" column="order_money_type" />
|
||||
<result property="mainOrderId" column="main_order_id" />
|
||||
<result property="afterSaleCommissOrder" column="after_sale_commiss_order" />
|
||||
<result property="commissStartTime" column="commiss_start_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="onSaleId" column="on_sale_id"/>
|
||||
<result property="orderType" column="order_type"/>
|
||||
<result property="orderCountType" column="order_count_type"/>
|
||||
<result property="orderMoneyType" column="order_money_type"/>
|
||||
<result property="mainOrderId" column="main_order_id"/>
|
||||
<result property="afterSaleCommissOrder" column="after_sale_commiss_order"/>
|
||||
<result property="commissStartTime" column="commiss_start_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
|
||||
<!-- 非持久化字段 -->
|
||||
<result property="afterSale" column="afterSale_name"></result><!-- 售后名称 -->
|
||||
@ -73,7 +73,7 @@
|
||||
<sql id="searchOrderType">
|
||||
<if test="searchOrderTypeArray != null">
|
||||
<trim prefix="AND (" suffix=")" suffixOverrides="or">
|
||||
<foreach collection="searchOrderTypeArray" separator="or" item="typeArray" index="i">
|
||||
<foreach collection="searchOrderTypeArray" separator="or" item="typeArray" index="i">
|
||||
(
|
||||
<foreach collection="typeArray" separator="and" item="type" index="j">
|
||||
<if test="j == 0">
|
||||
@ -99,8 +99,14 @@
|
||||
<if test="customer != null and customer != ''">
|
||||
and (customer like concat('%',#{customer},'%') or phone like concat('%',#{customer},'%'))
|
||||
</if>
|
||||
<if test="accRange != null">
|
||||
and account_id in
|
||||
<foreach collection="accRange" separator="," item="acc" open="(" close=")" >
|
||||
#{acc}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
|
||||
<!-- <if test="phone != null and phone != ''">and phone = #{phone}</if>-->
|
||||
<!-- <if test="phone != null and phone != ''">and phone = #{phone}</if>-->
|
||||
<if test="status != null ">and status = #{status}</if>
|
||||
<if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
|
||||
<if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
|
||||
@ -113,8 +119,12 @@
|
||||
<if test="operatorId != null ">and operator_id = #{operatorId}</if>
|
||||
<if test="operatorAssisId != null ">and operator_assis_id = #{operatorAssisId}</if>
|
||||
<if test="recommender != null and recommender != ''">and recommender = #{recommender}</if>
|
||||
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')</if>
|
||||
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')</if>
|
||||
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') >=
|
||||
date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') <=
|
||||
date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="serveTimeId != null ">and serve_time_id = #{serveTimeId}</if>
|
||||
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
|
||||
<if test="amountFlag != null">
|
||||
@ -141,7 +151,13 @@
|
||||
<if test="customer != null and customer != ''">
|
||||
and (sc.name like concat('%',#{customer},'%') or sc.phone like concat('%',#{customer},'%'))
|
||||
</if>
|
||||
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
|
||||
<if test="accRange != null">
|
||||
and account_id in
|
||||
<foreach collection="accRange" separator="," item="acc" open="(" close=")">
|
||||
#{acc}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
|
||||
<if test="phone != null and phone != ''">and sc.phone = #{phone}</if>
|
||||
<if test="status != null ">and status = #{status}</if>
|
||||
<if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
|
||||
@ -155,8 +171,12 @@
|
||||
<if test="operatorId != null ">and operator_id = #{operatorId}</if>
|
||||
<if test="operatorAssisId != null ">and operator_assis_id = #{operatorAssisId}</if>
|
||||
<if test="recommender != null and recommender != ''">and recommender = #{recommender}</if>
|
||||
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')</if>
|
||||
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')</if>
|
||||
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') >=
|
||||
date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') <=
|
||||
date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="serveTimeId != null ">and serve_time_id = #{serveTimeId}</if>
|
||||
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
|
||||
<if test="amountFlag != null">
|
||||
@ -319,10 +339,10 @@
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysOrderByIds" parameterType="String">
|
||||
<!-- delete from sys_order where order_id in-->
|
||||
<!-- <foreach item="orderId" collection="array" open="(" separator="," close=")">-->
|
||||
<!-- #{orderId}-->
|
||||
<!-- </foreach>-->
|
||||
<!-- delete from sys_order where order_id in-->
|
||||
<!-- <foreach item="orderId" collection="array" open="(" separator="," close=")">-->
|
||||
<!-- #{orderId}-->
|
||||
<!-- </foreach>-->
|
||||
</delete>
|
||||
|
||||
<resultMap type="SysOrder" id="SysOrderResultExtended">
|
||||
@ -362,14 +382,14 @@
|
||||
<result property="serverEndTime" column="server_end_time"/>
|
||||
<result property="becomeFanTime" column="become_fan_time"/>
|
||||
|
||||
<result property="onSaleId" column="on_sale_id" />
|
||||
<result property="orderType" column="order_type" />
|
||||
<result property="orderCountType" column="order_count_type" />
|
||||
<result property="orderMoneyType" column="order_money_type" />
|
||||
<result property="mainOrderId" column="main_order_id" />
|
||||
<result property="afterSaleCommissOrder" column="after_sale_commiss_order" />
|
||||
<result property="commissStartTime" column="commiss_start_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="onSaleId" column="on_sale_id"/>
|
||||
<result property="orderType" column="order_type"/>
|
||||
<result property="orderCountType" column="order_count_type"/>
|
||||
<result property="orderMoneyType" column="order_money_type"/>
|
||||
<result property="mainOrderId" column="main_order_id"/>
|
||||
<result property="afterSaleCommissOrder" column="after_sale_commiss_order"/>
|
||||
<result property="commissStartTime" column="commiss_start_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
|
||||
<!-- 非持久化字段 -->
|
||||
<result property="afterSale" column="afterSale_name"></result><!-- 售后名称 -->
|
||||
@ -378,17 +398,17 @@
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="SysOrderPause" id="SysOrderPauseResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="pauseStartDate" column="pause_start_date" />
|
||||
<result property="pauseEndDate" column="pause_end_date" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="remarks" column="remarks" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="id" column="id"/>
|
||||
<result property="orderId" column="order_id"/>
|
||||
<result property="pauseStartDate" column="pause_start_date"/>
|
||||
<result property="pauseEndDate" column="pause_end_date"/>
|
||||
<result property="reason" column="reason"/>
|
||||
<result property="remarks" column="remarks"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getOrderPauseByOrderId" parameterType="Long" resultMap="SysOrderPauseResult">
|
||||
@ -398,34 +418,15 @@
|
||||
|
||||
<!-- 查询2021年开始的已审核的订单信息(用于计算提成,请勿随意改动) -->
|
||||
<select id="selectSimpleOrderMessage" resultMap="SysOrderResultExtended" parameterType="SysCommision">
|
||||
select o.order_id,o.order_time,o.commiss_start_time,o.server_end_time,o.customer,o.review_status,o.amount,o.serve_time_id,o.give_serve_day,o.after_sale_id,su_sale.nick_name as afterSale_name,o.nutritionist_id,su_nutritionist.nick_name as nutritionist_name
|
||||
from sys_order o
|
||||
left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
|
||||
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag = 0
|
||||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR su_nutritionist.user_id is not null)
|
||||
and o.amount is not null
|
||||
<if test="reviewStatus != null and reviewStatus != ''">
|
||||
and review_status = #{reviewStatus}
|
||||
</if>
|
||||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||||
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||||
</if>
|
||||
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
|
||||
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
|
||||
</if>
|
||||
order by o.order_time desc
|
||||
</select>
|
||||
|
||||
<!-- 查询2021年开始的已审核的订单信息的总条数(用于计算提成,请勿随意改动) -->
|
||||
<select id="selectSimpleOrderMessageCount" resultType="int" parameterType="SysCommision">
|
||||
select count(o.order_id) as orderCount
|
||||
select
|
||||
o.order_id,o.order_time,o.commiss_start_time,o.server_end_time,o.customer,o.review_status,o.amount,o.serve_time_id,o.give_serve_day,o.after_sale_id,su_sale.nick_name
|
||||
as afterSale_name,o.nutritionist_id,su_nutritionist.nick_name as nutritionist_name
|
||||
from sys_order o
|
||||
left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
|
||||
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag = 0
|
||||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR su_nutritionist.user_id is not null)
|
||||
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag =
|
||||
0
|
||||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR
|
||||
su_nutritionist.user_id is not null)
|
||||
and o.amount is not null
|
||||
<if test="reviewStatus != null and reviewStatus != ''">
|
||||
and review_status = #{reviewStatus}
|
||||
@ -437,31 +438,59 @@
|
||||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||||
</if>
|
||||
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
|
||||
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
|
||||
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
|
||||
</if>
|
||||
order by o.order_time desc
|
||||
</select>
|
||||
|
||||
<!-- 查询2021年开始的已审核的订单信息的总条数(用于计算提成,请勿随意改动) -->
|
||||
<select id="selectSimpleOrderMessageCount" resultType="int" parameterType="SysCommision">
|
||||
select count(o.order_id) as orderCount
|
||||
from sys_order o
|
||||
left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
|
||||
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag =
|
||||
0
|
||||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR
|
||||
su_nutritionist.user_id is not null)
|
||||
and o.amount is not null
|
||||
<if test="reviewStatus != null and reviewStatus != ''">
|
||||
and review_status = #{reviewStatus}
|
||||
</if>
|
||||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||||
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||||
</if>
|
||||
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
|
||||
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
|
||||
</if>
|
||||
order by o.order_time desc
|
||||
</select>
|
||||
|
||||
<!-- 查询售后、营养师的每个月服务总金额 -->
|
||||
<select id="getTotalAmountByUserId" parameterType="SysCommision" resultType="com.stdiet.custom.dto.response.EveryMonthTotalAmount">
|
||||
<select id="getTotalAmountByUserId" parameterType="SysCommision"
|
||||
resultType="com.stdiet.custom.dto.response.EveryMonthTotalAmount">
|
||||
SELECT s.yearMonth,SUM(s.amount) AS totalAmount FROM
|
||||
(
|
||||
SELECT CONCAT(YEAR(o.order_time),'',MONTH(o.order_time)) AS yearMonth,o.amount
|
||||
FROM sys_order o
|
||||
LEFT JOIN sys_user su_sale ON su_sale.user_id = o.after_sale_id AND su_sale.del_flag = 0
|
||||
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = o.nutritionist_id AND su_nutritionist.del_flag = 0
|
||||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR su_nutritionist.user_id is not null)
|
||||
and o.amount is not null
|
||||
<if test="reviewStatus != null and reviewStatus != ''">
|
||||
SELECT CONCAT(YEAR(o.order_time),'',MONTH(o.order_time)) AS yearMonth,o.amount
|
||||
FROM sys_order o
|
||||
LEFT JOIN sys_user su_sale ON su_sale.user_id = o.after_sale_id AND su_sale.del_flag = 0
|
||||
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = o.nutritionist_id AND su_nutritionist.del_flag =
|
||||
0
|
||||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR
|
||||
su_nutritionist.user_id is not null)
|
||||
and o.amount is not null
|
||||
<if test="reviewStatus != null and reviewStatus != ''">
|
||||
and o.review_status = #{reviewStatus}
|
||||
</if>
|
||||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||||
</if>
|
||||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||||
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||||
</if>
|
||||
ORDER BY o.order_time ASC
|
||||
</if>
|
||||
ORDER BY o.order_time ASC
|
||||
) s
|
||||
GROUP BY s.yearMonth
|
||||
</select>
|
||||
|
@ -11,6 +11,7 @@ const getters = {
|
||||
roles: state => state.user.roles,
|
||||
permissions: state => state.user.permissions,
|
||||
userId: state => state.user.userId,
|
||||
userRemark: state => state.user.remark,
|
||||
permission_routes: state => state.permission.routes,
|
||||
//
|
||||
nutritionistIdOptions: state => state.global.nutritionistIdOptions,
|
||||
|
@ -1,100 +1,117 @@
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import { login, logout, getInfo } from "@/api/login";
|
||||
import { getToken, setToken, removeToken } from "@/utils/auth";
|
||||
|
||||
const user = {
|
||||
state: {
|
||||
token: getToken(),
|
||||
name: '',
|
||||
avatar: '',
|
||||
name: "",
|
||||
avatar: "",
|
||||
remark: "",
|
||||
roles: [],
|
||||
permissions: []
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_TOKEN: (state, token) => {
|
||||
state.token = token
|
||||
state.token = token;
|
||||
},
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
state.name = name;
|
||||
},
|
||||
SET_AVATAR: (state, avatar) => {
|
||||
state.avatar = avatar
|
||||
state.avatar = avatar;
|
||||
},
|
||||
SET_ROLES: (state, roles) => {
|
||||
state.roles = roles
|
||||
state.roles = roles;
|
||||
},
|
||||
SET_PERMISSIONS: (state, permissions) => {
|
||||
state.permissions = permissions
|
||||
state.permissions = permissions;
|
||||
},
|
||||
SET_USERID: (state, userId) => {
|
||||
state.userId = userId
|
||||
state.userId = userId;
|
||||
},
|
||||
SET_REMARK: (state, remark) => {
|
||||
state.remark = remark;
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
const uuid = userInfo.uuid
|
||||
const username = userInfo.username.trim();
|
||||
const password = userInfo.password;
|
||||
const code = userInfo.code;
|
||||
const uuid = userInfo.uuid;
|
||||
return new Promise((resolve, reject) => {
|
||||
login(username, password, code, uuid).then(res => {
|
||||
setToken(res.token)
|
||||
commit('SET_TOKEN', res.token)
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
login(username, password, code, uuid)
|
||||
.then(res => {
|
||||
setToken(res.token);
|
||||
commit("SET_TOKEN", res.token);
|
||||
resolve();
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo(state.token).then(res => {
|
||||
const user = res.user
|
||||
const avatar = user.avatar == "" ? require("@/assets/image/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
commit('SET_ROLES', res.roles)
|
||||
commit('SET_PERMISSIONS', res.permissions)
|
||||
} else {
|
||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||
}
|
||||
commit('SET_NAME', user.userName)
|
||||
commit('SET_AVATAR', avatar)
|
||||
commit('SET_USERID', user.userId)
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
getInfo(state.token)
|
||||
.then(res => {
|
||||
const user = res.user;
|
||||
const avatar =
|
||||
user.avatar == ""
|
||||
? require("@/assets/image/profile.jpg")
|
||||
: process.env.VUE_APP_BASE_API + user.avatar;
|
||||
if (res.roles && res.roles.length > 0) {
|
||||
// 验证返回的roles是否是一个非空数组
|
||||
commit("SET_ROLES", res.roles);
|
||||
commit("SET_PERMISSIONS", res.permissions);
|
||||
} else {
|
||||
commit("SET_ROLES", ["ROLE_DEFAULT"]);
|
||||
}
|
||||
commit("SET_NAME", user.userName);
|
||||
commit("SET_AVATAR", avatar);
|
||||
commit("SET_USERID", user.userId);
|
||||
commit("SET_REMARK", user.remark);
|
||||
resolve(res);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
removeToken()
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
logout(state.token)
|
||||
.then(() => {
|
||||
commit("SET_TOKEN", "");
|
||||
commit("SET_ROLES", []);
|
||||
commit("SET_PERMISSIONS", []);
|
||||
commit("SET_USERID", "");
|
||||
commit("SET_REMARK", "");
|
||||
removeToken();
|
||||
resolve();
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 前端 登出
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
commit("SET_TOKEN", "");
|
||||
removeToken();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default user
|
||||
export default user;
|
||||
|
@ -19,7 +19,7 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="收款方式" prop="payTypeId">
|
||||
<el-select
|
||||
v-model="queryParams.payTypeId"
|
||||
@ -37,10 +37,10 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="收款账号" prop="accountId">
|
||||
<el-form-item label="进粉渠道" prop="accountId">
|
||||
<el-select
|
||||
v-model="queryParams.accountId"
|
||||
placeholder="请选择账号"
|
||||
placeholder="请选择渠道"
|
||||
clearable
|
||||
size="small"
|
||||
>
|
||||
@ -70,7 +70,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="销售" prop="preSaleId">
|
||||
<el-select
|
||||
v-model="queryParams.preSaleId"
|
||||
@ -88,7 +88,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="售后" prop="afterSaleId">
|
||||
<el-select
|
||||
v-model="queryParams.afterSaleId"
|
||||
@ -106,7 +106,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="主营养师" prop="nutritionistId">
|
||||
<el-select
|
||||
v-model="queryParams.nutritionistId"
|
||||
@ -124,7 +124,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item
|
||||
label="营养师助理"
|
||||
prop="nutriAssisId"
|
||||
@ -147,7 +147,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="策划" prop="plannerId">
|
||||
<el-select
|
||||
v-model="queryParams.plannerId"
|
||||
@ -165,7 +165,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="策划助理" prop="plannerAssisId">
|
||||
<el-select
|
||||
v-model="queryParams.plannerAssisId"
|
||||
@ -183,7 +183,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="运营" prop="operatorId">
|
||||
<el-select
|
||||
v-model="queryParams.operatorId"
|
||||
@ -201,7 +201,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="运营助理" prop="operatorAssisId">
|
||||
<el-select
|
||||
v-model="queryParams.operatorAssisId"
|
||||
@ -235,7 +235,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-col :span="6" v-if="!isPartner">
|
||||
<el-form-item label="订单金额" prop="amountFlag">
|
||||
<el-select
|
||||
v-model="queryParams.amountFlag"
|
||||
@ -356,7 +356,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="收款账号"
|
||||
label="进粉渠道"
|
||||
align="center"
|
||||
prop="account"
|
||||
width="90"
|
||||
@ -586,6 +586,9 @@ export default {
|
||||
isMobile() {
|
||||
return this.device === "mobile";
|
||||
},
|
||||
isPartner() {
|
||||
return this.userRemark && this.userRemark.includes("|");
|
||||
},
|
||||
...mapGetters([
|
||||
// 售前字典
|
||||
"preSaleIdOptions",
|
||||
@ -606,6 +609,8 @@ export default {
|
||||
//
|
||||
"userId",
|
||||
//
|
||||
"userRemark",
|
||||
//
|
||||
"device",
|
||||
]),
|
||||
},
|
||||
@ -615,7 +620,18 @@ export default {
|
||||
this.payTypeIdOptions = response.data;
|
||||
});
|
||||
this.getDicts("cus_account").then((response) => {
|
||||
this.accountIdOptions = response.data;
|
||||
if (this.userRemark && this.userRemark.includes("|")) {
|
||||
const accRange = this.userRemark.split("|");
|
||||
this.accountIdOptions = accRange.reduce((arr, accId) => {
|
||||
const tarObj = response.data.find((obj) => obj.dictValue === accId);
|
||||
if (tarObj) {
|
||||
arr.push(tarObj);
|
||||
}
|
||||
return arr;
|
||||
}, []);
|
||||
} else {
|
||||
this.accountIdOptions = response.data;
|
||||
}
|
||||
});
|
||||
this.getDicts("cus_serve_time").then((response) => {
|
||||
this.serveTimeIdOption = response.data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user