| @@ -3,14 +3,12 @@ package com.iformall.controller; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.EnumCampaignStatus; | |||
| import com.iformall.enums.EnumCampaignType; | |||
| import com.iformall.enums.EnumCouponChannelType; | |||
| import com.iformall.service.WxCampaignService; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| @@ -63,26 +61,6 @@ public class WxCampaignController extends BaseController { | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::add"); | |||
| if (StringUtils.isEmpty(wxCampaign.getCoverImg())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "封面图不能为空"); | |||
| } | |||
| if(wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getTitle())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "标题不能为空"); | |||
| } | |||
| if (StringUtils.isEmpty(wxCampaign.getDetail())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "活动说明不能为空"); | |||
| } | |||
| }else if(wxCampaign.getType().equals(EnumCampaignType.FREE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getHtml())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); | |||
| } | |||
| }else{ | |||
| if (StringUtils.isEmpty(wxCampaign.getLink())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); | |||
| } | |||
| } | |||
| if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | |||
| String[] arys = wxCampaign.getCouponIds().split(","); | |||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | |||
| @@ -100,34 +78,20 @@ public class WxCampaignController extends BaseController { | |||
| public ResultData update(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::update"); | |||
| if (StringUtils.isEmpty(wxCampaign.getCoverImg())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "封面图不能为空"); | |||
| } | |||
| if(wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getTitle())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "标题不能为空"); | |||
| } | |||
| if (StringUtils.isEmpty(wxCampaign.getDetail())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "活动说明不能为空"); | |||
| } | |||
| }else if(wxCampaign.getType().equals(EnumCampaignType.FREE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getHtml())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); | |||
| } | |||
| }else{ | |||
| if (StringUtils.isEmpty(wxCampaign.getLink())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); | |||
| } | |||
| } | |||
| if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | |||
| String[] arys = wxCampaign.getCouponIds().split(","); | |||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | |||
| } else { | |||
| wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0])); | |||
| } | |||
| wxCampaignService.saveOrUpdate(wxCampaign); | |||
| return new ResultData(); | |||
| return wxCampaignService.saveOrUpdate(wxCampaign); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("updateStatus") | |||
| public ResultData updateStatus(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::updateStatus"); | |||
| return wxCampaignService.updateStatus(wxCampaign); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| public interface WxCampaignService { | |||
| @@ -26,9 +27,9 @@ public interface WxCampaignService { | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxCampaign record); | |||
| * @param record | |||
| */ | |||
| ResultData saveOrUpdate(WxCampaign record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| @@ -37,12 +38,7 @@ public interface WxCampaignService { | |||
| */ | |||
| void deleteById(Long id); | |||
| int getMaxSortNum(String tenantId); | |||
| ResultData updateStatus(WxCampaign wxCampaign); | |||
| } | |||
| @@ -5,19 +5,19 @@ import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.enums.EnumCampaignStatus; | |||
| import com.iformall.enums.EnumCouponChannelStatus; | |||
| import com.iformall.enums.EnumCouponChannelType; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxCampaignMapper; | |||
| import com.iformall.mapper.WxCouponChannelMapper; | |||
| import com.iformall.service.WxCampaignService; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -58,20 +58,34 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void saveOrUpdate(WxCampaign record) { | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxCampaignMapper.insertSelective(record); | |||
| } else { | |||
| wxCampaignMapper.updateByPrimaryKeySelective(record); | |||
| public ResultData saveOrUpdate(WxCampaign wxCampaign) { | |||
| if(wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getCoverImg())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "封面图不能为空"); | |||
| } | |||
| if (StringUtils.isEmpty(wxCampaign.getTitle())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "标题不能为空"); | |||
| } | |||
| if (StringUtils.isEmpty(wxCampaign.getDetail())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "活动说明不能为空"); | |||
| } | |||
| }else if(wxCampaign.getType().equals(EnumCampaignType.FREE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getHtml())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "图文不能为空"); | |||
| } | |||
| }else{ | |||
| if (StringUtils.isEmpty(wxCampaign.getLink())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "链接不能为空"); | |||
| } | |||
| } | |||
| record = wxCampaignMapper.selectByPrimaryKey(record); | |||
| if (record.getStatus().equals(EnumCampaignStatus.STATUS_THROW_IN.getCode())) { | |||
| addOrUpdateBatch(JSONArray.parseArray(record.getCouponIds(),String.class), record); | |||
| if (wxCampaign.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxCampaign.setId(idWorker.nextId()); | |||
| wxCampaignMapper.insertSelective(wxCampaign); | |||
| } else { | |||
| delBatch(record); | |||
| wxCampaignMapper.updateByPrimaryKeySelective(wxCampaign); | |||
| } | |||
| return new ResultData(Result.SUCCESS,"操作成功"); | |||
| } | |||
| public void delBatch(WxCampaign record) { | |||
| @@ -171,5 +185,17 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| return wxCampaignMapper.getMaxSortNum(tenantId); | |||
| } | |||
| @Override | |||
| public ResultData updateStatus(WxCampaign wxCampaign) { | |||
| wxCampaignMapper.updateByPrimaryKeySelective(wxCampaign); | |||
| wxCampaign = wxCampaignMapper.selectByPrimaryKey(wxCampaign); | |||
| if (wxCampaign.getStatus().equals(EnumCampaignStatus.STATUS_THROW_IN.getCode())) { | |||
| addOrUpdateBatch(JSONArray.parseArray(wxCampaign.getCouponIds(),String.class), wxCampaign); | |||
| } else { | |||
| delBatch(wxCampaign); | |||
| } | |||
| return new ResultData(Result.SUCCESS,"操作成功"); | |||
| } | |||
| } | |||
| @@ -16,6 +16,7 @@ import com.iformall.service.WxRentContractService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.io.FileUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.poi.xwpf.usermodel.XWPFDocument; | |||
| import org.apache.shiro.SecurityUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -69,6 +70,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Autowired | |||
| WxMallMapper wxMallMapper; | |||
| @Autowired | |||
| WxBrandMapper WxBrandMapper; | |||
| @Override | |||
| public Map<String, Object> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) { | |||
| Object rentContractStatusInfo = getRentContractStatusInfo(record.getTenantId()); | |||
| @@ -720,15 +724,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if (merchant!=null) { | |||
| //法人信息 | |||
| WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp(); | |||
| result.put("corpPapersNumber", wxMerchantCorp.getCorpPapersNumber() != null ? wxMerchantCorp.getCorpPapersNumber() : " "); | |||
| result.put("corpPapersNumber", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersNumber()) ? wxMerchantCorp.getCorpPapersNumber() : " "); | |||
| result.put("corpPapersType", wxMerchantCorp.getCorpPapersType() != null ? EnumPapersType.getEnum(wxMerchantCorp.getCorpPapersType()).getMessage() : " "); | |||
| result.put("corpPapersPerson", wxMerchantCorp.getCorpPapersPerson() != null ? wxMerchantCorp.getCorpPapersPerson() : " "); | |||
| result.put("corpPapersPerson", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersPerson()) ? wxMerchantCorp.getCorpPapersPerson() : " "); | |||
| //税务信息 | |||
| WxMerchantTax wxMerchantTax = merchant.getWxMerchantTax(); | |||
| result.put("taxPapersType", wxMerchantTax.getTaxPapersType() != null ? EnumTaxpayerType.getEnum(wxMerchantTax.getTaxPapersType()).getMessage() : " "); | |||
| result.put("bankName", wxMerchantTax.getBankName() != null ? wxMerchantTax.getBankName() : " "); | |||
| result.put("bankAccount", wxMerchantTax.getBankAccount() != null ? wxMerchantTax.getBankAccount() : " "); | |||
| result.put("invoiceAddressPhone", wxMerchantTax.getInvoiceAddressPhone() != null ? wxMerchantTax.getInvoiceAddressPhone() : " "); | |||
| result.put("bankName", StringUtils.isNotEmpty(wxMerchantTax.getBankName()) ? wxMerchantTax.getBankName() : " "); | |||
| result.put("bankAccount", StringUtils.isNotEmpty(wxMerchantTax.getBankAccount()) ? wxMerchantTax.getBankAccount() : " "); | |||
| result.put("invoiceAddressPhone", StringUtils.isNotEmpty(wxMerchantTax.getInvoiceAddressPhone()) ? wxMerchantTax.getInvoiceAddressPhone() : " "); | |||
| } else { | |||
| //法人信息 | |||
| result.put("corpPapersNumber", " "); | |||
| @@ -759,7 +763,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| result.put("receivePeriod", receivePeriod); | |||
| result.put("payAccount", wxRentContract.getPayAccount().equals("") ? " " : wxRentContract.getPayAccount()); | |||
| result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd")); | |||
| result.put("brand", wxRentContract.getBrand()); | |||
| //品牌 | |||
| Long brandId = wxRentContract.getBrand(); | |||
| String brand=" "; | |||
| if(brandId!=null){ | |||
| WxBrand wxBrand = WxBrandMapper.selectByPrimaryKey(brandId); | |||
| if(wxBrand!=null){ | |||
| brand=wxBrand.getName(); | |||
| } | |||
| } | |||
| result.put("brand", brand); | |||
| double adjustRatio = wxRentContract.getAdjustRatio() != null ? wxRentContract.getAdjustRatio() / 100.0 : 0; | |||
| result.put("adjustRatio", adjustRatio); | |||
| double priceRent = new BigDecimal(wxRentContract.getPrice()) | |||