|
|
@@ -1,8 +1,12 @@
|
|
|
package com.sqx.modules.order.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.core.util.URLUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.converters.longconverter.LongStringConverter;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -113,11 +117,15 @@ import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
+import org.springframework.web.context.request.RequestAttributes;
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
@@ -1840,17 +1848,18 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
messageInfo.setContent("您的餐品已制作完成,请及时取餐");
|
|
|
} else if (tbOrder.getOrderType() == 2) {
|
|
|
messageInfo.setContent("您的餐品已制作完成,正在配送中");
|
|
|
+ // 用户支付成功后,即创建跑腿状态为2的订单
|
|
|
//如果是外卖订单,则修改外卖订单的状态
|
|
|
- GoodsShop goodsShop = goodsShopDao.selectById(tbOrder.getShopId());
|
|
|
- if (goodsShop.getAutoSendOrder() == 0) {
|
|
|
- TbIndent tbIndent = tbIndentDao.selectOne(new QueryWrapper<TbIndent>().eq("order_id", tbOrder.getOrderId()));
|
|
|
- TbIndent tbIndent1 = new TbIndent();
|
|
|
- tbIndent1.setIndentId(tbIndent.getIndentId());
|
|
|
- tbIndent1.setCreateTime(format1);
|
|
|
- tbIndent1.setIndentState("2");
|
|
|
- tbIndentService.updateById(tbIndent1);
|
|
|
- tbIndentService.sendNewIndentMsg(tbIndent);
|
|
|
- }
|
|
|
+ // GoodsShop goodsShop = goodsShopDao.selectById(tbOrder.getShopId());
|
|
|
+ // if (goodsShop.getAutoSendOrder() == 0) {
|
|
|
+ // TbIndent tbIndent = tbIndentDao.selectOne(new QueryWrapper<TbIndent>().eq("order_id", tbOrder.getOrderId()));
|
|
|
+ // TbIndent tbIndent1 = new TbIndent();
|
|
|
+ // tbIndent1.setIndentId(tbIndent.getIndentId());
|
|
|
+ // tbIndent1.setCreateTime(format1);
|
|
|
+ // tbIndent1.setIndentState("2");
|
|
|
+ // tbIndentService.updateById(tbIndent1);
|
|
|
+ // tbIndentService.sendNewIndentMsg(tbIndent);
|
|
|
+ // }
|
|
|
}
|
|
|
messageInfo.setCreateAt(format1);
|
|
|
messageInfo.setUserId(tbOrder.getUserId().toString());
|
|
|
@@ -1971,6 +1980,8 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
tbCouponUserDao.updateById(tbCouponUser);
|
|
|
}
|
|
|
|
|
|
+ // 取消跑腿订单
|
|
|
+ tbIndentService.sysCancelOrder(tbOrder.getOrderNumber());
|
|
|
|
|
|
//设置小程序消息推送
|
|
|
CommonInfo one = commonInfoService.findOne(266);
|
|
|
@@ -2374,15 +2385,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
}
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
cal.add(Calendar.MINUTE, -1);
|
|
|
- Date parse = null;
|
|
|
- if (tbOrder.getStatus() == 6) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- try {
|
|
|
- parse = sdf.parse(tbOrder.getShopReceivingTime());
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
MessageInfo messageInfo1 = new MessageInfo();
|
|
|
messageInfo1.setTitle("用户取消订单");
|
|
|
messageInfo1.setCreateAt(DateUtils.format(new Date()));
|
|
|
@@ -2481,6 +2484,9 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
goodsShopDao.updateShopSales(2, goodsNum, goodsShopRelevancy.getShopId());
|
|
|
}
|
|
|
|
|
|
+ // 取消跑腿订单
|
|
|
+ tbIndentService.sysCancelOrder(tbOrder.getOrderNumber());
|
|
|
+
|
|
|
return Result.success("取消订单成功!");
|
|
|
}
|
|
|
return Result.error("餐品正在制作中,无法退款!");
|
|
|
@@ -2573,12 +2579,10 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 退款状态需要改成8
|
|
|
tbOrder.setStatus(8);
|
|
|
appOrderDao.updateById(tbOrder);
|
|
|
- //取消跑腿订单
|
|
|
- TbIndent tbIndent = new TbIndent();
|
|
|
- TbIndent tbIndent1 = tbIndentDao.selectOne(new QueryWrapper<TbIndent>().eq("order_id", orderId));
|
|
|
- tbIndent.setIndentId(tbIndent1.getIndentId());
|
|
|
- tbIndent.setIndentState("10");
|
|
|
- tbIndentDao.updateById(tbIndent);
|
|
|
+
|
|
|
+ // 取消跑腿订单
|
|
|
+ tbIndentService.sysCancelOrder(tbOrder.getOrderNumber());
|
|
|
+
|
|
|
//添加退款记录
|
|
|
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
|
|
userMoneyDetails.setUserId(tbOrder.getUserId());
|
|
|
@@ -2919,6 +2923,34 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
return pageUtils;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void exportGoodsSkuSalesCount(GoodsSkuQuery query) {
|
|
|
+ Page<GoodsSkuSalesCountVO> pages = new Page<>(query.getPage(), query.getLimit());
|
|
|
+ IPage<GoodsSkuSalesCountVO> page = baseMapper.getGoodsSkuSalesCount(pages, query);
|
|
|
+ List<GoodsSkuSalesCountVO> records = page.getRecords();
|
|
|
+
|
|
|
+ try {
|
|
|
+ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
|
|
+ HttpServletResponse response = ((ServletRequestAttributes) requestAttributes).getResponse();
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+
|
|
|
+ String excelName = "sku销售记录_";
|
|
|
+ excelName += DateUtil.format(new Date(), "yyyyMMddHHmmss");
|
|
|
+ String fileName = URLUtil.encode(excelName, "UTF-8");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+
|
|
|
+ EasyExcel.write(response.getOutputStream(), GoodsSkuSalesCountVO.class)
|
|
|
+ .sheet("sheet1")
|
|
|
+ .registerConverter(new LongStringConverter())
|
|
|
+ .doWrite(records);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("sku销售记录导出失败:{}", e.getMessage());
|
|
|
+ throw new SqxException("sku销售记录导出失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更新订单状态和支付顺序
|
|
|
*
|