| @@ -0,0 +1,387 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxRaffleActivity; | |||||
| import com.iformall.domain.po.WxRaffleActivityItem; | |||||
| import com.iformall.domain.po.WxRaffleActivityRecord; | |||||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumCashBackActivityItemRule; | |||||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||||
| import com.iformall.enums.EnumCashBackActivityStatus; | |||||
| import com.iformall.enums.EnumCashOutStatus; | |||||
| import com.iformall.enums.EnumCouponContentType; | |||||
| import com.iformall.enums.EnumCouponSourceType; | |||||
| import com.iformall.enums.EnumRentContractAppStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.WxCUserService; | |||||
| import com.iformall.service.WxCashOutService; | |||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxRaffleActivityService; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| /** | |||||
| * @author alascor | |||||
| * | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/raffle") | |||||
| @Api(description = "线下抽奖活动相关接口") | |||||
| public class WxRaffleActivityController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxRaffleActivityService wxCashBackActivityService; | |||||
| @Autowired | |||||
| WxCUserService wxCUserService; | |||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | |||||
| WxMallService wxMallService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute WxRaffleActivity wxCashBackActivity, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxCashBackActivity) wxCashBackActivity = new WxRaffleActivity(); | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCashBackActivity.updateTenantInfo(tenantInfo); | |||||
| if (null != wxCashBackActivity.getStatus() && wxCashBackActivity.getStatus().intValue()>0) { | |||||
| //已上架 | |||||
| if (wxCashBackActivity.getStatus().intValue() == EnumCashBackActivityStatus.ON_LINE.getCode().intValue()) { | |||||
| wxCashBackActivity.setValidTime(EnumYesOrNo.YES.getCode()); | |||||
| } | |||||
| //已过期 | |||||
| if (wxCashBackActivity.getStatus().intValue() == 2) { | |||||
| wxCashBackActivity.setStatus(null); | |||||
| wxCashBackActivity.setValidTime(EnumYesOrNo.NO.getCode()); | |||||
| } | |||||
| } | |||||
| wxCashBackActivity.setSortColumns(SortField.CreateDate_DESC); | |||||
| final PageInfo<WxRaffleActivity> page = wxCashBackActivityService.listActivityAsPage(wxCashBackActivity, pageNum, pageSize); | |||||
| if (null != page && null != page.getList()) { | |||||
| for (WxRaffleActivity a : page.getList()) { | |||||
| a.setItemCount(wxCashBackActivityService.getItemCount(a)); | |||||
| WxRaffleActivityRecord r = new WxRaffleActivityRecord(); | |||||
| r.setActivityId(a.getId()); | |||||
| r.updateTenantInfo(a); | |||||
| int allRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| a.setRecordCount(allRecordCount); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||||
| //int successRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| BigDecimal successRecordSum = wxCashBackActivityService.getRecordSum(r); | |||||
| if (null == successRecordSum) { | |||||
| successRecordSum = new BigDecimal(0); | |||||
| } | |||||
| a.setAuditSuccessRecordSum(successRecordSum); | |||||
| a.setAuditSuccessRecordSumRough(successRecordSum.setScale(0,BigDecimal.ROUND_HALF_UP)); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDTING.getCode()); | |||||
| // BigDecimal auditingRecordSum = wxCashBackActivityService.getRecordSum(r); | |||||
| // if (null == auditingRecordSum) { | |||||
| // auditingRecordSum = new BigDecimal(0); | |||||
| // } | |||||
| int auditingCount = wxCashBackActivityService.getRecordCount(r); | |||||
| a.setAuditingCount(auditingCount); | |||||
| if (a.getAllMerchant().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||||
| a.setMerchantCount("全部"); | |||||
| }else { | |||||
| a.setMerchantCount(String.valueOf(wxCashBackActivityService.getMerchantCount(a))); | |||||
| } | |||||
| r.setAuditStatus(null); | |||||
| BigDecimal mrchantSum = wxCashBackActivityService.getRecordMerchantSum(r); | |||||
| if (null == mrchantSum) { | |||||
| mrchantSum = new BigDecimal(0); | |||||
| } | |||||
| a.setMerchantRecordSum(mrchantSum); | |||||
| a.setMerchantRecordSumRough(mrchantSum.setScale(0,BigDecimal.ROUND_HALF_UP)); | |||||
| } | |||||
| } | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("auditingCount") | |||||
| public ResultData auditingCount() { | |||||
| WxRaffleActivityRecord r = new WxRaffleActivityRecord(); | |||||
| r.updateTenantInfo(this.getTenantInfo()); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDTING.getCode()); | |||||
| int rc = wxCashBackActivityService.getRecordCount(r); | |||||
| return new ResultData(rc); | |||||
| } | |||||
| @ApiOperation("新增修改接口") | |||||
| @PostMapping("saveOrUpdate") | |||||
| public ResultData saveOrUpdate(@RequestBody WxRaffleActivity wxCashBackActivity) { | |||||
| if (null == wxCashBackActivity.getItemList() || wxCashBackActivity.getItemList().size() <= 0 ) { | |||||
| return new ResultData(Result.ERROR,"规则不能为空"); | |||||
| } | |||||
| List<WxRaffleActivityItem> itemList = wxCashBackActivity.getItemList(); | |||||
| for (WxRaffleActivityItem i : itemList) { | |||||
| if (i.getMoneyRule().intValue() == EnumCashBackActivityItemRule.MALL_ONLY.getCode().intValue()) { | |||||
| i.setMallBackRate(i.getTotalBackRate()); | |||||
| i.setMerchantBackRate(new BigDecimal(0)); | |||||
| }else if (i.getMoneyRule().intValue() == EnumCashBackActivityItemRule.MERCHANT_ONLY.getCode().intValue()) { | |||||
| i.setMallBackRate(new BigDecimal(0)); | |||||
| i.setMerchantBackRate(i.getTotalBackRate()); | |||||
| }else if (i.getMoneyRule().intValue() == EnumCashBackActivityItemRule.SHARE.getCode().intValue()) { | |||||
| if (i.getMallBackRate().add(i.getMerchantBackRate()).intValue() != 100) { | |||||
| return new ResultData(Result.ERROR,"分担规则下,商户和商管的比例总和需要为100%"); | |||||
| } | |||||
| } | |||||
| } | |||||
| if (null != wxCashBackActivity.getAllMerchant() && EnumYesOrNo.YES.getCode().intValue() == wxCashBackActivity.getAllMerchant().intValue()) { | |||||
| }else { | |||||
| if (null == wxCashBackActivity.getMerchantList() || wxCashBackActivity.getMerchantList().size() <= 0 ) { | |||||
| return new ResultData(Result.ERROR,"商户不能为空"); | |||||
| } | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCashBackActivity.updateTenantInfo(tenantEntity); | |||||
| wxCashBackActivityService.saveOrUpdateActivity(wxCashBackActivity); | |||||
| return new ResultData(wxCashBackActivity); | |||||
| } | |||||
| @ApiOperation("新增修改接口") | |||||
| @PostMapping("online") | |||||
| public ResultData online(@RequestBody WxRaffleActivity wxCashBackActivity) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCashBackActivity.updateTenantInfo(tenantEntity); | |||||
| wxCashBackActivity.setStatus(EnumCashBackActivityStatus.ON_LINE.getCode()); | |||||
| wxCashBackActivityService.updateActivityStatus(wxCashBackActivity); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("新增修改接口") | |||||
| @PostMapping("offline") | |||||
| public ResultData offline(@RequestBody WxRaffleActivity wxCashBackActivity) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCashBackActivity.updateTenantInfo(tenantEntity); | |||||
| wxCashBackActivity.setStatus(EnumCashBackActivityStatus.OFF_LINE.getCode()); | |||||
| wxCashBackActivityService.updateActivityStatus(wxCashBackActivity); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("查询当前提现信息") | |||||
| @GetMapping("info") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||||
| public ResultData info(Long id) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivity activity = wxCashBackActivityService.getActivityById(id, tenantInfo.getTenantId()); | |||||
| activity.setItemList(wxCashBackActivityService.getActivityItems(id, tenantInfo.getTenantId())); | |||||
| activity.setMerchantList(wxCashBackActivityService.getActivityMerchants(id, tenantInfo.getTenantId(),true)); | |||||
| return new ResultData(activity); | |||||
| } | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("recordList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData recordList(@ModelAttribute WxRaffleActivityRecord wxCashBackActivityRecord, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxCashBackActivityRecord) wxCashBackActivityRecord = new WxRaffleActivityRecord(); | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantInfo); | |||||
| wxCashBackActivityRecord.setSortColumns(SortField.CreateDate_DESC); | |||||
| final PageInfo<WxRaffleActivityRecord> page = wxCashBackActivityService.listActivityRecordAsPage(wxCashBackActivityRecord, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("记录导出") | |||||
| @GetMapping("/recordExport") | |||||
| public void exportData(@ModelAttribute WxRaffleActivityRecord wxCashBackActivityRecord, HttpServletRequest request, HttpServletResponse response) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantInfo); | |||||
| wxCashBackActivityRecord.setSortColumns(SortField.CreateDate_DESC); | |||||
| PageInfo<WxRaffleActivityRecord> page = wxCashBackActivityService.listActivityRecordAsPage(wxCashBackActivityRecord, 1, 10000); | |||||
| List<WxRaffleActivityRecord> result = null; | |||||
| if (null != page && null != page.getList()) { | |||||
| result = page.getList(); | |||||
| }else { | |||||
| result = new ArrayList<WxRaffleActivityRecord>(); | |||||
| } | |||||
| wxCashBackActivityService.exportData(result,"现金返现记录",WxRaffleActivityRecord.class, request, response); | |||||
| } | |||||
| @ApiOperation("查询当前提现信息") | |||||
| @GetMapping("recordInfo") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||||
| public ResultData recordInfo(Long id) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivityRecord activity = wxCashBackActivityService.getActivityRecordById(id, tenantInfo.getTenantId()); | |||||
| if (null != activity) { | |||||
| if (null != activity.getActivityId()) { | |||||
| WxRaffleActivity a = wxCashBackActivityService.getActivityById(activity.getActivityId(), tenantInfo.getTenantId()); | |||||
| if (null != a) { | |||||
| activity.setActivityName(a.getName()); | |||||
| } | |||||
| } | |||||
| if (null != activity.getMerchantId()) { | |||||
| WxMerchant m = new WxMerchant(); | |||||
| m.updateTenantInfo(activity); | |||||
| m.setId(activity.getMerchantId()); | |||||
| WxMerchant _m = wxMerchantService.findListOne(m); | |||||
| if (null != _m) { | |||||
| activity.setMerchantName(_m.getName()); | |||||
| } | |||||
| } | |||||
| } | |||||
| return new ResultData(activity); | |||||
| } | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("itemList") | |||||
| public ResultData itemList(Long activityId) { | |||||
| return new ResultData(wxCashBackActivityService.getActivityItems(activityId, getTenantInfo().getTenantId())); | |||||
| } | |||||
| @ApiOperation("审核") | |||||
| @PostMapping("recordAudit") | |||||
| public ResultData recordAudit(@RequestBody WxRaffleActivityRecord wxCashBackActivityRecord) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantEntity); | |||||
| if (wxCashBackActivityRecord.getAuditStatus().intValue() == EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()) { | |||||
| WxRaffleActivityRecord _r = wxCashBackActivityService.getActivityRecordById(wxCashBackActivityRecord.getId(), tenantEntity.getTenantId()); | |||||
| wxCashBackActivityRecord.setOrderMoney(_r.getOrderMoney()); | |||||
| wxCashBackActivityService.calcuteMoney(wxCashBackActivityRecord); | |||||
| } | |||||
| wxCashBackActivityService.auditRecord(wxCashBackActivityRecord); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("计算金额") | |||||
| @PostMapping("calRecordMoney") | |||||
| public ResultData calRecordMoney(@RequestBody WxRaffleActivityRecord wxCashBackActivityRecord) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantEntity); | |||||
| wxCashBackActivityService.calcuteMoney(wxCashBackActivityRecord); | |||||
| return new ResultData(wxCashBackActivityRecord); | |||||
| } | |||||
| @ApiOperation("当前统计") | |||||
| @GetMapping("total") | |||||
| public ResultData total() { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivityRecord r = new WxRaffleActivityRecord(); | |||||
| r.updateTenantInfo(tenantInfo); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||||
| r.setCreateDateBegin(DateUtils.getTimeAfterDays(-30,new Date())); | |||||
| r.setCreateDateEnd(new Date()); | |||||
| int allRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| BigDecimal allSum = wxCashBackActivityService.getRecordSum(r); | |||||
| BigDecimal allMerchantSum = wxCashBackActivityService.getRecordMerchantSum(r); | |||||
| Map retMap = new HashMap(); | |||||
| retMap.put("allRecordCount", allRecordCount); | |||||
| retMap.put("allSum", allSum); | |||||
| retMap.put("allMerchantSum", allMerchantSum); | |||||
| return new ResultData(retMap); | |||||
| } | |||||
| @ApiOperation("商户统计") | |||||
| @GetMapping("activityMerchantTotal") | |||||
| public ResultData activityMerchantTotal(@ModelAttribute WxRaffleActivityRecord wxCashBackActivityRecord) { | |||||
| if (null == wxCashBackActivityRecord.getActivityId()) { | |||||
| return new ResultData(Result.ERROR,"活动ID不能为空"); | |||||
| } | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantInfo); | |||||
| wxCashBackActivityRecord.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||||
| List<Map> result = wxCashBackActivityService.getMerchantRecords(wxCashBackActivityRecord); | |||||
| if (null != result) { | |||||
| for (Map m : result) { | |||||
| Long merchantId = (Long) m.get("merchantId"); | |||||
| WxMerchant _m = new WxMerchant(); | |||||
| _m.updateTenantInfo(tenantInfo); | |||||
| _m.setId(merchantId); | |||||
| WxMerchant _mm = wxMerchantService.findListOne(_m); | |||||
| if (null != _mm) { | |||||
| m.put("merchantName", _mm.getName()); | |||||
| } | |||||
| } | |||||
| } | |||||
| return new ResultData(result); | |||||
| } | |||||
| @ApiOperation("查询当前提现信息") | |||||
| @GetMapping("merchantActivityRecordCount") | |||||
| public ResultData recordCount(@ModelAttribute WxRaffleActivityRecord wxCashBackActivityRecord) { | |||||
| if (null == wxCashBackActivityRecord.getMerchantId() || null == wxCashBackActivityRecord.getActivityId()) { | |||||
| return new ResultData(Result.ERROR,"参数错误"); | |||||
| } | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivity a = wxCashBackActivityService.getActivityById(wxCashBackActivityRecord.getActivityId(), tenantInfo.getTenantId()); | |||||
| if (null == a) { | |||||
| return new ResultData(Result.ERROR,"参数错误"); | |||||
| } | |||||
| WxRaffleActivityRecord r = new WxRaffleActivityRecord(); | |||||
| r.setActivityId(a.getId()); | |||||
| r.updateTenantInfo(a); | |||||
| r.setMerchantId(wxCashBackActivityRecord.getMerchantId()); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||||
| int allRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| BigDecimal orderMoneySum = wxCashBackActivityService.getRecordOrderMoneySum(r); | |||||
| BigDecimal recordSum = wxCashBackActivityService.getRecordSum(r); | |||||
| BigDecimal merchantRecordSum = wxCashBackActivityService.getRecordMerchantSum(r); | |||||
| Map retMap = new HashMap(); | |||||
| retMap.put("allRecordCount", allRecordCount); | |||||
| retMap.put("orderMoneySum", orderMoneySum); | |||||
| retMap.put("recordSum", recordSum); | |||||
| retMap.put("merchantRecordSum", merchantRecordSum); | |||||
| retMap.put("activityName", a.getName()); | |||||
| return new ResultData(retMap); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,199 @@ | |||||
| package com.iformall.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxRaffleActivity; | |||||
| import com.iformall.domain.po.WxRaffleActivityItem; | |||||
| import com.iformall.domain.po.WxRaffleActivityRecord; | |||||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||||
| import com.iformall.enums.EnumCashBackActivityStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.WxCUserService; | |||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxRaffleActivityService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author alascor | |||||
| * | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/api/raffle") | |||||
| @Api(description = "线下抽奖活动相关接口") | |||||
| public class WxRaffleActivityController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxRaffleActivityService wxCashBackActivityService; | |||||
| @Autowired | |||||
| WxCUserService wxCUserService; | |||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | |||||
| WxMallService wxMallService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute WxRaffleActivity wxCashBackActivity, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxCashBackActivity) wxCashBackActivity = new WxRaffleActivity(); | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCashBackActivity.updateTenantInfo(tenantInfo); | |||||
| wxCashBackActivity.setMerchantId(getLoginBUser().getMerchantId()); | |||||
| if (null != wxCashBackActivity.getStatus() && wxCashBackActivity.getStatus().intValue()>0) { | |||||
| //已上架 | |||||
| if (wxCashBackActivity.getStatus().intValue() == EnumCashBackActivityStatus.ON_LINE.getCode().intValue()) { | |||||
| wxCashBackActivity.setValidTime(EnumYesOrNo.YES.getCode()); | |||||
| } | |||||
| //已过期 | |||||
| if (wxCashBackActivity.getStatus().intValue() == 3) { | |||||
| wxCashBackActivity.setStatus(EnumCashBackActivityStatus.ON_LINE.getCode()); | |||||
| wxCashBackActivity.setValidTime(EnumYesOrNo.NO.getCode()); | |||||
| } | |||||
| //未开始 | |||||
| if (wxCashBackActivity.getStatus().intValue() == 4) { | |||||
| wxCashBackActivity.setStatus(EnumCashBackActivityStatus.ON_LINE.getCode()); | |||||
| wxCashBackActivity.setValidTime(4); | |||||
| } | |||||
| }else { | |||||
| wxCashBackActivity.setStatus(EnumCashBackActivityStatus.ON_LINE.getCode()); | |||||
| } | |||||
| wxCashBackActivity.setSortColumns(SortField.CreateDate_DESC); | |||||
| wxCashBackActivity.setHasGenericMerchant(true); | |||||
| final PageInfo<WxRaffleActivity> page = wxCashBackActivityService.listActivityAsPage(wxCashBackActivity, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("查询当前提现信息") | |||||
| @GetMapping("info") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||||
| public ResultData info(Long id) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivity activity = wxCashBackActivityService.getActivityById(id, tenantInfo.getTenantId()); | |||||
| activity.setItemList(wxCashBackActivityService.getActivityItems(id, tenantInfo.getTenantId())); | |||||
| activity.setMerchantList(wxCashBackActivityService.getActivityMerchants(id, tenantInfo.getTenantId(),false)); | |||||
| return new ResultData(activity); | |||||
| } | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("recordList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData recordList(@ModelAttribute WxRaffleActivityRecord wxCashBackActivityRecord, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxCashBackActivityRecord) wxCashBackActivityRecord = new WxRaffleActivityRecord(); | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantInfo); | |||||
| wxCashBackActivityRecord.setSortColumns(SortField.CreateDate_DESC); | |||||
| final PageInfo<WxRaffleActivityRecord> page = wxCashBackActivityService.listActivityRecordAsPage(wxCashBackActivityRecord, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("查询当前提现信息") | |||||
| @GetMapping("recordInfo") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||||
| public ResultData recordInfo(Long id) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivityRecord activity = wxCashBackActivityService.getActivityRecordById(id, tenantInfo.getTenantId()); | |||||
| if (null != activity) { | |||||
| if (null != activity.getActivityId()) { | |||||
| WxRaffleActivity a = wxCashBackActivityService.getActivityById(activity.getActivityId(), tenantInfo.getTenantId()); | |||||
| if (null != a) { | |||||
| activity.setActivityName(a.getName()); | |||||
| } | |||||
| } | |||||
| WxRaffleActivityItem item = wxCashBackActivityService.getActivityItemById(activity.getItemId(), tenantInfo.getTenantId()); | |||||
| if (null != item) { | |||||
| activity.setItemName(item.getName()); | |||||
| } | |||||
| if (null != activity.getMerchantId()) { | |||||
| WxMerchant m = new WxMerchant(); | |||||
| m.updateTenantInfo(activity); | |||||
| m.setId(activity.getMerchantId()); | |||||
| WxMerchant _m = wxMerchantService.findListOne(m); | |||||
| if (null != _m) { | |||||
| activity.setMerchantName(_m.getName()); | |||||
| } | |||||
| } | |||||
| } | |||||
| return new ResultData(activity); | |||||
| } | |||||
| @ApiOperation("查询当前提现信息") | |||||
| @GetMapping("recordCount") | |||||
| public ResultData recordCount(@ModelAttribute WxRaffleActivityRecord wxCashBackActivityRecord) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxRaffleActivity a = wxCashBackActivityService.getActivityById(wxCashBackActivityRecord.getActivityId(), tenantInfo.getTenantId()); | |||||
| if (null == a) { | |||||
| return new ResultData(Result.ERROR,"参数错误"); | |||||
| } | |||||
| WxRaffleActivityRecord r = new WxRaffleActivityRecord(); | |||||
| r.setActivityId(a.getId()); | |||||
| r.updateTenantInfo(a); | |||||
| int allRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||||
| int auditedRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDT_FAIL.getCode()); | |||||
| int failRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDTING.getCode()); | |||||
| int auditingRecordCount = wxCashBackActivityService.getRecordCount(r); | |||||
| Map retMap = new HashMap(); | |||||
| retMap.put("allRecordCount", allRecordCount); | |||||
| retMap.put("auditedRecordCount", auditedRecordCount); | |||||
| retMap.put("failRecordCount", failRecordCount); | |||||
| retMap.put("auditingRecordCount", auditingRecordCount); | |||||
| return new ResultData(retMap); | |||||
| } | |||||
| @ApiOperation("新增修改接口") | |||||
| @PostMapping("saveOrUpdateRecord") | |||||
| public ResultData saveOrUpdate(@RequestBody WxRaffleActivityRecord wxCashBackActivityRecord) { | |||||
| if (null == wxCashBackActivityRecord.getOrderMoney() ) { | |||||
| return new ResultData(Result.ERROR,"订单金额不能为空"); | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCashBackActivityRecord.updateTenantInfo(tenantEntity); | |||||
| WxRaffleActivity a = wxCashBackActivityService.getActivityById(wxCashBackActivityRecord.getActivityId(), tenantEntity.getTenantId()); | |||||
| if (null == a) { | |||||
| return new ResultData(Result.ERROR,"参数错误"); | |||||
| } | |||||
| if (wxCashBackActivityRecord.getOrderMoney().compareTo(a.getLimitMoney()) < 0) { | |||||
| return new ResultData(Result.ERROR,"该金额低于活动标准"); | |||||
| } | |||||
| wxCashBackActivityRecord.setMerchantId(getLoginBUser().getMerchantId()); | |||||
| wxCashBackActivityService.saveOrUpdateRecord(wxCashBackActivityRecord); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,78 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @TableName(value = "wx_raffle_activity") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxRaffleActivity extends TenantEntity { | |||||
| private Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "EnumCashBackActivityStatus", name = "status") | |||||
| private Integer status; | |||||
| @TableField(exist = false) | |||||
| private List<Integer> statusList; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||||
| private Date updateDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "名称", name = "name") | |||||
| private String name; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "开始时间", name = "startTime") | |||||
| private Date startTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "结束时间", name = "endTime") | |||||
| private Date endTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "最低订单金额", name = "limitMoney") | |||||
| private BigDecimal limitMoney; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "是否全部商户EnumYesOrNo", name = "allMerchant") | |||||
| private Integer allMerchant; | |||||
| @TableField(exist = false) | |||||
| private Integer validTime; | |||||
| @TableField(exist = false) | |||||
| private Integer itemCount; | |||||
| @TableField(exist = false) | |||||
| private Integer recordCount; | |||||
| @TableField(exist = false) | |||||
| private String merchantCount; | |||||
| @TableField(exist = false) | |||||
| private BigDecimal auditSuccessRecordSum; | |||||
| @TableField(exist = false) | |||||
| private BigDecimal auditSuccessRecordSumRough; | |||||
| @TableField(exist = false) | |||||
| private Integer auditingCount; | |||||
| @TableField(exist = false) | |||||
| private BigDecimal merchantRecordSum; | |||||
| @TableField(exist = false) | |||||
| private BigDecimal merchantRecordSumRough; | |||||
| @TableField(exist = false) | |||||
| private List<WxRaffleActivityItem> itemList; | |||||
| @TableField(exist = false) | |||||
| private List<WxRaffleActivityMerchant> merchantList; | |||||
| @TableField(exist = false) | |||||
| private Date begin; | |||||
| @TableField(exist = false) | |||||
| private Date end; | |||||
| @TableField(exist = false) | |||||
| private Long merchantId; | |||||
| @TableField(exist = false) | |||||
| private boolean hasGenericMerchant; | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | |||||
| @TableName(value = "wx_raffle_activity_item") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxRaffleActivityItem extends TenantEntity { | |||||
| private Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||||
| private Date createDate; | |||||
| @TableField(exist = false) | |||||
| private Date createDateBegin; | |||||
| @TableField(exist = false) | |||||
| private Date createDateEnd; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||||
| private Date updateDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "活动编号", name = "activityId") | |||||
| private Long activityId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "名称", name = "name") | |||||
| private String name; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "EnumCashBackActivityItemRule", name = "moneyRule") | |||||
| private Integer moneyRule; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "总返现比例", name = "totalBackRate") | |||||
| private BigDecimal totalBackRate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商管返现比例", name = "mallBackRate") | |||||
| private BigDecimal mallBackRate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户返现比例", name = "merchantBackRate") | |||||
| private BigDecimal merchantBackRate; | |||||
| } | |||||
| @@ -0,0 +1,31 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.util.Date; | |||||
| @TableName(value = "wx_raffle_activity_merchant") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxRaffleActivityMerchant extends TenantEntity { | |||||
| private Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||||
| private Date updateDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "名称", name = "activityId") | |||||
| private Long activityId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "最低订单金额", name = "merchantId") | |||||
| private Long merchantId; | |||||
| @TableField(exist = false) | |||||
| private WxMerchant merchant; | |||||
| } | |||||
| @@ -0,0 +1,95 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @TableName(value = "wx_raffle_activity_record") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxRaffleActivityRecord extends TenantEntity { | |||||
| private Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "活动", name = "activityId") | |||||
| private Long activityId; | |||||
| @Excel(name="活动名称",width = 20,orderNum = "1") | |||||
| @TableField(exist = false) | |||||
| private String activityName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | |||||
| private Long merchantId; | |||||
| @Excel(name="商户名称",width = 20,orderNum = "2") | |||||
| @TableField(exist = false) | |||||
| private String merchantName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "选项", name = "itemId") | |||||
| private Long itemId; | |||||
| @Excel(name="选项名称",width = 20,orderNum = "3") | |||||
| @TableField(exist = false) | |||||
| private String itemName; | |||||
| @Excel(name="订单号",width = 20,orderNum = "4") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "订单号", name = "orderNo") | |||||
| private String orderNo; | |||||
| @Excel(name="订单金额",width = 20,orderNum = "5") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "订单金额", name = "orderMoney") | |||||
| private BigDecimal orderMoney; | |||||
| @Excel(name="客户姓名",width = 20,orderNum = "6") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "客户姓名", name = "cusName") | |||||
| private String cusName; | |||||
| @Excel(name="客户电话",width = 20,orderNum = "7") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "客户电话", name = "phone") | |||||
| private String phone; | |||||
| @Excel(name="客户地址",width = 20,orderNum = "8") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "客户地址", name = "address") | |||||
| private String address; | |||||
| @Excel(name="状态",width = 20,replace = {"审核中_0", "审核通过_1", "审核驳回_2"},orderNum = "9") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "EnumCashBackActivityRecordStatus", name = "auditStatus") | |||||
| private Integer auditStatus; | |||||
| @TableField(exist = false) | |||||
| private List<Integer> auditStatusList; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "审核内容", name = "auditRemark") | |||||
| private String auditRemark; | |||||
| @Excel(name="返现比例(%)",width = 20,orderNum = "10") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "返现比率", name = "cashRate") | |||||
| private BigDecimal cashRate; | |||||
| @Excel(name="返现金额",width = 20,orderNum = "11") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "返现金额", name = "cashMoney") | |||||
| private BigDecimal cashMoney; | |||||
| @Excel(name="商管承担比例(%)",width = 20,orderNum = "12") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商管承担比例", name = "mallRate") | |||||
| private BigDecimal mallRate; | |||||
| @Excel(name="商管承担返现金额",width = 20,orderNum = "13") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商管承担返现金额", name = "mallCashMoney") | |||||
| private BigDecimal mallCashMoney; | |||||
| @Excel(name="商户承担比例(%)",width = 20,orderNum = "14") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户承担比例", name = "merchantRate") | |||||
| private BigDecimal merchantRate; | |||||
| @Excel(name="商户承担返现金额",width = 20,orderNum = "15") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户承担返现金额", name = "merchantCashMoney") | |||||
| private BigDecimal merchantCashMoney; | |||||
| @Excel(name="提交时间",width = 20,format="yyyy-MM-dd HH:mm:ss", orderNum = "16") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||||
| private Date createDate; | |||||
| @TableField(exist = false) | |||||
| private Date createDateBegin; | |||||
| @TableField(exist = false) | |||||
| private Date createDateEnd; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||||
| private Date updateDate; | |||||
| @TableField(exist = false) | |||||
| private List<Long> activityIdList; | |||||
| @TableField(exist = false) | |||||
| private List<Long> merchantIdList; | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxRaffleActivityItem; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| public interface WxRaffleActivityItemMapper extends CommonMapper<WxRaffleActivityItem, Long> { | |||||
| WxRaffleActivityItem selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| List<WxRaffleActivityItem> findList(WxRaffleActivityItem wxCashBackActivity); | |||||
| Integer itemCount(WxRaffleActivityItem wxCashBackActivity); | |||||
| void delete(WxRaffleActivityItem wxCashBackActivity); | |||||
| } | |||||
| @@ -0,0 +1,20 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxRaffleActivity; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| public interface WxRaffleActivityMapper extends CommonMapper<WxRaffleActivity, Long> { | |||||
| WxRaffleActivity selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| List<WxRaffleActivity> findList(WxRaffleActivity wxRaffleActivity); | |||||
| void updateStatus(WxRaffleActivity wxRaffleActivity); | |||||
| List<Long> findIds(WxRaffleActivity wxRaffleActivity); | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxRaffleActivityMerchant; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| public interface WxRaffleActivityMerchantMapper extends CommonMapper<WxRaffleActivityMerchant, Long> { | |||||
| WxRaffleActivityMerchant selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| List<WxRaffleActivityMerchant> findList(WxRaffleActivityMerchant wxCashBackActivityMerchant); | |||||
| void delete(WxRaffleActivityMerchant wxCashBackActivityMerchant); | |||||
| int merchantCount(WxRaffleActivityMerchant wxCashBackActivityMerchant); | |||||
| List<Long> findActivityIdList(@Param("merchantId")Long merchantId,@Param("tenantId")String tenantId); | |||||
| } | |||||
| @@ -0,0 +1,29 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxRaffleActivityRecord; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| public interface WxRaffleActivityRecordMapper extends CommonMapper<WxRaffleActivityRecord, Long> { | |||||
| WxRaffleActivityRecord selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| List<WxRaffleActivityRecord> findList(WxRaffleActivityRecord wxCashBackActivity); | |||||
| void updateStatus(WxRaffleActivityRecord wxCashBackActivity); | |||||
| Integer selectCount(WxRaffleActivityRecord wxCashBackActivity); | |||||
| BigDecimal sumAll(WxRaffleActivityRecord wxCashBackActivity); | |||||
| BigDecimal sumMerchant(WxRaffleActivityRecord wxCashBackActivity); | |||||
| BigDecimal sumOrderMoney(WxRaffleActivityRecord wxCashBackActivity); | |||||
| List<Map> selectMerchantRecords(WxRaffleActivityRecord wxCashBackActivity); | |||||
| } | |||||
| @@ -0,0 +1,76 @@ | |||||
| package com.iformall.service; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxRaffleActivity; | |||||
| import com.iformall.domain.po.WxRaffleActivityItem; | |||||
| import com.iformall.domain.po.WxRaffleActivityMerchant; | |||||
| import com.iformall.domain.po.WxRaffleActivityRecord; | |||||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||||
| public interface WxRaffleActivityService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxRaffleActivity> listActivityAsPage(WxRaffleActivity record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<WxRaffleActivityItem> listActivityItemAsPage(WxRaffleActivityItem record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<WxRaffleActivityRecord> listActivityRecordAsPage(WxRaffleActivityRecord record, Integer pageIndex, Integer pageSize); | |||||
| int getItemCount(WxRaffleActivity record); | |||||
| int getRecordCount(WxRaffleActivityRecord record); | |||||
| BigDecimal getRecordSum(WxRaffleActivityRecord record); | |||||
| BigDecimal getRecordMerchantSum(WxRaffleActivityRecord record); | |||||
| BigDecimal getRecordOrderMoneySum(WxRaffleActivityRecord record); | |||||
| List<Map> getMerchantRecords(WxRaffleActivityRecord record); | |||||
| int getMerchantCount(WxRaffleActivity record); | |||||
| void saveOrUpdateActivity(WxRaffleActivity record); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxRaffleActivity getActivityById(Long id,String tenantId); | |||||
| WxRaffleActivityItem getActivityItemById(Long id,String tenantId); | |||||
| WxRaffleActivityRecord getActivityRecordById(Long id,String tenantId); | |||||
| /** | |||||
| *更新状态 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void updateActivityStatus(WxRaffleActivity record); | |||||
| List<WxRaffleActivityItem> getActivityItems(Long activityId,String tenantId); | |||||
| List<WxRaffleActivityMerchant> getActivityMerchants(Long activityId,String tenantId,boolean hasMerchantInfo); | |||||
| void exportData(List objectList,String sheetName,Class objectCalss,HttpServletRequest request, HttpServletResponse response); | |||||
| void auditRecord(WxRaffleActivityRecord record); | |||||
| void calcuteMoney(WxRaffleActivityRecord record); | |||||
| void saveOrUpdateRecord(WxRaffleActivityRecord record); | |||||
| } | |||||
| @@ -0,0 +1,391 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxRaffleActivity; | |||||
| import com.iformall.domain.po.WxRaffleActivityItem; | |||||
| import com.iformall.domain.po.WxRaffleActivityMerchant; | |||||
| import com.iformall.domain.po.WxRaffleActivityRecord; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.WxCUserBasicInfoVo; | |||||
| import com.iformall.enums.EnumCashBackActivityItemRule; | |||||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.mapper.WxMerchantMapper; | |||||
| import com.iformall.mapper.WxRaffleActivityItemMapper; | |||||
| import com.iformall.mapper.WxRaffleActivityMapper; | |||||
| import com.iformall.mapper.WxRaffleActivityMerchantMapper; | |||||
| import com.iformall.mapper.WxRaffleActivityRecordMapper; | |||||
| import com.iformall.service.ExcelService; | |||||
| import com.iformall.service.WxRaffleActivityService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| @Service | |||||
| public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxRaffleActivityMapper wxActivityMapper; | |||||
| @Autowired | |||||
| WxRaffleActivityItemMapper wxActivityItemMapper; | |||||
| @Autowired | |||||
| WxRaffleActivityRecordMapper wxActivityRecordMapper; | |||||
| @Autowired | |||||
| WxRaffleActivityMerchantMapper wxActivityMerchantMapper; | |||||
| @Autowired | |||||
| WxMerchantMapper wxMerchantMapper; | |||||
| @Autowired | |||||
| ExcelService excelService; | |||||
| @Override | |||||
| public PageInfo<WxRaffleActivity> listActivityAsPage(WxRaffleActivity record, Integer pageIndex, Integer pageSize) { | |||||
| if (null != record.getMerchantId()) { | |||||
| //如果包含所有商户通用的活动 | |||||
| if (record.isHasGenericMerchant()) { | |||||
| WxRaffleActivity _a = new WxRaffleActivity(); | |||||
| _a.updateTenantInfo(record); | |||||
| _a.setAllMerchant(EnumYesOrNo.YES.getCode()); | |||||
| List<Long> allMids = wxActivityMapper.findIds(_a); | |||||
| List<Long> aids = wxActivityMerchantMapper.findActivityIdList(record.getMerchantId(), record.getTenantId()); | |||||
| if (null == aids || aids.size() <= 0 ) { | |||||
| if (null == allMids || allMids.size() <= 0 ) { | |||||
| record.setId(-1L); | |||||
| }else { | |||||
| record.setIds(allMids); | |||||
| } | |||||
| }else { | |||||
| allMids.addAll(aids); | |||||
| record.setIds(allMids); | |||||
| } | |||||
| }else { | |||||
| List<Long> aids = wxActivityMerchantMapper.findActivityIdList(record.getMerchantId(), record.getTenantId()); | |||||
| if (null == aids || aids.size() <= 0 ) { | |||||
| record.setId(-1L); | |||||
| }else { | |||||
| record.setIds(aids); | |||||
| } | |||||
| } | |||||
| } | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxActivityMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public PageInfo<WxRaffleActivityItem> listActivityItemAsPage(WxRaffleActivityItem record, Integer pageIndex, Integer pageSize) { | |||||
| PageInfo<WxRaffleActivityItem> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxActivityItemMapper.findList(record)); | |||||
| return page; | |||||
| } | |||||
| private void initRecordQueryParam(WxRaffleActivityRecord record) { | |||||
| if (StringUtils.isNotBlank(record.getActivityName())) { | |||||
| WxRaffleActivity a = new WxRaffleActivity(); | |||||
| a.updateTenantInfo(record); | |||||
| a.setName(record.getActivityName()); | |||||
| List<Long> aids = wxActivityMapper.findIds(a); | |||||
| if (null == aids || aids.size() <= 0 ) { | |||||
| record.setId(-1L); | |||||
| }else { | |||||
| record.setActivityIdList(aids); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotBlank(record.getMerchantName())) { | |||||
| WxMerchant merchant = new WxMerchant(); | |||||
| merchant.updateTenantInfo(record); | |||||
| merchant.setName(record.getMerchantName()); | |||||
| List<Long> mids = wxMerchantMapper.findIdList(merchant); | |||||
| if (null == mids || mids.size() <= 0 ) { | |||||
| record.setId(-1L); | |||||
| }else { | |||||
| record.setMerchantIdList(mids); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public PageInfo<WxRaffleActivityRecord> listActivityRecordAsPage(WxRaffleActivityRecord record, | |||||
| Integer pageIndex, Integer pageSize) { | |||||
| initRecordQueryParam(record); | |||||
| PageInfo<WxRaffleActivityRecord> recordPage = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxActivityRecordMapper.findList(record)); | |||||
| if (null != recordPage && null != recordPage.getList()) { | |||||
| handerRecordPageData(record,recordPage.getList()); | |||||
| } | |||||
| return recordPage; | |||||
| } | |||||
| private void handerRecordPageData(TenantEntity tenantEntity,List<WxRaffleActivityRecord> recordList) { | |||||
| if (null == recordList || recordList.size() <=0 ) { | |||||
| return; | |||||
| } | |||||
| List<Long> aidList = new ArrayList<Long>(); | |||||
| List<Long> midList = new ArrayList<Long>(); | |||||
| List<Long> itemIdList = new ArrayList<Long>(); | |||||
| for (WxRaffleActivityRecord r : recordList) { | |||||
| aidList.add(r.getActivityId()); | |||||
| midList.add(r.getMerchantId()); | |||||
| itemIdList.add(r.getItemId()); | |||||
| } | |||||
| WxRaffleActivity aq = new WxRaffleActivity(); | |||||
| aq.updateTenantInfo(tenantEntity); | |||||
| aq.setIds(aidList); | |||||
| List<WxRaffleActivity> aqList = wxActivityMapper.findList(aq); | |||||
| Map<Long,WxRaffleActivity> activityMap = new HashMap<Long,WxRaffleActivity>(); | |||||
| if (null != aqList && aqList.size() > 0 ) { | |||||
| for (WxRaffleActivity a : aqList) { | |||||
| activityMap.put(a.getId(), a); | |||||
| } | |||||
| } | |||||
| WxMerchant mq = new WxMerchant(); | |||||
| mq.updateTenantInfo(tenantEntity); | |||||
| mq.setIds(midList); | |||||
| List<WxMerchant> mlist = wxMerchantMapper.findList(mq); | |||||
| Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>(); | |||||
| if (null != mlist && mlist.size() > 0 ) { | |||||
| for (WxMerchant m : mlist) { | |||||
| merchantMap.put(m.getId(), m); | |||||
| } | |||||
| } | |||||
| WxRaffleActivityItem itemq = new WxRaffleActivityItem(); | |||||
| itemq.updateTenantInfo(tenantEntity); | |||||
| itemq.setIds(itemIdList); | |||||
| List<WxRaffleActivityItem> itemList = wxActivityItemMapper.findList(itemq); | |||||
| Map<Long,WxRaffleActivityItem> itemMap = new HashMap<Long,WxRaffleActivityItem>(); | |||||
| if (null != itemList && itemList.size() > 0 ) { | |||||
| for (WxRaffleActivityItem m : itemList) { | |||||
| itemMap.put(m.getId(), m); | |||||
| } | |||||
| } | |||||
| for (WxRaffleActivityRecord _r : recordList) { | |||||
| if (null != _r.getActivityId()) { | |||||
| WxRaffleActivity _a = activityMap.get(_r.getActivityId()); | |||||
| if (null != _a) { | |||||
| _r.setActivityName(_a.getName()); | |||||
| } | |||||
| } | |||||
| if (null != _r.getMerchantId()) { | |||||
| WxMerchant _m = merchantMap.get(_r.getMerchantId()); | |||||
| if (null != _m) { | |||||
| _r.setMerchantName(_m.getName()); | |||||
| } | |||||
| } | |||||
| if (null != _r.getItemId()) { | |||||
| WxRaffleActivityItem _i = itemMap.get(_r.getItemId()); | |||||
| if (null != _i) { | |||||
| _r.setItemName(_i.getName()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public int getItemCount(WxRaffleActivity record) { | |||||
| WxRaffleActivityItem item = new WxRaffleActivityItem(); | |||||
| item.setActivityId(record.getId()); | |||||
| item.updateTenantInfo(record); | |||||
| return wxActivityItemMapper.itemCount(item); | |||||
| } | |||||
| @Override | |||||
| public WxRaffleActivity getActivityById(Long id,String tenantId) { | |||||
| return wxActivityMapper.selectById(id,tenantId); | |||||
| } | |||||
| @Override | |||||
| public WxRaffleActivityItem getActivityItemById(Long id,String tenantId) { | |||||
| return wxActivityItemMapper.selectById(id,tenantId); | |||||
| } | |||||
| @Override | |||||
| public WxRaffleActivityRecord getActivityRecordById(Long id,String tenantId) { | |||||
| return wxActivityRecordMapper.selectById(id,tenantId); | |||||
| } | |||||
| @Override | |||||
| public void updateActivityStatus(WxRaffleActivity record) { | |||||
| wxActivityMapper.updateStatus(record); | |||||
| } | |||||
| @Override | |||||
| public List<WxRaffleActivityItem> getActivityItems(Long activityId,String tenantId) { | |||||
| WxRaffleActivityItem ai = new WxRaffleActivityItem(); | |||||
| ai.setTenantId(tenantId); | |||||
| ai.setActivityId(activityId); | |||||
| return wxActivityItemMapper.findList(ai); | |||||
| } | |||||
| @Override | |||||
| public int getRecordCount(WxRaffleActivityRecord record) { | |||||
| return wxActivityRecordMapper.selectCount(record); | |||||
| } | |||||
| @Override | |||||
| public BigDecimal getRecordSum(WxRaffleActivityRecord record) { | |||||
| return wxActivityRecordMapper.sumAll(record); | |||||
| } | |||||
| @Override | |||||
| public BigDecimal getRecordMerchantSum(WxRaffleActivityRecord record) { | |||||
| return wxActivityRecordMapper.sumMerchant(record); | |||||
| } | |||||
| @Override | |||||
| public BigDecimal getRecordOrderMoneySum(WxRaffleActivityRecord record) { | |||||
| return wxActivityRecordMapper.sumOrderMoney(record); | |||||
| } | |||||
| @Override | |||||
| public int getMerchantCount(WxRaffleActivity record) { | |||||
| WxRaffleActivityMerchant m = new WxRaffleActivityMerchant(); | |||||
| m.setActivityId(record.getId()); | |||||
| m.updateTenantInfo(record); | |||||
| return wxActivityMerchantMapper.merchantCount(m); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdateActivity(WxRaffleActivity record) { | |||||
| boolean isUpdate = true; | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| if (null == record.getId()) { | |||||
| isUpdate = false; | |||||
| record.setId(idWorker.nextId()); | |||||
| } | |||||
| if (isUpdate) { | |||||
| record.setUpdateDate(new Date()); | |||||
| wxActivityMapper.updateById(record); | |||||
| }else { | |||||
| record.setCreateDate(new Date()); | |||||
| record.setUpdateDate(new Date()); | |||||
| wxActivityMapper.insert(record); | |||||
| } | |||||
| if (isUpdate) { | |||||
| WxRaffleActivityItem item = new WxRaffleActivityItem(); | |||||
| item.updateTenantInfo(record); | |||||
| item.setActivityId(record.getId()); | |||||
| wxActivityItemMapper.delete(item); | |||||
| } | |||||
| List<WxRaffleActivityItem> itemList = record.getItemList(); | |||||
| if (null != itemList) { | |||||
| for (WxRaffleActivityItem i : itemList) { | |||||
| i.setId(idWorker.nextId()); | |||||
| i.setActivityId(record.getId()); | |||||
| i.updateTenantInfo(record); | |||||
| wxActivityItemMapper.insert(i); | |||||
| } | |||||
| } | |||||
| if (isUpdate) { | |||||
| WxRaffleActivityMerchant merchant = new WxRaffleActivityMerchant(); | |||||
| merchant.updateTenantInfo(record); | |||||
| merchant.setActivityId(record.getId()); | |||||
| wxActivityMerchantMapper.delete(merchant); | |||||
| } | |||||
| List<WxRaffleActivityMerchant> merchantList = record.getMerchantList(); | |||||
| if (null != merchantList) { | |||||
| for (WxRaffleActivityMerchant m : merchantList) { | |||||
| m.setId(idWorker.nextId()); | |||||
| m.setActivityId(record.getId()); | |||||
| m.updateTenantInfo(record); | |||||
| wxActivityMerchantMapper.insert(m); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public List<WxRaffleActivityMerchant> getActivityMerchants(Long activityId, String tenantId,boolean hasMerchantInfo) { | |||||
| WxRaffleActivityMerchant m = new WxRaffleActivityMerchant(); | |||||
| m.setActivityId(activityId); | |||||
| m.setTenantId(tenantId); | |||||
| List<WxRaffleActivityMerchant> amlist = wxActivityMerchantMapper.findList(m); | |||||
| if (hasMerchantInfo && null != amlist && amlist.size() > 0 ) { | |||||
| WxMerchant mq = new WxMerchant(); | |||||
| mq.setTenantId(tenantId); | |||||
| List<WxMerchant> mlist = wxMerchantMapper.findList(mq); | |||||
| Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>(); | |||||
| if (null != mlist && mlist.size() > 0 ) { | |||||
| for (WxMerchant _m : mlist) { | |||||
| merchantMap.put(_m.getId(), _m); | |||||
| } | |||||
| } | |||||
| for (WxRaffleActivityMerchant am : amlist) { | |||||
| if (null != am.getMerchantId()) { | |||||
| WxMerchant _mm = merchantMap.get(am.getMerchantId()); | |||||
| if (null != _mm) { | |||||
| am.setMerchant(_mm); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return amlist; | |||||
| } | |||||
| @Override | |||||
| public void exportData(List objectList,String sheetName,Class objectCalss,HttpServletRequest request, HttpServletResponse response) { | |||||
| excelService.exportExcel(objectList, null, sheetName, objectCalss, sheetName+".xlsx", response, false); | |||||
| } | |||||
| @Override | |||||
| public void auditRecord(WxRaffleActivityRecord record) { | |||||
| record.setUpdateDate(new Date()); | |||||
| wxActivityRecordMapper.updateStatus(record); | |||||
| } | |||||
| @Override | |||||
| public void calcuteMoney(WxRaffleActivityRecord record) { | |||||
| WxRaffleActivityItem item = wxActivityItemMapper.selectById(record.getItemId(), record.getTenantId()); | |||||
| EnumCashBackActivityItemRule moneyRule = EnumCashBackActivityItemRule.getEnum(item.getMoneyRule()); | |||||
| record.setCashRate(item.getTotalBackRate()); | |||||
| record.setCashMoney(record.getOrderMoney().multiply(item.getTotalBackRate()).divide(new BigDecimal(100)).setScale(3,BigDecimal.ROUND_HALF_UP)); | |||||
| record.setMallRate(item.getMallBackRate()); | |||||
| record.setMerchantRate(item.getMerchantBackRate()); | |||||
| if (moneyRule == EnumCashBackActivityItemRule.MALL_ONLY) { | |||||
| record.setMallCashMoney(record.getCashMoney()); | |||||
| record.setMerchantCashMoney(new BigDecimal(0)); | |||||
| }else if(moneyRule == EnumCashBackActivityItemRule.MERCHANT_ONLY) { | |||||
| record.setMallCashMoney(new BigDecimal(0)); | |||||
| record.setMerchantCashMoney(record.getCashMoney()); | |||||
| }else if (moneyRule == EnumCashBackActivityItemRule.SHARE) { | |||||
| record.setMallCashMoney(record.getCashMoney().multiply(item.getMallBackRate()).divide(new BigDecimal(100)).setScale(3,BigDecimal.ROUND_HALF_UP)); | |||||
| record.setMerchantCashMoney(record.getCashMoney().multiply(item.getMerchantBackRate()).divide(new BigDecimal(100)).setScale(3,BigDecimal.ROUND_HALF_UP)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdateRecord(WxRaffleActivityRecord record) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| if (null == record.getId()) { | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateDate(new Date()); | |||||
| record.setUpdateDate(new Date()); | |||||
| wxActivityRecordMapper.insert(record); | |||||
| }else { | |||||
| record.setUpdateDate(new Date()); | |||||
| wxActivityRecordMapper.updateById(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public List<Map> getMerchantRecords(WxRaffleActivityRecord record) { | |||||
| initRecordQueryParam(record); | |||||
| return wxActivityRecordMapper.selectMerchantRecords(record); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,80 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxRaffleActivityItemMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRaffleActivityItem"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| <result column="activity_id" jdbcType="BIGINT" property="activityId" /> | |||||
| <result column="money_rule" jdbcType="INTEGER" property="moneyRule" /> | |||||
| <result column="total_back_rate" jdbcType="DECIMAL" property="totalBackRate" /> | |||||
| <result column="mall_back_rate" jdbcType="DECIMAL" property="mallBackRate" /> | |||||
| <result column="merchant_back_rate" jdbcType="DECIMAL" property="merchantBackRate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`name`,`create_date`,`update_date`,`activity_id`,`money_rule`, | |||||
| `total_back_rate`,`mall_back_rate`,`merchant_back_rate` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != createDateBegin"> | |||||
| and `create_date` >= #{createDateBegin} | |||||
| </if> | |||||
| <if test=" null != createDateEnd"> | |||||
| and `create_date` <= #{createDateEnd} | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and `name` like concat('%', #{name},'%') | |||||
| </if> | |||||
| <if test=" null != activityId "> | |||||
| and `activity_id` = #{activityId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity_item where id = #{id} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxRaffleActivityItem" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity_item | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="itemCount" parameterType="com.iformall.domain.po.WxRaffleActivityItem" resultType="Integer"> | |||||
| select count(1) from wx_raffle_activity_item where `activity_id` = #{activityId} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <delete id="delete" parameterType="com.iformall.domain.po.WxRaffleActivityItem"> | |||||
| delete from wx_raffle_activity_item | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </delete> | |||||
| </mapper> | |||||
| @@ -0,0 +1,114 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxRaffleActivityMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRaffleActivity"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| <result column="start_time" jdbcType="TIMESTAMP" property="startTime" /> | |||||
| <result column="end_time" jdbcType="TIMESTAMP" property="endTime" /> | |||||
| <result column="limit_money" jdbcType="DECIMAL" property="limitMoney" /> | |||||
| <result column="all_merchant" jdbcType="INTEGER" property="allMerchant" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`status`,`name`,`create_date`,`update_date`,`start_time`,`end_time`,`limit_money`,`all_merchant` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != begin"> | |||||
| and `start_time` >= #{begin} | |||||
| </if> | |||||
| <if test=" null != end"> | |||||
| and `end_time` <= #{end} | |||||
| </if> | |||||
| <if test=" null != allMerchant"> | |||||
| and `all_merchant` = #{allMerchant} | |||||
| </if> | |||||
| <!-- 未过期 --> | |||||
| <if test=" 1 == validTime"> | |||||
| and end_time >= now() | |||||
| </if> | |||||
| <!-- 已过期 --> | |||||
| <if test=" 0 == validTime"> | |||||
| and end_time <= now() | |||||
| </if> | |||||
| <!-- 未开始 --> | |||||
| <if test=" 4 == validTime"> | |||||
| and start_time >= now() | |||||
| </if> | |||||
| <if test=" null != name and name != '' "> | |||||
| and `name` like concat('%', #{name},'%') | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and `status` = #{status} | |||||
| </if> | |||||
| <if test=" null != statusList "> | |||||
| and status in | |||||
| <foreach collection="statusList" index="index" item="statusItem" open="(" separator="," close=")"> | |||||
| #{statusItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity where id = #{id} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxRaffleActivity" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="findIds" parameterType="com.iformall.domain.po.WxRaffleActivity" resultType="Long"> | |||||
| select id from wx_raffle_activity | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <update id="updateStatus" parameterType="com.iformall.domain.po.WxRaffleActivity"> | |||||
| update wx_raffle_activity | |||||
| set `status` = #{status}, | |||||
| `update_date` = #{updateDate} | |||||
| where id=#{id} | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| </update> | |||||
| </mapper> | |||||
| @@ -0,0 +1,75 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxRaffleActivityMerchantMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRaffleActivityMerchant"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="activity_id" jdbcType="BIGINT" property="activityId" /> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`activity_id`,`merchant_id`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != activityId "> | |||||
| and `activity_id` = #{activityId} | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity_merchant where id = #{id} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxRaffleActivityMerchant" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity_merchant | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <delete id="delete" parameterType="com.iformall.domain.po.WxRaffleActivityMerchant"> | |||||
| delete from wx_raffle_activity_merchant | |||||
| where `activity_id` = #{activityId} | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| </delete> | |||||
| <select id="merchantCount" parameterType="com.iformall.domain.po.WxRaffleActivityMerchant" resultType="Integer"> | |||||
| select count(1) from wx_raffle_activity_merchant | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="findActivityIdList" parameterType="java.util.HashMap" resultType="Long"> | |||||
| select activity_id from wx_raffle_activity_merchant where merchant_id = #{merchantId} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,183 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxRaffleActivityRecordMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRaffleActivityRecord"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="activity_id" jdbcType="BIGINT" property="activityId" /> | |||||
| <result column="item_id" jdbcType="BIGINT" property="itemId" /> | |||||
| <result column="order_no" jdbcType="VARCHAR" property="orderNo" /> | |||||
| <result column="order_money" jdbcType="DECIMAL" property="orderMoney" /> | |||||
| <result column="cus_name" jdbcType="VARCHAR" property="cusName" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | |||||
| <result column="address" jdbcType="VARCHAR" property="address" /> | |||||
| <result column="audit_remark" jdbcType="VARCHAR" property="auditRemark" /> | |||||
| <result column="audit_status" jdbcType="INTEGER" property="auditStatus" /> | |||||
| <result column="cash_rate" jdbcType="DECIMAL" property="cashRate" /> | |||||
| <result column="cash_money" jdbcType="DECIMAL" property="cashMoney" /> | |||||
| <result column="mall_rate" jdbcType="DECIMAL" property="mallRate" /> | |||||
| <result column="mall_cash_money" jdbcType="DECIMAL" property="mallCashMoney" /> | |||||
| <result column="merchant_rate" jdbcType="DECIMAL" property="merchantRate" /> | |||||
| <result column="merchant_cash_money" jdbcType="DECIMAL" property="merchantCashMoney" /> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`activity_id`,`item_id`,`order_no`,`order_money`,`cus_name`,`create_date`,`update_date`,`phone`, | |||||
| `address`,`audit_remark`,`audit_status`,`cash_rate`,`cash_money`,`mall_rate`,`mall_cash_money`,`merchant_rate`,`merchant_cash_money`,`merchant_id` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != activityId "> | |||||
| and `activity_id` = #{activityId} | |||||
| </if> | |||||
| <if test=" null != itemId "> | |||||
| and `item_id` = #{itemId} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != createDateBegin"> | |||||
| and `create_date` >= #{createDateBegin} | |||||
| </if> | |||||
| <if test=" null != createDateEnd"> | |||||
| and `create_date` <= #{createDateEnd} | |||||
| </if> | |||||
| <if test=" null != cusName and cusName != '' "> | |||||
| and `cus_name` like concat('%', #{cusName},'%') | |||||
| </if> | |||||
| <if test=" null != phone and phone != '' "> | |||||
| and `phone` like concat('%', #{phone},'%') | |||||
| </if> | |||||
| <if test=" null != orderNo and orderNo != '' "> | |||||
| and `order_no` like concat('%', #{orderNo},'%') | |||||
| </if> | |||||
| <if test=" null != auditStatus "> | |||||
| and `audit_status` = #{auditStatus} | |||||
| </if> | |||||
| <if test=" null != activityIdList "> | |||||
| and activity_id in | |||||
| <foreach collection="activityIdList" index="index" item="aidItem" open="(" separator="," close=")"> | |||||
| #{aidItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != merchantIdList "> | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")"> | |||||
| #{midItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != auditStatusList "> | |||||
| and audit_status in | |||||
| <foreach collection="auditStatusList" index="index" item="statusItem" open="(" separator="," close=")"> | |||||
| #{statusItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity_record where id = #{id} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_raffle_activity_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <update id="updateStatus" parameterType="com.iformall.domain.po.WxRaffleActivityRecord"> | |||||
| update wx_raffle_activity_record | |||||
| set `audit_status` = #{auditStatus}, | |||||
| <if test=" null != auditRemark and '' != auditRemark"> | |||||
| `audit_remark` = #{auditRemark}, | |||||
| </if> | |||||
| <if test=" null != cashRate"> | |||||
| `cash_rate` = #{cashRate}, | |||||
| </if> | |||||
| <if test=" null != cashMoney"> | |||||
| `cash_money` = #{cashMoney}, | |||||
| </if> | |||||
| <if test=" null != mallRate"> | |||||
| `mall_rate` = #{mallRate}, | |||||
| </if> | |||||
| <if test=" null != mallCashMoney"> | |||||
| `mall_cash_money` = #{mallCashMoney}, | |||||
| </if> | |||||
| <if test=" null != merchantRate"> | |||||
| `merchant_rate` = #{merchantRate}, | |||||
| </if> | |||||
| <if test=" null != merchantCashMoney"> | |||||
| `merchant_cash_money` = #{merchantCashMoney}, | |||||
| </if> | |||||
| <if test=" null != itemId"> | |||||
| `item_id` = #{itemId}, | |||||
| </if> | |||||
| `update_date` = #{updateDate} | |||||
| where id=#{id} | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| </update> | |||||
| <select id="selectCount" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultType="Integer"> | |||||
| select count(1) from wx_raffle_activity_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="sumAll" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultType="BigDecimal"> | |||||
| select sum(cash_money) from wx_raffle_activity_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="sumMerchant" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultType="BigDecimal"> | |||||
| select sum(merchant_cash_money) from wx_raffle_activity_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="sumOrderMoney" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultType="BigDecimal"> | |||||
| select sum(order_money) from wx_raffle_activity_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="selectMerchantRecords" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultType="java.util.HashMap"> | |||||
| select merchant_id as merchantId,count(1) as orderCount,sum(order_money) as orderMoney, sum(cash_money) as allMoney,sum(merchant_cash_money) as merchantMenoy from wx_raffle_activity_record | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| group by merchant_id | |||||
| </select> | |||||
| </mapper> | |||||