|
@@ -1,8 +1,12 @@
|
|
package com.kmall.admin.service.impl;
|
|
package com.kmall.admin.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
+import com.google.gson.internal.LinkedTreeMap;
|
|
import com.kmall.admin.dao.*;
|
|
import com.kmall.admin.dao.*;
|
|
import com.kmall.admin.dao.alarm.Mall2LowPriceWarningDao;
|
|
import com.kmall.admin.dao.alarm.Mall2LowPriceWarningDao;
|
|
import com.kmall.admin.dao.mk.Mk2GoodsTopicPriceDao;
|
|
import com.kmall.admin.dao.mk.Mk2GoodsTopicPriceDao;
|
|
@@ -16,20 +20,22 @@ import com.kmall.admin.dao.vip.Mall2PointsRulesDao;
|
|
import com.kmall.admin.dto.*;
|
|
import com.kmall.admin.dto.*;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.OrderProcessRecordEntity;
|
|
import com.kmall.admin.entity.OrderProcessRecordEntity;
|
|
-import com.kmall.admin.entity.alarm.Mall2LowPriceWarningEntity;
|
|
|
|
-import com.kmall.admin.entity.mk.Mk2GoodsTopicPriceEntity;
|
|
|
|
|
|
+import com.kmall.admin.entity.kmall2eccs.KtoEccsEntity;
|
|
import com.kmall.admin.entity.mk.store.*;
|
|
import com.kmall.admin.entity.mk.store.*;
|
|
import com.kmall.admin.entity.vip.Mall2MemberConsumptionRecordsEntity;
|
|
import com.kmall.admin.entity.vip.Mall2MemberConsumptionRecordsEntity;
|
|
import com.kmall.admin.entity.vip.Mall2MemberPointsEntity;
|
|
import com.kmall.admin.entity.vip.Mall2MemberPointsEntity;
|
|
import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
|
|
import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
import com.kmall.admin.service.*;
|
|
import com.kmall.admin.service.*;
|
|
|
|
+import com.kmall.admin.service.kmall2eccs.KtoEccsService;
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
import com.kmall.admin.service.mk.store.MkStoreTicketDiscountService;
|
|
import com.kmall.admin.service.mk.store.MkStoreTicketDiscountService;
|
|
import com.kmall.admin.utils.CalculateTax;
|
|
import com.kmall.admin.utils.CalculateTax;
|
|
|
|
+import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
|
|
+import com.kmall.admin.utils.data.response.ResponseMessageData;
|
|
|
|
+import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
import com.kmall.api.entity.*;
|
|
import com.kmall.api.entity.*;
|
|
-import com.kmall.api.entity.mk.MkStoreTicketDiscountVo;
|
|
|
|
import com.kmall.common.utils.ResponseData;
|
|
import com.kmall.common.utils.ResponseData;
|
|
import com.kmall.common.utils.wechat.WechatMicropayApiResult;
|
|
import com.kmall.common.utils.wechat.WechatMicropayApiResult;
|
|
import com.kmall.common.utils.wechat.WechatReverseApiResult;
|
|
import com.kmall.common.utils.wechat.WechatReverseApiResult;
|
|
@@ -41,6 +47,7 @@ import com.kmall.manager.manager.express.sf.properties.SFUtil;
|
|
import com.kmall.manager.manager.express.sf.entity.SfRouteServiceResponseEntity;
|
|
import com.kmall.manager.manager.express.sf.entity.SfRouteServiceResponseEntity;
|
|
import com.kmall.manager.manager.express.sf.entity.RouteEntity;
|
|
import com.kmall.manager.manager.express.sf.entity.RouteEntity;
|
|
import com.kmall.manager.manager.express.sf.entity.RouteResponseEntity;
|
|
import com.kmall.manager.manager.express.sf.entity.RouteResponseEntity;
|
|
|
|
+import com.kmall.manager.manager.merch.OmsMerchProperties;
|
|
import com.kmall.manager.manager.print.ticket.TicketPrintUtil;
|
|
import com.kmall.manager.manager.print.ticket.TicketPrintUtil;
|
|
import com.kmall.manager.manager.wechat.WechatUtil;
|
|
import com.kmall.manager.manager.wechat.WechatUtil;
|
|
import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
|
|
import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
|
|
@@ -54,7 +61,7 @@ import com.kmall.common.utils.*;
|
|
import com.kmall.common.utils.print.ticket.item.*;
|
|
import com.kmall.common.utils.print.ticket.item.*;
|
|
import com.kmall.manager.manager.express.kdn.KdniaoUtil;
|
|
import com.kmall.manager.manager.express.kdn.KdniaoUtil;
|
|
import com.kmall.common.utils.wechat.WechatRefundApiResult;
|
|
import com.kmall.common.utils.wechat.WechatRefundApiResult;
|
|
-import com.mysql.cj.util.TimeUtil;
|
|
|
|
|
|
+import okhttp3.Request;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -62,18 +69,13 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.net.InetAddress;
|
|
import java.net.InetAddress;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
-import java.text.DateFormat;
|
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
-import java.time.LocalDate;
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
@Service("orderService")
|
|
@Service("orderService")
|
|
@@ -82,6 +84,9 @@ public class OrderServiceImpl implements OrderService {
|
|
private final Logger LOGGER = LoggerFactory.getLogger(OrderServiceImpl.class);
|
|
private final Logger LOGGER = LoggerFactory.getLogger(OrderServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private OmsMerchProperties omsMerchProperties;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
private OrderDao orderDao;
|
|
private OrderDao orderDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ShippingDao shippingDao;
|
|
private ShippingDao shippingDao;
|
|
@@ -171,6 +176,11 @@ public class OrderServiceImpl implements OrderService {
|
|
private OrderExceptionRecordService orderExceptionRecordService;
|
|
private OrderExceptionRecordService orderExceptionRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private KtoEccsService ktoEccsService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public OrderEntity queryObject(Long id) {
|
|
public OrderEntity queryObject(Long id) {
|
|
return orderDao.queryObject(id);
|
|
return orderDao.queryObject(id);
|
|
@@ -710,7 +720,61 @@ public class OrderServiceImpl implements OrderService {
|
|
queryStorePromRealUpdateIsScan(order);
|
|
queryStorePromRealUpdateIsScan(order);
|
|
}
|
|
}
|
|
|
|
|
|
- private void updateStock(OrderEntity order, String changeReason) {
|
|
|
|
|
|
+
|
|
|
|
+ private synchronized void restoreInventory(OrderEntity order, String changeReason) {
|
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
|
+ SysUserEntity user = ShiroUtils.getUserEntity();
|
|
|
|
+ map.put("orderId", order.getId());
|
|
|
|
+ List<OrderGoodsEntity> orderGoodsVoList = orderGoodsDao.queryList(map);
|
|
|
|
+
|
|
|
|
+ // TODO 退单的库存明细存入表中,准备发送到中控
|
|
|
|
+ List<KtoEccsEntity> ktoEccsEntities = new LinkedList<>();
|
|
|
|
+ for (OrderGoodsEntity orderGoodsEntity : orderGoodsVoList) {
|
|
|
|
+ ProductStoreRelaEntity storeRelaEntity = productStoreRelaDao
|
|
|
|
+ .queryByGoodsIdAndStoreId(order.getStoreId().longValue(), orderGoodsEntity.getGoodsId().longValue());
|
|
|
|
+ if (null == storeRelaEntity || null == storeRelaEntity.getSellVolume()) {
|
|
|
|
+ storeRelaEntity.setSellVolume(0);
|
|
|
|
+ }
|
|
|
|
+ BigDecimal sellVolume = new BigDecimal(storeRelaEntity.getSellVolume() - orderGoodsEntity.getNumber());//销售量
|
|
|
|
+ if (sellVolume.compareTo(Constant.ZERO) < 0) {
|
|
|
|
+ sellVolume = Constant.ZERO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Integer stockNum = 0;
|
|
|
|
+ GoodsEntity goodsEntity = goodsDao.queryObject(orderGoodsEntity.getGoodsId());
|
|
|
|
+ if (goodsEntity != null) {
|
|
|
|
+ stockNum = goodsEntity.getGoodsNumber();
|
|
|
|
+ //还原商户商品库存
|
|
|
|
+ resetGoodsStock(stockNum, storeRelaEntity, orderGoodsEntity, sellVolume, changeReason, user);
|
|
|
|
+ }
|
|
|
|
+ if (null != storeRelaEntity.getStockNum()) {
|
|
|
|
+ stockNum = storeRelaEntity.getStockNum();
|
|
|
|
+ resetStoreGoodsStock(stockNum, storeRelaEntity, orderGoodsEntity, sellVolume, changeReason, user);//还原门店库存
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// orderGoodsVoList
|
|
|
|
+ KtoEccsEntity ktoEccsEntity = new KtoEccsEntity();
|
|
|
|
+ ktoEccsEntity.setRequestData(JSON.toJSONString(orderGoodsEntity));
|
|
|
|
+ ktoEccsEntity.setRequestType("04");
|
|
|
|
+ ktoEccsEntity.setSendStatus("00");
|
|
|
|
+ ktoEccsEntity.setCreaterSn(user.getUserId()+"");
|
|
|
|
+ ktoEccsEntity.setCreateTime(new Date());
|
|
|
|
+ ktoEccsEntities.add(ktoEccsEntity);
|
|
|
|
+ }
|
|
|
|
+ if(ktoEccsEntities.size() > 0){
|
|
|
|
+ if(ktoEccsEntities.size() > 50){
|
|
|
|
+ List<List<KtoEccsEntity>> partition = Lists.partition(ktoEccsEntities, 50);
|
|
|
|
+ for (List<KtoEccsEntity> ktoEccs : partition) {
|
|
|
|
+ ktoEccsService.saveBatch(ktoEccs);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ ktoEccsService.saveBatch(ktoEccsEntities);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private synchronized void updateStock(OrderEntity order, String changeReason) {
|
|
Map<String, Object> map = new HashMap();
|
|
Map<String, Object> map = new HashMap();
|
|
SysUserEntity user = ShiroUtils.getUserEntity();
|
|
SysUserEntity user = ShiroUtils.getUserEntity();
|
|
map.put("orderId", order.getId());
|
|
map.put("orderId", order.getId());
|
|
@@ -785,10 +849,17 @@ public class OrderServiceImpl implements OrderService {
|
|
if (goodsEntity != null) {
|
|
if (goodsEntity != null) {
|
|
goodsEntity.setGoodsNumber(stockNum + orderGoodsEntity.getNumber());
|
|
goodsEntity.setGoodsNumber(stockNum + orderGoodsEntity.getNumber());
|
|
// goodsEntity.setSellVolume(Integer.parseInt(goodsSellVolume.toString()));
|
|
// goodsEntity.setSellVolume(Integer.parseInt(goodsSellVolume.toString()));
|
|
|
|
+ if("oms退单成功,恢复库存".equals(changeReason)){
|
|
|
|
+ goodsEntity.setToBeRestored(goodsEntity.getToBeRestored() - orderGoodsEntity.getNumber());
|
|
|
|
+ }
|
|
goodsDao.update(goodsEntity);
|
|
goodsDao.update(goodsEntity);
|
|
|
|
|
|
// storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString()));
|
|
// storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString()));
|
|
// productStoreRelaDao.update(storeRelaEntity);
|
|
// productStoreRelaDao.update(storeRelaEntity);
|
|
|
|
+ String username = "system";
|
|
|
|
+ if(user != null){
|
|
|
|
+ username = user.getUsername();
|
|
|
|
+ }
|
|
|
|
|
|
MngChangeEntity mngChangeEntity = new MngChangeEntity();
|
|
MngChangeEntity mngChangeEntity = new MngChangeEntity();
|
|
mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
|
|
mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
|
|
@@ -800,8 +871,8 @@ public class OrderServiceImpl implements OrderService {
|
|
mngChangeEntity.setValidNum(stockNum + orderGoodsEntity.getNumber());//可用数
|
|
mngChangeEntity.setValidNum(stockNum + orderGoodsEntity.getNumber());//可用数
|
|
mngChangeEntity.setCreateTime(new Date());
|
|
mngChangeEntity.setCreateTime(new Date());
|
|
mngChangeEntity.setModTime(new Date());
|
|
mngChangeEntity.setModTime(new Date());
|
|
- mngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
|
- mngChangeEntity.setModerSn(user.getUsername());
|
|
|
|
|
|
+ mngChangeEntity.setCreaterSn(username);
|
|
|
|
+ mngChangeEntity.setModerSn(username);
|
|
mngChangeEntity.setIsValid(0);
|
|
mngChangeEntity.setIsValid(0);
|
|
mngChangeEntity.setMerchSn(goodsEntity.getMerchSn());
|
|
mngChangeEntity.setMerchSn(goodsEntity.getMerchSn());
|
|
mngChangeDao.save(mngChangeEntity);
|
|
mngChangeDao.save(mngChangeEntity);
|
|
@@ -822,8 +893,16 @@ public class OrderServiceImpl implements OrderService {
|
|
OrderGoodsEntity orderGoodsEntity, BigDecimal sellVolume, String changeReason, SysUserEntity user) {
|
|
OrderGoodsEntity orderGoodsEntity, BigDecimal sellVolume, String changeReason, SysUserEntity user) {
|
|
storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString())); // 减退库存
|
|
storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString())); // 减退库存
|
|
storeRelaEntity.setStockNum(stockNum + orderGoodsEntity.getNumber());//库存数量
|
|
storeRelaEntity.setStockNum(stockNum + orderGoodsEntity.getNumber());//库存数量
|
|
|
|
+ if("oms退单成功,恢复库存".equals(changeReason)){
|
|
|
|
+ storeRelaEntity.setToBeRestored(storeRelaEntity.getToBeRestored() - orderGoodsEntity.getNumber());
|
|
|
|
+ }
|
|
productStoreRelaDao.update(storeRelaEntity);
|
|
productStoreRelaDao.update(storeRelaEntity);
|
|
|
|
|
|
|
|
+
|
|
|
|
+ String username = "system";
|
|
|
|
+ if(user != null){
|
|
|
|
+ username = user.getUsername();
|
|
|
|
+ }
|
|
StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
storeMngChangeEntity.setChangeType(Dict.changeType.item_0.getItem());
|
|
storeMngChangeEntity.setChangeType(Dict.changeType.item_0.getItem());
|
|
storeMngChangeEntity.setChangeReason(changeReason);
|
|
storeMngChangeEntity.setChangeReason(changeReason);
|
|
@@ -835,8 +914,8 @@ public class OrderServiceImpl implements OrderService {
|
|
storeMngChangeEntity.setStoreValidNum(stockNum + orderGoodsEntity.getNumber());
|
|
storeMngChangeEntity.setStoreValidNum(stockNum + orderGoodsEntity.getNumber());
|
|
storeMngChangeEntity.setCreateTime(new Date());
|
|
storeMngChangeEntity.setCreateTime(new Date());
|
|
storeMngChangeEntity.setModTime(new Date());
|
|
storeMngChangeEntity.setModTime(new Date());
|
|
- storeMngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
|
- storeMngChangeEntity.setModerSn(user.getUsername());
|
|
|
|
|
|
+ storeMngChangeEntity.setCreaterSn(username);
|
|
|
|
+ storeMngChangeEntity.setModerSn(username);
|
|
storeMngChangeEntity.setIsValid(0);
|
|
storeMngChangeEntity.setIsValid(0);
|
|
storeMngChangeDao.save(storeMngChangeEntity);
|
|
storeMngChangeDao.save(storeMngChangeEntity);
|
|
}
|
|
}
|
|
@@ -2020,11 +2099,15 @@ public class OrderServiceImpl implements OrderService {
|
|
resultObj.put("errmsg", "订单提交失败");
|
|
resultObj.put("errmsg", "订单提交失败");
|
|
return resultObj;
|
|
return resultObj;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ List<OrderGoodsVo> orderGoodsVoList = new ArrayList<>();
|
|
|
|
+
|
|
for (GoodsEntity goodsDto : goodsEntities) {
|
|
for (GoodsEntity goodsDto : goodsEntities) {
|
|
|
|
|
|
OrderGoodsVo orderGoodsVo = setOrderGoodsVo(order, goodsDto);
|
|
OrderGoodsVo orderGoodsVo = setOrderGoodsVo(order, goodsDto);
|
|
//新增订单详情
|
|
//新增订单详情
|
|
orderGoodsDao.saveOrderGoodsVo(orderGoodsVo);
|
|
orderGoodsDao.saveOrderGoodsVo(orderGoodsVo);
|
|
|
|
+ orderGoodsVoList.add(orderGoodsVo);
|
|
}
|
|
}
|
|
//清空预订单商品临时表
|
|
//清空预订单商品临时表
|
|
Map orderInfoMap = Maps.newHashMap();
|
|
Map orderInfoMap = Maps.newHashMap();
|
|
@@ -2061,8 +2144,11 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- OrderEntity orderEntity = queryObject(order.getId());
|
|
|
|
- orderDao.update(orderEntity);
|
|
|
|
|
|
+// OrderEntity orderEntity = queryObject(order.getId());
|
|
|
|
+// TODO 到时候要注释掉,测试用而已
|
|
|
|
+// orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
|
|
|
|
+// orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
|
|
+// orderDao.update(orderEntity);
|
|
resultObj.put("shopName", store.getStoreName()); // 根据门店编号查询
|
|
resultObj.put("shopName", store.getStoreName()); // 根据门店编号查询
|
|
resultObj.put("userName", user.getUsername());
|
|
resultObj.put("userName", user.getUsername());
|
|
|
|
|
|
@@ -2137,6 +2223,32 @@ public class OrderServiceImpl implements OrderService {
|
|
WebSocketServer.sendMessage(sessionId, order.getOrder_sn(), order.getStore_id()
|
|
WebSocketServer.sendMessage(sessionId, order.getOrder_sn(), order.getStore_id()
|
|
+ "");
|
|
+ "");
|
|
|
|
|
|
|
|
+ // TODO 下单流程完成了,现在将下单的库存明细存入表中,准备发送到中控
|
|
|
|
+ List<KtoEccsEntity> ktoEccsEntities = new LinkedList<>();
|
|
|
|
+// orderGoodsVoList
|
|
|
|
+ for (OrderGoodsVo orderGoodsVo : orderGoodsVoList) {
|
|
|
|
+ KtoEccsEntity ktoEccsEntity = new KtoEccsEntity();
|
|
|
|
+ ktoEccsEntity.setRequestData(JSON.toJSONString(orderGoodsVo));
|
|
|
|
+ ktoEccsEntity.setRequestType("03");
|
|
|
|
+ ktoEccsEntity.setSendStatus("00");
|
|
|
|
+ ktoEccsEntity.setCreaterSn(user.getUserId()+"");
|
|
|
|
+ ktoEccsEntity.setCreateTime(new Date());
|
|
|
|
+ ktoEccsEntities.add(ktoEccsEntity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(ktoEccsEntities.size() > 0){
|
|
|
|
+ if(ktoEccsEntities.size() > 50){
|
|
|
|
+ List<List<KtoEccsEntity>> partition = Lists.partition(ktoEccsEntities, 50);
|
|
|
|
+ for (List<KtoEccsEntity> ktoEccs : partition) {
|
|
|
|
+ ktoEccsService.saveBatch(ktoEccs);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ ktoEccsService.saveBatch(ktoEccsEntities);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
return resultObj;
|
|
return resultObj;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -2522,17 +2634,13 @@ public class OrderServiceImpl implements OrderService {
|
|
return orderDao.queryObjectByOrderSn(orderSn);
|
|
return orderDao.queryObjectByOrderSn(orderSn);
|
|
}
|
|
}
|
|
|
|
|
|
- // TODO 退款的代码
|
|
|
|
|
|
+ // 收银端退款的代码
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public synchronized R orderRefund(OrderEntity order, String sessionId) throws Exception {
|
|
|
|
|
|
+ public synchronized R orderRefund(OrderEntity order, String sessionId, SysUserEntity user) throws Exception {
|
|
String payFlag = order.getPayFlag();
|
|
String payFlag = order.getPayFlag();
|
|
|
|
|
|
- boolean needUpdateStock = true;
|
|
|
|
- if (Dict.payFlag.item_cash.getItem().equals(payFlag)) {
|
|
|
|
- order.setPayStatus(Integer.parseInt(Dict.payStatus.item_4.getItem()));
|
|
|
|
- // TODO 微信的退款代码
|
|
|
|
- } else if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
|
|
|
|
+ if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
OrderEntity orderInfo = order;
|
|
OrderEntity orderInfo = order;
|
|
if (null == orderInfo) {
|
|
if (null == orderInfo) {
|
|
return R.error("订单不存在");
|
|
return R.error("订单不存在");
|
|
@@ -2548,33 +2656,80 @@ public class OrderServiceImpl implements OrderService {
|
|
String refundResult = "";
|
|
String refundResult = "";
|
|
if (orderInfo.getOrderStatus() != Integer.parseInt(Dict.orderStatus.item_0.getItem())) {
|
|
if (orderInfo.getOrderStatus() != Integer.parseInt(Dict.orderStatus.item_0.getItem())) {
|
|
LOGGER.info("微信退款开始");
|
|
LOGGER.info("微信退款开始");
|
|
- refundResult = wxRefund(orderInfo, totalActualPrice);
|
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(refundResult)) {
|
|
|
|
- return R.error(refundResult);
|
|
|
|
|
|
+
|
|
|
|
+ WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(), totalActualPrice,
|
|
|
|
+ orderInfo.getActualPrice().doubleValue());
|
|
|
|
+ OrderRefundEntity orderRefund = new OrderRefundEntity();
|
|
|
|
+ orderRefund.setRefundId(result.getRefund_id());
|
|
|
|
+ orderRefund.setOutRefundNo(result.getOut_trade_no());
|
|
|
|
+ orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(result.getRefund_fee())).divide(Constant.ONE_HUNDRED));
|
|
|
|
+ orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));//退款处理中
|
|
|
|
+ orderRefund.setModTime(new Date());
|
|
|
|
+ orderRefund.setRefundTime(new Date());
|
|
|
|
+ orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
|
|
|
|
+ orderRefund.setUserId(user.getUserId().intValue());
|
|
|
|
+ orderRefund.setRefundId(order.getUserId() + "");
|
|
|
|
+ orderRefund.setCreateTime(new Date());
|
|
|
|
+ List<OrderEntity> list = orderDao.queryObjectByMerchOrderSn(order.getMerchOrderSn());
|
|
|
|
+ if (list.size() > 1) {//多条订单
|
|
|
|
+ orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_2.getItem()));//部分退款
|
|
|
|
+ } else {
|
|
|
|
+ orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));//用户全额退款
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
order.setPayStatus(Integer.parseInt(Dict.payStatus.item_5.getItem()));
|
|
order.setPayStatus(Integer.parseInt(Dict.payStatus.item_5.getItem()));
|
|
order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
|
|
order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
|
|
LOGGER.info("微信退款");
|
|
LOGGER.info("微信退款");
|
|
|
|
+
|
|
|
|
+ orderDao.update(order);//修改为退款成功
|
|
|
|
+ // 修改取货码
|
|
|
|
+ PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(order.getOrderSn());
|
|
|
|
+ pickUpCodeEntity.setPickUpCodeStatus("3");
|
|
|
|
+ pickUpCodeService.update(pickUpCodeEntity);
|
|
|
|
+
|
|
|
|
+ // 判断该订单是否进入oms系统
|
|
|
|
+ if(!arrivedOms(order.getOrderSn())){
|
|
|
|
+ // oms无该订单,则直接退款
|
|
|
|
+ restoreInventory(order, "收银端退款");
|
|
|
|
+ orderRefund.setRestore(1);
|
|
|
|
+ } else{
|
|
|
|
+ // 如果oms有订单,统一进入锁库存情况
|
|
|
|
+ orderRefund.setRestore(0);
|
|
|
|
+ toBeRestoreInventory(order);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ orderRefundDao.save(orderRefund);//退款记录
|
|
}
|
|
}
|
|
// 支付宝的退款代码
|
|
// 支付宝的退款代码
|
|
} else if (Dict.payFlag.item_alipay.getItem().equals(payFlag)) {
|
|
} else if (Dict.payFlag.item_alipay.getItem().equals(payFlag)) {
|
|
|
|
|
|
|
|
+ OrderEntity orderInfo = order;
|
|
|
|
+ if (null == orderInfo) {
|
|
|
|
+ return R.error("订单不存在");
|
|
|
|
+ }
|
|
|
|
+ if (orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_401.getItem()) ||
|
|
|
|
+ orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_402.getItem())) {
|
|
|
|
+ return R.error("订单已退款");
|
|
|
|
+ }
|
|
|
|
+
|
|
AliPayMicropayApiResult userRefund = AliPayUtil.aliTradeRefund(order.getOrderSn(), order.getActualPrice().toString(),
|
|
AliPayMicropayApiResult userRefund = AliPayUtil.aliTradeRefund(order.getOrderSn(), order.getActualPrice().toString(),
|
|
"用户退款", order.getStoreId() + "");
|
|
"用户退款", order.getStoreId() + "");
|
|
|
|
|
|
LOGGER.info(userRefund.getSubMsg());
|
|
LOGGER.info(userRefund.getSubMsg());
|
|
- order.setPayStatus(Integer.parseInt(Dict.payStatus.item_5.getItem()));
|
|
|
|
- order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
|
|
|
|
|
|
+
|
|
OrderRefundEntity orderRefund = new OrderRefundEntity();
|
|
OrderRefundEntity orderRefund = new OrderRefundEntity();
|
|
orderRefund.setRefundId(userRefund.getTradeNo());
|
|
orderRefund.setRefundId(userRefund.getTradeNo());
|
|
orderRefund.setOutRefundNo(userRefund.getOutTradeNo());
|
|
orderRefund.setOutRefundNo(userRefund.getOutTradeNo());
|
|
- orderRefund
|
|
|
|
- .setRefundMoney(new BigDecimal(userRefund.getRefundFee()));
|
|
|
|
|
|
+ orderRefund.setRefundMoney(new BigDecimal(userRefund.getRefundFee()));
|
|
|
|
+
|
|
|
|
+
|
|
orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));//退款成功
|
|
orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));//退款成功
|
|
orderRefund.setModTime(new Date());
|
|
orderRefund.setModTime(new Date());
|
|
orderRefund.setRefundTime(new Date());
|
|
orderRefund.setRefundTime(new Date());
|
|
orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
|
|
orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
|
|
- orderRefund.setUserId(Integer.parseInt(order.getUserId() + ""));
|
|
|
|
|
|
+ orderRefund.setUserId(user.getUserId().intValue());
|
|
|
|
+ orderRefund.setRefundId(order.getUserId() + "");
|
|
orderRefund.setCreateTime(new Date());
|
|
orderRefund.setCreateTime(new Date());
|
|
List<OrderEntity> list = orderDao.queryObjectByMerchOrderSn(order.getMerchOrderSn());
|
|
List<OrderEntity> list = orderDao.queryObjectByMerchOrderSn(order.getMerchOrderSn());
|
|
if (list.size() > 1) {//多条订单
|
|
if (list.size() > 1) {//多条订单
|
|
@@ -2582,17 +2737,114 @@ public class OrderServiceImpl implements OrderService {
|
|
} else {
|
|
} else {
|
|
orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));//用户全额退款
|
|
orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));//用户全额退款
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ order.setPayStatus(Integer.parseInt(Dict.payStatus.item_5.getItem()));
|
|
|
|
+ order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
|
|
|
|
+ orderDao.update(order);//修改为退款成功
|
|
|
|
+ // 修改取货码
|
|
|
|
+ PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(order.getOrderSn());
|
|
|
|
+ pickUpCodeEntity.setPickUpCodeStatus("3");
|
|
|
|
+ pickUpCodeService.update(pickUpCodeEntity);
|
|
|
|
+ // 判断该订单是否进入oms系统
|
|
|
|
+ if(!arrivedOms(order.getOrderSn())){
|
|
|
|
+ // oms无该订单,则直接退款
|
|
|
|
+ restoreInventory(order, "收银端退款");
|
|
|
|
+ orderRefund.setRestore(1);
|
|
|
|
+ } else{
|
|
|
|
+ // 如果oms有订单,统一进入锁库存情况
|
|
|
|
+ orderRefund.setRestore(0);
|
|
|
|
+ toBeRestoreInventory(order);
|
|
|
|
+ }
|
|
|
|
+
|
|
orderRefundDao.save(orderRefund);//退款记录
|
|
orderRefundDao.save(orderRefund);//退款记录
|
|
}
|
|
}
|
|
- orderDao.update(order);//修改为退款成功
|
|
|
|
- // 修改取货码
|
|
|
|
- PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(order.getOrderSn());
|
|
|
|
- pickUpCodeEntity.setPickUpCodeStatus("3");
|
|
|
|
- pickUpCodeService.update(pickUpCodeEntity);
|
|
|
|
- updateStock(order, "收银端退款");
|
|
|
|
|
|
+
|
|
return R.ok("退款成功");
|
|
return R.ok("退款成功");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ public void toBeRestoreInventory(OrderEntity order) {
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
|
+ SysUserEntity user = ShiroUtils.getUserEntity();
|
|
|
|
+ map.put("orderId", order.getId());
|
|
|
|
+ List<OrderGoodsEntity> orderGoodsVoList = orderGoodsDao.queryList(map);
|
|
|
|
+ for (OrderGoodsEntity orderGoodsEntity : orderGoodsVoList) {
|
|
|
|
+ Integer restoreNumber = orderGoodsEntity.getNumber();
|
|
|
|
+ ProductStoreRelaEntity storeRelaEntity = productStoreRelaDao
|
|
|
|
+ .queryByGoodsIdAndStoreId(order.getStoreId().longValue(), orderGoodsEntity.getGoodsId().longValue());
|
|
|
|
+ Integer toBeRestored = storeRelaEntity.getToBeRestored();
|
|
|
|
+ if(toBeRestored == null){
|
|
|
|
+ toBeRestored = 0;
|
|
|
|
+ }
|
|
|
|
+ // 修改待退款的数量
|
|
|
|
+ storeRelaEntity.setToBeRestored(toBeRestored +restoreNumber);
|
|
|
|
+
|
|
|
|
+ GoodsEntity goodsEntity = goodsDao.queryObject(orderGoodsEntity.getGoodsId());
|
|
|
|
+
|
|
|
|
+ toBeRestored = goodsEntity.getToBeRestored();
|
|
|
|
+ if(toBeRestored == null){
|
|
|
|
+ toBeRestored = 0;
|
|
|
|
+ }
|
|
|
|
+ goodsEntity.setToBeRestored(toBeRestored+restoreNumber);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ productStoreRelaDao.update(storeRelaEntity);
|
|
|
|
+ goodsDao.update(goodsEntity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询oms系统是否有该订单
|
|
|
|
+ * @param orderSn
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private boolean arrivedOms(String orderSn) {
|
|
|
|
+
|
|
|
|
+ Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
|
|
+// sParaTemp.put("data","ZWCW2020122749351849");
|
|
|
|
+ sParaTemp.put("data",orderSn);
|
|
|
|
+ sParaTemp.put("merchId",omsMerchProperties.getMerchSn());
|
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis()/1000);
|
|
|
|
+ sParaTemp.put("timestamp", timestamp);
|
|
|
|
+ //生成要请求给oms秘钥
|
|
|
|
+// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
|
|
+ LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
|
|
+ String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
|
|
|
|
+ sParaTemp.put("sign", sign);
|
|
|
|
+ //构建Request
|
|
|
|
+ String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
|
|
+ Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
|
|
+ LOGGER.info("oms的请求报文:" + request);
|
|
|
|
+ // 同步访问,返回结果字符串
|
|
|
|
+ String responseString = null;
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LOGGER.info("oms的响应报文"+responseString);
|
|
|
|
+ //解析响应数据
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
|
|
+ if(result == null){
|
|
|
|
+ String info = "解析响应数据Result失败";
|
|
|
|
+ LOGGER.error("--- {}", info);
|
|
|
|
+ throw new RuntimeException(info);
|
|
|
|
+ }
|
|
|
|
+ if("oms无该订单".equals(result.getMsg())){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private String wxRefund(OrderEntity orderInfo, Double totalActualPrice) {
|
|
private String wxRefund(OrderEntity orderInfo, Double totalActualPrice) {
|
|
WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(), totalActualPrice,
|
|
WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(), totalActualPrice,
|
|
@@ -2670,30 +2922,28 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<OrderEntity> queryLastDayOrder() {
|
|
|
|
|
|
+ public List<OrderEntity> queryLastDayOrder(String comparedDate) {
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
+//
|
|
|
|
+// DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//格式化一下时间
|
|
|
|
+//
|
|
|
|
+// Date dNow = new Date(); //当前时间
|
|
|
|
+//
|
|
|
|
+// Date dBefore = new Date();
|
|
|
|
+//
|
|
|
|
+// Calendar calendar = Calendar.getInstance(); //得到日历
|
|
|
|
+//
|
|
|
|
+// calendar.setTime(dNow);//把当前时间赋给日历
|
|
|
|
+//
|
|
|
|
+// calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天
|
|
|
|
+//
|
|
|
|
+// dBefore = calendar.getTime(); //得到前一天的时间
|
|
|
|
|
|
- DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//格式化一下时间
|
|
|
|
-
|
|
|
|
- Date dNow = new Date(); //当前时间
|
|
|
|
-
|
|
|
|
- Date dBefore = new Date();
|
|
|
|
-
|
|
|
|
- Calendar calendar = Calendar.getInstance(); //得到日历
|
|
|
|
-
|
|
|
|
- calendar.setTime(dNow);//把当前时间赋给日历
|
|
|
|
-
|
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天
|
|
|
|
-
|
|
|
|
- dBefore = calendar.getTime(); //得到前一天的时间
|
|
|
|
-
|
|
|
|
- String defaultStartDate = dateFmt.format(dBefore); //格式化前一天
|
|
|
|
-
|
|
|
|
- defaultStartDate = defaultStartDate.substring(0, 10) + " 00:00:00";
|
|
|
|
|
|
+ String defaultStartDate = comparedDate + " 00:00:00";
|
|
|
|
|
|
|
|
|
|
- String defaultEndDate = defaultStartDate.substring(0, 10) + " 23:59:59";
|
|
|
|
|
|
+ String defaultEndDate = comparedDate + " 23:59:59";
|
|
|
|
|
|
|
|
|
|
map.put("startTime", defaultStartDate);
|
|
map.put("startTime", defaultStartDate);
|
|
@@ -2812,16 +3062,16 @@ public class OrderServiceImpl implements OrderService {
|
|
// 获取实际支付价格
|
|
// 获取实际支付价格
|
|
String postTaxPrice = taxDetailDto.getPostTaxPrice();
|
|
String postTaxPrice = taxDetailDto.getPostTaxPrice();
|
|
// 获取总税额
|
|
// 获取总税额
|
|
- String taxStr = taxDetailDto.getTax();
|
|
|
|
|
|
+ String taxStr = taxDetailDto.getPreTax();
|
|
// 税前金额
|
|
// 税前金额
|
|
BigDecimal tax = new BigDecimal(taxStr);
|
|
BigDecimal tax = new BigDecimal(taxStr);
|
|
BigDecimal pretaxPrice = new BigDecimal(postTaxPrice).subtract(tax).setScale(2, RoundingMode.HALF_UP);
|
|
BigDecimal pretaxPrice = new BigDecimal(postTaxPrice).subtract(tax).setScale(2, RoundingMode.HALF_UP);
|
|
// 计算综合税率
|
|
// 计算综合税率
|
|
BigDecimal taxRate = tax.divide(pretaxPrice, 4, RoundingMode.HALF_UP);
|
|
BigDecimal taxRate = tax.divide(pretaxPrice, 4, RoundingMode.HALF_UP);
|
|
// 消费税率
|
|
// 消费税率
|
|
- BigDecimal saleTaxRate = new BigDecimal(taxDetailDto.getSaleTaxRate()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
|
|
|
|
|
|
+ BigDecimal saleTaxRate = new BigDecimal(taxDetailDto.getPreSaleTax()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
|
|
// 综合税率
|
|
// 综合税率
|
|
- BigDecimal vatRate = new BigDecimal(taxDetailDto.getVatRate()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
|
|
|
|
|
|
+ BigDecimal vatRate = new BigDecimal(taxDetailDto.getPreVat()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
|
|
// 消费税 = (明细商品总价 / (1-消费税税率)) * 消费税税率
|
|
// 消费税 = (明细商品总价 / (1-消费税税率)) * 消费税税率
|
|
// 增值税 = (明细商品总价 + 消费税) * 增值税税率
|
|
// 增值税 = (明细商品总价 + 消费税) * 增值税税率
|
|
// 订单该商品总税费 = (商品消费税 + 商品增值税)* 0.7
|
|
// 订单该商品总税费 = (商品消费税 + 商品增值税)* 0.7
|
|
@@ -2838,8 +3088,8 @@ public class OrderServiceImpl implements OrderService {
|
|
// 不需要算消费税,增值税计算
|
|
// 不需要算消费税,增值税计算
|
|
vat = pretaxPrice.multiply(vatRate).multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
vat = pretaxPrice.multiply(vatRate).multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
}
|
|
}
|
|
- taxDetailDto.setPreSaleTax(saleTax.toString());
|
|
|
|
- taxDetailDto.setPreVat(vat.toString());
|
|
|
|
|
|
+ taxDetailDto.setPreSaleTax(saleTax.compareTo(BigDecimal.ZERO)==0?saleTax.toString():"-"+saleTax.toString());
|
|
|
|
+ taxDetailDto.setPreVat(vat.compareTo(BigDecimal.ZERO)==0?vat.toString():"-"+vat.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2848,6 +3098,99 @@ public class OrderServiceImpl implements OrderService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> queryInveResponse(String orderSn) throws IOException {
|
|
|
|
+ Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
|
|
+ sParaTemp.put("data",orderSn);
|
|
|
|
+ sParaTemp.put("merchId",omsMerchProperties.getMerchSn());
|
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis()/1000);
|
|
|
|
+ sParaTemp.put("timestamp", timestamp);
|
|
|
|
+ //生成要请求给oms秘钥
|
|
|
|
+// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
|
|
+ LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
|
|
+ String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
|
|
|
|
+ sParaTemp.put("sign", sign);
|
|
|
|
+ //构建Request
|
|
|
|
+ String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
|
|
+ Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
|
|
+ LOGGER.info("oms的请求报文:" + request);
|
|
|
|
+ // 同步访问,返回结果字符串
|
|
|
|
+ String responseString = null;
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LOGGER.info("oms的响应报文"+responseString);
|
|
|
|
+ //解析响应数据
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
|
|
+ if(result == null){
|
|
|
|
+ String info = "解析响应数据Result失败";
|
|
|
|
+ LOGGER.error("--- {}", info);
|
|
|
|
+ throw new RuntimeException(info);
|
|
|
|
+ }
|
|
|
|
+ ResponseMessageData data = result.getData();
|
|
|
|
+ List rows = data.getRows();
|
|
|
|
+ List<String> resultMessage = new LinkedList<>();
|
|
|
|
+ for (Object row : rows) {
|
|
|
|
+ if(row instanceof ArrayList){
|
|
|
|
+ for (Object o : ((ArrayList<?>) row)) {
|
|
|
|
+ if(o instanceof LinkedTreeMap){
|
|
|
|
+ String cusReturnInfo = (String) ((LinkedTreeMap<?, ?>) o).get("cusReturnInfo");
|
|
|
|
+ resultMessage.add(cusReturnInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+// cusReturnInfo -> [Code:2600;Desc:放行]
|
|
|
|
+ return resultMessage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有状态为201的订单。且下单时间超过5分钟的订单
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<OrderEntity> queryAll201Order() {
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String date = format.format(new Date());
|
|
|
|
+ return orderDao.queryAll201Order(date);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 恢复kmall退单冻结的库存
|
|
|
|
+ *
|
|
|
|
+ * @param orderSn
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void toBeRestored(String orderSn) {
|
|
|
|
+
|
|
|
|
+ // 查询该订单在库存是否已经释放过,避免重复恢复库存
|
|
|
|
+ OrderEntity orderInfo = orderDao.queryObjectByOrderSn(orderSn);
|
|
|
|
+ OrderRefundEntity orderRefundEntity = orderRefundService.queryObjectByOrderId(orderInfo.getId());
|
|
|
|
+ if(orderRefundEntity == null){
|
|
|
|
+ LOGGER.error("该订单无退款记录,订单号{}",orderSn);
|
|
|
|
+ throw new RuntimeException("该订单无退款记录,订单号:"+orderSn);
|
|
|
|
+ }
|
|
|
|
+ Integer restore = orderRefundEntity.getRestore();
|
|
|
|
+ if(restore == 1){
|
|
|
|
+ LOGGER.error("该订单库存记录已恢复过,订单号{}",orderSn);
|
|
|
|
+ throw new RuntimeException("该订单库存记录已恢复过,订单号:"+orderSn);
|
|
|
|
+ }
|
|
|
|
+ restoreInventory(orderInfo,"oms退单成功,恢复库存");
|
|
|
|
+ orderRefundEntity.setRestore(1);
|
|
|
|
+ orderRefundService.update(orderRefundEntity);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置订单数据
|
|
* 设置订单数据
|
|
@@ -3003,7 +3346,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
// 计算税费
|
|
// 计算税费
|
|
GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue());
|
|
GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue());
|
|
- BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,goodsDto.getActualPaymentAmount().divide(number,2,RoundingMode.HALF_UP),goodsService).setScale(3,RoundingMode.HALF_UP);
|
|
|
|
|
|
+ BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,goodsDto.getStoreRetailPrice(),goodsService).setScale(3,RoundingMode.HALF_UP);
|
|
goodsTax = goodsTax.multiply(number).setScale(2,RoundingMode.HALF_UP);
|
|
goodsTax = goodsTax.multiply(number).setScale(2,RoundingMode.HALF_UP);
|
|
orderGoodsVo.setTaxPrice(goodsTax);
|
|
orderGoodsVo.setTaxPrice(goodsTax);
|
|
|
|
|