/** * 新增/修改(第三方调用,会同时维护经销商购买的服务表) * * @param dealerBuySerLog refrenceId 经销商购买的服务表的主键(由第三方调用者提供) dealerBuyServiceId * 经销商购买的服务的主键(由第三方调用者提供,若记录不存在:新增、记录已存在:修改) dealerId 经销商编号(必填) dealerName 经销商名称 serviceId * 服务编号(必填) servicerCate 服务类别(读字典:字典编码 servicerCate)(必填) buyNum 购买数量(必填) buyMoney 购买的金额(必填) * chargType 购买类型(1:续期、2:增加数量)(必填) beginTime 服务开始时间 endTime 服务结束时间 * @author 周光暖 */ @Override public DealerBuyService saveByClient(DealerBuySerLog dealerBuySerLog) throws BusinessException { DealerBuyService dealerBuyService = builtDealerBuyService(dealerBuySerLog); // 判断服务是否存在 if (!webServiceItemsService.isExist( dealerBuySerLog.getServiceId(), dealerBuySerLog.getServicerCate(), dealerBuySerLog.getChargType())) { throw new BusinessException(ClientConst.PARAMERROR.code, "网站服务不存在"); } DealerBuyService dbDealerBuyService = this.findBy(dealerBuySerLog.getDealerId(), dealerBuySerLog.getServiceId()); if (null == dbDealerBuyService) { dealerBuyService.setRefrenceId(SerialnoUtils.buildPrimaryKey()); dealerBuyService.setCreateTime(CalendarUtils.getCurrentLong()); this.handChargType(dealerBuyService, null); this.insertSelective(dealerBuyService); } else { dealerBuyService.setRefrenceId(dbDealerBuyService.getRefrenceId()); this.handChargType(dealerBuyService, dbDealerBuyService); dealerBuyService.setBuyMoney( dealerBuyService.getBuyMoney().add(dbDealerBuyService.getBuyMoney())); this.updateByPrimaryKeySelective(dealerBuyService); } dealerBuySerLog.setBuyTime(dealerBuyService.getBuyTime()); dealerBuySerLog.setEndTime(dealerBuyService.getEndTime()); dealerBuySerLogService.createDealerBuySerLog(dealerBuySerLog); return dealerBuyService; }
private DealerBuyService builtDealerBuyService(DealerBuySerLog dealerBuySerLog) { DealerBuyService dealerBuyService = new DealerBuyService(); dealerBuyService.setDealerId(dealerBuySerLog.getDealerId()); dealerBuyService.setDealerName(dealerBuySerLog.getDealerName()); dealerBuyService.setServiceId(dealerBuySerLog.getServiceId()); dealerBuyService.setServicerCate(dealerBuySerLog.getServicerCate()); dealerBuyService.setChargType(dealerBuySerLog.getChargType()); dealerBuyService.setBuyTime(CalendarUtils.getCurrentLong()); dealerBuyService.setBeginTime(dealerBuySerLog.getBeginTime()); dealerBuyService.setBuyMoney(dealerBuySerLog.getBuyMoney()); return dealerBuyService; }