From 391b64ce62f567c1da66445663c41cdd29b39268 Mon Sep 17 00:00:00 2001
From: yanghui <2536613402@qq.com>
Date: 星期四, 01 十二月 2022 09:13:45 +0800
Subject: [PATCH] #feat ..
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java | 80 ++++++++++++++++++++++++++++++++++-----
1 files changed, 69 insertions(+), 11 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java
index 8c6ec90..e166449 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java
@@ -1,26 +1,32 @@
package com.panzhihua.service_community.service.impl;
+import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.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.panzhihua.common.constants.Constants;
import com.panzhihua.common.model.dtos.shop.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.convenient.ConvenientElevatingPointVO;
import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO;
import com.panzhihua.common.model.vos.shop.*;
-import com.panzhihua.common.utlis.DateUtils;
-import com.panzhihua.common.utlis.OrderNoUtils;
-import com.panzhihua.common.utlis.StringUtils;
-import com.panzhihua.common.utlis.WxPayUtils;
+import com.panzhihua.common.model.vos.user.SysUserVO;
+import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.common.utlis.*;
import com.panzhihua.common.utlis.wx.WXPayUtil;
import com.panzhihua.service_community.dao.*;
import com.panzhihua.service_community.model.dos.*;
import com.panzhihua.service_community.service.ComShopFlowerOrderService;
+import com.panzhihua.service_community.util.WxMaConfiguration;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -71,6 +77,10 @@
private ComShopFlowerRefundOrderDAO comShopFlowerRefundOrderDAO;
@Resource
private ComShopFlowerOrderDeliveryDAO comShopFlowerOrderDeliveryDAO;
+ @Resource
+ private WxMaConfiguration wxMaConfiguration;
+ @Resource
+ private UserService userService;
@Value("${hcMin.app.isTest}")
@@ -377,6 +387,24 @@
orderVo.setComShopFlowerEvaluateVO(comShopFlowerEvaluateVO);
}
}
+
+ //判断是否可以退款 订单是否已超过15天 是否已有退款订单
+ int count = comShopFlowerRefundOrderDAO.selectCountRefundNowByOrderId(orderVo.getOrderId());
+ if (count > 0){
+ orderVo.setRefundable(2);
+ }else {
+ if (null == orderVo.getReceivingTime()){
+ orderVo.setRefundable(2);
+ }else {
+ //收货时间往前推15天和当前时间做比较
+ Date date = DateUtils.addDay(orderVo.getReceivingTime(), 15);
+ if(date.before(new Date())){
+ orderVo.setRefundable(2);
+ }
+ }
+ }
+
+
});
}
return R.ok(orderPageVOIPage);
@@ -399,7 +427,7 @@
//查询自提点信息
ConvenientElevatingPointDO convenientElevatingPointDO = convenientElevatingPointDAO.selectOne(new LambdaQueryWrapper<ConvenientElevatingPointDO>().eq(ConvenientElevatingPointDO::getWechatAccount, phone));
if (isNull(convenientElevatingPointDO)) {
- return R.fail("自提点不存在");
+ return R.ok("订单不在该自提点");
}
Long pointDOId = convenientElevatingPointDO.getId();
shopOrderDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopFlowerOrderDO>().eq(ComShopFlowerOrderDO::getId, orderId).eq(ComShopFlowerOrderDO::getPointId, pointDOId));
@@ -451,7 +479,10 @@
orderGoodsVOS.add(orderGoodsVO);
sbr.append(orderGoods.getGoodsName()).append(" ");
});
+ orderVO.setGoodsAttrPic(orderGoodsDOList.get(0).getGoodsAttrPic());
+ orderVO.setGoodsAttrName(orderGoodsDOList.get(0).getGoodsAttrName());
}
+
orderVO.setOrderGoodsVOList(orderGoodsVOS);
orderVO.setGoodsName(sbr.toString());
@@ -693,6 +724,17 @@
if (inserted != 1) {
log.error("订单发货日志保存错误");
}
+ //发货通知
+ WxMaService maService = wxMaConfiguration.getMaService(Constants.HC_APP_ID);
+ R userOpenId = userService.getUserOpenId(comShopOrderDO.getUserId());
+ if (R.isOk(userOpenId)) {
+ String openid = userOpenId.getData().toString();
+ try {
+ WxUtil.sendDeliverGoodsNotice(openid,maService.getAccessToken(),orderShipDTO.getLogisticsCompany(),orderShipDTO.getLogisticsNo(),comShopOrderDO.getOrderNo(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
+ } catch (WxErrorException e) {
+ e.printStackTrace();
+ }
+ }
return R.ok("发货成功");
}
return R.fail("发货失败!");
@@ -833,6 +875,9 @@
List<ComShopFlowerOrderGoodsDO> orderGoodsList =
comShopFlowerOrderGoodsDAO.selectList(new QueryWrapper<ComShopFlowerOrderGoodsDO>().lambda()
.eq(ComShopFlowerOrderGoodsDO::getOrderNo, shopOrderDO.getOrderNo()));
+
+ ConvenientMerchantDO storeDO = convenientMerchantDAO.selectById(shopOrderDO.getStoreId());
+
if (!orderGoodsList.isEmpty()) {
int goodsNub = 0;
for (ComShopFlowerOrderGoodsDO orderGood : orderGoodsList) {
@@ -855,7 +900,6 @@
}
// 更新店铺销量以及销售额
- ConvenientMerchantDO storeDO = convenientMerchantDAO.selectById(shopOrderDO.getStoreId());
if (storeDO != null) {
storeDO.setSale(storeDO.getSale() + goodsNub);
storeDO.setSaleVolume(storeDO.getSaleVolume().add(shopOrderDO.getTotalAmount()));
@@ -885,6 +929,21 @@
orderPayDO.setOrderId(shopOrderDO.getId());
orderPayDO.setPayType(ComShopFlowerOrderPayDO.payType.zf);
comShopFlowerOrderPayDAO.insert(orderPayDO);
+ if (nonNull(storeDO)){
+ WxMaService maService = wxMaConfiguration.getMaService(Constants.HC_APP_ID);
+ R sysUserVOR = userService.getSysUserVOByPhone(storeDO.getMobilePhone());
+ if (R.isOk(sysUserVOR)) {
+ SysUserVO sysUserVO = JSONObject.parseObject(JSONObject.toJSONString(sysUserVOR.getData()), SysUserVO.class);
+ try {
+ WxUtil.sendNewOrderNotice(sysUserVO.getOpenid(),maService.getAccessToken(),shopOrderDO.getOrderNo(),
+ shopOrderDO.getDeliveryType()==1?"拼单订单":"快递订单",orderGoodsList.get(0).getGoodsName(),
+ shopOrderDO.getTotalAmount().toString(),DateUtil.format(shopOrderDO.getCreateAt(),"yyyy-MM-dd HH:mm"));
+ } catch (WxErrorException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
}
/**
@@ -951,8 +1010,8 @@
Map<String, Integer> retMap = new HashMap<>();
int amountTotal = 0;
for (int i = 0; i < statusStr.length; i++) {
- if (collect.containsKey(i)) {
- Integer amount = collect.get(i);
+ if (collect.containsKey(i+1)) {
+ Integer amount = collect.get(i+1);
amountTotal = amountTotal + amount;
retMap.put(statusStr[i], amount);
} else {
@@ -990,8 +1049,8 @@
R r1 = this.selectCountByDeliveryType(ComShopFlowerOrderDO.deliveryType.express, userId);
retMap.put("kdddStatus", r1.getData());
//营业额
- List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS3 = this.baseMapper.selectSumAmountByStoreId(storeId);
- Map<String, Integer> yyeMap = comShopOrderStoreIdCountVOS3.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum));
+ List<ComShopOrderStoreIdNumVO> comShopOrderStoreIdCountVOS3 = this.baseMapper.selectSumAmountByStoreId(storeId);
+ Map<String, BigDecimal> yyeMap = comShopOrderStoreIdCountVOS3.stream().collect(Collectors.toMap(ComShopOrderStoreIdNumVO::getCountName, ComShopOrderStoreIdNumVO::getCountNum));
retMap.put("yye", yyeMap);
//在售商品
Integer countSale = comShopFlowerGoodsDAO.selectCountSaleByStoreId(storeId);
@@ -999,7 +1058,6 @@
//退款申请
Integer refundOrder = comShopFlowerRefundOrderDAO.selectCountByStoreId(storeId);
retMap.put("refundOrder", refundOrder);
-
return R.ok(retMap);
}
--
Gitblit v1.7.1