xhxu 5 лет назад
Родитель
Сommit
5ea0f32f3d
7 измененных файлов: 78 добавлений и 4 удалений
  1. +25
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java
  2. +38
    -2
      mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql
  3. +1
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java
  4. +1
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxProjectConfigMapper.java
  5. +2
    -0
      mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java
  6. +7
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  7. +4
    -0
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml

+ 25
- 0
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java Просмотреть файл

@@ -566,4 +566,29 @@ public class WxCUserBasicInfoController extends BaseController {
return wxCUserBasicInfoService.updateStatus(wxCUserBasicInfo);
}

@ApiOperation("根据手机号迁移")
@PostMapping("/cuserOldToNew")
@SystemControllerLog(description = "会员管理-迁移数据")
public ResultData cuserOldToNew(@RequestBody Map<String,String> map) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::cuserOldToNew");
String oldCuserPhone = (String) map.get("oldCuserPhone");
String newCuserPhone = (String) map.get("newCuserPhone");
if(StringUtils.isNotBlank(oldCuserPhone) && StringUtils.isNotBlank(newCuserPhone)){
WxCUserBasicInfo oldCuser = wxCUserBasicInfoService.findInfoByPhone(ifParentUpdateTenantInfo(), oldCuserPhone);
WxCUserBasicInfo newCuser = wxCUserBasicInfoService.findInfoByPhone(ifParentUpdateTenantInfo(), newCuserPhone);
if(null != oldCuser && null != newCuser){
if(!oldCuserPhone.equals(newCuserPhone)){
wxCUserBasicInfoService.cuserOldToNew(oldCuser.getId(),newCuser.getId());
return new ResultData();
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"同一个用户");
}
}else{
return new ResultData(ErrorCode.USER_IS_EMPTY);
}
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
}

}

+ 38
- 2
mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql Просмотреть файл

@@ -10,8 +10,7 @@ ADD COLUMN `final_tenant_id` varchar(5) NOT NULL COMMENT '归属租户ID' AFTER
update wx_c_user_basic_info set final_tenant_id = parent_tenant_id;
update wx_c_user_basic_info set final_tenant_id = tenant_id where (parent_tenant_id is null or trim(parent_tenant_id) = "");

DROP INDEX `PHONE_UNIQUE`,
ADD UNIQUE INDEX `PHONE_UNIQUE`(`final_tenant_id`, `phone`) USING BTREE;
ALTER TABLE wx_c_user_basic_info ADD UNIQUE INDEX `PHONE_UNIQUE`(`final_tenant_id`, `phone`) USING BTREE;


ALTER TABLE `wx_c_user_basic_info`
@@ -69,5 +68,42 @@ ADD COLUMN `from_id` BIGINT(20) DEFAULT NULL COMMENT '来源ID,针对续签,
合同状态为4(即将到期)更新为计租中,合同状态为8(补录),9(续签)更新为草稿。


CREATE DEFINER=`root`@`%` PROCEDURE `cuser_old_to_new`(IN `oldCuserId` bigint,IN `newCuserId` bigint)
BEGIN
DECLARE err_flag INT DEFAULT FALSE;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET err_flag = TRUE;

UPDATE wx_c_user SET user_id = newCuserId WHERE user_id = oldCuserId ;
UPDATE wx_activity_join SET user_id = newCuserId WHERE user_id = oldCuserId ;
UPDATE wx_c_user_tags SET user_id = newCuserId WHERE user_id = oldCuserId ;
UPDATE wx_game_action_log SET user_id = newCuserId WHERE user_id = oldCuserId ;
UPDATE wx_order_group SET user_id = newCuserId WHERE user_id = oldCuserId ;
UPDATE wx_order_press SET user_id = newCuserId WHERE user_id = oldCuserId ;
UPDATE wx_question_log SET user_id = newCuserId WHERE user_id = oldCuserId ;

UPDATE wx_c_user_car SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_c_user_from_b SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_coupon_order SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_credit_history SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_order SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_pay_order SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_refund_order SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;
UPDATE wx_score_history SET c_user_id = newCuserId WHERE c_user_id = oldCuserId ;

UPDATE wx_card_spend SET owner_id = newCuserId WHERE owner_id = oldCuserId ;
UPDATE wx_coupon_order SET owner_id = newCuserId WHERE owner_id = oldCuserId ;

UPDATE wx_credit_history SET operator_id = newCuserId WHERE operator_type in (1,2) and operator_id = oldCuserId ;

UPDATE wx_c_user_basic_info SET phone = phone + '(作废)',`status` = 1 WHERE id = oldCuserId ;

IF err_flag THEN
ROLLBACK;
ELSE
COMMIT;
END IF;
END





+ 1
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java Просмотреть файл

@@ -73,6 +73,7 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S
*/
List<WxCUserBasicInfo> selectNotCUserList();

void cuserOldToNew(@Param(value = "oldCuserId")Long oldCuserId, @Param(value = "newCuserId")Long newCuserId);

}


+ 1
- 1
mallinkService/src/main/java/com/iformall/mapper/WxProjectConfigMapper.java Просмотреть файл

@@ -7,6 +7,6 @@ import org.apache.ibatis.annotations.Param;

public interface WxProjectConfigMapper extends BaseMapper<WxProjectConfig> {


void initAfterGroup(@Param(value = "tenantId")String tenantId, @Param(value = "subTenantIds")String subTenantIds);

}

+ 2
- 0
mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java Просмотреть файл

@@ -168,5 +168,7 @@ public interface WxCUserBasicInfoService {
List<WxCUserBasicInfo> findListByScore(TenantEntity tenantEntity, WxCUserBasicInfoDto wxCUserBasicInfoDto);

List<WxCUserBasicInfo> findBirthdayList(TenantEntity tenantEntity, String format, String format1);

void cuserOldToNew(Long oldCuserId, Long newCuserId);
}


+ 7
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java Просмотреть файл

@@ -1207,7 +1207,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc
return wxCUserBasicInfoMapper.findBirthdayList(finalTenantId,format,format1);
}
}
@Override

@Override
public void cuserOldToNew(Long oldCuserId, Long newCuserId) {
wxCUserBasicInfoMapper.cuserOldToNew(oldCuserId,newCuserId);
}

@Override
public List<Object> selectListForExcelExport(Object queryParams, int page) {
Map params = (Map) queryParams;
WxCUserBasicInfo basicInfo = (WxCUserBasicInfo) params.get("basicInfo");


+ 4
- 0
mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml Просмотреть файл

@@ -1065,4 +1065,8 @@
<select id="selectNotCUserList" resultMap="BaseResultMap">
select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.user_id=cub.id) and cub.credit is null
</select>

<update id="cuserOldToNew" statementType="CALLABLE" >
{call cuser_old_to_new(#{oldCuserId},#{newCuserId})}
</update>
</mapper>

Загрузка…
Отмена
Сохранить