250522
This commit is contained in:
@@ -13,8 +13,6 @@ import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
import com.gxwebsoft.shop.service.GoodsPhoneModelService;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.vivo.entity.VivoPhoneModel;
|
||||
import com.gxwebsoft.vivo.param.VivoPhoneModelParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -52,35 +50,9 @@ public class GoodsController extends BaseController {
|
||||
public ApiResult<Goods> info(@RequestBody GoodsParam param) {
|
||||
Goods goods = goodsService.getById(param.getGoodsId());
|
||||
User loginUser = getLoginUser();
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
return success(goods);
|
||||
}
|
||||
|
||||
@PostMapping("/info-by-phone-code")
|
||||
public ApiResult<?> infoByPhoneCode(@RequestBody VivoPhoneModelParam phoneModelParam) {
|
||||
List<Goods> goodsList = goodsService.getByPhoneModelCode(phoneModelParam.getCode());
|
||||
User loginUser = getLoginUser();
|
||||
if (goodsList.isEmpty()) return fail("该机型暂无碎屏宝");
|
||||
goodsList.forEach(goods -> {
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
});
|
||||
return success(goodsList);
|
||||
}
|
||||
|
||||
@PostMapping("/info-by-phone-model")
|
||||
public ApiResult<?> infoByPhoneModel(@RequestBody VivoPhoneModelParam phoneModelParam) {
|
||||
List<Goods> goodsList = goodsService.getByPhoneModel(phoneModelParam.getName());
|
||||
User loginUser = getLoginUser();
|
||||
if (goodsList == null) return fail("该机型暂无碎屏宝");
|
||||
goodsList.forEach(goods -> {
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
});
|
||||
return success(goodsList);
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@OperationLog
|
||||
|
||||
@@ -77,33 +77,6 @@ public class GoodsPriceController extends BaseController {
|
||||
//return success(goodsPriceService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品价格()")
|
||||
@GetMapping("/by-goodsId-n-city/{id}")
|
||||
public ApiResult<GoodsPrice> getByGoodsIdNCity(@PathVariable("id") Integer id) {
|
||||
User loginUser = getLoginUser();
|
||||
return success(goodsPriceService.getByGoodsIdNCity(id, loginUser.getCityId()));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品价格()")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsPrice goodsPrice) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goodsPrice.setUserId(loginUser.getUserId());
|
||||
Area province = areaService.getParent(goodsPrice.getCity());
|
||||
goodsPrice.setProvince(province.getId());
|
||||
goodsPrice.setProvince(loginUser.getCityId());
|
||||
}
|
||||
if (goodsPriceService.save(goodsPrice)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:update')")
|
||||
@OperationLog
|
||||
|
||||
@@ -1,615 +0,0 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.Area;
|
||||
import com.gxwebsoft.common.system.entity.FileRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.service.FileRecordService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.constants.OrderConstants;
|
||||
import com.gxwebsoft.shop.entity.*;
|
||||
import com.gxwebsoft.shop.param.OrderGoodsParam;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.*;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.vivo.entity.VivoFixStore;
|
||||
import com.gxwebsoft.vivo.entity.VivoStore;
|
||||
import com.gxwebsoft.vivo.service.VivoFixStoreService;
|
||||
import com.gxwebsoft.vivo.service.VivoStoreService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
|
||||
/**
|
||||
* 订单记录表控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-16 11:25:58
|
||||
*/
|
||||
@Api(tags = "订单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order")
|
||||
public class OrderController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsPriceService goodsPriceService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private VivoStoreService storeService;
|
||||
@Resource
|
||||
private VivoFixStoreService fixStoreService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private OrderRefundService orderRefundService;
|
||||
@Resource
|
||||
private FileRecordService fileRecordService;
|
||||
|
||||
@Autowired
|
||||
private WxPayController wxPayController;
|
||||
|
||||
@Value("${config.upload-path}")
|
||||
private String uploadPath;
|
||||
|
||||
@Value("${config.server-url}")
|
||||
private String requestURL;
|
||||
|
||||
@PostMapping("/new")
|
||||
public ApiResult<?> addOrder(@RequestBody Order order) {
|
||||
User loginUser = getLoginUser();
|
||||
order.setUserId(loginUser.getUserId());
|
||||
order.setOrgId(loginUser.getOrganizationId());
|
||||
order.setOrderNo(makeOrderNumber(""));
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
order.setStoreId(loginUser.getStoreId());
|
||||
order.setCityId(loginUser.getCityId());
|
||||
BigDecimal goodsAmount = goods.getLinePriceMin();
|
||||
BigDecimal commission = BigDecimal.ZERO;
|
||||
if (goodsPrice != null) {
|
||||
if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
goodsAmount = goods.getGoodsPriceMin();
|
||||
}
|
||||
if (loginUser.getUserLevel().equals(3)) {
|
||||
if (goodsPrice.getLevel3commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel3commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel3commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(4)) {
|
||||
if (goodsPrice.getLevel4commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel4commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel4commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel5commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(6)) {
|
||||
if (goodsPrice.getLevel6commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel6commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel6commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(7)) {
|
||||
if (goodsPrice.getLevel7commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel7commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel7commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
}
|
||||
// else if (loginUser.getUserLevel().equals(8)) {
|
||||
// commission = goodsAmount.multiply(goodsPrice.getLevel8commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
// order.setCommission(commission);
|
||||
// }
|
||||
// if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
// if (loginUser.getFixStoreId() != null) {
|
||||
// BigDecimal fixStoreLeaderCommission = order.getCommission()
|
||||
// .multiply(goodsPrice.getFixStoreLeaderCommissionRate())
|
||||
// .divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
// order.setFixStoreLeaderCommission(fixStoreLeaderCommission);
|
||||
// }
|
||||
// }
|
||||
if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
order.setAgentCommission(BigDecimal.ZERO);
|
||||
} else {
|
||||
order.setAgentCommission(goodsAmount.subtract(goods.getCost()).subtract(commission));
|
||||
}
|
||||
}
|
||||
order.setTotalPrice(goodsAmount);
|
||||
if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
if (loginUser.getFixStoreId() != null) {
|
||||
order.setFixStoreId(loginUser.getFixStoreId());
|
||||
}
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
OrderGoods orderGoods = order.getOrderGoods();
|
||||
orderGoods.setOrderId(order.getOrderId());
|
||||
orderGoods.setUserId(getLoginUserId());
|
||||
orderGoodsService.save(orderGoods);
|
||||
return success("下单成功", order.getOrderId());
|
||||
}
|
||||
return fail("下单失败");
|
||||
}
|
||||
|
||||
@PostMapping("/update-info")
|
||||
public ApiResult<?> updateInfo(@RequestBody Order order) {
|
||||
return success(orderService.updateById(order));
|
||||
}
|
||||
|
||||
@PostMapping("/make-pay-qr")
|
||||
public ApiResult<?> makePayQr(@RequestBody Order order) {
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
Goods goods = goodsService.getById(order1.getGoodsId());
|
||||
return success(wxPayController.nativePay(order1.getOrderNo(),
|
||||
order1.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue(), goods.getGoodsName()));
|
||||
}
|
||||
|
||||
@PostMapping("/set-pay-voucher")
|
||||
public ApiResult<?> setPayVoucher(@RequestBody Order order) {
|
||||
order.setOrderStatus(OrderConstants.ORDER_STATUS_PAID);
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
order.setReceiptAmount(order1.getTotalAmount());
|
||||
if (orderService.updateById(order)) {
|
||||
orderService.updateIncome(order1);
|
||||
return success("更新成功");
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
|
||||
@PostMapping("/set-refund")
|
||||
public ApiResult<?> setRefund(@RequestBody Order order) {
|
||||
order.setOrderStatus(OrderConstants.ORDER_STATUS_REFUNDING);
|
||||
if (orderService.updateById(order)) {
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
OrderRefund orderRefund = new OrderRefund();
|
||||
orderRefund.setOrderId(order1.getOrderId());
|
||||
orderRefund.setOrderGoodsId(order1.getGoodsId());
|
||||
orderRefund.setRefundMoney(order1.getReceiptAmount());
|
||||
orderRefund.setTenantId(10049);
|
||||
orderRefundService.save(orderRefund);
|
||||
return success("申请成功,请等待审核");
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/do-refund")
|
||||
public ApiResult<?> doRefund(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
refund(order);
|
||||
return success("退款成功");
|
||||
}
|
||||
return fail("退款失败");
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public ApiResult<?> listForFront(@RequestBody OrderParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel() < 3) {
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
param.setFixStoreId(0);
|
||||
}
|
||||
} else {
|
||||
if (loginUser.getUserLevel().equals(8)) {
|
||||
VivoFixStore fixStore = fixStoreService.getByUserId(loginUser.getUserId());
|
||||
if (fixStore != null) {
|
||||
param.setFixStoreId(fixStore.getId());
|
||||
}
|
||||
} else {
|
||||
param.setUserId(getLoginUserId());
|
||||
}
|
||||
}
|
||||
List<Order> list = orderService.listRel(param);
|
||||
list.forEach(order -> {
|
||||
if (order.getStoreId() != null) order.setStore(storeService.getById(order.getStoreId()));
|
||||
if (order.getFixStoreId() != null) order.setFixStore(fixStoreService.getById(order.getFixStoreId()));
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
goods.setGoodsPrice(goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId()));
|
||||
order.setGoods(goods);
|
||||
order.setUser(userService.getById(order.getUserId()));
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/info")
|
||||
public ApiResult<Order> info(@RequestBody OrderParam param) {
|
||||
Order order = orderService.getByIdRel(param.getOrderId());
|
||||
if (order != null) {
|
||||
if (order.getStoreId() != null) order.setStore(storeService.getById(order.getStoreId()));
|
||||
if (order.getFixStoreId() != null) order.setFixStore(fixStoreService.getById(order.getFixStore()));
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PostMapping("/set-done")
|
||||
public ApiResult<Order> setDone(@RequestBody Order order) {
|
||||
order.setUseTime(DateUtil.date());
|
||||
orderService.updateById(order);
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询订单记录表")
|
||||
@PostMapping("/page")
|
||||
public ApiResult<PageResult<Order>> page(@RequestBody OrderParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
}
|
||||
Page<Order> list = orderService.getByPage(param);
|
||||
list.getRecords().forEach(order -> {
|
||||
if (order.getStoreId() != null) order.setStore(storeService.getById(order.getStoreId()));
|
||||
if (order.getFixStoreId() != null) order.setFixStore(fixStoreService.getById(order.getFixStore()));
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
order.setGoods(goods);
|
||||
order.setUser(userService.getById(order.getUserId()));
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部订单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("按订单集查询")
|
||||
@PostMapping("/listByIds")
|
||||
public ApiResult<List<Order>> listByIds(@RequestBody List<Integer> orderIds) {
|
||||
System.out.println("按订单集查询 = " + orderIds);
|
||||
Integer userId = getLoginUserId();
|
||||
// 代报餐情况(未完成)
|
||||
final Order order = orderService.getById(orderIds.get(0));
|
||||
if (!order.getUserId().equals(getLoginUserId())) {
|
||||
userId = order.getUserId();
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderId, orderIds).eq(Order::getUserId, userId).eq(Order::getPayStatus, PAY_STATUS_NO_PAY));
|
||||
final Set<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getUserId, getLoginUserId()).eq(Order::getPayStatus, PAY_STATUS_NO_PAY));
|
||||
final List<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
// 使用关联查询
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询订单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
Order order = orderService.getByIdRel(id);
|
||||
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加订单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Order order) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
order.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
// 是否存入星期值
|
||||
if (order.getDeliveryTime() != null) {
|
||||
order.setWeek(DateUtil.dayOfWeek(order.getDeliveryTime()) - 1);
|
||||
}
|
||||
return success("添加成功", order);
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改订单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
refund(order);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
private void refund(Order order) {
|
||||
if (order.getOrderStatus().equals(OrderConstants.ORDER_STATUS_REFUND_SUCCESS)) {
|
||||
OrderRefund orderRefund = orderRefundService.getByOrderId(order.getOrderId());
|
||||
orderRefund.setAuditStatus(10);
|
||||
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
User user = userService.getById(order1.getUserId());
|
||||
user.setBalance(user.getBalance().subtract(order1.getCommission()));
|
||||
user.setTotalIncome(user.getTotalIncome().subtract(order1.getCommission()));
|
||||
userService.updateById(user);
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order1.getOrderId());
|
||||
setUserId(user.getUserId());
|
||||
setScene(1);
|
||||
setMoney(order1.getCommission());
|
||||
setBalance(user.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order1.getOrderNo() + "退款,收回返利");
|
||||
}}
|
||||
);
|
||||
|
||||
// 售后门店
|
||||
// if (order1.getFixStoreId() != null
|
||||
// && order1.getFixStoreLeaderCommission() != null
|
||||
// && order1.getFixStoreLeaderCommission().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// VivoFixStore vivoFixStore = fixStoreService.getById(order1.getFixStoreId());
|
||||
// User fixStoreLeader = userService.getById(vivoFixStore.getUserId());
|
||||
// fixStoreLeader.setBalance(fixStoreLeader.getBalance().subtract(order1.getFixStoreLeaderCommission()));
|
||||
// fixStoreLeader.setTotalIncome(fixStoreLeader.getTotalIncome().subtract(order1.getFixStoreLeaderCommission()));
|
||||
// userService.updateById(fixStoreLeader);
|
||||
// userBalanceLogService.save(
|
||||
// new UserBalanceLog() {{
|
||||
// setOrderId(order1.getOrderId());
|
||||
// setUserId(fixStoreLeader.getUserId());
|
||||
// setScene(1);
|
||||
// setMoney(order1.getFixStoreLeaderCommission());
|
||||
// setBalance(fixStoreLeader.getBalance());
|
||||
// setTenantId(10049);
|
||||
// setCreateTime(DateUtil.date());
|
||||
// setRemark("订单:" + order1.getOrderNo() + "退款,收回店长门店返利");
|
||||
// }}
|
||||
// );
|
||||
// }
|
||||
|
||||
User cityAgent = userService.getCityAgent(order1.getCityId());
|
||||
if (cityAgent != null && order1.getAgentCommission() != null && order1.getAgentCommission().compareTo(BigDecimal.ZERO) > 0) {
|
||||
cityAgent.setBalance(cityAgent.getBalance().subtract(order1.getAgentCommission()));
|
||||
cityAgent.setTotalIncome(cityAgent.getTotalIncome().subtract(order1.getAgentCommission()));
|
||||
userService.updateById(cityAgent);
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order1.getOrderId());
|
||||
setUserId(cityAgent.getUserId());
|
||||
setScene(1);
|
||||
setMoney(order1.getAgentCommission());
|
||||
setBalance(cityAgent.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order1.getOrderNo() + "退款,收回区域返利");
|
||||
}}
|
||||
);
|
||||
}
|
||||
|
||||
if (order1.getPayMethod().equals(OrderConstants.ORDER_PAY_METHOD_WECHAT.toString())) {
|
||||
orderRefund.setOrder(orderService.getById(order1.getOrderId()));
|
||||
wxPayController.refund(orderRefund);
|
||||
} else {
|
||||
orderRefund.setRefundStatus(1);
|
||||
}
|
||||
orderRefundService.updateById(orderRefund);
|
||||
} else if (order.getOrderStatus().equals(OrderConstants.ORDER_STATUS_REFUND_FAIL)) {
|
||||
OrderRefund orderRefund = orderRefundService.getByOrderId(order.getOrderId());
|
||||
orderRefund.setAuditStatus(20);
|
||||
orderRefundService.updateById(orderRefund);
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除订单记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加订单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
|
||||
if (orderService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改订单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
||||
if (batchParam.update(orderService, "order_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除订单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("支付成功")
|
||||
@PostMapping("/setPayStatus")
|
||||
public ApiResult<?> setPayStatus(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
return success("设置成功");
|
||||
}
|
||||
return fail("设置失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("导出")
|
||||
@PostMapping("/export")
|
||||
public ApiResult<?> export(@RequestBody OrderParam param, HttpServletRequest request) throws IOException {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
}
|
||||
String filename = "file/excel/订单表" + new Date().getTime() + ".xls";
|
||||
String path = uploadPath + filename;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
//创建工作表单
|
||||
HSSFSheet sheet = workbook.createSheet();
|
||||
List<Order> orderList = orderService.listRel(param);
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
row.createCell(0).setCellValue("订单号");
|
||||
row.createCell(1).setCellValue("下单人手机号");
|
||||
row.createCell(2).setCellValue("购买的产品");
|
||||
row.createCell(3).setCellValue("IMEI");
|
||||
row.createCell(4).setCellValue("型号");
|
||||
row.createCell(5).setCellValue("系列");
|
||||
row.createCell(6).setCellValue("上报人工号");
|
||||
row.createCell(7).setCellValue("上报人姓名");
|
||||
row.createCell(8).setCellValue("激活状态");
|
||||
row.createCell(9).setCellValue("激活时间");
|
||||
row.createCell(10).setCellValue("门店");
|
||||
row.createCell(11).setCellValue("二级区域名称");
|
||||
row.createCell(12).setCellValue("零售商名称");
|
||||
row.createCell(13).setCellValue("好/坏机");
|
||||
row.createCell(14).setCellValue("下单人信息");
|
||||
row.createCell(15).setCellValue("下单门店信息");
|
||||
row.createCell(16).setCellValue("有效期开始时间");
|
||||
row.createCell(17).setCellValue("有效期结束时间");
|
||||
row.createCell(18).setCellValue("订单金额");
|
||||
row.createCell(19).setCellValue("成本价");
|
||||
row.createCell(20).setCellValue("下单人佣金");
|
||||
row.createCell(21).setCellValue("区域代理佣金");
|
||||
row.createCell(22).setCellValue("订单状态");
|
||||
row.createCell(23).setCellValue("下单时间");
|
||||
int rowNum = 1;
|
||||
for (Order order : orderList) {
|
||||
//订单状态(0已取消1待支付2已支付3已结束4退款审核中5退款成功6退款失败)
|
||||
String orderStatus = "";
|
||||
HSSFRow orderRow = sheet.createRow(rowNum);
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
String storeName = "";
|
||||
if (order.getStoreId() != null) {
|
||||
VivoStore store = storeService.getById(order.getStoreId());
|
||||
if (store != null) storeName = store.getName();
|
||||
}
|
||||
if (order.getFixStoreId() != null) {
|
||||
VivoFixStore store = fixStoreService.getById(order.getFixStoreId());
|
||||
if (store != null) storeName = store.getName();
|
||||
}
|
||||
User user = userService.getById(order.getUserId());
|
||||
orderRow.createCell(0).setCellValue(order.getOrderNo());
|
||||
orderRow.createCell(1).setCellValue(user.getPhone());
|
||||
orderRow.createCell(2).setCellValue(goods.getGoodsName());
|
||||
orderRow.createCell(3).setCellValue(order.getImei());
|
||||
orderRow.createCell(4).setCellValue(order.getSkuName());
|
||||
orderRow.createCell(5).setCellValue(order.getModelName());
|
||||
orderRow.createCell(6).setCellValue(order.getSellerCode());
|
||||
orderRow.createCell(7).setCellValue(order.getSellerName());
|
||||
orderRow.createCell(8).setCellValue(order.getActiveState());
|
||||
orderRow.createCell(9).setCellValue(order.getActiveDate());
|
||||
orderRow.createCell(10).setCellValue(order.getStoreName());
|
||||
orderRow.createCell(11).setCellValue(order.getSecondAreaName());
|
||||
orderRow.createCell(12).setCellValue(order.getRetailerName());
|
||||
orderRow.createCell(13).setCellValue(!order.getGoodOrBad().equals("undefined") ? order.getGoodOrBad() : "");
|
||||
orderRow.createCell(14).setCellValue(user.getRealName());
|
||||
orderRow.createCell(15).setCellValue(storeName);
|
||||
orderRow.createCell(16).setCellValue(DateUtil.formatDateTime(order.getStartTime()) + " ");
|
||||
orderRow.createCell(17).setCellValue(DateUtil.formatDateTime(order.getExpirationTime()) + " ");
|
||||
orderRow.createCell(18).setCellValue(order.getTotalPrice().toString());
|
||||
orderRow.createCell(19).setCellValue(goods.getCost().toString());
|
||||
orderRow.createCell(20).setCellValue(order.getCommission() != null ? order.getCommission().toString() : "0");
|
||||
orderRow.createCell(21).setCellValue(order.getAgentCommission() != null ? order.getAgentCommission().toString() : "0");
|
||||
orderRow.createCell(22).setCellValue(OrderConstants.ORDER_STATUS_MAP.get(order.getOrderStatus()));
|
||||
orderRow.createCell(23).setCellValue(DateUtil.formatDateTime(order.getCreateTime()) + " ");
|
||||
rowNum++;
|
||||
}
|
||||
FileOutputStream output = new FileOutputStream(path);
|
||||
workbook.write(output);
|
||||
output.flush();
|
||||
|
||||
FileRecord result = new FileRecord();
|
||||
result.setCreateUserId(getLoginUserId());
|
||||
result.setName(filename);
|
||||
result.setPath(path);
|
||||
result.setUrl(requestURL + "/" + filename);
|
||||
// result.setMerchantCode(getMerchantCode());
|
||||
fileRecordService.save(result);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
protected void task() {
|
||||
// 1小时未支付的单
|
||||
orderService.update(
|
||||
new UpdateWrapper<Order>().eq("order_status", 1)
|
||||
.lt("create_time", DateUtil.offsetHour(new Date(), -1))
|
||||
.set("order_status", 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.FileRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
@@ -21,10 +22,6 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.vivo.entity.VivoFixStore;
|
||||
import com.gxwebsoft.vivo.entity.VivoStore;
|
||||
import com.gxwebsoft.vivo.service.VivoFixStoreService;
|
||||
import com.gxwebsoft.vivo.service.VivoStoreService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
@@ -56,10 +53,6 @@ public class UserBalanceLogController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private VivoFixStoreService fixStoreService;
|
||||
@Resource
|
||||
private VivoStoreService storeService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsPriceService goodsPriceService;
|
||||
@@ -82,17 +75,6 @@ public class UserBalanceLogController extends BaseController {
|
||||
List<UserBalanceLog> userBalanceLogList = userBalanceLogService.listRel(param);
|
||||
userBalanceLogList.forEach(userBalanceLog -> {
|
||||
Order order = orderService.getByIdRel(userBalanceLog.getOrderId());
|
||||
if (order.getStoreId() != null && order.getStoreId() != 0) {
|
||||
VivoStore store = storeService.getById(order.getStoreId());
|
||||
if (store != null) order.setStore(store);
|
||||
}
|
||||
if (order.getFixStoreId() != null && order.getFixStoreId() != 0) {
|
||||
VivoFixStore fixStore = fixStoreService.getById(order.getFixStoreId());
|
||||
if (fixStore != null) order.setFixStore(fixStore);
|
||||
}
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
goods.setGoodsPrice(goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId()));
|
||||
order.setGoods(goods);
|
||||
userBalanceLog.setOrder(order);
|
||||
});
|
||||
return success(userBalanceLogList);
|
||||
@@ -103,9 +85,9 @@ public class UserBalanceLogController extends BaseController {
|
||||
@ApiOperation("分页查询用户余额变动明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserBalanceLog>> page(UserBalanceLogParam param) {
|
||||
PageResult<UserBalanceLog> list = userBalanceLogService.pageRel(param);
|
||||
list.getList().forEach(userBalanceLog -> {
|
||||
userBalanceLog.setUser(userService.getByIdRel(userBalanceLog.getUserId()));
|
||||
IPage<UserBalanceLog> list = userBalanceLogService.getByPage(param);
|
||||
list.getRecords().forEach(userBalanceLog -> {
|
||||
userBalanceLog.setUser(userService.getById(userBalanceLog.getUserId()));
|
||||
});
|
||||
// 使用关联查询
|
||||
return success(list);
|
||||
@@ -224,7 +206,8 @@ public class UserBalanceLogController extends BaseController {
|
||||
row.createCell(3).setCellValue("订单金额");
|
||||
row.createCell(4).setCellValue("收/支");
|
||||
row.createCell(5).setCellValue("佣金");
|
||||
row.createCell(6).setCellValue("下单时间");
|
||||
row.createCell(6).setCellValue("说明");
|
||||
row.createCell(7).setCellValue("下单时间");
|
||||
int rowNum = 1;
|
||||
for (UserBalanceLog log : list) {
|
||||
HSSFRow orderRow = sheet.createRow(rowNum);
|
||||
@@ -236,7 +219,8 @@ public class UserBalanceLogController extends BaseController {
|
||||
orderRow.createCell(3).setCellValue(order.getTotalPrice().toString());
|
||||
orderRow.createCell(4).setCellValue(log.getScene().equals(1) ? "退款" : "收入");
|
||||
orderRow.createCell(5).setCellValue((log.getScene().equals(1) ? "-" : "") + log.getMoney().toString());
|
||||
orderRow.createCell(6).setCellValue(DateUtil.formatDateTime(order.getCreateTime()) + " ");
|
||||
orderRow.createCell(6).setCellValue(log.getRemark());
|
||||
orderRow.createCell(7).setCellValue(DateUtil.formatDateTime(order.getCreateTime()) + " ");
|
||||
rowNum++;
|
||||
}
|
||||
FileOutputStream output = new FileOutputStream(path);
|
||||
|
||||
@@ -81,10 +81,6 @@ public class WxLoginController extends BaseController {
|
||||
// 1.获取openid
|
||||
JSONObject result = getOpenIdByCode(userParam);
|
||||
String openid = result.getString("openid");
|
||||
String unionid = result.getString("unionid");
|
||||
// WxMaJscode2SessionResult result = getOpenIdByCode(userParam);
|
||||
// String openid = result.getOpenid();
|
||||
// String unionid = result.getUnionid();
|
||||
if (openid == null) {
|
||||
return fail("获取openid失败", null);
|
||||
}
|
||||
@@ -99,7 +95,6 @@ public class WxLoginController extends BaseController {
|
||||
uo.setTenantId(user.getTenantId());
|
||||
uo.setOauthType("MP-WEIXIN");
|
||||
uo.setOauthId(openid);
|
||||
uo.setUnionid(unionid);
|
||||
userOauthService.save(uo);
|
||||
}
|
||||
// 4.签发token
|
||||
|
||||
@@ -186,7 +186,6 @@ public class WxPayController extends BaseController {
|
||||
order.setPayTime(DateUtil.date());
|
||||
orderService.updateById(order);
|
||||
|
||||
orderService.updateIncome(order);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user