完成查询优惠券

dev-discount
= 4 years ago
parent d1792fa55b
commit 14eade9413
  1. 58
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java
  2. 4
      hai-service/src/main/java/com/hai/entity/HighDiscountAgentCode.java
  3. 44
      hai-service/src/main/java/com/hai/model/HighDiscountAgentCodeModel.java
  4. 7
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  5. 33
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  6. 21
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -15,15 +15,11 @@ import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil; import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator; import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighAgent; import com.hai.entity.*;
import com.hai.entity.HighDiscount;
import com.hai.entity.HighDiscountAgentRel;
import com.hai.enum_type.QrCodeType; import com.hai.enum_type.QrCodeType;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.HighAgentService; import com.hai.service.*;
import com.hai.service.HighDiscountAgentRelService;
import com.hai.service.HighDiscountService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -62,6 +58,12 @@ public class HighDiscountAgentRelController {
@Resource @Resource
private HighDiscountAgentRelService highDiscountAgentRelService; private HighDiscountAgentRelService highDiscountAgentRelService;
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighOrderService highOrderService;
@RequestMapping(value="/insertDiscountAgent",method = RequestMethod.POST) @RequestMapping(value="/insertDiscountAgent",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "分配优惠券给代理商") @ApiOperation(value = "分配优惠券给代理商")
@ -157,4 +159,48 @@ public class HighDiscountAgentRelController {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value="/getDiscountCodeList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券码 列表")
public ResponseData getDiscountAgentList(@RequestParam(name = "couponAgentId", required = true) Long couponAgentId,
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
Map<String, Object> map = new HashMap<>();
map.put("couponAgentId", couponAgentId);
map.put("status", status);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highDiscountAgentCodeService.getDiscountCode(map)));
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountAgentList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDiscountCodeById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券码 详情")
public ResponseData getDiscountCodeById(@RequestParam(name = "couponCodeId", required = true) Long couponCodeId) {
try {
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(couponCodeId);
if (code != null) {
HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(code.getDiscountAgentId());
code.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId()));
code.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId()));
code.setHighOrder(highOrderService.getConsumeOrderByDiscountCode(code.getId()));
return ResponseMsgUtil.success(code);
}
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountCodeById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
} }

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

@ -0,0 +1,44 @@
package com.hai.model;
import com.hai.entity.HighAgent;
import com.hai.entity.HighDiscount;
import com.hai.entity.HighOrder;
/**
* 优惠券码
*/
public class HighDiscountAgentCodeModel {
// 代理商
private HighAgent highAgent;
// 优惠券
private HighDiscount highDiscount;
// 订单
private HighOrder highOrder;
public HighAgent getHighAgent() {
return highAgent;
}
public void setHighAgent(HighAgent highAgent) {
this.highAgent = highAgent;
}
public HighDiscount getHighDiscount() {
return highDiscount;
}
public void setHighDiscount(HighDiscount highDiscount) {
this.highDiscount = highDiscount;
}
public HighOrder getHighOrder() {
return highOrder;
}
public void setHighOrder(HighOrder highOrder) {
this.highOrder = highOrder;
}
}

@ -105,6 +105,13 @@ public interface HighOrderService {
**/ **/
List<HighOrder> getCloseOrder(); List<HighOrder> getCloseOrder();
/**
* 根据优惠券代理商id 查询已消费的订单
* @param discountAgentId
* @return
*/
HighOrder getConsumeOrderByDiscountCode(Long discountCodeId);
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 子订单完成 * @Description 子订单完成

@ -1,9 +1,8 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.hai.dao.HighDiscountAgentCodeMapper; import com.hai.dao.HighDiscountAgentCodeMapper;
import com.hai.entity.HighDiscountAgentCode; import com.hai.entity.*;
import com.hai.entity.HighDiscountAgentCodeExample; import com.hai.service.*;
import com.hai.service.HighDiscountAgentCodeService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,6 +21,18 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
@Resource @Resource
private HighDiscountAgentCodeMapper highDiscountAgentCodeMapper; private HighDiscountAgentCodeMapper highDiscountAgentCodeMapper;
@Resource
private HighDiscountAgentRelService highDiscountAgentRelService;
@Resource
private HighDiscountService highDiscountService;
@Resource
private HighAgentService highAgentService;
@Resource
private HighOrderService highOrderService;
@Override @Override
public void insertCodeList(List<HighDiscountAgentCode> discountAgentCodeList) { public void insertCodeList(List<HighDiscountAgentCode> discountAgentCodeList) {
highDiscountAgentCodeMapper.insertListCode(discountAgentCodeList); highDiscountAgentCodeMapper.insertListCode(discountAgentCodeList);
@ -45,7 +56,21 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
if (MapUtils.getLong(map, "discountAgentId") != null) { if (MapUtils.getLong(map, "discountAgentId") != null) {
criteria.andDiscountAgentIdEqualTo(MapUtils.getLong(map, "discountAgentId")); criteria.andDiscountAgentIdEqualTo(MapUtils.getLong(map, "discountAgentId"));
} }
return highDiscountAgentCodeMapper.selectByExample(example);
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
example.setOrderByClause("create_time desc");
List<HighDiscountAgentCode> list = highDiscountAgentCodeMapper.selectByExample(example);
for (HighDiscountAgentCode code : list) {
HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(code.getDiscountAgentId());
if (rel != null) {
code.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId()));
code.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId()));
}
}
return list;
} }
@Override @Override

@ -342,6 +342,27 @@ public class HighOrderServiceImpl implements HighOrderService {
return highOrderMapperExt.getCloseOrder(); return highOrderMapperExt.getCloseOrder();
} }
@Override
public HighOrder getConsumeOrderByDiscountCode(Long discountCodeId) {
// 查询优惠券有没有被使用
HighDiscountUserRelExample example = new HighDiscountUserRelExample();
example.createCriteria().andDiscountAgentCodeIdEqualTo(discountCodeId).andStatusEqualTo(2);
List<HighDiscountUserRel> userRels = highDiscountUserRelMapper.selectByExample(example);
if (userRels.size() > 0) {
HighOrderExample orderExample =new HighOrderExample();
orderExample.createCriteria().andMemDiscountIdEqualTo(userRels.get(0).getId());
List<HighOrder> orderList = highOrderMapper.selectByExample(orderExample);
if (orderList.size() > 0) {
HighOrder highOrder = orderList.get(0);
highOrder.setHighChildOrderList(getChildOrderByOrder(highOrder.getId()));
return highOrder;
}
}
return null;
}
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRES_NEW)
public void childOrderComplete(Long childOrderId) { public void childOrderComplete(Long childOrderId) {

Loading…
Cancel
Save