| @@ -1,5 +1,6 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| @@ -156,82 +157,6 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| return ttMerchantPoiService.supplierQuery(getTenantInfo(),id); | |||
| } | |||
| // @ApiOperation("获取商品可用的POI") | |||
| // @GetMapping("/findPoi") | |||
| // @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| // @SystemControllerLog(description = "查询") | |||
| // public ResultData findPoi(Long couponChannelId) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId); | |||
| // } | |||
| // @ApiOperation("商品同步") | |||
| // @PostMapping("spuSync") | |||
| // @SystemControllerLog(description = "商品同步") | |||
| // public ResultData spuSync(@RequestBody Map<String, String> param) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync"); | |||
| // String couponChannelIdStr = param.get("couponChannelId"); | |||
| // Long couponChannelId = null; | |||
| // try{ | |||
| // couponChannelId = Long.parseLong(couponChannelIdStr); | |||
| // }catch(Exception e){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||
| // } | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| //// String merchantIdStr = param.get("merchantIds"); | |||
| //// List<Long> merchantIds = new ArrayList<>(); | |||
| //// try{ | |||
| //// List<String> strings = Arrays.asList(merchantIdStr.split(",")); | |||
| //// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); | |||
| //// }catch(Exception e){ | |||
| //// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||
| //// } | |||
| //// if(merchantIds == null || merchantIds.size() == 0){ | |||
| //// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| //// } | |||
| // return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null); | |||
| // } | |||
| // @ApiOperation("商品同步查询") | |||
| // @GetMapping("spuGet") | |||
| // @SystemControllerLog(description = "商品同步查询") | |||
| // public ResultData spuGet(Long couponChannelId) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId); | |||
| // } | |||
| // | |||
| // @ApiOperation("商品状态同步") | |||
| // @PostMapping("spuStatusSync") | |||
| // @SystemControllerLog(description = "商品状态同步") | |||
| // public ResultData spuStatusSync(@RequestBody Map<String, Long> param) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync"); | |||
| // Long couponChannelId = param.get("couponChannelId"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId); | |||
| // } | |||
| // | |||
| // @ApiOperation("商品库存同步") | |||
| // @PostMapping("spuStockSync") | |||
| // @SystemControllerLog(description = "商品库存同步") | |||
| // public ResultData spuStockSync(@RequestBody Map<String, Long> param) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync"); | |||
| // Long couponChannelId = param.get("couponChannelId"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId); | |||
| // } | |||
| @TenantIgnore | |||
| @RequestMapping("/exportTemplate") | |||
| public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { | |||
| @@ -251,7 +176,6 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| @TenantIgnore | |||
| @PostMapping(value = "/addLocationInfo", consumes = "multipart/*") | |||
| //@SystemControllerLog(description = "poi-来客模版补齐地理位置信息") | |||
| public void addLocationInfo(@RequestParam("poiFile") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| @@ -259,7 +183,8 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| //return addLocationInfo(mFile,false); | |||
| throw new MallinkException(Result.ERROR,"当前版本无需补齐地理位置信息"); | |||
| }else { | |||
| addLocationInfo(mFile,true,"1bdc087fc6f72820dc5c848a033de7f9",request,response); | |||
| File lFile = handlerImportFile(mFile,null,"poiAddLocation"); | |||
| asyncTask.exportExcelPoiDataAddLocationForNew(this.getTenantInfo(),"1bdc087fc6f72820dc5c848a033de7f9",lFile,request,response); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("addLocationInfo error.",e); | |||
| @@ -267,19 +192,32 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| } | |||
| } | |||
| private void addLocationInfo(MultipartFile mFile,boolean isNew,String gaodeKey, | |||
| HttpServletRequest request, HttpServletResponse response) throws Exception{ | |||
| private File handlerImportFile(MultipartFile mFile,String importKey,String fileNamePre) { | |||
| if (mFile.isEmpty()) { | |||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| } | |||
| //得到当前用户ID | |||
| boolean isSetCacheLock = true; | |||
| if (StringUtils.isBlank(importKey)) { | |||
| isSetCacheLock = false; | |||
| } | |||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||
| if (isSetCacheLock) { | |||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||
| if (allCount) { | |||
| throw new MallinkException(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||
| } | |||
| String fpath = fmUploadDir; | |||
| File targetFile = new File(fpath); | |||
| if (!targetFile.exists()) { | |||
| targetFile.mkdirs(); | |||
| } | |||
| String fileName = "poiAddLocation" + Math.round(Math.random() * 100000000000L); | |||
| String fileName = fileNamePre + Math.round(Math.random() * 100000000000L); | |||
| int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||
| fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||
| @@ -297,134 +235,84 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| return lFile; | |||
| } catch (Exception e) { | |||
| logger.error("poiAddLocation create tempFile error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| if (isSetCacheLock) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| } | |||
| logger.error("poi import error.",e); | |||
| throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } finally { | |||
| if (fos != null) { | |||
| try { | |||
| fos.close(); | |||
| } catch (IOException e) { | |||
| logger.error("poiAddLocation create tempFile error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| if (isSetCacheLock) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| } | |||
| logger.error("poi import error.",e); | |||
| throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| if (fs != null) { | |||
| try { | |||
| fs.close(); | |||
| } catch (IOException e) { | |||
| logger.error("poiAddLocation create tempFile error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| if (isSetCacheLock) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| } | |||
| logger.error("poi import error.",e); | |||
| throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| } | |||
| if (isNew) { | |||
| asyncTask.exportExcelPoiDataAddLocationForNew(gaodeKey,lFile,request,response); | |||
| }else { | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @PostMapping(value = "/importPoi", consumes = "multipart/*") | |||
| @SystemControllerLog(description = "poi-导入数据") | |||
| public ResultData importPoi(@RequestParam("file") MultipartFile mFile) { | |||
| public void importPoi(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| return processImport(mFile,false); | |||
| }else { | |||
| return processImport(mFile,true); | |||
| } | |||
| //得到当前用户ID | |||
| final MallUserInfo user = getUser(); | |||
| String userId = "" + user.getId(); | |||
| String importKey = Constant.importPoiPrev + userId; | |||
| File lFile = handlerImportFile(mFile,importKey,"poi"); | |||
| if (isSaas) { | |||
| asyncTask.importExcelPoiDataForNew(lFile, user, importKey,request,response); | |||
| }else { | |||
| asyncTask.importExcelPoiData(lFile, user, importKey,request,response); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("allTreeList error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| private ResultData processImport(MultipartFile mFile,boolean isNew) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::importPoi"); | |||
| if (mFile.isEmpty()) { | |||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| } | |||
| //得到当前用户ID | |||
| final MallUserInfo user = getUser(); | |||
| String userId = "" + user.getId(); | |||
| String importKey = Constant.importPoiPrev + userId; | |||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||
| if (allCount) { | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||
| stringRedisTemplate.expire(importKey,30, TimeUnit.MINUTES); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||
| String fpath = fmUploadDir; | |||
| File targetFile = new File(fpath); | |||
| if (!targetFile.exists()) { | |||
| targetFile.mkdirs(); | |||
| } | |||
| String fileName = "poi" + Math.round(Math.random() * 100000000000L); | |||
| int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||
| fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||
| File lFile = new File(fpath + File.separator + fileName); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| try { | |||
| fos = new FileOutputStream(lFile); | |||
| fs = (BufferedInputStream) mFile.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| } catch (Exception e) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } finally { | |||
| if (fos != null) { | |||
| try { | |||
| fos.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| if (fs != null) { | |||
| try { | |||
| fs.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| } | |||
| if (isNew) { | |||
| asyncTask.importExcelPoiDataForNew(lFile, user, importKey); | |||
| }else { | |||
| asyncTask.importExcelPoiData(lFile, user, importKey); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| @TenantIgnore | |||
| @PostMapping(value = "/importMerchantInitByPoi", consumes = "multipart/*") | |||
| @SystemControllerLog(description = "poi-初始化商户商户") | |||
| public void importMerchantInitByPoi(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| throw new MallinkException(Result.ERROR,"当前版本不支持"); | |||
| }else { | |||
| final MallUserInfo user = getUser(); | |||
| String userId = "" + user.getId(); | |||
| String importKey = Constant.importPoiMerchantPrev + userId; | |||
| File lFile = handlerImportFile(mFile,importKey,"poiMerchantInit"); | |||
| asyncTask.importMerchantInit(lFile, user, importKey,request,response); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("importMerchantInitByPoi error.",e); | |||
| throw new MallinkException(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil; | |||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ExportParams; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; | |||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| @@ -11,16 +12,21 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.TtMerchantPoi; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxTags; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||
| import com.iformall.domain.vo.GaoDePoiInfo; | |||
| import com.iformall.domain.vo.MerchantPoiT; | |||
| import com.iformall.domain.vo.MerchantPoiTNew; | |||
| import com.iformall.domain.vo.WxCardPriceTemplate; | |||
| import com.iformall.enums.EnumMerchantCreateFrom; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.TtMerchantPoiService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCouponPasswordService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxTagsService; | |||
| import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||
| @@ -36,7 +42,9 @@ import org.springframework.stereotype.Component; | |||
| import java.io.File; | |||
| import java.io.OutputStream; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @@ -60,6 +68,9 @@ public class AsyncTask { | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||
| @Override | |||
| @@ -178,19 +189,18 @@ public class AsyncTask { | |||
| } | |||
| @Async | |||
| public void importExcelPoiData(File file, MallUserInfo user, String importKey) { | |||
| public void importCardPriceData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", | |||
| "已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息"}); | |||
| IExcelDataHandler<MerchantPoiT> handler = new AsyncTask.PoiExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"服务商POI_ID","已匹配POI_ID"}); | |||
| params.setImportFields(new String[]{"*卡ID", "*面额(元)"}); | |||
| IExcelDataHandler<WxCardPriceTemplate> handler = new AsyncTask.CardPriceExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"*卡ID","*面额(元)"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<MerchantPoiT> datalist = null; | |||
| ExcelImportResult<WxCardPriceTemplate> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiT.class, params); | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxCardPriceTemplate.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| @@ -207,8 +217,8 @@ public class AsyncTask { | |||
| return; | |||
| } | |||
| List<MerchantPoiT> successList = datalist.getList(); | |||
| List<MerchantPoiT> failList = datalist.getFailList(); | |||
| List<WxCardPriceTemplate> successList = datalist.getList(); | |||
| List<WxCardPriceTemplate> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| @@ -224,7 +234,7 @@ public class AsyncTask { | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| ttMerchantPoiService.importOneMem(user,importKey, poiBase); | |||
| wxCouponPasswordService.importPrice(user,importKey, poiBase); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| } | |||
| @@ -237,38 +247,118 @@ public class AsyncTask { | |||
| } | |||
| } | |||
| public void exportExcelPoiDataAddLocationForNew(String gaodeKey,File file,HttpServletRequest request, HttpServletResponse response) throws Exception { | |||
| ImportParams params = new ImportParams(); | |||
| private ExcelImportResult handleImportFile(String importKey,File file,Class dataClazz,String[] importFields,String[] needFields,IExcelDataHandler handler) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| String[] headers = new String[]{"富茂系统商户ID", "富茂系统商户名称","门店名称", "门店ID", "城市", "详细地址","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","高德匹配备注"}; | |||
| params.setImportFields(headers); | |||
| IExcelDataHandler<MerchantPoiTNew> handler = new AsyncTask.PoiNewExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"门店名称", "门店ID", "城市", "详细地址"}); | |||
| params.setImportFields(importFields); | |||
| handler.setNeedHandlerFields(needFields); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<MerchantPoiTNew> datalist = null; | |||
| ExcelImportResult<MerchantPoiT> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiTNew.class, params); | |||
| datalist = ExcelImportUtil.importExcelMore(file, dataClazz, params); | |||
| } catch (Exception e) { | |||
| logger.error("exportExcelPoiDataAddLocationForNew import error.",e); | |||
| logger.error(e.getMessage(),e); | |||
| if (StringUtils.isNotBlank(importKey)) { | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| return null; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if(datalist == null) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"解析模版失败,请检查模版格式"); | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| if (StringUtils.isNotBlank(importKey)) { | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| return null; | |||
| } | |||
| return datalist; | |||
| } | |||
| @Async | |||
| public void importExcelPoiData(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { | |||
| String[] importFields = new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", | |||
| "已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息","POI导入结果"}; | |||
| String[] needFields = new String[]{"服务商POI_ID","已匹配POI_ID"}; | |||
| ExcelImportResult<MerchantPoiT> datalist = handleImportFile(importKey,file,MerchantPoiT.class,importFields,needFields,new AsyncTask.PoiExcelHandler()); | |||
| if (null == datalist) { | |||
| return; | |||
| } | |||
| List<MerchantPoiT> successList = datalist.getList(); | |||
| if(successList.size() > 0) { | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| ttMerchantPoiService.importOneMem(user, poiBase); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| } | |||
| }); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| exportExcel(request, response, successList,MerchantPoiT.class, "POI导入-结果.xlsx"); | |||
| } catch (Exception e) { | |||
| logger.error("导入模板失败:"+e.getMessage(),e); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| } | |||
| private static final String[] poiImportFields = new String[]{"门店名称", "门店ID", "城市", "详细地址","管理员手机号","富茂系统商户ID", "富茂系统商户名称","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","初始化商户日志","高德匹配备注","POI导入日志"}; | |||
| public void exportExcelPoiDataAddLocationForNew(TenantEntity tenantEntity,String gaodeKey,File file,HttpServletRequest request, HttpServletResponse response) throws Exception { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| String[] needFields = new String[]{"门店名称", "门店ID", "城市", "详细地址"}; | |||
| ExcelImportResult<MerchantPoiTNew> datalist = handleImportFile(null,file,MerchantPoiTNew.class,poiImportFields,needFields,new AsyncTask.PoiNewExcelHandler()); | |||
| if (null == datalist) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"解析模版失败,请检查模版格式"); | |||
| } | |||
| List<MerchantPoiTNew> successList = datalist.getList(); | |||
| //List<MerchantPoiTNew> failList = datalist.getFailList(); | |||
| if(null != successList && successList.size() > 0 ) { | |||
| try { | |||
| //查询所有匹配了poi的 | |||
| TtMerchantPoi poiQ = new TtMerchantPoi(); | |||
| poiQ.updateTenantInfo(tenantEntity); | |||
| Map<String,TtMerchantPoi> poiMerchantMap = ttMerchantPoiService.queryPoiMerchantMap(poiQ); | |||
| //查询所有商户 | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| Map<Long,WxMerchant> merchantMap = wxMerchantService.findMerchantMap(merchantQ); | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| String poiId = poiBase.getPoiId(); | |||
| if (StringUtils.isNotBlank(poiId) && null != poiMerchantMap) { | |||
| TtMerchantPoi tm = poiMerchantMap.get(poiId); | |||
| if (null != tm) { | |||
| if (tm.getId() > 0 ) { | |||
| poiBase.setMerchantId(String.valueOf(tm.getId())); | |||
| poiBase.setProvince(tm.getProvince()); | |||
| poiBase.setCity(tm.getCity()); | |||
| poiBase.setAddress(tm.getAddress()); | |||
| poiBase.setLongitude(tm.getLongitude()); | |||
| poiBase.setLatitude(tm.getLatitude()); | |||
| poiBase.setGaodeRemark("已匹配过,无需查询高德匹配"); | |||
| }else { | |||
| poiBase.setMerchantId(null); | |||
| poiBase.setMerchantName("多个商户已匹配该POI,请手动输入商户信息"); | |||
| } | |||
| } | |||
| if (null != merchantMap && null != tm && tm.getId() > 0) { | |||
| WxMerchant m = merchantMap.get(tm.getId()); | |||
| if (null != m) { | |||
| poiBase.setMerchantName(m.getName()); | |||
| } | |||
| } | |||
| } | |||
| if (StringUtils.isNotBlank(poiBase.getProvince()) && StringUtils.isNotBlank(poiBase.getCity()) | |||
| && StringUtils.isNotBlank(poiBase.getAddress()) && null != poiBase.getLongitude() && null != poiBase.getLatitude()) { | |||
| //do nothing | |||
| @@ -294,145 +384,135 @@ public class AsyncTask { | |||
| poiBase.setGaodeRemark("查询高德API失败"); | |||
| } | |||
| }); | |||
| ExportParams exportParams = new ExportParams(); | |||
| //exportParams.setCreateHeadRows(true); | |||
| //exportParams.setExclusions(headers); | |||
| Workbook workBook = ExcelExportUtil.exportExcel(exportParams, MerchantPoiTNew.class, successList); | |||
| exportExcel(request, response, workBook, "POI匹配模版-高德.xls"); | |||
| exportExcel(request, response, successList,MerchantPoiTNew.class, "POI匹配模版-高德.xlsx"); | |||
| } catch (Exception e) { | |||
| logger.error("更新地理信息失败:"+e.getMessage(),e); | |||
| } | |||
| } | |||
| } | |||
| private static void exportExcel(HttpServletRequest request, HttpServletResponse response, Workbook wb, String fileName) throws Exception { | |||
| private static void exportExcel(HttpServletRequest request, HttpServletResponse response,List successList, Class dataClass, String fileName) throws Exception { | |||
| ExportParams exportParams = new ExportParams(); | |||
| exportParams.setType(ExcelType.XSSF); | |||
| Workbook workBook = ExcelExportUtil.exportExcel(exportParams, dataClass, successList); | |||
| response.setContentType("application/octet-stream;charset=UTF-8"); | |||
| response.setHeader("Content-Type", "application/vnd.ms-excel"); | |||
| //response.setHeader("Content-Type", "application/vnd.ms-excel");//xls | |||
| response.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");//xlsx | |||
| response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("GB2312"), "8859_1")); | |||
| response.addHeader("Pargam", "no-cache"); | |||
| response.addHeader("Cache-Control", "no-cache"); | |||
| OutputStream out = response.getOutputStream(); | |||
| wb.write(out); | |||
| workBook.write(out); | |||
| out.flush(); | |||
| out.close(); | |||
| } | |||
| @Async | |||
| public void importExcelPoiDataForNew(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| public void importExcelPoiDataForNew(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { | |||
| // 需要验证 | |||
| String[] headers = new String[]{"富茂系统商户ID", "富茂系统商户名称","门店名称", "门店ID", "城市", "详细地址","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","高德匹配备注"}; | |||
| params.setImportFields(headers); | |||
| IExcelDataHandler<MerchantPoiTNew> handler = new AsyncTask.PoiNewExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"富茂系统商户ID","门店ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<MerchantPoiTNew> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiTNew.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if(datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| String[] needFields = new String[]{"门店ID","富茂系统商户ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"}; | |||
| ExcelImportResult<MerchantPoiTNew> datalist = handleImportFile(null,file,MerchantPoiTNew.class,poiImportFields,needFields,new AsyncTask.PoiNewExcelHandler()); | |||
| if (null == datalist) { | |||
| return ; | |||
| } | |||
| List<MerchantPoiTNew> successList = datalist.getList(); | |||
| List<MerchantPoiTNew> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int total = successList.size() + failList.size(); | |||
| int all_success = successList.size(); | |||
| int all_fail = failList.size(); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if(successList.size() > 0) { | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| ttMerchantPoiService.importOnePoiNew(user,importKey, poiBase); | |||
| ttMerchantPoiService.importOnePoiNew(user, poiBase); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| logger.error("session :"+ue.getMessage(),ue); | |||
| } | |||
| }); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| exportExcel(request, response, successList,MerchantPoiTNew.class, "POI导入-结果.xlsx"); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:"+e.getMessage()); | |||
| logger.error("导入模板失败:"+e.getMessage(),e); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| } | |||
| @Async | |||
| public void importCardPriceData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| public void importMerchantInit(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"*卡ID", "*面额(元)"}); | |||
| IExcelDataHandler<WxCardPriceTemplate> handler = new AsyncTask.CardPriceExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"*卡ID","*面额(元)"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxCardPriceTemplate> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxCardPriceTemplate.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| String[] needFields = new String[]{"门店名称", "门店ID", "城市", "详细地址"}; | |||
| ExcelImportResult<MerchantPoiTNew> datalist = handleImportFile(null,file,MerchantPoiTNew.class,poiImportFields,needFields,new AsyncTask.PoiNewExcelHandler()); | |||
| if (null == datalist) { | |||
| return ; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if(datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| //查询所有来客创建的商户 | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(user); | |||
| merchantQ.setCreateFrom(EnumMerchantCreateFrom.DOUYIN_LAIKE.getCode()); | |||
| Map<String, WxMerchant> createMerchantMap = wxMerchantService.findMerchantMapByCreateFromId(merchantQ); | |||
| if (null == createMerchantMap) { | |||
| createMerchantMap = new HashMap<String, WxMerchant>(); | |||
| } | |||
| List<WxCardPriceTemplate> successList = datalist.getList(); | |||
| List<WxCardPriceTemplate> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int total = successList.size() + failList.size(); | |||
| int all_success = successList.size(); | |||
| int all_fail = failList.size(); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| //查询所有已经匹配了poi的商户 | |||
| TtMerchantPoi poiQ = new TtMerchantPoi(); | |||
| poiQ.updateTenantInfo(user); | |||
| Map<String,TtMerchantPoi> poiMerchantMap = ttMerchantPoiService.queryPoiMerchantMap(poiQ); | |||
| if (null == poiMerchantMap) { | |||
| poiMerchantMap = new HashMap<String,TtMerchantPoi>(); | |||
| } | |||
| List<MerchantPoiTNew> successList = datalist.getList(); | |||
| if(successList.size() > 0) { | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| wxCouponPasswordService.importPrice(user,importKey, poiBase); | |||
| for (int i = 0 ; i < successList.size(); i ++) { | |||
| try { | |||
| MerchantPoiTNew poiBase = successList.get(i); | |||
| WxMerchant createM = createMerchantMap.get(poiBase.getPoiId()); | |||
| boolean create = true; | |||
| if (null != createM ) { | |||
| create = false; | |||
| if (createM.getId() > 0 ) { | |||
| poiBase.setMerchantId(String.valueOf(createM.getId())); | |||
| poiBase.setMerchantName(createM.getName()); | |||
| poiBase.setInitMerchantRemark("已存在该POI创建的商户,无需重复创建"); | |||
| }else { | |||
| poiBase.setMerchantName(createM.getName()); | |||
| poiBase.setInitMerchantRemark("初始化商户失败,已存在多个该POI创建的商户"); | |||
| } | |||
| }else { | |||
| TtMerchantPoi poi = poiMerchantMap.get(poiBase.getPoiId()); | |||
| if (null != poi) { | |||
| create = false; | |||
| if (poi.getId() > 0 ) { | |||
| poiBase.setMerchantId(String.valueOf(poi.getId())); | |||
| poiBase.setMerchantName(poi.getPoiName()); | |||
| poiBase.setInitMerchantRemark("已存在该POI创建的商户,无需重复创建"); | |||
| }else { | |||
| poiBase.setMerchantName(poi.getPoiName()); | |||
| poiBase.setInitMerchantRemark("初始化商户失败,该POI匹配了多个商户"); | |||
| } | |||
| } | |||
| } | |||
| if (create) { | |||
| try { | |||
| WxMerchant merchant = wxMerchantService.initMerchantByPoi(user,poiBase.getPoiName(), poiBase.getPoiId(),poiBase.getPhone()); | |||
| poiBase.setMerchantId(String.valueOf(merchant.getId())); | |||
| poiBase.setMerchantName(merchant.getName()); | |||
| poiBase.setInitMerchantRemark("初始化商户成功."); | |||
| }catch(Exception e) { | |||
| poiBase.setInitMerchantRemark("初始化商户失败."+e.getMessage()); | |||
| } | |||
| } | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| logger.error("session :"+ue.getMessage(),ue); | |||
| } | |||
| }); | |||
| } | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| exportExcel(request, response, successList,MerchantPoiTNew.class, "POI初始化商户.xlsx"); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:"+e.getMessage()); | |||
| logger.error("导入模板失败:"+e.getMessage(),e); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,2 @@ | |||
| alter table wx_merchant add column create_from int(1) NOT NULL DEFAULT 1 COMMENT '创建来源EnumMerchantCreateFrom' ; | |||
| alter table wx_merchant add column create_from_id varchar(100) COMMENT '创建来源编号' ; | |||
| @@ -150,6 +150,12 @@ public class WxMerchant extends TenantEntity { | |||
| // @Excel(name = "辅谈人", width = 20, orderNum = "17") | |||
| @io.swagger.annotations.ApiModelProperty(value = "辅谈人", name = "talkUserAux") | |||
| private String talkUserAux; | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建来源EnumMerchantCreateFrom", name = "createFrom") | |||
| private Integer createFrom; | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建来源Id", name = "createFromId") | |||
| private String createFromId; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "开始时间", name = "startTime") | |||
| @@ -66,5 +66,9 @@ public class MerchantPoiT implements Serializable { | |||
| @Excel(name = "其他信息", width = 20, orderNum = "15") | |||
| @io.swagger.annotations.ApiModelProperty(value="其他信息",name="extra") | |||
| private String extra; | |||
| @Excel(name = "POI导入结果", width = 20, orderNum = "16") | |||
| @io.swagger.annotations.ApiModelProperty(value="POI导入结果",name="importRemark") | |||
| private String importRemark; | |||
| } | |||
| @@ -12,42 +12,49 @@ import java.math.BigDecimal; | |||
| @Data | |||
| public class MerchantPoiTNew implements Serializable { | |||
| @Excel(name="富茂系统商户ID",width = 20,orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户ID",name="merchantId") | |||
| private String merchantId; | |||
| @Excel(name="富茂系统商户名称",width = 20,orderNum = "2") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户名称",name="merchantName") | |||
| private String merchantName; | |||
| @Excel(name = "门店名称", width = 20, orderNum = "3") | |||
| @Excel(name = "门店名称", width = 20, orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店名称",name="poiName") | |||
| private String poiName; | |||
| @Excel(name="门店ID",width = 20,orderNum = "4") | |||
| @Excel(name="门店ID",width = 20,orderNum = "2") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店ID",name="poiId") | |||
| private String poiId; | |||
| @Excel(name = "城市", width = 20, orderNum = "5") | |||
| @Excel(name = "城市", width = 20, orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店城市",name="poiCity") | |||
| private String poiCity; | |||
| @Excel(name = "详细地址", width = 20, orderNum = "6") | |||
| @Excel(name = "详细地址", width = 20, orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店详细地址",name="poiAddress") | |||
| private String poiAddress; | |||
| @Excel(name = "富茂系统省份", width = 20, orderNum = "7") | |||
| @Excel(name = "管理员手机号", width = 20, orderNum = "5") | |||
| @io.swagger.annotations.ApiModelProperty(value="管理员手机号",name="phone") | |||
| private String phone; | |||
| @Excel(name="富茂系统商户ID",width = 20,orderNum = "6") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户ID",name="merchantId") | |||
| private String merchantId; | |||
| @Excel(name="富茂系统商户名称",width = 20,orderNum = "7") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户名称",name="merchantName") | |||
| private String merchantName; | |||
| @Excel(name = "富茂系统省份", width = 20, orderNum = "8") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统省份",name="province") | |||
| private String province; | |||
| @Excel(name = "富茂系统城市", width = 20, orderNum = "8") | |||
| @Excel(name = "富茂系统城市", width = 20, orderNum = "9") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统城市",name="city") | |||
| private String city; | |||
| @Excel(name = "富茂系统地址", width = 20, orderNum = "9") | |||
| @Excel(name = "富茂系统地址", width = 20, orderNum = "10") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统地址",name="address") | |||
| private String address; | |||
| @Excel(name="富茂系统经度",width = 20,orderNum = "10") | |||
| @Excel(name="富茂系统经度",width = 20,orderNum = "11") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统经度",name="longitude") | |||
| private BigDecimal longitude; | |||
| @Excel(name = "富茂系统纬度", width = 20, orderNum = "11") | |||
| @Excel(name = "富茂系统纬度", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统纬度",name="latitude") | |||
| private BigDecimal latitude; | |||
| @Excel(name = "高德匹配备注", width = 20, orderNum = "12") | |||
| @Excel(name = "初始化商户日志", width = 20, orderNum = "13") | |||
| @io.swagger.annotations.ApiModelProperty(value="初始化商户日志",name="initMerchantRemark") | |||
| private String initMerchantRemark; | |||
| @Excel(name = "高德匹配备注", width = 20, orderNum = "14") | |||
| @io.swagger.annotations.ApiModelProperty(value="高德匹配备注",name="gaodeRemark") | |||
| private String gaodeRemark; | |||
| @Excel(name = "POI导入日志", width = 20, orderNum = "15") | |||
| @io.swagger.annotations.ApiModelProperty(value="POI导入日志",name="importRemark") | |||
| private String importRemark; | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumMerchantCreateFrom { | |||
| CREATE(1, "手动创建"), | |||
| DOUYIN_LAIKE(2, "抖音来客"); | |||
| public static EnumMerchantCreateFrom getEnum(Integer code) { | |||
| for (EnumMerchantCreateFrom value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumMerchantCreateFrom(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -4,6 +4,7 @@ import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.TtMerchantPoi; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface TtMerchantPoiMapper extends CommonMapper<TtMerchantPoi, Long> { | |||
| @@ -14,5 +15,5 @@ public interface TtMerchantPoiMapper extends CommonMapper<TtMerchantPoi, Long> { | |||
| List<TtMerchantPoi> findTaskIdList(TtMerchantPoi record); | |||
| int deleteByUpdate(Long id); | |||
| } | |||
| @@ -12,6 +12,7 @@ import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService; | |||
| import com.iformall.douyin.web.api.web.TtWebService; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @@ -63,11 +64,13 @@ public interface TtMerchantPoiService { | |||
| // ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId); | |||
| void importOneMem(MallUserInfo user, String importKey, MerchantPoiT poiBase); | |||
| void importOneMem(MallUserInfo user, MerchantPoiT poiBase); | |||
| void importOnePoiNew(MallUserInfo user, String importKey, MerchantPoiTNew poiBase); | |||
| void importOnePoiNew(MallUserInfo user, MerchantPoiTNew poiBase); | |||
| void exportTemplate(HttpServletRequest request, HttpServletResponse response,boolean isNew); | |||
| GaoDePoiInfo queryGaoDePoiInfo(String gaodeKey,String address); | |||
| Map<String,TtMerchantPoi> queryPoiMerchantMap(TtMerchantPoi merchantPoiQ); | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxMerchantDto; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBusinessCircleOrder; | |||
| import com.iformall.domain.po.WxMerchantCorp; | |||
| import com.iformall.domain.po.WxPark; | |||
| @@ -215,12 +216,15 @@ public interface WxMerchantService { | |||
| WxMerchant findBrandAdmin(TenantEntity tenantEntity, Long brandId); | |||
| Map<Long, WxMerchant> findMerchantMap(WxMerchant merchantQ); | |||
| Map<String,WxMerchant> findMerchantMapByCreateFromId(WxMerchant merchantQ); | |||
| WxMerchant findParkMerchant(WxPark wxPark); | |||
| List<WxMerchant> relationList(Long regionId); | |||
| PageInfo<WxMerchant> subMerchantList(WxMerchant wxMerchant, Integer pageNum, Integer pageSize); | |||
| List<Long> selectByMerchantIds(String merchantName); | |||
| WxMerchant initMerchantByPoi(MallUserInfo user,String poiName,String poiId,String phone) throws Exception; | |||
| } | |||
| @@ -103,5 +103,7 @@ public interface WxShopService { | |||
| */ | |||
| Map<Long,List<WxShopVo>> findMerchantShopVoListMap(TenantEntity tenantEntity, List<Long> merchantIds); | |||
| List<WxShopVo> findMerchantShopVoList(TenantEntity tenantEntity,Long merchantId); | |||
| WxShop getShopByShopNumber(TenantEntity tenantEntity,String shopNumber); | |||
| } | |||
| @@ -556,15 +556,13 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| } | |||
| @Override | |||
| public void importOneMem(MallUserInfo user, String importKey, MerchantPoiT poiBase) { | |||
| public void importOneMem(MallUserInfo user, MerchantPoiT poiBase) { | |||
| if (StringUtils.isBlank(poiBase.getMerchantId())) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| logger.error("服务商POI_ID为空", poiBase.toString()); | |||
| poiBase.setImportRemark("导入失败.服务商POI_ID为空"); | |||
| return; | |||
| } | |||
| if (StringUtils.isBlank(poiBase.getPoiId())) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| logger.error("已匹配POI_ID为空", poiBase.toString()); | |||
| poiBase.setImportRemark("导入失败.已匹配POI_ID为空"); | |||
| return; | |||
| } | |||
| @@ -598,31 +596,29 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| }else{ | |||
| ttMerchantPoiMapper.updateById(merchantPoi); | |||
| } | |||
| poiBase.setImportRemark("导入成功"); | |||
| } catch (Exception e) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| logger.error(e.getMessage()); | |||
| logger.error("importOneMem error.",e); | |||
| poiBase.setImportRemark("导入失败."+e.getMessage()); | |||
| return; | |||
| } | |||
| stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| @Override | |||
| public void importOnePoiNew(MallUserInfo user, String importKey, MerchantPoiTNew poiBase) { | |||
| if (StringUtils.isBlank(poiBase.getMerchantId())) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| return; | |||
| } | |||
| public void importOnePoiNew(MallUserInfo user, MerchantPoiTNew poiBase){ | |||
| if (StringUtils.isBlank(poiBase.getPoiId())) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| return; | |||
| poiBase.setImportRemark("导入失败.门店ID为空"); | |||
| return; | |||
| } | |||
| if (StringUtils.isBlank(poiBase.getMerchantId())) { | |||
| poiBase.setImportRemark("导入失败.富茂系统商户ID为空"); | |||
| return; | |||
| } | |||
| try { | |||
| TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(poiBase.getMerchantId())); | |||
| Date now = new Date(); | |||
| TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(poiBase.getMerchantId())); | |||
| if(merchantPoi == null){ | |||
| merchantPoi = new TtMerchantPoi(); | |||
| } | |||
| @@ -640,6 +636,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| merchantPoi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | |||
| merchantPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | |||
| merchantPoi.setUpdateDate(now); | |||
| if(merchantPoi.getId() == null){ | |||
| merchantPoi.setId(Long.parseLong(poiBase.getMerchantId())); | |||
| merchantPoi.setCreateDate(now); | |||
| @@ -647,57 +644,14 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| }else{ | |||
| ttMerchantPoiMapper.updateById(merchantPoi); | |||
| } | |||
| poiBase.setImportRemark("导入成功"); | |||
| } catch (Exception e) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| logger.error(e.getMessage()); | |||
| logger.error(e.getMessage(),e); | |||
| poiBase.setImportRemark("导入失败."+e.getMessage()); | |||
| return; | |||
| } | |||
| stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| // @Override | |||
| // public ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId) { | |||
| // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | |||
| // if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据"); | |||
| // } | |||
| // if(!EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(couponChannel.getTargetAd())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"只有投放在列表的卷才能进行同步poi"); | |||
| // } | |||
| // WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); | |||
| // if(coupon == null || !EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(coupon.getStatus())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到可投放的卷"); | |||
| // } | |||
| // if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); | |||
| // } | |||
| //// List<TtMerchantPoi> list = new ArrayList<>(); | |||
| //// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); | |||
| ////// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); | |||
| //// list.add(merchantPoi); | |||
| // | |||
| // List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); | |||
| // if(merchantIds == null || merchantIds.size() == 0 ){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); | |||
| // } | |||
| // | |||
| // TtMerchantPoi poi = new TtMerchantPoi(); | |||
| // poi.updateTenantInfo(tenantInfo); | |||
| // poi.setIds(merchantIds); | |||
| // poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); | |||
| // poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | |||
| // List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); | |||
| // if(poiList != null && merchantIds.size() == poiList.size()){ | |||
| // return new ResultData(poiList); | |||
| // }else{ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配"); | |||
| // } | |||
| // | |||
| // } | |||
| private void updateWebAccessToken(WxAppinfo appinfo, TtBasicService ttbasicService) { | |||
| try { | |||
| String accessToken = ttbasicService.getAccessToken(true); | |||
| @@ -775,388 +729,28 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| } | |||
| return null; | |||
| } | |||
| // @Override | |||
| // public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId, List<Long> merchantIds) { | |||
| // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | |||
| // if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据"); | |||
| // } | |||
| // if(!EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(couponChannel.getTargetAd())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"只有投放在列表的卷才能进行同步poi"); | |||
| // } | |||
| // WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); | |||
| // if(coupon == null || !EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(coupon.getStatus())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到可投放的卷"); | |||
| // } | |||
| // if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); | |||
| // } | |||
| // List<Long> couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); | |||
| // if(couponMerchantIds == null || couponMerchantIds.size() == 0 ){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); | |||
| // } | |||
| // | |||
| // TtMerchantPoi poi = new TtMerchantPoi(); | |||
| // poi.updateTenantInfo(tenantInfo); | |||
| // poi.setIds(couponMerchantIds); | |||
| // poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); | |||
| // poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); | |||
| // List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); | |||
| // if(poiList == null || poiList.isEmpty()){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi"); | |||
| // } | |||
| //// List<Long> collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList()); | |||
| // | |||
| // String spuId = spuSync(coupon,couponChannel,couponMerchantIds); | |||
| // if(StringUtils.isBlank(spuId)){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); | |||
| // } | |||
| // WxCouponChannel ccUpd = new WxCouponChannel(); | |||
| // ccUpd.setId(couponChannel.getId()); | |||
| // ccUpd.updateTenantInfo(couponChannel); | |||
| // ccUpd.setTtSpuId(spuId); | |||
| // ccUpd.setUpdateDate(new Date()); | |||
| // wxCouponChannelMapper.updateById(ccUpd); | |||
| // | |||
| // syncCouponChannelPoi(ccUpd); | |||
| // return new ResultData(); | |||
| // } | |||
| // private void syncCouponChannelPoi(WxCouponChannel ccUpd){ | |||
| // TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getTenantId(),ccUpd.getId()); | |||
| // if(ttCouponChannelPoi != null){ | |||
| // ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); | |||
| // ttCouponChannelPoi.setLastStatusDesc(""); | |||
| // ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); | |||
| // ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi); | |||
| // }else{ | |||
| // ttCouponChannelPoi = new TtCouponChannelPoi(); | |||
| // ttCouponChannelPoi.setId(ccUpd.getId()); | |||
| // ttCouponChannelPoi.updateTenantInfo(ccUpd); | |||
| // ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId()); | |||
| // ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); | |||
| // ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); | |||
| // ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate()); | |||
| // ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); | |||
| // ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); | |||
| // } | |||
| // } | |||
| // private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List<Long> merchantIds){ | |||
| // TtSpuSync spuSync = new TtSpuSync(); | |||
| // spuSync.setEntryInfo(getEntryInfo(couponChannel)); | |||
| //// spuSync.setFrontCategoryTag();//前台品类标签 | |||
| //// spuSync.setRecommendWord();//推荐语,5~20个字 | |||
| //// spuSync.setSortWeight();//排序权重,按降序排列 | |||
| // List<String> collect = merchantIds.stream().map(merchantId -> merchantId.toString()).collect(Collectors.toList()); | |||
| // spuSync.setSupplierExtIdList(collect); | |||
| // spuSync.setPrice(coupon.getSalePrice()); | |||
| // spuSync.setSpuExtId(couponChannel.getId().toString()); | |||
| // spuSync.setImageList(JSONArray.parseArray(coupon.getCoverPicture(),String.class)); | |||
| //// spuSync.setMpSettletype();//小程序结算类型 1-包销 2-代销 | |||
| // spuSync.setOriginPrice(coupon.getPrice()); | |||
| //// spuSync.setTakeRate();//商品的抽佣率,万分数 | |||
| // spuSync.setAttribute(getAttribute(coupon,couponChannel)); | |||
| //// spuSync.setHighlights(getHighlights(coupon)); | |||
| // spuSync.setName(coupon.getTitle()); | |||
| //// spuSync.setOrderDependsOnDate(false);//下单是否依赖日期 | |||
| // spuSync.setSpuType(91);//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券 | |||
| // if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ | |||
| // spuSync.setStatus(1); | |||
| // }else{ | |||
| // spuSync.setStatus(2); | |||
| // } | |||
| // spuSync.setStock(coupon.getRemainInventory()); | |||
| // | |||
| // String spuId = null; | |||
| // try { | |||
| // spuId = getTtWebService(coupon).getProductService().spuSync(spuSync); | |||
| // } catch (WxErrorException e) { | |||
| // logger.error("发起商品同步error"+e.getMessage()); | |||
| // throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| // } | |||
| // return spuId; | |||
| // } | |||
| //__________________________________商品同步_______________________________________________ | |||
| //获取入口信息 | |||
| // private JsonObject getEntryInfo(WxCouponChannel couponChannel){ | |||
| // JsonObject object = new JsonObject(); | |||
| // object.addProperty("entry_type",2);//入口类型(1:H5,2:抖音小程序,3:抖音链接) | |||
| // JsonObject miniApp = new JsonObject(); | |||
| // miniApp.addProperty("params",couponChannel.getTtparams()); | |||
| // miniApp.addProperty("path",couponChannel.getTtPath()); | |||
| // WxAppinfo appInfo = wxAppinfoService.getCAppInfo(couponChannel, EnumAppPlat.TOUTIAO); | |||
| // miniApp.addProperty("app_id",appInfo.getAppId()); | |||
| // object.add("entry_miniApp",miniApp); | |||
| // return object; | |||
| // } | |||
| // | |||
| // //获取SPU属性字段 | |||
| // private JsonObject getAttribute(WxCoupon coupon,WxCouponChannel couponChannel){ | |||
| //// JsonObject object = new JsonObject(); | |||
| // JsonObject productObjuct = new JsonObject(); | |||
| // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| // productObjuct.addProperty("groupon_valid_start",dateFormat.format(couponChannel.getShowBeginTime()));//团购售卖时间开始 | |||
| // // todo 要求必传, 可能为空 | |||
| // productObjuct.addProperty("groupon_valid_end",dateFormat.format(coupon.getValidEndDate()));//******* | |||
| // | |||
| // productObjuct.addProperty("order_limit",coupon.getUseLimitQuantity());//单个用户购买数量限制 | |||
| // if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(coupon.getValidType())){ | |||
| // productObjuct.addProperty("order_valid_start",dateFormat.format(coupon.getValidStartDate())); | |||
| // productObjuct.addProperty("order_valid_end",dateFormat.format(coupon.getValidEndDate())); | |||
| // }else if(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode().equals(coupon.getValidType())){ | |||
| // productObjuct.addProperty("post_purchase_day",coupon.getValidDays()); | |||
| // } | |||
| // //todo 商家客服电话 目前传的广场的客服电话 联系人广场名称 | |||
| // WxMall mall = wxMallMapper.getByTenantId(coupon.getTenantId()); | |||
| // JsonArray phoneArray = new JsonArray(); | |||
| // phoneArray.add(mall.getServicePhone()); | |||
| // productObjuct.add("service_phone",phoneArray); | |||
| // productObjuct.addProperty("contact_name",mall.getName()); | |||
| // | |||
| // //todo 团购须知 要求格式 标题加类容 是否二选一 待测试 | |||
| // JsonArray notificationArray = new JsonArray(); | |||
| //// for ( : ) { | |||
| // JsonObject contentObject = new JsonObject(); | |||
| // contentObject.addProperty("title","");//标题 | |||
| // contentObject.addProperty("content",coupon.getRemark());//内容 | |||
| // notificationArray.add(contentObject); | |||
| //// } | |||
| // productObjuct.add("notification",notificationArray); | |||
| // if(EnumCouponContentType.HTML.getCode().equals(coupon.getContentType())){ | |||
| // productObjuct.addProperty("notification_rich_text",coupon.getHtml()); | |||
| // } | |||
| // productObjuct.addProperty("sub_title",coupon.getSubTitle()); | |||
| // | |||
| // //todo 团购详情 要求必传, 待测试 | |||
| // if(StringUtils.isNotBlank(coupon.getItemGroup())){ | |||
| // JsonArray groupArray = new JsonParser().parse(coupon.getItemGroup()).getAsJsonArray(); | |||
| // productObjuct.add("pay_item_groups",groupArray); | |||
| // } | |||
| //// JsonArray groupArray = new JsonArray(); | |||
| //// for ( : ) { | |||
| //// JsonObject groupObject = new JsonObject(); | |||
| //// groupObject.addProperty("group_name","标题");//标题 | |||
| //// JsonArray itemArray = new JsonArray(); //菜品 | |||
| //// for (:) { | |||
| //// JsonObject itemObject = new JsonObject(); | |||
| //// itemObject.addProperty("name","菜名"); | |||
| //// itemObject.addProperty("count","数量"); | |||
| //// itemObject.addProperty("price","价格"); | |||
| //// itemArray.add(itemObject); | |||
| //// } | |||
| //// groupObject.add("item_list",itemArray); | |||
| //// groupArray.add(groupObject); | |||
| //// } | |||
| //// productObjuct.add("pay_item_groups",groupArray); | |||
| // | |||
| // //使用日期规则 | |||
| //// JsonObject dateRuleObject = new JsonObject(); | |||
| //// JsonObject unDateObject = new JsonObject();//不可用日期 | |||
| //// JsonArray dateArray = new JsonArray();//日期列表,格式yyyy-mm-dd,最多传100个 | |||
| //// JsonArray weekDayArray = new JsonArray();//星期列表,1-7代表周一到周天,[1,2]代表周一周二不可用 | |||
| //// unDateObject.add("date_list",dateArray); | |||
| //// unDateObject.add("weekday_list",weekDayArray); | |||
| //// dateRuleObject.add("unavailable_date",unDateObject); | |||
| //// productObjuct.add("date_rule",dateRuleObject); | |||
| // | |||
| // return productObjuct; | |||
| // } | |||
| // | |||
| // //商品亮点标签 | |||
| // private JsonArray getHighlights(WxCoupon coupon){ | |||
| // JsonArray array = new JsonArray(); | |||
| //// for (:) { | |||
| //// JsonObject object = new JsonObject(); | |||
| //// object.addProperty("content",);//介绍,字符串长度<=5 | |||
| //// object.addProperty("priority",);//优先级,数字越小优先级越高 | |||
| //// array.add(object); | |||
| //// } | |||
| // return array; | |||
| // } | |||
| //_________________________________________________________________________________ | |||
| // @Override | |||
| // public ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId) { | |||
| // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | |||
| // if(couponChannel == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); | |||
| // } | |||
| // if(StringUtils.isBlank(couponChannel.getTtSpuId())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); | |||
| // } | |||
| // TtSpuGet spuGet = new TtSpuGet(); | |||
| // spuGet.setSpuExtId(couponChannel.getId().toString()); | |||
| // spuGet.setNeedSpuDraft(true); | |||
| // spuGet.setSpuDraftcount(3); | |||
| // try { | |||
| // TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet); | |||
| // handSyncCouponChannelPoi(tenantInfo,spuGetResult); | |||
| // //处理一下数据 | |||
| // Map<String,Object> map = new HashMap<>(); | |||
| // if(spuGetResult.getSpuDetail() != null){//线上数据 | |||
| // TtSpuSync spuDetail = spuGetResult.getSpuDetail(); | |||
| // map.put("spuDetail",handSpuSync(spuDetail)); | |||
| // } | |||
| // if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据 | |||
| // TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0); | |||
| // map.put("spuDraft",handSpuSync(spuDraft)); | |||
| // } | |||
| // return new ResultData(map); | |||
| // } catch (WxErrorException e) { | |||
| // logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage()); | |||
| // return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| // } | |||
| // } | |||
| // | |||
| // private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){ | |||
| // Date now = new Date(); | |||
| // TtSpuSync spuDetail = spuGetResult.getSpuDetail(); | |||
| // if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId()) | |||
| // && spuDetail.getStatus() != null){ | |||
| // TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDetail.getSpuExtId())); | |||
| // if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){ | |||
| // TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); | |||
| // ccPoi.setId(ttCouponChannelPoi.getId()); | |||
| // ccPoi.setStatus(spuDetail.getStatus()); | |||
| // ccPoi.setStatusDesc(spuDetail.getStatusDesc()); | |||
| // ccPoi.setUpdateDate(now); | |||
| // ttCouponChannelPoiMapper.updateById(ccPoi); | |||
| // }else if(ttCouponChannelPoi == null){ | |||
| // ttCouponChannelPoi = new TtCouponChannelPoi(); | |||
| // ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId())); | |||
| // ttCouponChannelPoi.updateTenantInfo(tenantInfo); | |||
| // ttCouponChannelPoi.setSpuId(spuDetail.getSpuId()); | |||
| // ttCouponChannelPoi.setStatus(spuDetail.getStatus()); | |||
| // ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc()); | |||
| // ttCouponChannelPoi.setCreateDate(now); | |||
| // ttCouponChannelPoi.setUpdateDate(now); | |||
| // ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); | |||
| // } | |||
| // } | |||
| // List<TtSpuSync> spuDraftList = spuGetResult.getSpuDraft(); | |||
| // if(spuDraftList != null && spuDraftList.size() > 0){ | |||
| // TtSpuSync spuDraft = spuDraftList.get(0); | |||
| // if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId()) | |||
| // && spuDraft.getStatus() != null){ | |||
| // TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDraft.getSpuExtId())); | |||
| // if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){ | |||
| // TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); | |||
| // ccPoi.setId(ttCouponChannelPoi.getId()); | |||
| // ccPoi.setLastStatus(spuDraft.getStatus()); | |||
| // ccPoi.setLastStatusDesc(spuDraft.getStatusDesc()); | |||
| // ccPoi.setUpdateDate(now); | |||
| // ttCouponChannelPoiMapper.updateById(ccPoi); | |||
| // }else if(ttCouponChannelPoi == null){ | |||
| // ttCouponChannelPoi = new TtCouponChannelPoi(); | |||
| // ttCouponChannelPoi.setId(Long.parseLong(spuDraft.getSpuExtId())); | |||
| // ttCouponChannelPoi.updateTenantInfo(tenantInfo); | |||
| // ttCouponChannelPoi.setSpuId(spuDraft.getSpuId()); | |||
| // ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); | |||
| // ttCouponChannelPoi.setLastStatus(spuDraft.getStatus()); | |||
| // ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc()); | |||
| // ttCouponChannelPoi.setCreateDate(now); | |||
| // ttCouponChannelPoi.setUpdateDate(now); | |||
| // ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); | |||
| // } | |||
| // } | |||
| // } | |||
| // } | |||
| // | |||
| // private Map<String,Object> handSpuSync(TtSpuSync spuSync){ | |||
| // Map<String,Object> map = new HashMap<>(); | |||
| // map.put("id",spuSync.getSpuExtId()); | |||
| // map.put("spu_id",spuSync.getSpuId()); | |||
| // map.put("image_list",spuSync.getImageList()); | |||
| // map.put("name",spuSync.getName()); | |||
| // if(spuSync.getAttribute() != null){ | |||
| // JsonObject attribute = spuSync.getAttribute(); | |||
| // JsonArray pay_item_groups = attribute.getAsJsonArray("pay_item_groups"); | |||
| // map.put("pay_item_groups",pay_item_groups.toString()); | |||
| // JsonArray notification = attribute.getAsJsonArray("notification"); | |||
| // map.put("notification",notification.toString()); | |||
| // map.put("order_limit", GsonHelper.getString(attribute, "order_limit")); | |||
| // //售卖有效期 | |||
| // map.put("groupon_valid_start", GsonHelper.getString(attribute, "groupon_valid_start")); | |||
| // map.put("groupon_valid_end", GsonHelper.getString(attribute, "groupon_valid_end")); | |||
| // //卷有效期 | |||
| // map.put("order_valid_start", GsonHelper.getString(attribute, "order_valid_start")); | |||
| // map.put("order_valid_end", GsonHelper.getString(attribute, "order_valid_end")); | |||
| // | |||
| // } | |||
| // | |||
| // map.put("price",spuSync.getPrice()); | |||
| // map.put("origin_price",spuSync.getOriginPrice()); | |||
| // map.put("stock",spuSync.getStock()); | |||
| // map.put("status",spuSync.getStatus()); | |||
| // map.put("status_desc",spuSync.getStatusDesc()); | |||
| // return map; | |||
| // } | |||
| // @Override | |||
| // public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) { | |||
| // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | |||
| // if(couponChannel == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); | |||
| // } | |||
| // if(StringUtils.isBlank(couponChannel.getTtSpuId())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); | |||
| // } | |||
| // TtSpuStatusSync statusSync = new TtSpuStatusSync(); | |||
| // List<String> ids = new ArrayList<>(); | |||
| // ids.add(couponChannel.getId().toString()); | |||
| // statusSync.setSpuExtIdList(ids); | |||
| // if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ | |||
| // statusSync.setStatus(1); | |||
| // }else{ | |||
| // statusSync.setStatus(2); | |||
| // } | |||
| // try { | |||
| // TtSpuStatusSync statusSyncResult = getTtWebService(tenantInfo).getProductService().spuStatusSync(statusSync); | |||
| // if(statusSyncResult.getSpuExtIdList() != null && statusSyncResult.getSpuExtIdList().containsAll(ids)){ | |||
| // return new ResultData(); | |||
| // } | |||
| // } catch (WxErrorException e) { | |||
| // logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); | |||
| // throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| //// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| // } | |||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); | |||
| //// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); | |||
| // } | |||
| // @Override | |||
| // public ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId) { | |||
| // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | |||
| // if(couponChannel == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); | |||
| // } | |||
| // if(StringUtils.isBlank(couponChannel.getTtSpuId())){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); | |||
| // } | |||
| // WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); | |||
| // if(coupon == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到卷数据"); | |||
| // } | |||
| // TtSpuStockSync stockSync = new TtSpuStockSync(); | |||
| // stockSync.setSpuExtId(couponChannel.getId().toString()); | |||
| // stockSync.setStock(coupon.getRemainInventory()); | |||
| // try { | |||
| // boolean syncResult = getTtWebService(tenantInfo).getProductService().spuStockUpdate(stockSync); | |||
| // if(syncResult){ | |||
| // return new ResultData(); | |||
| // } | |||
| // } catch (WxErrorException e) { | |||
| // logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); | |||
| // throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| //// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); | |||
| // } | |||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); | |||
| //// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); | |||
| // } | |||
| @Override | |||
| public Map<String, TtMerchantPoi> queryPoiMerchantMap(TtMerchantPoi merchantPoiQ) { | |||
| List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(merchantPoiQ); | |||
| if (null != poiList) { | |||
| Map<String,TtMerchantPoi> poiMerchantIdMap = new HashMap<String,TtMerchantPoi>(); | |||
| for (int i = 0 ; i < poiList.size(); i++) { | |||
| TtMerchantPoi poi = poiList.get(i); | |||
| if (StringUtils.isNotBlank(poi.getPoiId())) { | |||
| TtMerchantPoi curm = poiMerchantIdMap.get(poi.getPoiId()); | |||
| if (null == curm) { | |||
| poiMerchantIdMap.put(poi.getPoiId(), poi); | |||
| }else { | |||
| TtMerchantPoi _poiT = new TtMerchantPoi(); | |||
| _poiT.setId(-1L); | |||
| _poiT.setMerchantName("多个商户已匹配该POI"); | |||
| poiMerchantIdMap.put(poi.getPoiId(), _poiT); | |||
| } | |||
| } | |||
| } | |||
| return poiMerchantIdMap; | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -156,6 +156,10 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @Autowired | |||
| WxMerchantRelationService wxMerchantRelationService; | |||
| @Lazy | |||
| @Autowired | |||
| private WxMallBuildingService wxMallBuildingService; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @@ -2087,6 +2091,33 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| } | |||
| return merchantMap; | |||
| } | |||
| @Override | |||
| public Map<String, WxMerchant> findMerchantMapByCreateFromId(WxMerchant merchantQ) { | |||
| List<WxMerchant> list = this.findList(merchantQ); | |||
| if(null != list){ | |||
| Map<String,WxMerchant> merchantMap = new HashMap<>(); | |||
| for (int i = 0 ; i < list.size(); i++ ){ | |||
| WxMerchant m = list.get(i); | |||
| if (StringUtils.isNotBlank(m.getCreateFromId())) { | |||
| WxMerchant cm = merchantMap.get(m.getCreateFromId()); | |||
| if (null != cm) { | |||
| WxMerchant _m = new WxMerchant(); | |||
| _m.setId(-1L); | |||
| _m.setName("该编码已创建了多个商户"); | |||
| merchantMap.put(m.getCreateFromId(), _m); | |||
| }else { | |||
| merchantMap.put(m.getCreateFromId(), m); | |||
| } | |||
| } | |||
| } | |||
| if (merchantMap.size() > 0 ){ | |||
| return merchantMap; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public WxMerchant findParkMerchant(WxPark wxPark) { | |||
| @@ -2139,4 +2170,103 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| merchant.setName(merchantName); | |||
| return wxMerchantMapper.findIdList(merchant); | |||
| } | |||
| } | |||
| private WxShop initShopByPoiId(TenantEntity tenantEntity,String poiId) throws Exception { | |||
| String shopNumber = "DYPOI-"+poiId; | |||
| WxShop shop = wxShopService.getShopByShopNumber(tenantEntity, shopNumber); | |||
| if (null == shop) { | |||
| Long buildingId = null; | |||
| Long floorId = null; | |||
| try { | |||
| ResultData builds = wxMallBuildingService.getBuildingFloorList(tenantEntity); | |||
| if (null == builds || null == builds.data) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层楼座未查询到."); | |||
| } | |||
| List<WxMallBuilding> wxMallBuildings = (List<WxMallBuilding>) builds.data; | |||
| if (null == wxMallBuildings || wxMallBuildings.size() <= 0 ){ | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层楼座未查询到."); | |||
| } | |||
| WxMallBuilding building = wxMallBuildings.get(0); | |||
| buildingId = building.getId() ; | |||
| List<WxMallFloor> floors = building.getFloors(); | |||
| if (null == floors || floors.size() <= 0 ){ | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼座"+building.getBuildingName()+"没有楼层"); | |||
| } | |||
| floorId = floors.get(0).getId(); | |||
| } catch(Exception e) { | |||
| logger.error("initMerchantByPoi error.",e); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层楼座查询错误."+e.getMessage()); | |||
| } | |||
| shop = new WxShop(); | |||
| shop.updateTenantInfo(tenantEntity); | |||
| shop.setBuildArea("0"); | |||
| shop.setShopNumber(shopNumber); | |||
| shop.setBuilding(buildingId); | |||
| shop.setFloor(floorId); | |||
| shop.setOperationArea("0"); | |||
| shop.setBusinessId(0); | |||
| shop.setRentUnit(2); | |||
| wxShopService.saveOrUpdate(shop); | |||
| } | |||
| return shop; | |||
| } | |||
| private WxMerchant initMerchantByPoiId(WxShop shop,MallUserInfo user,String poiName, String poiId,String phone) { | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(user); | |||
| merchantQ.setCreateFrom(EnumMerchantCreateFrom.DOUYIN_LAIKE.getCode()); | |||
| merchantQ.setCreateFromId(poiId); | |||
| Map<String,WxMerchant> poiCreateMerchant = this.findMerchantMapByCreateFromId(merchantQ); | |||
| WxMerchant merchant = null; | |||
| if (null != poiCreateMerchant) { | |||
| merchant = poiCreateMerchant.get(poiId); | |||
| } | |||
| if (null == merchant) { | |||
| merchant = new WxMerchant(); | |||
| merchant.setIsAdmin(EnumMerchantAdmin.PUBLIC_COMMON.getCode()); | |||
| merchant.setCarVendorType(0); | |||
| merchant.setImgUrl("https://formall.oss-accelerate.aliyuncs.com/234/WechatIMG5071.png"); | |||
| merchant.setName(poiName); | |||
| if (StringUtils.isBlank(phone)) { | |||
| merchant.setLinkPhone("11111111111"); | |||
| }else { | |||
| merchant.setLinkPhone(phone); | |||
| } | |||
| merchant.setLinkPerson("default"); | |||
| List<Long> shopIds = new ArrayList<Long>(); | |||
| shopIds.add(shop.getId()); | |||
| merchant.setShopids(shopIds); | |||
| merchant.setBusinessId(shop.getBusinessId()); | |||
| merchant.setType(1); | |||
| merchant.setCreateFrom(EnumMerchantCreateFrom.DOUYIN_LAIKE.getCode()); | |||
| merchant.setCreateFromId(poiId); | |||
| this.addMerchant(merchant, user.getId()); | |||
| } | |||
| return merchant; | |||
| } | |||
| @Override | |||
| public WxMerchant initMerchantByPoi(MallUserInfo user,String poiName, String poiId,String phone) throws Exception{ | |||
| WxShop shop = initShopByPoiId(user,poiId); | |||
| if (null == shop) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"商铺信息初始化失败"); | |||
| } | |||
| WxMerchant merchant = initMerchantByPoiId(shop, user, poiName, poiId, phone); | |||
| if (null == merchant) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"商户信息初始化失败"); | |||
| } | |||
| //加管理员 | |||
| if (StringUtils.isNotBlank(phone)) { | |||
| List<WxMerchantBUser> users = new ArrayList<WxMerchantBUser>(); | |||
| WxMerchantBUser buser = new WxMerchantBUser(); | |||
| buser.setName("管理员"); | |||
| buser.setPhone(phone); | |||
| buser.setUserPwd("123456Abc"); | |||
| buser.setIsAdmin(merchant.getIsAdmin()); | |||
| users.add(buser); | |||
| merchant.setUsers(users); | |||
| this.updateMerchantAdmin(merchant) ; | |||
| } | |||
| return merchant; | |||
| } | |||
| } | |||
| @@ -709,4 +709,16 @@ public class WxShopServiceImpl implements WxShopService { | |||
| Map<Long,List<WxShopVo>> map = findMerchantShopVoListMap(tenantEntity, merchantIds); | |||
| return map.get(merchantId); | |||
| } | |||
| @Override | |||
| public WxShop getShopByShopNumber(TenantEntity tenantEntity,String shopNumber) { | |||
| WxShop shopQ = new WxShop(); | |||
| shopQ.updateTenantInfo(tenantEntity); | |||
| shopQ.setShopNumber(shopNumber); | |||
| List<WxShop> shopList = wxShopMapper.findList(shopQ); | |||
| if (null != shopList && shopList.size() > 0 ) { | |||
| return shopList.get(0); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.service.park.impl.ketuo; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @@ -65,20 +66,7 @@ public class KeTuoParkService extends BaseParkService implements ParkAdapterServ | |||
| KeTuoUtil ketuo = new KeTuoUtil(); | |||
| /** | |||
| * 先去捷顺注册,调用登陆获取令牌,然后根据令牌调用别的接口 | |||
| * http://ap.jieshun.cn:9088/apply/ 注册信息地址 fumao/iformall2020 | |||
| * | |||
| * 捷顺商户平台:http://merchant.jslife.com.cn/merchant/index.html#/auth/login | |||
| * 捷顺门店平台:http://merchant.jslife.com.cn/store/index.html#/auth/login | |||
| * 门店商户号 000000008032172000003 密码 ycHqp61Acudxz | |||
| * | |||
| * | |||
| * API对接注意事项: | |||
| 1、token有效期两个小时,每两小时内登录一次获取token,调业务接口不需要频繁登录用,建议获取一次token存本地缓存,之后从本地获取,两小时内刷新一次, | |||
| 为避免调业务接口时刚好token被刷新,导致token失效(无效的令牌或令牌已过期),可以做下容错,重新登录获取token或用最新token重新调业务接口。 | |||
| 2、token是和ip是一对一绑定,新的ip服务器调捷顺的接口会出现ip不合法,需把ip提供捷顺方,添加白名单。多个服务调捷顺接口共用一个ip情况下,只能共用一套登录获取token机制,各自登录会冲突。 | |||
| 3、所有接口要带车牌的一律带横杠。格式如:粤-B12345。 | |||
| 4、无效的数据签名是指sn加密方式不对。sn加密方式是对p+signkey进行Md5加密,加密后的字符串大写。 | |||
| * 科拓 停车场云助手App. 开通电子抵扣券 | |||
| */ | |||
| @Override | |||
| @@ -122,7 +110,8 @@ public class KeTuoParkService extends BaseParkService implements ParkAdapterServ | |||
| if (null == retObject ) { | |||
| throw new MallinkException(retObj.getInteger("resCode"), "ketuo getCarStopFee error. no order result"+carNumber); | |||
| } | |||
| Double totalFee = retObject.getDouble("payable"); | |||
| Double totalFee = retObject.getDouble("payable");//分 | |||
| String _fee = String.valueOf(new BigDecimal(totalFee).divide(new BigDecimal(100)).doubleValue()); | |||
| String appId = "wx54e676273869baa6"; | |||
| String parkOrderId = retObject.getString("orderNo"); | |||
| Integer freeMinute = (Integer)park.getVendorParamsByKey("freeMinute"); | |||
| @@ -130,7 +119,7 @@ public class KeTuoParkService extends BaseParkService implements ParkAdapterServ | |||
| String endTime = retObject.getString("payTime");//离场时间,格式为“yyyy-MM-dd HH:mi:ss” | |||
| String payPath = "pages/index/index?lotId="+Integer.parseInt(park.getParkingId())+"&lpn="+carNumber; | |||
| return new ParkStopFee(parkOrderId,ketuo.utcToLocal(createTime),ketuo.utcToLocal(endTime), | |||
| String.valueOf(totalFee),appId,payPath,null,null,"请支付后"+freeMinute+"分钟内离场"); | |||
| _fee,appId,payPath,null,null,"请支付后"+freeMinute+"分钟内离场"); | |||
| }else { | |||
| logger.error("ketuoCarStopFee error. paramMap: {} . ketuoResult: {}",JSON.toJSONString(paramMap),ret); | |||
| String msg = retObj.getString("resMsg"); | |||
| @@ -167,7 +156,8 @@ public class KeTuoParkService extends BaseParkService implements ParkAdapterServ | |||
| boolean isReduceMoney = this.isReduceMoney(coupon); | |||
| Integer reduceValue = this.getReduceValue(coupon); | |||
| String executeRet = ketuo.executediscount(park, fee.getOrderId(), planNo, Integer.parseInt(fee.getRemainingFee()),isReduceMoney, reduceValue); | |||
| Integer parkFee = new BigDecimal(fee.getRemainingFee()).multiply(new BigDecimal(100)).intValue(); | |||
| String executeRet = ketuo.executediscount(park, fee.getOrderId(), planNo, parkFee,isReduceMoney, reduceValue); | |||
| logger.info("ketuo executediscount result:"+executeRet); | |||
| JSONObject executeRetObj = JSON.parseObject(executeRet); | |||
| if (executeRetObj.getIntValue("resCode") == 0){ | |||
| @@ -74,7 +74,9 @@ public class KeTuoUtil { | |||
| param.put("payMethod", 1010);//付款方式 | |||
| if (isDiscountMoney) { | |||
| param.put("freeMoney", discountValue);//减免总金额(单位 分) | |||
| param.put("freeTime", 0); | |||
| }else { | |||
| param.put("freeMoney", 0); | |||
| param.put("freeTime", discountValue*3600);//减免总时长(单位 秒) | |||
| } | |||
| param.put("isCarLeave", 0);//车辆是否离场 | |||
| @@ -94,6 +94,8 @@ public class Constant { | |||
| // 导入POI | |||
| public static final String importPoiPrev = "importpoi:"; | |||
| public static final String importPoiMerchantPrev = "importpoimerchant:"; | |||
| //商品门店 | |||
| public static final String coupon_merchants_key = "coupon:merchants:"; | |||
| @@ -140,7 +140,7 @@ | |||
| from tt_merchant_poi | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <update id="deleteByUpdate" parameterType="Long"> | |||
| update tt_merchant_poi set is_del = 1 | |||
| where id = #{id} | |||
| @@ -48,12 +48,16 @@ | |||
| <result column="cash_out_number" jdbcType="INTEGER" property="cashOutNumber"/> | |||
| <result column="cash_out_count" jdbcType="INTEGER" property="cashOutCount"/> | |||
| <result column="cash_out_last_time" jdbcType="TIMESTAMP" property="cashOutLastTime"/> | |||
| <result column="create_from" jdbcType="INTEGER" property="createFrom"/> | |||
| <result column="create_from_id" jdbcType="VARCHAR" property="createFromId"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| m.`id`,m.`tenant_id`,m.`parent_tenant_id`,m.`img_url`,m.`name`,m.`encode`,m.`link_phone`,m.`create_date`,m.`update_date`,m.`car_vendor_type`,m.`car_params`,m.`status`,m.`link_person`, | |||
| m.`business_id`,m.`business_types`,m.`sub_business_id`,m.`shop_type`,m.`brand`,m.`type`,m.`is_public`,m.`is_private`,m.email,m.`title`,m.`cover_picture`,m.`is_admin`,m.`bill_setting`,m.`qr_code`,m.`tt_qr_code`, | |||
| m.`introduction`,m.`action_desc`,m.`mark`,m.mark_time,m.`is_del`,m.`talk_user_main`,m.`talk_user_aux`,m.link_line_phone,m.search_card_by_phone,m.credit_locked,m.credit_locked,m.entry_amount,m.cash_out_count,m.cash_out_last_time | |||
| m.`introduction`,m.`action_desc`,m.`mark`,m.mark_time,m.`is_del`,m.`talk_user_main`,m.`talk_user_aux`,m.link_line_phone,m.search_card_by_phone,m.credit_locked,m.credit_locked,m.entry_amount,m.cash_out_count, | |||
| m.cash_out_last_time,m.create_from,m.create_from_id | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -168,6 +172,15 @@ | |||
| <if test=" null != creditLocked "> | |||
| and m.`credit_locked` = #{creditLocked} | |||
| </if> | |||
| <if test=" null != createFrom "> | |||
| and m.`create_from` = #{createFrom} | |||
| </if> | |||
| <if test=" null != createFromId and '' != createFromId"> | |||
| and m.`create_from_id` = #{createFromId} | |||
| </if> | |||
| <if test=" null != adminTypes and adminTypes.size > 0"> | |||
| and m.`is_admin` in | |||
| <foreach collection="adminTypes" index="index" item="typeItem" open="(" separator="," close=")"> | |||