Skip to content

Commit 248395e

Browse files
author
wuxw7
committed
商户服务功能测试通过
1 parent 9adbbca commit 248395e

10 files changed

Lines changed: 217 additions & 86 deletions

File tree

StoreService/src/main/java/com/java110/store/dao/impl/StoreServiceDaoImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alibaba.fastjson.JSONObject;
44
import com.java110.common.constant.ResponseConstant;
55
import com.java110.common.exception.DAOException;
6+
import com.java110.common.util.DateUtil;
67
import com.java110.core.base.dao.BaseServiceDao;
78
import com.java110.store.dao.IStoreServiceDao;
89
import org.slf4j.Logger;
@@ -30,6 +31,7 @@ public class StoreServiceDaoImpl extends BaseServiceDao implements IStoreService
3031
*/
3132
@Override
3233
public void saveBusinessStoreInfo(Map businessStoreInfo) throws DAOException {
34+
businessStoreInfo.put("month", DateUtil.getCurrentMonth());
3335
// 查询business_user 数据是否已经存在
3436
logger.debug("保存商户信息 入参 businessStoreInfo : {}",businessStoreInfo);
3537
int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStoreInfo",businessStoreInfo);
@@ -46,6 +48,7 @@ public void saveBusinessStoreInfo(Map businessStoreInfo) throws DAOException {
4648
*/
4749
@Override
4850
public void saveBusinessStoreAttr(Map businessStoreAttr) throws DAOException {
51+
businessStoreAttr.put("month", DateUtil.getCurrentMonth());
4952
// 查询business_user 数据是否已经存在
5053
logger.debug("保存商户属性信息 入参 businessStoreAttr : {}",businessStoreAttr);
5154

@@ -63,7 +66,7 @@ public void saveBusinessStoreAttr(Map businessStoreAttr) throws DAOException {
6366
*/
6467
@Override
6568
public void saveBusinessStorePhoto(Map businessStorePhoto) throws DAOException {
66-
69+
businessStorePhoto.put("month", DateUtil.getCurrentMonth());
6770
logger.debug("保存商户照片信息 入参 businessStorePhoto : {}",businessStorePhoto);
6871

6972
int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStorePhoto",businessStorePhoto);
@@ -80,6 +83,7 @@ public void saveBusinessStorePhoto(Map businessStorePhoto) throws DAOException {
8083
*/
8184
@Override
8285
public void saveBusinessStoreCerdentials(Map businessStoreCerdentials) throws DAOException {
86+
businessStoreCerdentials.put("month", DateUtil.getCurrentMonth());
8387
logger.debug("保存商户证件信息 入参 businessStoreCerdentials : {}",businessStoreCerdentials);
8488

8589
int saveFlag = sqlSessionTemplate.insert("storeServiceDaoImpl.saveBusinessStoreCerdentials",businessStoreCerdentials);
@@ -216,7 +220,7 @@ public Map getStoreInfo(Map info) throws DAOException {
216220
logger.debug("查询商户信息 入参 info : {}",info);
217221

218222
List<Map> businessStoreInfos = sqlSessionTemplate.selectList("storeServiceDaoImpl.getStoreInfo",info);
219-
if(businessStoreInfos == null){
223+
if(businessStoreInfos == null || businessStoreInfos.size() == 0){
220224
return null;
221225
}
222226
if(businessStoreInfos.size() >1){

StoreService/src/main/java/com/java110/store/kafka/StoreServiceKafka.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class StoreServiceKafka extends BaseController {
2727
@Autowired
2828
private IStoreServiceSMO storeServiceSMOImpl;
2929

30-
@KafkaListener(topics = {"userServiceTopic"})
30+
@KafkaListener(topics = {"storeServiceTopic"})
3131
public void listen(ConsumerRecord<?, ?> record) {
3232
logger.info("kafka的key: " + record.key());
3333
logger.info("kafka的value: " + record.value().toString());

StoreService/src/main/java/com/java110/store/listener/AbstractStoreBusinessServiceDataFlowListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ protected void autoSaveDelBusinessStoreCerdentials(Business business,JSONObject
179179
currentStoreCerdentials.put("positivePhoto",currentStoreCerdentials.get("positive_photo"));
180180
currentStoreCerdentials.put("negativePhoto",currentStoreCerdentials.get("negative_photo"));
181181
currentStoreCerdentials.put("operate",StatusConstant.OPERATE_DEL);
182-
getStoreServiceDaoImpl().saveBusinessStoreAttr(currentStoreCerdentials);
182+
getStoreServiceDaoImpl().saveBusinessStoreCerdentials(currentStoreCerdentials);
183183
}
184184
}

StoreService/src/main/java/com/java110/store/listener/DeleteStoreInfoListener.java

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,37 +92,42 @@ protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business
9292
protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
9393
String bId = business.getbId();
9494
//Assert.hasLength(bId,"请求报文中没有包含 bId");
95+
96+
//商户信息
9597
Map info = new HashMap();
96-
info.put("bId",bId);
97-
info.put("statusCd",StatusConstant.STATUS_CD_VALID);
98+
info.put("bId",business.getbId());
99+
info.put("operate",StatusConstant.OPERATE_DEL);
98100

99-
Map paramIn = new HashMap();
100-
paramIn.put("bId",bId);
101-
paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
102101
//商户信息
103-
Map storeInfo = storeServiceDaoImpl.getStoreInfo(info);
104-
if(storeInfo != null && !storeInfo.isEmpty()){
105-
paramIn.put("storeId",storeInfo.get("store_id").toString());
106-
storeServiceDaoImpl.updateStoreInfoInstance(paramIn);
107-
dataFlowContext.addParamOut("storeId",storeInfo.get("store_id"));
102+
Map businessStoreInfo = storeServiceDaoImpl.getBusinessStoreInfo(info);
103+
if( businessStoreInfo != null && !businessStoreInfo.isEmpty()) {
104+
flushBusinessStoreInfo(businessStoreInfo,StatusConstant.STATUS_CD_INVALID);
105+
storeServiceDaoImpl.updateStoreInfoInstance(businessStoreInfo);
106+
dataFlowContext.addParamOut("storeId",businessStoreInfo.get("store_id"));
108107
}
109-
110108
//商户属性
111-
List<Map> storeAttrs = storeServiceDaoImpl.getStoreAttrs(info);
112-
if(storeAttrs != null && storeAttrs.size()>0){
113-
storeServiceDaoImpl.updateStoreAttrInstance(paramIn);
109+
List<Map> businessStoreAttrs = storeServiceDaoImpl.getBusinessStoreAttrs(info);
110+
if(businessStoreAttrs != null && businessStoreAttrs.size() > 0) {
111+
for(Map businessStoreAttr : businessStoreAttrs) {
112+
flushBusinessStoreAttr(businessStoreAttr,StatusConstant.STATUS_CD_INVALID);
113+
storeServiceDaoImpl.updateStoreAttrInstance(businessStoreAttr);
114+
}
114115
}
115-
116116
//商户照片
117-
List<Map> storePhotos = storeServiceDaoImpl.getStorePhoto(info);
118-
if(storePhotos != null && storePhotos.size()>0){
119-
storeServiceDaoImpl.updateStorePhotoInstance(paramIn);
117+
List<Map> businessStorePhotos = storeServiceDaoImpl.getBusinessStorePhoto(info);
118+
if(businessStorePhotos != null && businessStorePhotos.size() >0){
119+
for(Map businessStorePhoto : businessStorePhotos) {
120+
flushBusinessStorePhoto(businessStorePhoto,StatusConstant.STATUS_CD_INVALID);
121+
storeServiceDaoImpl.updateStorePhotoInstance(businessStorePhoto);
122+
}
120123
}
121-
122-
//商户属性
123-
List<Map> storeCerdentialses = storeServiceDaoImpl.getStoreCerdentials(info);
124-
if(storeCerdentialses != null && storeCerdentialses.size()>0){
125-
storeServiceDaoImpl.updateStoreCerdentailsInstance(paramIn);
124+
//商户证件
125+
List<Map> businessStoreCerdentialses = storeServiceDaoImpl.getBusinessStoreCerdentials(info);
126+
if(businessStoreCerdentialses != null && businessStoreCerdentialses.size()>0){
127+
for(Map businessStoreCerdentials : businessStoreCerdentialses) {
128+
flushBusinessStoreCredentials(businessStoreCerdentials,StatusConstant.STATUS_CD_INVALID);
129+
storeServiceDaoImpl.updateStoreCerdentailsInstance(businessStoreCerdentials);
130+
}
126131
}
127132
}
128133

@@ -210,13 +215,11 @@ protected void doRecover(DataFlowContext dataFlowContext, Business business) {
210215
*/
211216
private void doBusinessStorePhoto(Business business, JSONArray businessStorePhotos) {
212217

213-
Map info = null;
214-
Map currentStorePhoto = null;
215218
for(int businessStorePhotoIndex = 0 ;businessStorePhotoIndex < businessStorePhotos.size();businessStorePhotoIndex++) {
216219
JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex);
217220
Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
218221

219-
if (businessStorePhoto.getLong("storePhotoId") < 0) {
222+
if (businessStorePhoto.getString("storePhotoId").startsWith("-")) {
220223
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto);
221224
}
222225

@@ -233,7 +236,7 @@ private void doBusinessStore(Business business,JSONObject businessStore){
233236

234237
Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点");
235238

236-
if(businessStore.getLong("storeId") < 0){
239+
if(businessStore.getString("storeId").startsWith("-")){
237240
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore);
238241
}
239242
//自动插入DEL
@@ -253,7 +256,7 @@ private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreA
253256
for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){
254257
JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex);
255258
Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点");
256-
if(storeAttr.getLong("attrId") < 0){
259+
if(storeAttr.getString("attrId").startsWith("-")){
257260
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr);
258261
}
259262

@@ -275,7 +278,7 @@ private void doBusinessStoreCerdentials(Business business, JSONArray businessSto
275278
JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex);
276279
Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
277280

278-
if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) {
281+
if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) {
279282
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials);
280283
}
281284

StoreService/src/main/java/com/java110/store/listener/SaveStoreInfoListener.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
import com.alibaba.fastjson.JSONArray;
44
import com.alibaba.fastjson.JSONObject;
5+
import com.java110.common.constant.ResponseConstant;
56
import com.java110.common.constant.ServiceCodeConstant;
67
import com.java110.common.constant.StatusConstant;
8+
import com.java110.common.exception.ListenerExecuteException;
79
import com.java110.common.util.Assert;
10+
import com.java110.common.util.DateUtil;
11+
import com.java110.common.util.StringUtil;
812
import com.java110.core.annotation.Java110Listener;
913
import com.java110.core.context.DataFlowContext;
1014
import com.java110.core.factory.GenerateCodeFactory;
@@ -15,6 +19,8 @@
1519
import org.springframework.beans.factory.annotation.Autowired;
1620
import org.springframework.transaction.annotation.Transactional;
1721

22+
import java.text.ParseException;
23+
import java.util.Date;
1824
import java.util.HashMap;
1925
import java.util.List;
2026
import java.util.Map;
@@ -164,7 +170,7 @@ private void doBusinessStorePhoto(Business business, JSONArray businessStorePhot
164170
JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex);
165171
Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
166172

167-
if (businessStorePhoto.getLong("storePhotoId") < 0) {
173+
if (businessStorePhoto.getString("storePhotoId").startsWith("-")) {
168174
String storePhotoId = GenerateCodeFactory.getStorePhotoId();
169175
businessStorePhoto.put("storePhotoId", storePhotoId);
170176
}
@@ -184,12 +190,11 @@ private void doBusinessStore(Business business,JSONObject businessStore){
184190

185191
Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点");
186192

187-
if(businessStore.getInteger("storeId") < 0){
193+
if(businessStore.getString("storeId").startsWith("-")){
188194
//刷新缓存
189195
flushStoreId(business.getDatas());
190196
}
191197

192-
193198
businessStore.put("bId",business.getbId());
194199
businessStore.put("operate", StatusConstant.OPERATE_ADD);
195200
//保存商户信息
@@ -211,7 +216,7 @@ private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreA
211216
JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex);
212217
Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点");
213218

214-
if(storeAttr.getInteger("attrId") < 0){
219+
if(storeAttr.getString("attrId").startsWith("-")){
215220
String attrId = GenerateCodeFactory.getAttrId();
216221
storeAttr.put("attrId",attrId);
217222
}
@@ -235,10 +240,21 @@ private void doBusinessStoreCerdentials(Business business, JSONArray businessSto
235240
JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex);
236241
Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
237242

238-
if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) {
243+
if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) {
239244
String storePhotoId = GenerateCodeFactory.getStoreCerdentialsId();
240245
businessStoreCerdentials.put("storeCerdentialsId", storePhotoId);
241246
}
247+
Date validityPeriod = null;
248+
try {
249+
if(StringUtil.isNullOrNone(businessStoreCerdentials.getString("validityPeriod"))){
250+
validityPeriod = DateUtil.getLastDate();
251+
}else {
252+
validityPeriod = DateUtil.getDateFromString(businessStoreCerdentials.getString("validityPeriod"), DateUtil.DATE_FORMATE_STRING_B);
253+
}
254+
} catch (ParseException e) {
255+
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 validityPeriod 格式不正确,请填写 "+DateUtil.DATE_FORMATE_STRING_B +" 格式,"+businessStoreCerdentials);
256+
}
257+
businessStoreCerdentials.put("validityPeriod",validityPeriod);
242258
businessStoreCerdentials.put("bId", business.getbId());
243259
businessStoreCerdentials.put("operate", StatusConstant.OPERATE_ADD);
244260
//保存商户信息

StoreService/src/main/java/com/java110/store/listener/UpdateStoreInfoListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private void doBusinessStorePhoto(Business business, JSONArray businessStorePhot
220220
JSONObject businessStorePhoto = businessStorePhotos.getJSONObject(businessStorePhotoIndex);
221221
Assert.jsonObjectHaveKey(businessStorePhoto, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
222222

223-
if (businessStorePhoto.getLong("storePhotoId") < 0) {
223+
if (businessStorePhoto.getString("storePhotoId").startsWith("-")) {
224224
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStorePhoto);
225225
}
226226

@@ -243,7 +243,7 @@ private void doBusinessStore(Business business,JSONObject businessStore){
243243

244244
Assert.jsonObjectHaveKey(businessStore,"storeId","businessStore 节点下没有包含 storeId 节点");
245245

246-
if(businessStore.getLong("storeId") < 0){
246+
if(businessStore.getString("storeId").startsWith("-")){
247247
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storeId 错误,不能自动生成(必须已经存在的storeId)"+businessStore);
248248
}
249249
//自动保存DEL
@@ -270,7 +270,7 @@ private void doSaveBusinessStoreAttrs(Business business,JSONArray businessStoreA
270270
for(int storeAttrIndex = 0 ; storeAttrIndex < businessStoreAttrs.size();storeAttrIndex ++){
271271
JSONObject storeAttr = businessStoreAttrs.getJSONObject(storeAttrIndex);
272272
Assert.jsonObjectHaveKey(storeAttr,"attrId","businessStoreAttr 节点下没有包含 attrId 节点");
273-
if(storeAttr.getLong("attrId") < 0){
273+
if(storeAttr.getString("attrId").startsWith("-")){
274274
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+storeAttr);
275275
}
276276
//自动保存DEL数据
@@ -296,7 +296,7 @@ private void doBusinessStoreCerdentials(Business business, JSONArray businessSto
296296
JSONObject businessStoreCerdentials = businessStoreCerdentialses.getJSONObject(businessStoreCerdentialsIndex);
297297
Assert.jsonObjectHaveKey(businessStoreCerdentials, "storeId", "businessStorePhoto 节点下没有包含 storeId 节点");
298298

299-
if (businessStoreCerdentials.getLong("storeCerdentialsId") < 0) {
299+
if (businessStoreCerdentials.getString("storeCerdentialsId").startsWith("-")) {
300300
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"storePhotoId 错误,不能自动生成(必须已经存在的storePhotoId)"+businessStoreCerdentials);
301301
}
302302

java110-common/src/main/java/com/java110/common/util/DateUtil.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.java110.common.util;
22

3+
import java.sql.Timestamp;
34
import java.text.DateFormat;
45
import java.text.ParseException;
56
import java.text.SimpleDateFormat;
@@ -73,6 +74,19 @@ public static int getCurrentMonth(){
7374
return calendar.get(Calendar.MONTH)+1;
7475
}
7576

77+
public static Date getLastDate() throws ParseException {
78+
return getDateFromString("3000-01-01",DATE_FORMATE_STRING_B);
79+
}
80+
81+
/**
82+
* 转TimeStamp
83+
* @param date
84+
* @return
85+
*/
86+
public static Timestamp getTimestamp(Date date){
87+
Timestamp timestamp = new Timestamp(date.getTime());
88+
return timestamp;
89+
}
7690
/**
7791
* 获取未来时间
7892
* @param second 秒

java110-config/db/CenterService/create_table.db

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ VALUES('update.center.mapping','Q','修改映射信息',1,'http://center-service
271271
INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id)
272272
VALUES('save.user.userInfo','D','保存用户信息',1,'http://user-service/userApi/service','8000418003');
273273

274+
INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id)
275+
VALUES('save.store.info','D','保存商户信息',1,'http://store-service/storeApi/service','8000418003');
276+
277+
INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id)
278+
VALUES('update.store.info','D','修改商户信息',1,'http://store-service/storeApi/service','8000418003');
279+
280+
INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id)
281+
VALUES('delete.store.info','D','删除商户信息',1,'http://store-service/storeApi/service','8000418003');
282+
274283

275284
INSERT INTO c_service(service_code,business_type_cd,`name`,seq,url,provide_app_id)
276285
VALUES('transfer.console.menu','T','透传菜单查询',1,'http://192.168.31.199:8001/userApi/service','8000418001');

0 commit comments

Comments
 (0)