diff --git a/mallinkAdmin/src/main/resources/db/migration/V202007311142__GROUP__ADD_002.sql b/mallinkAdmin/src/main/resources/db/migration/V202007311142__GROUP__ADD_002.sql index b8684007b..5352bdee7 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202007311142__GROUP__ADD_002.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202007311142__GROUP__ADD_002.sql @@ -26,7 +26,7 @@ BEGIN EXECUTE stmt_new; DEALLOCATE PREPARE stmt_new; END IF; - END LOOP; + END LOOP; CLOSE table_cursor; IF err_flag THEN ROLLBACK; diff --git a/mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql b/mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql index bab3db886..f9ad847a9 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202007311200__FOR_MEMBER_ONLY_001.sql @@ -134,7 +134,6 @@ BEGIN 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 ; @@ -148,12 +147,19 @@ BEGIN 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 poins = (SELECT SUM(poins) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)), + select group_concat(tenantId) into @tenantIds from ( + SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.tenant_id,',',b.help_topic_id + 1),',',-1) as tenantId FROM + (SELECT DISTINCT tenant_id FROM wx_c_user_basic_info where id in (newCuserId,oldCuserId)) a + JOIN mysql.help_topic b ON b.help_topic_id < (LENGTH(a.tenant_id) - LENGTH(REPLACE(a.tenant_id,',','')) + 1) + ) c where tenantId != ""; + + UPDATE wx_c_user_basic_info SET tenant_id = concat(',',@tenantIds,','), + poins = (SELECT SUM(poins) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)), credit = (SELECT SUM(credit) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)), login_count = (SELECT SUM(login_count) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)) WHERE id = newCuserId ; - UPDATE wx_c_user_basic_info SET phone = concat(phone,'(作废)'),`status` = 1 WHERE id = oldCuserId ; + UPDATE wx_c_user_basic_info SET phone = concat(phone,'_del_',date_format(now(),'%Y%m%d%H%m%s')),`status` = 1 WHERE id = oldCuserId ; IF err_flag THEN ROLLBACK; diff --git a/mallinkAdmin/src/main/resources/db/migration/V202009041200__commercialPreferential.sql b/mallinkAdmin/src/main/resources/db/migration/V202009041200__commercialPreferential.sql index 88e24ff5d..05bd89902 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202009041200__commercialPreferential.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202009041200__commercialPreferential.sql @@ -27,7 +27,7 @@ update wx_c_user_basic_info set tenant_id = concat(",",final_tenant_id,","); -CREATE DEFINER=`root`@`%` PROCEDURE `move_after_group`(IN tenantIds VARCHAR(125)) +CREATE DEFINER=`root`@`%` PROCEDURE `move_after_group`(IN tenantIds VARCHAR(125),IN groupTenantId VARCHAR(125)) BEGIN DECLARE done INT DEFAULT 0; @@ -48,7 +48,7 @@ BEGIN DECLARE oldCuserId BIGINT DEFAULT 0; DECLARE newCuserId BIGINT DEFAULT 0; - DECLARE users CURSOR FOR SELECT id FROM `wx_c_user_basic_info` WHERE phone = phonestr and FIND_IN_SET(final_tenant_id,tenantIds) order by active_time DESC; + DECLARE users CURSOR FOR SELECT id FROM `wx_c_user_basic_info` WHERE phone = phonestr and FIND_IN_SET(final_tenant_id,tenantIds) order by active_time DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done2 = 1; OPEN users; @@ -58,48 +58,23 @@ BEGIN SET oldCuserId =userid; ELSE SET newCuserId =userid; - - 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_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 poins = (SELECT SUM(poins) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)), - credit = (SELECT SUM(credit) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)), - login_count = (SELECT SUM(login_count) FROM wx_c_user_basic_info WHERE id in (oldCuserId,newCuserId)) - WHERE id = newCuserId ; - - UPDATE wx_c_user_basic_info SET phone = concat(phone,'(作废)',"--",num),`status` = 1 WHERE id = oldCuserId ; - + CALL cuser_old_to_new(oldCuserId,newCuserId); END IF; SET num = num +1; FETCH users INTO userid; END WHILE; CLOSE users; - END; FETCH phones INTO phonestr; END WHILE; CLOSE phones; + UPDATE wx_c_user_basic_info SET final_tenant_id = groupTenantId WHERE FIND_IN_SET(final_tenant_id,tenantIds); + UPDATE wx_c_user_tags SET tenant_id = groupTenantId WHERE FIND_IN_SET(tenant_id,tenantIds); + CALL init_after_group(groupTenantId,tenantIds); + IF done = -1 THEN ROLLBACK; ELSE diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java index da6a7d3b6..92c9f76a4 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java @@ -76,11 +76,7 @@ public class WxMsgValidationcodeController extends BaseController { ResultData rd = wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); if (rd.code == Result.SUCCESS) { // 更新到basicinfo - Long userId = user.getId(); - if (user.basicInfoIs()) { - userId = user.getUserId(); - } - Long basicUserId = saveToBasicInfoByCUser(phone, user.getNickName(), user.getAvatarUrl(), user.getGender(), userId); + Long basicUserId = saveToBasicInfoByCUser(phone, user.getNickName(), user.getAvatarUrl(), user.getGender(), user.getUserId()); if (null != basicUserId) { if(basicUserId.intValue() == -1){ return rd; @@ -91,6 +87,7 @@ public class WxMsgValidationcodeController extends BaseController { user.setVerifyCodePhone(phone); user.setUpdateDate(new Date()); wxCUserService.saveOrUpdate(user); +// wxCUserService.assureUserIdOnly(user.getId(),); wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE,user); cUserTokenService.removeTokenCache(user.getToken()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index ef3bc5e9f..16abac583 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -996,10 +996,10 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc // user.setCredit(credit); // wxCUserMapper.updateById(user); // } - if(user.getUserId() == null){ - user.setUserId(user.getId()); - wxCUserMapper.updateById(user); - } +// if(user.getUserId() == null){ +// user.setUserId(oldUserBase.getId()); +// wxCUserMapper.updateById(user); +// } bHaveCUser = true; if (oldUserBase != null) { if(oldUserBase != null) {