v1.0.26 #36

Merged
timi merged 6 commits from dev into master 2026-08-28 16:52:15 +00:00
4 changed files with 22 additions and 7 deletions
Showing only changes of commit 0239697a2b - Show all commits
@@ -6,6 +6,7 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.Collection;
import java.util.List;
@@ -48,4 +49,11 @@ public interface GaoCustomerMapper extends BaseMapper<GaoCustomer, String> {
/// @param page 查询条件
/// @return 客户列表
List<GaoCustomer> selectByQuery(GaoCustomerPage page);
/// 原子调整邀请客户数
///
/// @param customerId 客户 ID
/// @param delta 变化量
@Update("UPDATE `gao_customer` SET `invited_count` = GREATEST(IFNULL(`invited_count`, 0) + #{delta}, 0), `updated_at` = " + UNIX_TIME + " WHERE `id` = #{customerId}" + NOT_DELETE)
void updateInvitedCountDelta(@Param("customerId") String customerId, @Param("delta") Long delta);
}
@@ -117,12 +117,10 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
customer.setAge(ChronoUnit.YEARS.between(customer.getBirthdate(), LocalDate.now()));
}
customer.setInvitedCount(0L);
if (customer.hasIntroducer()) {
customer.setInvitedCount(1L);
}
customer.setCreatorUserId(userLoginService.getRequireLoginUserId());
super.create(customer);
changeInvitedCount(customer.getIntroducerCustomerId(), 1);
// 标签
if (customer.getTagApply() != null) {
tagService.apply(TagApply.BizType.GAO_CUSTOMER, customer.getId(), customer.getTagApply().getTagIdList());
@@ -369,10 +367,12 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
try {
logger.setContent(customerId);
GaoCustomer customer = get(customerId);
TimiException.required(customer, "not found customer");
String oldIntroducerCustomerId = customer.getIntroducerCustomerId();
customer.setIntroducerCustomerId(null);
mapper.update(customer);
changeInvitedCount(customer.getIntroducerCustomerId(), -1);
changeInvitedCount(oldIntroducerCustomerId, -1);
logger.setLevel(Logger.Level.INFO);
logger.setResult(customerId);
} catch (TimiException e) {
@@ -434,9 +434,7 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
if (TimiJava.isEmpty(customerId) || delta == 0) {
return;
}
GaoCustomer customer = get(customerId);
customer.setInvitedCount(customer.getInvitedCount() + delta);
mapper.update(customer);
mapper.updateInvitedCountDelta(customerId, delta);
}
private void fillPinyin(GaoCustomer customer) {
@@ -0,0 +1,9 @@
UPDATE `gao_customer` AS `customer`
SET `invited_count` = (
SELECT COUNT(1)
FROM `gao_customer` AS `invitee`
WHERE
`invitee`.`introducer_customer_id` = `customer`.`id`
AND `invitee`.`deleted_at` IS NULL
)
WHERE `customer`.`deleted_at` IS NULL;