|
@@ -49,6 +49,7 @@ import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
import com.fs.hisStore.domain.FsStorePaymentScrm;
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
|
|
|
|
+import com.fs.hisStore.param.FsStoreOrderRefundByProductParam;
|
|
import com.fs.hisapi.domain.ApiResponse;
|
|
import com.fs.hisapi.domain.ApiResponse;
|
|
import com.fs.hisapi.param.CreateOrderParam;
|
|
import com.fs.hisapi.param.CreateOrderParam;
|
|
import com.fs.hisapi.param.RecipeDetailParam;
|
|
import com.fs.hisapi.param.RecipeDetailParam;
|
|
@@ -3726,6 +3727,16 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
param.setDeliveryStatus((vo.getDeliveryStatus()==null|| vo.getDeliveryStatus().isEmpty())?null:Integer.valueOf(vo.getDeliveryStatus()));
|
|
param.setDeliveryStatus((vo.getDeliveryStatus()==null|| vo.getDeliveryStatus().isEmpty())?null:Integer.valueOf(vo.getDeliveryStatus()));
|
|
param.setDeliveryType(vo.getDeliveryType().isEmpty()?null:vo.getDeliveryType());
|
|
param.setDeliveryType(vo.getDeliveryType().isEmpty()?null:vo.getDeliveryType());
|
|
param.setUpdateTime(DateUtils.getNowDate());
|
|
param.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
+
|
|
|
|
+ //修改订单金额
|
|
|
|
+ BigDecimal payRemain = vo.getPayRemain();
|
|
|
|
+ if (payRemain != null){
|
|
|
|
+ if (!payRemain.equals(o.getPayRemain())){
|
|
|
|
+ BigDecimal payMoney = o.getPayMoney(); //实收金额
|
|
|
|
+ param.setPayPrice(payMoney.add(payRemain)); //应收金额
|
|
|
|
+ param.setPayRemain(vo.getPayRemain());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
fsStoreOrderMapper.updateFsStoreOrder(param);
|
|
fsStoreOrderMapper.updateFsStoreOrder(param);
|
|
|
|
|
|
successNum++;
|
|
successNum++;
|
|
@@ -3762,4 +3773,132 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
return fsStoreOrderMapper.selectFsStoreOrderProductStatistics(fsStoreOrder);
|
|
return fsStoreOrderMapper.selectFsStoreOrderProductStatistics(fsStoreOrder);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public int afterSalesByProduct(FsStoreOrderSalesParam param) {
|
|
|
|
+ FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(param.getOrderId());
|
|
|
|
+ if (order.getStatus() < 0) {
|
|
|
|
+ throw new CustomException("订单不可提交售后");
|
|
|
|
+ }
|
|
|
|
+ //判断总退款金额是否小于等于实付金额
|
|
|
|
+ BigDecimal refundAmount = param.getRefundAmount();
|
|
|
|
+ if (refundAmount.compareTo(order.getPayMoney())>0){
|
|
|
|
+ throw new CustomException("退款金额不能大于实付金额");
|
|
|
|
+ }
|
|
|
|
+ List<FsStoreOrderRefundByProductParam> refundList = param.getRefundList();
|
|
|
|
+ List<Long> itemIds = refundList.stream().filter(item->item.getNum()>0).map(FsStoreOrderRefundByProductParam::getItemId).collect(Collectors.toList());
|
|
|
|
+ if (itemIds.isEmpty()){
|
|
|
|
+ throw new CustomException("没有选择需要退款的商品/选择退款商品数量不能为0");
|
|
|
|
+ }
|
|
|
|
+ List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemMapper.selectFsStoreOrderItemListByItemIds(itemIds);
|
|
|
|
+ if (fsStoreOrderItems.size() != itemIds.size()){
|
|
|
|
+ throw new CustomException("所退商品明细不存在");
|
|
|
|
+ }
|
|
|
|
+ FsStoreAfterSales fsStoreAfterSales = new FsStoreAfterSales();
|
|
|
|
+ fsStoreAfterSales.setOrderId(order.getOrderId());
|
|
|
|
+ fsStoreAfterSales.setStoreId(order.getStoreId());
|
|
|
|
+ fsStoreAfterSales.setRefundAmount(refundAmount);
|
|
|
|
+ fsStoreAfterSales.setCreateTime(DateUtils.getNowDate());
|
|
|
|
+ if (order.getStatus() == 2 || order.getStatus() == 3) {
|
|
|
|
+ fsStoreAfterSales.setRefundType(0);
|
|
|
|
+ }
|
|
|
|
+ if (order.getStatus() == 4) {
|
|
|
|
+ FsStore fsStore = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
|
|
|
|
+ fsStoreAfterSales.setRefundType(1);
|
|
|
|
+ fsStoreAfterSales.setPhoneNumber(fsStore.getRefundPhone());
|
|
|
|
+ fsStoreAfterSales.setAddress(fsStore.getRefundAddress());
|
|
|
|
+ fsStoreAfterSales.setConsignee(fsStore.getRefundConsignee());
|
|
|
|
+ }
|
|
|
|
+ fsStoreAfterSales.setStatus(0);
|
|
|
|
+ fsStoreAfterSales.setDeptId(order.getDeptId());
|
|
|
|
+ fsStoreAfterSales.setSalesStatus(0);
|
|
|
|
+ fsStoreAfterSales.setOrderStatus(order.getStatus());
|
|
|
|
+ fsStoreAfterSales.setUserId(order.getUserId());
|
|
|
|
+ fsStoreAfterSales.setCompanyId(order.getCompanyId());
|
|
|
|
+ fsStoreAfterSales.setCompanyUserId(order.getCompanyUserId());
|
|
|
|
+ fsStoreAfterSales.setIsDel(0);
|
|
|
|
+ fsStoreAfterSalesService.insertFsStoreAfterSales(fsStoreAfterSales);
|
|
|
|
+
|
|
|
|
+ for (FsStoreOrderItem fsStoreOrderItem : fsStoreOrderItems) {
|
|
|
|
+ for (FsStoreOrderRefundByProductParam fsStoreOrderRefundByProductParam : refundList) {
|
|
|
|
+ if (Objects.equals(fsStoreOrderRefundByProductParam.getItemId(), fsStoreOrderItem.getItemId())) {
|
|
|
|
+ FsStoreAfterSalesItem item = new FsStoreAfterSalesItem();
|
|
|
|
+ item.setAfterSalesId(fsStoreAfterSales.getId());
|
|
|
|
+ item.setProductId(fsStoreOrderItem.getProductId());
|
|
|
|
+ String jsonInfo = fsStoreOrderItem.getJsonInfo();
|
|
|
|
+ FsProdItemDTO fsProdItemDTO = JSON.parseObject(jsonInfo, FsProdItemDTO.class);
|
|
|
|
+ fsProdItemDTO.setPrice(fsStoreOrderRefundByProductParam.getMoney());
|
|
|
|
+ fsProdItemDTO.setNum(fsStoreOrderRefundByProductParam.getNum());
|
|
|
|
+ item.setJsonInfo(JSONUtil.toJsonStr(fsProdItemDTO));
|
|
|
|
+ fsStoreAfterSalesItemMapper.insertFsStoreAfterSalesItem(item);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //增加操作日志
|
|
|
|
+ FsStoreAfterSalesLogs logs = new FsStoreAfterSalesLogs();
|
|
|
|
+ logs.setChangeTime(new DateTime());
|
|
|
|
+ logs.setChangeType(0);
|
|
|
|
+ logs.setStoreAfterSalesId(fsStoreAfterSales.getId());
|
|
|
|
+ logs.setOperator(param.getOperator());
|
|
|
|
+ logs.setCompanyId(param.getCompanyId());
|
|
|
|
+ logs.setChangeMessage("平台提交售后");
|
|
|
|
+ fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
|
|
+ //添加订单日志
|
|
|
|
+ fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.REFUND_ORDER_PLATFORM.getValue(),
|
|
|
|
+ param.getOperator() + " " +FsStoreOrderLogEnum.REFUND_ORDER_PLATFORM.getDesc());
|
|
|
|
+ //判断是否开启erp
|
|
|
|
+ FsSysConfig sysConfig = configUtil.getSysConfig();
|
|
|
|
+ Integer erpOpen = sysConfig.getErpOpen();
|
|
|
|
+ if (erpOpen != null && erpOpen == 1) {
|
|
|
|
+ //判断erp类型
|
|
|
|
+ Integer erpType = sysConfig.getErpType();
|
|
|
|
+ if (erpType != null) {
|
|
|
|
+
|
|
|
|
+ IErpOrderService erpOrderService = null;
|
|
|
|
+ if (erpType == 1) {
|
|
|
|
+ //管易
|
|
|
|
+ erpOrderService = gyOrderService;
|
|
|
|
+ } else if (erpType == 2) {
|
|
|
|
+ //旺店通
|
|
|
|
+ erpOrderService = wdtOrderService;
|
|
|
|
+ } else if (erpType == 3) {
|
|
|
|
+ //瀚智
|
|
|
|
+ erpOrderService = hzOMSOrderService;
|
|
|
|
+ } else if (erpType == 4) {
|
|
|
|
+ //瀚智
|
|
|
|
+ erpOrderService = dfOrderService;
|
|
|
|
+ } else if (erpType == 5) {
|
|
|
|
+ erpOrderService = jSTOrderService;
|
|
|
|
+ }else if (erpType == 6) {
|
|
|
|
+ erpOrderService = k9OrderService;
|
|
|
|
+ }
|
|
|
|
+ if (erpOrderService != null && StringUtils.isNotEmpty(order.getExtendOrderId())) {
|
|
|
|
+ if (!order.getExtendOrderId().equals("HIS")) {
|
|
|
|
+ if (erpType != 3) {
|
|
|
|
+ ErpRefundUpdateRequest request = new ErpRefundUpdateRequest();
|
|
|
|
+ request.setTid(order.getOrderCode());
|
|
|
|
+ request.setOid(order.getOrderCode());
|
|
|
|
+ request.setRefund_state(1);
|
|
|
|
+ erpOrderService.refundUpdate(request);
|
|
|
|
+ } else {
|
|
|
|
+ ErpRefundOrder erpRefundOrder = new ErpRefundOrder();
|
|
|
|
+ erpRefundOrder.setOrderCode(order.getOrderCode());
|
|
|
|
+ erpRefundOrder.setAfterSalesId(fsStoreAfterSales.getId());
|
|
|
|
+ erpOrderService.refundOrder(erpRefundOrder);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ order.setStatus(-1);
|
|
|
|
+ order.setRefundStatus(1 + "");
|
|
|
|
+ fsStoreOrderMapper.updateFsStoreOrder(order);
|
|
|
|
+ if (order.getPackageOrderId() != null) {
|
|
|
|
+ FsPackageOrder fsPackageOrder = fsPackageOrderMapper.selectFsPackageOrderByOrderId(order.getPackageOrderId());
|
|
|
|
+ fsPackageOrder.setRefundStatus(1);
|
|
|
|
+ fsPackageOrderMapper.updateFsPackageOrder(fsPackageOrder);
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|