订单行为记录
This commit is contained in:
parent
7b0c54024e
commit
ccda079938
|
|
@ -3,6 +3,7 @@ package com.ghy.web.controller.order;
|
|||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.enums.FinancialDetailType;
|
||||
import com.ghy.common.enums.OrderBehaviorEnum;
|
||||
import com.ghy.common.enums.OrderStatus;
|
||||
import com.ghy.common.enums.PayStatus;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
|
|
@ -17,17 +18,11 @@ import com.ghy.goods.request.AppGoodsRequest;
|
|||
import com.ghy.goods.service.DeptGoodsCategoryService;
|
||||
import com.ghy.goods.service.GoodsService;
|
||||
import com.ghy.goods.service.GoodsStandardService;
|
||||
import com.ghy.order.domain.AfterServiceRecord;
|
||||
import com.ghy.order.domain.OrderDetail;
|
||||
import com.ghy.order.domain.OrderGoods;
|
||||
import com.ghy.order.domain.OrderMaster;
|
||||
import com.ghy.order.domain.*;
|
||||
import com.ghy.order.request.AppOrderAssignRequest;
|
||||
import com.ghy.order.request.AppOrderRequest;
|
||||
import com.ghy.order.request.SysOrderAssignRequest;
|
||||
import com.ghy.order.service.IAfterServiceRecordService;
|
||||
import com.ghy.order.service.OrderDetailService;
|
||||
import com.ghy.order.service.OrderGoodsService;
|
||||
import com.ghy.order.service.OrderMasterService;
|
||||
import com.ghy.order.service.*;
|
||||
import com.ghy.payment.domain.FinancialChangeRecord;
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.domain.FinancialMaster;
|
||||
|
|
@ -44,11 +39,9 @@ import com.ghy.worker.domain.WorkerCertification;
|
|||
import com.ghy.worker.service.IWorkerCertificationService;
|
||||
import com.ghy.worker.service.WorkerService;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -57,13 +50,13 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -75,73 +68,60 @@ import java.util.stream.Collectors;
|
|||
@RequestMapping("/order")
|
||||
public class OrderController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private DeptGoodsCategoryService deptGoodsCategoryService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private WorkerService workerService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderMasterService orderMasterService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private FinancialMasterService financialMasterService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private FinancialDetailService financialDetailService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private GoodsStandardService goodsStandardService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private CustomerAddressService addressService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private ISysAreaService sysAreaService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderFineRecordService orderFineRecordService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private FinancialChangeRecordService financialChangeRecordService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private IWorkerCertificationService workerCertificationService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private IAfterServiceRecordService afterServiceRecordService;
|
||||
@Resource
|
||||
private OrderBehaviorService orderBehaviorService;
|
||||
|
||||
/**
|
||||
* 可派单商品数量
|
||||
* */
|
||||
*/
|
||||
@PostMapping("/can/assign")
|
||||
@ResponseBody
|
||||
public AjaxResult canAssign(@RequestBody AppOrderAssignRequest request){
|
||||
public AjaxResult canAssign(@RequestBody AppOrderAssignRequest request) {
|
||||
try {
|
||||
// 找出原单的数量
|
||||
List<OrderGoods> orderGoodsList = orderGoodsService.selectByOrderMasterId(request.getOrderMasterId());
|
||||
List<OrderGoods> orderGoodsList = orderGoodsService.selectByOrderMasterId(request.getOrderMasterId());
|
||||
// 找出原单关联的细单的商品数量
|
||||
List<OrderDetail> orderDetailList = orderDetailService.selectByOrderMasterId(request.getOrderMasterId());
|
||||
for (OrderDetail orderDetail : orderDetailList){
|
||||
for (OrderDetail orderDetail : orderDetailList) {
|
||||
// 子单数量
|
||||
List<OrderGoods> orderDetailGoodsList = orderGoodsService.selectByOrderDetailId(orderDetail.getId());
|
||||
|
||||
// 计算剩余未分配的商品数量
|
||||
for (OrderGoods detailGoods : orderDetailGoodsList) {
|
||||
for(OrderGoods masterGoods : orderGoodsList){
|
||||
if(Objects.equals(masterGoods.getGoodsStandardId(), detailGoods.getGoodsStandardId())){
|
||||
for (OrderGoods masterGoods : orderGoodsList) {
|
||||
if (Objects.equals(masterGoods.getGoodsStandardId(), detailGoods.getGoodsStandardId())) {
|
||||
masterGoods.setGoodsNum(masterGoods.getGoodsNum() - detailGoods.getGoodsNum());
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +129,7 @@ public class OrderController extends BaseController {
|
|||
}
|
||||
//计算新单的数量
|
||||
return AjaxResult.success(orderGoodsList);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
|
@ -157,10 +137,10 @@ public class OrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 后台批量下单
|
||||
* */
|
||||
*/
|
||||
@PostMapping("/sys/order")
|
||||
@ResponseBody
|
||||
public AjaxResult sysOrder(@RequestBody SysOrderAssignRequest request){
|
||||
public AjaxResult sysOrder(@RequestBody SysOrderAssignRequest request) {
|
||||
try {
|
||||
// 新增商品 -- 商品不关联师傅,状态为不展示在商城页面
|
||||
|
||||
|
|
@ -174,13 +154,15 @@ public class OrderController extends BaseController {
|
|||
|
||||
// 生成财务细单 -- 平台扣点、提成
|
||||
return AjaxResult.success("下单成功");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
|
||||
return AjaxResult.error("系统异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分配订单
|
||||
*/
|
||||
@PostMapping("/assign")
|
||||
@ResponseBody
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
@ -197,11 +179,11 @@ public class OrderController extends BaseController {
|
|||
Assert.notNull(acceptWorker, "查询接单师傅信息失败");
|
||||
om.setAllSelfAssigned(0);
|
||||
// 校验接单师傅和派单师傅是不是同一个Team
|
||||
if(!om.getWorkerId().equals(request.getWorkerId())){
|
||||
if (!om.getWorkerId().equals(request.getWorkerId())) {
|
||||
fm.setServerMoney(fm.getServerMoney().subtract(request.getTotalPay()));
|
||||
boolean checkInTeam = workerService.checkInTeam(assignWorker.getWorkerId(), acceptWorker.getWorkerId());
|
||||
Assert.isTrue(checkInTeam, "接单师傅不在本团队");
|
||||
}else {
|
||||
} else {
|
||||
// 自己接单 -- 计算剩余金额
|
||||
om.setAllSelfAssigned(1);
|
||||
BigDecimal realPay = fm.getPayMoney();
|
||||
|
|
@ -217,7 +199,7 @@ public class OrderController extends BaseController {
|
|||
}
|
||||
|
||||
// 判断是否全部派完
|
||||
if(request.getIsAll() == 1){
|
||||
if (request.getIsAll() == 1) {
|
||||
om.setHasDispatchedAll(1);
|
||||
}
|
||||
orderMasterService.updateOrderMaster(om);
|
||||
|
|
@ -260,6 +242,11 @@ public class OrderController extends BaseController {
|
|||
|
||||
// 更新财务主单金额
|
||||
financialMasterService.updateFinancialMaster(fm);
|
||||
|
||||
OrderBehavior orderBehavior = new OrderBehavior().setOrderMasterId(om.getId()).setOrderMasterCode(om.getCode())
|
||||
.setWorkerId(assignWorker.getWorkerId()).setWorkerName(assignWorker.getName()).setBehavior(OrderBehaviorEnum.ASSIGN_ORDER);
|
||||
orderBehaviorService.insert(orderBehavior);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -328,7 +315,7 @@ public class OrderController extends BaseController {
|
|||
// createFinancialDetail(goodsList.get(0).getDeptGoodsCategoryId(), deptId, customer, payMoney, financialMaster);
|
||||
|
||||
//生成财务子单
|
||||
createFinancialDetail(appGoodsList,deptId, customer, payMoney, financialMaster);
|
||||
createFinancialDetail(appGoodsList, deptId, customer, payMoney, financialMaster);
|
||||
|
||||
// 生成商品订单
|
||||
Map<Long, GoodsStandard> goodsMap = goodsList.stream().filter(Objects::nonNull)
|
||||
|
|
@ -343,7 +330,7 @@ public class OrderController extends BaseController {
|
|||
return AjaxResult.success(orderMaster);
|
||||
}
|
||||
|
||||
private void createFinancialDetail(List<AppGoodsRequest> appGoodsList, Long deptId, Customer customer, BigDecimal serverMoney, FinancialMaster financialMaster){
|
||||
private void createFinancialDetail(List<AppGoodsRequest> appGoodsList, Long deptId, Customer customer, BigDecimal serverMoney, FinancialMaster financialMaster) {
|
||||
// 平台
|
||||
BigDecimal deptMoney = BigDecimal.ZERO;
|
||||
// 一级分销
|
||||
|
|
@ -354,12 +341,12 @@ public class OrderController extends BaseController {
|
|||
BigDecimal threeMoney = BigDecimal.ZERO;
|
||||
// 截流扣点
|
||||
BigDecimal specialMoney = BigDecimal.ZERO;
|
||||
for(AppGoodsRequest goodsRequest : appGoodsList){
|
||||
for (AppGoodsRequest goodsRequest : appGoodsList) {
|
||||
// 商品规格-提成额
|
||||
GoodsStandard goodsStandard = goodsStandardService.selectById(goodsRequest.getGoodsStandardId());
|
||||
// 扣点设置类目
|
||||
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId());
|
||||
for (int index = 0; index < goodsRequest.getNum(); index++){
|
||||
for (int index = 0; index < goodsRequest.getNum(); index++) {
|
||||
// 一级分销 = 商品单价 * 扣点比例
|
||||
oneMoney = oneMoney
|
||||
.add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(Double.parseDouble(deptGoodsCategory.getOneRate()))));
|
||||
|
|
@ -508,7 +495,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 订单统计
|
||||
* */
|
||||
*/
|
||||
@PostMapping("/app/statistics")
|
||||
@ResponseBody
|
||||
public AjaxResult orderStatistics(@RequestBody OrderStatisticsRequest request) {
|
||||
|
|
@ -566,7 +553,7 @@ public class OrderController extends BaseController {
|
|||
orderListRequest.setIsMonitoredOrder(true);
|
||||
orderListRequest.setAllSelfAssigned(0);
|
||||
AjaxResult afterListRes = this.appMixAfterList(orderListRequest);
|
||||
List<AfterServiceRecord> afterList = (List<AfterServiceRecord>)afterListRes.get("data");
|
||||
List<AfterServiceRecord> afterList = (List<AfterServiceRecord>) afterListRes.get("data");
|
||||
response.setAfterListNum(afterList.size());
|
||||
// 统计超时单量
|
||||
orderListRequest = new OrderListRequest();
|
||||
|
|
@ -575,7 +562,7 @@ public class OrderController extends BaseController {
|
|||
orderListRequest.setIsMonitoredOrder(true);
|
||||
orderListRequest.setAllSelfAssigned(0);
|
||||
AjaxResult overTimeRes = this.appMixOrderList(orderListRequest);
|
||||
List<OrderListResponse> overTimeList = (List)overTimeRes.get("data");
|
||||
List<OrderListResponse> overTimeList = (List) overTimeRes.get("data");
|
||||
response.setOverTimeOrderNum(overTimeList.size());
|
||||
// 统计今日单量
|
||||
LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
||||
|
|
@ -602,7 +589,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
/**
|
||||
* 查询主单子单的混合列表,根据预约时间倒序排列,请求参数中的师傅id不能为空
|
||||
* */
|
||||
*/
|
||||
@PostMapping("/app/mix/order/list")
|
||||
@ResponseBody
|
||||
public AjaxResult appMixOrderList(@RequestBody OrderListRequest orderListRequest) {
|
||||
|
|
@ -625,13 +612,13 @@ public class OrderController extends BaseController {
|
|||
if (orderListRequest.getIsOverTime() != null && orderListRequest.getIsOverTime()) {
|
||||
// 需要排除同个师傅的主单子单同时出现
|
||||
List<OrderListResponse> filteredMasterList = new ArrayList<OrderListResponse>();
|
||||
for (OrderListResponse master: masterList) {
|
||||
for (OrderListResponse master : masterList) {
|
||||
boolean isKeep = false;
|
||||
// 查询该主单下所有售后中的子单
|
||||
OrderDetail detailAfterListOfMasterQry = new OrderDetail();
|
||||
detailAfterListOfMasterQry.setOrderMasterCode(master.getOrderMasterCode());
|
||||
List<OrderListResponse> detailListOfMasters = this.getDetailList(detailAfterListOfMasterQry);
|
||||
for (OrderListResponse detailListOfMaster: detailListOfMasters) {
|
||||
for (OrderListResponse detailListOfMaster : detailListOfMasters) {
|
||||
if (!detailListOfMaster.getWorkerId().equals(orderListRequest.getWorkerId())) {
|
||||
isKeep = true;
|
||||
break;
|
||||
|
|
@ -677,13 +664,13 @@ public class OrderController extends BaseController {
|
|||
List<OrderListResponse> masterList = this.getMasterAfterList(orderMasterReq);
|
||||
// 需要排除同个师傅的主单子单同时出现
|
||||
List<OrderListResponse> filteredMasterList = new ArrayList<OrderListResponse>();
|
||||
for (OrderListResponse master: masterList) {
|
||||
for (OrderListResponse master : masterList) {
|
||||
boolean isKeep = false;
|
||||
// 查询该主单下所有售后中的子单
|
||||
OrderDetail detailAfterListOfMasterQry = new OrderDetail();
|
||||
detailAfterListOfMasterQry.setOrderMasterCode(master.getOrderMasterCode());
|
||||
List<OrderListResponse> detailAfterListOfMasters = this.getDetailAfterList(detailAfterListOfMasterQry);
|
||||
for (OrderListResponse detailAfterListOfMaster: detailAfterListOfMasters) {
|
||||
for (OrderListResponse detailAfterListOfMaster : detailAfterListOfMasters) {
|
||||
if (!detailAfterListOfMaster.getWorkerId().equals(orderListRequest.getWorkerId())) {
|
||||
isKeep = true;
|
||||
break;
|
||||
|
|
@ -713,31 +700,31 @@ public class OrderController extends BaseController {
|
|||
afterServiceRecord.setExcludeAfterServiceFinished(Boolean.TRUE);
|
||||
List<AfterServiceRecord> afterServiceRecordList = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecord);
|
||||
// 踢重后的子单ids
|
||||
List<Long> detailIds = afterServiceRecordList.stream().map(AfterServiceRecord::getOrderDetailId).distinct().collect(Collectors.toList());
|
||||
List<Long> detailIds = afterServiceRecordList.stream().map(AfterServiceRecord::getOrderDetailId).distinct().collect(Collectors.toList());
|
||||
StringBuilder orderDetailIds = new StringBuilder();
|
||||
OrderDetail orderDetail = new OrderDetail();
|
||||
orderDetail.setCustomerId(orderMaster.getCustomerId());
|
||||
orderDetail.setDeptId(orderMaster.getDeptId());
|
||||
detailIds.forEach(id->{
|
||||
detailIds.forEach(id -> {
|
||||
orderDetailIds.append(id).append(",");
|
||||
});
|
||||
String ids = orderDetailIds.toString();
|
||||
if(StringUtils.isNotEmpty(ids)){
|
||||
orderDetail.setOrderDetailIds(ids.substring(0, ids.length()-1));
|
||||
}else {
|
||||
if (StringUtils.isNotEmpty(ids)) {
|
||||
orderDetail.setOrderDetailIds(ids.substring(0, ids.length() - 1));
|
||||
} else {
|
||||
orderDetail.setOrderDetailIds("0");
|
||||
}
|
||||
// 所有售后的子单
|
||||
List<OrderDetail> orderDetailList = orderDetailService.selectOrderDetailList(orderDetail);
|
||||
StringBuilder orderMasterIds = new StringBuilder();
|
||||
orderDetailList.stream().map(OrderDetail::getOrderMasterId).distinct()
|
||||
.collect(Collectors.toList()).forEach(id->{
|
||||
orderMasterIds.append(id).append(",");
|
||||
});
|
||||
.collect(Collectors.toList()).forEach(id -> {
|
||||
orderMasterIds.append(id).append(",");
|
||||
});
|
||||
String orderIds = orderMasterIds.toString();
|
||||
if(StringUtils.isNotEmpty(orderIds)){
|
||||
orderMaster.setOrderMasterIds(orderIds.substring(0, orderIds.length()-1));
|
||||
}else {
|
||||
if (StringUtils.isNotEmpty(orderIds)) {
|
||||
orderMaster.setOrderMasterIds(orderIds.substring(0, orderIds.length() - 1));
|
||||
} else {
|
||||
orderMaster.setOrderMasterIds("0");
|
||||
}
|
||||
|
||||
|
|
@ -798,7 +785,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
AfterServiceRecord afterServiceRecordQry = new AfterServiceRecord();
|
||||
afterServiceRecordQry.setOrderDetailId(detail.getId());
|
||||
List<AfterServiceRecord> records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry);
|
||||
List<AfterServiceRecord> records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry);
|
||||
afterServiceRecords.addAll(records);
|
||||
});
|
||||
|
||||
|
|
@ -846,17 +833,17 @@ public class OrderController extends BaseController {
|
|||
AfterServiceRecord afterServiceRecord = new AfterServiceRecord();
|
||||
afterServiceRecord.setExcludeAfterServiceFinished(Boolean.TRUE);
|
||||
List<AfterServiceRecord> afterServiceRecordList = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecord);
|
||||
Map<Long, List<AfterServiceRecord>> detailRecordMap = afterServiceRecordList.stream().collect(Collectors.groupingBy(record->record.getOrderDetailId()));
|
||||
Map<Long, List<AfterServiceRecord>> detailRecordMap = afterServiceRecordList.stream().collect(Collectors.groupingBy(record -> record.getOrderDetailId()));
|
||||
// 踢重后的子单ids
|
||||
List<Long> detailIds = afterServiceRecordList.stream().map(AfterServiceRecord::getOrderDetailId).distinct().collect(Collectors.toList());
|
||||
List<Long> detailIds = afterServiceRecordList.stream().map(AfterServiceRecord::getOrderDetailId).distinct().collect(Collectors.toList());
|
||||
StringBuilder orderDetailIds = new StringBuilder();
|
||||
detailIds.forEach(id->{
|
||||
detailIds.forEach(id -> {
|
||||
orderDetailIds.append(id).append(",");
|
||||
});
|
||||
String ids = orderDetailIds.toString();
|
||||
if(StringUtils.isNotEmpty(ids)){
|
||||
orderDetail.setOrderDetailIds(ids.substring(0, ids.length()-1));
|
||||
}else {
|
||||
if (StringUtils.isNotEmpty(ids)) {
|
||||
orderDetail.setOrderDetailIds(ids.substring(0, ids.length() - 1));
|
||||
} else {
|
||||
orderDetail.setOrderDetailIds("0");
|
||||
}
|
||||
List<OrderListResponse> orderListResponses = new ArrayList<>();
|
||||
|
|
@ -924,7 +911,7 @@ public class OrderController extends BaseController {
|
|||
OrderTimeoutRecord orderTimeoutRecord = orderFineRecordService.selectByDetailIdAndStatus(detail.getId(), detail.getOrderStatus());
|
||||
Boolean isOverTime = orderTimeoutRecord == null ? false : true;
|
||||
|
||||
if(this.checkIsOnlyServer(orderMaster.getId(), detail.getWorkerId())){
|
||||
if (this.checkIsOnlyServer(orderMaster.getId(), detail.getWorkerId())) {
|
||||
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(detail.getOrderMasterId());
|
||||
BigDecimal workerFee = financialMaster.getPayMoney();
|
||||
List<FinancialDetail> financialDetailList = financialDetailService.selectByFinancialMasterId(financialMaster.getId());
|
||||
|
|
@ -935,7 +922,7 @@ public class OrderController extends BaseController {
|
|||
}
|
||||
orderListResponse.setPayMoney(workerFee);
|
||||
orderListResponse.setIsOnlyServ(Boolean.TRUE);
|
||||
}else {
|
||||
} else {
|
||||
orderListResponse.setPayMoney(detailPayMoney);
|
||||
orderListResponse.setIsOnlyServ(Boolean.FALSE);
|
||||
}
|
||||
|
|
@ -1012,7 +999,7 @@ public class OrderController extends BaseController {
|
|||
// 查询加价价格
|
||||
BigDecimal changeMoney = BigDecimal.ZERO;
|
||||
List<FinancialChangeRecord> changeRecords = financialChangeRecordService.selectByDetailIds(StringUtils.join(orderDetailIds, ","));
|
||||
for (FinancialChangeRecord changeRecord: changeRecords) {
|
||||
for (FinancialChangeRecord changeRecord : changeRecords) {
|
||||
if (PayStatus.WAIT_PAY.getCode().equals(changeRecord.getPayStatus())) {
|
||||
changeMoney = changeMoney.add(changeRecord.getChangeMoney());
|
||||
}
|
||||
|
|
@ -1036,7 +1023,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
AfterServiceRecord afterServiceRecordQry = new AfterServiceRecord();
|
||||
afterServiceRecordQry.setOrderDetailId(detail.getId());
|
||||
List<AfterServiceRecord> records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry);
|
||||
List<AfterServiceRecord> records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry);
|
||||
afterServiceRecords.addAll(records);
|
||||
});
|
||||
if (Boolean.TRUE.equals(orderMaster.getIsOverTime()) && timeoutRecords.size() == 0) {
|
||||
|
|
@ -1180,22 +1167,22 @@ public class OrderController extends BaseController {
|
|||
return orderListResponses;
|
||||
}
|
||||
|
||||
private boolean checkIsOnlyServer(Long orderMasterId, Long workId){
|
||||
private boolean checkIsOnlyServer(Long orderMasterId, Long workId) {
|
||||
// 找出原单的数量
|
||||
List<OrderGoods> orderGoodsList = orderGoodsService.selectByOrderMasterId(orderMasterId);
|
||||
List<OrderGoods> orderGoodsList = orderGoodsService.selectByOrderMasterId(orderMasterId);
|
||||
// 找出原单关联的细单的商品数量
|
||||
List<OrderDetail> orderDetailList = orderDetailService.selectByOrderMasterId(orderMasterId);
|
||||
for (OrderDetail detail : orderDetailList){
|
||||
for (OrderDetail detail : orderDetailList) {
|
||||
// 非一个师傅接单
|
||||
if(!workId.equals(detail.getWorkerId())){
|
||||
if (!workId.equals(detail.getWorkerId())) {
|
||||
return false;
|
||||
}
|
||||
// 子单数量
|
||||
List<OrderGoods> orderDetailGoodsList = orderGoodsService.selectByOrderDetailId(detail.getId());
|
||||
// 计算剩余未分配的商品数量
|
||||
for (OrderGoods detailGoods : orderDetailGoodsList) {
|
||||
for(OrderGoods masterGoods : orderGoodsList){
|
||||
if(Objects.equals(masterGoods.getGoodsStandardId(), detailGoods.getGoodsStandardId())){
|
||||
for (OrderGoods masterGoods : orderGoodsList) {
|
||||
if (Objects.equals(masterGoods.getGoodsStandardId(), detailGoods.getGoodsStandardId())) {
|
||||
masterGoods.setGoodsNum(masterGoods.getGoodsNum() - detailGoods.getGoodsNum());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ import com.ghy.common.constant.UserConstants;
|
|||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.core.page.TableDataInfo;
|
||||
import com.ghy.common.enums.BusinessType;
|
||||
import com.ghy.common.enums.ImgType;
|
||||
import com.ghy.common.enums.OrderStatus;
|
||||
import com.ghy.common.enums.PayStatus;
|
||||
import com.ghy.common.enums.*;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.common.utils.poi.ExcelUtil;
|
||||
|
|
@ -48,7 +45,6 @@ import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.util.Assert;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
|
@ -74,40 +70,42 @@ public class OrderDetailController extends BaseController {
|
|||
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderMasterService orderMasterService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private WorkerService workerService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private CustomerAddressService addressService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private ISysAreaService sysAreaService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private GoodsImgsService goodsImgsService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private GoodsStandardService goodsStandardService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private FinancialDetailService financialDetailService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private OrderFineRecordService orderFineRecordService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private IAfterServiceRecordService afterServiceRecordService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private FinancialChangeRecordService financialChangeRecordService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private IWorkerCertificationService workerCertificationService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private IOrderAssessLabelService orderAssessLabelService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private FinancialMasterService financialMasterService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private ISysDeptConfigService sysDeptConfigService;
|
||||
@Resource
|
||||
private OrderBehaviorService orderBehaviorService;
|
||||
|
||||
@RequiresPermissions("order:detail:view")
|
||||
@GetMapping()
|
||||
|
|
@ -796,17 +794,22 @@ public class OrderDetailController extends BaseController {
|
|||
return AjaxResult.success("发起成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝订单
|
||||
*/
|
||||
@PostMapping("/app/order/reject")
|
||||
@ResponseBody
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult rejectDetailOrder(@RequestBody OrderDetail orderDetail) {
|
||||
// 查询子单信息
|
||||
OrderDetail detailInfo = this.orderDetailService.selectById(orderDetail.getId());
|
||||
// 查询订单信息
|
||||
OrderDetail od = this.orderDetailService.selectById(orderDetail.getId());
|
||||
OrderMaster om = orderMasterService.selectById(od.getOrderMasterId());
|
||||
Worker worker = workerService.selectById(od.getWorkerId());
|
||||
// 删除子单
|
||||
orderDetailService.deleteOrderDetailByIds(orderDetail.getId().toString());
|
||||
FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(detailInfo.getId());
|
||||
FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(od.getId());
|
||||
// 财务子单金额返还给主单
|
||||
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(detailInfo.getOrderMasterId());
|
||||
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(od.getOrderMasterId());
|
||||
financialMaster.setServerMoney(financialMaster.getServerMoney().add(financialDetail.getPayMoney()));
|
||||
financialMasterService.updateFinancialMaster(financialMaster);
|
||||
// 删除子财务单
|
||||
|
|
@ -814,7 +817,7 @@ public class OrderDetailController extends BaseController {
|
|||
// 退回旧商品
|
||||
// List<OrderGoods> goodsList = orderGoodsService.selectByOrderDetailId(orderDetail.getId());
|
||||
// goodsList.forEach(orderGoods -> {
|
||||
// List<OrderGoods> masterGoods = orderGoodsService.selectByOrderMasterId(detailInfo.getOrderMasterId());
|
||||
// List<OrderGoods> masterGoods = orderGoodsService.selectByOrderMasterId(od.getOrderMasterId());
|
||||
// masterGoods.forEach(master->{
|
||||
// if(master.getGoodsStandardId().equals(orderGoods.getGoodsStandardId())){
|
||||
// master.setServerGoodsNum(master.getServerGoodsNum()-orderGoods.getGoodsNum());
|
||||
|
|
@ -825,10 +828,10 @@ public class OrderDetailController extends BaseController {
|
|||
// 删除派单记录
|
||||
orderGoodsService.deleteByOrderDetailId(orderDetail.getId());
|
||||
OrderMaster orderMaster2Update = new OrderMaster();
|
||||
orderMaster2Update.setId(detailInfo.getOrderMasterId());
|
||||
orderMaster2Update.setId(od.getOrderMasterId());
|
||||
orderMaster2Update.setOrderStatus(OrderStatus.PLAIN.code());
|
||||
// 查询是否还有派单记录,没有的话需要重置主单是否自己承接的字段为NULL
|
||||
List<OrderGoods> existOrderGoods = orderGoodsService.selectByOrderMasterId(detailInfo.getOrderMasterId());
|
||||
List<OrderGoods> existOrderGoods = orderGoodsService.selectByOrderMasterId(od.getOrderMasterId());
|
||||
if (CollectionUtils.isNotEmpty(existOrderGoods)) {
|
||||
orderMaster2Update.setResetAllSelfAssigned(true);
|
||||
}
|
||||
|
|
@ -836,6 +839,10 @@ public class OrderDetailController extends BaseController {
|
|||
orderMaster2Update.setHasDispatchedAll(0);
|
||||
orderMasterService.updateOrderMaster(orderMaster2Update);
|
||||
|
||||
OrderBehavior orderBehavior = new OrderBehavior().setOrderMasterId(om.getId()).setOrderMasterCode(om.getCode())
|
||||
.setWorkerId(worker.getWorkerId()).setWorkerName(worker.getName()).setBehavior(OrderBehaviorEnum.REFUSE_ORDER);
|
||||
orderBehaviorService.insert(orderBehavior);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.ghy.common.enums;
|
||||
|
||||
/**
|
||||
* 用户行为枚举
|
||||
*
|
||||
* @author HH
|
||||
*/
|
||||
|
||||
public enum OrderBehaviorEnum {
|
||||
|
||||
/**
|
||||
* 接受订单
|
||||
*/
|
||||
ACCEPT_ORDER("ACCEPT_ORDER", "接受订单"),
|
||||
/**
|
||||
* 拒绝订单
|
||||
*/
|
||||
REFUSE_ORDER("REFUSE_ORDER", "拒绝订单"),
|
||||
/**
|
||||
* 完成订单
|
||||
*/
|
||||
FINISH_ORDER("FINISH_ORDER", "完成订单"),
|
||||
/**
|
||||
* 派单
|
||||
*/
|
||||
ASSIGN_ORDER("ASSIGN_ORDER", "派单");
|
||||
|
||||
public final String code;
|
||||
public final String desc;
|
||||
|
||||
OrderBehaviorEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.ghy.order.domain;
|
||||
|
||||
|
||||
import com.ghy.common.enums.OrderBehaviorEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单行为 order_behavior
|
||||
*
|
||||
* @author HH
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrderBehavior {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
private Long workerId;
|
||||
@NotBlank
|
||||
private String workerName;
|
||||
|
||||
@NotNull
|
||||
private Long orderMasterId;
|
||||
@NotBlank
|
||||
private String orderMasterCode;
|
||||
|
||||
private Long orderDetailId;
|
||||
private String orderDetailCode;
|
||||
|
||||
@NotNull
|
||||
private OrderBehaviorEnum behavior;
|
||||
|
||||
private LocalDateTime behaviorTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ghy.order.mapper;
|
||||
|
||||
import com.ghy.order.domain.OrderBehavior;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author HH
|
||||
*/
|
||||
public interface OrderBehaviorMapper {
|
||||
|
||||
int insert(OrderBehavior orderBehavior);
|
||||
|
||||
int delete(Long id);
|
||||
|
||||
int batchDelete(Set<Long> ids);
|
||||
|
||||
OrderBehavior selectById(Long id);
|
||||
|
||||
List<OrderBehavior> selectByIds(Set<Long> ids);
|
||||
|
||||
List<OrderBehavior> select(OrderBehavior orderBehavior);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.ghy.order.service;
|
||||
|
||||
import com.ghy.order.domain.OrderBehavior;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author HH
|
||||
*/
|
||||
public interface OrderBehaviorService {
|
||||
|
||||
int insert(OrderBehavior orderBehavior);
|
||||
|
||||
int delete(Long id);
|
||||
|
||||
int batchDelete(Set<Long> ids);
|
||||
|
||||
OrderBehavior selectById(Long id);
|
||||
|
||||
List<OrderBehavior> selectByIds(Set<Long> ids);
|
||||
|
||||
List<OrderBehavior> select(OrderBehavior orderBehavior);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.ghy.order.service.impl;
|
||||
|
||||
import com.ghy.order.domain.OrderBehavior;
|
||||
import com.ghy.order.mapper.OrderBehaviorMapper;
|
||||
import com.ghy.order.service.OrderBehaviorService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author HH
|
||||
*/
|
||||
@Service
|
||||
public class OrderBehaviorServiceImpl implements OrderBehaviorService {
|
||||
|
||||
@Resource
|
||||
private OrderBehaviorMapper orderBehaviorMapper;
|
||||
|
||||
@Override
|
||||
public int insert(@Valid OrderBehavior orderBehavior) {
|
||||
return orderBehaviorMapper.insert(orderBehavior);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return orderBehaviorMapper.delete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(Set<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return 0;
|
||||
}
|
||||
return orderBehaviorMapper.batchDelete(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderBehavior selectById(Long id) {
|
||||
if (id == null || id < 1) {
|
||||
return null;
|
||||
}
|
||||
return orderBehaviorMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderBehavior> selectByIds(Set<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return orderBehaviorMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderBehavior> select(OrderBehavior orderBehavior) {
|
||||
return orderBehaviorMapper.select(orderBehavior);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?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">
|
||||
<mapper namespace="com.ghy.order.mapper.OrderBehaviorMapper">
|
||||
|
||||
<resultMap id="ColumnMap" type="com.ghy.order.domain.OrderBehavior">
|
||||
<id property="id" column="id"/>
|
||||
<result property="workerId" column="worker_id"/>
|
||||
<result property="workerName" column="worker_name"/>
|
||||
<result property="orderMasterId" column="order_master_id"/>
|
||||
<result property="orderMasterCode" column="order_master_code"/>
|
||||
<result property="orderDetailId" column="order_detail_id"/>
|
||||
<result property="orderDetailCode" column="order_detail_code"/>
|
||||
<result property="behavior" column="behavior"/>
|
||||
<result property="behaviorTime" column="behavior_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectColumns">
|
||||
SELECT id,
|
||||
worker_id,
|
||||
worker_name,
|
||||
order_master_id,
|
||||
order_master_code,
|
||||
order_detail_id,
|
||||
order_detail_code,
|
||||
behavior,
|
||||
behavior_time
|
||||
FROM order_behavior
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.ghy.order.domain.OrderBehavior" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO order_behavior(
|
||||
worker_id, worker_name, order_master_id, order_master_code,
|
||||
order_detail_id, order_detail_code, behavior, behavior_time
|
||||
)VALUES(
|
||||
#{workerId}, #{workerName}, #{orderMasterId}, #{orderMasterCode},
|
||||
#{orderDetailId}, #{orderDetailCode}, #{behavior}, NOW())
|
||||
</insert>
|
||||
|
||||
<select id="select" parameterType="com.ghy.order.domain.OrderBehavior" resultMap="ColumnMap">
|
||||
<include refid="selectColumns"/>
|
||||
<where>
|
||||
<if test="workerId != null and workerId != 0">
|
||||
AND worker_id = #{workerId}
|
||||
</if>
|
||||
<if test="orderMasterId != null and orderMasterId != 0">
|
||||
AND order_master_id = #{orderMasterId}
|
||||
</if>
|
||||
<if test="orderMasterCode != null and orderMasterCode != ''">
|
||||
AND order_master_code = #{orderMasterCode}
|
||||
</if>
|
||||
<if test="orderDetailId != null and orderDetailId != 0">
|
||||
AND order_detail_id = #{orderDetailId}
|
||||
</if>
|
||||
<if test="orderDetailCode != null and orderDetailCode != ''">
|
||||
AND order_detail_code = #{orderDetailCode}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectById" parameterType="long" resultMap="ColumnMap">
|
||||
<include refid="selectColumns"/> WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultMap="ColumnMap">
|
||||
<include refid="selectColumns"/> WHERE id IN
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="delete" parameterType="Long">
|
||||
DELETE FROM order_behavior WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="batchDelete">
|
||||
DELETE FROM order_behavior WHERE id IN
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
#{userId},
|
||||
<if test="templateName != null and templateName != 0">#{templateName},</if>
|
||||
<if test="goodsBrand != null and goodsBrand != 0">#{goodsBrand},</if>
|
||||
<if test="goodsSpecification != null and goodsSpecification != 0">goods_specification = #{goodsSpecification},</if>
|
||||
<if test="goodsSpecification != null and goodsSpecification != 0">#{goodsSpecification},</if>
|
||||
<if test="videoUrl != null and videoUrl != 0">#{videoUrl},</if>
|
||||
<if test="imageUrl != null and imageUrl != 0">#{imageUrl},</if>
|
||||
<if test="addressId != null and addressId != 0">#{addressId},</if>
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
<include refid="selectColumns"/> WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="com.ghy.order.domain.OrderTemplate">
|
||||
<select id="selectByIds" resultMap="ColumnMap">
|
||||
<include refid="selectColumns"/> WHERE id IN
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
|
|
|
|||
Loading…
Reference in New Issue