From 5b9a853a768f5a7337a7fcd9eac2a17923c75c4e Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Tue, 25 Apr 2023 10:41:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9F=A5=E8=AF=A2=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E5=92=8C=E7=A7=AF=E5=88=86=E8=BF=94=E5=88=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/CommonController.java | 49 ++++++- .../com/cweb/controller/TestController.java | 33 +++++ .../config/controller/CommonController.java | 60 ++++++++ .../java/com/hfkj/dao/BsStoreMapperExt.java | 20 +++ .../java/com/hfkj/model/OpenStoreModel.java | 134 ++++++++++++++++++ .../java/com/hfkj/service/BsStoreService.java | 11 ++ .../java/com/hfkj/service/CommonService.java | 10 ++ .../hfkj/service/impl/BsStoreServiceImpl.java | 20 ++- .../hfkj/service/impl/CommonServiceImpl.java | 12 ++ 9 files changed, 341 insertions(+), 8 deletions(-) create mode 100644 open-api/src/main/java/com/api/config/controller/CommonController.java create mode 100644 service/src/main/java/com/hfkj/model/OpenStoreModel.java diff --git a/cweb/src/main/java/com/cweb/controller/CommonController.java b/cweb/src/main/java/com/cweb/controller/CommonController.java index a3c67d7..3fc12e7 100644 --- a/cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/cweb/src/main/java/com/cweb/controller/CommonController.java @@ -1,5 +1,6 @@ package com.cweb.controller; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hfkj.channel.lakala.config.LaKaLaConfig; @@ -10,11 +11,10 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsCompany; import com.hfkj.entity.SecRegion; +import com.hfkj.model.OpenStoreModel; import com.hfkj.model.ResponseData; -import com.hfkj.service.BsCompanyService; -import com.hfkj.service.BsIndustryService; -import com.hfkj.service.BsLklMccService; -import com.hfkj.service.CommonService; +import com.hfkj.model.StoreModel; +import com.hfkj.service.*; import com.hfkj.service.impl.BsLklMccServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -52,6 +52,9 @@ public class CommonController { @Resource private SaasCommon saasCommon; + @Resource + private BsStoreService storeService; + @RequestMapping(value="/getDredgeProvince",method= RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询已开通的省份") @@ -265,4 +268,42 @@ public class CommonController { } } + + + @RequestMapping(value="/getStoreList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "商户查询门店列表") + public ResponseData getStoreListByMer( + @RequestParam(value = "name" , required = false) String name, + @RequestParam(value = "childId" , required = false) Long childId + ) { + try { + + List list = storeService.getStoreList(name , childId); + + for (OpenStoreModel storeModel : list ) { + Map map = new HashMap<>(); + String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, ·、?]"; + map.put("address" , storeModel.getBlisRegAddress().replaceAll(regEx,"")); + map.put("location" , "showLocation"); + JSONObject object = commonService.getMapDetail(map); + + if (object.getInteger("status") == 0) { + JSONObject jsonObject = object.getJSONObject("result").getJSONObject("location"); + storeModel.setLatitude(jsonObject.getString("lat")); + storeModel.setLongitude(jsonObject.getString("lng")); + } + + } + + return ResponseMsgUtil.success(list); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + + } diff --git a/cweb/src/main/java/com/cweb/controller/TestController.java b/cweb/src/main/java/com/cweb/controller/TestController.java index b55f7d8..862bb1d 100644 --- a/cweb/src/main/java/com/cweb/controller/TestController.java +++ b/cweb/src/main/java/com/cweb/controller/TestController.java @@ -16,7 +16,10 @@ import com.hfkj.channel.saas.utils.SaasCommon; import com.hfkj.channel.saas.saasenum.FileImgType; import com.hfkj.channel.saas.utils.SaasMerRequest; import com.hfkj.channel.weixin.WeiXinMerService; +import com.hfkj.channel.weixin.utils.WxUtils; +import com.hfkj.channel.weixin.utils.sdk.WXPayConstants; import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.device.SoundService; import com.hfkj.config.mqtt.MqttProviderService; @@ -28,6 +31,7 @@ import com.hfkj.service.CommonService; import com.hfkj.service.SecRegionService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +40,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.File; +import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -295,4 +300,32 @@ public class TestController { } } + @RequestMapping(value = "/rebate", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "返利") + public ResponseData rebate(@RequestParam(name = "orderNo", required = true) String orderNo, + @RequestParam(name = "orderId", required = true) Long orderId, + @RequestParam(name = "price", required = true) BigDecimal price) { + try { + + Map mapPost = new HashMap<>(); + mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); + mapPost.put("merchId" , "20230258302"); + mapPost.put("productType" , 102); + mapPost.put("orderNo" , orderNo); + mapPost.put("userId" , 366); + mapPost.put("orderId" , orderId); + mapPost.put("price" , price); + mapPost.put("title" , "南充大饭店"); + mapPost.put("createTime" , new Date()); + + + mapPost.put("sign" , WxUtils.generateSignApi(mapPost, MapUtils.getString(mapPost, "apiKey"), WXPayConstants.SignType.MD5)); + return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/orderRebate/rebate" , mapPost , new HashMap<>())); + } catch (Exception e) { + log.error("HighOrderController --> getBackendToken() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/open-api/src/main/java/com/api/config/controller/CommonController.java b/open-api/src/main/java/com/api/config/controller/CommonController.java new file mode 100644 index 0000000..4fe917a --- /dev/null +++ b/open-api/src/main/java/com/api/config/controller/CommonController.java @@ -0,0 +1,60 @@ +package com.api.config.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.channel.lakala.config.LaKaLaConfig; +import com.hfkj.channel.saas.utils.SaasCommon; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsCompany; +import com.hfkj.entity.SecRegion; +import com.hfkj.model.ResponseData; +import com.hfkj.model.StoreModel; +import com.hfkj.service.BsCompanyService; +import com.hfkj.service.BsIndustryService; +import com.hfkj.service.BsLklMccService; +import com.hfkj.service.CommonService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@RestController +@RequestMapping(value="/common") +@Api(value="共用接口") +public class CommonController { + + Logger log = LoggerFactory.getLogger(CommonController.class); + + @Resource + private BsIndustryService industryService; + + + @RequestMapping(value="/getIndustry",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取行业数据") + public ResponseData getIndustry() { + try { + + return ResponseMsgUtil.success(industryService.getCacheIndustry()); + + } catch (Exception e) { + log.error("CommonController --> getIndustry() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + +} diff --git a/service/src/main/java/com/hfkj/dao/BsStoreMapperExt.java b/service/src/main/java/com/hfkj/dao/BsStoreMapperExt.java index dff0097..11768d8 100644 --- a/service/src/main/java/com/hfkj/dao/BsStoreMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsStoreMapperExt.java @@ -1,8 +1,10 @@ package com.hfkj.dao; +import com.hfkj.model.OpenStoreModel; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import java.util.List; import java.util.Map; /** @@ -22,4 +24,22 @@ public interface BsStoreMapperExt { " and `status` in (${param.status}) " + " ") Map countStoreTrade(@Param("param") Map param); + + @Select(" ") + List getStoreList(@Param("param") Map param); } diff --git a/service/src/main/java/com/hfkj/model/OpenStoreModel.java b/service/src/main/java/com/hfkj/model/OpenStoreModel.java new file mode 100644 index 0000000..f184b6e --- /dev/null +++ b/service/src/main/java/com/hfkj/model/OpenStoreModel.java @@ -0,0 +1,134 @@ +package com.hfkj.model; + +import javax.xml.crypto.Data; + +/** + * 对外的门店信息内容 + * @author sum1dream + */ +public class OpenStoreModel { + + // 门店地址 + private String blisRegAddress; + + // 门头照 + private String doorHeadImg; + + // 门店名称 + private String storeName; + + // 父类行业分类id + private Long parentId; + + // 子类行业分类id + private Long childId; + + // 父类行业分类名称 + private String parentName; + + // 子类行业分类名称 + private String childName; + + // 门店状态 0:删除 1:正常 2:停用 3:审核中 4:审核失败 + private Integer storeStatus; + + + // 唯独 + private String latitude; + + // 经度 + private String longitude; + + // 创建时间 + private Data storeCreateTime; + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + + + public String getBlisRegAddress() { + return blisRegAddress; + } + + public void setBlisRegAddress(String blisRegAddress) { + this.blisRegAddress = blisRegAddress; + } + + public String getDoorHeadImg() { + return doorHeadImg; + } + + public void setDoorHeadImg(String doorHeadImg) { + this.doorHeadImg = doorHeadImg; + } + + public String getStoreName() { + return storeName; + } + + public void setStoreName(String storeName) { + this.storeName = storeName; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Long getChildId() { + return childId; + } + + public void setChildId(Long childId) { + this.childId = childId; + } + + public String getParentName() { + return parentName; + } + + public void setParentName(String parentName) { + this.parentName = parentName; + } + + public String getChildName() { + return childName; + } + + public void setChildName(String childName) { + this.childName = childName; + } + + public Integer getStoreStatus() { + return storeStatus; + } + + public void setStoreStatus(Integer storeStatus) { + this.storeStatus = storeStatus; + } + + public Data getStoreCreateTime() { + return storeCreateTime; + } + + public void setStoreCreateTime(Data storeCreateTime) { + this.storeCreateTime = storeCreateTime; + } +} diff --git a/service/src/main/java/com/hfkj/service/BsStoreService.java b/service/src/main/java/com/hfkj/service/BsStoreService.java index f78abcc..7efc41c 100644 --- a/service/src/main/java/com/hfkj/service/BsStoreService.java +++ b/service/src/main/java/com/hfkj/service/BsStoreService.java @@ -2,6 +2,7 @@ package com.hfkj.service; import com.hfkj.entity.BsStore; import com.hfkj.model.MerBasisModel; +import com.hfkj.model.OpenStoreModel; import com.hfkj.model.StoreModel; import com.hfkj.sysenum.StoreCreateTypeEnum; @@ -62,6 +63,16 @@ public interface BsStoreService { */ List getStoreList(Map param); + /** + * @Author Sum1Dream + * @Name getStoreList + * @Description // 根据名称查询对外门店列表 + * @Date 17:21 2023/4/23 + * @Param [name] + * @Return java.util.List + */ + List getStoreList(String name , Long childId); + /** * 统计门店交易 * @param param diff --git a/service/src/main/java/com/hfkj/service/CommonService.java b/service/src/main/java/com/hfkj/service/CommonService.java index 4d23706..38c1205 100644 --- a/service/src/main/java/com/hfkj/service/CommonService.java +++ b/service/src/main/java/com/hfkj/service/CommonService.java @@ -190,5 +190,15 @@ public interface CommonService { void updateDictionary(SecDictionary secDictionary); + /** + * @Author Sum1Dream + * @Name getMapDetail + * @Description // 获取地图详细信息 + * @Date 17:27 2023/4/23 + * @Param [address] + * @Return com.alibaba.fastjson.JSONObject + */ + JSONObject getMapDetail(Map map); + } diff --git a/service/src/main/java/com/hfkj/service/impl/BsStoreServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsStoreServiceImpl.java index 4fef841..b03ce5a 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsStoreServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsStoreServiceImpl.java @@ -8,6 +8,7 @@ import com.hfkj.common.utils.IDGenerator; import com.hfkj.dao.BsStoreMapper; import com.hfkj.entity.*; import com.hfkj.model.MerBasisModel; +import com.hfkj.model.OpenStoreModel; import com.hfkj.model.StoreModel; import com.hfkj.service.*; import com.hfkj.sysenum.SecUserRoleIdEnum; @@ -21,10 +22,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @Service("storeService") public class BsStoreServiceImpl implements BsStoreService { @@ -226,6 +224,20 @@ public class BsStoreServiceImpl implements BsStoreService { return storeModels; } + @Override + public List getStoreList(String name , Long childId) { + + Map map = new HashMap<>(); + if (name != null) { + map.put("name" , name); + } + if (childId != null) { + map.put("childId" , childId); + } + + return storeMapper.getStoreList(map); + } + @Override public Map countStoreTrade(Map param) { return storeMapper.countStoreTrade(param); diff --git a/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java index 3805939..d515ddf 100644 --- a/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java @@ -11,6 +11,7 @@ import com.alicp.jetcache.embedded.LinkedHashMapCacheBuilder; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.RedisUtil; import com.hfkj.dao.SecDictionaryMapper; import com.hfkj.dao.SecRegionMapper; @@ -471,5 +472,16 @@ public class CommonServiceImpl implements CommonService { dicMapper.updateByPrimaryKeySelective(secDictionary); } + @Override + public JSONObject getMapDetail(Map map) { + + //申请百度开放平台KEY(ak) + map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR"); + // 输出Json数据 + map.put("output", "json"); + + + return HttpsUtils.doGet("http://api.map.baidu.com/geocoding/v3/" , map); + } }