| New file |
| | |
| | | package com.java110.job.adapt.payment.receipt; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.aliyuncs.CommonRequest; |
| | | import com.aliyuncs.CommonResponse; |
| | | import com.aliyuncs.DefaultAcsClient; |
| | | import com.aliyuncs.IAcsClient; |
| | | import com.aliyuncs.exceptions.ClientException; |
| | | import com.aliyuncs.exceptions.ServerException; |
| | | import com.aliyuncs.http.MethodType; |
| | | import com.aliyuncs.profile.DefaultProfile; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.factory.WechatFactory; |
| | | import com.java110.core.smo.IComputeFeeSMO; |
| | | import com.java110.dto.basePrivilege.BasePrivilegeDto; |
| | | import com.java110.dto.community.CommunityDto; |
| | | import com.java110.dto.fee.FeeDetailDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | | import com.java110.dto.smallWechatAttr.SmallWechatAttrDto; |
| | | import com.java110.dto.staffAppAuth.StaffAppAuthDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.entity.order.Business; |
| | | import com.java110.entity.wechat.Content; |
| | | import com.java110.entity.wechat.Data; |
| | | import com.java110.entity.wechat.PropertyFeeTemplateMessage; |
| | | import com.java110.intf.community.ICommunityInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeDetailInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeReceiptDetailInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeReceiptInnerServiceSMO; |
| | | import com.java110.intf.order.IPrivilegeInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWeChatInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO; |
| | | import com.java110.intf.user.*; |
| | | import com.java110.job.adapt.DatabusAdaptImpl; |
| | | import com.java110.po.fee.PayFeeDetailPo; |
| | | import com.java110.po.feeReceipt.FeeReceiptPo; |
| | | import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 缴费收据处理 |
| | | * |
| | | * @author fqz |
| | | * @date 2020-12-11 18:54 |
| | | */ |
| | | @Component(value = "payFeeReceiptAdapt") |
| | | public class PayFeeReceiptAdapt extends DatabusAdaptImpl { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(PayFeeReceiptAdapt.class); |
| | | |
| | | @Autowired |
| | | private ICommunityInnerServiceSMO communityInnerServiceSMO; |
| | | |
| | | |
| | | @Autowired |
| | | private IFeeReceiptInnerServiceSMO feeReceiptInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeReceiptDetailInnerServiceSMO feeReceiptDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeInnerServiceSMO feeInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeDetailInnerServiceSMO feeDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IComputeFeeSMO computeFeeSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMO; |
| | | |
| | | @Autowired |
| | | private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMO; |
| | | |
| | | @Autowired |
| | | private IOwnerInnerServiceSMO ownerInnerServiceSMO; |
| | | |
| | | @Autowired |
| | | private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMO; |
| | | |
| | | //模板信息推送地址 |
| | | private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="; |
| | | |
| | | public final static String ALI_SMS_DOMAIN = "ALI_SMS"; |
| | | |
| | | @Override |
| | | public void execute(Business business, List<Business> businesses) { |
| | | JSONObject data = business.getData(); |
| | | JSONArray businessPayFeeDetails = null; |
| | | if (data == null) { |
| | | FeeDetailDto feeDetailDto = new FeeDetailDto(); |
| | | feeDetailDto.setbId(business.getbId()); |
| | | List<FeeDetailDto> feeDetailDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(feeDetailDto); |
| | | Assert.listOnlyOne(feeDetailDtos, "未查询到缴费记录"); |
| | | businessPayFeeDetails = JSONArray.parseArray(JSONArray.toJSONString(feeDetailDtos, SerializerFeature.WriteDateUseDateFormat)); |
| | | } else if (data.containsKey(PayFeeDetailPo.class.getSimpleName())) { |
| | | Object bObj = data.get(PayFeeDetailPo.class.getSimpleName()); |
| | | if (bObj instanceof JSONObject) { |
| | | businessPayFeeDetails = new JSONArray(); |
| | | businessPayFeeDetails.add(bObj); |
| | | } else if (bObj instanceof Map) { |
| | | businessPayFeeDetails = new JSONArray(); |
| | | businessPayFeeDetails.add(JSONObject.parseObject(JSONObject.toJSONString(bObj))); |
| | | } else if (bObj instanceof List) { |
| | | businessPayFeeDetails = JSONArray.parseArray(JSONObject.toJSONString(bObj)); |
| | | } else { |
| | | businessPayFeeDetails = (JSONArray) bObj; |
| | | } |
| | | } else { |
| | | return; |
| | | } |
| | | |
| | | if (businessPayFeeDetails == null) { |
| | | return; |
| | | } |
| | | for (int bPayFeeDetailIndex = 0; bPayFeeDetailIndex < businessPayFeeDetails.size(); bPayFeeDetailIndex++) { |
| | | JSONObject businessPayFeeDetail = businessPayFeeDetails.getJSONObject(bPayFeeDetailIndex); |
| | | doPayFeeDetail(business, businessPayFeeDetail); |
| | | } |
| | | } |
| | | |
| | | private void doPayFeeDetail(Business business, JSONObject businessPayFeeDetail) { |
| | | //查询缴费明细 |
| | | PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(businessPayFeeDetail, PayFeeDetailPo.class); |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(payFeeDetailPo.getFeeId()); |
| | | feeDto.setCommunityId(payFeeDetailPo.getCommunityId()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | |
| | | Assert.listOnlyOne(feeDtos, "未查询到费用信息"); |
| | | |
| | | //添加单元信息 |
| | | FeeReceiptPo feeReceiptPo = new FeeReceiptPo(); |
| | | FeeReceiptDetailPo feeReceiptDetailPo = new FeeReceiptDetailPo(); |
| | | |
| | | feeReceiptDetailPo.setAmount(businessPayFeeDetail.getString("receivedAmount")); |
| | | feeReceiptDetailPo.setCommunityId(feeDto.getCommunityId()); |
| | | feeReceiptDetailPo.setCycle(businessPayFeeDetail.getString("cycles")); |
| | | feeReceiptDetailPo.setDetailId(businessPayFeeDetail.getString("detailId")); |
| | | feeReceiptDetailPo.setEndTime(businessPayFeeDetail.getString("endTime")); |
| | | feeReceiptDetailPo.setFeeId(feeDto.getFeeId()); |
| | | feeReceiptDetailPo.setFeeName(StringUtil.isEmpty(feeDto.getImportFeeName()) ? feeDto.getFeeName() : feeDto.getImportFeeName()); |
| | | feeReceiptDetailPo.setStartTime(businessPayFeeDetail.getString("startTime")); |
| | | feeReceiptDetailPo.setReceiptId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId)); |
| | | computeFeeSMOImpl.freshFeeReceiptDetail(feeDto, feeReceiptDetailPo); |
| | | feeReceiptPo.setAmount(feeReceiptDetailPo.getAmount()); |
| | | feeReceiptPo.setCommunityId(feeReceiptDetailPo.getCommunityId()); |
| | | feeReceiptPo.setReceiptId(feeReceiptDetailPo.getReceiptId()); |
| | | feeReceiptPo.setObjType(feeDto.getPayerObjType()); |
| | | feeReceiptPo.setObjId(feeDto.getPayerObjId()); |
| | | feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto)); |
| | | //这里只是写入 收据表,暂不考虑 事务一致性问题,就算写入失败 也只是影响 收据打印,如果 贵公司对 收据要求 比较高,不能有失败的情况 请加入事务管理 |
| | | feeReceiptDetailInnerServiceSMOImpl.saveFeeReceiptDetail(feeReceiptDetailPo); |
| | | feeReceiptInnerServiceSMOImpl.saveFeeReceipt(feeReceiptPo); |
| | | } |
| | | |
| | | |
| | | } |