|
|
|
@@ -0,0 +1,172 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCashBackActivity; |
|
|
|
import com.iformall.domain.po.WxCashBackActivityRecord; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
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.WxCashBackActivityService; |
|
|
|
import com.iformall.service.WxMallService; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
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("/cashback") |
|
|
|
@Api(description = "现金返现活动相关接口") |
|
|
|
public class WxCashBackActivityController extends BaseController { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCashBackActivityService 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 WxCashBackActivity wxCashBackActivity, Integer pageNum, Integer pageSize) { |
|
|
|
if (null == wxCashBackActivity) wxCashBackActivity = new WxCashBackActivity(); |
|
|
|
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(null); |
|
|
|
wxCashBackActivity.setValidTime(EnumYesOrNo.NO.getCode()); |
|
|
|
} |
|
|
|
//未开始 |
|
|
|
if (wxCashBackActivity.getStatus().intValue() == 4) { |
|
|
|
wxCashBackActivity.setStatus(null); |
|
|
|
wxCashBackActivity.setValidTime(4); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCashBackActivity.setSortColumns(SortField.CreateDate_DESC); |
|
|
|
final PageInfo<WxCashBackActivity> 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(); |
|
|
|
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("recordInfo") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) |
|
|
|
public ResultData recordInfo(Long id) { |
|
|
|
TenantEntity tenantInfo = getTenantInfo(); |
|
|
|
WxCashBackActivityRecord activity = wxCashBackActivityService.getActivityRecordById(id, tenantInfo.getTenantId()); |
|
|
|
if (null != activity) { |
|
|
|
if (null != activity.getActivityId()) { |
|
|
|
WxCashBackActivity 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("recordCount") |
|
|
|
public ResultData recordCount(@ModelAttribute WxCashBackActivityRecord wxCashBackActivityRecord) { |
|
|
|
TenantEntity tenantInfo = getTenantInfo(); |
|
|
|
WxCashBackActivity a = wxCashBackActivityService.getActivityById(wxCashBackActivityRecord.getActivityId(), tenantInfo.getTenantId()); |
|
|
|
if (null == a) { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
int allRecordCount = wxCashBackActivityService.getRecordCount(a, null); |
|
|
|
int auditedRecordCount = wxCashBackActivityService.getRecordCount(a, EnumCashBackActivityRecordStatus.AUDI_SUCCESS); |
|
|
|
int failRecordCount = wxCashBackActivityService.getRecordCount(a, EnumCashBackActivityRecordStatus.AUDT_FAIL); |
|
|
|
int auditingRecordCount = wxCashBackActivityService.getRecordCount(a, EnumCashBackActivityRecordStatus.AUDTING); |
|
|
|
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("saveOrUpdate") |
|
|
|
public ResultData saveOrUpdate(@RequestBody WxCashBackActivityRecord wxCashBackActivityRecord) { |
|
|
|
|
|
|
|
if (null == wxCashBackActivityRecord.getOrderMoney() ) { |
|
|
|
return new ResultData(Result.ERROR,"订单金额不能为空"); |
|
|
|
} |
|
|
|
TenantEntity tenantEntity = getTenantInfo(); |
|
|
|
wxCashBackActivityRecord.updateTenantInfo(tenantEntity); |
|
|
|
wxCashBackActivityService.saveOrUpdateRecord(wxCashBackActivityRecord); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
} |