FeeApi.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. package com.java110.fee.api;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.core.base.controller.BaseController;
  4. import com.java110.core.context.BusinessServiceDataFlow;
  5. import com.java110.core.factory.DataTransactionFactory;
  6. import com.java110.core.log.LoggerFactory;
  7. import com.java110.dto.fee.FeeAttrDto;
  8. import com.java110.dto.fee.FeeDto;
  9. import com.java110.fee.bmo.*;
  10. import com.java110.fee.smo.IFeeServiceSMO;
  11. import com.java110.utils.constant.ResponseConstant;
  12. import com.java110.utils.exception.InitConfigDataException;
  13. import com.java110.utils.exception.InitDataFlowContextException;
  14. import com.java110.utils.util.Assert;
  15. import com.java110.utils.util.StringUtil;
  16. import org.slf4j.Logger;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.http.ResponseEntity;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletRequest;
  21. import java.util.HashMap;
  22. import java.util.Map;
  23. /**
  24. * 用户服务类
  25. * Created by wuxw on 2018/5/14.
  26. */
  27. @RestController
  28. @RequestMapping(value = "/feeApi")
  29. public class FeeApi extends BaseController {
  30. private final static Logger logger = LoggerFactory.getLogger(FeeApi.class);
  31. @Autowired
  32. IFeeServiceSMO feeServiceSMOImpl;
  33. @Autowired
  34. private IQueryFeeByAttr queryFeeByAttrImpl;
  35. @Autowired
  36. private IQueryParkspaceFee queryParkspaceFeeImpl;
  37. @Autowired
  38. private IQueryOweFee queryOweFeeImpl;
  39. @Autowired
  40. private IPayOweFee payOweFeeImpl;
  41. @Autowired
  42. private IImportRoomFee importRoomFeeImpl;
  43. @RequestMapping(path = "/service", method = RequestMethod.GET)
  44. public String serviceGet(HttpServletRequest request) {
  45. return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, "不支持Get方法请求").toJSONString();
  46. }
  47. /**
  48. * 用户服务统一处理接口
  49. *
  50. * @param orderInfo
  51. * @param request
  52. * @return
  53. */
  54. @RequestMapping(path = "/service", method = RequestMethod.POST)
  55. public String servicePost(@RequestBody String orderInfo, HttpServletRequest request) {
  56. BusinessServiceDataFlow businessServiceDataFlow = null;
  57. JSONObject responseJson = null;
  58. try {
  59. Map<String, String> headers = new HashMap<String, String>();
  60. getRequestInfo(request, headers);
  61. //预校验
  62. preValiateOrderInfo(orderInfo);
  63. businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers);
  64. responseJson = feeServiceSMOImpl.service(businessServiceDataFlow);
  65. } catch (InitDataFlowContextException e) {
  66. logger.error("请求报文错误,初始化 BusinessServiceDataFlow失败" + orderInfo, e);
  67. responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo, ResponseConstant.RESULT_PARAM_ERROR, e.getMessage(), null);
  68. } catch (InitConfigDataException e) {
  69. logger.error("请求报文错误,加载配置信息失败" + orderInfo, e);
  70. responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo, ResponseConstant.RESULT_PARAM_ERROR, e.getMessage(), null);
  71. } catch (Exception e) {
  72. logger.error("请求订单异常", e);
  73. responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow, ResponseConstant.RESULT_CODE_ERROR, e.getMessage() + e,
  74. null);
  75. } finally {
  76. }
  77. return responseJson.toJSONString();
  78. }
  79. /**
  80. * 这里预校验,请求报文中不能有 dataFlowId
  81. *
  82. * @param orderInfo
  83. */
  84. private void preValiateOrderInfo(String orderInfo) {
  85. /* if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){
  86. throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"报文中不能存在dataFlowId节点");
  87. }*/
  88. }
  89. /**
  90. * 获取请求信息
  91. *
  92. * @param request
  93. * @param headers
  94. * @throws RuntimeException
  95. */
  96. private void getRequestInfo(HttpServletRequest request, Map headers) throws Exception {
  97. try {
  98. super.initHeadParam(request, headers);
  99. super.initUrlParam(request, headers);
  100. } catch (Exception e) {
  101. logger.error("加载头信息失败", e);
  102. throw new InitConfigDataException(ResponseConstant.RESULT_PARAM_ERROR, "加载头信息失败");
  103. }
  104. }
  105. public IFeeServiceSMO getFeeServiceSMOImpl() {
  106. return feeServiceSMOImpl;
  107. }
  108. public void setFeeServiceSMOImpl(IFeeServiceSMO feeServiceSMOImpl) {
  109. this.feeServiceSMOImpl = feeServiceSMOImpl;
  110. }
  111. /**
  112. * 停车费查询
  113. *
  114. * @param reqJson
  115. * @return
  116. */
  117. @RequestMapping(value = "/parkSpaceFee", method = RequestMethod.POST)
  118. public ResponseEntity<String> parkSpaceFee(@RequestBody JSONObject reqJson) {
  119. Assert.hasKeyAndValue(reqJson, "code", "未包含小区编码");
  120. return queryParkspaceFeeImpl.query(reqJson);
  121. }
  122. /**
  123. * 根据属性查询费用
  124. *
  125. * @param communityId
  126. * @return
  127. * @path /app/feeApi/listFeeByAttr
  128. */
  129. @RequestMapping(value = "/listFeeByAttr", method = RequestMethod.GET)
  130. public ResponseEntity<String> listFeeByAttr(@RequestParam(value = "communityId") String communityId,
  131. @RequestParam(value = "feeId", required = false) String feeId,
  132. @RequestParam(value = "specCd") String specCd,
  133. @RequestParam(value = "value") String value,
  134. @RequestParam(value = "row") int row,
  135. @RequestParam(value = "page") int page) {
  136. FeeAttrDto feeAttrDto = new FeeAttrDto();
  137. feeAttrDto.setCommunityId(communityId);
  138. feeAttrDto.setSpecCd(specCd);
  139. feeAttrDto.setValue(value);
  140. feeAttrDto.setFeeId(feeId);
  141. feeAttrDto.setRow(row);
  142. feeAttrDto.setPage(page);
  143. return queryFeeByAttrImpl.query(feeAttrDto);
  144. }
  145. /**
  146. * 查询欠费费用
  147. *
  148. * @param payObjId 付费方ID
  149. * @param communityId 小区ID
  150. * @return
  151. * @path /app/feeApi/listOweFees
  152. */
  153. @RequestMapping(value = "/listOweFees", method = RequestMethod.GET)
  154. public ResponseEntity<String> listOweFees(
  155. @RequestParam(value = "payObjId", required = false) String payObjId,
  156. @RequestParam(value = "payObjType", required = false) String payObjType,
  157. @RequestParam(value = "ownerId", required = false) String ownerId,
  158. @RequestParam(value = "communityId") String communityId) {
  159. if (StringUtil.isEmpty(payObjId) && StringUtil.isEmpty(ownerId)) {
  160. throw new IllegalArgumentException("费用对象或者业主不能都为空");
  161. }
  162. FeeDto feeDto = new FeeDto();
  163. feeDto.setPayerObjId(payObjId);
  164. feeDto.setPayerObjType(payObjType);
  165. feeDto.setOwnerId(ownerId);
  166. feeDto.setCommunityId(communityId);
  167. return queryOweFeeImpl.query(feeDto);
  168. }
  169. /**
  170. * 查询欠费费用
  171. *
  172. * @param roomId 房屋ID
  173. * @param communityId 小区ID
  174. * @return
  175. * @path /app/feeApi/listAllRoomOweFees
  176. */
  177. @RequestMapping(value = "/listAllRoomOweFees", method = RequestMethod.GET)
  178. public ResponseEntity<String> listAllRoomOweFees(
  179. @RequestParam(value = "roomId", required = false) String roomId,
  180. @RequestParam(value = "communityId") String communityId) {
  181. FeeDto feeDto = new FeeDto();
  182. feeDto.setPayerObjId(roomId);
  183. feeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
  184. feeDto.setCommunityId(communityId);
  185. return queryOweFeeImpl.querys(feeDto);
  186. }
  187. /**
  188. * 查询欠费费用(批量查询)
  189. *
  190. * @param num 停车位或房屋编号
  191. * @param communityId 小区ID
  192. * @return
  193. * @path /app/feeApi/getOweFees
  194. */
  195. @RequestMapping(value = "/getOweFees", method = RequestMethod.GET)
  196. public ResponseEntity<String> getOweFees(
  197. @RequestParam(value = "payObjType") String payObjType,
  198. @RequestParam(value = "communityId") String communityId,
  199. @RequestParam(value = "billType") String billType,
  200. @RequestParam(value = "row") int row,
  201. @RequestParam(value = "page") int page,
  202. @RequestParam(value = "num", required = false) String num
  203. ) {
  204. FeeDto feeDto = new FeeDto();
  205. feeDto.setPayerObjId(num);
  206. feeDto.setPayerObjType(payObjType);
  207. feeDto.setCommunityId(communityId);
  208. feeDto.setBillType(billType);
  209. feeDto.setRow(row);
  210. feeDto.setPage(page);
  211. return queryOweFeeImpl.queryAllOwneFee(feeDto);
  212. }
  213. /**
  214. * 欠费批量缴费
  215. *
  216. * @param reqJson {
  217. * "communityId":"",
  218. * "fees":[
  219. * {
  220. * "feeId":"123123",
  221. * "feePrice":10.00,
  222. * <p>
  223. * }
  224. * <p>
  225. * ]
  226. * }
  227. * @return
  228. * @path /app/feeApi/payOweFee
  229. */
  230. @RequestMapping(value = "/payOweFee", method = RequestMethod.POST)
  231. public ResponseEntity<String> payOweFee(@RequestBody JSONObject reqJson) {
  232. Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
  233. Assert.hasKey(reqJson, "fees", "未包含缴费项目");
  234. return payOweFeeImpl.pay(reqJson);
  235. }
  236. /**
  237. * 费用导入
  238. *
  239. * @param reqString
  240. * @return
  241. */
  242. @RequestMapping(value = "/importRoomFees", method = RequestMethod.POST)
  243. public ResponseEntity<String> importRoomFees(@RequestBody String reqString) {
  244. JSONObject reqJson = JSONObject.parseObject(reqString);
  245. Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
  246. Assert.hasKeyAndValue(reqJson, "feeTypeCd", "未包含费用类型");
  247. Assert.hasKeyAndValue(reqJson, "storeId", "未包含商户信息");
  248. Assert.hasKeyAndValue(reqJson, "userId", "未包含用户信息");
  249. Assert.hasKeyAndValue(reqJson, "batchId", "未包含用户信息");
  250. return importRoomFeeImpl.importFee(reqJson);
  251. }
  252. /**
  253. * 车辆费用导入
  254. * /feeApi/importCarFees
  255. * path /app/feeApi/importCarFees
  256. *
  257. * @param reqString
  258. * @return
  259. */
  260. @RequestMapping(value = "/importCarFees", method = RequestMethod.POST)
  261. public ResponseEntity<String> importCarFees(@RequestBody String reqString) {
  262. JSONObject reqJson = JSONObject.parseObject(reqString);
  263. Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
  264. Assert.hasKeyAndValue(reqJson, "feeTypeCd", "未包含费用类型");
  265. Assert.hasKeyAndValue(reqJson, "storeId", "未包含商户信息");
  266. Assert.hasKeyAndValue(reqJson, "userId", "未包含用户信息");
  267. Assert.hasKeyAndValue(reqJson, "batchId", "未包含批次信息");
  268. return importRoomFeeImpl.importCarFee(reqJson);
  269. }
  270. /**
  271. * 合同费用导入
  272. * /feeApi/importContractFees
  273. * path /app/feeApi/importContractFees
  274. *
  275. * @param reqString
  276. * @return
  277. */
  278. @RequestMapping(value = "/importContractFees", method = RequestMethod.POST)
  279. public ResponseEntity<String> importContractFees(@RequestBody String reqString) {
  280. JSONObject reqJson = JSONObject.parseObject(reqString);
  281. Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
  282. Assert.hasKeyAndValue(reqJson, "feeTypeCd", "未包含费用类型");
  283. Assert.hasKeyAndValue(reqJson, "storeId", "未包含商户信息");
  284. Assert.hasKeyAndValue(reqJson, "userId", "未包含用户信息");
  285. Assert.hasKeyAndValue(reqJson, "batchId", "未包含批次信息");
  286. return importRoomFeeImpl.importContractFees(reqJson);
  287. }
  288. }