| @@ -12,6 +12,7 @@ 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.WxRaffleActivityRecordItem; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCashBackActivityItemRule; | |||
| @@ -105,6 +106,9 @@ public class WxRaffleActivityController extends BaseController { | |||
| int allRecordCount = wxCashBackActivityService.getRecordCount(r); | |||
| a.setRecordCount(allRecordCount); | |||
| int allRaffledCount = wxCashBackActivityService.getRecordItemCount(r); | |||
| a.setAllRaffledCount(allRaffledCount); | |||
| r.setAuditStatus(EnumCashBackActivityRecordStatus.AUDI_SUCCESS.getCode()); | |||
| //int successRecordCount = wxCashBackActivityService.getRecordCount(r); | |||
| BigDecimal successRecordSum = wxCashBackActivityService.getRecordSum(r); | |||
| @@ -163,11 +167,11 @@ public class WxRaffleActivityController extends BaseController { | |||
| List<WxRaffleActivityItem> itemList = wxCashBackActivity.getItemList(); | |||
| for (WxRaffleActivityItem i : itemList) { | |||
| if (i.getMoneyRule().intValue() == EnumCashBackActivityItemRule.MALL_ONLY.getCode().intValue()) { | |||
| i.setMallBackRate(i.getTotalBackRate()); | |||
| i.setMallBackRate(new BigDecimal(100)); | |||
| i.setMerchantBackRate(new BigDecimal(0)); | |||
| }else if (i.getMoneyRule().intValue() == EnumCashBackActivityItemRule.MERCHANT_ONLY.getCode().intValue()) { | |||
| i.setMallBackRate(new BigDecimal(0)); | |||
| i.setMerchantBackRate(i.getTotalBackRate()); | |||
| i.setMerchantBackRate(new BigDecimal(100)); | |||
| }else if (i.getMoneyRule().intValue() == EnumCashBackActivityItemRule.SHARE.getCode().intValue()) { | |||
| if (i.getMallBackRate().add(i.getMerchantBackRate()).intValue() != 100) { | |||
| return new ResultData(Result.ERROR,"分担规则下,商户和商管的比例总和需要为100%"); | |||
| @@ -247,7 +251,7 @@ public class WxRaffleActivityController extends BaseController { | |||
| }else { | |||
| result = new ArrayList<WxRaffleActivityRecord>(); | |||
| } | |||
| wxCashBackActivityService.exportData(result,"现金返现记录",WxRaffleActivityRecord.class, request, response); | |||
| wxCashBackActivityService.exportData(result,"线下抽奖记录",WxRaffleActivityRecord.class, request, response); | |||
| } | |||
| @ApiOperation("查询当前提现信息") | |||
| @@ -289,18 +293,22 @@ public class WxRaffleActivityController extends BaseController { | |||
| 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("recordItemSave") | |||
| public ResultData recordItemSave(@RequestBody WxRaffleActivityRecordItem wxCashBackActivityRecord) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxCashBackActivityRecord.updateTenantInfo(tenantEntity); | |||
| wxCashBackActivityService.saveOrUpdateRecordItem(wxCashBackActivityRecord); | |||
| return new ResultData(wxCashBackActivityRecord); | |||
| } | |||
| @ApiOperation("计算金额") | |||
| @PostMapping("calRecordMoney") | |||
| public ResultData calRecordMoney(@RequestBody WxRaffleActivityRecord wxCashBackActivityRecord) { | |||
| public ResultData calRecordMoney(@RequestBody WxRaffleActivityRecordItem wxCashBackActivityRecord) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxCashBackActivityRecord.updateTenantInfo(tenantEntity); | |||
| wxCashBackActivityService.calcuteMoney(wxCashBackActivityRecord); | |||
| @@ -30,7 +30,10 @@ 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.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -128,10 +131,9 @@ public class WxRaffleActivityController extends BaseController { | |||
| } | |||
| } | |||
| WxRaffleActivityItem item = wxCashBackActivityService.getActivityItemById(activity.getItemId(), tenantInfo.getTenantId()); | |||
| if (null != item) { | |||
| activity.setItemName(item.getName()); | |||
| } | |||
| List<Long> aids = new ArrayList<Long>();; | |||
| aids.add(activity.getActivityId()); | |||
| activity.setRecordItemList(wxCashBackActivityService.getActivityRecordItemListByRecordId(aids, id, tenantInfo)); | |||
| if (null != activity.getMerchantId()) { | |||
| WxMerchant m = new WxMerchant(); | |||
| @@ -35,6 +35,8 @@ public class WxRaffleActivity extends TenantEntity { | |||
| private Date endTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "最低订单金额", name = "limitMoney") | |||
| private BigDecimal limitMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value = "奖券总数量", name = "totalCount") | |||
| private Integer totalCount; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否全部商户EnumYesOrNo", name = "allMerchant") | |||
| private Integer allMerchant; | |||
| @@ -46,6 +48,8 @@ public class WxRaffleActivity extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private Integer recordCount; | |||
| @TableField(exist = false) | |||
| private Integer allRaffledCount; | |||
| @TableField(exist = false) | |||
| private String merchantCount; | |||
| @TableField(exist = false) | |||
| private BigDecimal auditSuccessRecordSum; | |||
| @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @TableName(value = "wx_raffle_activity_item") | |||
| @Data | |||
| @@ -30,12 +31,15 @@ public class WxRaffleActivityItem extends TenantEntity { | |||
| 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 = "totalMoney") | |||
| private BigDecimal totalMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商管返现比例", name = "mallBackRate") | |||
| private BigDecimal mallBackRate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户返现比例", name = "merchantBackRate") | |||
| private BigDecimal merchantBackRate; | |||
| @TableField(exist = false) | |||
| private List<Long> activityIdList; | |||
| } | |||
| @@ -31,11 +31,6 @@ public class WxRaffleActivityRecord extends TenantEntity { | |||
| @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; | |||
| @@ -58,24 +53,6 @@ public class WxRaffleActivityRecord extends TenantEntity { | |||
| 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; | |||
| @@ -86,10 +63,32 @@ public class WxRaffleActivityRecord extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||
| private Date updateDate; | |||
| @Excel(name="中奖信息",width = 20, orderNum = "16") | |||
| @io.swagger.annotations.ApiModelProperty(value = "中奖信息", name = "itemDetail") | |||
| @TableField(exist = false) | |||
| private String itemDetail; | |||
| @TableField(exist = false) | |||
| private List<Long> activityIdList; | |||
| @TableField(exist = false) | |||
| private List<Long> merchantIdList; | |||
| @TableField(exist = false) | |||
| private List<WxRaffleActivityRecordItem> recordItemList; | |||
| public String generateItemDetaiJson() { | |||
| if (null != recordItemList && recordItemList.size() > 0 ) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| for (int i = 0 ; i < recordItemList.size() ; i++) { | |||
| WxRaffleActivityRecordItem ri = recordItemList.get(i); | |||
| sb.append("奖项[").append(i+1).append("]:奖券编码-").append(ri.getCode()).append(",奖项-").append(ri.getItemName()).append(",总价值-") | |||
| .append(ri.getCashMoney()).append(",商管承担-").append(ri.getMallCashMoney()).append("元(").append(ri.getMallRate()).append("%),") | |||
| .append("商户承担-").append(ri.getMerchantCashMoney()).append("元(").append(ri.getMerchantRate()).append("%). \n"); | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,58 @@ | |||
| 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_item") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxRaffleActivityRecordItem extends TenantEntity { | |||
| private Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value = "活动", name = "activityId") | |||
| private Long activityId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "记录id", name = "recordId") | |||
| private Long recordId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "选项", name = "itemId") | |||
| private Long itemId; | |||
| @TableField(exist = false) | |||
| private String itemName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "奖券编码", name = "code") | |||
| private String code; | |||
| @io.swagger.annotations.ApiModelProperty(value = "返现金额", name = "cashMoney") | |||
| private BigDecimal cashMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商管承担比例", name = "mallRate") | |||
| private BigDecimal mallRate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商管承担返现金额", name = "mallCashMoney") | |||
| private BigDecimal mallCashMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户承担比例", name = "merchantRate") | |||
| private BigDecimal merchantRate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户承担返现金额", name = "merchantCashMoney") | |||
| private BigDecimal merchantCashMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private List<Long> activityIdList; | |||
| @TableField(exist = false) | |||
| private List<Long> recordIdIdList; | |||
| @TableField(exist = false) | |||
| private List<Long> merchantIdList; | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxRaffleActivityRecordItem; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxRaffleActivityRecordItemMapper extends CommonMapper<WxRaffleActivityRecordItem, Long> { | |||
| WxRaffleActivityRecordItem selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxRaffleActivityRecordItem> findList(WxRaffleActivityRecordItem wxCashBackActivity); | |||
| Integer selectCount(WxRaffleActivityRecordItem wxCashBackActivity); | |||
| BigDecimal sumAll(WxRaffleActivityRecordItem wxCashBackActivity); | |||
| BigDecimal sumMerchant(WxRaffleActivityRecordItem wxCashBackActivity); | |||
| BigDecimal sumOrderMoney(WxRaffleActivityRecordItem wxCashBackActivity); | |||
| List<Map> selectMerchantRecords(WxRaffleActivityRecordItem wxCashBackActivity); | |||
| } | |||
| @@ -14,16 +14,10 @@ public interface WxRaffleActivityRecordMapper extends CommonMapper<WxRaffleActiv | |||
| List<WxRaffleActivityRecord> findList(WxRaffleActivityRecord wxCashBackActivity); | |||
| List<Long> findIdList(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); | |||
| } | |||
| @@ -12,6 +12,8 @@ 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.WxRaffleActivityRecordItem; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCashBackActivityRecordStatus; | |||
| public interface WxRaffleActivityService { | |||
| @@ -32,6 +34,7 @@ public interface WxRaffleActivityService { | |||
| int getItemCount(WxRaffleActivity record); | |||
| int getRecordCount(WxRaffleActivityRecord record); | |||
| int getRecordItemCount(WxRaffleActivityRecord record); | |||
| BigDecimal getRecordSum(WxRaffleActivityRecord record); | |||
| BigDecimal getRecordMerchantSum(WxRaffleActivityRecord record); | |||
| BigDecimal getRecordOrderMoneySum(WxRaffleActivityRecord record); | |||
| @@ -52,7 +55,8 @@ public interface WxRaffleActivityService { | |||
| WxRaffleActivityRecord getActivityRecordById(Long id,String tenantId); | |||
| List<WxRaffleActivityRecordItem> getActivityRecordItemListByRecordId(List<Long> activitIds,Long recordId,TenantEntity tenantEntity); | |||
| /** | |||
| *更新状态 | |||
| * | |||
| @@ -68,7 +72,9 @@ public interface WxRaffleActivityService { | |||
| void auditRecord(WxRaffleActivityRecord record); | |||
| void calcuteMoney(WxRaffleActivityRecord record); | |||
| void saveOrUpdateRecordItem(WxRaffleActivityRecordItem record); | |||
| void calcuteMoney(WxRaffleActivityRecordItem record); | |||
| void saveOrUpdateRecord(WxRaffleActivityRecord record); | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| @@ -9,6 +10,7 @@ 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.WxRaffleActivityRecordItem; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCUserBasicInfoVo; | |||
| import com.iformall.enums.EnumCashBackActivityItemRule; | |||
| @@ -18,6 +20,7 @@ import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.mapper.WxRaffleActivityItemMapper; | |||
| import com.iformall.mapper.WxRaffleActivityMapper; | |||
| import com.iformall.mapper.WxRaffleActivityMerchantMapper; | |||
| import com.iformall.mapper.WxRaffleActivityRecordItemMapper; | |||
| import com.iformall.mapper.WxRaffleActivityRecordMapper; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxRaffleActivityService; | |||
| @@ -42,6 +45,8 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| @Autowired | |||
| WxRaffleActivityRecordMapper wxActivityRecordMapper; | |||
| @Autowired | |||
| WxRaffleActivityRecordItemMapper wxActivityRecordItemMapper; | |||
| @Autowired | |||
| WxRaffleActivityMerchantMapper wxActivityMerchantMapper; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @@ -131,11 +136,9 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| } | |||
| 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); | |||
| @@ -159,17 +162,6 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| } | |||
| } | |||
| 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()); | |||
| @@ -184,15 +176,24 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| _r.setMerchantName(_m.getName()); | |||
| } | |||
| } | |||
| if (null != _r.getItemId()) { | |||
| WxRaffleActivityItem _i = itemMap.get(_r.getItemId()); | |||
| if (null != _i) { | |||
| _r.setItemName(_i.getName()); | |||
| } | |||
| } | |||
| _r.setRecordItemList(getActivityRecordItemListByRecordId(aidList,_r.getId(),_r)); | |||
| _r.setItemDetail(_r.generateItemDetaiJson()); | |||
| } | |||
| } | |||
| private Map<Long,WxRaffleActivityItem> getItemMap(TenantEntity tenantEntity,List<Long> activitIds) { | |||
| WxRaffleActivityItem iq = new WxRaffleActivityItem(); | |||
| iq.updateTenantInfo(tenantEntity); | |||
| iq.setActivityIdList(activitIds); | |||
| List<WxRaffleActivityItem> iqList = wxActivityItemMapper.findList(iq); | |||
| Map<Long,WxRaffleActivityItem> itemMap = new HashMap<Long,WxRaffleActivityItem>(); | |||
| if (null != iqList && iqList.size() > 0 ) { | |||
| for (WxRaffleActivityItem i : iqList) { | |||
| itemMap.put(i.getId(), i); | |||
| } | |||
| } | |||
| return itemMap; | |||
| } | |||
| @Override | |||
| public int getItemCount(WxRaffleActivity record) { | |||
| @@ -235,19 +236,48 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| return wxActivityRecordMapper.selectCount(record); | |||
| } | |||
| private WxRaffleActivityRecordItem generateItemByRecordQuery(WxRaffleActivityRecord record) { | |||
| WxRaffleActivityRecordItem ri = new WxRaffleActivityRecordItem(); | |||
| ri.updateTenantInfo(record); | |||
| ri.setMerchantId(record.getMerchantId()); | |||
| ri.setActivityId(record.getActivityId()); | |||
| ri.setRecordId(record.getId()); | |||
| if (null != record.getActivityIdList() && record.getActivityIdList().size() > 0 ) { | |||
| ri.setActivityIdList(record.getActivityIdList()); | |||
| } | |||
| if (null != record.getMerchantIdList() && record.getMerchantIdList().size() > 0 ) { | |||
| ri.setMerchantIdList(record.getMerchantIdList()); | |||
| } | |||
| return ri; | |||
| } | |||
| @Override | |||
| public int getRecordItemCount(WxRaffleActivityRecord record) { | |||
| return wxActivityRecordItemMapper.selectCount(generateItemByRecordQuery(record)); | |||
| } | |||
| @Override | |||
| public BigDecimal getRecordSum(WxRaffleActivityRecord record) { | |||
| return wxActivityRecordMapper.sumAll(record); | |||
| WxRaffleActivityRecordItem ri = generateItemByRecordQuery(record); | |||
| if (null != record.getAuditStatus()) { | |||
| List<Long> rids = wxActivityRecordMapper.findIdList(record); | |||
| if (null == rids || rids.size() <= 0 ) { | |||
| return new BigDecimal(0); | |||
| } | |||
| ri.setRecordIdIdList(rids); | |||
| } | |||
| return wxActivityRecordItemMapper.sumAll(ri); | |||
| } | |||
| @Override | |||
| public BigDecimal getRecordMerchantSum(WxRaffleActivityRecord record) { | |||
| return wxActivityRecordMapper.sumMerchant(record); | |||
| return wxActivityRecordItemMapper.sumMerchant(generateItemByRecordQuery(record)); | |||
| } | |||
| @Override | |||
| public BigDecimal getRecordOrderMoneySum(WxRaffleActivityRecord record) { | |||
| return wxActivityRecordMapper.sumOrderMoney(record); | |||
| return wxActivityRecordItemMapper.sumOrderMoney(generateItemByRecordQuery(record)); | |||
| } | |||
| @Override | |||
| @@ -348,11 +378,24 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| } | |||
| @Override | |||
| public void calcuteMoney(WxRaffleActivityRecord record) { | |||
| public void saveOrUpdateRecordItem(WxRaffleActivityRecordItem record) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| if (null == record.getId()) { | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| wxActivityRecordItemMapper.insert(record); | |||
| }else { | |||
| record.setUpdateDate(new Date()); | |||
| wxActivityRecordItemMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void calcuteMoney(WxRaffleActivityRecordItem 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.setCashMoney(item.getTotalMoney().setScale(3,BigDecimal.ROUND_HALF_UP)); | |||
| record.setMallRate(item.getMallBackRate()); | |||
| record.setMerchantRate(item.getMerchantBackRate()); | |||
| if (moneyRule == EnumCashBackActivityItemRule.MALL_ONLY) { | |||
| @@ -385,7 +428,32 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||
| @Override | |||
| public List<Map> getMerchantRecords(WxRaffleActivityRecord record) { | |||
| initRecordQueryParam(record); | |||
| return wxActivityRecordMapper.selectMerchantRecords(record); | |||
| return wxActivityRecordItemMapper.selectMerchantRecords(generateItemByRecordQuery(record)); | |||
| } | |||
| @Override | |||
| public List<WxRaffleActivityRecordItem> getActivityRecordItemListByRecordId(List<Long> activitIds,Long recordId, | |||
| TenantEntity tenantEntity) { | |||
| Map<Long,WxRaffleActivityItem> itemMap = getItemMap(tenantEntity,activitIds); | |||
| WxRaffleActivityRecordItem _ri = new WxRaffleActivityRecordItem(); | |||
| _ri.updateTenantInfo(tenantEntity); | |||
| _ri.setRecordId(recordId); | |||
| List<WxRaffleActivityRecordItem> _riList = wxActivityRecordItemMapper.findList(_ri); | |||
| if (null != _riList && _riList.size() >= 0 ) { | |||
| if (null != itemMap) { | |||
| for (int j = 0 ; j < _riList.size() ; j++) { | |||
| WxRaffleActivityRecordItem ari = _riList.get(j); | |||
| WxRaffleActivityItem ai = itemMap.get(ari.getItemId()); | |||
| if (null != ai) { | |||
| ari.setItemName(ai.getName()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return _riList; | |||
| } | |||
| } | |||
| @@ -10,14 +10,14 @@ | |||
| <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="total_money" jdbcType="DECIMAL" property="totalMoney" /> | |||
| <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` | |||
| `total_money`,`mall_back_rate`,`merchant_back_rate` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -50,6 +50,13 @@ | |||
| and `activity_id` = #{activityId} | |||
| </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 != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -12,11 +12,12 @@ | |||
| <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="total_count" jdbcType="INTEGER" property="totalCount" /> | |||
| <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` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`status`,`name`,`create_date`,`update_date`,`start_time`,`end_time`,`limit_money`,`total_count`,`all_merchant` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -0,0 +1,121 @@ | |||
| <?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.WxRaffleActivityRecordItemMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxRaffleActivityRecordItem"> | |||
| <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="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="activity_id" jdbcType="BIGINT" property="activityId" /> | |||
| <result column="record_id" jdbcType="BIGINT" property="recordId" /> | |||
| <result column="item_id" jdbcType="BIGINT" property="itemId" /> | |||
| <result column="code" jdbcType="VARCHAR" property="code" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <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" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`activity_id`,`record_id`,`item_id`,`code`,`create_date`,`update_date`, | |||
| `cash_money`,`mall_rate`,`mall_cash_money`,`merchant_rate`,`merchant_cash_money` | |||
| </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 != recordId "> | |||
| and `record_id` = #{recordId} | |||
| </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 != itemId "> | |||
| and `item_id` = #{itemId} | |||
| </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 != recordIdIdList "> | |||
| and record_id in | |||
| <foreach collection="recordIdIdList" index="index" item="ridItem" open="(" separator="," close=")"> | |||
| #{ridItem} | |||
| </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 != 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_item where id = #{id} and tenant_id=#{tenantId} | |||
| </select> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxRaffleActivityRecordItem" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_raffle_activity_record_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="selectCount" parameterType="com.iformall.domain.po.WxRaffleActivityRecordItem" resultType="Integer"> | |||
| select count(1) from wx_raffle_activity_record_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="sumAll" parameterType="com.iformall.domain.po.WxRaffleActivityRecordItem" resultType="BigDecimal"> | |||
| select sum(cash_money) from wx_raffle_activity_record_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="sumMerchant" parameterType="com.iformall.domain.po.WxRaffleActivityRecordItem" resultType="BigDecimal"> | |||
| select sum(merchant_cash_money) from wx_raffle_activity_record_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="sumOrderMoney" parameterType="com.iformall.domain.po.WxRaffleActivityRecordItem" resultType="BigDecimal"> | |||
| select sum(order_money) from wx_raffle_activity_record_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="selectMerchantRecords" parameterType="com.iformall.domain.po.WxRaffleActivityRecordItem" resultType="java.util.HashMap"> | |||
| select merchant_id as merchantId,count(1) as orderCount, sum(cash_money) as allMoney, | |||
| sum(merchant_cash_money) as merchantMenoy from wx_raffle_activity_record_item | |||
| <include refid="dynamicWhereConditions" /> | |||
| group by merchant_id | |||
| </select> | |||
| </mapper> | |||
| @@ -6,7 +6,6 @@ | |||
| <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" /> | |||
| @@ -16,19 +15,13 @@ | |||
| <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` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`activity_id`,`order_no`,`order_money`,`cus_name`,`create_date`,`update_date`,`phone`, | |||
| `address`,`audit_remark`,`audit_status`,`merchant_id` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -43,10 +36,6 @@ | |||
| <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> | |||
| @@ -116,6 +105,11 @@ | |||
| select <include refid="allColumns" /> from wx_raffle_activity_record | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findIdList" parameterType="com.iformall.domain.po.WxRaffleActivityRecord" resultMap="BaseResultMap"> | |||
| select id from wx_raffle_activity_record | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <update id="updateStatus" parameterType="com.iformall.domain.po.WxRaffleActivityRecord"> | |||
| update wx_raffle_activity_record | |||
| @@ -123,27 +117,6 @@ | |||
| <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"> | |||
| @@ -159,25 +132,4 @@ | |||
| <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> | |||