| | |
| | | package com.jilongda.manage.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.manage.model.TLineUp; |
| | | import com.jilongda.manage.authority.model.SecUser; |
| | | import com.jilongda.manage.authority.service.SecUserService; |
| | | import com.jilongda.manage.dto.AccountDetailDTO; |
| | | import com.jilongda.manage.model.*; |
| | | import com.jilongda.manage.query.TLineUpQuery; |
| | | import com.jilongda.manage.query.TOrderAccountingQuery; |
| | | import com.jilongda.manage.service.TOrderAccountingService; |
| | | import com.jilongda.manage.service.TOrderService; |
| | | import com.jilongda.manage.service.TStoreService; |
| | | import com.jilongda.manage.service.*; |
| | | import com.jilongda.manage.utils.LoginInfoUtil; |
| | | import com.jilongda.manage.vo.TOrderAccountVO; |
| | | import com.jilongda.manage.vo.TOrderVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/t-order-accounting") |
| | | public class TOrderAccountingController { |
| | | @Autowired |
| | | private SecUserService secUserService; |
| | | @Autowired |
| | | private TStoreService storeService; |
| | | @Autowired |
| | | private TOrderService orderService; |
| | | @Autowired |
| | | private TOrderAccountingService orderAccountingService; |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @Autowired |
| | | private TOptometryDetailService optometryDetailService; |
| | | @Autowired |
| | | private TOrderGoodsService orderGoodsService; |
| | | @Autowired |
| | | private SecFeeItemsService feeItemsService; |
| | | @Autowired |
| | | private LoginInfoUtil loginInfoUtil; |
| | | @Autowired |
| | | private TOptometryService optometryService; |
| | | |
| | | @ApiOperation(value = "核算订单分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult<PageInfo<TOrderVO>> pageList(@RequestBody TOrderAccountingQuery query) { |
| | |
| | | } |
| | | @ApiOperation(value = "核算详情页面") |
| | | @GetMapping(value = "/detail") |
| | | public ApiResult detail(Integer id) { |
| | | |
| | | return ApiResult.success(); |
| | | public ApiResult<TOrderAccountVO> detail(Integer id) { |
| | | TOrderAccountVO res = new TOrderAccountVO(); |
| | | TOrder byId = orderService.getById(id); |
| | | if (byId.getUserId()!=null){ |
| | | TAppUser byId1 = appUserService.getById(byId.getUserId()); |
| | | if(byId1!=null){ |
| | | res.setName(byId1.getName()); |
| | | res.setPhone(byId1.getPhone()); |
| | | res.setRealName(byId1.getRealName()); |
| | | res.setGender(byId1.getGender()); |
| | | } |
| | | }else { |
| | | res.setPhone(byId.getPhone()); |
| | | res.setAge(byId.getAge()); |
| | | res.setRealName(byId.getRealName()); |
| | | res.setGender(byId.getGender()); |
| | | } |
| | | List<TOrderItems> list1 = orderItemsService.lambdaQuery().eq(TOrderItems::getOrderId, id).list(); |
| | | for (TOrderItems orderItems : list1) { |
| | | SecFeeItems secFeeItems = feeItemsService.getById(orderItems.getItemsId()); |
| | | orderItems.setItemsName(secFeeItems.getName()); |
| | | } |
| | | res.setItemsId(byId.getItemsId()); |
| | | res.setUserId(byId.getUserId()); |
| | | res.setOptometryId(byId.getOptometryId()); |
| | | List<TOptometryDetail> list = optometryDetailService.lambdaQuery().eq(TOptometryDetail::getOrderId, id) |
| | | .eq(TOptometryDetail::getType, 1).list(); |
| | | res.setOptometryDetails(list); |
| | | List<TOrderGoods> orderGoods = orderGoodsService.lambdaQuery() |
| | | .eq(TOrderGoods::getOrderId, id).list(); |
| | | BigDecimal goodsMoney = new BigDecimal("0"); |
| | | BigDecimal costMoney = new BigDecimal("0"); |
| | | BigDecimal constConfirm = new BigDecimal("0"); |
| | | for (TOrderGoods orderGood : orderGoods) { |
| | | goodsMoney =goodsMoney.add(orderGood.getGoodsMoney()); |
| | | costMoney=costMoney.add(orderGood.getCost()==null?new BigDecimal("0"):orderGood.getCost()); |
| | | constConfirm=constConfirm.add(orderGood.getConstConfirm()==null?new BigDecimal("0"):orderGood.getConstConfirm()); |
| | | } |
| | | res.setOrderGoods(orderGoods); |
| | | TStore byId1 = storeService.getById(byId.getStoreId()); |
| | | res.setStoreName(byId1.getName()); |
| | | res.setOrderMoney(goodsMoney); |
| | | res.setCouponMoney(byId.getCouponMoney()); |
| | | res.setPayMoney(byId.getPayMoney()); |
| | | res.setRealPayMoney(byId.getPayMoney()); |
| | | SecFeeItems one1 = feeItemsService.lambdaQuery().eq(SecFeeItems::getId, byId.getItemsId()) |
| | | .one(); |
| | | res.setPayType(one1.getName()); |
| | | res.setProfitMoney(byId.getProfitMoney()); |
| | | res.setProfitRating(byId.getProfitRating()); |
| | | List<TOrderItems> orderItems = orderItemsService.list(Wrappers.lambdaQuery(TOrderItems.class) |
| | | .eq(TOrderItems::getOrderId, id)); |
| | | res.setOrderItems(orderItems); |
| | | return ApiResult.success(res); |
| | | } |
| | | @Autowired |
| | | private TOrderItemsService orderItemsService; |
| | | @ApiOperation(value = "确认核算操作") |
| | | @PostMapping(value = "/confirm") |
| | | public ApiResult confirm(@RequestBody TOrderAccountingQuery query) { |
| | | if (StringUtils.hasLength(query.getStartTime())){ |
| | | query.setStartTime(query.getStartTime()+" 00:00:00"); |
| | | query.setEndTime(query.getEndTime()+" 23:59:59"); |
| | | } |
| | | PageInfo<TOrderVO> res = orderAccountingService.pageList(query); |
| | | return ApiResult.success(res); |
| | | public ApiResult confirm(@RequestBody AccountDetailDTO dto) { |
| | | List<TOrderGoods> list = dto.getList(); |
| | | orderGoodsService.updateBatchById(list); |
| | | TOrder byId = orderService.getById(dto.getId()); |
| | | byId.setPayTypeName(dto.getPayTypeName()); |
| | | byId.setPayMoney(dto.getPayMoney()); |
| | | byId.setCommissionMoney(dto.getCommission()); |
| | | byId.setIsAccounting(1); |
| | | Long userId = loginInfoUtil.getUserId(); |
| | | SecUser byId1 = secUserService.getById(userId); |
| | | byId.setAccountingName(byId1.getNickName()); |
| | | byId.setAccountingTime(LocalDateTime.now()); |
| | | byId.setProfitRating(dto.getProfitRating()); |
| | | byId.setProfitMoney(dto.getProfitMoney()); |
| | | orderService.updateById(byId); |
| | | boolean remove = orderItemsService |
| | | .remove(new LambdaQueryWrapper<TOrderItems>() |
| | | .eq(TOrderItems::getOrderId, dto.getId())); |
| | | orderItemsService.saveBatch(dto.getListItems()); |
| | | return ApiResult.success(); |
| | | } |
| | | } |
| | | |