| | |
| | | import com.java110.core.smo.IComputeFeeSMO; |
| | | import com.java110.dto.account.AccountDto; |
| | | import com.java110.dto.community.CommunityDto; |
| | | import com.java110.dto.couponUser.CouponUserDto; |
| | | import com.java110.dto.coupon.CouponUserDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDetailDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.feeDiscount.ComputeDiscountDto; |
| | | import com.java110.dto.fee.ComputeDiscountDto; |
| | | import com.java110.intf.acct.IAccountDetailInnerServiceSMO; |
| | | import com.java110.intf.acct.IAccountInnerServiceSMO; |
| | | import com.java110.intf.acct.ICouponUserV1InnerServiceSMO; |
| | | import com.java110.intf.community.ICommunityV1InnerServiceSMO; |
| | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | */ |
| | | @Java110Cmd(serviceCode = "fee.payFeePre") |
| | | public class PayFeePreCmd extends Cmd { |
| | | private static Logger logger = LoggerFactory.getLogger(PayFeePreCmd.class); |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(PayFeePreCmd.class); |
| | | |
| | | @Autowired |
| | | private IFeeInnerServiceSMO feeInnerServiceSMOImpl; |
| | |
| | | |
| | | @Autowired |
| | | private IComputeFeeSMO computeFeeSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { |
| | |
| | | Assert.hasLength(reqJson.getString("receivedAmount"), "实收金额不能为空"); |
| | | Assert.hasLength(reqJson.getString("feeId"), "费用ID不能为空"); |
| | | Assert.hasLength(reqJson.getString("appId"), "appId不能为空"); |
| | | |
| | | |
| | | //判断是否 费用状态为缴费结束 |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(reqJson.getString("feeId")); |
| | | feeDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | |
| | | Assert.listOnlyOne(feeDtos, "传入费用ID错误"); |
| | | |
| | | feeDto = feeDtos.get(0); |
| | | |
| | | if (FeeDto.STATE_FINISH.equals(feeDto.getState())) { |
| | | throw new IllegalArgumentException("收费已经结束,不能再缴费"); |
| | | } |
| | | |
| | | Date endTime = feeDto.getEndTime(); |
| | | |
| | | FeeConfigDto feeConfigDto = new FeeConfigDto(); |
| | | feeConfigDto.setConfigId(feeDto.getConfigId()); |
| | | feeConfigDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | |
| | | if (feeConfigDtos != null && feeConfigDtos.size() == 1) { |
| | | try { |
| | | Date configEndTime = DateUtil.getDateFromString(feeConfigDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A); |
| | | configEndTime = DateUtil.stepDay(configEndTime, 5); |
| | | |
| | | Date newDate = DateUtil.stepMonth(endTime, reqJson.getInteger("cycles")); |
| | | |
| | | if (newDate.getTime() > configEndTime.getTime()) { |
| | | throw new IllegalArgumentException("缴费周期超过 缴费结束时间"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("比较费用日期失败", e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | logger.debug("ServiceDataFlowEvent : {}", event); |
| | | |
| | | String userId = cmdDataFlowContext.getReqHeaders().get("user-id"); |
| | | |
| | | String appId = cmdDataFlowContext.getReqHeaders().get("app-id"); |
| | | reqJson.put("appId", appId); |
| | | reqJson.put("userId",userId); |
| | | |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(reqJson.getString("feeId")); |
| | |
| | | return 0.0; |
| | | } |
| | | |
| | | BigDecimal totalAccountAmount = new BigDecimal(0); |
| | | for (AccountDto tmpAccountDto : accountDtos) { |
| | | totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount())); |
| | | } |
| | | BigDecimal money = new BigDecimal(0); |
| | | |
| | | double tmpDeductionAmount = totalAccountAmount.subtract(new BigDecimal(deductionAmount)).doubleValue(); |
| | | if (tmpDeductionAmount < 0) { |
| | | reqJson.put("deductionAmount", totalAccountAmount.doubleValue()); |
| | | reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); |
| | | return totalAccountAmount.doubleValue(); |
| | | } |
| | | reqJson.put("deductionAmount", deductionAmount); |
| | | reqJson.put("deductionAmount", money.doubleValue()); |
| | | reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); |
| | | return deductionAmount; |
| | | return money.doubleValue(); |
| | | } |
| | | |
| | | private double checkCouponUser(JSONObject paramObj) { |