'修复已知问题'

dev-discount
199901012 4 years ago
parent a41a674e4d
commit f75dad3bb3
  1. 4
      hai-bweb/src/main/java/com/bweb/controller/LoginController.java
  2. 4
      hai-bweb/src/main/java/com/bweb/excelListener/ImportCouponListener.java
  3. 2
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java
  4. 27
      hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java
  5. 8
      hai-service/src/main/java/com/hai/service/HighCouponAgentService.java
  6. 19
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java
  7. 52
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java

@ -111,7 +111,7 @@ public class LoginController {
if (secUser.getObjectType() == 0 || secUser.getObjectType() == 1) { if (secUser.getObjectType() == 0 || secUser.getObjectType() == 1) {
// 公司员工(超级管理员和单位员工) // 公司员工(超级管理员和单位员工)
//查询公司 //查询公司
BsCompany bsCompany = bsCompanyService.getCompanyById(secUser.getCompanyId()); /* BsCompany bsCompany = bsCompanyService.getCompanyById(secUser.getCompanyId());
if(bsCompany == null){ if(bsCompany == null){
log.error("login error!","未找到公司"); log.error("login error!","未找到公司");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COMPANY, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COMPANY, "");
@ -128,7 +128,7 @@ public class LoginController {
userInfoModel.setBsOrganization(bsOrganization); //部门信息 userInfoModel.setBsOrganization(bsOrganization); //部门信息
} }
userInfoModel.setBsCompany(bsCompany); //公司信息 userInfoModel.setBsCompany(bsCompany); //公司信息*/
} else if (secUser.getObjectType() == 2) { } else if (secUser.getObjectType() == 2) {

@ -27,6 +27,7 @@ public class ImportCouponListener extends AnalysisEventListener<ImportCouponMode
List<ImportCouponModel> errorData = new ArrayList<>(); List<ImportCouponModel> errorData = new ArrayList<>();
List<HighCouponCode> successData = new ArrayList<>(); List<HighCouponCode> successData = new ArrayList<>();
List<HighCouponCode> allCouponCode = new ArrayList<>(); List<HighCouponCode> allCouponCode = new ArrayList<>();
List<HighCouponCode> allCouponCodeKey = new ArrayList<>();
HighCouponCode highCouponCode; HighCouponCode highCouponCode;
HighCoupon highCoupon; HighCoupon highCoupon;
UserInfoModel userInfoModel; UserInfoModel userInfoModel;
@ -56,7 +57,7 @@ public class ImportCouponListener extends AnalysisEventListener<ImportCouponMode
} }
if (StringUtils.isNotBlank(importCouponModel.getCodeKey())) { if (StringUtils.isNotBlank(importCouponModel.getCodeKey())) {
List<HighCouponCode> codeList = allCouponCode.stream().filter(o -> o.getCodeKey().equals(importCouponModel.getCodeKey())).collect(Collectors.toList()); List<HighCouponCode> codeList = allCouponCodeKey.stream().filter(o -> o.getCodeKey().equals(importCouponModel.getCodeKey())).collect(Collectors.toList());
if (codeList.size() > 0) { if (codeList.size() > 0) {
importCouponModel.setErrorMessage("卡券编号id已存在"); importCouponModel.setErrorMessage("卡券编号id已存在");
errorData.add(importCouponModel); errorData.add(importCouponModel);
@ -122,6 +123,7 @@ public class ImportCouponListener extends AnalysisEventListener<ImportCouponMode
this.userInfoModel = userInfoModel; this.userInfoModel = userInfoModel;
this.highCouponCodeService = highCouponCodeService; this.highCouponCodeService = highCouponCodeService;
this.allCouponCode = this.highCouponCodeService.getCouponCodeList(new HashMap<>()); this.allCouponCode = this.highCouponCodeService.getCouponCodeList(new HashMap<>());
this.allCouponCodeKey = allCouponCode.stream().filter(o -> !Objects.equals(o.getCodeKey(), null)).collect(Collectors.toList());
} }
} }

@ -15,7 +15,7 @@ public interface HighCouponAgentRelMapperExt {
" case when sum(c.sales_price) is not null then sum(c.sales_price) else 0 end salesCountPrice " + " case when sum(c.sales_price) is not null then sum(c.sales_price) else 0 end salesCountPrice " +
" from high_coupon_agent_code a,high_coupon_code b,high_coupon_agent_rel c" + " 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 = #{agentId}" + " where c.id = a.coupon_agent_id and c.agent_id = #{agentId}" +
" and a.status = 2 and a.coupon_code_id = b.id and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE}") " 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); AgentSalesModel getAgentSales(@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}) ") @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) ")

@ -13,18 +13,33 @@ public interface HighCouponCodeMapperExt {
@Insert({ @Insert({
"<script>", "<script>",
"insert into high_coupon_code (coupon_id, merchant_id, ", "insert into high_coupon_code (" +
"child_order_id, sales_code, ", "coupon_id, " +
"sales_end_time, use_end_time, ", "merchant_id, ",
"create_time, receive_time, ", "is_assign_agent," +
"consume_time, `status`, ", "agent_id, ",
"operator_id, operator_name, ", "store_id, " +
"child_order_id," +
"code_key, " +
"sales_code," +
"sales_end_time," +
"use_end_time, ",
"create_time," +
"receive_time, ",
"consume_time, " +
"`status`, ",
"operator_id, " +
"operator_name, ",
"ext_1, ext_2, ext_3)", "ext_1, ext_2, ext_3)",
"values ", "values ",
"<foreach collection='list' item='item' index='index' separator=','>", "<foreach collection='list' item='item' index='index' separator=','>",
"(#{item.couponId,jdbcType=BIGINT}, " + "(#{item.couponId,jdbcType=BIGINT}, " +
"#{item.merchantId,jdbcType=BIGINT}," + "#{item.merchantId,jdbcType=BIGINT}," +
"#{item.isAssignAgent,jdbcType=BIT}," +
"#{item.agentId,jdbcType=BIGINT}," +
"#{item.storeId,jdbcType=BIGINT}," +
"#{item.childOrderId,jdbcType=BIGINT}, " + "#{item.childOrderId,jdbcType=BIGINT}, " +
"#{item.codeKey,jdbcType=VARCHAR}, " +
"#{item.salesCode,jdbcType=VARCHAR}, ", "#{item.salesCode,jdbcType=VARCHAR}, ",
"#{item.salesEndTime,jdbcType=TIMESTAMP}," + "#{item.salesEndTime,jdbcType=TIMESTAMP}," +
"#{item.useEndTime,jdbcType=TIMESTAMP}, ", "#{item.useEndTime,jdbcType=TIMESTAMP}, ",

@ -56,6 +56,14 @@ public interface HighCouponAgentService {
**/ **/
HighCouponAgentCode getCodeById(Long couponAgentCodeId); HighCouponAgentCode getCodeById(Long couponAgentCodeId);
/**
* @Author 胡锐
* @Description 根据销售码id和代理商 查询代理商销售码
* @Date 2021/4/24 21:58
**/
HighCouponAgentCode getAgentCodeByCodeIdAgent(Long codeId,Long agentId);
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 生成二维码 * @Description 生成二维码

@ -154,6 +154,17 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
return highCouponAgentCodeMapper.selectByPrimaryKey(couponAgentCodeId); return highCouponAgentCodeMapper.selectByPrimaryKey(couponAgentCodeId);
} }
@Override
public HighCouponAgentCode getAgentCodeByCodeIdAgent(Long codeId, Long agentId) {
HighCouponAgentCodeExample example = new HighCouponAgentCodeExample();
example.createCriteria().andCouponCodeIdEqualTo(codeId).andAgentIdEqualTo(agentId);
List<HighCouponAgentCode> list = highCouponAgentCodeMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRES_NEW)
public Map<String, Object> generateCode(Long couponAgentCodeId,String remark) { public Map<String, Object> generateCode(Long couponAgentCodeId,String remark) {
@ -210,10 +221,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
consumeTimeS.set(Calendar.SECOND, 00); consumeTimeS.set(Calendar.SECOND, 00);
Calendar consumeTimeE = Calendar.getInstance(); Calendar consumeTimeE = Calendar.getInstance();
consumeTimeS.setTime(new Date()); consumeTimeE.setTime(new Date());
consumeTimeS.set(Calendar.HOUR_OF_DAY, 23); consumeTimeE.set(Calendar.HOUR_OF_DAY, 23);
consumeTimeS.set(Calendar.MINUTE, 59); consumeTimeE.set(Calendar.MINUTE, 59);
consumeTimeS.set(Calendar.SECOND, 59); consumeTimeE.set(Calendar.SECOND, 59);
AgentSalesModel agentSales = highCouponAgentRelMapper.getAgentSales(agentId, DateUtil.date2String(consumeTimeS.getTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(consumeTimeE.getTime(), "yyyy-MM-dd HH:mm:ss")); AgentSalesModel agentSales = highCouponAgentRelMapper.getAgentSales(agentId, DateUtil.date2String(consumeTimeS.getTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(consumeTimeE.getTime(), "yyyy-MM-dd HH:mm:ss"));

@ -10,10 +10,7 @@ import com.hai.dao.HighCouponCodeMapper;
import com.hai.dao.HighCouponCodeMapperExt; import com.hai.dao.HighCouponCodeMapperExt;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.HighCouponCodeService; import com.hai.service.*;
import com.hai.service.HighCouponService;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserCouponService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -49,6 +46,9 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
@Resource @Resource
private HighUserCouponService highUserCouponService; private HighUserCouponService highUserCouponService;
@Resource
private HighCouponAgentService highCouponAgentService;
@Override @Override
public void insertCouponCode(HighCouponCode highCouponCode) { public void insertCouponCode(HighCouponCode highCouponCode) {
highCouponCodeMapper.insert(highCouponCode); highCouponCodeMapper.insert(highCouponCode);
@ -105,21 +105,29 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
salesCode.setStatus(3); salesCode.setStatus(3);
updateCouponCode(salesCode); updateCouponCode(salesCode);
//修改 用户与卡卷的关系 // 代理商
HighUserCoupon userCoupon = highUserCouponService.getDetailByCodeId(salesCode.getId()); if (salesCode.getIsAssignAgent() == true) {
if (userCoupon == null) { HighCouponAgentCode couponAgentCode = highCouponAgentService.getAgentCodeByCodeIdAgent(salesCode.getId(), salesCode.getAgentId());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷状态异常"); if (couponAgentCode != null) {
couponAgentCode.setStatus(3);
highCouponAgentService.updateCouponAgentCode(couponAgentCode);
}
} }
HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId()); //修改 用户与卡卷的关系
if (order == null) { HighUserCoupon userCoupon = highUserCouponService.getDetailByCodeId(salesCode.getId());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); // 可能是分卡卡券,分发卡券没有绑定用户
if (userCoupon != null) {
HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId());
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单");
}
userCoupon.setStoreId(userInfoModel.getMerchantStore().getId());
userCoupon.setConsumeTime(new Date());
userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponService.updateUserCoupon(userCoupon);
highOrderService.childOrderComplete(order.getId());
} }
userCoupon.setStoreId(userInfoModel.getMerchantStore().getId());
userCoupon.setConsumeTime(new Date());
userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponService.updateUserCoupon(userCoupon);
highOrderService.childOrderComplete(order.getId());
} }
@Override @Override
@ -134,6 +142,16 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("status", "1"); map.put("status", "1");
map.put("couponCodeId", code.getId()); map.put("couponCodeId", code.getId());
// 代理商
if (code.getIsAssignAgent() == true) {
HighCouponAgentCode couponAgentCode = highCouponAgentService.getAgentCodeByCodeIdAgent(code.getId(), code.getAgentId());
if (couponAgentCode != null) {
couponAgentCode.setStatus(3);
highCouponAgentService.updateCouponAgentCode(couponAgentCode);
}
}
List<HighUserCoupon> list = highUserCouponService.getUserCouponList(map); List<HighUserCoupon> list = highUserCouponService.getUserCouponList(map);
if (list.size() > 0) { if (list.size() > 0) {
for (HighUserCoupon userCoupon : list) { for (HighUserCoupon userCoupon : list) {
@ -200,7 +218,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
@Override @Override
public List<HighCouponCode> getNoSaleCode(Long couponId) { public List<HighCouponCode> getNoSaleCode(Long couponId) {
HighCouponCodeExample example = new HighCouponCodeExample(); HighCouponCodeExample example = new HighCouponCodeExample();
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1); example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1).andIsAssignAgentEqualTo(false);
return highCouponCodeMapper.selectByExample(example); return highCouponCodeMapper.selectByExample(example);
} }

Loading…
Cancel
Save