| | |
| | | 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.IRoomInnerServiceSMO; |
| | | import com.java110.intf.fee.*; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.po.account.AccountPo; |
| | | import com.java110.po.accountDetail.AccountDetailPo; |
| | | import com.java110.po.feeAccountDetail.FeeAccountDetailPo; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | |
| | | 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")); |
| | |
| | | reqJson.put("deductionAmount", 0.0); |
| | | return 0.0; |
| | | } |
| | | |
| | | BigDecimal money = new BigDecimal(0); |
| | | BigDecimal totalAccountAmount = new BigDecimal(0); |
| | | for (AccountDto tmpAccountDto : accountDtos) { |
| | | if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2004")) { //积分账户 |
| | | String maximum = ""; |
| | | String deduction = ""; |
| | | for (int index = 0; index < selectUserAccount.size(); index++) { |
| | | JSONObject param = selectUserAccount.getJSONObject(index); |
| | | if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) { //积分账户 |
| | | maximum = param.getString("maximumNumber"); |
| | | deduction = param.getString("deductionProportion"); |
| | | } |
| | | } |
| | | //账户金额 |
| | | BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount()); |
| | | //获取最大抵扣积分 |
| | | BigDecimal maximumNumber = new BigDecimal(maximum); |
| | | //获取积分抵扣比例 |
| | | BigDecimal deductionProportion = new BigDecimal(deduction); |
| | | int flag = amount.compareTo(maximumNumber); |
| | | BigDecimal redepositAmount = new BigDecimal("0.00"); |
| | | BigDecimal integralAmount = new BigDecimal("0.00"); |
| | | if (flag == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣 |
| | | redepositAmount = maximumNumber; |
| | | integralAmount = amount.subtract(maximumNumber); |
| | | } |
| | | if (flag > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣 |
| | | redepositAmount = maximumNumber; |
| | | integralAmount = amount.subtract(maximumNumber); |
| | | } |
| | | if (flag == -1) { //账户积分小于最大使用积分,就用账户积分抵扣 |
| | | redepositAmount = amount; |
| | | } |
| | | if (flag < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣 |
| | | redepositAmount = amount; |
| | | } |
| | | if (flag == 0) { //账户积分等于最大使用积分 |
| | | redepositAmount = amount; |
| | | } |
| | | //更新账户信息 |
| | | // AccountPo accountPo = new AccountPo(); |
| | | // accountPo.setAcctId(tmpAccountDto.getAcctId()); |
| | | // accountPo.setAmount(integralAmount.toString()); |
| | | // accountInnerServiceSMOImpl.updateAccount(accountPo); |
| | | //生成账户详情 |
| | | // AccountDetailPo accountDetailPo = new AccountDetailPo(); |
| | | // accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); |
| | | // accountDetailPo.setAcctId(tmpAccountDto.getAcctId()); |
| | | // accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出 |
| | | // accountDetailPo.setRelAcctId("-1"); |
| | | // accountDetailPo.setAmount(redepositAmount.toString()); |
| | | // accountDetailPo.setObjType("6006"); //6006 个人 7007 商户 |
| | | // accountDetailPo.setObjId(tmpAccountDto.getObjId()); |
| | | // accountDetailPo.setOrderId("-1"); |
| | | // accountDetailPo.setbId("-1"); |
| | | // accountDetailPo.setRemark("手机端积分抵扣"); |
| | | // accountDetailPo.setCreateTime(new Date()); |
| | | // accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo); |
| | | //计算积分换算的金额 |
| | | BigDecimal divide = redepositAmount.divide(deductionProportion); |
| | | BigDecimal dedAmount = new BigDecimal(deductionAmount); |
| | | //计算实付金额 |
| | | int flag2 = divide.compareTo(dedAmount); |
| | | BigDecimal subtract = new BigDecimal("0.00"); |
| | | //生成抵扣明细记录 |
| | | FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); |
| | | if (flag2 == -1) { //积分换算金额小于应付金额 |
| | | //subtract = dedAmount.subtract(divide); |
| | | BigDecimal multiply = divide.multiply(deductionProportion); |
| | | feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额 |
| | | } else if (flag < 1) { //积分换算金额小于等于应付金额 |
| | | //subtract = dedAmount.subtract(divide); |
| | | BigDecimal multiply = divide.multiply(deductionProportion); |
| | | feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额 |
| | | } else { |
| | | BigDecimal multiply = dedAmount.multiply(deductionProportion); |
| | | feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额 |
| | | } |
| | | reqJson.put("receivedMoney", divide); |
| | | // feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); |
| | | // feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId()); |
| | | // feeAccountDetailPo.setCommunityId(reqJson.getString("communityId")); |
| | | // feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 |
| | | // feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); |
| | | money = divide; |
| | | } else if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2003")) { //现金账户 |
| | | if (AccountDto.ACCT_TYPE_CASH.equals(tmpAccountDto.getAcctType())) { //现金账户 |
| | | //账户金额 |
| | | BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount()); |
| | | //获取应收金额 |
| | |
| | | if (flag == 0) { //现金账户等于应收金额 |
| | | redepositAmount = amount; |
| | | } |
| | | //更新账户信息 |
| | | // AccountPo accountPo = new AccountPo(); |
| | | // accountPo.setAcctId(tmpAccountDto.getAcctId()); |
| | | // accountPo.setAmount(integralAmount.toString()); |
| | | // accountInnerServiceSMOImpl.updateAccount(accountPo); |
| | | //生成账户详情 |
| | | // AccountDetailPo accountDetailPo = new AccountDetailPo(); |
| | | // accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); |
| | | // accountDetailPo.setAcctId(tmpAccountDto.getAcctId()); |
| | | // accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出 |
| | | // accountDetailPo.setRelAcctId("-1"); |
| | | // accountDetailPo.setAmount(redepositAmount.toString()); |
| | | // accountDetailPo.setObjType("6006"); //6006 个人 7007 商户 |
| | | // accountDetailPo.setObjId(tmpAccountDto.getObjId()); |
| | | // accountDetailPo.setOrderId("-1"); |
| | | // accountDetailPo.setbId("-1"); |
| | | // accountDetailPo.setRemark("手机端现金账户抵扣"); |
| | | // accountDetailPo.setCreateTime(new Date()); |
| | | // accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo); |
| | | //生成抵扣明细记录 |
| | | // FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); |
| | | // feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); |
| | | // feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId()); |
| | | // feeAccountDetailPo.setCommunityId(reqJson.getString("communityId")); |
| | | // feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 |
| | | // feeAccountDetailPo.setAmount(redepositAmount.toString()); //积分抵扣金额 |
| | | // feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); |
| | | money = money.add(redepositAmount); |
| | | /*int flag2 = money.compareTo(amount); |
| | | if (flag2 == 1) { //剩余金额大于现金账户 |
| | | money = money.subtract(amount); |
| | | } |
| | | if (flag2 > -1) { //剩余金额大于等于现金账户 |
| | | money = money.subtract(amount); |
| | | } |
| | | if (flag2 == -1) { //剩余金额小于现金账户 |
| | | money = new BigDecimal(0); |
| | | } |
| | | if (flag2 < 1) { //剩余金额小于等于现金账户 |
| | | money = new BigDecimal(0); |
| | | } |
| | | if (flag2 == 0) { //剩余金额等于现金账户 |
| | | money = new BigDecimal(0); |
| | | }*/ |
| | | } |
| | | // totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount())); |
| | | } |
| | | |
| | | /* 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("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); |
| | | return deductionAmount;*/ |
| | | |
| | | reqJson.put("deductionAmount", money.doubleValue()); |
| | | reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); |
| | | return money.doubleValue(); |