|  |  | 
 |  |  | import com.matrix.system.common.dao.SystemDictionaryDao; | 
 |  |  | import com.matrix.system.hive.action.util.QueryUtil; | 
 |  |  | import com.matrix.system.hive.dao.SysVipInfoDao; | 
 |  |  | import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService; | 
 |  |  | import com.matrix.system.shopXcx.bean.ShopActivities; | 
 |  |  | import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; | 
 |  |  | import com.matrix.system.shopXcx.bean.ShopLogisticsInfo; | 
 |  |  | 
 |  |  |     ShopDeliveryInfoDao shopDeliveryInfoDao; | 
 |  |  |     @Autowired | 
 |  |  |     ShopLogisticsInfoDao shopLogisticsInfoDao; | 
 |  |  |     @Autowired | 
 |  |  |     private WxShopLogisticsQueryService wxShopLogisticsQueryService; | 
 |  |  |  | 
 |  |  |     public IPage<SignWriteoffListVo> findSignWriteoffList(Page<SignWriteoffListVo> page, | 
 |  |  |             SignWriteoffListDto signWriteoffListDto) { | 
 |  |  | 
 |  |  |                  | 
 |  |  |                 //物流跟踪 | 
 |  |  |                 Integer logisticsId = activitySignWriteoffLogistics.getLogisticsId(); | 
 |  |  |                 if(ObjectUtil.isNotEmpty(logisticsId)) { | 
 |  |  |                     List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(logisticsId); | 
 |  |  |                     if(CollUtil.isNotEmpty(shopLogisticsInfos)) { | 
 |  |  |                         ArrayList<LogisticsVo> logisticsVos = new ArrayList<>(); | 
 |  |  |                         for(ShopLogisticsInfo shopLogistics : shopLogisticsInfos) { | 
 |  |  |                             LogisticsVo logisticsVo = new LogisticsVo(); | 
 |  |  |                             logisticsVo.setContent(shopLogistics.getDescribe()); | 
 |  |  |                             logisticsVo.setTimestamp(shopLogistics.getLogisticsTime()); | 
 |  |  |                             logisticsVos.add(logisticsVo); | 
 |  |  |                         } | 
 |  |  |                         signWriteoffVo.setActivities(logisticsVos); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |         		 | 
 |  |  |                 ShopDeliveryInfo shopDeliveryInfo = shopDeliveryInfoDao.selectById(logisticsId); | 
 |  |  |                 if(ObjectUtil.isNotEmpty(shopDeliveryInfo)){ | 
 |  |  |                     //查看物流信息 | 
 |  |  |                     wxShopLogisticsQueryService.selectLogisticsInfo(shopDeliveryInfo); | 
 |  |  |                     List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId()); | 
 |  |  |                     if(CollUtil.isNotEmpty(shopLogisticsInfos)) { | 
 |  |  |                         ArrayList<LogisticsVo> logisticsVos = new ArrayList<>(); | 
 |  |  |                         for(ShopLogisticsInfo shopLogistics : shopLogisticsInfos) { | 
 |  |  |                             LogisticsVo logisticsVo = new LogisticsVo(); | 
 |  |  |                             logisticsVo.setContent(shopLogistics.getDescribe()); | 
 |  |  |                             logisticsVo.setTimestamp(shopLogistics.getLogisticsTime()); | 
 |  |  |                             logisticsVos.add(logisticsVo); | 
 |  |  |                         } | 
 |  |  |                         signWriteoffVo.setActivities(logisticsVos); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         result.putInMap("signWriteoffVo", signWriteoffVo); | 
 |  |  | 
 |  |  |  | 
 |  |  |         shopDeliveryInfo.setDeliveryTime(new Date()); | 
 |  |  |         shopDeliveryInfoDao.insert(shopDeliveryInfo); | 
 |  |  | //        Integer id = shopDeliveryInfo.getId(); | 
 |  |  | //        if(ObjectUtil.isNotEmpty(id)) { | 
 |  |  | //            List<ShopLogisticsInfo> shopLogisticsList = new ArrayList<ShopLogisticsInfo>(); | 
 |  |  | //            AjaxResult result = new AjaxResult(); | 
 |  |  | //            Map<String, String> logisticsInfo = new HashMap<String, String>(); | 
 |  |  | //            try { | 
 |  |  | //                if (shopDeliveryInfo == null) { | 
 |  |  | //                    return new AjaxResult(AjaxResult.STATUS_FAIL, "找不到发货信息"); | 
 |  |  | //                } | 
 |  |  | //                if (!StringUtils.isNotBlank(shopDeliveryInfo.getWaybillNo()) || !StringUtils.isNotBlank(shopDeliveryInfo.getLogisticsCompanyCode())) { | 
 |  |  | //                    return new AjaxResult(AjaxResult.STATUS_FAIL, "物流公司信息为空"); | 
 |  |  | //                } | 
 |  |  | //                logisticsInfo.put("logisticsCompany", shopDeliveryInfo.getLogisticsCompany()); | 
 |  |  | //                logisticsInfo.put("waybillNo", shopDeliveryInfo.getWaybillNo()); | 
 |  |  | // | 
 |  |  | //                //如果已经签收直接查数据库 | 
 |  |  | //                if (AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR.equals(shopDeliveryInfo.getLogisticsStatus())) { | 
 |  |  | // | 
 |  |  | //                    List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId()); | 
 |  |  | //                    logisticsInfo.put("logisticsStatus", String.valueOf(AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR)); | 
 |  |  | //                    result.setStatus(AjaxResult.STATUS_SUCCESS); | 
 |  |  | //                    result.setRows(shopLogisticsInfos); | 
 |  |  | //                    result.putInMap("logisticsInfo", logisticsInfo); | 
 |  |  | //                    return result; | 
 |  |  | //                } | 
 |  |  | //                Map<String, String> param = new HashMap<String, String>(); | 
 |  |  | //                param.put("ShipperCode", shopDeliveryInfo.getLogisticsCompanyCode()); | 
 |  |  | //                param.put("LogisticCode", shopDeliveryInfo.getWaybillNo()); | 
 |  |  | //                Map<String, String> paramsUrl = getparams(param); | 
 |  |  | //                LogUtil.info("物流查询参数" + paramsUrl); | 
 |  |  | //                String logisticsResult = HttpCurlUtil.sendPost(logisticsUrl, paramsUrl); | 
 |  |  | //                LogUtil.info("查询物流返回信息" + logisticsResult); | 
 |  |  | //                LogisticsInfoVo logisticsInfoVo = JSON.parseObject(logisticsResult, LogisticsInfoVo.class); | 
 |  |  | //                if (logisticsInfoVo.isSuccess()) { | 
 |  |  | //                    ShopDeliveryInfo shopDelivery = new ShopDeliveryInfo(); | 
 |  |  | //                    shopDelivery.setLogisticsStatus(Integer.valueOf(logisticsInfoVo.getState())); | 
 |  |  | //                    shopDelivery.setId(shopDeliveryInfo.getId()); | 
 |  |  | //                    logisticsInfo.put("logisticsStatus", logisticsInfoVo.getState()); | 
 |  |  | //                    //更新物流状态 | 
 |  |  | //                    shopDeliveryInfoDao.updateByModel(shopDelivery); | 
 |  |  | //                    if (CollectionUtils.isNotEmpty(logisticsInfoVo.getTraces())) { | 
 |  |  | //                        List<Map<String, String>> mapTraces = logisticsInfoVo.getTraces(); | 
 |  |  | //                        for (int i = 0; i < mapTraces.size(); i++) { | 
 |  |  | //                            ShopLogisticsInfo shopLogisticsInfo = new ShopLogisticsInfo(); | 
 |  |  | //                            shopLogisticsInfo.setCreateBy(AppConstance.SYSTEM_USER); | 
 |  |  | //                            shopLogisticsInfo.setUpdateBy(AppConstance.SYSTEM_USER); | 
 |  |  | //                            shopLogisticsInfo.setLogisticsTime(mapTraces.get(i).get("AcceptTime")); | 
 |  |  | //                            String acceptStation = mapTraces.get(i).get("AcceptStation"); | 
 |  |  | //                            shopLogisticsInfo.setDescribe(acceptStation); | 
 |  |  | //                            shopLogisticsInfo.setDelieryId(shopDeliveryInfo.getId()); | 
 |  |  | //                            if (acceptStation.indexOf(AppConstance.KDN_IS_SIGN) != -1) { | 
 |  |  | //                                shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR); | 
 |  |  | //                            } else if (acceptStation.indexOf(AppConstance.KDN_IS_RECEIVE) != -1) { | 
 |  |  | //                                shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_RECEIVE); | 
 |  |  | //                            } else if (acceptStation.indexOf(AppConstance.KDN_IS_ON_WAY) != -1) { | 
 |  |  | //                                shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_ON_WAY); | 
 |  |  | //                            } else if (acceptStation.indexOf(AppConstance.KDN_IS_MISTAKE) != -1) { | 
 |  |  | //                                shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_MISTAKE); | 
 |  |  | //                            } else { | 
 |  |  | //                                shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_NONE); | 
 |  |  | //                            } | 
 |  |  | //                            shopLogisticsList.add(shopLogisticsInfo); | 
 |  |  | //                        } | 
 |  |  | //                        shopLogisticsInfoDao.deleteByDelieryId(shopDeliveryInfo.getId()); | 
 |  |  | //                        if (CollectionUtils.isNotEmpty(shopLogisticsList)) { | 
 |  |  | //                            shopLogisticsInfoDao.batchInsert(shopLogisticsList); | 
 |  |  | //                        } | 
 |  |  | //                    } | 
 |  |  | //                } else { | 
 |  |  | //                    throw new GlobleException(logisticsInfoVo.getReason()); | 
 |  |  | //                } | 
 |  |  | // | 
 |  |  | //            } catch (Exception e) { | 
 |  |  | //                throw new GlobleException("物流信息查询失败"); | 
 |  |  | //            } | 
 |  |  |             //更新核销记录 | 
 |  |  |             activitySignWriteoff.setState(ActivitySignWriteoff.STATE_THREE); | 
 |  |  |             activitySignWriteoff.setWriteoffTime(new Date()); | 
 |  |  |             activitySignWriteoff.setWriteoffUser(sysUsers.getSuName()); | 
 |  |  |             activitySignWriteoff.setWriteoffUserid(sysUsers.getSuId()); | 
 |  |  |             activitySignWriteoff.setLogisticsId(shopDeliveryInfo.getId()); | 
 |  |  |             activitySignWriteoffDao.updateById(activitySignWriteoff); | 
 |  |  |             //更新领取记录 | 
 |  |  |             ActivitySignReceiveRecord activitySignReceiveRecord = activitySignReceiveRecordDao.selectById(receiveId); | 
 |  |  |             activitySignReceiveRecord.setState(ActivitySignReceiveRecord.STATE_THREE); | 
 |  |  |             activitySignReceiveRecord.setConsignee(logisticsSubmitDto.getShr()); | 
 |  |  |             activitySignReceiveRecord.setConsigneeAddress(logisticsSubmitDto.getShdz()); | 
 |  |  |             activitySignReceiveRecord.setConsigneePhone(logisticsSubmitDto.getLxdh()); | 
 |  |  |             activitySignReceiveRecordDao.updateById(activitySignReceiveRecord); | 
 |  |  | //        } | 
 |  |  |         //更新核销记录 | 
 |  |  |         activitySignWriteoff.setState(ActivitySignWriteoff.STATE_THREE); | 
 |  |  |         activitySignWriteoff.setWriteoffTime(new Date()); | 
 |  |  |         activitySignWriteoff.setWriteoffUser(sysUsers.getSuName()); | 
 |  |  |         activitySignWriteoff.setWriteoffUserid(sysUsers.getSuId()); | 
 |  |  |         activitySignWriteoff.setLogisticsId(shopDeliveryInfo.getId()); | 
 |  |  |         activitySignWriteoffDao.updateById(activitySignWriteoff); | 
 |  |  |         //更新领取记录 | 
 |  |  |         ActivitySignReceiveRecord activitySignReceiveRecord = activitySignReceiveRecordDao.selectById(receiveId); | 
 |  |  |         activitySignReceiveRecord.setState(ActivitySignReceiveRecord.STATE_THREE); | 
 |  |  |         activitySignReceiveRecord.setConsignee(logisticsSubmitDto.getShr()); | 
 |  |  |         activitySignReceiveRecord.setConsigneeAddress(logisticsSubmitDto.getShdz()); | 
 |  |  |         activitySignReceiveRecord.setConsigneePhone(logisticsSubmitDto.getLxdh()); | 
 |  |  |         activitySignReceiveRecordDao.updateById(activitySignReceiveRecord); | 
 |  |  |         return new AjaxResult(AjaxResult.STATUS_SUCCESS, "发货成功"); | 
 |  |  |     } | 
 |  |  |  |