| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>MicroCommunity</artifactId> |
| | | <groupId>com.java110</groupId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ShopService</artifactId> |
| | | |
| | | <name>ShopService</name> |
| | | <!-- FIXME change it to the project's website --> |
| | | <url>http://www.example.com</url> |
| | | |
| | | <properties> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <maven.compiler.source>1.7</maven.compiler.source> |
| | | <maven.compiler.target>1.7</maven.compiler.target> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.java110</groupId> |
| | | <artifactId>java110-service</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.java110</groupId> |
| | | <artifactId>java110-event</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <finalName>ShopService</finalName> |
| | | <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-dependency-plugin</artifactId> |
| | | <version>2.10</version> |
| | | <executions> |
| | | <execution> |
| | | <id>unpack</id> |
| | | <phase>generate-resources</phase> |
| | | <goals> |
| | | <goal>unpack</goal> |
| | | </goals> |
| | | <configuration> |
| | | <artifactItems> |
| | | <artifactItem> |
| | | <groupId>com.java110</groupId> |
| | | <artifactId>java110-config</artifactId> |
| | | <version>${microcommunity.version}</version> |
| | | <type>jar</type> |
| | | <overWrite>true</overWrite> |
| | | <outputDirectory>${project.build.directory}/classes</outputDirectory> |
| | | </artifactItem> |
| | | </artifactItems> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <mainClass>com.java110.store.ShopServiceApplicationStart</mainClass> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </pluginManagement> |
| | | </build> |
| | | </project> |
| New file |
| | |
| | | package com.java110.shop; |
| | | |
| | | import com.java110.core.annotation.Java110ListenerDiscovery; |
| | | import com.java110.event.service.BusinessServiceDataFlowEventPublishing; |
| | | import com.java110.service.init.ServiceStartInit; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.web.client.RestTemplateBuilder; |
| | | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
| | | import org.springframework.cloud.client.loadbalancer.LoadBalanced; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.nio.charset.Charset; |
| | | |
| | | |
| | | /** |
| | | * spring boot 初始化启动类 |
| | | * |
| | | * @version v0.1 |
| | | * @auther com.java110.wuxw |
| | | * @mail 928255095@qq.com |
| | | * @date 2016年8月6日 |
| | | * @tag |
| | | */ |
| | | @SpringBootApplication(scanBasePackages={"com.java110.service","com.java110.store","com.java110.core","com.java110.cache"}) |
| | | @EnableDiscoveryClient |
| | | @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class, |
| | | basePackages = {"com.java110.store.listener"}) |
| | | public class ShopServiceApplicationStart { |
| | | |
| | | private final static String LISTENER_PATH = "java110.StoreService.listeners"; |
| | | |
| | | /** |
| | | * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力. |
| | | * @return restTemplate |
| | | */ |
| | | @Bean |
| | | @LoadBalanced |
| | | public RestTemplate restTemplate() { |
| | | StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8")); |
| | | RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(); |
| | | return restTemplate; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception{ |
| | | ApplicationContext context = SpringApplication.run(ShopServiceApplicationStart.class, args); |
| | | ServiceStartInit.initSystemConfig(context); |
| | | //加载业务侦听 |
| | | //SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.api; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.InitConfigDataException; |
| | | import com.java110.common.exception.InitDataFlowContextException; |
| | | import com.java110.core.base.controller.BaseController; |
| | | import com.java110.core.context.BusinessServiceDataFlow; |
| | | import com.java110.core.factory.DataTransactionFactory; |
| | | import com.java110.shop.smo.IShopServiceSMO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 用户服务类 |
| | | * Created by wuxw on 2018/5/14. |
| | | */ |
| | | @RestController |
| | | public class ShopApi extends BaseController { |
| | | |
| | | @Autowired |
| | | IShopServiceSMO shopServiceSMOImpl; |
| | | |
| | | @RequestMapping(path = "/storeApi/service",method= RequestMethod.GET) |
| | | public String serviceGet(HttpServletRequest request) { |
| | | return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,"不支持Get方法请求").toJSONString(); |
| | | } |
| | | |
| | | /** |
| | | * 用户服务统一处理接口 |
| | | * @param orderInfo |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(path = "/storeApi/service",method= RequestMethod.POST) |
| | | public String servicePost(@RequestBody String orderInfo, HttpServletRequest request) { |
| | | BusinessServiceDataFlow businessServiceDataFlow = null; |
| | | JSONObject responseJson = null; |
| | | try { |
| | | Map<String, String> headers = new HashMap<String, String>(); |
| | | getRequestInfo(request, headers); |
| | | //预校验 |
| | | preValiateOrderInfo(orderInfo); |
| | | businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers); |
| | | responseJson = shopServiceSMOImpl.service(businessServiceDataFlow); |
| | | }catch (InitDataFlowContextException e){ |
| | | logger.error("请求报文错误,初始化 BusinessServiceDataFlow失败"+orderInfo,e); |
| | | responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null); |
| | | }catch (InitConfigDataException e){ |
| | | logger.error("请求报文错误,加载配置信息失败"+orderInfo,e); |
| | | responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null); |
| | | }catch (Exception e){ |
| | | logger.error("请求订单异常",e); |
| | | responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow,ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e, |
| | | null); |
| | | }finally { |
| | | return responseJson.toJSONString(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 这里预校验,请求报文中不能有 dataFlowId |
| | | * @param orderInfo |
| | | */ |
| | | private void preValiateOrderInfo(String orderInfo) { |
| | | /* if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){ |
| | | throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"报文中不能存在dataFlowId节点"); |
| | | }*/ |
| | | } |
| | | |
| | | /** |
| | | * 获取请求信息 |
| | | * @param request |
| | | * @param headers |
| | | * @throws RuntimeException |
| | | */ |
| | | private void getRequestInfo(HttpServletRequest request,Map headers) throws Exception{ |
| | | try{ |
| | | super.initHeadParam(request,headers); |
| | | super.initUrlParam(request,headers); |
| | | }catch (Exception e){ |
| | | logger.error("加载头信息失败",e); |
| | | throw new InitConfigDataException(ResponseConstant.RESULT_PARAM_ERROR,"加载头信息失败"); |
| | | } |
| | | } |
| | | |
| | | public IShopServiceSMO getShopServiceSMOImpl() { |
| | | return shopServiceSMOImpl; |
| | | } |
| | | |
| | | public void setShopServiceSMOImpl(IShopServiceSMO shopServiceSMOImpl) { |
| | | this.shopServiceSMOImpl = shopServiceSMOImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.dao; |
| | | |
| | | |
| | | import com.java110.common.exception.DAOException; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 商户组件内部之间使用,没有给外围系统提供服务能力 |
| | | * 商户服务接口类,要求全部以字符串传输,方便微服务化 |
| | | * 新建客户,修改客户,删除客户,查询客户等功能 |
| | | * |
| | | * Created by wuxw on 2016/12/27. |
| | | */ |
| | | public interface IShopServiceDao { |
| | | |
| | | /** |
| | | * 保存 商户信息 |
| | | * @param businessStoreInfo 商户信息 封装 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | public void saveBusinessStoreInfo(Map businessStoreInfo) throws DAOException; |
| | | |
| | | /** |
| | | * 保存商户属性 |
| | | * @param businessStoreAttr 商户属性信息封装 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | public void saveBusinessStoreAttr(Map businessStoreAttr) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 保存商户照片信息 |
| | | * @param businessStorePhoto 商户照片 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | public void saveBusinessStorePhoto(Map businessStorePhoto) throws DAOException; |
| | | |
| | | /** |
| | | * 保存商户证件信息 |
| | | * @param businessStoreCerdentials 商户证件 |
| | | * @throws DAOException 操作数据库异常 |
| | | */ |
| | | public void saveBusinessStoreCerdentials(Map businessStoreCerdentials) throws DAOException; |
| | | |
| | | /** |
| | | * 查询商户信息(business过程) |
| | | * 根据bId 查询商户信息 |
| | | * @param info bId 信息 |
| | | * @return 商户信息 |
| | | * @throws DAOException |
| | | */ |
| | | public Map getBusinessStoreInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询商户属性信息(business过程) |
| | | * @param info bId 信息 |
| | | * @return 商户属性 |
| | | * @throws DAOException |
| | | */ |
| | | public List<Map> getBusinessStoreAttrs(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询商户照片 |
| | | * @param info bId 信息 |
| | | * @return 商户照片 |
| | | * @throws DAOException |
| | | */ |
| | | public List<Map> getBusinessStorePhoto(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询商户证件信息 |
| | | * @param info bId 信息 |
| | | * @return 商户照片 |
| | | * @throws DAOException |
| | | */ |
| | | public List<Map> getBusinessStoreCerdentials(Map info) throws DAOException; |
| | | |
| | | /** |
| | | * 保存 商户信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException |
| | | */ |
| | | public void saveStoreInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 保存 商户属性信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException |
| | | */ |
| | | public void saveStoreAttrsInstance(Map info) throws DAOException; |
| | | |
| | | /** |
| | | * 保存 商户照片信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException |
| | | */ |
| | | public void saveStorePhotoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 保存 商户证件信息 Business数据到 Instance中 |
| | | * @param info |
| | | * @throws DAOException |
| | | */ |
| | | public void saveStoreCerdentialsInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询商户信息(instance过程) |
| | | * 根据bId 查询商户信息 |
| | | * @param info bId 信息 |
| | | * @return 商户信息 |
| | | * @throws DAOException |
| | | */ |
| | | public Map getStoreInfo(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询商户属性信息(instance过程) |
| | | * @param info bId 信息 |
| | | * @return 商户属性 |
| | | * @throws DAOException |
| | | */ |
| | | public List<Map> getStoreAttrs(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 查询商户照片(instance 过程) |
| | | * @param info bId 信息 |
| | | * @return 商户照片 |
| | | * @throws DAOException |
| | | */ |
| | | public List<Map> getStorePhoto(Map info) throws DAOException; |
| | | |
| | | /** |
| | | * 查询商户证件信息(instance 过程) |
| | | * @param info bId 信息 |
| | | * @return 商户照片 |
| | | * @throws DAOException |
| | | */ |
| | | public List<Map> getStoreCerdentials(Map info) throws DAOException; |
| | | |
| | | /** |
| | | * 修改商户信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | public void updateStoreInfoInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 修改商户属性信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | public void updateStoreAttrInstance(Map info) throws DAOException; |
| | | |
| | | |
| | | /** |
| | | * 修改商户照片信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | public void updateStorePhotoInstance(Map info) throws DAOException; |
| | | |
| | | /** |
| | | * 修改商户证件信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | public void updateStoreCerdentailsInstance(Map info) throws DAOException; |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.shop.dao.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.DAOException; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.core.base.dao.BaseServiceDao; |
| | | import com.java110.shop.dao.IShopServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 商户服务 与数据库交互 |
| | | * Created by wuxw on 2017/4/5. |
| | | */ |
| | | @Service("shopServiceDaoImpl") |
| | | //@Transactional |
| | | public class ShopServiceDaoImpl extends BaseServiceDao implements IShopServiceDao { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(ShopServiceDaoImpl.class); |
| | | |
| | | /** |
| | | * 商户信息封装 |
| | | * @param businessStoreInfo 商户信息 封装 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveBusinessStoreInfo(Map businessStoreInfo) throws DAOException { |
| | | businessStoreInfo.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存商户信息 入参 businessStoreInfo : {}",businessStoreInfo); |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStoreInfo",businessStoreInfo); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户数据失败:"+ JSONObject.toJSONString(businessStoreInfo)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 商户属性信息分装 |
| | | * @param businessStoreAttr 商户属性信息封装 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveBusinessStoreAttr(Map businessStoreAttr) throws DAOException { |
| | | businessStoreAttr.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存商户属性信息 入参 businessStoreAttr : {}",businessStoreAttr); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStoreAttr",businessStoreAttr); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户属性数据失败:"+ JSONObject.toJSONString(businessStoreAttr)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存商户照片信息 |
| | | * @param businessStorePhoto 商户照片 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveBusinessStorePhoto(Map businessStorePhoto) throws DAOException { |
| | | businessStorePhoto.put("month", DateUtil.getCurrentMonth()); |
| | | logger.debug("保存商户照片信息 入参 businessStorePhoto : {}",businessStorePhoto); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStorePhoto",businessStorePhoto); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户照片数据失败:"+ JSONObject.toJSONString(businessStorePhoto)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存商户证件信息 |
| | | * @param businessStoreCerdentials 商户证件 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveBusinessStoreCerdentials(Map businessStoreCerdentials) throws DAOException { |
| | | businessStoreCerdentials.put("month", DateUtil.getCurrentMonth()); |
| | | logger.debug("保存商户证件信息 入参 businessStoreCerdentials : {}",businessStoreCerdentials); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStoreCerdentials",businessStoreCerdentials); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户证件数据失败:"+ JSONObject.toJSONString(businessStoreCerdentials)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询商户信息 |
| | | * @param info bId 信息 |
| | | * @return 商户信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public Map getBusinessStoreInfo(Map info) throws DAOException { |
| | | |
| | | logger.debug("查询商户信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessStoreInfos = sqlSessionTemplate.selectList("storeServiceDaoImpl.getBusinessStoreInfo",info); |
| | | if(businessStoreInfos == null){ |
| | | return null; |
| | | } |
| | | if(businessStoreInfos.size() >1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessStoreInfos,"+ JSONObject.toJSONString(info)); |
| | | } |
| | | |
| | | return businessStoreInfos.get(0); |
| | | } |
| | | |
| | | /** |
| | | * 查询商户属性 |
| | | * @param info bId 信息 |
| | | * @return 商户属性 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public List<Map> getBusinessStoreAttrs(Map info) throws DAOException { |
| | | logger.debug("查询商户属性信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessStoreAttrs = sqlSessionTemplate.selectList("storeServiceDaoImpl.getBusinessStoreAttrs",info); |
| | | |
| | | return businessStoreAttrs; |
| | | } |
| | | |
| | | /** |
| | | * 查询商户照片 |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public List<Map> getBusinessStorePhoto(Map info) throws DAOException { |
| | | logger.debug("查询商户照片信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessStorePhotos = sqlSessionTemplate.selectList("storeServiceDaoImpl.getBusinessStorePhoto",info); |
| | | |
| | | return businessStorePhotos; |
| | | } |
| | | |
| | | /** |
| | | * 查询商户证件 |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public List<Map> getBusinessStoreCerdentials(Map info) throws DAOException { |
| | | logger.debug("查询商户证件信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessStoreCerdentialses = sqlSessionTemplate.selectList("storeServiceDaoImpl.getBusinessStoreCerdentials",info); |
| | | |
| | | return businessStoreCerdentialses; |
| | | } |
| | | |
| | | /** |
| | | * 保存商户信息 到 instance |
| | | * @param info bId 信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void saveStoreInfoInstance(Map info) throws DAOException { |
| | | logger.debug("保存商户信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveStoreInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void saveStoreAttrsInstance(Map info) throws DAOException { |
| | | logger.debug("保存商户属性信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveStoreAttrsInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户属性信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void saveStorePhotoInstance(Map info) throws DAOException { |
| | | logger.debug("保存商户照片信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveStorePhotoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户照片信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void saveStoreCerdentialsInstance(Map info) throws DAOException { |
| | | logger.debug("保存商户证件信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveStoreCerdentialsInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商户证件信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询商户信息(instance) |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public Map getStoreInfo(Map info) throws DAOException { |
| | | logger.debug("查询商户信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessStoreInfos = sqlSessionTemplate.selectList("storeServiceDaoImpl.getStoreInfo",info); |
| | | if(businessStoreInfos == null || businessStoreInfos.size() == 0){ |
| | | return null; |
| | | } |
| | | if(businessStoreInfos.size() >1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getStoreInfo,"+ JSONObject.toJSONString(info)); |
| | | } |
| | | |
| | | return businessStoreInfos.get(0); |
| | | } |
| | | |
| | | /** |
| | | * 商户属性查询(instance) |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public List<Map> getStoreAttrs(Map info) throws DAOException { |
| | | logger.debug("查询商户属性信息 入参 info : {}",info); |
| | | |
| | | List<Map> storeAttrs = sqlSessionTemplate.selectList("storeServiceDaoImpl.getStoreAttrs",info); |
| | | |
| | | return storeAttrs; |
| | | } |
| | | |
| | | /** |
| | | * 商户照片查询(instance) |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public List<Map> getStorePhoto(Map info) throws DAOException { |
| | | logger.debug("查询商户照片信息 入参 info : {}",info); |
| | | |
| | | List<Map> storePhotos = sqlSessionTemplate.selectList("storeServiceDaoImpl.getStorePhoto",info); |
| | | |
| | | return storePhotos; |
| | | } |
| | | |
| | | /** |
| | | * 商户证件查询(instance) |
| | | * @param info bId 信息 |
| | | * @return |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public List<Map> getStoreCerdentials(Map info) throws DAOException { |
| | | logger.debug("查询商户证件信息 入参 info : {}",info); |
| | | |
| | | List<Map> storeCerdentialses = sqlSessionTemplate.selectList("storeServiceDaoImpl.getStoreCerdentials",info); |
| | | |
| | | return storeCerdentialses; |
| | | } |
| | | |
| | | /** |
| | | * 修改商户信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void updateStoreInfoInstance(Map info) throws DAOException { |
| | | logger.debug("修改商户信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("storeServiceDaoImpl.updateStoreInfoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商户信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改商户属性信息(instance) |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void updateStoreAttrInstance(Map info) throws DAOException { |
| | | logger.debug("修改商户属性信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("storeServiceDaoImpl.updateStoreAttrInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商户属性信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改 商户照片信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void updateStorePhotoInstance(Map info) throws DAOException { |
| | | logger.debug("修改商户照片信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("storeServiceDaoImpl.updateStorePhotoInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商户照片信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改商户证件信息 |
| | | * @param info 修改信息 |
| | | * @throws DAOException |
| | | */ |
| | | @Override |
| | | public void updateStoreCerdentailsInstance(Map info) throws DAOException { |
| | | logger.debug("修改商户证件信息Instance 入参 info : {}",info); |
| | | |
| | | int saveFlag = sqlSessionTemplate.update("storeServiceDaoImpl.updateStoreCerdentailsInstance",info); |
| | | |
| | | if(saveFlag < 1){ |
| | | throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商户证件信息Instance数据失败:"+ JSONObject.toJSONString(info)); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.kafka; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * Created by wuxw on 2018/4/15. |
| | | */ |
| | | @Configuration |
| | | public class ShopServiceBean { |
| | | @Bean |
| | | public ShopServiceKafka listener() { |
| | | return new ShopServiceKafka(); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.shop.kafka; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.KafkaConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.InitConfigDataException; |
| | | import com.java110.common.exception.InitDataFlowContextException; |
| | | import com.java110.common.kafka.KafkaFactory; |
| | | import com.java110.core.base.controller.BaseController; |
| | | import com.java110.core.context.BusinessServiceDataFlow; |
| | | import com.java110.core.factory.DataTransactionFactory; |
| | | import com.java110.shop.smo.IShopServiceSMO; |
| | | import org.apache.kafka.clients.consumer.ConsumerRecord; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.kafka.annotation.KafkaListener; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * kafka侦听 |
| | | * Created by wuxw on 2018/4/15. |
| | | */ |
| | | public class ShopServiceKafka extends BaseController { |
| | | |
| | | @Autowired |
| | | private IShopServiceSMO shopServiceSMOImpl; |
| | | |
| | | @KafkaListener(topics = {"shopServiceTopic"}) |
| | | public void listen(ConsumerRecord<?, ?> record) { |
| | | logger.info("kafka的key: " + record.key()); |
| | | logger.info("kafka的value: " + record.value().toString()); |
| | | String orderInfo = record.value().toString(); |
| | | BusinessServiceDataFlow businessServiceDataFlow = null; |
| | | JSONObject responseJson = null; |
| | | try { |
| | | Map<String, String> headers = new HashMap<String, String>(); |
| | | //预校验 |
| | | preValiateOrderInfo(orderInfo); |
| | | businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers); |
| | | responseJson = shopServiceSMOImpl.service(businessServiceDataFlow); |
| | | }catch (InitDataFlowContextException e){ |
| | | logger.error("请求报文错误,初始化 BusinessServiceDataFlow失败"+orderInfo,e); |
| | | responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null); |
| | | }catch (InitConfigDataException e){ |
| | | logger.error("请求报文错误,加载配置信息失败"+orderInfo,e); |
| | | responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null); |
| | | }catch (Exception e){ |
| | | logger.error("请求订单异常",e); |
| | | responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow,ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e, |
| | | null); |
| | | }finally { |
| | | logger.debug("当前请求报文:" + orderInfo +", 当前返回报文:" +responseJson.toJSONString()); |
| | | //只有business 和 instance 过程才做通知消息 |
| | | if(!StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(responseJson.getString("businessType")) |
| | | && !StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(responseJson.getString("businessType"))){ |
| | | return ; |
| | | } |
| | | try { |
| | | KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_NOTIFY_CENTER_SERVICE_NAME, "", responseJson.toJSONString()); |
| | | }catch (Exception e){ |
| | | logger.error("用户服务通知centerService失败"+responseJson,e); |
| | | //这里保存异常信息 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 这里预校验,请求报文中不能有 dataFlowId |
| | | * @param orderInfo |
| | | */ |
| | | private void preValiateOrderInfo(String orderInfo) { |
| | | /* if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){ |
| | | throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"报文中不能存在dataFlowId节点"); |
| | | }*/ |
| | | } |
| | | |
| | | public IShopServiceSMO getShopServiceSMOImpl() { |
| | | return shopServiceSMOImpl; |
| | | } |
| | | |
| | | public void setShopServiceSMOImpl(IShopServiceSMO shopServiceSMOImpl) { |
| | | this.shopServiceSMOImpl = shopServiceSMOImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.listener; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.event.service.AbstractBusinessServiceDataFlowListener; |
| | | import com.java110.shop.dao.IShopServiceDao; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * 商户 服务侦听 父类 |
| | | * Created by wuxw on 2018/7/4. |
| | | */ |
| | | public abstract class AbstractShopBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener{ |
| | | |
| | | |
| | | /** |
| | | * 获取 DAO工具类 |
| | | * @return |
| | | */ |
| | | public abstract IShopServiceDao getShopServiceDaoImpl(); |
| | | |
| | | /** |
| | | * 刷新 businessStoreInfo 数据 |
| | | * 主要将 数据库 中字段和 接口传递字段建立关系 |
| | | * @param businessStoreInfo |
| | | */ |
| | | protected void flushBusinessStoreInfo(Map businessStoreInfo,String statusCd){ |
| | | businessStoreInfo.put("newBId",businessStoreInfo.get("b_id")); |
| | | businessStoreInfo.put("storeId",businessStoreInfo.get("store_id")); |
| | | businessStoreInfo.put("userId",businessStoreInfo.get("user_id")); |
| | | businessStoreInfo.put("storeTypeCd",businessStoreInfo.get("store_type_cd")); |
| | | businessStoreInfo.put("nearbyLandmarks",businessStoreInfo.get("nearby_landmarks")); |
| | | businessStoreInfo.put("mapX",businessStoreInfo.get("map_x")); |
| | | businessStoreInfo.put("mapY",businessStoreInfo.get("map_y")); |
| | | businessStoreInfo.put("statusCd", statusCd); |
| | | } |
| | | |
| | | /** |
| | | 刷新 businessStoreAttr 数据 |
| | | * 主要将 数据库 中字段和 接口传递字段建立关系 |
| | | * @param businessStoreAttr |
| | | * @param statusCd |
| | | */ |
| | | protected void flushBusinessStoreAttr(Map businessStoreAttr,String statusCd){ |
| | | businessStoreAttr.put("attrId",businessStoreAttr.get("attr_id")); |
| | | businessStoreAttr.put("specCd",businessStoreAttr.get("spec_cd")); |
| | | businessStoreAttr.put("storeId",businessStoreAttr.get("store_id")); |
| | | businessStoreAttr.put("newBId",businessStoreAttr.get("b_id")); |
| | | businessStoreAttr.put("statusCd",statusCd); |
| | | } |
| | | |
| | | /** |
| | | * 刷新 businessStorePhoto 数据 |
| | | * @param businessStorePhoto |
| | | * @param statusCd |
| | | */ |
| | | protected void flushBusinessStorePhoto(Map businessStorePhoto,String statusCd){ |
| | | businessStorePhoto.put("storeId",businessStorePhoto.get("store_id")); |
| | | businessStorePhoto.put("storePhotoId",businessStorePhoto.get("store_photo_id")); |
| | | businessStorePhoto.put("storePhotoTypeCd",businessStorePhoto.get("store_photo_type_cd")); |
| | | businessStorePhoto.put("newBId",businessStorePhoto.get("b_id")); |
| | | businessStorePhoto.put("statusCd",statusCd); |
| | | } |
| | | |
| | | /** |
| | | * 刷新 businessStoreCerdentials 数据 |
| | | * @param businessStoreCerdentials |
| | | * @param statusCd |
| | | */ |
| | | protected void flushBusinessStoreCredentials(Map businessStoreCerdentials ,String statusCd){ |
| | | businessStoreCerdentials.put("storeId",businessStoreCerdentials.get("store_id")); |
| | | businessStoreCerdentials.put("storeCerdentialsId",businessStoreCerdentials.get("store_cerdentials_id")); |
| | | businessStoreCerdentials.put("credentialsCd",businessStoreCerdentials.get("credentials_cd")); |
| | | businessStoreCerdentials.put("validityPeriod",businessStoreCerdentials.get("validity_period")); |
| | | businessStoreCerdentials.put("positivePhoto",businessStoreCerdentials.get("positive_photo")); |
| | | businessStoreCerdentials.put("negativePhoto",businessStoreCerdentials.get("negative_photo")); |
| | | businessStoreCerdentials.put("newBId",businessStoreCerdentials.get("b_id")); |
| | | businessStoreCerdentials.put("statusCd",statusCd); |
| | | } |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * @param businessStore 商户信息 |
| | | */ |
| | | protected void autoSaveDelBusinessStore(Business business, JSONObject businessStore){ |
| | | //自动插入DEL |
| | | Map info = new HashMap(); |
| | | info.put("storeId",businessStore.getString("storeId")); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map currentStoreInfo = getShopServiceDaoImpl().getStoreInfo(info); |
| | | if(currentStoreInfo == null || currentStoreInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| | | } |
| | | currentStoreInfo.put("bId",business.getbId()); |
| | | currentStoreInfo.put("storeId",currentStoreInfo.get("store_id")); |
| | | currentStoreInfo.put("userId",currentStoreInfo.get("user_id")); |
| | | currentStoreInfo.put("storeTypeCd",currentStoreInfo.get("store_type_cd")); |
| | | currentStoreInfo.put("nearbyLandmarks",currentStoreInfo.get("nearby_landmarks")); |
| | | currentStoreInfo.put("mapX",currentStoreInfo.get("map_x")); |
| | | currentStoreInfo.put("mapY",currentStoreInfo.get("map_y")); |
| | | currentStoreInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | getShopServiceDaoImpl().saveBusinessStoreInfo(currentStoreInfo); |
| | | } |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * @param business 当前业务 |
| | | * @param storeAttr 商户属性 |
| | | */ |
| | | protected void autoSaveDelBusinessStoreAttr(Business business, JSONObject storeAttr){ |
| | | Map info = new HashMap(); |
| | | info.put("attrId",storeAttr.getString("attrId")); |
| | | info.put("storeId",storeAttr.getString("storeId")); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | List<Map> currentStoreAttrs = getShopServiceDaoImpl().getStoreAttrs(info); |
| | | if(currentStoreAttrs == null || currentStoreAttrs.size() != 1){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| | | } |
| | | Map currentStoreAttr = currentStoreAttrs.get(0); |
| | | currentStoreAttr.put("bId",business.getbId()); |
| | | currentStoreAttr.put("attrId",currentStoreAttr.get("attr_id")); |
| | | currentStoreAttr.put("storeId",currentStoreAttr.get("store_id")); |
| | | currentStoreAttr.put("specCd",currentStoreAttr.get("spec_cd")); |
| | | currentStoreAttr.put("operate",StatusConstant.OPERATE_DEL); |
| | | getShopServiceDaoImpl().saveBusinessStoreAttr(currentStoreAttr); |
| | | } |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * @param business |
| | | * @param businessStorePhoto 商户照片 |
| | | */ |
| | | protected void autoSaveDelBusinessStorePhoto(Business business,JSONObject businessStorePhoto){ |
| | | Map info = new HashMap(); |
| | | info.put("storePhotoId",businessStorePhoto.getString("storePhotoId")); |
| | | info.put("storeId",businessStorePhoto.getString("storeId")); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | List<Map> currentStorePhotos = getShopServiceDaoImpl().getStorePhoto(info); |
| | | if(currentStorePhotos == null || currentStorePhotos.size() != 1){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| | | } |
| | | Map currentStorePhoto = currentStorePhotos.get(0); |
| | | currentStorePhoto.put("bId",business.getbId()); |
| | | currentStorePhoto.put("storePhotoId",currentStorePhoto.get("store_photo_id")); |
| | | currentStorePhoto.put("storeId",currentStorePhoto.get("store_id")); |
| | | currentStorePhoto.put("storePhotoTypeCd",currentStorePhoto.get("store_photo_type_cd")); |
| | | currentStorePhoto.put("operate",StatusConstant.OPERATE_DEL); |
| | | getShopServiceDaoImpl().saveBusinessStorePhoto(currentStorePhoto); |
| | | } |
| | | |
| | | /** |
| | | * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| | | * @param business |
| | | * @param businessStoreCerdentials 商户证件 |
| | | */ |
| | | protected void autoSaveDelBusinessStoreCerdentials(Business business,JSONObject businessStoreCerdentials){ |
| | | Map info = new HashMap(); |
| | | info.put("storeCerdentialsId",businessStoreCerdentials.getString("storeCerdentialsId")); |
| | | info.put("storeId",businessStoreCerdentials.getString("storeId")); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | List<Map> currentStoreCerdentailses = getShopServiceDaoImpl().getStoreCerdentials(info); |
| | | if(currentStoreCerdentailses == null || currentStoreCerdentailses.size() != 1){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| | | } |
| | | Map currentStoreCerdentials = currentStoreCerdentailses.get(0); |
| | | |
| | | currentStoreCerdentials.put("bId",business.getbId()); |
| | | currentStoreCerdentials.put("storeCerdentialsId",currentStoreCerdentials.get("store_cerdentials_id")); |
| | | currentStoreCerdentials.put("storeId",currentStoreCerdentials.get("store_id")); |
| | | currentStoreCerdentials.put("credentialsCd",currentStoreCerdentials.get("credentials_cd")); |
| | | currentStoreCerdentials.put("validityPeriod",currentStoreCerdentials.get("validity_period")); |
| | | currentStoreCerdentials.put("positivePhoto",currentStoreCerdentials.get("positive_photo")); |
| | | currentStoreCerdentials.put("negativePhoto",currentStoreCerdentials.get("negative_photo")); |
| | | currentStoreCerdentials.put("operate",StatusConstant.OPERATE_DEL); |
| | | getShopServiceDaoImpl().saveBusinessStoreCerdentials(currentStoreCerdentials); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.listener; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceCodeConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.shop.dao.IShopServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 删除商户信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessStore:{} 商户基本信息节点 |
| | | * 2、businessStoreAttr:[{}] 商户属性信息节点 |
| | | * 3、businessStorePhoto:[{}] 商户照片信息节点 |
| | | * 4、businessStoreCerdentials:[{}] 商户证件信息节点 |
| | | * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("deleteShopInfoListener") |
| | | @Transactional |
| | | public class DeleteShopInfoListener extends AbstractShopBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(DeleteShopInfoListener.class); |
| | | @Autowired |
| | | IShopServiceDao shopServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeConstant.SERVICE_CODE_DELETE_STORE_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessStore 节点 按理这里不应该处理,程序上支持,以防真有这种业务 |
| | | if(data.containsKey("businessStore")){ |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | doBusinessStore(business,businessStore); |
| | | dataFlowContext.addParamOut("storeId",businessStore.getString("storeId")); |
| | | } |
| | | |
| | | if(data.containsKey("businessStoreAttr")){ |
| | | JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr"); |
| | | doSaveBusinessStoreAttrs(business,businessStoreAttrs); |
| | | } |
| | | |
| | | if(data.containsKey("businessStorePhoto")){ |
| | | JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto"); |
| | | doBusinessStorePhoto(business,businessStorePhotos); |
| | | } |
| | | |
| | | if(data.containsKey("businessStoreCerdentials")){ |
| | | JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials"); |
| | | doBusinessStoreCerdentials(business,businessStoreCerdentialses); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除 instance数据 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | |
| | | //商户信息 |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_DEL); |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = shopServiceDaoImpl.getBusinessStoreInfo(info); |
| | | if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) { |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_INVALID); |
| | | shopServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id")); |
| | | } |
| | | //商户属性 |
| | | List<Map> businessStoreAttrs = shopServiceDaoImpl.getBusinessStoreAttrs(info); |
| | | if(businessStoreAttrs != null && businessStoreAttrs.size() > 0) { |
| | | for(Map businessStoreAttr : businessStoreAttrs) { |
| | | flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_INVALID); |
| | | shopServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr); |
| | | } |
| | | } |
| | | //商户照片 |
| | | List<Map> businessStorePhotos = shopServiceDaoImpl.getBusinessStorePhoto(info); |
| | | if(businessStorePhotos != null && businessStorePhotos.size() >0){ |
| | | for(Map businessStorePhoto : businessStorePhotos) { |
| | | flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_INVALID); |
| | | shopServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto); |
| | | } |
| | | } |
| | | //商户证件 |
| | | List<Map> businessStoreCerdentialses = shopServiceDaoImpl.getBusinessStoreCerdentials(info); |
| | | if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){ |
| | | for(Map businessStoreCerdentials : businessStoreCerdentialses) { |
| | | flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_INVALID); |
| | | shopServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * 从business表中查询到DEL的数据 将instance中的数据更新回来 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //商户信息 |
| | | Map storeInfo = shopServiceDaoImpl.getStoreInfo(info); |
| | | if(storeInfo != null && !storeInfo.isEmpty()){ |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = shopServiceDaoImpl.getBusinessStoreInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreInfo == null || businessStoreInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",storeInfo.get("store_id")); |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeAttrs = shopServiceDaoImpl.getStoreAttrs(info); |
| | | if(storeAttrs != null && storeAttrs.size()>0){ |
| | | |
| | | List<Map> businessStoreAttrs = shopServiceDaoImpl.getBusinessStoreAttrs(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreAttrs == null || businessStoreAttrs.size() ==0 ){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_attr),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for(Map businessStoreAttr : businessStoreAttrs) { |
| | | flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr); |
| | | } |
| | | } |
| | | |
| | | //商户照片 |
| | | List<Map> storePhotos = shopServiceDaoImpl.getStorePhoto(info); |
| | | if(storePhotos != null && storePhotos.size()>0){ |
| | | List<Map> businessStorePhotos = shopServiceDaoImpl.getBusinessStorePhoto(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStorePhotos == null || businessStorePhotos.size() ==0 ){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_photo),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for(Map businessStorePhoto : businessStorePhotos) { |
| | | flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto); |
| | | } |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeCerdentialses = shopServiceDaoImpl.getStoreCerdentials(info); |
| | | if(storeCerdentialses != null && storeCerdentialses.size()>0){ |
| | | List<Map> businessStoreCerdentialses = shopServiceDaoImpl.getBusinessStoreCerdentials(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreCerdentialses == null || businessStoreCerdentialses.size() ==0 ){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_cerdentials),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for(Map businessStoreCerdentials : businessStoreCerdentialses) { |
| | | flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存商户照片 |
| | | * @param business 业务对象 |
| | | * @param businessStorePhotos 商户照片 |
| | | */ |
| | | private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) { |
| | | |
| | | for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) { |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStorePhoto.getString("storePhotoId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto); |
| | | } |
| | | |
| | | autoSaveDelBusinessStorePhoto(business,businessStorePhoto); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理 businessStore 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessStore 商户节点 |
| | | */ |
| | | private void doBusinessStore(Business business,JSONObject businessStore){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore); |
| | | } |
| | | //自动插入DEL |
| | | autoSaveDelBusinessStore(business,businessStore); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存商户属性信息 |
| | | * @param business 当前业务 |
| | | * @param businessStoreAttrs 商户属性 |
| | | */ |
| | | private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreAttrs){ |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){ |
| | | JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex); |
| | | Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点"); |
| | | if(storeAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr); |
| | | } |
| | | |
| | | autoSaveDelBusinessStoreAttr(business,storeAttr); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存 商户证件 信息 |
| | | * @param business 当前业务 |
| | | * @param businessStoreCerdentialses 商户证件 |
| | | */ |
| | | private void doBusinessStoreCerdentials(Business business, JSONArray businessStoreCerdentialses) { |
| | | |
| | | Map info = null; |
| | | Map currentStoreCerdentials = null; |
| | | for(int businessStoreCerdentialsIndex = 0 ; businessStoreCerdentialsIndex < businessStoreCerdentialses.size() ; businessStoreCerdentialsIndex ++) { |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials); |
| | | } |
| | | |
| | | autoSaveDelBusinessStoreCerdentials(business,businessStoreCerdentials); |
| | | } |
| | | } |
| | | |
| | | public IShopServiceDao getShopServiceDaoImpl() { |
| | | return shopServiceDaoImpl; |
| | | } |
| | | |
| | | public void setShopServiceDaoImpl(IShopServiceDao shopServiceDaoImpl) { |
| | | this.shopServiceDaoImpl = shopServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.listener; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceCodeConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.common.util.StringUtil; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.shop.dao.IShopServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 保存 用户信息 侦听 |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("saveShopInfoListener") |
| | | @Transactional |
| | | public class SaveShopInfoListener extends AbstractShopBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(SaveShopInfoListener.class); |
| | | |
| | | @Autowired |
| | | IShopServiceDao shopServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO; |
| | | } |
| | | |
| | | /** |
| | | * 保存商户信息 business 表中 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessStore 节点 |
| | | if(data.containsKey("businessStore")){ |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | doBusinessStore(business,businessStore); |
| | | dataFlowContext.addParamOut("storeId",businessStore.getString("storeId")); |
| | | } |
| | | |
| | | if(data.containsKey("businessStoreAttr")){ |
| | | JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr"); |
| | | doSaveBusinessStoreAttrs(business,businessStoreAttrs); |
| | | } |
| | | |
| | | if(data.containsKey("businessStorePhoto")){ |
| | | JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto"); |
| | | doBusinessStorePhoto(business,businessStorePhotos); |
| | | } |
| | | |
| | | if(data.containsKey("businessStoreCerdentials")){ |
| | | JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials"); |
| | | doBusinessStoreCerdentials(business,businessStoreCerdentialses); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * business 数据转移到 instance |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_ADD); |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = shopServiceDaoImpl.getBusinessStoreInfo(info); |
| | | if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) { |
| | | shopServiceDaoImpl.saveStoreInfoInstance(info); |
| | | dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id")); |
| | | } |
| | | //商户属性 |
| | | List<Map> businessStoreAttrs = shopServiceDaoImpl.getBusinessStoreAttrs(info); |
| | | if(businessStoreAttrs != null && businessStoreAttrs.size() > 0) { |
| | | shopServiceDaoImpl.saveStoreAttrsInstance(info); |
| | | } |
| | | //商户照片 |
| | | List<Map> businessStorePhotos = shopServiceDaoImpl.getBusinessStorePhoto(info); |
| | | if(businessStorePhotos != null && businessStorePhotos.size() >0){ |
| | | shopServiceDaoImpl.saveStorePhotoInstance(info); |
| | | } |
| | | //商户证件 |
| | | List<Map> businessStoreCerdentialses = shopServiceDaoImpl.getBusinessStoreCerdentials(info); |
| | | if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){ |
| | | shopServiceDaoImpl.saveStoreCerdentialsInstance(info); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map paramIn = new HashMap(); |
| | | paramIn.put("bId",bId); |
| | | paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID); |
| | | //商户信息 |
| | | Map storeInfo = shopServiceDaoImpl.getStoreInfo(info); |
| | | if(storeInfo != null && !storeInfo.isEmpty()){ |
| | | paramIn.put("storeId",storeInfo.get("store_id").toString()); |
| | | shopServiceDaoImpl.updateStoreInfoInstance(paramIn); |
| | | dataFlowContext.addParamOut("storeId",storeInfo.get("store_id")); |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeAttrs = shopServiceDaoImpl.getStoreAttrs(info); |
| | | if(storeAttrs != null && storeAttrs.size()>0){ |
| | | shopServiceDaoImpl.updateStoreAttrInstance(paramIn); |
| | | } |
| | | |
| | | //商户照片 |
| | | List<Map> storePhotos = shopServiceDaoImpl.getStorePhoto(info); |
| | | if(storePhotos != null && storePhotos.size()>0){ |
| | | shopServiceDaoImpl.updateStorePhotoInstance(paramIn); |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeCerdentialses = shopServiceDaoImpl.getStoreCerdentials(info); |
| | | if(storeCerdentialses != null && storeCerdentialses.size()>0){ |
| | | shopServiceDaoImpl.updateStoreCerdentailsInstance(paramIn); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存商户照片 |
| | | * @param business 业务对象 |
| | | * @param businessStorePhotos 商户照片 |
| | | */ |
| | | private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) { |
| | | |
| | | for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) { |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStorePhoto.getString("storePhotoId").startsWith("-")) { |
| | | String storePhotoId = GenerateCodeFactory.getStorePhotoId(); |
| | | businessStorePhoto.put("storePhotoId", storePhotoId); |
| | | } |
| | | businessStorePhoto.put("bId", business.getbId()); |
| | | businessStorePhoto.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | shopServiceDaoImpl.saveBusinessStorePhoto(businessStorePhoto); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理 businessStore 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessStore 商户节点 |
| | | */ |
| | | private void doBusinessStore(Business business,JSONObject businessStore){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | //刷新缓存 |
| | | flushStoreId(business.getDatas()); |
| | | } |
| | | |
| | | businessStore.put("bId",business.getbId()); |
| | | businessStore.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | shopServiceDaoImpl.saveBusinessStoreInfo(businessStore); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存商户属性信息 |
| | | * @param business 当前业务 |
| | | * @param businessStoreAttrs 商户属性 |
| | | */ |
| | | private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreAttrs){ |
| | | JSONObject data = business.getDatas(); |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){ |
| | | JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex); |
| | | Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(storeAttr.getString("attrId").startsWith("-")){ |
| | | String attrId = GenerateCodeFactory.getAttrId(); |
| | | storeAttr.put("attrId",attrId); |
| | | } |
| | | |
| | | storeAttr.put("bId",business.getbId()); |
| | | storeAttr.put("storeId",businessStore.getString("storeId")); |
| | | storeAttr.put("operate", StatusConstant.OPERATE_ADD); |
| | | |
| | | shopServiceDaoImpl.saveBusinessStoreAttr(storeAttr); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存 商户证件 信息 |
| | | * @param business 当前业务 |
| | | * @param businessStoreCerdentialses 商户证件 |
| | | */ |
| | | private void doBusinessStoreCerdentials(Business business, JSONArray businessStoreCerdentialses) { |
| | | for(int businessStoreCerdentialsIndex = 0 ; businessStoreCerdentialsIndex < businessStoreCerdentialses.size() ; businessStoreCerdentialsIndex ++) { |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) { |
| | | String storePhotoId = GenerateCodeFactory.getStoreCerdentialsId(); |
| | | businessStoreCerdentials.put("storeCerdentialsId", storePhotoId); |
| | | } |
| | | Date validityPeriod = null; |
| | | try { |
| | | if(StringUtil.isNullOrNone(businessStoreCerdentials.getString("validityPeriod"))){ |
| | | validityPeriod = DateUtil.getLastDate(); |
| | | }else { |
| | | validityPeriod = DateUtil.getDateFromString(businessStoreCerdentials.getString("validityPeriod"), DateUtil.DATE_FORMATE_STRING_B); |
| | | } |
| | | } catch (ParseException e) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 validityPeriod 格式不正确,请填写 "+DateUtil.DATE_FORMATE_STRING_B +" 格式,"+businessStoreCerdentials); |
| | | } |
| | | businessStoreCerdentials.put("validityPeriod",validityPeriod); |
| | | businessStoreCerdentials.put("bId", business.getbId()); |
| | | businessStoreCerdentials.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | shopServiceDaoImpl.saveBusinessStoreCerdentials(businessStoreCerdentials); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 刷新 商户ID |
| | | * @param data |
| | | */ |
| | | private void flushStoreId(JSONObject data) { |
| | | |
| | | String storeId = GenerateCodeFactory.getStoreId(); |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | businessStore.put("storeId",storeId); |
| | | //刷商户属性 |
| | | if(data.containsKey("businessStoreAttr")) { |
| | | JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr"); |
| | | for(int businessStoreAttrIndex = 0;businessStoreAttrIndex < businessStoreAttrs.size();businessStoreAttrIndex++) { |
| | | JSONObject businessStoreAttr = businessStoreAttrs.getJSONObject(businessStoreAttrIndex); |
| | | businessStoreAttr.put("storeId", storeId); |
| | | } |
| | | } |
| | | //刷 是商户照片 的 storeId |
| | | if(data.containsKey("businessStorePhoto")) { |
| | | JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto"); |
| | | for(int businessStorePhotoIndex = 0;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) { |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | businessStorePhoto.put("storeId", storeId); |
| | | } |
| | | } |
| | | //刷 商户证件 的storeId |
| | | if(data.containsKey("businessStoreCerdentials")) { |
| | | JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials"); |
| | | for(int businessStoreCerdentialsIndex = 0;businessStoreCerdentialsIndex < businessStoreCerdentialses.size();businessStoreCerdentialsIndex++) { |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | businessStoreCerdentials.put("storeId", storeId); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public IShopServiceDao getShopServiceDaoImpl() { |
| | | return shopServiceDaoImpl; |
| | | } |
| | | |
| | | public void setShopServiceDaoImpl(IShopServiceDao shopServiceDaoImpl) { |
| | | this.shopServiceDaoImpl = shopServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.listener; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceCodeConstant; |
| | | import com.java110.common.constant.StatusConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.entity.center.Business; |
| | | import com.java110.shop.dao.IShopServiceDao; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 修改商户信息 侦听 |
| | | * |
| | | * 处理节点 |
| | | * 1、businessStore:{} 商户基本信息节点 |
| | | * 2、businessStoreAttr:[{}] 商户属性信息节点 |
| | | * 3、businessStorePhoto:[{}] 商户照片信息节点 |
| | | * 4、businessStoreCerdentials:[{}] 商户证件信息节点 |
| | | * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E4%BF%AE%E6%94%B9%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("updateShopInfoListener") |
| | | @Transactional |
| | | public class UpdateShopInfoListener extends AbstractShopBusinessServiceDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(UpdateShopInfoListener.class); |
| | | @Autowired |
| | | IShopServiceDao shopServiceDaoImpl; |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 2; |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeConstant.SERVICE_CODE_UPDATE_STORE_INFO; |
| | | } |
| | | |
| | | /** |
| | | * business过程 |
| | | * @param dataFlowContext |
| | | * @param business |
| | | */ |
| | | @Override |
| | | protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理"); |
| | | |
| | | //处理 businessStore 节点 |
| | | if(data.containsKey("businessStore")){ |
| | | JSONObject businessStore = data.getJSONObject("businessStore"); |
| | | doBusinessStore(business,businessStore); |
| | | dataFlowContext.addParamOut("storeId",businessStore.getString("storeId")); |
| | | } |
| | | |
| | | if(data.containsKey("businessStoreAttr")){ |
| | | JSONArray businessStoreAttrs = data.getJSONArray("businessStoreAttr"); |
| | | doSaveBusinessStoreAttrs(business,businessStoreAttrs); |
| | | } |
| | | |
| | | if(data.containsKey("businessStorePhoto")){ |
| | | JSONArray businessStorePhotos = data.getJSONArray("businessStorePhoto"); |
| | | doBusinessStorePhoto(business,businessStorePhotos); |
| | | } |
| | | |
| | | if(data.containsKey("businessStoreCerdentials")){ |
| | | JSONArray businessStoreCerdentialses = data.getJSONArray("businessStoreCerdentials"); |
| | | doBusinessStoreCerdentials(business,businessStoreCerdentialses); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * business to instance 过程 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_ADD); |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = shopServiceDaoImpl.getBusinessStoreInfo(info); |
| | | if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) { |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id")); |
| | | } |
| | | //商户属性 |
| | | List<Map> businessStoreAttrs = shopServiceDaoImpl.getBusinessStoreAttrs(info); |
| | | if(businessStoreAttrs != null && businessStoreAttrs.size() > 0) { |
| | | for(Map businessStoreAttr : businessStoreAttrs) { |
| | | flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr); |
| | | } |
| | | } |
| | | //商户照片 |
| | | List<Map> businessStorePhotos = shopServiceDaoImpl.getBusinessStorePhoto(info); |
| | | if(businessStorePhotos != null && businessStorePhotos.size() >0){ |
| | | for(Map businessStorePhoto : businessStorePhotos) { |
| | | flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto); |
| | | } |
| | | } |
| | | //商户证件 |
| | | List<Map> businessStoreCerdentialses = shopServiceDaoImpl.getBusinessStoreCerdentials(info); |
| | | if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){ |
| | | for(Map businessStoreCerdentials : businessStoreCerdentialses) { |
| | | flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 撤单 |
| | | * @param dataFlowContext 数据对象 |
| | | * @param business 当前业务对象 |
| | | */ |
| | | @Override |
| | | protected void doRecover(DataFlowContext dataFlowContext, Business business) { |
| | | |
| | | String bId = business.getbId(); |
| | | //Assert.hasLength(bId,"请求报文中没有包含 bId"); |
| | | Map info = new HashMap(); |
| | | info.put("bId",bId); |
| | | info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| | | Map delInfo = new HashMap(); |
| | | delInfo.put("bId",business.getbId()); |
| | | delInfo.put("operate",StatusConstant.OPERATE_DEL); |
| | | //商户信息 |
| | | Map storeInfo = shopServiceDaoImpl.getStoreInfo(info); |
| | | if(storeInfo != null && !storeInfo.isEmpty()){ |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = shopServiceDaoImpl.getBusinessStoreInfo(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreInfo == null || businessStoreInfo.isEmpty()){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",storeInfo.get("store_id")); |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeAttrs = shopServiceDaoImpl.getStoreAttrs(info); |
| | | if(storeAttrs != null && storeAttrs.size()>0){ |
| | | |
| | | List<Map> businessStoreAttrs = shopServiceDaoImpl.getBusinessStoreAttrs(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreAttrs == null || businessStoreAttrs.size() ==0 ){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_attr),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for(Map businessStoreAttr : businessStoreAttrs) { |
| | | flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr); |
| | | } |
| | | } |
| | | |
| | | //商户照片 |
| | | List<Map> storePhotos = shopServiceDaoImpl.getStorePhoto(info); |
| | | if(storePhotos != null && storePhotos.size()>0){ |
| | | List<Map> businessStorePhotos = shopServiceDaoImpl.getBusinessStorePhoto(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStorePhotos == null || businessStorePhotos.size() ==0 ){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_photo),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for(Map businessStorePhoto : businessStorePhotos) { |
| | | flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto); |
| | | } |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeCerdentialses = shopServiceDaoImpl.getStoreCerdentials(info); |
| | | if(storeCerdentialses != null && storeCerdentialses.size()>0){ |
| | | List<Map> businessStoreCerdentialses = shopServiceDaoImpl.getBusinessStoreCerdentials(delInfo); |
| | | //除非程序出错了,这里不会为空 |
| | | if(businessStoreCerdentialses == null || businessStoreCerdentialses.size() ==0 ){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(store_cerdentials),程序内部异常,请检查! "+delInfo); |
| | | } |
| | | for(Map businessStoreCerdentials : businessStoreCerdentialses) { |
| | | flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_VALID); |
| | | shopServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存商户照片 |
| | | * @param business 业务对象 |
| | | * @param businessStorePhotos 商户照片 |
| | | */ |
| | | private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) { |
| | | |
| | | |
| | | for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) { |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStorePhoto.getString("storePhotoId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto); |
| | | } |
| | | |
| | | //自动保存DEL信息 |
| | | autoSaveDelBusinessStorePhoto(business,businessStorePhoto); |
| | | |
| | | businessStorePhoto.put("bId", business.getbId()); |
| | | businessStorePhoto.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | shopServiceDaoImpl.saveBusinessStorePhoto(businessStorePhoto); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理 businessStore 节点 |
| | | * @param business 总的数据节点 |
| | | * @param businessStore 商户节点 |
| | | */ |
| | | private void doBusinessStore(Business business,JSONObject businessStore){ |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore); |
| | | } |
| | | //自动保存DEL |
| | | autoSaveDelBusinessStore(business,businessStore); |
| | | |
| | | businessStore.put("bId",business.getbId()); |
| | | businessStore.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | shopServiceDaoImpl.saveBusinessStoreInfo(businessStore); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存商户属性信息 |
| | | * @param business 当前业务 |
| | | * @param businessStoreAttrs 商户属性 |
| | | */ |
| | | private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreAttrs){ |
| | | JSONObject data = business.getDatas(); |
| | | |
| | | |
| | | for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){ |
| | | JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex); |
| | | Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点"); |
| | | if(storeAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr); |
| | | } |
| | | //自动保存DEL数据 |
| | | autoSaveDelBusinessStoreAttr(business,storeAttr); |
| | | |
| | | storeAttr.put("bId",business.getbId()); |
| | | storeAttr.put("storeId",storeAttr.getString("storeId")); |
| | | storeAttr.put("operate", StatusConstant.OPERATE_ADD); |
| | | |
| | | shopServiceDaoImpl.saveBusinessStoreAttr(storeAttr); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存 商户证件 信息 |
| | | * @param business 当前业务 |
| | | * @param businessStoreCerdentialses 商户证件 |
| | | */ |
| | | private void doBusinessStoreCerdentials(Business business, JSONArray businessStoreCerdentialses) { |
| | | |
| | | for(int businessStoreCerdentialsIndex = 0 ; businessStoreCerdentialsIndex < businessStoreCerdentialses.size() ; businessStoreCerdentialsIndex ++) { |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials); |
| | | } |
| | | |
| | | autoSaveDelBusinessStoreCerdentials(business,businessStoreCerdentials); |
| | | |
| | | businessStoreCerdentials.put("bId", business.getbId()); |
| | | businessStoreCerdentials.put("operate", StatusConstant.OPERATE_ADD); |
| | | //保存商户信息 |
| | | shopServiceDaoImpl.saveBusinessStoreCerdentials(businessStoreCerdentials); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public IShopServiceDao getShopServiceDaoImpl() { |
| | | return shopServiceDaoImpl; |
| | | } |
| | | |
| | | public void setShopServiceDaoImpl(IShopServiceDao shopServiceDaoImpl) { |
| | | this.shopServiceDaoImpl = shopServiceDaoImpl; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.shop.smo; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.exception.SMOException; |
| | | import com.java110.core.context.BusinessServiceDataFlow; |
| | | |
| | | /** |
| | | * |
| | | * 用户信息管理,服务 |
| | | * Created by wuxw on 2017/4/5. |
| | | */ |
| | | public interface IShopServiceSMO { |
| | | |
| | | |
| | | public JSONObject service(BusinessServiceDataFlow businessServiceDataFlow) throws SMOException; |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.shop.smo.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.cache.MappingCache; |
| | | import com.java110.common.constant.KafkaConstant; |
| | | import com.java110.common.constant.MappingConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.exception.SMOException; |
| | | import com.java110.common.kafka.KafkaFactory; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.core.context.BusinessServiceDataFlow; |
| | | import com.java110.core.factory.DataFlowFactory; |
| | | import com.java110.entity.center.DataFlowLinksCost; |
| | | import com.java110.entity.center.DataFlowLog; |
| | | import com.java110.event.service.BusinessServiceDataFlowEventPublishing; |
| | | import com.java110.shop.smo.IShopServiceSMO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户服务信息管理业务信息实现 |
| | | * Created by wuxw on 2017/4/5. |
| | | */ |
| | | @Service("shopServiceSMOImpl") |
| | | @Transactional |
| | | public class ShopServiceSMOImpl extends BaseServiceSMO implements IShopServiceSMO { |
| | | |
| | | |
| | | @Override |
| | | public JSONObject service(BusinessServiceDataFlow businessServiceDataFlow) throws SMOException { |
| | | try { |
| | | Assert.hasLength(businessServiceDataFlow.getbId(),"bId 不能为空"); |
| | | |
| | | BusinessServiceDataFlowEventPublishing.multicastEvent(businessServiceDataFlow); |
| | | Assert.notEmpty(businessServiceDataFlow.getResJson(),"商品服务["+businessServiceDataFlow.getCurrentBusiness().getServiceCode()+"]没有返回内容"); |
| | | } catch (Exception e) { |
| | | logger.error("商品信息处理异常",e); |
| | | throw new SMOException(ResponseConstant.RESULT_PARAM_ERROR,"商品信息处理异常"+e.getMessage()); |
| | | }finally { |
| | | if(businessServiceDataFlow == null){ |
| | | return null; |
| | | } |
| | | |
| | | //这里记录日志 |
| | | Date endDate = DateUtil.getCurrentDate(); |
| | | |
| | | businessServiceDataFlow.setEndDate(endDate); |
| | | //添加耗时 |
| | | DataFlowFactory.addCostTime(businessServiceDataFlow, "service", "业务处理总耗时", |
| | | businessServiceDataFlow.getStartDate(), businessServiceDataFlow.getEndDate()); |
| | | //保存耗时 |
| | | saveCostTimeLogMessage(businessServiceDataFlow); |
| | | //保存日志 |
| | | saveLogMessage(businessServiceDataFlow); |
| | | } |
| | | return businessServiceDataFlow.getResJson(); |
| | | } |
| | | |
| | | /** |
| | | * 保存日志信息 |
| | | * @param businessServiceDataFlow |
| | | */ |
| | | private void saveLogMessage(BusinessServiceDataFlow businessServiceDataFlow){ |
| | | |
| | | try{ |
| | | if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_LOG_ON_OFF))){ |
| | | for(DataFlowLog dataFlowLog :businessServiceDataFlow.getLogDatas()) { |
| | | KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_LOG_NAME, "", JSONObject.toJSONString(dataFlowLog)); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | logger.error("报错日志出错了,",e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存耗时信息 |
| | | * @param businessServiceDataFlow |
| | | */ |
| | | private void saveCostTimeLogMessage(BusinessServiceDataFlow businessServiceDataFlow){ |
| | | try{ |
| | | if(MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))){ |
| | | List<DataFlowLinksCost> dataFlowLinksCosts = businessServiceDataFlow.getLinksCostDates(); |
| | | JSONObject costDate = new JSONObject(); |
| | | JSONArray costDates = new JSONArray(); |
| | | JSONObject newObj = null; |
| | | for(DataFlowLinksCost dataFlowLinksCost : dataFlowLinksCosts){ |
| | | newObj = JSONObject.parseObject(JSONObject.toJSONString(dataFlowLinksCost)); |
| | | newObj.put("dataFlowId",businessServiceDataFlow.getDataFlowId()); |
| | | newObj.put("transactionId",businessServiceDataFlow.getTransactionId()); |
| | | costDates.add(newObj); |
| | | } |
| | | costDate.put("costDates",costDates); |
| | | |
| | | KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME,"",costDate.toJSONString()); |
| | | } |
| | | }catch (Exception e){ |
| | | logger.error("报错日志出错了,",e); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | jedis: |
| | | pool: |
| | | config: |
| | | maxTotal: 100 |
| | | maxIdle: 20 |
| | | maxWaitMillis: 20000 |
| | | host: 192.168.31.199 |
| | | port: 6379 |
| | | |
| | | eureka: |
| | | instance: |
| | | leaseRenewalIntervalInSeconds: 10 |
| | | leaseExpirationDurationInSeconds: 30 |
| | | client: |
| | | serviceUrl: |
| | | defaultZone: http://192.168.31.199:8761/eureka/ |
| | | #defaultZone: http://localhost:8761/eureka/ |
| | | server: |
| | | port: 8007 |
| | | tomcat: |
| | | uri-encoding: UTF-8 |
| | | |
| | | spring: |
| | | http: |
| | | encoding: |
| | | charset: UTF-8 |
| | | enabled: true |
| | | force: true |
| | | application: |
| | | name: shop-service |
| | | redis: |
| | | database: 0 |
| | | host: 192.168.31.199 |
| | | port: 6379 |
| | | pool: |
| | | max-active: 300 |
| | | max-wait: 10000 |
| | | max-idle: 100 |
| | | min-idle: 0 |
| | | timeout: 0 |
| | | datasource: |
| | | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 |
| | | minIdle: 5 |
| | | validationQuery: SELECT 1 FROM DUAL |
| | | initialSize: 5 |
| | | maxWait: 60000 |
| | | filters: stat,wall,log4j |
| | | poolPreparedStatements: true |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | url: jdbc:mysql://192.168.31.199:3306/TT?useUnicode=true&characterEncoding=utf-8 |
| | | maxPoolPreparedStatementPerConnectionSize: 20 |
| | | password: TT@12345678 |
| | | testOnBorrow: false |
| | | testWhileIdle: true |
| | | minEvictableIdleTimeMillis: 300000 |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | testOnReturn: false |
| | | driverClassName: com.mysql.jdbc.Driver |
| | | maxActive: 20 |
| | | username: TT |
| | | |
| | | #============== kafka =================== |
| | | kafka: |
| | | consumer: |
| | | zookeeper: |
| | | connect: 192.168.31.199:2181 |
| | | servers: 192.168.31.199:9092 |
| | | enable: |
| | | auto: |
| | | commit: true |
| | | session: |
| | | timeout: 6000 |
| | | auto: |
| | | commit: |
| | | interval: 100 |
| | | offset: |
| | | reset: latest |
| | | topic: test |
| | | group: |
| | | id: storeBusinessStatus |
| | | concurrency: 10 |
| | | |
| | | producer: |
| | | zookeeper: |
| | | connect: 192.168.31.199:2181 |
| | | servers: 192.168.31.199:9092 |
| | | retries: 0 |
| | | batch: |
| | | size: 4096 |
| | | linger: 1 |
| | | buffer: |
| | | memory: 40960 |
| New file |
| | |
| | | jedis: |
| | | pool: |
| | | config: |
| | | maxTotal: 100 |
| | | maxIdle: 20 |
| | | maxWaitMillis: 20000 |
| | | host: 135.192.86.200 |
| | | port: 6379 |
| | | |
| | | eureka: |
| | | instance: |
| | | leaseRenewalIntervalInSeconds: 10 |
| | | leaseExpirationDurationInSeconds: 30 |
| | | client: |
| | | serviceUrl: |
| | | defaultZone: http://135.192.86.200:8761/eureka/ |
| | | #defaultZone: http://localhost:8761/eureka/ |
| | | server: |
| | | port: 8007 |
| | | tomcat: |
| | | uri-encoding: UTF-8 |
| | | |
| | | spring: |
| | | http: |
| | | encoding: |
| | | charset: UTF-8 |
| | | enabled: true |
| | | force: true |
| | | application: |
| | | name: shop-service |
| | | redis: |
| | | database: 0 |
| | | host: 135.192.86.200 |
| | | port: 6379 |
| | | pool: |
| | | max-active: 300 |
| | | max-wait: 10000 |
| | | max-idle: 100 |
| | | min-idle: 0 |
| | | timeout: 0 |
| | | datasource: |
| | | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 |
| | | minIdle: 5 |
| | | validationQuery: SELECT 1 FROM DUAL |
| | | initialSize: 5 |
| | | maxWait: 60000 |
| | | filters: stat,wall,log4j |
| | | poolPreparedStatements: true |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | url: jdbc:mysql://135.192.86.200:3306/TT?useUnicode=true&characterEncoding=utf-8 |
| | | maxPoolPreparedStatementPerConnectionSize: 20 |
| | | password: TT@12345678 |
| | | testOnBorrow: false |
| | | testWhileIdle: true |
| | | minEvictableIdleTimeMillis: 300000 |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | testOnReturn: false |
| | | driverClassName: com.mysql.jdbc.Driver |
| | | maxActive: 20 |
| | | username: TT |
| | | |
| | | #============== kafka =================== |
| | | kafka: |
| | | consumer: |
| | | zookeeper: |
| | | connect: 135.192.86.200:2181 |
| | | servers: 135.192.86.200:9092 |
| | | enable: |
| | | auto: |
| | | commit: true |
| | | session: |
| | | timeout: 6000 |
| | | auto: |
| | | commit: |
| | | interval: 100 |
| | | offset: |
| | | reset: latest |
| | | topic: test |
| | | group: |
| | | id: storeBusinessStatus |
| | | concurrency: 10 |
| | | |
| | | producer: |
| | | zookeeper: |
| | | connect: 135.192.86.200:2181 |
| | | servers: 135.192.86.200:9092 |
| | | retries: 0 |
| | | batch: |
| | | size: 4096 |
| | | linger: 1 |
| | | buffer: |
| | | memory: 40960 |
| New file |
| | |
| | | jedis: |
| | | pool: |
| | | config: |
| | | maxTotal: 100 |
| | | maxIdle: 20 |
| | | maxWaitMillis: 20000 |
| | | host: 135.192.86.200 |
| | | port: 6379 |
| | | |
| | | eureka: |
| | | instance: |
| | | leaseRenewalIntervalInSeconds: 10 |
| | | leaseExpirationDurationInSeconds: 30 |
| | | client: |
| | | serviceUrl: |
| | | defaultZone: http://135.192.86.200:8761/eureka/ |
| | | #defaultZone: http://localhost:8761/eureka/ |
| | | server: |
| | | port: 8007 |
| | | tomcat: |
| | | uri-encoding: UTF-8 |
| | | |
| | | spring: |
| | | http: |
| | | encoding: |
| | | charset: UTF-8 |
| | | enabled: true |
| | | force: true |
| | | application: |
| | | name: shop-service |
| | | redis: |
| | | database: 0 |
| | | host: 135.192.86.200 |
| | | port: 6379 |
| | | pool: |
| | | max-active: 300 |
| | | max-wait: 10000 |
| | | max-idle: 100 |
| | | min-idle: 0 |
| | | timeout: 0 |
| | | datasource: |
| | | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 |
| | | minIdle: 5 |
| | | validationQuery: SELECT 1 FROM DUAL |
| | | initialSize: 5 |
| | | maxWait: 60000 |
| | | filters: stat,wall,log4j |
| | | poolPreparedStatements: true |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | url: jdbc:mysql://135.192.86.200:3306/TT?useUnicode=true&characterEncoding=utf-8 |
| | | maxPoolPreparedStatementPerConnectionSize: 20 |
| | | password: TT@12345678 |
| | | testOnBorrow: false |
| | | testWhileIdle: true |
| | | minEvictableIdleTimeMillis: 300000 |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | testOnReturn: false |
| | | driverClassName: com.mysql.jdbc.Driver |
| | | maxActive: 20 |
| | | username: TT |
| | | |
| | | #============== kafka =================== |
| | | kafka: |
| | | consumer: |
| | | zookeeper: |
| | | connect: 135.192.86.200:2181 |
| | | servers: 135.192.86.200:9092 |
| | | enable: |
| | | auto: |
| | | commit: true |
| | | session: |
| | | timeout: 6000 |
| | | auto: |
| | | commit: |
| | | interval: 100 |
| | | offset: |
| | | reset: latest |
| | | topic: test |
| | | group: |
| | | id: storeBusinessStatus |
| | | concurrency: 10 |
| | | |
| | | producer: |
| | | zookeeper: |
| | | connect: 135.192.86.200:2181 |
| | | servers: 135.192.86.200:9092 |
| | | retries: 0 |
| | | batch: |
| | | size: 4096 |
| | | linger: 1 |
| | | buffer: |
| | | memory: 40960 |
| New file |
| | |
| | | spring: |
| | | profiles: |
| | | active: test |
| New file |
| | |
| | | ${AnsiColor.BRIGHT_RED} |
| | | _ ___ ___ ____ _____ __ _____ _ |
| | | (_) ____ _ _ __ ____ _ < / < / / __ \ / ___/ / /_ ____ ____ / ___/ ___ _____ _ __ (_) _____ ___ |
| | | / / / __ `/| | / / / __ `/ / / / / / / / / \__ \ / __ \ / __ \ / __ \ \__ \ / _ \ / ___/| | / / / / / ___/ / _ \ |
| | | / / / /_/ / | |/ / / /_/ / / / / / / /_/ / ___/ / / / / // /_/ / / /_/ / ___/ / / __/ / / | |/ / / / / /__ / __/ |
| | | __/ / \__,_/ |___/ \__,_/ /_/ /_/ \____/ /____/ /_/ /_/ \____/ / .___/ /____/ \___/ /_/ |___/ /_/ \___/ \___/ |
| | | /___/ /_/ |
| | | |
| | | java110 ShopService starting, more information scan https://github.com/java110/MicroCommunity |
| New file |
| | |
| | | package com.java110; |
| | | |
| | | |
| | | /** |
| | | * Unit test for simple App. |
| | | */ |
| | | public class AppTest |
| | | { |
| | | /** |
| | | * Rigorous Test :-) |
| | | */ |
| | | |
| | | public void shouldAnswerWithTrue() |
| | | { |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | -- create 商品表 |
| | | create table business_shop( |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | | `name` VARCHAR(100) NOT NULL COMMENT '商品名称', |
| | | hot_buy varchar(2) not null default 'N' comment '是否热卖 Y是 N否', |
| | | sale_price DECIMAL(10,2) not null comment '商品销售价,再没有打折情况下显示', |
| | | open_shop_count varchar(2) not null default 'N' comment '是否开启库存管理,默认N Y开启,N关闭,开启后界面显示数量,如果为0 则下架', |
| | | shop_count DECIMAL(10,0) not null default 10000 comment '商品库存', |
| | | start_date date not null comment '商品开始时间', |
| | | end_date date not null comment '商品结束时间', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL' |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION business_shop_1 VALUES LESS THAN (2), |
| | | PARTITION business_shop_2 VALUES LESS THAN (3), |
| | | PARTITION business_shop_3 VALUES LESS THAN (4), |
| | | PARTITION business_shop_4 VALUES LESS THAN (5), |
| | | PARTITION business_shop_5 VALUES LESS THAN (6), |
| | | PARTITION business_shop_6 VALUES LESS THAN (7), |
| | | PARTITION business_shop_7 VALUES LESS THAN (8), |
| | | PARTITION business_shop_8 VALUES LESS THAN (9), |
| | | PARTITION business_shop_9 VALUES LESS THAN (10), |
| | | PARTITION business_shop_10 VALUES LESS THAN (11), |
| | | PARTITION business_shop_11 VALUES LESS THAN (12), |
| | | PARTITION business_shop_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_shop_shop_id ON business_shop(shop_id); |
| | | CREATE INDEX idx_business_shop_b_id ON business_shop(b_id); |
| | | -- 商品属性表 |
| | | create table business_shop_attr( |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | | attr_id VARCHAR(30) NOT NULL COMMENT '属性id', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表', |
| | | value VARCHAR(50) NOT NULL COMMENT '属性值', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL' |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION business_shop_attr_1 VALUES LESS THAN (2), |
| | | PARTITION business_shop_attr_2 VALUES LESS THAN (3), |
| | | PARTITION business_shop_attr_3 VALUES LESS THAN (4), |
| | | PARTITION business_shop_attr_4 VALUES LESS THAN (5), |
| | | PARTITION business_shop_attr_5 VALUES LESS THAN (6), |
| | | PARTITION business_shop_attr_6 VALUES LESS THAN (7), |
| | | PARTITION business_shop_attr_7 VALUES LESS THAN (8), |
| | | PARTITION business_shop_attr_8 VALUES LESS THAN (9), |
| | | PARTITION business_shop_attr_9 VALUES LESS THAN (10), |
| | | PARTITION business_shop_attr_10 VALUES LESS THAN (11), |
| | | PARTITION business_shop_attr_11 VALUES LESS THAN (12), |
| | | PARTITION business_shop_attr_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_shop_attr_shop_id ON business_shop_attr(shop_id); |
| | | CREATE INDEX idx_business_shop_attr_b_id ON business_shop_attr(b_id); |
| | | |
| | | -- 商品属性 离散值表,例如 手机颜色 黑 白 红 |
| | | create table business_shop_attr_param( |
| | | attr_param_id VARCHAR(30) NOT NULL COMMENT '商品属性参数ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表', |
| | | param VARCHAR(50) NOT NULL COMMENT '参数值', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL' |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION business_shop_attr_param_1 VALUES LESS THAN (2), |
| | | PARTITION business_shop_attr_param_2 VALUES LESS THAN (3), |
| | | PARTITION business_shop_attr_param_3 VALUES LESS THAN (4), |
| | | PARTITION business_shop_attr_param_4 VALUES LESS THAN (5), |
| | | PARTITION business_shop_attr_param_5 VALUES LESS THAN (6), |
| | | PARTITION business_shop_attr_param_6 VALUES LESS THAN (7), |
| | | PARTITION business_shop_attr_param_7 VALUES LESS THAN (8), |
| | | PARTITION business_shop_attr_param_8 VALUES LESS THAN (9), |
| | | PARTITION business_shop_attr_param_9 VALUES LESS THAN (10), |
| | | PARTITION business_shop_attr_param_10 VALUES LESS THAN (11), |
| | | PARTITION business_shop_attr_param_11 VALUES LESS THAN (12), |
| | | PARTITION business_shop_attr_param_12 VALUES LESS THAN (13) |
| | | ); |
| | | |
| | | CREATE INDEX idx_business_shop_attr_param_shop_id ON business_shop_attr_param(shop_id); |
| | | CREATE INDEX idx_business_shop_attr_param_b_id ON business_shop_attr_param(b_id); |
| | | |
| | | -- 商品优惠表 |
| | | create table business_shop_preferential( |
| | | shop_preferential_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | original_price DECIMAL(10,2) not null comment '商品销售价,再没有优惠的情况下和售价是一致的', |
| | | discount_rate decimal(1,2) not null default 1.00 comment '商品打折率', |
| | | show_original_price varchar(2) not null default 'N' comment '是否显示原价,Y显示,N 不显示', |
| | | preferential_start_date not null comment '商品优惠开始时间', |
| | | preferential_end_date date not null comment '商品优惠结束时间', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL' |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION business_shop_preferential_1 VALUES LESS THAN (2), |
| | | PARTITION business_shop_preferential_2 VALUES LESS THAN (3), |
| | | PARTITION business_shop_preferential_3 VALUES LESS THAN (4), |
| | | PARTITION business_shop_preferential_4 VALUES LESS THAN (5), |
| | | PARTITION business_shop_preferential_5 VALUES LESS THAN (6), |
| | | PARTITION business_shop_preferential_6 VALUES LESS THAN (7), |
| | | PARTITION business_shop_preferential_7 VALUES LESS THAN (8), |
| | | PARTITION business_shop_preferential_8 VALUES LESS THAN (9), |
| | | PARTITION business_shop_preferential_9 VALUES LESS THAN (10), |
| | | PARTITION business_shop_preferential_10 VALUES LESS THAN (11), |
| | | PARTITION business_shop_preferential_11 VALUES LESS THAN (12), |
| | | PARTITION business_shop_preferential_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_shop_preferential_shop_id ON business_shop_preferential(shop_id); |
| | | CREATE INDEX idx_business_shop_preferential_b_id ON business_shop_preferential(b_id); |
| | | -- 商品描述 |
| | | create table business_shop_desc( |
| | | shop_desc_id VARCHAR(30) NOT NULL COMMENT '商品描述ID', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | shop_describe LONGTEXT not null COMMENT '商品描述', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL' |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION business_shop_desc_1 VALUES LESS THAN (2), |
| | | PARTITION business_shop_desc_2 VALUES LESS THAN (3), |
| | | PARTITION business_shop_desc_3 VALUES LESS THAN (4), |
| | | PARTITION business_shop_desc_4 VALUES LESS THAN (5), |
| | | PARTITION business_shop_desc_5 VALUES LESS THAN (6), |
| | | PARTITION business_shop_desc_6 VALUES LESS THAN (7), |
| | | PARTITION business_shop_desc_7 VALUES LESS THAN (8), |
| | | PARTITION business_shop_desc_8 VALUES LESS THAN (9), |
| | | PARTITION business_shop_desc_9 VALUES LESS THAN (10), |
| | | PARTITION business_shop_desc_10 VALUES LESS THAN (11), |
| | | PARTITION business_shop_desc_11 VALUES LESS THAN (12), |
| | | PARTITION business_shop_desc_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_shop_desc_shop_id ON business_shop_desc(shop_id); |
| | | CREATE INDEX idx_business_shop_desc_b_id ON business_shop_desc(b_id); |
| | | |
| | | |
| | | -- create 商品表 |
| | | create table s_shop( |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | | `name` VARCHAR(100) NOT NULL COMMENT '商品名称', |
| | | hot_buy varchar(2) not null default 'N' comment '是否热卖 Y是 N否', |
| | | sale_price DECIMAL(10,2) not null comment '商品销售价,再没有打折情况下显示', |
| | | open_shop_count varchar(2) not null default 'N' comment '是否开启库存管理,默认N Y开启,N关闭,开启后界面显示数量,如果为0 则下架', |
| | | shop_count DECIMAL(10,0) not null default 10000 comment '商品库存', |
| | | start_date date not null comment '商品开始时间', |
| | | end_date date not null comment '商品结束时间', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (shop_id) |
| | | ); |
| | | CREATE INDEX idx_store_b_id ON s_shop(b_id); |
| | | CREATE UNIQUE INDEX idx_shop_shop_id ON s_shop(shop_id); |
| | | -- 商品属性表 |
| | | create table s_shop_attr( |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | | attr_id VARCHAR(30) NOT NULL COMMENT '属性id', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表', |
| | | value VARCHAR(50) NOT NULL COMMENT '属性值', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (attr_id) |
| | | ); |
| | | CREATE INDEX idx_store_attr_b_id ON s_shop_attr(b_id); |
| | | CREATE INDEX idx_shop_attr_shop_id ON s_shop_attr(shop_id); |
| | | |
| | | -- 商品属性 离散值表,例如 手机颜色 黑 白 红 |
| | | create table s_shop_attr_param( |
| | | attr_param_id VARCHAR(30) NOT NULL COMMENT '商品属性参数ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表', |
| | | param VARCHAR(50) NOT NULL COMMENT '参数值', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (attr_param_id) |
| | | ); |
| | | CREATE INDEX idx_shop_attr_param_b_id ON s_shop_attr_param(b_id); |
| | | CREATE INDEX idx_shop_attr_param_shop_id ON s_shop_attr_param(shop_id); |
| | | |
| | | -- 商品优惠表 |
| | | create table s_shop_preferential( |
| | | shop_preferential_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | original_price DECIMAL(10,2) not null comment '商品销售价,再没有优惠的情况下和售价是一致的', |
| | | discount_rate decimal(1,2) not null default 1.00 comment '商品打折率', |
| | | show_original_price varchar(2) not null default 'N' comment '是否显示原价,Y显示,N 不显示', |
| | | preferential_start_date not null comment '商品优惠开始时间', |
| | | preferential_end_date date not null comment '商品优惠结束时间', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (shop_preferential_id) |
| | | ); |
| | | CREATE INDEX idx_shop_preferential_b_id ON s_shop_preferential(b_id); |
| | | CREATE INDEX idx_shop_preferential_shop_id ON s_shop_preferential(shop_id); |
| | | -- 商品描述 |
| | | create table s_shop_desc( |
| | | shop_desc_id VARCHAR(30) NOT NULL COMMENT '商品描述ID', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | shop_describe LONGTEXT not null COMMENT '商品描述', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (shop_desc_id) |
| | | ); |
| | | CREATE INDEX idx_shop_desc_b_id ON s_shop_desc(b_id); |
| | | CREATE INDEX idx_shop_desc_shop_id ON s_shop_desc(shop_id); |
| | | |
| | | -- 商品购买记录 |
| | | |
| | | create table s_buy_shop( |
| | | buy_id varchar(30) not null comment '购买ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | shop_id VARCHAR(30) NOT NULL COMMENT '商品ID', |
| | | buy_count DECIMAL(10,0) not null default 1 comment '购买商品数', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (buy_id) |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION buy_shop_1 VALUES LESS THAN (2), |
| | | PARTITION buy_shop_2 VALUES LESS THAN (3), |
| | | PARTITION buy_shop_3 VALUES LESS THAN (4), |
| | | PARTITION buy_shop_4 VALUES LESS THAN (5), |
| | | PARTITION buy_shop_5 VALUES LESS THAN (6), |
| | | PARTITION buy_shop_6 VALUES LESS THAN (7), |
| | | PARTITION buy_shop_7 VALUES LESS THAN (8), |
| | | PARTITION buy_shop_8 VALUES LESS THAN (9), |
| | | PARTITION buy_shop_9 VALUES LESS THAN (10), |
| | | PARTITION buy_shop_10 VALUES LESS THAN (11), |
| | | PARTITION buy_shop_11 VALUES LESS THAN (12), |
| | | PARTITION buy_shop_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_buy_shop_b_id ON s_buy_shop(b_id); |
| | | -- 商品购买属性 |
| | | create table s_buy_shop_attr( |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | | attr_id VARCHAR(30) NOT NULL COMMENT '属性id', |
| | | buy_id VARCHAR(30) NOT NULL COMMENT '购买ID buy_id', |
| | | spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表', |
| | | value VARCHAR(50) NOT NULL COMMENT '属性值', |
| | | `month` INT NOT NULL COMMENT '月份', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (attr_id) |
| | | ) |
| | | PARTITION BY RANGE (`month`) ( |
| | | PARTITION buy_shop_attr_1 VALUES LESS THAN (2), |
| | | PARTITION buy_shop_attr_2 VALUES LESS THAN (3), |
| | | PARTITION buy_shop_attr_3 VALUES LESS THAN (4), |
| | | PARTITION buy_shop_attr_4 VALUES LESS THAN (5), |
| | | PARTITION buy_shop_attr_5 VALUES LESS THAN (6), |
| | | PARTITION buy_shop_attr_6 VALUES LESS THAN (7), |
| | | PARTITION buy_shop_attr_7 VALUES LESS THAN (8), |
| | | PARTITION buy_shop_attr_8 VALUES LESS THAN (9), |
| | | PARTITION buy_shop_attr_9 VALUES LESS THAN (10), |
| | | PARTITION buy_shop_attr_10 VALUES LESS THAN (11), |
| | | PARTITION buy_shop_attr_11 VALUES LESS THAN (12), |
| | | PARTITION buy_shop_attr_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_buy_shop_attr_b_id ON s_buy_shop_attr(b_id); |
| | | CREATE INDEX idx_buy_shop_attr_buy_id ON s_buy_shop_attr(buy_id); |
| | |
| | | |
| | | |
| | | CREATE TABLE s_store( |
| | | id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | user_id VARCHAR(30) NOT NULL COMMENT '用户ID', |
| | |
| | | CREATE UNIQUE INDEX idx_store_store_id ON s_store(store_id); |
| | | |
| | | CREATE TABLE s_store_attr( |
| | | id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | | attr_id VARCHAR(30) NOT NULL COMMENT '属性id', |
| | | store_id VARCHAR(30) NOT NULL COMMENT '用户ID', |
| | |
| | | |
| | | -- 商店照片 |
| | | CREATE TABLE s_store_photo( |
| | | id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', |
| | | store_photo_id VARCHAR(30) NOT NULL COMMENT '商户照片ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | |
| | | |
| | | -- 商户证件 |
| | | create table s_store_cerdentials( |
| | | id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', |
| | | store_cerdentials_id varchar(30) not null comment '商户证件ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | |
| | | <module>ConsoleService</module> |
| | | <module>java110-logAgent</module> |
| | | <module>zipkin</module> |
| | | <module>ShopService</module> |
| | | </modules> |
| | | |
| | | <parent> |