'修复已知问题'

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

@ -27,6 +27,7 @@ public class ImportCouponListener extends AnalysisEventListener<ImportCouponMode
List<ImportCouponModel> errorData = new ArrayList<>();
List<HighCouponCode> successData = new ArrayList<>();
List<HighCouponCode> allCouponCode = new ArrayList<>();
List<HighCouponCode> allCouponCodeKey = new ArrayList<>();
HighCouponCode highCouponCode;
HighCoupon highCoupon;
UserInfoModel userInfoModel;
@ -56,7 +57,7 @@ public class ImportCouponListener extends AnalysisEventListener<ImportCouponMode
}
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) {
importCouponModel.setErrorMessage("卡券编号id已存在");
errorData.add(importCouponModel);
@ -122,6 +123,7 @@ public class ImportCouponListener extends AnalysisEventListener<ImportCouponMode
this.userInfoModel = userInfoModel;
this.highCouponCodeService = highCouponCodeService;
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 " +
" 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}" +
" 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);
@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({
"<script>",
"insert into high_coupon_code (coupon_id, merchant_id, ",
"child_order_id, sales_code, ",
"sales_end_time, use_end_time, ",
"create_time, receive_time, ",
"consume_time, `status`, ",
"operator_id, operator_name, ",
"insert into high_coupon_code (" +
"coupon_id, " +
"merchant_id, ",
"is_assign_agent," +
"agent_id, ",
"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)",
"values ",
"<foreach collection='list' item='item' index='index' separator=','>",
"(#{item.couponId,jdbcType=BIGINT}, " +
"#{item.merchantId,jdbcType=BIGINT}," +
"#{item.isAssignAgent,jdbcType=BIT}," +
"#{item.agentId,jdbcType=BIGINT}," +
"#{item.storeId,jdbcType=BIGINT}," +
"#{item.childOrderId,jdbcType=BIGINT}, " +
"#{item.codeKey,jdbcType=VARCHAR}, " +
"#{item.salesCode,jdbcType=VARCHAR}, ",
"#{item.salesEndTime,jdbcType=TIMESTAMP}," +
"#{item.useEndTime,jdbcType=TIMESTAMP}, ",

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

@ -154,6 +154,17 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
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
@Transactional(propagation= Propagation.REQUIRES_NEW)
public Map<String, Object> generateCode(Long couponAgentCodeId,String remark) {
@ -210,10 +221,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
consumeTimeS.set(Calendar.SECOND, 00);
Calendar consumeTimeE = Calendar.getInstance();
consumeTimeS.setTime(new Date());
consumeTimeS.set(Calendar.HOUR_OF_DAY, 23);
consumeTimeS.set(Calendar.MINUTE, 59);
consumeTimeS.set(Calendar.SECOND, 59);
consumeTimeE.setTime(new Date());
consumeTimeE.set(Calendar.HOUR_OF_DAY, 23);
consumeTimeE.set(Calendar.MINUTE, 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"));

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

Loading…
Cancel
Save