|
@@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableBiMap;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import com.kmall.admin.dao.*;
|
|
import com.kmall.admin.dao.*;
|
|
import com.kmall.admin.dao.mk.store.MkStorePromOrderRealDao;
|
|
import com.kmall.admin.dao.mk.store.MkStorePromOrderRealDao;
|
|
-import com.kmall.admin.dto.GoodsDto;
|
|
|
|
import com.kmall.admin.dto.OrderExpressDto;
|
|
import com.kmall.admin.dto.OrderExpressDto;
|
|
import com.kmall.admin.dto.OrderRecognitionDto;
|
|
import com.kmall.admin.dto.OrderRecognitionDto;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.*;
|
|
@@ -14,13 +13,13 @@ import com.kmall.admin.entity.mk.store.MkStorePromOrderRealEntity;
|
|
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.websocket.WebSocketServer;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
-import com.kmall.api.dto.CampMinusDto;
|
|
|
|
import com.kmall.api.entity.*;
|
|
import com.kmall.api.entity.*;
|
|
-import com.kmall.api.entity.mk.MkStoreCampMinusVo;
|
|
|
|
-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;
|
|
|
|
+import com.kmall.manager.manager.alipay.AliPayMicropayApiResult;
|
|
|
|
+import com.kmall.manager.manager.alipay.AliPayRequestParams;
|
|
|
|
+import com.kmall.manager.manager.alipay.AliPayUtil;
|
|
import com.kmall.manager.manager.express.sf.properties.SFPropertiesBuilder;
|
|
import com.kmall.manager.manager.express.sf.properties.SFPropertiesBuilder;
|
|
import com.kmall.manager.manager.express.sf.properties.SFUtil;
|
|
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;
|
|
@@ -39,10 +38,13 @@ 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 org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -51,6 +53,10 @@ import java.util.*;
|
|
|
|
|
|
@Service("orderService")
|
|
@Service("orderService")
|
|
public class OrderServiceImpl implements OrderService {
|
|
public class OrderServiceImpl implements OrderService {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private final Logger LOGGER = LoggerFactory.getLogger(OrderServiceImpl.class);
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private OrderDao orderDao;
|
|
private OrderDao orderDao;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -101,6 +107,8 @@ public class OrderServiceImpl implements OrderService {
|
|
@Autowired
|
|
@Autowired
|
|
private PickUpCodeService pickUpCodeService;
|
|
private PickUpCodeService pickUpCodeService;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public OrderEntity queryObject(Long id) {
|
|
public OrderEntity queryObject(Long id) {
|
|
return orderDao.queryObject(id);
|
|
return orderDao.queryObject(id);
|
|
@@ -234,6 +242,9 @@ public class OrderServiceImpl implements OrderService {
|
|
@Override
|
|
@Override
|
|
public Ticket printMsg(Long id) {
|
|
public Ticket printMsg(Long id) {
|
|
OrderEntity orderEntity = queryInfos(id);
|
|
OrderEntity orderEntity = queryInfos(id);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
List<OrderGoodsEntity> orderGoodsEntityList = orderEntity.getOrderGoodsEntityList();
|
|
List<OrderGoodsEntity> orderGoodsEntityList = orderEntity.getOrderGoodsEntityList();
|
|
// 获取门店
|
|
// 获取门店
|
|
StoreEntity storeEntity = storeDao.queryObject(orderEntity.getStoreId());
|
|
StoreEntity storeEntity = storeDao.queryObject(orderEntity.getStoreId());
|
|
@@ -286,6 +297,82 @@ public class OrderServiceImpl implements OrderService {
|
|
cusListing.setOriginAddress(PrintTicketPropertiesBuilder.instance().getAddress());
|
|
cusListing.setOriginAddress(PrintTicketPropertiesBuilder.instance().getAddress());
|
|
cusListing.setDeliveryAddress(storeEntity.getStoreAddress());
|
|
cusListing.setDeliveryAddress(storeEntity.getStoreAddress());
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Ticket printMsg(Long id, String sessionId) {
|
|
|
|
+ OrderEntity orderEntity = queryInfos(id);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<OrderGoodsEntity> orderGoodsEntityList = orderEntity.getOrderGoodsEntityList();
|
|
|
|
+ // 获取门店
|
|
|
|
+ StoreEntity storeEntity = storeDao.queryObject(orderEntity.getStoreId());
|
|
|
|
+ // 获取清关信息
|
|
|
|
+ OrderProcessRecordEntity orderProcessRecordEntity =
|
|
|
|
+ orderProcessRecordDao.queryObjectByOrderSn(orderEntity.getOrderSn());
|
|
|
|
+
|
|
|
|
+ // 小票头
|
|
|
|
+ TicketHead head = new TicketHead();
|
|
|
|
+ head.setTitle(OmsMerchPropertiesBuilder.instance().getMerchName() + storeEntity.getStoreName());
|
|
|
|
+ // head.setMemberId(orderEntity.getUserName().toString());
|
|
|
|
+ head.setOrderId(orderEntity.getOrderSn());
|
|
|
|
+ head.setTradeTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE").format(new Date()));
|
|
|
|
+
|
|
|
|
+ // 商品信息
|
|
|
|
+ Integer goodsTotal = 0; // 商品总个数
|
|
|
|
+ BigDecimal total = Constant.ZERO; // 商品总计
|
|
|
|
+ List<Goods> goodsList = new ArrayList<>();
|
|
|
|
+ for (OrderGoodsEntity orderGoods : orderGoodsEntityList) {
|
|
|
|
+ goodsTotal += orderGoods.getNumber();
|
|
|
|
+ total = total.add(orderGoods.getRetailPrice().multiply(new BigDecimal(orderGoods.getNumber())))
|
|
|
|
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ Goods goods = new Goods(orderGoods.getGoodsName(), orderGoods.getRetailPrice().toString(),
|
|
|
|
+ orderGoods.getNumber().toString(),
|
|
|
|
+ orderGoods.getRetailPrice().multiply(new BigDecimal(orderGoods.getNumber()))
|
|
|
|
+ .setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
+ goodsList.add(goods);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 收银信息
|
|
|
|
+ CashInfo cashInfo = new CashInfo();
|
|
|
|
+ cashInfo.setGoodsTotal(goodsTotal.toString());
|
|
|
|
+ cashInfo.setTotal(total.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
+ cashInfo.setReceipts(orderEntity.getActualPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
+ cashInfo.setOddChange("0.00");
|
|
|
|
+ cashInfo.setCoupon(orderEntity.getCouponPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
+ cashInfo.setFreight(
|
|
|
|
+ new BigDecimal(orderEntity.getFreightPrice()).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
+ cashInfo.setPaymentMode("微信支付");
|
|
|
|
+
|
|
|
|
+ // 海关清单
|
|
|
|
+ CusListing cusListing = new CusListing();
|
|
|
|
+ cusListing.setOrderId(orderEntity.getOrderSn());
|
|
|
|
+ if (!orderEntity.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_11.getItem())) {
|
|
|
|
+ cusListing.setWaybillId(orderProcessRecordEntity.getLogisticsNo());
|
|
|
|
+ cusListing.setInvtNo(orderProcessRecordEntity.getInvtNo());
|
|
|
|
+ cusListing.setConsignee(orderEntity.getConsignee());
|
|
|
|
+ cusListing.setConsigneeTel(orderEntity.getMobile());
|
|
|
|
+ }
|
|
|
|
+ cusListing.setOriginAddress(PrintTicketPropertiesBuilder.instance().getAddress());
|
|
|
|
+ cusListing.setDeliveryAddress(storeEntity.getStoreAddress());
|
|
|
|
+ // 尝试在取货码表中查询数据,如果有的话就改变状态
|
|
|
|
+ String orderSn = orderEntity.getOrderSn();
|
|
|
|
+ PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(orderSn);
|
|
|
|
+ if(pickUpCodeEntity != null){
|
|
|
|
+ pickUpCodeEntity.setPickUpCodeStatus("1");
|
|
|
|
+ pickUpCodeService.update(pickUpCodeEntity);
|
|
|
|
+// try {
|
|
|
|
+// WebSocketServer.delete(sessionId,orderEntity.getStoreId(),pickUpCodeEntity);
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+ }
|
|
return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing);
|
|
return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -341,6 +428,7 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
// 更新库存
|
|
// 更新库存
|
|
updateStock(order, "管理后台订单退款");*/
|
|
updateStock(order, "管理后台订单退款");*/
|
|
|
|
+// updateStock(order, "管理后台订单退款");
|
|
|
|
|
|
queryStorePromRealUpdateIsScan(order);
|
|
queryStorePromRealUpdateIsScan(order);
|
|
}
|
|
}
|
|
@@ -1003,7 +1091,7 @@ public class OrderServiceImpl implements OrderService {
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
for (LinkedHashMap goods : goodsList) {
|
|
for (LinkedHashMap goods : goodsList) {
|
|
goodsTotalPrice = goodsTotalPrice
|
|
goodsTotalPrice = goodsTotalPrice
|
|
- .add(new BigDecimal((Double) goods.get("retailPrice")).multiply(new BigDecimal((Integer) goods.get("sellVolume"))));
|
|
|
|
|
|
+ .add(new BigDecimal( goods.get("retailPrice").toString()).multiply(new BigDecimal( goods.get("sellVolume").toString())));
|
|
}
|
|
}
|
|
//订单价格计算:订单的总价+运费
|
|
//订单价格计算:订单的总价+运费
|
|
BigDecimal orderTotalPrice = goodsTotalPrice.add(freightPrice);
|
|
BigDecimal orderTotalPrice = goodsTotalPrice.add(freightPrice);
|
|
@@ -1174,8 +1262,12 @@ public class OrderServiceImpl implements OrderService {
|
|
orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
orderEntity.setPayFlag(payFlag);
|
|
orderEntity.setPayFlag(payFlag);
|
|
orderEntity.setPayTime(new Date());
|
|
orderEntity.setPayTime(new Date());
|
|
- if(orderSnWx != null){
|
|
|
|
- orderEntity.setOrderSnWx(orderSnWx);
|
|
|
|
|
|
+ if(Dict.payFlag.item_alipay.getItem().equalsIgnoreCase(payFlag)){
|
|
|
|
+ orderEntity.setAliTradeNo(orderSnWx);
|
|
|
|
+ }else {
|
|
|
|
+ if (orderSnWx != null) {
|
|
|
|
+ orderEntity.setOrderSnWx(orderSnWx);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
orderDao.update(orderEntity);
|
|
orderDao.update(orderEntity);
|
|
return 0;
|
|
return 0;
|
|
@@ -1398,6 +1490,7 @@ public class OrderServiceImpl implements OrderService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional
|
|
public Map offlineRetailSubmit(Map param, SysUserEntity user) {
|
|
public Map offlineRetailSubmit(Map param, SysUserEntity user) {
|
|
// 解析订单数据 List
|
|
// 解析订单数据 List
|
|
List<LinkedHashMap> goodsList = (List<LinkedHashMap>) param.get("goodsList");
|
|
List<LinkedHashMap> goodsList = (List<LinkedHashMap>) param.get("goodsList");
|
|
@@ -1439,8 +1532,7 @@ public class OrderServiceImpl implements OrderService {
|
|
return resultObj;
|
|
return resultObj;
|
|
}
|
|
}
|
|
Integer sellVolume = (Integer)goodsDto.get("sellVolume");
|
|
Integer sellVolume = (Integer)goodsDto.get("sellVolume");
|
|
- goodsEntity.setGoodsNumber(sellVolume);
|
|
|
|
- goodsEntities.add(goodsEntity);
|
|
|
|
|
|
+
|
|
goodsDto.put("goodsId",goodsEntity.getId());
|
|
goodsDto.put("goodsId",goodsEntity.getId());
|
|
goodsDto.put("goodsSn",goodsEntity.getGoodsSn());
|
|
goodsDto.put("goodsSn",goodsEntity.getGoodsSn());
|
|
goodsDto.put("productId",goodsEntity.getProductId());
|
|
goodsDto.put("productId",goodsEntity.getProductId());
|
|
@@ -1460,13 +1552,15 @@ public class OrderServiceImpl implements OrderService {
|
|
productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
|
|
productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
|
|
productInfo.setStoreId(Long.valueOf(storeId));
|
|
productInfo.setStoreId(Long.valueOf(storeId));
|
|
productInfo.addSellVolume();
|
|
productInfo.addSellVolume();
|
|
-// productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
|
|
|
|
|
|
+ productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
|
|
|
|
|
|
if(goodsEntity != null) {
|
|
if(goodsEntity != null) {
|
|
- goodsEntity.setStockNum((Integer.parseInt(goodsEntity.getStockNum()) - sellVolume)+"");
|
|
|
|
-// goodsDao.update(goodsEntity);
|
|
|
|
|
|
+ goodsEntity.setGoodsNumber(goodsEntity.getGoodsNumber() - sellVolume);
|
|
|
|
+ goodsDao.update(goodsEntity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ goodsEntity.setGoodsNumber(sellVolume);
|
|
|
|
+ goodsEntities.add(goodsEntity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1481,6 +1575,7 @@ public class OrderServiceImpl implements OrderService {
|
|
userEntity.setGender(1);
|
|
userEntity.setGender(1);
|
|
userEntity.setRegisterTime(new Date());
|
|
userEntity.setRegisterTime(new Date());
|
|
userEntity.setLastLoginTime(new Date());
|
|
userEntity.setLastLoginTime(new Date());
|
|
|
|
+ userEntity.setIdNo((String) userInfo.get("customIDCard"));
|
|
userDao.save(userEntity);
|
|
userDao.save(userEntity);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1492,7 +1587,7 @@ public class OrderServiceImpl implements OrderService {
|
|
order.setStore_id(storeId.longValue());
|
|
order.setStore_id(storeId.longValue());
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
|
|
|
|
- //开启事务,插入订单信息和订单商品
|
|
|
|
|
|
+ //插入订单信息和订单商品
|
|
orderDao.saveOrderVo(order);
|
|
orderDao.saveOrderVo(order);
|
|
|
|
|
|
// TODO 订单流转表
|
|
// TODO 订单流转表
|
|
@@ -1534,9 +1629,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
|
|
|
|
// 微信支付
|
|
// 微信支付
|
|
- wxPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
|
|
|
+// wxPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
// 支付宝支付
|
|
// 支付宝支付
|
|
-// AliPay();
|
|
|
|
|
|
+ AliPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
|
|
|
// 保存订单流转表
|
|
// 保存订单流转表
|
|
// 设置下单完成时间
|
|
// 设置下单完成时间
|
|
@@ -1560,8 +1655,8 @@ public class OrderServiceImpl implements OrderService {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
resultObj.put("errno", 400);
|
|
resultObj.put("errno", 400);
|
|
- resultObj.put("errmsg", "订单异常");
|
|
|
|
- return resultObj;
|
|
|
|
|
|
+ resultObj.put("errmsg", "订单异常------"+e.getMessage());
|
|
|
|
+ throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1570,6 +1665,106 @@ public class OrderServiceImpl implements OrderService {
|
|
return resultObj;
|
|
return resultObj;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void AliPay(SysUserEntity user, String parCode, Map resultObj, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws Exception {
|
|
|
|
+
|
|
|
|
+ AliPayRequestParams params = new AliPayRequestParams();
|
|
|
|
+ params.setAuthCode(parCode);
|
|
|
|
+ params.setBody(order.getApprovalRemark());
|
|
|
|
+ params.setOutTradeNo(order.getOrder_sn());
|
|
|
|
+ params.setSubject("CW下单");
|
|
|
|
+ params.setStoreId(store.getId()+"");
|
|
|
|
+ params.setTotalAmount(order.getActual_price().setScale(2,BigDecimal.ROUND_HALF_UP)+"");
|
|
|
|
+ LOGGER.info("调用阿里支付接口的请求参数:"+JacksonUtils.toJson(params));
|
|
|
|
+ AliPayMicropayApiResult aliPayMicropayApiResult = AliPayUtil.aliTradePay(params);
|
|
|
|
+ orderWXPayRecordService.updateRecordByAli(orderWXPayRecordCurrent.getId(), aliPayMicropayApiResult);
|
|
|
|
+ LOGGER.info("调用阿里支付接口的同步返回结果:"+JacksonUtils.toJson(aliPayMicropayApiResult));
|
|
|
|
+ resultObj.put("shopName",store.getStoreName()); // 根据门店编号查询
|
|
|
|
+ resultObj.put("userName",user.getUsername());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 修改订单状态
|
|
|
|
+ //当支付成功时,修改订单,并把其他支付记录撤销
|
|
|
|
+ if (AliPayUtil.AliPayTradeState.SUCC.getCode().equals(aliPayMicropayApiResult.getCode())) {
|
|
|
|
+// //查询当前订单所有的支付记录
|
|
|
|
+// List<OrderWXPayRecordEntity> orderWXPayRecordEntitys =
|
|
|
|
+// orderWXPayRecordService.getRecordsByOutTradeNo(order.getOrder_sn());
|
|
|
|
+ this.confirmPay(order.getId(), Dict.payFlag.item_alipay.getItem(), aliPayMicropayApiResult.getTradeNo());
|
|
|
|
+ // 设置支付单完成时间
|
|
|
|
+ processRecordEntity.setPaymentSuccTime(aliPayMicropayApiResult.getGmtPayment());
|
|
|
|
+ processRecordEntity.setPayTransactionId(aliPayMicropayApiResult.getTradeNo());
|
|
|
|
+
|
|
|
|
+ // 系统繁忙
|
|
|
|
+ } else if(AliPayUtil.AliPayTradeState.SERVER_FAIL.getCode().equals(aliPayMicropayApiResult.getCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请稍后再试");
|
|
|
|
+
|
|
|
|
+ // 支付失败
|
|
|
|
+ }else if(AliPayUtil.AliPayTradeState.BUSINESS_FAIL.getCode().equals(aliPayMicropayApiResult.getCode())){
|
|
|
|
+ // 系统异常
|
|
|
|
+ if(AliPayUtil.BusinessFailState.SYSTEM_ERROR.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请稍后再试");
|
|
|
|
+ // 订单总额超过限额
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.TOTAL_FEE_EXCEED.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请告知顾客");
|
|
|
|
+ // 授权码无效
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.PAYMENT_AUTH_CODE_INVALID.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请顾客刷新条码后,重新支付");
|
|
|
|
+ // 交易信息被篡改
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.CONTEXT_INCONSISTENT.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请重试");
|
|
|
|
+ // 余额支付功能关闭
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.ERROR_BALANCE_PAYMENT_DISABLE.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请用户打开余额支付");
|
|
|
|
+ // 交易买家不匹配
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.TRADE_BUYER_NOT_MATCH.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请重试");
|
|
|
|
+ // 买家状态非法
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.BUYER_ENABLE_STATUS_FORBID.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请买家联系支付宝小二,确认为什么非法");
|
|
|
|
+ // 唤起移动收银台失败
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.PULL_MOBILE_CASHIER_FAIL.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请用户刷新条码后,重新支付");
|
|
|
|
+ // 用户的无限支付开关关闭
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.MOBILE_PAYMENT_SWITCH_OFF.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请用户在PC上打开无线支付开关后,在发起支付");
|
|
|
|
+ // 支付失败
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.PAYMENT_FAIL.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请重试");
|
|
|
|
+ // 商户账号被冻结
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.SELLER_BEEN_BLOCKED.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请联系支付宝小二解冻");
|
|
|
|
+ // 买家未通过人行认证
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.ERROR_BUYER_CERTIFY_LEVEL_LIMIT.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请买家联系支付宝小二");
|
|
|
|
+ // 用户当面付付款开关管壁
|
|
|
|
+ }else if(AliPayUtil.BusinessFailState.USER_FACE_PAYMENT_SWITCH_OFF.getCode().equalsIgnoreCase(aliPayMicropayApiResult.getSubCode())){
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+",请买家打开当面付付款开关");
|
|
|
|
+ }else{
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ }
|
|
|
|
+ // 其他支付异常状态
|
|
|
|
+ } else {
|
|
|
|
+ LOGGER.info(aliPayMicropayApiResult.getSubMsg());
|
|
|
|
+ throw new RuntimeException(aliPayMicropayApiResult.getSubMsg()+"...........请联系管理员");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private void wxPay(SysUserEntity user, String parCode, Map resultObj, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws ParseException {
|
|
private void wxPay(SysUserEntity user, String parCode, Map resultObj, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws ParseException {
|
|
R r;
|
|
R r;
|
|
WechatMicropayApiResult wechatMicropayApiResult = WechatUtil
|
|
WechatMicropayApiResult wechatMicropayApiResult = WechatUtil
|
|
@@ -1649,6 +1844,50 @@ public class OrderServiceImpl implements OrderService {
|
|
return orderDao.queryObjectByOrderSn(orderSn);
|
|
return orderDao.queryObjectByOrderSn(orderSn);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void orderRefund(OrderEntity order, String sessionId) throws Exception {
|
|
|
|
+ boolean needUpdateStock = true;
|
|
|
|
+ if (order.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_201.getItem())) {
|
|
|
|
+ order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
|
|
|
|
+ }
|
|
|
|
+ if (Dict.payFlag.item_cash.getItem().equals(order.getPayFlag())) {
|
|
|
|
+ order.setPayStatus(Integer.parseInt(Dict.payStatus.item_4.getItem()));
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ AliPayMicropayApiResult userRefund = AliPayUtil.aliTradeRefund(order.getMerchOrderSn(), "38.81",
|
|
|
|
+ "用户退款", order.getStoreId() + "");
|
|
|
|
+
|
|
|
|
+ LOGGER.info(userRefund.getSubMsg());
|
|
|
|
+ order.setPayStatus(Integer.parseInt(Dict.payStatus.item_3.getItem()));
|
|
|
|
+ OrderRefundEntity orderRefund = new OrderRefundEntity();
|
|
|
|
+ orderRefund.setRefundId(userRefund.getTradeNo());
|
|
|
|
+ orderRefund.setOutRefundNo(userRefund.getOutTradeNo());
|
|
|
|
+ orderRefund
|
|
|
|
+ .setRefundMoney(new BigDecimal(userRefund.getRefundFee()));
|
|
|
|
+ orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));//退款成功
|
|
|
|
+ orderRefund.setModTime(new Date());
|
|
|
|
+
|
|
|
|
+ orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
|
|
|
|
+ orderRefund.setUserId(Integer.parseInt(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()));//用户全额退款
|
|
|
|
+ }
|
|
|
|
+ orderRefundDao.save(orderRefund);//退款记录
|
|
|
|
+ }
|
|
|
|
+ orderDao.update(order);//修改为退款成功
|
|
|
|
+ // 修改取货码
|
|
|
|
+ PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(order.getOrderSn());
|
|
|
|
+ pickUpCodeEntity.setPickUpCodeStatus("3");
|
|
|
|
+ pickUpCodeService.update(pickUpCodeEntity);
|
|
|
|
+// WebSocketServer.delete(sessionId,order.getStoreId(),pickUpCodeEntity);
|
|
|
|
+ updateStock(order, "收银端退款");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置订单数据
|
|
* 设置订单数据
|
|
@@ -1660,8 +1899,9 @@ public class OrderServiceImpl implements OrderService {
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal freightPrice = Constant.ZERO;
|
|
BigDecimal freightPrice = Constant.ZERO;
|
|
for (LinkedHashMap goods : goodsList) {
|
|
for (LinkedHashMap goods : goodsList) {
|
|
|
|
+
|
|
goodsTotalPrice = goodsTotalPrice
|
|
goodsTotalPrice = goodsTotalPrice
|
|
- .add(new BigDecimal((Double) goods.get("retailPrice")).multiply(new BigDecimal((Integer) goods.get("sellVolume"))));
|
|
|
|
|
|
+ .add(new BigDecimal(goods.get("retailPrice").toString()).multiply(new BigDecimal(goods.get("sellVolume").toString())));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1709,7 +1949,7 @@ public class OrderServiceImpl implements OrderService {
|
|
orderInfo.setOrder_price(orderTotalPrice);
|
|
orderInfo.setOrder_price(orderTotalPrice);
|
|
orderInfo.setActual_price(actualPrice);
|
|
orderInfo.setActual_price(actualPrice);
|
|
orderInfo.setOrder_type("1");
|
|
orderInfo.setOrder_type("1");
|
|
- orderInfo.setOrder_status(201);
|
|
|
|
|
|
+ orderInfo.setOrder_status(0);
|
|
orderInfo.setShipping_status(0);
|
|
orderInfo.setShipping_status(0);
|
|
orderInfo.setPay_status(0);
|
|
orderInfo.setPay_status(0);
|
|
orderInfo.setShipping_id(0L);
|
|
orderInfo.setShipping_id(0L);
|