| @@ -25,6 +25,8 @@ import com.iformall.service.WxCashBackActivityService; | |||
| import com.iformall.service.WxCashOutService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -41,8 +43,12 @@ 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; | |||
| @@ -91,8 +97,14 @@ public class WxCashBackActivityController extends BaseController { | |||
| if (null != page && null != page.getList()) { | |||
| for (WxCashBackActivity a : page.getList()) { | |||
| a.setItemCount(wxCashBackActivityService.getItemCount(a)); | |||
| int allRecordCount = wxCashBackActivityService.getRecordCount(a, null); | |||
| int successRecordCount = wxCashBackActivityService.getRecordCount(a, EnumCashBackActivityRecordStatus.AUDI_SUCCESS); | |||
| WxCashBackActivityRecord r = new WxCashBackActivityRecord(); | |||
| r.setActivityId(a.getId()); | |||
| r.updateTenantInfo(a); | |||
| int allRecordCount = wxCashBackActivityService.getRecordCount(r); | |||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||
| int successRecordCount = wxCashBackActivityService.getRecordCount(r); | |||
| a.setRecordCount(allRecordCount); | |||
| a.setAuditSuccessRecordCount(successRecordCount); | |||
| a.setMerchantCount(wxCashBackActivityService.getMerchantCount(a)); | |||
| @@ -226,4 +238,51 @@ public class WxCashBackActivityController extends BaseController { | |||
| wxCashBackActivityService.auditRecord(wxCashBackActivityRecord); | |||
| return new ResultData(wxCashBackActivityRecord); | |||
| } | |||
| @ApiOperation("查询当前提现信息") | |||
| @GetMapping("total") | |||
| public ResultData total() { | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| WxCashBackActivityRecord r = new WxCashBackActivityRecord(); | |||
| 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 WxCashBackActivityRecord 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); | |||
| } | |||
| } | |||
| @@ -144,10 +144,20 @@ public class WxCashBackActivityController extends BaseController { | |||
| 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); | |||
| WxCashBackActivityRecord r = new WxCashBackActivityRecord(); | |||
| 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); | |||
| @@ -3,6 +3,8 @@ 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; | |||
| @@ -19,26 +21,34 @@ public class WxCashBackActivityRecord 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; | |||
| @TableField(exist = false) | |||
| @Excel(name="活动名称",width = 20,orderNum = "1") | |||
| 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; | |||
| @io.swagger.annotations.ApiModelProperty(value = "EnumCashBackActivityRecordStatus", name = "auditStatus") | |||
| @@ -46,22 +56,36 @@ public class WxCashBackActivityRecord extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private List<Integer> auditStatusList; | |||
| @io.swagger.annotations.ApiModelProperty(value = "审核内容", name = "auditRemark") | |||
| private String auditRemark; | |||
| private String auditRemark; | |||
| @Excel(name="返现比例(%)",width = 20,orderNum = "9") | |||
| @io.swagger.annotations.ApiModelProperty(value = "返现比率", name = "cashRate") | |||
| private BigDecimal cashRate; | |||
| @Excel(name="返现金额",width = 20,orderNum = "10") | |||
| @io.swagger.annotations.ApiModelProperty(value = "返现金额", name = "cashMoney") | |||
| private BigDecimal cashMoney; | |||
| @Excel(name="商管承担比例(%)",width = 20,orderNum = "11") | |||
| @TableField(exist = false) | |||
| private BigDecimal mallRate; | |||
| @Excel(name="商管承担返现金额",width = 20,orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value = "商管承担返现金额", name = "mallCashMoney") | |||
| private BigDecimal mallCashMoney; | |||
| @Excel(name="商户承担比例(%)",width = 20,orderNum = "13") | |||
| @TableField(exist = false) | |||
| private BigDecimal merchantRate; | |||
| @Excel(name="商户承担返现金额",width = 20,orderNum = "14") | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户承担返现金额", name = "merchantCashMoney") | |||
| private BigDecimal merchantCashMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | |||
| private Long merchantId; | |||
| @Excel(name="提交时间",width = 20,format="yyyy-MM-dd HH:mm:ss", orderNum = "15") | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||
| private Date createDate; | |||
| @TableField(exist = false) | |||
| private String activityName; | |||
| private Date createDateBegin; | |||
| @TableField(exist = false) | |||
| private String merchantName; | |||
| private Date createDateEnd; | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private List<Long> activityIdList; | |||
| @TableField(exist = false) | |||
| @@ -5,7 +5,9 @@ import com.iformall.domain.po.WxCashBackActivityRecord; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxCashBackActivityRecordMapper extends CommonMapper<WxCashBackActivityRecord, Long> { | |||
| @@ -16,5 +18,11 @@ public interface WxCashBackActivityRecordMapper extends CommonMapper<WxCashBackA | |||
| void updateStatus(WxCashBackActivityRecord wxCashBackActivity); | |||
| Integer selectCount(WxCashBackActivityRecord wxCashBackActivity); | |||
| BigDecimal sumAll(WxCashBackActivityRecord wxCashBackActivity); | |||
| BigDecimal sumMerchant(WxCashBackActivityRecord wxCashBackActivity); | |||
| List<Map> selectMerchantRecords(WxCashBackActivityRecord wxCashBackActivity); | |||
| } | |||
| @@ -1,6 +1,8 @@ | |||
| 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; | |||
| @@ -29,7 +31,10 @@ public interface WxCashBackActivityService { | |||
| PageInfo<WxCashBackActivityRecord> listActivityRecordAsPage(WxCashBackActivityRecord record, Integer pageIndex, Integer pageSize); | |||
| int getItemCount(WxCashBackActivity record); | |||
| int getRecordCount(WxCashBackActivity record,EnumCashBackActivityRecordStatus status); | |||
| int getRecordCount(WxCashBackActivityRecord record); | |||
| BigDecimal getRecordSum(WxCashBackActivityRecord record); | |||
| BigDecimal getRecordMerchantSum(WxCashBackActivityRecord record); | |||
| List<Map> getMerchantRecords(WxCashBackActivityRecord record); | |||
| int getMerchantCount(WxCashBackActivity record); | |||
| void saveOrUpdateActivity(WxCashBackActivity record); | |||
| @@ -64,7 +64,8 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| @Override | |||
| public PageInfo<WxCashBackActivityItem> listActivityItemAsPage(WxCashBackActivityItem record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCashBackActivityItemMapper.findList(record)); | |||
| PageInfo<WxCashBackActivityItem> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCashBackActivityItemMapper.findList(record)); | |||
| return page; | |||
| } | |||
| private void initRecordQueryParam(WxCashBackActivityRecord record) { | |||
| @@ -108,9 +109,11 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| private void handerRecordPageData(TenantEntity tenantEntity,List<WxCashBackActivityRecord> recordList) { | |||
| List<Long> aidList = new ArrayList<Long>(); | |||
| List<Long> midList = new ArrayList<Long>(); | |||
| List<Long> itemIdList = new ArrayList<Long>(); | |||
| for (WxCashBackActivityRecord r : recordList) { | |||
| aidList.add(r.getActivityId()); | |||
| midList.add(r.getMerchantId()); | |||
| itemIdList.add(r.getItemId()); | |||
| } | |||
| WxCashBackActivity aq = new WxCashBackActivity(); | |||
| aq.updateTenantInfo(tenantEntity); | |||
| @@ -134,6 +137,17 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| } | |||
| } | |||
| WxCashBackActivityItem itemq = new WxCashBackActivityItem(); | |||
| itemq.updateTenantInfo(tenantEntity); | |||
| itemq.setIds(itemIdList); | |||
| List<WxCashBackActivityItem> itemList = wxCashBackActivityItemMapper.findList(itemq); | |||
| Map<Long,WxCashBackActivityItem> itemMap = new HashMap<Long,WxCashBackActivityItem>(); | |||
| if (null != itemList && itemList.size() > 0 ) { | |||
| for (WxCashBackActivityItem m : itemList) { | |||
| itemMap.put(m.getId(), m); | |||
| } | |||
| } | |||
| for (WxCashBackActivityRecord _r : recordList) { | |||
| if (null != _r.getActivityId()) { | |||
| WxCashBackActivity _a = activityMap.get(_r.getActivityId()); | |||
| @@ -148,6 +162,15 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| _r.setMerchantName(_m.getName()); | |||
| } | |||
| } | |||
| if (null != _r.getItemId()) { | |||
| WxCashBackActivityItem _i = itemMap.get(_r.getItemId()); | |||
| if (null != _i) { | |||
| _r.setItemName(_i.getName()); | |||
| _r.setMallRate(_i.getMallBackRate()); | |||
| _r.setMerchantRate(_i.getMerchantBackRate()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -188,14 +211,18 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| } | |||
| @Override | |||
| public int getRecordCount(WxCashBackActivity record, EnumCashBackActivityRecordStatus status) { | |||
| WxCashBackActivityRecord r = new WxCashBackActivityRecord(); | |||
| r.setActivityId(record.getId()); | |||
| r.updateTenantInfo(record); | |||
| if (null != status) { | |||
| r.setAuditStatus(status.getCode()); | |||
| } | |||
| return wxCashBackActivityRecordMapper.selectCount(r); | |||
| public int getRecordCount(WxCashBackActivityRecord record) { | |||
| return wxCashBackActivityRecordMapper.selectCount(record); | |||
| } | |||
| @Override | |||
| public BigDecimal getRecordSum(WxCashBackActivityRecord record) { | |||
| return wxCashBackActivityRecordMapper.sumAll(record); | |||
| } | |||
| @Override | |||
| public BigDecimal getRecordMerchantSum(WxCashBackActivityRecord record) { | |||
| return wxCashBackActivityRecordMapper.sumMerchant(record); | |||
| } | |||
| @Override | |||
| @@ -307,4 +334,10 @@ public class WxCashBackActivityServiceImpl implements WxCashBackActivityService | |||
| } | |||
| @Override | |||
| public List<Map> getMerchantRecords(WxCashBackActivityRecord record) { | |||
| initRecordQueryParam(record); | |||
| return wxCashBackActivityRecordMapper.selectMerchantRecords(record); | |||
| } | |||
| } | |||
| @@ -148,4 +148,20 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="sumAll" parameterType="com.iformall.domain.po.WxCashBackActivityRecord" resultType="BigDecimal"> | |||
| select sum(cash_money) from wx_cash_back_activity_record | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="sumMerchant" parameterType="com.iformall.domain.po.WxCashBackActivityRecord" resultType="BigDecimal"> | |||
| select sum(merchant_cash_money) from wx_cash_back_activity_record | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="selectMerchantRecords" parameterType="com.iformall.domain.po.WxCashBackActivityRecord" 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_cash_back_activity_record | |||
| <include refid="dynamicWhereConditions" /> | |||
| group by merchant_id | |||
| </select> | |||
| </mapper> | |||