|
@@ -1,5 +1,6 @@
|
|
package com.kmall.admin.service.impl;
|
|
package com.kmall.admin.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.io.IoUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
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;
|
|
@@ -35,6 +36,7 @@ import com.kmall.admin.utils.ShiroUtils;
|
|
import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
import com.kmall.admin.utils.data.response.ResponseMessage;
|
|
import com.kmall.admin.utils.data.response.ResponseMessageData;
|
|
import com.kmall.admin.utils.data.response.ResponseMessageData;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
|
|
+import com.kmall.admin.utils.pdf.BarcodeUtil;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
import com.kmall.api.entity.OrderGoodsVo;
|
|
import com.kmall.api.entity.OrderGoodsVo;
|
|
import com.kmall.api.entity.OrderVo;
|
|
import com.kmall.api.entity.OrderVo;
|
|
@@ -58,6 +60,7 @@ import com.kmall.manager.manager.merch.OmsMerchProperties;
|
|
import com.kmall.manager.manager.merch.OmsMerchPropertiesBuilder;
|
|
import com.kmall.manager.manager.merch.OmsMerchPropertiesBuilder;
|
|
import com.kmall.manager.manager.print.ticket.PrintTicketPropertiesBuilder;
|
|
import com.kmall.manager.manager.print.ticket.PrintTicketPropertiesBuilder;
|
|
import com.kmall.manager.manager.print.ticket.TicketPrintUtil;
|
|
import com.kmall.manager.manager.print.ticket.TicketPrintUtil;
|
|
|
|
+import com.kmall.manager.manager.redis.JedisUtil;
|
|
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;
|
|
import okhttp3.Request;
|
|
import okhttp3.Request;
|
|
@@ -67,14 +70,21 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
|
+import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
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.nio.charset.Charset;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
|
|
@Service("orderService")
|
|
@Service("orderService")
|
|
@@ -174,12 +184,14 @@ public class OrderServiceImpl implements OrderService {
|
|
@Autowired
|
|
@Autowired
|
|
private OrderExceptionRecordService orderExceptionRecordService;
|
|
private OrderExceptionRecordService orderExceptionRecordService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private AddressInfoService addressInfoService;
|
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private KtoEccsService ktoEccsService;
|
|
private KtoEccsService ktoEccsService;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public OrderEntity queryObject(Long id) {
|
|
public OrderEntity queryObject(Long id) {
|
|
return orderDao.queryObject(id);
|
|
return orderDao.queryObject(id);
|
|
@@ -415,9 +427,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
GoodsEntity goodsEntity = goodsService.queryObject(orderGoods.getGoodsId());
|
|
GoodsEntity goodsEntity = goodsService.queryObject(orderGoods.getGoodsId());
|
|
- BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,orderGoods.getRetailPrice(),goodsService).setScale(3,RoundingMode.HALF_UP);
|
|
|
|
- goodsTax = goodsTax.multiply(new BigDecimal(orderGoods.getNumber())).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
- taxTotal = taxTotal.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
|
+ BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, orderGoods.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ goodsTax = goodsTax.multiply(new BigDecimal(orderGoods.getNumber())).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ taxTotal = taxTotal.add(goodsTax).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
Goods goods = new Goods(orderGoods.getGoodsName(),
|
|
Goods goods = new Goods(orderGoods.getGoodsName(),
|
|
orderGoods.getRetailPrice().toString(), // 含税价
|
|
orderGoods.getRetailPrice().toString(), // 含税价
|
|
@@ -475,7 +487,44 @@ public class OrderServiceImpl implements OrderService {
|
|
// e.printStackTrace();
|
|
// e.printStackTrace();
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
- return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing);
|
|
|
|
|
|
+ TicketMailInfo mailInfo = new TicketMailInfo();
|
|
|
|
+ String exprNo = orderProcessRecordEntity.getLogisticsNo();
|
|
|
|
+ if (StringUtils.isNullOrEmpty(exprNo)) {
|
|
|
|
+ throw new RRException("快递面单为空,请联系客服");
|
|
|
|
+ }
|
|
|
|
+ mailInfo.setExprNo(exprNo);
|
|
|
|
+ String logoUrl = "/statics/img/yto_logo.jpg";
|
|
|
|
+
|
|
|
|
+ Map<String, String> logoMap = new HashMap<>();
|
|
|
|
+ logoMap.put("yto", "/statics/img/yto_logo.jpg");
|
|
|
|
+ logoMap.put("best", "/statics/img/bestex_logo3.png");
|
|
|
|
+ if (StringUtils.isNotEmpty(orderEntity.getShippingCode()) && logoMap.containsKey(orderEntity.getShippingCode())) {
|
|
|
|
+ logoUrl = logoMap.get(orderEntity.getShippingCode());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mailInfo.setExprLogoUrl(logoUrl);
|
|
|
|
+ byte[] barCode128 = BarcodeUtil.generateBarCode128(exprNo, 6.0D, null, true, false);
|
|
|
|
+ String exprNoBase64Img = new String(Base64.getEncoder().encode(barCode128));
|
|
|
|
+ mailInfo.setShopTel("0752-2688660");
|
|
|
|
+
|
|
|
|
+ // 发货人
|
|
|
|
+ mailInfo.setSenderTel("0752-2688660");
|
|
|
|
+ mailInfo.setSenderName("CW澳洲大药房");
|
|
|
|
+ mailInfo.setSenderProvince("广东省");
|
|
|
|
+ mailInfo.setSenderCity("深圳市");
|
|
|
|
+ mailInfo.setSenderDistrict("南山区");
|
|
|
|
+ mailInfo.setSenderAddress("前海综合保税区W104");
|
|
|
|
+
|
|
|
|
+ // 收货人
|
|
|
|
+ mailInfo.setConsigneeMob(new StringBuilder(orderEntity.getMobile()).replace(3, 7, "****").toString());
|
|
|
|
+ mailInfo.setConsigneeName(new StringBuilder(orderEntity.getConsignee()).replace(1, 2, "*").toString());
|
|
|
|
+ mailInfo.setConsigneeProvince(orderEntity.getProvince());
|
|
|
|
+ mailInfo.setConsigneeCity(orderEntity.getCity());
|
|
|
|
+ mailInfo.setConsigneeDistrict(orderEntity.getDistrict());
|
|
|
|
+ mailInfo.setConsigneeAddress(orderEntity.getAddress());
|
|
|
|
+
|
|
|
|
+ mailInfo.setExprNoBase64Img(exprNoBase64Img);
|
|
|
|
+ return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing, mailInfo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -757,21 +806,21 @@ public class OrderServiceImpl implements OrderService {
|
|
ktoEccsEntity.setRequestData(JSON.toJSONString(orderGoodsEntity));
|
|
ktoEccsEntity.setRequestData(JSON.toJSONString(orderGoodsEntity));
|
|
ktoEccsEntity.setRequestType("04");
|
|
ktoEccsEntity.setRequestType("04");
|
|
ktoEccsEntity.setSendStatus("00");
|
|
ktoEccsEntity.setSendStatus("00");
|
|
- if(user != null){
|
|
|
|
- ktoEccsEntity.setCreaterSn(user.getUserId()+"");
|
|
|
|
- }else{
|
|
|
|
|
|
+ if (user != null) {
|
|
|
|
+ ktoEccsEntity.setCreaterSn(user.getUserId() + "");
|
|
|
|
+ } else {
|
|
ktoEccsEntity.setCreaterSn("9999");
|
|
ktoEccsEntity.setCreaterSn("9999");
|
|
}
|
|
}
|
|
ktoEccsEntity.setCreateTime(new Date());
|
|
ktoEccsEntity.setCreateTime(new Date());
|
|
ktoEccsEntities.add(ktoEccsEntity);
|
|
ktoEccsEntities.add(ktoEccsEntity);
|
|
}
|
|
}
|
|
- if(ktoEccsEntities.size() > 0){
|
|
|
|
- if(ktoEccsEntities.size() > 50){
|
|
|
|
|
|
+ if (ktoEccsEntities.size() > 0) {
|
|
|
|
+ if (ktoEccsEntities.size() > 50) {
|
|
List<List<KtoEccsEntity>> partition = Lists.partition(ktoEccsEntities, 50);
|
|
List<List<KtoEccsEntity>> partition = Lists.partition(ktoEccsEntities, 50);
|
|
for (List<KtoEccsEntity> ktoEccs : partition) {
|
|
for (List<KtoEccsEntity> ktoEccs : partition) {
|
|
ktoEccsService.saveBatch(ktoEccs);
|
|
ktoEccsService.saveBatch(ktoEccs);
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
ktoEccsService.saveBatch(ktoEccsEntities);
|
|
ktoEccsService.saveBatch(ktoEccsEntities);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -852,7 +901,7 @@ 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)){
|
|
|
|
|
|
+ if ("oms退单成功,恢复库存".equals(changeReason)) {
|
|
goodsEntity.setToBeRestored(goodsEntity.getToBeRestored() - orderGoodsEntity.getNumber());
|
|
goodsEntity.setToBeRestored(goodsEntity.getToBeRestored() - orderGoodsEntity.getNumber());
|
|
}
|
|
}
|
|
goodsDao.update(goodsEntity);
|
|
goodsDao.update(goodsEntity);
|
|
@@ -860,7 +909,7 @@ public class OrderServiceImpl implements OrderService {
|
|
// storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString()));
|
|
// storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString()));
|
|
// productStoreRelaDao.update(storeRelaEntity);
|
|
// productStoreRelaDao.update(storeRelaEntity);
|
|
String username = "system";
|
|
String username = "system";
|
|
- if(user != null){
|
|
|
|
|
|
+ if (user != null) {
|
|
username = user.getUsername();
|
|
username = user.getUsername();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -896,14 +945,14 @@ 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)){
|
|
|
|
|
|
+ if ("oms退单成功,恢复库存".equals(changeReason)) {
|
|
storeRelaEntity.setToBeRestored(storeRelaEntity.getToBeRestored() - orderGoodsEntity.getNumber());
|
|
storeRelaEntity.setToBeRestored(storeRelaEntity.getToBeRestored() - orderGoodsEntity.getNumber());
|
|
}
|
|
}
|
|
productStoreRelaDao.update(storeRelaEntity);
|
|
productStoreRelaDao.update(storeRelaEntity);
|
|
|
|
|
|
|
|
|
|
String username = "system";
|
|
String username = "system";
|
|
- if(user != null){
|
|
|
|
|
|
+ if (user != null) {
|
|
username = user.getUsername();
|
|
username = user.getUsername();
|
|
}
|
|
}
|
|
StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
@@ -1798,7 +1847,7 @@ public class OrderServiceImpl implements OrderService {
|
|
Map<String, String> mapAddr = new HashMap<>();
|
|
Map<String, String> mapAddr = new HashMap<>();
|
|
if (status == 0) {
|
|
if (status == 0) {
|
|
//省
|
|
//省
|
|
- String cmbProvince = (String)param.get("cmbProvince");
|
|
|
|
|
|
+ String cmbProvince = (String) param.get("cmbProvince");
|
|
//市
|
|
//市
|
|
String cmbCity = (String) param.get("cmbCity");
|
|
String cmbCity = (String) param.get("cmbCity");
|
|
//区
|
|
//区
|
|
@@ -1806,10 +1855,10 @@ public class OrderServiceImpl implements OrderService {
|
|
//详细地址
|
|
//详细地址
|
|
String addrUser = (String) param.get("addrUser");
|
|
String addrUser = (String) param.get("addrUser");
|
|
|
|
|
|
- mapAddr.put("cmbProvince",cmbProvince);
|
|
|
|
- mapAddr.put("cmbCity",cmbCity);
|
|
|
|
- mapAddr.put("cmbArea",cmbArea);
|
|
|
|
- mapAddr.put("addrUser",addrUser);
|
|
|
|
|
|
+ mapAddr.put("cmbProvince", cmbProvince);
|
|
|
|
+ mapAddr.put("cmbCity", cmbCity);
|
|
|
|
+ mapAddr.put("cmbArea", cmbArea);
|
|
|
|
+ mapAddr.put("addrUser", addrUser);
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -2068,9 +2117,6 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// TODO 查询使用的优惠券,并减扣金额
|
|
// TODO 查询使用的优惠券,并减扣金额
|
|
String couponSn = (String) userInfo.get("couponSn");
|
|
String couponSn = (String) userInfo.get("couponSn");
|
|
// 获取当前时间
|
|
// 获取当前时间
|
|
@@ -2102,7 +2148,7 @@ public class OrderServiceImpl implements OrderService {
|
|
// 生成订单
|
|
// 生成订单
|
|
String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
|
|
String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
|
|
|
|
|
|
- OrderVo order = setOrderVo(goodsEntities, userEntity, storeId.longValue(), user.getMerchSn(), disCountAmount, totalTax,status,mapAddr);
|
|
|
|
|
|
+ OrderVo order = setOrderVo(goodsEntities, userEntity, storeId.longValue(), user.getMerchSn(), disCountAmount, totalTax, status, mapAddr);
|
|
order.setStore_id(storeId.longValue());
|
|
order.setStore_id(storeId.longValue());
|
|
// if(storeTopic != null){
|
|
// if(storeTopic != null){
|
|
// order.setActivity_id(storeTopic.getId().longValue());
|
|
// order.setActivity_id(storeTopic.getId().longValue());
|
|
@@ -2153,29 +2199,32 @@ public class OrderServiceImpl implements OrderService {
|
|
// 设置支付单开始时间
|
|
// 设置支付单开始时间
|
|
processRecordEntity.setPaymentStartTime(new Date());
|
|
processRecordEntity.setPaymentStartTime(new Date());
|
|
// 判断是微信的支付码还是支付宝的支付码
|
|
// 判断是微信的支付码还是支付宝的支付码
|
|
-// if (parCode.startsWith("28")) {
|
|
|
|
-// // 支付宝支付
|
|
|
|
-// try {
|
|
|
|
-// AliPay(user, parCode, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// throw e;
|
|
|
|
-// }
|
|
|
|
-// } else {
|
|
|
|
-// // 微信支付
|
|
|
|
-// try {
|
|
|
|
-// wxPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// throw e;
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
|
|
+ if (parCode.startsWith("28")) {
|
|
|
|
+ // 支付宝支付
|
|
|
|
+ try {
|
|
|
|
+ AliPay(user, parCode, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 微信支付
|
|
|
|
+ try {
|
|
|
|
+ wxPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// // TODO 到时候要注释掉,测试用而已
|
|
|
|
+// OrderEntity orderEntity = queryObject(order.getId());
|
|
|
|
+// orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
|
|
|
|
+// orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
|
|
+// orderEntity.setPayTime(new Date());
|
|
|
|
+// orderDao.update(orderEntity);
|
|
|
|
+
|
|
|
|
|
|
- //// TODO 到时候要注释掉,测试用而已
|
|
|
|
- OrderEntity orderEntity = queryObject(order.getId());
|
|
|
|
- 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());
|
|
|
|
|
|
@@ -2246,7 +2295,7 @@ public class OrderServiceImpl implements OrderService {
|
|
resultObj.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
resultObj.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
resultObj.put("orderNo", order.getOrder_sn()); //
|
|
resultObj.put("orderNo", order.getOrder_sn()); //
|
|
|
|
|
|
- resultObj.put("phone",(String) userInfo.get("customPhone"));
|
|
|
|
|
|
+ resultObj.put("phone", (String) userInfo.get("customPhone"));
|
|
// 通知WebSocket
|
|
// 通知WebSocket
|
|
WebSocketServer.sendMessage(sessionId, order.getOrder_sn(), order.getStore_id()
|
|
WebSocketServer.sendMessage(sessionId, order.getOrder_sn(), order.getStore_id()
|
|
+ "");
|
|
+ "");
|
|
@@ -2665,21 +2714,44 @@ public class OrderServiceImpl implements OrderService {
|
|
return orderDao.queryObjectByOrderSn(orderSn);
|
|
return orderDao.queryObjectByOrderSn(orderSn);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ExecutorService service = Executors.newSingleThreadExecutor();
|
|
// 收银端退款的代码
|
|
// 收银端退款的代码
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public synchronized R orderRefund(OrderEntity order, String sessionId, SysUserEntity user) throws Exception {
|
|
public synchronized R orderRefund(OrderEntity order, String sessionId, SysUserEntity user) throws Exception {
|
|
|
|
+ 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("订单已退款");
|
|
|
|
+ }
|
|
|
|
+
|
|
String payFlag = order.getPayFlag();
|
|
String payFlag = order.getPayFlag();
|
|
|
|
|
|
- if (Dict.payFlag.item_weixin.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("订单已退款");
|
|
|
|
|
|
+ String key = "kmall_order_refund_" + order.getOrderSn();
|
|
|
|
+ if (JedisUtil.exists(key)) {
|
|
|
|
+ return R.error("订单退款操作过快,请等待!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JedisUtil.set(key, System.currentTimeMillis() + "", 2);
|
|
|
|
+ if (orderInfo.getPayStatus() == Integer.parseInt(Dict.payStatus.item_3.getItem())) {
|
|
|
|
+ return R.error("订单正在退款中,请勿重复退款");
|
|
|
|
+ }
|
|
|
|
+ CountDownLatch cdl = new CountDownLatch(1);
|
|
|
|
+ service.submit(()-> {
|
|
|
|
+ try {
|
|
|
|
+ orderDao.updateOrderRefunding(order.getId());
|
|
|
|
+ } finally {
|
|
|
|
+ cdl.countDown();
|
|
}
|
|
}
|
|
|
|
+ });
|
|
|
|
+ cdl.await();
|
|
|
|
+
|
|
|
|
+ if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
|
|
+
|
|
Double totalActualPrice = orderDao.getTotalActualPrice(orderInfo.getMerchOrderSn());
|
|
Double totalActualPrice = orderDao.getTotalActualPrice(orderInfo.getMerchOrderSn());
|
|
if (totalActualPrice == null) {
|
|
if (totalActualPrice == null) {
|
|
totalActualPrice = 0d;
|
|
totalActualPrice = 0d;
|
|
@@ -2720,11 +2792,11 @@ public class OrderServiceImpl implements OrderService {
|
|
pickUpCodeService.update(pickUpCodeEntity);
|
|
pickUpCodeService.update(pickUpCodeEntity);
|
|
|
|
|
|
// 判断该订单是否进入oms系统
|
|
// 判断该订单是否进入oms系统
|
|
- if(!arrivedOms(order.getOrderSn())){
|
|
|
|
|
|
+ if (!arrivedOms(order.getOrderSn())) {
|
|
// oms无该订单,则直接退款
|
|
// oms无该订单,则直接退款
|
|
restoreInventory(order, "收银端退款");
|
|
restoreInventory(order, "收银端退款");
|
|
orderRefund.setRestore(1);
|
|
orderRefund.setRestore(1);
|
|
- } else{
|
|
|
|
|
|
+ } else {
|
|
// 如果oms有订单,统一进入锁库存情况
|
|
// 如果oms有订单,统一进入锁库存情况
|
|
orderRefund.setRestore(0);
|
|
orderRefund.setRestore(0);
|
|
toBeRestoreInventory(order);
|
|
toBeRestoreInventory(order);
|
|
@@ -2735,14 +2807,7 @@ public class OrderServiceImpl implements OrderService {
|
|
// 支付宝的退款代码
|
|
// 支付宝的退款代码
|
|
} 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() + "");
|
|
@@ -2778,11 +2843,11 @@ public class OrderServiceImpl implements OrderService {
|
|
pickUpCodeEntity.setPickUpCodeStatus("3");
|
|
pickUpCodeEntity.setPickUpCodeStatus("3");
|
|
pickUpCodeService.update(pickUpCodeEntity);
|
|
pickUpCodeService.update(pickUpCodeEntity);
|
|
// 判断该订单是否进入oms系统
|
|
// 判断该订单是否进入oms系统
|
|
- if(!arrivedOms(order.getOrderSn())){
|
|
|
|
|
|
+ if (!arrivedOms(order.getOrderSn())) {
|
|
// oms无该订单,则直接退款
|
|
// oms无该订单,则直接退款
|
|
restoreInventory(order, "收银端退款");
|
|
restoreInventory(order, "收银端退款");
|
|
orderRefund.setRestore(1);
|
|
orderRefund.setRestore(1);
|
|
- } else{
|
|
|
|
|
|
+ } else {
|
|
// 如果oms有订单,统一进入锁库存情况
|
|
// 如果oms有订单,统一进入锁库存情况
|
|
orderRefund.setRestore(0);
|
|
orderRefund.setRestore(0);
|
|
toBeRestoreInventory(order);
|
|
toBeRestoreInventory(order);
|
|
@@ -2806,19 +2871,19 @@ public class OrderServiceImpl implements OrderService {
|
|
ProductStoreRelaEntity storeRelaEntity = productStoreRelaDao
|
|
ProductStoreRelaEntity storeRelaEntity = productStoreRelaDao
|
|
.queryByGoodsIdAndStoreId(order.getStoreId().longValue(), orderGoodsEntity.getGoodsId().longValue());
|
|
.queryByGoodsIdAndStoreId(order.getStoreId().longValue(), orderGoodsEntity.getGoodsId().longValue());
|
|
Integer toBeRestored = storeRelaEntity.getToBeRestored();
|
|
Integer toBeRestored = storeRelaEntity.getToBeRestored();
|
|
- if(toBeRestored == null){
|
|
|
|
|
|
+ if (toBeRestored == null) {
|
|
toBeRestored = 0;
|
|
toBeRestored = 0;
|
|
}
|
|
}
|
|
// 修改待退款的数量
|
|
// 修改待退款的数量
|
|
- storeRelaEntity.setToBeRestored(toBeRestored +restoreNumber);
|
|
|
|
|
|
+ storeRelaEntity.setToBeRestored(toBeRestored + restoreNumber);
|
|
|
|
|
|
GoodsEntity goodsEntity = goodsDao.queryObject(orderGoodsEntity.getGoodsId());
|
|
GoodsEntity goodsEntity = goodsDao.queryObject(orderGoodsEntity.getGoodsId());
|
|
|
|
|
|
toBeRestored = goodsEntity.getToBeRestored();
|
|
toBeRestored = goodsEntity.getToBeRestored();
|
|
- if(toBeRestored == null){
|
|
|
|
|
|
+ if (toBeRestored == null) {
|
|
toBeRestored = 0;
|
|
toBeRestored = 0;
|
|
}
|
|
}
|
|
- goodsEntity.setToBeRestored(toBeRestored+restoreNumber);
|
|
|
|
|
|
+ goodsEntity.setToBeRestored(toBeRestored + restoreNumber);
|
|
|
|
|
|
|
|
|
|
productStoreRelaDao.update(storeRelaEntity);
|
|
productStoreRelaDao.update(storeRelaEntity);
|
|
@@ -2829,6 +2894,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询oms系统是否有该订单
|
|
* 查询oms系统是否有该订单
|
|
|
|
+ *
|
|
* @param orderSn
|
|
* @param orderSn
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -2836,17 +2902,17 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
// sParaTemp.put("data","ZWCW2020122749351849");
|
|
// sParaTemp.put("data","ZWCW2020122749351849");
|
|
- sParaTemp.put("data",orderSn);
|
|
|
|
- sParaTemp.put("merchId",omsMerchProperties.getMerchSn());
|
|
|
|
- String timestamp = String.valueOf(System.currentTimeMillis()/1000);
|
|
|
|
|
|
+ sParaTemp.put("data", orderSn);
|
|
|
|
+ sParaTemp.put("merchId", omsMerchProperties.getMerchSn());
|
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
//生成要请求给oms秘钥
|
|
//生成要请求给oms秘钥
|
|
// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
- String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
|
|
|
|
|
|
+ String sign = OmsSign.sign(sParaTemp, omsMerchProperties.getMd5Salt());
|
|
sParaTemp.put("sign", sign);
|
|
sParaTemp.put("sign", sign);
|
|
//构建Request
|
|
//构建Request
|
|
- String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
|
|
|
|
+ String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
LOGGER.info("oms的请求报文:" + request);
|
|
LOGGER.info("oms的请求报文:" + request);
|
|
// 同步访问,返回结果字符串
|
|
// 同步访问,返回结果字符串
|
|
@@ -2859,16 +2925,16 @@ public class OrderServiceImpl implements OrderService {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
- LOGGER.info("oms的响应报文"+responseString);
|
|
|
|
|
|
+ LOGGER.info("oms的响应报文" + responseString);
|
|
//解析响应数据
|
|
//解析响应数据
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
- if(result == null){
|
|
|
|
|
|
+ if (result == null) {
|
|
String info = "解析响应数据Result失败";
|
|
String info = "解析响应数据Result失败";
|
|
LOGGER.error("--- {}", info);
|
|
LOGGER.error("--- {}", info);
|
|
throw new RuntimeException(info);
|
|
throw new RuntimeException(info);
|
|
}
|
|
}
|
|
- if("oms无该订单".equals(result.getMsg())){
|
|
|
|
|
|
+ if ("oms无该订单".equals(result.getMsg())) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2971,7 +3037,7 @@ public class OrderServiceImpl implements OrderService {
|
|
//
|
|
//
|
|
// dBefore = calendar.getTime(); //得到前一天的时间
|
|
// dBefore = calendar.getTime(); //得到前一天的时间
|
|
|
|
|
|
- String defaultStartDate = comparedDate + " 00:00:00";
|
|
|
|
|
|
+ String defaultStartDate = comparedDate + " 00:00:00";
|
|
|
|
|
|
|
|
|
|
String defaultEndDate = comparedDate + " 23:59:59";
|
|
String defaultEndDate = comparedDate + " 23:59:59";
|
|
@@ -2992,11 +3058,11 @@ public class OrderServiceImpl implements OrderService {
|
|
@Override
|
|
@Override
|
|
public ExportExcelDto querySumAmount(String billDate, String storeId) {
|
|
public ExportExcelDto querySumAmount(String billDate, String storeId) {
|
|
ExportExcelDto exportExcelDto = new ExportExcelDto();
|
|
ExportExcelDto exportExcelDto = new ExportExcelDto();
|
|
- ExportExcelDto totalAmount = orderDao.totalAmount(billDate,storeId);
|
|
|
|
- ExportExcelDto refundCurrentAmount = orderDao.refundCurrentAmount(billDate,storeId);
|
|
|
|
- ExportExcelDto refundPreviousAmount = orderDao.refundPreviousAmount(billDate,storeId);
|
|
|
|
- ExportExcelDto currentTax = orderDao.currentTax(billDate,storeId);
|
|
|
|
- ExportExcelDto refundPreviousTax = orderDao.refundPreviousTax(billDate,storeId);
|
|
|
|
|
|
+ ExportExcelDto totalAmount = orderDao.totalAmount(billDate, storeId);
|
|
|
|
+ ExportExcelDto refundCurrentAmount = orderDao.refundCurrentAmount(billDate, storeId);
|
|
|
|
+ ExportExcelDto refundPreviousAmount = orderDao.refundPreviousAmount(billDate, storeId);
|
|
|
|
+ ExportExcelDto currentTax = orderDao.currentTax(billDate, storeId);
|
|
|
|
+ ExportExcelDto refundPreviousTax = orderDao.refundPreviousTax(billDate, storeId);
|
|
|
|
|
|
// 以下是直接从数据库中查出来的
|
|
// 以下是直接从数据库中查出来的
|
|
exportExcelDto.setTotalAmount(totalAmount.getTotalAmount()); // 总销售额
|
|
exportExcelDto.setTotalAmount(totalAmount.getTotalAmount()); // 总销售额
|
|
@@ -3010,71 +3076,71 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
// 以下是通过计算的出来的
|
|
// 以下是通过计算的出来的
|
|
// 销售净额
|
|
// 销售净额
|
|
- exportExcelDto.setNetAmount( new BigDecimal(exportExcelDto.getTotalAmount()).subtract(new BigDecimal(exportExcelDto.getRefundPreviousAmount())).setScale(2,RoundingMode.HALF_UP).toString() );
|
|
|
|
|
|
+ exportExcelDto.setNetAmount(new BigDecimal(exportExcelDto.getTotalAmount()).subtract(new BigDecimal(exportExcelDto.getRefundPreviousAmount())).setScale(2, RoundingMode.HALF_UP).toString());
|
|
// 总税额
|
|
// 总税额
|
|
- exportExcelDto.setTotalTax(new BigDecimal(exportExcelDto.getCurrentTax()).add(new BigDecimal(exportExcelDto.getPreviousTax())).setScale(2,RoundingMode.HALF_UP).toString());
|
|
|
|
|
|
+ exportExcelDto.setTotalTax(new BigDecimal(exportExcelDto.getCurrentTax()).add(new BigDecimal(exportExcelDto.getPreviousTax())).setScale(2, RoundingMode.HALF_UP).toString());
|
|
// 税前总额
|
|
// 税前总额
|
|
- exportExcelDto.setPreTaxTotalAmount(new BigDecimal(exportExcelDto.getNetAmount()).subtract(new BigDecimal(exportExcelDto.getTotalTax())).setScale(2,RoundingMode.HALF_UP).toString());
|
|
|
|
|
|
+ exportExcelDto.setPreTaxTotalAmount(new BigDecimal(exportExcelDto.getNetAmount()).subtract(new BigDecimal(exportExcelDto.getTotalTax())).setScale(2, RoundingMode.HALF_UP).toString());
|
|
// 成功单数
|
|
// 成功单数
|
|
- exportExcelDto.setSuccessNumber(new BigDecimal(exportExcelDto.getTotalCount()).subtract(new BigDecimal(exportExcelDto.getRefundPreviousCount())).setScale(2,RoundingMode.HALF_UP).toString());
|
|
|
|
|
|
+ exportExcelDto.setSuccessNumber(new BigDecimal(exportExcelDto.getTotalCount()).subtract(new BigDecimal(exportExcelDto.getRefundPreviousCount())).setScale(2, RoundingMode.HALF_UP).toString());
|
|
// 退款总额
|
|
// 退款总额
|
|
- exportExcelDto.setRefundAmount(new BigDecimal(exportExcelDto.getRefundCurrentAmount()).add(new BigDecimal(exportExcelDto.getRefundPreviousAmount())).setScale(2,RoundingMode.HALF_UP).toString());
|
|
|
|
|
|
+ exportExcelDto.setRefundAmount(new BigDecimal(exportExcelDto.getRefundCurrentAmount()).add(new BigDecimal(exportExcelDto.getRefundPreviousAmount())).setScale(2, RoundingMode.HALF_UP).toString());
|
|
// 退单单数
|
|
// 退单单数
|
|
- exportExcelDto.setRefundCount(new BigDecimal(exportExcelDto.getRefundCurrentCount()).add(new BigDecimal(exportExcelDto.getRefundPreviousCount())).setScale(2,RoundingMode.HALF_UP).toString());
|
|
|
|
|
|
+ exportExcelDto.setRefundCount(new BigDecimal(exportExcelDto.getRefundCurrentCount()).add(new BigDecimal(exportExcelDto.getRefundPreviousCount())).setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
|
|
|
return exportExcelDto;
|
|
return exportExcelDto;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String,List<OrderEntity>> querySaleOrderList(String billDate, String storeId) {
|
|
|
|
- Map<String,List<OrderEntity>> result = new HashMap<>();
|
|
|
|
|
|
+ public Map<String, List<OrderEntity>> querySaleOrderList(String billDate, String storeId) {
|
|
|
|
+ Map<String, List<OrderEntity>> result = new HashMap<>();
|
|
// 查询当天所有订单
|
|
// 查询当天所有订单
|
|
- List<OrderEntity> orderEntityList = orderDao.queryCurrentPreviousOrderList(billDate,storeId);
|
|
|
|
- result.put("current",orderEntityList);
|
|
|
|
|
|
+ List<OrderEntity> orderEntityList = orderDao.queryCurrentPreviousOrderList(billDate, storeId);
|
|
|
|
+ result.put("current", orderEntityList);
|
|
// 查询当天退前期订单
|
|
// 查询当天退前期订单
|
|
- List<OrderEntity> refundPreviousOrderList = orderDao.queryRefundPreviousOrderList(billDate,storeId);
|
|
|
|
- result.put("previous",refundPreviousOrderList);
|
|
|
|
|
|
+ List<OrderEntity> refundPreviousOrderList = orderDao.queryRefundPreviousOrderList(billDate, storeId);
|
|
|
|
+ result.put("previous", refundPreviousOrderList);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, List<TaxDetailDto>> queryTaxDetailList(String billDate, String storeId) {
|
|
public Map<String, List<TaxDetailDto>> queryTaxDetailList(String billDate, String storeId) {
|
|
- Map<String,List<TaxDetailDto>> result = new HashMap<>();
|
|
|
|
|
|
+ Map<String, List<TaxDetailDto>> result = new HashMap<>();
|
|
// 查询当天所有订单税单
|
|
// 查询当天所有订单税单
|
|
- List<TaxDetailDto> taxDetailList = orderDao.queryCurrentTaxDetailList(billDate,storeId);
|
|
|
|
|
|
+ List<TaxDetailDto> taxDetailList = orderDao.queryCurrentTaxDetailList(billDate, storeId);
|
|
|
|
|
|
// 计算税前价,增值税,消费税
|
|
// 计算税前价,增值税,消费税
|
|
BigDecimal discountRate = new BigDecimal(0.7);
|
|
BigDecimal discountRate = new BigDecimal(0.7);
|
|
- if(taxDetailList != null && taxDetailList.size() != 0){
|
|
|
|
|
|
+ if (taxDetailList != null && taxDetailList.size() != 0) {
|
|
for (TaxDetailDto taxDetailDto : taxDetailList) {
|
|
for (TaxDetailDto taxDetailDto : taxDetailList) {
|
|
// 获取实际支付价格
|
|
// 获取实际支付价格
|
|
String postTaxPrice = taxDetailDto.getPostTaxPrice();
|
|
String postTaxPrice = taxDetailDto.getPostTaxPrice();
|
|
// 获取总税额
|
|
// 获取总税额
|
|
- String taxStr = taxDetailDto.getTax();
|
|
|
|
|
|
+ String taxStr = taxDetailDto.getTax();
|
|
// 税前金额
|
|
// 税前金额
|
|
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.getSaleTaxRate()).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.getVatRate()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
|
|
// 消费税 = (明细商品总价 / (1-消费税税率)) * 消费税税率
|
|
// 消费税 = (明细商品总价 / (1-消费税税率)) * 消费税税率
|
|
// 增值税 = (明细商品总价 + 消费税) * 增值税税率
|
|
// 增值税 = (明细商品总价 + 消费税) * 增值税税率
|
|
// 订单该商品总税费 = (商品消费税 + 商品增值税)* 0.7
|
|
// 订单该商品总税费 = (商品消费税 + 商品增值税)* 0.7
|
|
// 如果大于,要算消费税
|
|
// 如果大于,要算消费税
|
|
BigDecimal saleTax = new BigDecimal(0);
|
|
BigDecimal saleTax = new BigDecimal(0);
|
|
BigDecimal vat = new BigDecimal(0);
|
|
BigDecimal vat = new BigDecimal(0);
|
|
- if(taxRate.compareTo(new BigDecimal("0.23")) > 0){
|
|
|
|
|
|
+ if (taxRate.compareTo(new BigDecimal("0.23")) > 0) {
|
|
saleTax = pretaxPrice.divide(new BigDecimal(1).subtract(saleTaxRate), 2, RoundingMode.HALF_UP).multiply(saleTaxRate).
|
|
saleTax = pretaxPrice.divide(new BigDecimal(1).subtract(saleTaxRate), 2, RoundingMode.HALF_UP).multiply(saleTaxRate).
|
|
setScale(2, RoundingMode.HALF_UP);
|
|
setScale(2, RoundingMode.HALF_UP);
|
|
vat = pretaxPrice.add(saleTax).multiply(vatRate).
|
|
vat = pretaxPrice.add(saleTax).multiply(vatRate).
|
|
multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
- saleTax = saleTax.multiply(discountRate).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
|
+ saleTax = saleTax.multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
// 不需要算消费税,增值税计算
|
|
// 不需要算消费税,增值税计算
|
|
vat = pretaxPrice.multiply(vatRate).multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
vat = pretaxPrice.multiply(vatRate).multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
}
|
|
}
|
|
@@ -3083,48 +3149,48 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- result.put("current",taxDetailList);
|
|
|
|
|
|
+ result.put("current", taxDetailList);
|
|
// 查询当天退前期订单税单
|
|
// 查询当天退前期订单税单
|
|
- List<TaxDetailDto> refundPrevioustaxDetailList = orderDao.queryRefundPreviousTaxDetailList(billDate,storeId);
|
|
|
|
|
|
+ List<TaxDetailDto> refundPrevioustaxDetailList = orderDao.queryRefundPreviousTaxDetailList(billDate, storeId);
|
|
|
|
|
|
// 计算税前价,增值税,消费税
|
|
// 计算税前价,增值税,消费税
|
|
- if(refundPrevioustaxDetailList != null && refundPrevioustaxDetailList.size() != 0){
|
|
|
|
|
|
+ if (refundPrevioustaxDetailList != null && refundPrevioustaxDetailList.size() != 0) {
|
|
for (TaxDetailDto taxDetailDto : refundPrevioustaxDetailList) {
|
|
for (TaxDetailDto taxDetailDto : refundPrevioustaxDetailList) {
|
|
// 获取实际支付价格
|
|
// 获取实际支付价格
|
|
String postTaxPrice = taxDetailDto.getPostTaxPrice();
|
|
String postTaxPrice = taxDetailDto.getPostTaxPrice();
|
|
// 获取总税额
|
|
// 获取总税额
|
|
- String taxStr = taxDetailDto.getPreTax();
|
|
|
|
|
|
+ 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.getPreSaleTax()).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.getPreVat()).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
|
|
// 如果大于,要算消费税
|
|
// 如果大于,要算消费税
|
|
BigDecimal saleTax = new BigDecimal(0);
|
|
BigDecimal saleTax = new BigDecimal(0);
|
|
BigDecimal vat = new BigDecimal(0);
|
|
BigDecimal vat = new BigDecimal(0);
|
|
- if(taxRate.compareTo(new BigDecimal("0.23")) > 0){
|
|
|
|
|
|
+ if (taxRate.compareTo(new BigDecimal("0.23")) > 0) {
|
|
saleTax = pretaxPrice.divide(new BigDecimal(1).subtract(saleTaxRate), 2, RoundingMode.HALF_UP).multiply(saleTaxRate).
|
|
saleTax = pretaxPrice.divide(new BigDecimal(1).subtract(saleTaxRate), 2, RoundingMode.HALF_UP).multiply(saleTaxRate).
|
|
multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
vat = pretaxPrice.add(saleTax).multiply(vatRate).
|
|
vat = pretaxPrice.add(saleTax).multiply(vatRate).
|
|
multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
// 不需要算消费税,增值税计算
|
|
// 不需要算消费税,增值税计算
|
|
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.compareTo(BigDecimal.ZERO)==0?saleTax.toString():"-"+saleTax.toString());
|
|
|
|
- taxDetailDto.setPreVat(vat.compareTo(BigDecimal.ZERO)==0?vat.toString():"-"+vat.toString());
|
|
|
|
|
|
+ taxDetailDto.setPreSaleTax(saleTax.compareTo(BigDecimal.ZERO) == 0 ? saleTax.toString() : "-" + saleTax.toString());
|
|
|
|
+ taxDetailDto.setPreVat(vat.compareTo(BigDecimal.ZERO) == 0 ? vat.toString() : "-" + vat.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- result.put("previous",refundPrevioustaxDetailList);
|
|
|
|
|
|
+ result.put("previous", refundPrevioustaxDetailList);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -3132,17 +3198,17 @@ public class OrderServiceImpl implements OrderService {
|
|
@Override
|
|
@Override
|
|
public List<String> queryInveResponse(String orderSn) throws IOException {
|
|
public List<String> queryInveResponse(String orderSn) throws IOException {
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
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("data", orderSn);
|
|
|
|
+ sParaTemp.put("merchId", omsMerchProperties.getMerchSn());
|
|
|
|
+ String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
//生成要请求给oms秘钥
|
|
//生成要请求给oms秘钥
|
|
// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
|
|
- String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
|
|
|
|
|
|
+ String sign = OmsSign.sign(sParaTemp, omsMerchProperties.getMd5Salt());
|
|
sParaTemp.put("sign", sign);
|
|
sParaTemp.put("sign", sign);
|
|
//构建Request
|
|
//构建Request
|
|
- String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
|
|
|
|
+ String url = omsMerchProperties.getQueryInveResponseUrl();
|
|
Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
|
|
LOGGER.info("oms的请求报文:" + request);
|
|
LOGGER.info("oms的请求报文:" + request);
|
|
// 同步访问,返回结果字符串
|
|
// 同步访问,返回结果字符串
|
|
@@ -3156,11 +3222,11 @@ public class OrderServiceImpl implements OrderService {
|
|
throw e;
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
|
|
- LOGGER.info("oms的响应报文"+responseString);
|
|
|
|
|
|
+ LOGGER.info("oms的响应报文" + responseString);
|
|
//解析响应数据
|
|
//解析响应数据
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
|
|
- if(result == null){
|
|
|
|
|
|
+ if (result == null) {
|
|
String info = "解析响应数据Result失败";
|
|
String info = "解析响应数据Result失败";
|
|
LOGGER.error("--- {}", info);
|
|
LOGGER.error("--- {}", info);
|
|
throw new RuntimeException(info);
|
|
throw new RuntimeException(info);
|
|
@@ -3169,9 +3235,9 @@ public class OrderServiceImpl implements OrderService {
|
|
List rows = data.getRows();
|
|
List rows = data.getRows();
|
|
List<String> resultMessage = new LinkedList<>();
|
|
List<String> resultMessage = new LinkedList<>();
|
|
for (Object row : rows) {
|
|
for (Object row : rows) {
|
|
- if(row instanceof ArrayList){
|
|
|
|
|
|
+ if (row instanceof ArrayList) {
|
|
for (Object o : ((ArrayList<?>) row)) {
|
|
for (Object o : ((ArrayList<?>) row)) {
|
|
- if(o instanceof LinkedTreeMap){
|
|
|
|
|
|
+ if (o instanceof LinkedTreeMap) {
|
|
String cusReturnInfo = (String) ((LinkedTreeMap<?, ?>) o).get("cusReturnInfo");
|
|
String cusReturnInfo = (String) ((LinkedTreeMap<?, ?>) o).get("cusReturnInfo");
|
|
resultMessage.add(cusReturnInfo);
|
|
resultMessage.add(cusReturnInfo);
|
|
}
|
|
}
|
|
@@ -3207,16 +3273,16 @@ public class OrderServiceImpl implements OrderService {
|
|
// 查询该订单在库存是否已经释放过,避免重复恢复库存
|
|
// 查询该订单在库存是否已经释放过,避免重复恢复库存
|
|
OrderEntity orderInfo = orderDao.queryObjectByOrderSn(orderSn);
|
|
OrderEntity orderInfo = orderDao.queryObjectByOrderSn(orderSn);
|
|
OrderRefundEntity orderRefundEntity = orderRefundService.queryObjectByOrderId(orderInfo.getId());
|
|
OrderRefundEntity orderRefundEntity = orderRefundService.queryObjectByOrderId(orderInfo.getId());
|
|
- if(orderRefundEntity == null){
|
|
|
|
- LOGGER.error("该订单无退款记录,订单号{}",orderSn);
|
|
|
|
- throw new RuntimeException("该订单无退款记录,订单号:"+orderSn);
|
|
|
|
|
|
+ if (orderRefundEntity == null) {
|
|
|
|
+ LOGGER.error("该订单无退款记录,订单号{}", orderSn);
|
|
|
|
+ throw new RuntimeException("该订单无退款记录,订单号:" + orderSn);
|
|
}
|
|
}
|
|
Integer restore = orderRefundEntity.getRestore();
|
|
Integer restore = orderRefundEntity.getRestore();
|
|
- if(restore == 1){
|
|
|
|
- LOGGER.error("该订单库存记录已恢复过,订单号{}",orderSn);
|
|
|
|
- throw new RuntimeException("该订单库存记录已恢复过,订单号:"+orderSn);
|
|
|
|
|
|
+ if (restore == 1) {
|
|
|
|
+ LOGGER.error("该订单库存记录已恢复过,订单号{}", orderSn);
|
|
|
|
+ throw new RuntimeException("该订单库存记录已恢复过,订单号:" + orderSn);
|
|
}
|
|
}
|
|
- restoreInventory(orderInfo,"oms退单成功,恢复库存");
|
|
|
|
|
|
+ restoreInventory(orderInfo, "oms退单成功,恢复库存");
|
|
orderRefundEntity.setRestore(1);
|
|
orderRefundEntity.setRestore(1);
|
|
orderRefundService.update(orderRefundEntity);
|
|
orderRefundService.update(orderRefundEntity);
|
|
|
|
|
|
@@ -3314,12 +3380,13 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
return orderInfo;
|
|
return orderInfo;
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 设置订单数据
|
|
* 设置订单数据
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser, Long storeId, String merchSn, BigDecimal disCountAmount, BigDecimal totalTax,int status,Map mapAddr) {
|
|
|
|
|
|
+ public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser, Long storeId, String merchSn, BigDecimal disCountAmount, BigDecimal totalTax, int status, Map mapAddr) {
|
|
OrderVo orderInfo = new OrderVo();
|
|
OrderVo orderInfo = new OrderVo();
|
|
|
|
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
@@ -3359,9 +3426,9 @@ public class OrderServiceImpl implements OrderService {
|
|
orderInfo.setMobile(loginUser.getMobile());
|
|
orderInfo.setMobile(loginUser.getMobile());
|
|
orderInfo.setCountry("");
|
|
orderInfo.setCountry("");
|
|
//根据 前端的选择方式 1 是柜取 0 是 邮寄
|
|
//根据 前端的选择方式 1 是柜取 0 是 邮寄
|
|
- if (status==0) {
|
|
|
|
|
|
+ if (status == 0) {
|
|
//省
|
|
//省
|
|
- String cmbProvince = (String)mapAddr.get("cmbProvince");
|
|
|
|
|
|
+ String cmbProvince = (String) mapAddr.get("cmbProvince");
|
|
//市
|
|
//市
|
|
String cmbCity = (String) mapAddr.get("cmbCity");
|
|
String cmbCity = (String) mapAddr.get("cmbCity");
|
|
//区
|
|
//区
|
|
@@ -3372,7 +3439,7 @@ public class OrderServiceImpl implements OrderService {
|
|
orderInfo.setCity(cmbCity);
|
|
orderInfo.setCity(cmbCity);
|
|
orderInfo.setDistrict(cmbArea);
|
|
orderInfo.setDistrict(cmbArea);
|
|
orderInfo.setAddress(addrUser);
|
|
orderInfo.setAddress(addrUser);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
orderInfo.setProvince(storeEntity.getProvinceName());
|
|
orderInfo.setProvince(storeEntity.getProvinceName());
|
|
orderInfo.setCity(storeEntity.getCityName());
|
|
orderInfo.setCity(storeEntity.getCityName());
|
|
orderInfo.setDistrict(storeEntity.getCountyName());
|
|
orderInfo.setDistrict(storeEntity.getCountyName());
|
|
@@ -3419,6 +3486,20 @@ public class OrderServiceImpl implements OrderService {
|
|
orderInfo.setIsOnfflineOrder(Dict.isOnfflineOrder.item_1.getItem());
|
|
orderInfo.setIsOnfflineOrder(Dict.isOnfflineOrder.item_1.getItem());
|
|
orderInfo.setOrderBizType(Dict.orderBizType.item_10.getItem());
|
|
orderInfo.setOrderBizType(Dict.orderBizType.item_10.getItem());
|
|
|
|
|
|
|
|
+ // 添加快递信息
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ StoreExprActiveDto activeExpr = addressInfoService.queryByStoreId(storeId);
|
|
|
|
+ if (activeExpr == null) {
|
|
|
|
+ throw new RRException("门店未配置快递信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ orderInfo.setShipping_id(activeExpr.getExprId());
|
|
|
|
+ orderInfo.setShipping_code(activeExpr.getExprCode());
|
|
|
|
+ orderInfo.setShipping_name(activeExpr.getExprName());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ LOGGER.error("订单写入门店快递配置信息有误:", e);
|
|
|
|
+ }
|
|
return orderInfo;
|
|
return orderInfo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3448,8 +3529,6 @@ public class OrderServiceImpl implements OrderService {
|
|
orderGoodsVo.setSku(goodsDto.getSku());
|
|
orderGoodsVo.setSku(goodsDto.getSku());
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getGoodsNumber()));
|
|
BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getGoodsNumber()));
|
|
BigDecimal goodsTotal = goodsDto.getRetailPrice().multiply(number);//单商品总价
|
|
BigDecimal goodsTotal = goodsDto.getRetailPrice().multiply(number);//单商品总价
|
|
BigDecimal rate = goodsTotal.divide(orderInfo.getGoods_price(), 2, BigDecimal.ROUND_HALF_UP);//当前商品总价/订单总价(不含运费、不含优惠券)
|
|
BigDecimal rate = goodsTotal.divide(orderInfo.getGoods_price(), 2, BigDecimal.ROUND_HALF_UP);//当前商品总价/订单总价(不含运费、不含优惠券)
|
|
@@ -3483,8 +3562,8 @@ 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.getStoreRetailPrice(),goodsService).setScale(3,RoundingMode.HALF_UP);
|
|
|
|
- goodsTax = goodsTax.multiply(number).setScale(2,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);
|
|
orderGoodsVo.setTaxPrice(goodsTax);
|
|
orderGoodsVo.setTaxPrice(goodsTax);
|
|
|
|
|
|
return orderGoodsVo;
|
|
return orderGoodsVo;
|