| @@ -1,15 +1,23 @@ | |||
| package com.iformall.controller.market; | |||
| 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.WxCashBackActivity; | |||
| import com.iformall.domain.po.WxCashBackActivityRecord; | |||
| import com.iformall.domain.po.WxCashOut; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| 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.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.WxCashBackActivityService; | |||
| @@ -20,17 +28,24 @@ 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.util.ArrayList; | |||
| import java.util.List; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| /** | |||
| * @author alascor | |||
| * | |||
| @@ -86,13 +101,91 @@ public class WxCashBackActivityController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增修改接口") | |||
| @PostMapping("saveOrUpdate") | |||
| public ResultData saveOrUpdate(@RequestBody WxCashBackActivity wxCashBackActivity) { | |||
| if (null == wxCashBackActivity.getItemList() || wxCashBackActivity.getItemList().size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"规则不能为空"); | |||
| } | |||
| 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(); | |||
| } | |||
| @ApiOperation("新增修改接口") | |||
| @PostMapping("online") | |||
| public ResultData online(@RequestBody WxCashBackActivity 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 WxCashBackActivity wxCashBackActivity) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxCashBackActivity.updateTenantInfo(tenantEntity); | |||
| wxCashBackActivity.setStatus(EnumCashBackActivityStatus.OFF_LINE.getCode()); | |||
| wxCashBackActivityService.updateActivityStatus(wxCashBackActivity); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("查询当前提现信息") | |||
| @GetMapping("getInfo") | |||
| @GetMapping("info") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||
| public ResultData getCurrentCashOutData(Long id) { | |||
| public ResultData info(Long id) { | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| WxCashOut out = wxCashOutService.getById(id, tenantInfo.getTenantId()); | |||
| return new ResultData(out); | |||
| WxCashBackActivity activity = wxCashBackActivityService.getActivityById(id, tenantInfo.getTenantId()); | |||
| activity.setItemList(wxCashBackActivityService.getActivityItems(id, tenantInfo.getTenantId())); | |||
| activity.setMerchantList(wxCashBackActivityService.getActivityMerchants(id, tenantInfo.getTenantId())); | |||
| 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 WxCashBackActivityRecord wxCashBackActivityRecord, Integer pageNum, Integer pageSize) { | |||
| if (null == wxCashBackActivityRecord) wxCashBackActivityRecord = new WxCashBackActivityRecord(); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCashBackActivityRecord.updateTenantInfo(tenantInfo); | |||
| wxCashBackActivityRecord.setSortColumns(SortField.CreateDate_DESC); | |||
| final PageInfo<WxCashBackActivityRecord> page = wxCashBackActivityService.listActivityRecordAsPage(wxCashBackActivityRecord, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("记录导出") | |||
| @GetMapping("/recordExport") | |||
| public void exportData(@ModelAttribute WxCashBackActivityRecord wxCashBackActivityRecord, HttpServletRequest request, HttpServletResponse response) { | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCashBackActivityRecord.updateTenantInfo(tenantInfo); | |||
| wxCashBackActivityRecord.setSortColumns(SortField.CreateDate_DESC); | |||
| PageInfo<WxCashBackActivityRecord> page = wxCashBackActivityService.listActivityRecordAsPage(wxCashBackActivityRecord, 1, 10000); | |||
| List<WxCashBackActivityRecord> result = null; | |||
| if (null != page && null != page.getList()) { | |||
| result = page.getList(); | |||
| }else { | |||
| result = new ArrayList<WxCashBackActivityRecord>(); | |||
| } | |||
| wxCashBackActivityService.exportData(result,"现金返现记录",WxCashBackActivityRecord.class, request, response); | |||
| } | |||
| @ApiOperation("新增修改接口") | |||
| @PostMapping("recordAudit") | |||
| public ResultData recordAudit(@RequestBody WxCashBackActivityRecord wxCashBackActivityRecord) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxCashBackActivityRecord.updateTenantInfo(tenantEntity); | |||
| wxCashBackActivityService.updateActivityStatus(wxCashBackActivity); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -51,4 +51,10 @@ public class WxCashBackActivity extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private Integer auditSuccessRecordCount; | |||
| @TableField(exist = false) | |||
| private List<WxCashBackActivityItem> itemList; | |||
| @TableField(exist = false) | |||
| private List<WxCashBackActivityMerchant> merchantList; | |||
| } | |||
| @@ -58,4 +58,13 @@ public class WxCashBackActivityRecord extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | |||
| private Long merchantId; | |||
| @TableField(exist = false) | |||
| private String activityName; | |||
| @TableField(exist = false) | |||
| private String merchantName; | |||
| @TableField(exist = false) | |||
| private List<Long> activityIdList; | |||
| @TableField(exist = false) | |||
| private List<Long> merchantIdList; | |||
| } | |||
| @@ -14,4 +14,6 @@ public interface WxCashBackActivityItemMapper extends CommonMapper<WxCashBackAct | |||
| List<WxCashBackActivityItem> findList(WxCashBackActivityItem wxCashBackActivity); | |||
| Integer itemCount(WxCashBackActivityItem wxCashBackActivity); | |||
| void delete(WxCashBackActivityItem wxCashBackActivity); | |||
| } | |||
| @@ -13,5 +13,7 @@ public interface WxCashBackActivityMapper extends CommonMapper<WxCashBackActivit | |||
| List<WxCashBackActivity> findList(WxCashBackActivity wxCashBackActivity); | |||
| void updateStatus(WxCashBackActivity wxCashBackActivity); | |||
| List<Long> findIds(WxCashBackActivity wxCashBackActivity); | |||
| } | |||
| @@ -11,10 +11,10 @@ public interface WxCashBackActivityMerchantMapper extends CommonMapper<WxCashBac | |||
| WxCashBackActivityMerchant selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxCashBackActivityMerchant> findList(WxCashBackActivityMerchant wxCashBackActivity); | |||
| List<WxCashBackActivityMerchant> findList(WxCashBackActivityMerchant wxCashBackActivityMerchant); | |||
| void delete(WxCashBackActivityMerchant wxCashBackActivity); | |||
| void delete(WxCashBackActivityMerchant wxCashBackActivityMerchant); | |||
| int merchantCount(WxCashBackActivityMerchant wxCashBackActivity); | |||
| int merchantCount(WxCashBackActivityMerchant wxCashBackActivityMerchant); | |||
| } | |||
| @@ -2,9 +2,14 @@ package com.iformall.service; | |||
| import java.util.List; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxCashBackActivity; | |||
| import com.iformall.domain.po.WxCashBackActivityItem; | |||
| import com.iformall.domain.po.WxCashBackActivityMerchant; | |||
| import com.iformall.domain.po.WxCashBackActivityRecord; | |||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||
| public interface WxCashBackActivityService { | |||
| @@ -21,10 +26,14 @@ public interface WxCashBackActivityService { | |||
| PageInfo<WxCashBackActivityItem> listActivityItemAsPage(WxCashBackActivityItem record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxCashBackActivityRecord> listActivityRecordAsPage(WxCashBackActivityRecord record, Integer pageIndex, Integer pageSize); | |||
| int getItemCount(WxCashBackActivity record); | |||
| int getRecordCount(WxCashBackActivity record,EnumCashBackActivityRecordStatus status); | |||
| int getMerchantCount(WxCashBackActivity record); | |||
| void saveOrUpdateActivity(WxCashBackActivity record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| @@ -44,5 +53,9 @@ public interface WxCashBackActivityService { | |||
| List<WxCashBackActivityItem> getActivityItems(Long activityId,String tenantId); | |||
| List<WxCashBackActivityMerchant> getActivityMerchants(Long activityId,String tenantId); | |||
| void exportData(List objectList,String sheetName,Class objectCalss,HttpServletRequest request, HttpServletResponse response); | |||
| } | |||
| @@ -1,16 +1,23 @@ | |||
| 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.WxCashBackActivity; | |||
| import com.iformall.domain.po.WxCashBackActivityItem; | |||
| import com.iformall.domain.po.WxCashBackActivityMerchant; | |||
| import com.iformall.domain.po.WxCashBackActivityRecord; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCUserBasicInfoVo; | |||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||
| import com.iformall.mapper.WxCashBackActivityItemMapper; | |||
| import com.iformall.mapper.WxCashBackActivityMapper; | |||
| import com.iformall.mapper.WxCashBackActivityMerchantMapper; | |||
| import com.iformall.mapper.WxCashBackActivityRecordMapper; | |||
| import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxCashBackActivityService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -19,6 +26,9 @@ import org.springframework.stereotype.Service; | |||
| import java.util.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @Service | |||
| public class WxCashBackActivityServiceImpl implements WxCashBackActivityService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -31,7 +41,12 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| WxCashBackActivityRecordMapper wxCashBackActivityRecordMapper; | |||
| @Autowired | |||
| WxCashBackActivityMerchantMapper wxCashBackActivityMerchantMapper; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @Autowired | |||
| ExcelService excelService; | |||
| @Override | |||
| public PageInfo<WxCashBackActivity> listActivityAsPage(WxCashBackActivity record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCashBackActivityMapper.findList(record)); | |||
| @@ -42,6 +57,90 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCashBackActivityItemMapper.findList(record)); | |||
| } | |||
| private void initRecordQueryParam(WxCashBackActivityRecord record) { | |||
| if (StringUtils.isNotBlank(record.getActivityName())) { | |||
| WxCashBackActivity a = new WxCashBackActivity(); | |||
| a.updateTenantInfo(record); | |||
| a.setName(record.getActivityName()); | |||
| List<Long> aids = wxCashBackActivityMapper.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<WxCashBackActivityRecord> listActivityRecordAsPage(WxCashBackActivityRecord record, | |||
| Integer pageIndex, Integer pageSize) { | |||
| initRecordQueryParam(record); | |||
| PageInfo<WxCashBackActivityRecord> recordPage = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCashBackActivityRecordMapper.findList(record)); | |||
| if (null != recordPage && null != recordPage.getList()) { | |||
| handerRecordPageData(record,recordPage.getList()); | |||
| } | |||
| return recordPage; | |||
| } | |||
| private void handerRecordPageData(TenantEntity tenantEntity,List<WxCashBackActivityRecord> recordList) { | |||
| List<Long> aidList = new ArrayList<Long>(); | |||
| List<Long> midList = new ArrayList<Long>(); | |||
| for (WxCashBackActivityRecord r : recordList) { | |||
| aidList.add(r.getActivityId()); | |||
| midList.add(r.getMerchantId()); | |||
| } | |||
| WxCashBackActivity aq = new WxCashBackActivity(); | |||
| aq.updateTenantInfo(tenantEntity); | |||
| aq.setIds(aidList); | |||
| List<WxCashBackActivity> aqList = wxCashBackActivityMapper.findList(aq); | |||
| Map<Long,WxCashBackActivity> activityMap = new HashMap<Long,WxCashBackActivity>(); | |||
| if (null != aqList && aqList.size() > 0 ) { | |||
| for (WxCashBackActivity 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); | |||
| } | |||
| } | |||
| for (WxCashBackActivityRecord _r : recordList) { | |||
| if (null != _r.getActivityId()) { | |||
| WxCashBackActivity _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()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public int getItemCount(WxCashBackActivity record) { | |||
| WxCashBackActivityItem item = new WxCashBackActivityItem(); | |||
| @@ -92,7 +191,67 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| return wxCashBackActivityMerchantMapper.merchantCount(m); | |||
| } | |||
| @Override | |||
| public void saveOrUpdateActivity(WxCashBackActivity 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()); | |||
| wxCashBackActivityMapper.updateById(record); | |||
| }else { | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| wxCashBackActivityMapper.insert(record); | |||
| } | |||
| if (isUpdate) { | |||
| WxCashBackActivityItem item = new WxCashBackActivityItem(); | |||
| item.updateTenantInfo(record); | |||
| item.setActivityId(record.getId()); | |||
| wxCashBackActivityItemMapper.delete(item); | |||
| } | |||
| List<WxCashBackActivityItem> itemList = record.getItemList(); | |||
| if (null != itemList) { | |||
| for (WxCashBackActivityItem i : itemList) { | |||
| i.setId(idWorker.nextId()); | |||
| i.setActivityId(record.getId()); | |||
| i.updateTenantInfo(record); | |||
| wxCashBackActivityItemMapper.insert(i); | |||
| } | |||
| } | |||
| if (isUpdate) { | |||
| WxCashBackActivityMerchant merchant = new WxCashBackActivityMerchant(); | |||
| merchant.updateTenantInfo(record); | |||
| merchant.setActivityId(record.getId()); | |||
| wxCashBackActivityMerchantMapper.delete(merchant); | |||
| } | |||
| List<WxCashBackActivityMerchant> merchantList = record.getMerchantList(); | |||
| if (null != merchantList) { | |||
| for (WxCashBackActivityMerchant m : merchantList) { | |||
| m.setId(idWorker.nextId()); | |||
| m.setActivityId(record.getId()); | |||
| m.updateTenantInfo(record); | |||
| wxCashBackActivityMerchantMapper.insert(m); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public List<WxCashBackActivityMerchant> getActivityMerchants(Long activityId, String tenantId) { | |||
| WxCashBackActivityMerchant m = new WxCashBackActivityMerchant(); | |||
| m.setActivityId(activityId); | |||
| m.setTenantId(tenantId); | |||
| return wxCashBackActivityMerchantMapper.findList(m); | |||
| } | |||
| @Override | |||
| public void exportData(List objectList,String sheetName,Class objectCalss,HttpServletRequest request, HttpServletResponse response) { | |||
| excelService.exportExcel(objectList, null, sheetName, objectCalss, sheetName+".xlsx", response, false); | |||
| } | |||
| } | |||
| @@ -71,5 +71,10 @@ | |||
| <select id="itemCount" parameterType="com.iformall.domain.po.WxCashBackActivityItem" resultType="Integer"> | |||
| select count(1) from wx_cash_back_activity_item where `activity_id` = #{activityId} and tenant_id=#{tenantId} | |||
| </select> | |||
| <delete id="delete" parameterType="com.iformall.domain.po.WxCashBackActivityItem"> | |||
| delete from wx_cash_back_activity_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| </delete> | |||
| </mapper> | |||
| @@ -80,6 +80,11 @@ | |||
| select <include refid="allColumns" /> from wx_cash_back_activity | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findIds" parameterType="com.iformall.domain.po.WxCashBackActivity" resultType="Long"> | |||
| select id from wx_cash_back_activity | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <update id="updateStatus" parameterType="com.iformall.domain.po.WxCashBackActivity"> | |||
| update wx_cash_back_activity | |||
| @@ -76,6 +76,20 @@ | |||
| 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=")"> | |||