提交代码

dev-discount
= 4 years ago
parent 14eade9413
commit 12fb4390be
  1. 90
      hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java
  2. 64
      hai-bweb/src/main/java/com/bweb/controller/HighGoldRecController.java
  3. 2
      hai-cweb/src/main/java/com/cweb/controller/HighGoldRecController.java
  4. 29
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java
  5. 4
      hai-service/src/main/java/com/hai/entity/HighGoldRec.java
  6. 16
      hai-service/src/main/java/com/hai/model/HighGoldRecModel.java
  7. 27
      hai-service/src/main/java/com/hai/service/HighCouponAgentService.java
  8. 15
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  9. 63
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java
  10. 14
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  11. 2
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java
  12. 10
      hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java

@ -9,6 +9,7 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.*;
import com.hai.model.HighAgentModel;
@ -27,10 +28,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Auther: 胡锐
@ -65,7 +64,7 @@ public class HighCouponAgentController {
@RequestMapping(value = "/getAgentCount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据销售码查询详情")
@ApiOperation(value = "代理商统计")
public ResponseData getAgentCount(HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
@ -84,6 +83,42 @@ public class HighCouponAgentController {
}
}
@RequestMapping(value = "/getAgentSalesCodeList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询今天 代理商已销售的卡券")
public ResponseData getAgentSalesCodeList(HttpServletRequest request,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getHighAgent() == null) {
log.error("HighCouponAgentController -> assignCouponAgent() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
// 计算使用有效期
Calendar consumeTimeS = Calendar.getInstance();
consumeTimeS.setTime(new Date());
consumeTimeS.set(Calendar.HOUR_OF_DAY, 00);
consumeTimeS.set(Calendar.MINUTE, 00);
consumeTimeS.set(Calendar.SECOND, 00);
Calendar consumeTimeE = Calendar.getInstance();
consumeTimeE.setTime(new Date());
consumeTimeE.set(Calendar.HOUR_OF_DAY, 23);
consumeTimeE.set(Calendar.MINUTE, 59);
consumeTimeE.set(Calendar.SECOND, 59);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highCouponAgentService.getAgentSalesCodeList(userInfoModel.getHighAgent().getId(), DateUtil.date2String(consumeTimeS.getTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(consumeTimeE.getTime(), "yyyy-MM-dd HH:mm:ss"))));
} catch (Exception e) {
log.error("HighCouponAgentController --> getAgentSalesCodeList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/assignCouponAgent", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "分配卡券给代理商")
@ -197,12 +232,13 @@ public class HighCouponAgentController {
}
}
@RequestMapping(value = "/getCodeListByAgentCoupon", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据代理商和卡券 查询分配的销售码")
public ResponseData getCodeListByAgentCoupon(@RequestParam(name = "couponId", required = true) Long couponId,
@RequestParam(name = "status", required = false) String status,
@RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "createTimeE", required = false) Long createTimeE,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
@ -219,6 +255,8 @@ public class HighCouponAgentController {
map.put("agentId", userInfoModel.getHighAgent().getId());
map.put("couponId", couponId);
map.put("status", status);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
PageHelper.startPage(pageNum,pageSize);
PageInfo<HighCouponAgentCode> pageInfo = new PageInfo<>(highCouponAgentService.getCouponCodeList(map));
@ -327,4 +365,44 @@ public class HighCouponAgentController {
}
}
@RequestMapping(value = "/getRecordByCouponAgentId", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据卡券与代理商关系 查询分发记录")
public ResponseData getRecordByCouponAgentId(@RequestParam(name = "couponAgentId", required = true) Long couponAgentId,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
Map<String,Object> map = new HashMap<>();
map.put("couponAgentId", couponAgentId);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highCouponAgentService.getRecordList(map)));
} catch (Exception e) {
log.error("HighCouponAgentController --> getRecordByCouponAgentId() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getCouponByRecord", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据分发记录 查询卡券")
public ResponseData getCouponByRecord(@RequestParam(name = "recordId", required = true) Long recordId,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
Map<String,Object> map = new HashMap<>();
map.put("recordId", recordId);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highCouponAgentService.getCouponAgentCodeList(map)));
} catch (Exception e) {
log.error("HighCouponAgentController --> getCouponByRecord() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,64 @@
package com.bweb.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.HighGoldRecService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/28 23:54
*/
@Controller
@RequestMapping(value = "/highGoldRec")
@Api(value = "金币接口")
public class HighGoldRecController {
private static Logger log = LoggerFactory.getLogger(HighGoldRecController.class);
@Autowired
private UserCenter userCenter;
@Resource
private HighGoldRecService highGoldRecService;
@RequestMapping(value="/getUserGoldRecList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户金币使用情况")
public ResponseData getUserGoldRecList(@RequestParam(name = "goldType", required = false) Integer goldType,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
Map<String, Object> map = new HashMap<>();
map.put("goldType", goldType);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highGoldRecService.getGoldRec(map)));
} catch (Exception e) {
log.error("HighCouponController -> getCouponList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -31,7 +31,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping(value = "/highGoldRec")
@Api(value = "卡卷接口")
@Api(value = "金币接口")
public class HighGoldRecController {
private static Logger log = LoggerFactory.getLogger(HighGoldRecController.class);

@ -1,8 +1,14 @@
package com.hai.dao;
import com.hai.entity.HighCouponAgentCode;
import com.hai.model.AgentSalesModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
/**
@ -18,6 +24,29 @@ public interface HighCouponAgentRelMapperExt {
" and a.status = 3 and a.coupon_code_id = b.id and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE}")
AgentSalesModel getAgentSales(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE);
@Select(" select a.* from high_coupon_agent_code a,high_coupon_code b,high_coupon_agent_rel c " +
" where c.id = a.coupon_agent_id and c.agent_id = 8 and a.status = 3 and a.coupon_code_id = b.id " +
" and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE} ORDER BY b.consume_time desc")
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT),
@Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<HighCouponAgentCode> getAgentSalesCodeList(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE);
@Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) ")
Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status);
}

@ -1,5 +1,7 @@
package com.hai.entity;
import com.hai.model.HighGoldRecModel;
import java.io.Serializable;
import java.util.Date;
@ -12,7 +14,7 @@ import java.util.Date;
* 代码由工具生成
*
**/
public class HighGoldRec implements Serializable {
public class HighGoldRec extends HighGoldRecModel implements Serializable {
/**
* 编号
*/

@ -0,0 +1,16 @@
package com.hai.model;
import com.hai.entity.HighUser;
public class HighGoldRecModel {
private HighUser highUser;
public HighUser getHighUser() {
return highUser;
}
public void setHighUser(HighUser highUser) {
this.highUser = highUser;
}
}

@ -1,7 +1,9 @@
package com.hai.service;
import com.hai.entity.HighCouponAgentCode;
import com.hai.entity.HighCouponAgentRecord;
import com.hai.entity.HighCouponAgentRel;
import org.apache.ibatis.annotations.Param;
import java.security.PrivateKey;
import java.util.List;
@ -77,4 +79,29 @@ public interface HighCouponAgentService {
* @Date 2021/4/22 22:26
**/
Map<String, Object> getSalesCountByAgent(Long agentId) throws Exception;
/**
*
* @param map
* @return 查询分发记录
* @throws Exception
*/
List<HighCouponAgentRecord> getRecordList(Map<String, Object> map);
/**
* 查询代理商的卡券
* @param map
* @return
*/
List<HighCouponAgentCode> getCouponAgentCodeList(Map<String, Object> map);
/**
* 根据时间查询 代理商已销售的卡券
* @param agentId
* @param consumeTimeS
* @param consumeTimeE
* @return
*/
List<HighCouponAgentCode> getAgentSalesCodeList(Long agentId,String consumeTimeS,String consumeTimeE);
}

@ -46,4 +46,19 @@ public interface HighDiscountAgentCodeService {
* @Date 2021/4/14 23:38
**/
HighDiscountAgentCode getCodeById(Long id);
/**
* 查询已分配的优惠券总数
* @param discountAgentId
* @return
*/
Integer getTotalDiscount(Long discountAgentId);
/**
* 查询已领取的优惠券总数
* @param discountAgentId
* @return
*/
Integer getSalesDiscount(Long discountAgentId);
}

@ -11,10 +11,7 @@ import com.hai.dao.HighCouponAgentRecordMapper;
import com.hai.dao.HighCouponAgentRelMapper;
import com.hai.entity.*;
import com.hai.model.AgentSalesModel;
import com.hai.service.HighAgentService;
import com.hai.service.HighCouponAgentService;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService;
import com.hai.service.*;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -38,6 +35,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
@Resource
private HighCouponAgentRelMapper highCouponAgentRelMapper;
@Resource
private HighMerchantService highMerchantService;
@Resource
private HighCouponAgentCodeMapper highCouponAgentCodeMapper;
@ -161,6 +161,14 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
criteria.andAgentIdEqualTo(MapUtils.getLong(map, "agentId"));
}
if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
}
if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) {
String[] strings = MapUtils.getString(map, "status").split(",");
List<Integer> statusList = new ArrayList<>();
@ -229,7 +237,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
Map<String,Object> listMap = new HashMap<>();
listMap.put("agentId", agentId);
List<HighCouponAgentRel> list = getCouponAgentList(listMap);
List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList());
for (HighCouponAgentRel highCouponAgentRel : list) {
BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice()));
surplusCountPrice = surplusCountPrice.add(surplusPrice);
@ -265,4 +273,49 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
returnMap.put("list", list);
return returnMap;
}
@Override
public List<HighCouponAgentRecord> getRecordList(Map<String, Object> map) {
HighCouponAgentRecordExample example = new HighCouponAgentRecordExample();
HighCouponAgentRecordExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "couponAgentId") != null) {
criteria.andCouponAgentIdEqualTo(MapUtils.getLong(map, "couponAgentId"));
}
example.setOrderByClause("create_time desc");
return highCouponAgentRecordMapper.selectByExample(example);
}
@Override
public List<HighCouponAgentCode> getCouponAgentCodeList(Map<String, Object> map) {
HighCouponAgentCodeExample example = new HighCouponAgentCodeExample();
HighCouponAgentCodeExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "recordId") != null) {
criteria.andCouponAgentRecordIdEqualTo(MapUtils.getLong(map, "recordId"));
}
example.setOrderByClause("create_time desc");
return highCouponAgentCodeMapper.selectByExample(example);
}
@Override
public List<HighCouponAgentCode> getAgentSalesCodeList(Long agentId, String consumeTimeS, String consumeTimeE) {
List<HighCouponAgentCode> list = highCouponAgentRelMapper.getAgentSalesCodeList(agentId, consumeTimeS, consumeTimeE);
if (list != null && list.size() > 0) {
for (HighCouponAgentCode code : list) {
HighCoupon highCoupon = highCouponService.getCouponById(code.getCouponId());
if (highCoupon != null) {
HighMerchant merchant = highMerchantService.getMerchantById(highCoupon.getMerchantId());
code.setMerchantLogo(merchant.getMerchantLogo());
code.setMerchantName(merchant.getMerchantName());
}
code.setHighCoupon(highCoupon);
code.setHighCouponCode(highCouponCodeService.getCouponCodeById(code.getCouponCodeId()));
}
return list;
}
return new ArrayList<>();
}
}

@ -77,4 +77,18 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
public HighDiscountAgentCode getCodeById(Long id) {
return highDiscountAgentCodeMapper.selectByPrimaryKey(id);
}
@Override
public Integer getTotalDiscount(Long discountAgentId) {
HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample();
example.createCriteria().andDiscountAgentIdEqualTo(discountAgentId);
return highDiscountAgentCodeMapper.selectByExample(example).size();
}
@Override
public Integer getSalesDiscount(Long discountAgentId) {
HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample();
example.createCriteria().andDiscountAgentIdEqualTo(discountAgentId).andStatusNotEqualTo(1);
return highDiscountAgentCodeMapper.selectByExample(example).size();
}
}

@ -125,6 +125,8 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
for (HighDiscountAgentRel rel : list) {
rel.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId()));
rel.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId()));
// rel.setTotalCount(highDiscountAgentCodeService.getTotalDiscount(rel.getId()));
// rel.setSalesCount(highDiscountAgentCodeService.getSalesDiscount(rel.getId()));
}
return list;
}

@ -4,6 +4,7 @@ import com.hai.dao.HighGoldRecMapper;
import com.hai.entity.HighGoldRec;
import com.hai.entity.HighGoldRecExample;
import com.hai.service.HighGoldRecService;
import com.hai.service.HighUserService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
@ -22,6 +23,9 @@ public class HighGoldRecServiceImpl implements HighGoldRecService {
@Resource
private HighGoldRecMapper highGoldRecMapper;
@Resource
private HighUserService highUserService;
@Override
public void insertGoldRec(HighGoldRec highGoldRec) {
highGoldRecMapper.insert(highGoldRec);
@ -41,6 +45,10 @@ public class HighGoldRecServiceImpl implements HighGoldRecService {
}
example.setOrderByClause("create_time desc");
return highGoldRecMapper.selectByExample(example);
List<HighGoldRec> list = highGoldRecMapper.selectByExample(example);
for (HighGoldRec highGoldRec : list) {
highGoldRec.setHighUser(highUserService.findByUserId(highGoldRec.getUserId()));
}
return list;
}
}

Loading…
Cancel
Save