| | |
| | | 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.store.dao.IStoreServiceDao; |
| | | import org.slf4j.Logger; |
| | |
| | | */ |
| | | @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); |
| | |
| | | */ |
| | | @Override |
| | | public void saveBusinessStoreAttr(Map businessStoreAttr) throws DAOException { |
| | | businessStoreAttr.put("month", DateUtil.getCurrentMonth()); |
| | | // 查询business_user 数据是否已经存在 |
| | | logger.debug("保存商户属性信息 入参 businessStoreAttr : {}",businessStoreAttr); |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void saveBusinessStorePhoto(Map businessStorePhoto) throws DAOException { |
| | | |
| | | businessStorePhoto.put("month", DateUtil.getCurrentMonth()); |
| | | logger.debug("保存商户照片信息 入参 businessStorePhoto : {}",businessStorePhoto); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStorePhoto",businessStorePhoto); |
| | |
| | | */ |
| | | @Override |
| | | public void saveBusinessStoreCerdentials(Map businessStoreCerdentials) throws DAOException { |
| | | businessStoreCerdentials.put("month", DateUtil.getCurrentMonth()); |
| | | logger.debug("保存商户证件信息 入参 businessStoreCerdentials : {}",businessStoreCerdentials); |
| | | |
| | | int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStoreCerdentials",businessStoreCerdentials); |
| | |
| | | logger.debug("查询商户信息 入参 info : {}",info); |
| | | |
| | | List<Map> businessStoreInfos = sqlSessionTemplate.selectList("storeServiceDaoImpl.getStoreInfo",info); |
| | | if(businessStoreInfos == null){ |
| | | if(businessStoreInfos == null || businessStoreInfos.size() == 0){ |
| | | return null; |
| | | } |
| | | if(businessStoreInfos.size() >1){ |
| | |
| | | @Autowired |
| | | private IStoreServiceSMO storeServiceSMOImpl; |
| | | |
| | | @KafkaListener(topics = {"userServiceTopic"}) |
| | | @KafkaListener(topics = {"storeServiceTopic"}) |
| | | public void listen(ConsumerRecord<?, ?> record) { |
| | | logger.info("kafka的key: " + record.key()); |
| | | logger.info("kafka的value: " + record.value().toString()); |
| | |
| | | currentStoreCerdentials.put("positivePhoto",currentStoreCerdentials.get("positive_photo")); |
| | | currentStoreCerdentials.put("negativePhoto",currentStoreCerdentials.get("negative_photo")); |
| | | currentStoreCerdentials.put("operate",StatusConstant.OPERATE_DEL); |
| | | getStoreServiceDaoImpl().saveBusinessStoreAttr(currentStoreCerdentials); |
| | | getStoreServiceDaoImpl().saveBusinessStoreCerdentials(currentStoreCerdentials); |
| | | } |
| | | } |
| | |
| | | protected void doBusinessToInstance(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 = storeServiceDaoImpl.getStoreInfo(info); |
| | | if(storeInfo != null && !storeInfo.isEmpty()){ |
| | | paramIn.put("storeId",storeInfo.get("store_id").toString()); |
| | | storeServiceDaoImpl.updateStoreInfoInstance(paramIn); |
| | | dataFlowContext.addParamOut("storeId",storeInfo.get("store_id")); |
| | | } |
| | | Map info = new HashMap(); |
| | | info.put("bId",business.getbId()); |
| | | info.put("operate",StatusConstant.OPERATE_DEL); |
| | | |
| | | //商户信息 |
| | | Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(info); |
| | | if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) { |
| | | flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_INVALID); |
| | | storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo); |
| | | dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id")); |
| | | } |
| | | //商户属性 |
| | | List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info); |
| | | if(storeAttrs != null && storeAttrs.size()>0){ |
| | | storeServiceDaoImpl.updateStoreAttrInstance(paramIn); |
| | | List<Map> businessStoreAttrs = storeServiceDaoImpl.getBusinessStoreAttrs(info); |
| | | if(businessStoreAttrs != null && businessStoreAttrs.size() > 0) { |
| | | for(Map businessStoreAttr : businessStoreAttrs) { |
| | | flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_INVALID); |
| | | storeServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr); |
| | | } |
| | | } |
| | | |
| | | //商户照片 |
| | | List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info); |
| | | if(storePhotos != null && storePhotos.size()>0){ |
| | | storeServiceDaoImpl.updateStorePhotoInstance(paramIn); |
| | | List<Map> businessStorePhotos = storeServiceDaoImpl.getBusinessStorePhoto(info); |
| | | if(businessStorePhotos != null && businessStorePhotos.size() >0){ |
| | | for(Map businessStorePhoto : businessStorePhotos) { |
| | | flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_INVALID); |
| | | storeServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto); |
| | | } |
| | | } |
| | | |
| | | //商户属性 |
| | | List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info); |
| | | if(storeCerdentialses != null && storeCerdentialses.size()>0){ |
| | | storeServiceDaoImpl.updateStoreCerdentailsInstance(paramIn); |
| | | //商户证件 |
| | | List<Map> businessStoreCerdentialses = storeServiceDaoImpl.getBusinessStoreCerdentials(info); |
| | | if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){ |
| | | for(Map businessStoreCerdentials : businessStoreCerdentialses) { |
| | | flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_INVALID); |
| | | storeServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) { |
| | | |
| | | Map info = null; |
| | | Map currentStorePhoto = null; |
| | | for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) { |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStorePhoto.getLong("storePhotoId") < 0) { |
| | | if (businessStorePhoto.getString("storePhotoId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto); |
| | | } |
| | | |
| | |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getLong("storeId") < 0){ |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore); |
| | | } |
| | | //自动插入DEL |
| | |
| | | for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){ |
| | | JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex); |
| | | Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点"); |
| | | if(storeAttr.getLong("attrId") < 0){ |
| | | if(storeAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr); |
| | | } |
| | | |
| | |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) { |
| | | if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials); |
| | | } |
| | | |
| | |
| | | |
| | | 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 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; |
| | |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStorePhoto.getLong("storePhotoId") < 0) { |
| | | if (businessStorePhoto.getString("storePhotoId").startsWith("-")) { |
| | | String storePhotoId = GenerateCodeFactory.getStorePhotoId(); |
| | | businessStorePhoto.put("storePhotoId", storePhotoId); |
| | | } |
| | |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getInteger("storeId") < 0){ |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | //刷新缓存 |
| | | flushStoreId(business.getDatas()); |
| | | } |
| | | |
| | | |
| | | businessStore.put("bId",business.getbId()); |
| | | businessStore.put("operate", StatusConstant.OPERATE_ADD); |
| | |
| | | JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex); |
| | | Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点"); |
| | | |
| | | if(storeAttr.getInteger("attrId") < 0){ |
| | | if(storeAttr.getString("attrId").startsWith("-")){ |
| | | String attrId = GenerateCodeFactory.getAttrId(); |
| | | storeAttr.put("attrId",attrId); |
| | | } |
| | |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) { |
| | | 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); |
| | | //保存商户信息 |
| | |
| | | JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex); |
| | | Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStorePhoto.getLong("storePhotoId") < 0) { |
| | | if (businessStorePhoto.getString("storePhotoId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto); |
| | | } |
| | | |
| | |
| | | |
| | | Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点"); |
| | | |
| | | if(businessStore.getLong("storeId") < 0){ |
| | | if(businessStore.getString("storeId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore); |
| | | } |
| | | //自动保存DEL |
| | |
| | | for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){ |
| | | JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex); |
| | | Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点"); |
| | | if(storeAttr.getLong("attrId") < 0){ |
| | | if(storeAttr.getString("attrId").startsWith("-")){ |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr); |
| | | } |
| | | //自动保存DEL数据 |
| | |
| | | JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex); |
| | | Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点"); |
| | | |
| | | if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) { |
| | | if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials); |
| | | } |
| | | |
| | |
| | | package com.java110.common.util; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | return calendar.get(Calendar.MONTH)+1; |
| | | } |
| | | |
| | | public static Date getLastDate() throws ParseException { |
| | | return getDateFromString("3000-01-01",DATE_FORMATE_STRING_B); |
| | | } |
| | | |
| | | /** |
| | | * 转TimeStamp |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static Timestamp getTimestamp(Date date){ |
| | | Timestamp timestamp = new Timestamp(date.getTime()); |
| | | return timestamp; |
| | | } |
| | | /** |
| | | * 获取未来时间 |
| | | * @param second 秒 |
| | |
| | | INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id) |
| | | VALUES('save.user.userInfo','D','保存用户信息',1,'http://user-service/userApi/service','8000418003'); |
| | | |
| | | INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id) |
| | | VALUES('save.store.info','D','保存商户信息',1,'http://store-service/storeApi/service','8000418003'); |
| | | |
| | | INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id) |
| | | VALUES('update.store.info','D','修改商户信息',1,'http://store-service/storeApi/service','8000418003'); |
| | | |
| | | INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id) |
| | | VALUES('delete.store.info','D','删除商户信息',1,'http://store-service/storeApi/service','8000418003'); |
| | | |
| | | |
| | | INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id) |
| | | VALUES('transfer.console.menu','T','透传菜单查询',1,'http://192.168.31.199:8001/userApi/service','8000418001'); |
| | |
| | | -- store 表 过程表 |
| | | |
| | | create table business_store( |
| | | CREATE TABLE business_store( |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | | b_id VARCHAR(30) NOT NULL COMMENT '业务Id', |
| | | user_id VARCHAR(30) NOT NULL COMMENT '用户ID', |
| | | name varchar(100) not null comment '店铺名称', |
| | | address varchar(200) not null comment '店铺地址', |
| | | tel varchar(11) not null comment '电话', |
| | | store_type_cd varchar(10) not null commnet '店铺种类,对应表 store_type', |
| | | nearby_landmarks varchar(200) comment '地标,如王府井北60米', |
| | | map_x varchar(20) not null comment '地区 x坐标', |
| | | map_y varchar(20) not null comment '地区 y坐标', |
| | | `name` VARCHAR(100) NOT NULL COMMENT '店铺名称', |
| | | address VARCHAR(200) NOT NULL COMMENT '店铺地址', |
| | | tel VARCHAR(11) NOT NULL COMMENT '电话', |
| | | store_type_cd VARCHAR(10) NOT NULL COMMENT '店铺种类,对应表 store_type', |
| | | nearby_landmarks VARCHAR(200) COMMENT '地标,如王府井北60米', |
| | | map_x VARCHAR(20) NOT NULL COMMENT '地区 x坐标', |
| | | map_y VARCHAR(20) NOT NULL COMMENT '地区 y坐标', |
| | | `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_store_1 VALUES LESS THAN (2), |
| | | PARTITION business_store_2 VALUES LESS THAN (3), |
| | | PARTITION business_store_3 VALUES LESS THAN (4), |
| | | PARTITION business_store_4 VALUES LESS THAN (5), |
| | | PARTITION business_store_5 VALUES LESS THAN (6), |
| | | PARTITION business_store_6 VALUES LESS THAN (7), |
| | | PARTITION business_store_7 VALUES LESS THAN (8), |
| | | PARTITION business_store_8 VALUES LESS THAN (9), |
| | | PARTITION business_store_9 VALUES LESS THAN (10), |
| | | PARTITION business_store_10 VALUES LESS THAN (11), |
| | | PARTITION business_store_11 VALUES LESS THAN (12), |
| | | PARTITION business_store_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_store_store_id ON business_store(store_id); |
| | | CREATE INDEX idx_business_store_b_id ON business_store(b_id); |
| | | |
| | | create table business_store_attr( |
| | | b_id VARCHAR(30) NOT NULL COMMENT '订单ID', |
| | |
| | | store_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_store_attr_1 VALUES LESS THAN (2), |
| | | partition business_store_attr_2 VALUES LESS THAN (3), |
| | | partition business_store_attr_3 VALUES LESS THAN (4), |
| | | partition business_store_attr_4 VALUES LESS THAN (5), |
| | | partition business_store_attr_5 VALUES LESS THAN (6), |
| | | partition business_store_attr_6 VALUES LESS THAN (7), |
| | | partition business_store_attr_7 VALUES LESS THAN (8), |
| | | partition business_store_attr_8 VALUES LESS THAN (9), |
| | | partition business_store_attr_9 VALUES LESS THAN (10), |
| | | partition business_store_attr_10 VALUES LESS THAN (11), |
| | | partition business_store_attr_11 VALUES LESS THAN (12), |
| | | partition business_store_attr_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_store_attr_store_id ON business_store_attr(store_id); |
| | | CREATE INDEX idx_business_store_attr_b_id ON business_store_attr(b_id); |
| | | |
| | | -- 商店照片 |
| | | create table business_store_photo( |
| | | store_photo_id varchar(30) not null commnet '商户照片ID', |
| | | CREATE TABLE business_store_photo( |
| | | 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', |
| | | store_photo_type_cd varchar(12) not null comment '商户照片类型,T 门头照 I 内景照', |
| | | photo varchar(100) not null comment '照片', |
| | | store_photo_type_cd VARCHAR(12) NOT NULL COMMENT '商户照片类型,T 门头照 I 内景照', |
| | | photo VARCHAR(100) 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_store_photo_1 VALUES LESS THAN (2), |
| | | PARTITION business_store_photo_2 VALUES LESS THAN (3), |
| | | PARTITION business_store_photo_3 VALUES LESS THAN (4), |
| | | PARTITION business_store_photo_4 VALUES LESS THAN (5), |
| | | PARTITION business_store_photo_5 VALUES LESS THAN (6), |
| | | PARTITION business_store_photo_6 VALUES LESS THAN (7), |
| | | PARTITION business_store_photo_7 VALUES LESS THAN (8), |
| | | PARTITION business_store_photo_8 VALUES LESS THAN (9), |
| | | PARTITION business_store_photo_9 VALUES LESS THAN (10), |
| | | PARTITION business_store_photo_10 VALUES LESS THAN (11), |
| | | PARTITION business_store_photo_11 VALUES LESS THAN (12), |
| | | PARTITION business_store_photo_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_store_photo_store_id ON business_store_photo(store_id); |
| | | CREATE INDEX idx_business_store_photo_b_id ON business_store_photo(b_id); |
| | | -- 商户证件 |
| | | create table business_store_cerdentials( |
| | | store_cerdentials_id varchar(30) not null comment '商户证件ID', |
| | |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | | credentials_cd varchar(12) not null comment '证件类型,对应于 credentials表', |
| | | value varchar(50) not null comment '证件号码', |
| | | validity_period TIMESTAMP NOT NULL COMMENT '有效期,如果是长期有效 写成 3000/1/1', |
| | | validity_period DATE NOT NULL COMMENT '有效期,如果是长期有效 写成 3000/1/1', |
| | | positive_photo varchar(100) comment '正面照片', |
| | | negative_photo varchar(100) 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_store_cerdentials_1 VALUES LESS THAN (2), |
| | | partition business_store_cerdentials_2 VALUES LESS THAN (3), |
| | | partition business_store_cerdentials_3 VALUES LESS THAN (4), |
| | | partition business_store_cerdentials_4 VALUES LESS THAN (5), |
| | | partition business_store_cerdentials_5 VALUES LESS THAN (6), |
| | | partition business_store_cerdentials_6 VALUES LESS THAN (7), |
| | | partition business_store_cerdentials_7 VALUES LESS THAN (8), |
| | | partition business_store_cerdentials_8 VALUES LESS THAN (9), |
| | | partition business_store_cerdentials_9 VALUES LESS THAN (10), |
| | | partition business_store_cerdentials_10 VALUES LESS THAN (11), |
| | | partition business_store_cerdentials_11 VALUES LESS THAN (12), |
| | | partition business_store_cerdentials_12 VALUES LESS THAN (13) |
| | | ); |
| | | CREATE INDEX idx_business_store_cerdentials_store_id ON business_store_cerdentials(store_id); |
| | | CREATE INDEX idx_business_store_cerdentials_b_id ON business_store_cerdentials(b_id); |
| | | |
| | | |
| | | |
| | | create table s_store( |
| | | 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', |
| | | name varchar(100) not null comment '店铺名称', |
| | | address varchar(200) not null comment '店铺地址', |
| | | tel varchar(11) not null comment '电话', |
| | | store_type_cd varchar(10) not null commnet '店铺种类', |
| | | nearby_landmarks varchar(200) comment '地标,如王府井北60米', |
| | | map_x varchar(20) not null comment '地区 x坐标', |
| | | map_y varchar(20) not null comment '地区 y坐标', |
| | | `name` VARCHAR(100) NOT NULL COMMENT '店铺名称', |
| | | address VARCHAR(200) NOT NULL COMMENT '店铺地址', |
| | | tel VARCHAR(11) NOT NULL COMMENT '电话', |
| | | store_type_cd VARCHAR(10) NOT NULL COMMENT '店铺种类', |
| | | nearby_landmarks VARCHAR(200) COMMENT '地标,如王府井北60米', |
| | | map_x VARCHAR(20) NOT NULL COMMENT '地区 x坐标', |
| | | map_y VARCHAR(20) NOT NULL COMMENT '地区 y坐标', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效' |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (store_id) |
| | | ); |
| | | CREATE INDEX idx_store_b_id ON s_store(b_id); |
| | | CREATE UNIQUE INDEX idx_store_store_id ON s_store(store_id); |
| | | |
| | | create table s_store_attr( |
| | | 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', |
| | | spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表', |
| | | value VARCHAR(50) NOT NULL COMMENT '属性值', |
| | | 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失效' |
| | | 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_store_attr(b_id); |
| | | CREATE INDEX idx_store_attr_store_id ON s_store_attr(store_id); |
| | | |
| | | -- 商店照片 |
| | | create table s_store_photo( |
| | | CREATE TABLE s_store_photo( |
| | | id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', |
| | | store_photo_id varchar(30) not null commnet '商户照片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', |
| | | store_photo_type_cd varchar(12) not null comment '商户照片类型,T 门头照 I 内景照', |
| | | photo varchar(100) not null comment '照片', |
| | | store_photo_type_cd VARCHAR(12) NOT NULL COMMENT '商户照片类型,T 门头照 I 内景照', |
| | | photo VARCHAR(100) 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失效' |
| | | status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | UNIQUE KEY (store_photo_id) |
| | | ); |
| | | CREATE INDEX idx_store_photo_b_id ON s_store_photo(b_id); |
| | | CREATE INDEX idx_store_photo_store_id ON s_store_photo(store_id); |
| | | CREATE INDEX idx_store_photo_store_photo_id ON s_store_photo(store_photo_id); |
| | | |
| | | -- 商户证件 |
| | | create table s_store_cerdentials( |
| | | id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id', |
| | |
| | | store_id VARCHAR(30) NOT NULL COMMENT '商店ID', |
| | | credentials_cd varchar(12) not null comment '证件类型,对应于 credentials表', |
| | | value varchar(50) not null comment '证件号码', |
| | | validity_period TIMESTAMP NOT NULL COMMENT '有效期,如果是长期有效 写成 3000/1/1', |
| | | validity_period DATE NOT NULL COMMENT '有效期,如果是长期有效 写成 3000/1/1', |
| | | positive_photo varchar(100) comment '正面照片', |
| | | negative_photo varchar(100) comment '反面照片', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效' |
| | | status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效', |
| | | unique KEY (store_cerdentials_id) |
| | | ); |
| | | |
| | | CREATE INDEX idx_store_cerdentials_b_id ON s_store_cerdentials(b_id); |
| | | CREATE INDEX idx_store_cerdentials_store_id ON s_store_cerdentials(store_id); |
| | | CREATE INDEX idx_store_cerdentials_store_cerdentials_id ON s_store_cerdentials(store_cerdentials_id); |
| | | |
| | | -- 店铺种类 |
| | | create table store_type( |
| | |
| | | store_type_cd VARCHAR(12) NOT NULL COMMENT '店铺编码', |
| | | `name` VARCHAR(50) NOT NULL COMMENT '店铺种类编码', |
| | | description VARCHAR(200) COMMENT '描述', |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间' |
| | | create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | unique KEY (store_type_cd) |
| | | ); |
| | |
| | | |
| | | <!-- 保存商户信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessStoreInfo" parameterType="Map"> |
| | | insert into business_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,operate) |
| | | values(#{storeId},#{bId},#{userId},#{name},#{address},#{tel},#{storeTypeCd},#{nearbyLandmarks},#{mapX},#{mapY},#{operate}) |
| | | insert into business_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,month,operate) |
| | | values(#{storeId},#{bId},#{userId},#{name},#{address},#{tel},#{storeTypeCd},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate}) |
| | | </insert> |
| | | <!-- 保存商户属性信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessStoreAttr" parameterType="Map"> |
| | | insert into business_store_attr(b_id,attr_id,store_id,spec_cd,value,operate) |
| | | values(#{bId},#{attrId},#{storeId},#{specCd},#{value},#{operate}) |
| | | insert into business_store_attr(b_id,attr_id,store_id,spec_cd,value,month,operate) |
| | | values(#{bId},#{attrId},#{storeId},#{specCd},#{value},#{month},#{operate}) |
| | | </insert> |
| | | <!-- 保存商户照片信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessStorePhoto" parameterType="Map"> |
| | | insert into business_store_photo(store_photo_id,b_id,store_id,store_photo_type_cd,photo,operate) |
| | | values(#{storePhotoId},#{bId},#{storeId},#{storePhotoTypeCd},#{photo}) |
| | | insert into business_store_photo(store_photo_id,b_id,store_id,store_photo_type_cd,photo,month,operate) |
| | | values(#{storePhotoId},#{bId},#{storeId},#{storePhotoTypeCd},#{photo},#{month},#{operate}) |
| | | </insert> |
| | | <!-- 保存商户证件信息 add by wuxw 2018-07-03 --> |
| | | <insert id="saveBusinessStoreCerdentials" parameterType="Map"> |
| | | insert into business_store_cerdentials(store_cerdentials_id,b_id,store_id,credentials_cd,value,validity_period,positive_photo,negative_photo,operate) |
| | | values(#{storeCerdentialsId},#{bId},#{storeId},#{credentialsCd},#{value},#{validityPeriod},#{positivePhoto},#{negativePhoto},#{operate}) |
| | | insert into business_store_cerdentials(store_cerdentials_id,b_id,store_id,credentials_cd,value,validity_period,positive_photo,negative_photo,month,operate) |
| | | values(#{storeCerdentialsId},#{bId},#{storeId},#{credentialsCd},#{value},#{validityPeriod},#{positivePhoto},#{negativePhoto},#{month},#{operate}) |
| | | </insert> |
| | | |
| | | <!-- 查询商户信息(Business) add by wuxw 2018-07-03 --> |
| | |
| | | select sa.b_id,sa.attr_id,sa.store_id,sa.spec_cd,sa.value,sa.operate |
| | | from business_store_attr sa where 1=1 |
| | | <if test="operate != null and operate != ''"> |
| | | and s.operate = #{operate} |
| | | and sa.operate = #{operate} |
| | | </if> |
| | | <if test="bId != null and bId !=''"> |
| | | and sa.b_id = #{bId} |
| | |
| | | </select> |
| | | |
| | | <!-- 查询商户属性信息 add by wuxw 2018-07-03 --> |
| | | <select id="getStoreAttr" parameterType="Map" resultType="Map"> |
| | | <select id="getStoreAttrs" parameterType="Map" resultType="Map"> |
| | | select sa.b_id,sa.attr_id,sa.store_id,sa.spec_cd,sa.value,sa.status_cd |
| | | from s_store_attr sa |
| | | where |
| | |
| | | <if test="value != null and value != ''"> |
| | | ,sc.value = #{value} |
| | | </if> |
| | | <if test="validityPeriod != null and validityPeriod != ''"> |
| | | <if test="validityPeriod != null"> |
| | | ,sc.validity_period = #{validityPeriod} |
| | | </if> |
| | | <if test="positivePhoto != null and positivePhoto != ''"> |