修复总计

This commit is contained in:
huangdeliang
2020-10-18 10:59:09 +08:00
parent 72a3837804
commit a23a02ab60
8 changed files with 171 additions and 4 deletions

View File

@ -1,9 +1,12 @@
package com.ruoyi.web.controller.custom;
import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.custom.controller.OrderBaseController;
import com.ruoyi.custom.page.OrderTableDataInfo;
import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
@ -33,7 +36,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
*/
@RestController
@RequestMapping("/custom/order")
public class SysOrderController extends BaseController {
public class SysOrderController extends OrderBaseController {
@Autowired
private ISysOrderService sysOrderService;
@ -48,10 +51,11 @@ public class SysOrderController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('custom:order:list')")
@GetMapping("/list")
public TableDataInfo list(SysOrder sysOrder) {
public OrderTableDataInfo list(SysOrder sysOrder) {
startPage();
List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder);
List<SysUser> userList = userService.selectAllUser();
BigDecimal totalAmount = sysOrderService.selectAllOrderAmount(sysOrder);
for (SysOrder order : list) {
for (SysUser user : userList) {
@ -74,7 +78,7 @@ public class SysOrderController extends BaseController {
}
}
}
return getDataTable(list);
return getOrderDataTable(list, totalAmount.longValue());
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.custom.controller;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.custom.page.OrderTableDataInfo;
import java.util.List;
public class OrderBaseController extends BaseController {
protected OrderTableDataInfo getOrderDataTable(List<?> list, long totalAmount) {
OrderTableDataInfo rspData = new OrderTableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(list);
rspData.setTotalAmount(totalAmount);
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.custom.mapper;
import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.custom.domain.SysOrder;
@ -58,4 +59,11 @@ public interface SysOrderMapper
* @return 结果
*/
public int deleteSysOrderByIds(Long[] orderIds);
/**
* 计算所有订单总额
* @param sysOrder
* @return
*/
public BigDecimal selectAllOrderAmount(SysOrder sysOrder);
}

View File

@ -0,0 +1,91 @@
package com.ruoyi.custom.page;
import java.io.Serializable;
import java.util.List;
public class OrderTableDataInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总记录数
*/
private long total;
/**
* 列表数据
*/
private List<?> rows;
/**
* 消息状态码
*/
private int code;
/**
* 消息内容
*/
private String msg;
/**
* 金额总数
*/
private long totalAmount;
/**
* 表格数据对象
*/
public OrderTableDataInfo() {
}
/**
* 分页
*
* @param list 列表数据
* @param total 总记录数
*/
public OrderTableDataInfo(List<?> list, int total) {
this.rows = list;
this.total = total;
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public List<?> getRows() {
return rows;
}
public void setRows(List<?> rows) {
this.rows = rows;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public void setTotalAmount(long totalAmount) {
this.totalAmount = totalAmount;
}
public long getTotalAmount() {
return totalAmount;
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.custom.service;
import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.custom.domain.SysOrder;
@ -58,4 +59,11 @@ public interface ISysOrderService
* @return 结果
*/
public int deleteSysOrderById(Long orderId);
/**
* 计算所有订单总额
* @param sysOrder
* @return
*/
public BigDecimal selectAllOrderAmount(SysOrder sysOrder);
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.custom.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@ -91,4 +92,14 @@ public class SysOrderServiceImpl implements ISysOrderService {
public int deleteSysOrderById(Long orderId) {
return sysOrderMapper.deleteSysOrderById(orderId);
}
/**
* 计算所有订单总额
* @param sysOrder
* @return
*/
@Override
public BigDecimal selectAllOrderAmount(SysOrder sysOrder) {
return sysOrderMapper.selectAllOrderAmount(sysOrder);
}
}

View File

@ -40,6 +40,30 @@
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_serve_time') AS ser ON ser.dict_value = o.serve_time_id
</sql>
<select id="selectAllOrderAmount" parameterType="SysOrder" resultType="BigDecimal">
SELECT SUM(amount) FROM sys_order
<where>
<if test="orderId != null and orderId != ''">and order_id = #{orderId}</if>
<if test="customer != null and customer != ''">and customer = #{customer}</if>
<if test="phone != null and phone != ''">and phone = #{phone}</if>
<if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
<if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
<if test="afterSaleId != null ">and after_sale_id = #{afterSaleId}</if>
<if test="nutritionistId != null ">and nutritionist_id = #{nutritionistId}</if>
<if test="nutriAssisId != null ">and nutri_assis_id = #{nutriAssisId}</if>
<if test="accountId != null ">and account_id = #{accountId}</if>
<if test="plannerId != null ">and planner_id = #{plannerId}</if>
<if test="plannerAssisId != null ">and planner_assis_id = #{plannerAssisId}</if>
<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') &gt;= date_format(#{beginTime},'%y%m%d')</if>
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') &lt;= 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>
</where>
</select>
<select id="selectSysOrderList" parameterType="SysOrder" resultMap="SysOrderResult">
<include refid="selectSysOrderVo"/>
<where>

View File

@ -617,7 +617,7 @@
this.orderList = response.rows;
this.total = response.total;
this.loading = false;
this.totalAmount = response.rows.reduce((acc, cur) => cur.amount + acc, 0);
this.totalAmount = response.totalAmount;
});
},// 收款方式字典翻译
payTypeIdFormat(row, column) {