| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.account.AccountDto; |
| | | import com.java110.dto.app.AppDto; |
| | | import com.java110.dto.couponUser.CouponUserDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.feeDiscount.ComputeDiscountDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.payFeeDetailDiscount.PayFeeDetailDiscountDto; |
| | | import com.java110.dto.parkingSpaceApply.ParkingSpaceApplyDto; |
| | | import com.java110.dto.repair.RepairDto; |
| | | import com.java110.dto.repair.RepairUserDto; |
| | | import com.java110.entity.order.Orders; |
| | | import com.java110.fee.bmo.fee.IFeeBMO; |
| | | import com.java110.intf.acct.IAccountInnerServiceSMO; |
| | | import com.java110.intf.acct.ICouponUserDetailV1InnerServiceSMO; |
| | | import com.java110.intf.acct.ICouponUserV1InnerServiceSMO; |
| | | import com.java110.intf.community.IParkingSpaceApplyV1InnerServiceSMO; |
| | | import com.java110.intf.community.IRepairUserInnerServiceSMO; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | | import com.java110.intf.fee.*; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.po.accountDetail.AccountDetailPo; |
| | | import com.java110.po.applyRoomDiscount.ApplyRoomDiscountPo; |
| | | import com.java110.po.car.OwnerCarPo; |
| | | import com.java110.po.couponUser.CouponUserPo; |
| | | import com.java110.po.couponUserDetail.CouponUserDetailPo; |
| | | import com.java110.po.owner.RepairPoolPo; |
| | | import com.java110.po.owner.RepairUserPo; |
| | | import com.java110.po.parkingSpaceApply.ParkingSpaceApplyPo; |
| | | import com.java110.po.payFeeDetailDiscount.PayFeeDetailDiscountPo; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | |
| | | import java.util.List; |
| | | |
| | | @Java110Cmd(serviceCode = "fee.payFeeConfirm") |
| | | public class PayFeeConfirmCmd extends AbstractServiceCmdListener { |
| | | public class PayFeeConfirmCmd extends Cmd { |
| | | |
| | | @Autowired |
| | | private IFeeBMO feeBMOImpl; |
| | |
| | | private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl; |
| | | @Autowired |
| | | private ICouponUserDetailV1InnerServiceSMO couponUserDetailV1InnerServiceSMOImpl; |
| | | @Autowired |
| | | private IParkingSpaceApplyV1InnerServiceSMO parkingSpaceApplyV1InnerServiceSMOImpl; |
| | | @Autowired |
| | | private IAccountInnerServiceSMO accountInnerServiceSMOImpl; |
| | | |
| | | //默认序列 |
| | | protected static final int DEFAULT_SEQ = 1; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | String paramIn = CommonCache.getAndRemoveValue("payFeePre" + reqJson.getString("oId")); |
| | | JSONObject paramObj = JSONObject.parseObject(paramIn); |
| | |
| | | paramObj.put("remark", "线上小程序支付"); |
| | | } |
| | | |
| | | //处理现金账户 |
| | | dealAccount(paramObj); |
| | | |
| | | paramObj.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); |
| | | |
| | | //处理 优惠折扣 |
| | | addDiscount(paramObj); |
| | | |
| | | //修改已使用优惠卷信息 |
| | | modifyCouponUser(paramObj); |
| | | |
| | | //添加单元信息 |
| | | feeBMOImpl.addFeePreDetail(paramObj); |
| | | feeBMOImpl.modifyPreFee(paramObj); |
| | | |
| | | double discountPrice = paramObj.getDouble("discountPrice"); |
| | | if (discountPrice > 0) { |
| | | addDiscount(paramObj); |
| | | } |
| | | |
| | | dealOwnerCartEndTime(paramObj); |
| | | |
| | | //修改已使用优惠卷信息 |
| | | modifyCouponUser(paramObj); |
| | | |
| | | //判断是否有派单属性ID |
| | | FeeAttrDto feeAttrDto = new FeeAttrDto(); |
| | |
| | | if (flag < 1) { |
| | | throw new CmdException("更新微信派单池信息失败"); |
| | | } |
| | | } |
| | | //修改报修派单状态 |
| | | if (feeAttrDtos != null && feeAttrDtos.size() > 0) { |
| | | |
| | | RepairUserDto repairUserDto = new RepairUserDto(); |
| | | repairUserDto.setRepairId(feeAttrDtos.get(0).getValue()); |
| | | repairUserDto.setState(RepairUserDto.STATE_PAY_FEE); |
| | |
| | | DecimalFormat df = new DecimalFormat("0.00"); |
| | | BigDecimal payment_amount = new BigDecimal(paramObj.getString("receivableAmount")); |
| | | repairUserPo.setContext("已支付" + df.format(payment_amount) + "元"); |
| | | int flag = repairUserNewV1InnerServiceSMOImpl.updateRepairUserNew(repairUserPo); |
| | | flag = repairUserNewV1InnerServiceSMOImpl.updateRepairUserNew(repairUserPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("更新微信派单池信息失败"); |
| | | } |
| | |
| | | //获取bId |
| | | String bId = feeDetailDtoList.get(0).getbId(); |
| | | //获取优惠 |
| | | List<ComputeDiscountDto> computeDiscountDtos = (List<ComputeDiscountDto>) paramObj.get("computeDiscountDtos"); |
| | | if (computeDiscountDtos != null) { |
| | | for (ComputeDiscountDto computeDiscountDto : computeDiscountDtos) { |
| | | //List<ComputeDiscountDto> computeDiscountDtos = (List<ComputeDiscountDto>) paramObj.get("computeDiscountDtos"); |
| | | JSONArray computeDiscountDtos = paramObj.getJSONArray("computeDiscountDtos"); |
| | | ComputeDiscountDto computeDiscountDto = null; |
| | | if (computeDiscountDtos != null && computeDiscountDtos.size() > 0) { |
| | | for (int accountIndex = 0; accountIndex < computeDiscountDtos.size(); accountIndex++) { |
| | | computeDiscountDto = BeanConvertUtil.covertBean(computeDiscountDtos.getJSONObject(accountIndex), ComputeDiscountDto.class); |
| | | if (!StringUtil.isEmpty(computeDiscountDto.getArdId())) { |
| | | ApplyRoomDiscountPo applyRoomDiscountPo = new ApplyRoomDiscountPo(); |
| | | //将业务id更新到空置房优惠里面 |
| | |
| | | } |
| | | |
| | | } |
| | | //回调判断 车位申请表是否有数据,有数据则刷新申请表状态为 3003 完成状态即可 |
| | | //判断车辆是否已经有申请单 |
| | | ParkingSpaceApplyDto parkingSpaceApplyDto = new ParkingSpaceApplyDto(); |
| | | parkingSpaceApplyDto.setFeeId(paramObj.getString("feeId")); |
| | | parkingSpaceApplyDto.setState("2002");//审核中 |
| | | List<ParkingSpaceApplyDto> parkingSpaceApplyDtos = parkingSpaceApplyV1InnerServiceSMOImpl.queryParkingSpaceApplys(parkingSpaceApplyDto); |
| | | if (parkingSpaceApplyDtos != null && parkingSpaceApplyDtos.size() > 0) { |
| | | ParkingSpaceApplyPo parkingSpaceApplyPo = new ParkingSpaceApplyPo(); |
| | | parkingSpaceApplyPo.setApplyId(parkingSpaceApplyDtos.get(0).getApplyId()); |
| | | parkingSpaceApplyPo.setState("3003"); |
| | | int flag = parkingSpaceApplyV1InnerServiceSMOImpl.updateParkingSpaceApply(parkingSpaceApplyPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("更新车位申请表状态失败"); |
| | | } |
| | | } |
| | | |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.success()); |
| | | } |
| | | |
| | | private void dealAccount(JSONObject paramObj) { |
| | | |
| | | if (!paramObj.containsKey("deductionAmount") || paramObj.getDouble("deductionAmount") <= 0) { |
| | | return; |
| | | } |
| | | |
| | | BigDecimal deductionAmount = new BigDecimal(paramObj.getDouble("deductionAmount")); |
| | | |
| | | JSONArray accountDtos = paramObj.getJSONArray("selectUserAccount"); |
| | | BigDecimal amount = null; |
| | | AccountDto accountDto = null; |
| | | for (int accountIndex = 0; accountIndex < accountDtos.size(); accountIndex++) { |
| | | accountDto = BeanConvertUtil.covertBean(accountDtos.getJSONObject(accountIndex), AccountDto.class); |
| | | amount = new BigDecimal(Double.parseDouble(accountDto.getAmount())); |
| | | AccountDetailPo accountDetailPo = new AccountDetailPo(); |
| | | accountDetailPo.setAcctId(accountDto.getAcctId()); |
| | | accountDetailPo.setObjId(accountDto.getObjId()); |
| | | accountDetailPo.setObjType(accountDto.getObjType()); |
| | | if (amount.doubleValue() < deductionAmount.doubleValue()) { |
| | | accountDetailPo.setAmount(amount.doubleValue() + ""); |
| | | deductionAmount = deductionAmount.subtract(amount).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | } else { |
| | | accountDetailPo.setAmount(deductionAmount.doubleValue() + ""); |
| | | deductionAmount = deductionAmount.subtract(deductionAmount).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | int flag = accountInnerServiceSMOImpl.withholdAccount(accountDetailPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("扣款失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (deductionAmount.doubleValue() > 0) { |
| | | throw new CmdException("账户金额不足"); |
| | | } |
| | | |
| | | paramObj.put("remark", paramObj.getString("remark") + "-现金账户抵扣" + paramObj.getDouble("deductionAmount") + "元"); |
| | | |
| | | } |
| | | |
| | | private void modifyCouponUser(JSONObject paramObj) { |
| | | FeeDto feeInfo = (FeeDto) paramObj.get("feeInfo"); |
| | | List<CouponUserDto> couponUserDtos = (List<CouponUserDto>) paramObj.get("couponUserDtos"); |
| | | for (CouponUserDto couponUser : couponUserDtos) { |
| | | if (!paramObj.containsKey("couponPrice") || paramObj.getDouble("couponPrice") <= 0) { |
| | | return; |
| | | } |
| | | //FeeDto feeInfo = (FeeDto) paramObj.get("feeInfo"); |
| | | CouponUserDto couponUserDto = null; |
| | | JSONArray couponUserDtos = paramObj.getJSONArray("couponUserDtos"); |
| | | CouponUserDto couponUser = null; |
| | | for (int accountIndex = 0; accountIndex < couponUserDtos.size(); accountIndex++) { |
| | | couponUser = BeanConvertUtil.covertBean(couponUserDtos.getJSONObject(accountIndex), CouponUserDto.class); |
| | | couponUserDto = new CouponUserDto(); |
| | | couponUserDto.setCouponId(couponUser.getCouponId()); |
| | | couponUserDto.setState(CouponUserDto.COUPON_STATE_RUN); |
| | | List<CouponUserDto> couponUserDtos1 = couponUserV1InnerServiceSMOImpl.queryCouponUsers(couponUserDto); |
| | | if (couponUserDtos1 == null || couponUserDtos1.size() < 1) { |
| | | throw new CmdException("优惠券被使用"); |
| | | } |
| | | CouponUserPo couponUserPo = new CouponUserPo(); |
| | | couponUserPo.setState(CouponUserDto.COUPON_STATE_STOP); |
| | | couponUserPo.setCouponId(couponUser.getCouponId()); |
| | |
| | | couponUserDetailPo.setUserId(couponUser.getUserId()); |
| | | couponUserDetailPo.setCouponName(couponUser.getCouponName()); |
| | | couponUserDetailPo.setUserName(couponUser.getUserName()); |
| | | couponUserDetailPo.setObjId(feeInfo.getFeeId()); |
| | | couponUserDetailPo.setObjType(feeInfo.getFeeTypeCd()); |
| | | couponUserDetailPo.setObjId(paramObj.getString("feeId")); |
| | | couponUserDetailPo.setObjType(paramObj.getString("feeTypeCd")); |
| | | couponUserDetailPo.setOrderId(paramObj.getString("oId")); |
| | | fage = couponUserDetailV1InnerServiceSMOImpl.saveCouponUserDetail(couponUserDetailPo); |
| | | if (fage < 1) { |
| | |
| | | } |
| | | } |
| | | |
| | | paramObj.put("remark", paramObj.getString("remark") + "-优惠劵抵扣" + paramObj.getDouble("couponPrice") + "元"); |
| | | |
| | | } |
| | | |
| | | private void addDiscount(JSONObject paramObj) { |
| | | List<ComputeDiscountDto> computeDiscountDtos = (List<ComputeDiscountDto>) paramObj.get("computeDiscountDtos"); |
| | | for (ComputeDiscountDto computeDiscountDto : computeDiscountDtos) { |
| | | |
| | | if (!paramObj.containsKey("discountPrice") || paramObj.getDouble("discountPrice") <= 0) { |
| | | return; |
| | | } |
| | | JSONArray computeDiscountDtos = paramObj.getJSONArray("computeDiscountDtos"); |
| | | ComputeDiscountDto computeDiscountDto = null; |
| | | for (int accountIndex = 0; accountIndex < computeDiscountDtos.size(); accountIndex++) { |
| | | computeDiscountDto = BeanConvertUtil.covertBean(computeDiscountDtos.getJSONObject(accountIndex), ComputeDiscountDto.class); |
| | | if (computeDiscountDto.getDiscountPrice() <= 0) { |
| | | continue; |
| | | } |