| | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.*; |
| | | import com.ruoyi.account.api.model.*; |
| | |
| | | private ShopBalanceStatementClient shopBalanceStatementClient; |
| | | |
| | | @Resource |
| | | private GoodsEvaluateClient goodsEvaluateClient; |
| | | |
| | | @Resource |
| | | private SystemConfigClient systemConfigClient; |
| | | |
| | | @Resource |
| | |
| | | Goods goods = JSONObject.parseObject(goodJson, Goods.class); |
| | | |
| | | OrderGoodsVO orderGoodsVO = new OrderGoodsVO(); |
| | | BeanUtils.copyProperties(orderGood, orderGoodsVO); |
| | | orderGoodsVO.setGoodsId(goods.getId()); |
| | | orderGoodsVO.setGoodsName(goods.getName()); |
| | | orderGoodsVO.setGoodsPic(goods.getHomePagePicture()); |
| | | orderGoodsVO.setNum(order.getNum()); |
| | | orderGoodsVO.setSellingPrice(goods.getSellingPrice()); |
| | | orderGoodsVO.setIntegral(goods.getIntegral()); |
| | | orderGoodsVO.setOriginalPrice(goods.getOriginalPrice()); |
| | | |
| | | OrderDetailVO orderDetailVO = new OrderDetailVO(); |
| | | orderDetailVO.setOrderGoodsVO(orderGoodsVO); |
| | | Shop shop = shopR.getData(); |
| | | |
| | | orderDetailVO.setId(order.getId()); |
| | | orderDetailVO.setOrderStatus(order.getOrderStatus()); |
| | | orderDetailVO.setPoint(order.getPoint()); |
| | | orderDetailVO.setPoint(order.getPoint());//使用的积分 |
| | | orderDetailVO.setOrderNumber(order.getOrderNumber()); |
| | | orderDetailVO.setCreateTime(order.getCreateTime()); |
| | | orderDetailVO.setTotalAmount(order.getTotalAmount()); |
| | | orderDetailVO.setPointDeductionAmount(order.getPointDeductionAmount());//积分抵扣金额 |
| | | orderDetailVO.setPaymentAmount(order.getPaymentAmount()); |
| | | orderDetailVO.setShopName(shop.getName()); |
| | | orderDetailVO.setShopAddress(shop.getAddress()); |
| | |
| | | e.printStackTrace(); |
| | | throw new ServiceException("生成核销码失败"); |
| | | } |
| | | //该商品是否被用户评论 |
| | | Long evaluateId = goodsEvaluateClient.getEvaluateIdByUserIdAndGoodId(goods.getId(), order.getAppUserId()).getData(); |
| | | orderDetailVO.setEvaluateId(evaluateId); |
| | | |
| | | return orderDetailVO; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void writeOff(String id, Integer shopId, String technicianId) { |
| | | public void writeOff(String id, Integer shopId) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | Order order = orderMapper.selectById(id); |
| | | boolean check = check(order, shopId, loginUserApplet.getUserid()); |
| | | if (!check) { |
| | | if (order == null) { |
| | | throw new ServiceException("订单不存在"); |
| | | } |
| | | if (!order.getShopId().equals(shopId)) { |
| | | throw new ServiceException("该订单与当前扫码门店不一致"); |
| | | } |
| | | |
| | | |
| | | // 售后设置 |
| | | R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5); |
| | |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | order.setEndTime(LocalDateTime.now()); |
| | | order.setCancellerAppUserId(loginUserApplet.getUserid()); |
| | | if (StringUtils.isNotEmpty(technicianId) && !"null".equals(technicianId)) { |
| | | // order.setTechnicianId(Integer.valueOf(technicianId)); |
| | | } |
| | | orderMapper.updateById(order); |
| | | //店铺可用金额增加 |
| | | Shop shop = shopClient.getShopById(shopId).getData(); |
| | | shop.setCanWithdrawMoney(shop.getCanWithdrawMoney().add(order.getTotalAmount())); |
| | | shopClient.updateShop(shop); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | /* Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | if (2 == sysUser.getRoleType()) { |
| | | orderPageList.setShopId(sysUser.getObjectId()); |
| | |
| | | } |
| | | |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | return pageInfo.setRecords(list);*/ |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | confirmOrderVo.setCash(good.getSellingPrice()); |
| | | confirmOrderVo.setPoint(good.getIntegral()); |
| | | |
| | | //计算活动价格信息 |
| | | Price price = getPrice(goodId); |
| | | if (null != price) { |
| | | confirmOrderVo.setCash(price.getCash()); |
| | | confirmOrderVo.setOrderPoint(price.getPoint()); |
| | | confirmOrderVo.setEndTimeStamp(price.getEndTimeStamp()); |
| | | //是否在秒杀活动中 |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |
| | | info.setGoodsId(goodId); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | |
| | | if (null != goodsSeckill){ |
| | | SeckillActivityInfo activityInfo = seckillActivityInfoClient.getSeckillActivityInfoById(goodsSeckill.getSeckillActivityInfoId()).getData(); |
| | | //价格 |
| | | confirmOrderVo.setCash(goodsSeckill.getSellingPrice());//秒杀活动价格 |
| | | confirmOrderVo.setPoint(goodsSeckill.getIntegral());//秒杀活动积分价格 |
| | | confirmOrderVo.setPurchaseLimitNum(activityInfo.getMaxNum());//限购数量 |
| | | } |
| | | |
| | | |
| | | //判断是否是积分支付 |
| | | if (type == 1) {//现金 |
| | | confirmOrderVo.setOrderMoney(confirmOrderVo.getCash()); |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<OrderPageListVo> getShopOrderList(String content, Integer status, Integer shopId, Integer pageNum, Integer pageSize) { |
| | | // 创建分页对象 |
| | | Page<Order> page = new Page<>(pageNum, pageSize); |
| | | // 构建查询条件 |
| | | QueryWrapper<Order> queryWrapper = new QueryWrapper<>(); |
| | | // 添加门店ID条件 |
| | | if (shopId != null) { |
| | | queryWrapper.eq("shop_id", shopId); |
| | | } |
| | | // 添加订单状态条件 |
| | | if (status != null) { |
| | | queryWrapper.eq("order_status", status); |
| | | } |
| | | // 模糊查询条件 |
| | | if (StringUtils.isNotBlank(content)) { |
| | | // 构建OR条件组:订单编号/商品名/手机号 |
| | | queryWrapper.and(wrapper -> wrapper |
| | | .like("order_number", content) // 订单编号 |
| | | .or() |
| | | .like("goods_name", content) // 商品名 |
| | | .or() |
| | | .inSql("app_user_id", "select id from t_app_user where phone like '%" + content + "%'") // 手机号 |
| | | ); |
| | | } |
| | | |
| | | // 执行分页查询 |
| | | IPage<Order> orderPage = orderMapper.selectPage(page, queryWrapper); |
| | | // 转换为VO对象 |
| | | return orderPage.convert(this::convertToOrderListVo); |
| | | } |
| | | |
| | | @Override |
| | | public R shopCancelOrder(Long orderId) { |
| | | Order order = this.getById(orderId); |
| | | if (Arrays.asList(5, 6, 7).contains(order.getOrderStatus())) { |
| | | return R.fail("无效的操作"); |
| | | } |
| | | if (null != order.getAfterSaleTime() && LocalDateTime.now().isAfter(order.getAfterSaleTime())) { |
| | | return R.fail("订单取消失败"); |
| | | } |
| | | order.setOrderStatus(5); |
| | | R r = refundPayMoney(order); |
| | | if (200 == r.getCode()) { |
| | | this.updateById(order); |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | private OrderPageListVo convertToOrderListVo(Order order) { |
| | | OrderPageListVo vo = new OrderPageListVo(); |
| | | // 复制属性 |
| | | BeanUtils.copyProperties(order, vo); |
| | | |
| | | // 查询用户信息 |
| | | AppUser user = appUserClient.getAppUserById(order.getAppUserId()); |
| | | if (user != null) { |
| | | vo.setPhone(user.getPhone()); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | public String getNumber(Integer size){ |
| | | StringBuilder str = new StringBuilder(); |
| | | for (int i = 0; i < size; i++) { |
| | |
| | | } |
| | | return str.toString(); |
| | | } |
| | | /** |
| | | * 根据商品的价格配置体系获取商品当前的价格 |
| | | */ |
| | | public Price getPrice( Integer goodsId){ |
| | | //判断是否有在秒杀活动时间中的商品 |
| | | Price price = new Price(); |
| | | GetSeckillActivityInfo getSeckillActivityInfo = new GetSeckillActivityInfo(); |
| | | getSeckillActivityInfo.setGoodsId(goodsId); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(getSeckillActivityInfo).getData(); |
| | | //没有秒杀活动 |
| | | if(null == goodsSeckill ){ |
| | | return null; |
| | | } |
| | | //秒杀活动价格 |
| | | price.setCash(goodsSeckill.getSellingPrice()); |
| | | //计算对应积分 |
| | | price.setPoint(getPoint(price.getCash())); |
| | | //结束时间 |
| | | price.setEndTimeStamp(goodsSeckill.getEndTime()); |
| | | return price; |
| | | } |
| | | |
| | | /** |
| | | * 获取现金对应积分 |
| | | */ |