|
| 1 | +package com.java110.store.listener; |
| 2 | + |
| 3 | +import com.alibaba.fastjson.JSONObject; |
| 4 | +import com.java110.common.constant.ResponseConstant; |
| 5 | +import com.java110.common.constant.StatusConstant; |
| 6 | +import com.java110.common.exception.ListenerExecuteException; |
| 7 | +import com.java110.entity.center.Business; |
| 8 | +import com.java110.event.service.AbstractBusinessServiceDataFlowListener; |
| 9 | +import com.java110.store.dao.IStoreServiceDao; |
| 10 | + |
| 11 | +import java.util.HashMap; |
| 12 | +import java.util.List; |
| 13 | +import java.util.Map; |
| 14 | + |
| 15 | +/** |
| 16 | + * |
| 17 | + * 商户 服务侦听 父类 |
| 18 | + * Created by wuxw on 2018/7/4. |
| 19 | + */ |
| 20 | +public abstract class AbstractStoreBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener{ |
| 21 | + |
| 22 | + |
| 23 | + /** |
| 24 | + * 获取 DAO工具类 |
| 25 | + * @return |
| 26 | + */ |
| 27 | + public abstract IStoreServiceDao getStoreServiceDaoImpl(); |
| 28 | + |
| 29 | + /** |
| 30 | + * 刷新 businessStoreInfo 数据 |
| 31 | + * 主要将 数据库 中字段和 接口传递字段建立关系 |
| 32 | + * @param businessStoreInfo |
| 33 | + */ |
| 34 | + protected void flushBusinessStoreInfo(Map businessStoreInfo,String statusCd){ |
| 35 | + businessStoreInfo.put("newBId",businessStoreInfo.get("b_id")); |
| 36 | + businessStoreInfo.put("storeId",businessStoreInfo.get("store_id")); |
| 37 | + businessStoreInfo.put("userId",businessStoreInfo.get("user_id")); |
| 38 | + businessStoreInfo.put("storeTypeCd",businessStoreInfo.get("store_type_cd")); |
| 39 | + businessStoreInfo.put("nearbyLandmarks",businessStoreInfo.get("nearby_landmarks")); |
| 40 | + businessStoreInfo.put("mapX",businessStoreInfo.get("map_x")); |
| 41 | + businessStoreInfo.put("mapY",businessStoreInfo.get("map_y")); |
| 42 | + businessStoreInfo.put("statusCd", statusCd); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + 刷新 businessStoreAttr 数据 |
| 47 | + * 主要将 数据库 中字段和 接口传递字段建立关系 |
| 48 | + * @param businessStoreAttr |
| 49 | + * @param statusCd |
| 50 | + */ |
| 51 | + protected void flushBusinessStoreAttr(Map businessStoreAttr,String statusCd){ |
| 52 | + businessStoreAttr.put("attrId",businessStoreAttr.get("attr_id")); |
| 53 | + businessStoreAttr.put("specCd",businessStoreAttr.get("spec_cd")); |
| 54 | + businessStoreAttr.put("storeId",businessStoreAttr.get("store_id")); |
| 55 | + businessStoreAttr.put("newBId",businessStoreAttr.get("b_id")); |
| 56 | + businessStoreAttr.put("statusCd",statusCd); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * 刷新 businessStorePhoto 数据 |
| 61 | + * @param businessStorePhoto |
| 62 | + * @param statusCd |
| 63 | + */ |
| 64 | + protected void flushBusinessStorePhoto(Map businessStorePhoto,String statusCd){ |
| 65 | + businessStorePhoto.put("storeId",businessStorePhoto.get("store_id")); |
| 66 | + businessStorePhoto.put("storePhotoId",businessStorePhoto.get("store_photo_id")); |
| 67 | + businessStorePhoto.put("storePhotoTypeCd",businessStorePhoto.get("store_photo_type_cd")); |
| 68 | + businessStorePhoto.put("newBId",businessStorePhoto.get("b_id")); |
| 69 | + businessStorePhoto.put("statusCd",statusCd); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * 刷新 businessStoreCerdentials 数据 |
| 74 | + * @param businessStoreCerdentials |
| 75 | + * @param statusCd |
| 76 | + */ |
| 77 | + protected void flushBusinessStoreCredentials(Map businessStoreCerdentials ,String statusCd){ |
| 78 | + businessStoreCerdentials.put("storeId",businessStoreCerdentials.get("store_id")); |
| 79 | + businessStoreCerdentials.put("storeCerdentialsId",businessStoreCerdentials.get("store_cerdentials_id")); |
| 80 | + businessStoreCerdentials.put("credentialsCd",businessStoreCerdentials.get("credentials_cd")); |
| 81 | + businessStoreCerdentials.put("validityPeriod",businessStoreCerdentials.get("validity_period")); |
| 82 | + businessStoreCerdentials.put("positivePhoto",businessStoreCerdentials.get("positive_photo")); |
| 83 | + businessStoreCerdentials.put("negativePhoto",businessStoreCerdentials.get("negative_photo")); |
| 84 | + businessStoreCerdentials.put("newBId",businessStoreCerdentials.get("b_id")); |
| 85 | + businessStoreCerdentials.put("statusCd",statusCd); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| 90 | + * @param businessStore 商户信息 |
| 91 | + */ |
| 92 | + protected void autoSaveDelBusinessStore(Business business, JSONObject businessStore){ |
| 93 | +//自动插入DEL |
| 94 | + Map info = new HashMap(); |
| 95 | + info.put("storeId",businessStore.getString("storeId")); |
| 96 | + info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| 97 | + Map currentStoreInfo = getStoreServiceDaoImpl().getStoreInfo(info); |
| 98 | + if(currentStoreInfo == null || currentStoreInfo.isEmpty()){ |
| 99 | + throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| 100 | + } |
| 101 | + currentStoreInfo.put("bId",business.getbId()); |
| 102 | + currentStoreInfo.put("storeId",currentStoreInfo.get("store_id")); |
| 103 | + currentStoreInfo.put("userId",currentStoreInfo.get("user_id")); |
| 104 | + currentStoreInfo.put("storeTypeCd",currentStoreInfo.get("store_type_cd")); |
| 105 | + currentStoreInfo.put("nearbyLandmarks",currentStoreInfo.get("nearby_landmarks")); |
| 106 | + currentStoreInfo.put("mapX",currentStoreInfo.get("map_x")); |
| 107 | + currentStoreInfo.put("mapY",currentStoreInfo.get("map_y")); |
| 108 | + currentStoreInfo.put("operate",StatusConstant.OPERATE_DEL); |
| 109 | + getStoreServiceDaoImpl().saveBusinessStoreInfo(currentStoreInfo); |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| 114 | + * @param business 当前业务 |
| 115 | + * @param storeAttr 商户属性 |
| 116 | + */ |
| 117 | + protected void autoSaveDelBusinessStoreAttr(Business business, JSONObject storeAttr){ |
| 118 | + Map info = new HashMap(); |
| 119 | + info.put("attrId",storeAttr.getString("attrId")); |
| 120 | + info.put("storeId",storeAttr.getString("storeId")); |
| 121 | + info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| 122 | + List<Map> currentStoreAttrs = getStoreServiceDaoImpl().getStoreAttrs(info); |
| 123 | + if(currentStoreAttrs == null || currentStoreAttrs.size() != 1){ |
| 124 | + throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| 125 | + } |
| 126 | + Map currentStoreAttr = currentStoreAttrs.get(0); |
| 127 | + currentStoreAttr.put("bId",business.getbId()); |
| 128 | + currentStoreAttr.put("attrId",currentStoreAttr.get("attr_id")); |
| 129 | + currentStoreAttr.put("storeId",currentStoreAttr.get("store_id")); |
| 130 | + currentStoreAttr.put("specCd",currentStoreAttr.get("spec_cd")); |
| 131 | + currentStoreAttr.put("operate",StatusConstant.OPERATE_DEL); |
| 132 | + getStoreServiceDaoImpl().saveBusinessStoreAttr(currentStoreAttr); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| 137 | + * @param business |
| 138 | + * @param businessStorePhoto 商户照片 |
| 139 | + */ |
| 140 | + protected void autoSaveDelBusinessStorePhoto(Business business,JSONObject businessStorePhoto){ |
| 141 | + Map info = new HashMap(); |
| 142 | + info.put("storePhotoId",businessStorePhoto.getString("storePhotoId")); |
| 143 | + info.put("storeId",businessStorePhoto.getString("storeId")); |
| 144 | + info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| 145 | + List<Map> currentStorePhotos = getStoreServiceDaoImpl().getStorePhoto(info); |
| 146 | + if(currentStorePhotos == null || currentStorePhotos.size() != 1){ |
| 147 | + throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| 148 | + } |
| 149 | + Map currentStorePhoto = currentStorePhotos.get(0); |
| 150 | + currentStorePhoto.put("bId",business.getbId()); |
| 151 | + currentStorePhoto.put("storePhotoId",currentStorePhoto.get("store_photo_id")); |
| 152 | + currentStorePhoto.put("storeId",currentStorePhoto.get("store_id")); |
| 153 | + currentStorePhoto.put("storePhotoTypeCd",currentStorePhoto.get("store_photo_type_cd")); |
| 154 | + currentStorePhoto.put("operate",StatusConstant.OPERATE_DEL); |
| 155 | + getStoreServiceDaoImpl().saveBusinessStorePhoto(currentStorePhoto); |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中 |
| 160 | + * @param business |
| 161 | + * @param businessStoreCerdentials 商户证件 |
| 162 | + */ |
| 163 | + protected void autoSaveDelBusinessStoreCerdentials(Business business,JSONObject businessStoreCerdentials){ |
| 164 | + Map info = new HashMap(); |
| 165 | + info.put("storeCerdentialsId",businessStoreCerdentials.getString("storeCerdentialsId")); |
| 166 | + info.put("storeId",businessStoreCerdentials.getString("storeId")); |
| 167 | + info.put("statusCd",StatusConstant.STATUS_CD_VALID); |
| 168 | + List<Map> currentStoreCerdentailses = getStoreServiceDaoImpl().getStoreCerdentials(info); |
| 169 | + if(currentStoreCerdentailses == null || currentStoreCerdentailses.size() != 1){ |
| 170 | + throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info); |
| 171 | + } |
| 172 | + Map currentStoreCerdentials = currentStoreCerdentailses.get(0); |
| 173 | + |
| 174 | + currentStoreCerdentials.put("bId",business.getbId()); |
| 175 | + currentStoreCerdentials.put("storeCerdentialsId",currentStoreCerdentials.get("store_cerdentials_id")); |
| 176 | + currentStoreCerdentials.put("storeId",currentStoreCerdentials.get("store_id")); |
| 177 | + currentStoreCerdentials.put("credentialsCd",currentStoreCerdentials.get("credentials_cd")); |
| 178 | + currentStoreCerdentials.put("validityPeriod",currentStoreCerdentials.get("validity_period")); |
| 179 | + currentStoreCerdentials.put("positivePhoto",currentStoreCerdentials.get("positive_photo")); |
| 180 | + currentStoreCerdentials.put("negativePhoto",currentStoreCerdentials.get("negative_photo")); |
| 181 | + currentStoreCerdentials.put("operate",StatusConstant.OPERATE_DEL); |
| 182 | + getStoreServiceDaoImpl().saveBusinessStoreAttr(currentStoreCerdentials); |
| 183 | + } |
| 184 | +} |
0 commit comments