Browse Source

一键通关修改

huwei 1 month ago
parent
commit
e2c8e76c69

+ 25 - 57
server/internal/admin/service/gm.go

@@ -128,55 +128,25 @@ func (s *sGm) UpdateChapter(ctx *gin.Context, req forms.UpdateChapterReq) serial
 	}
 
 	msgId := character.GenerateMsgId()
+	var msg msg2.GmUpdateChapter
 	if req.OneFull {
-		msg := msg2.GmUpdateChapter{
+		msg = msg2.GmUpdateChapter{
 			MsgId:    msgId,
 			PlayerID: req.Playerid,
 			Chapters: NewFullChapters(true),
 		}
 
 		rpc_share.MsgMap[msgId] = fmt.Sprintf("GM为玩家[%d]一键通关", req.Playerid)
-
-		var resp *msg2.ResponseGmUpdateChapter
-		res, err := config.GmNats.GmRequest(DB, "GmUpdateChapter", msg)
-		if err != nil {
-			return serializer.Err(consts.CodeParamErr, err.Error(), err)
-		}
-
-		if err = json.Unmarshal(res, &resp); err != nil {
-			return serializer.Err(consts.CodeParamErr, err.Error(), err)
-		}
-
-		rpc_share.LogChan <- rpc_share.LogMsg{
-			MsgID: msg.MsgId,
-			Data:  resp,
-		}
-
 	} else if req.OneEmpty {
-		msg := msg2.GmUpdateChapter{
+		msg = msg2.GmUpdateChapter{
 			MsgId:    msgId,
 			PlayerID: req.Playerid,
 			Chapters: NewFullChapters(false),
 		}
 
 		rpc_share.MsgMap[msgId] = fmt.Sprintf("GM清除了玩家[%d]的通关数据", req.Playerid)
-
-		var resp *msg2.ResponseGmUpdateChapter
-		res, err := config.GmNats.GmRequest(DB, "GmUpdateChapter", msg)
-		if err != nil {
-			return serializer.Err(consts.CodeParamErr, err.Error(), err)
-		}
-
-		if err = json.Unmarshal(res, &resp); err != nil {
-			return serializer.Err(consts.CodeParamErr, err.Error(), err)
-		}
-
-		rpc_share.LogChan <- rpc_share.LogMsg{
-			MsgID: msg.MsgId,
-			Data:  resp,
-		}
 	} else {
-		msg := msg2.GmUpdateChapter{
+		msg = msg2.GmUpdateChapter{
 			MsgId:    msgId,
 			PlayerID: req.Playerid,
 			Chapters: NewPassChapters(req.PassChapters),
@@ -185,44 +155,42 @@ func (s *sGm) UpdateChapter(ctx *gin.Context, req forms.UpdateChapterReq) serial
 			return serializer.Err(consts.CodeParamErr, "请选择一个有效的关卡", nil)
 		}
 		rpc_share.MsgMap[msgId] = fmt.Sprintf("GM为玩家[%d]通关了指定关卡:%v", req.Playerid, req.PassChapters)
+	}
 
-		var resp *msg2.ResponseGmUpdateChapter
-		res, err := config.GmNats.GmRequest(DB, "GmUpdateChapter", msg)
-		if err != nil {
-			return serializer.Err(consts.CodeParamErr, err.Error(), err)
-		}
+	var resp *msg2.ResponseGmUpdateChapter
+	res, err := config.GmNats.GmRequest(DB, "GmUpdateChapter", msg)
+	if err != nil {
+		return serializer.Err(consts.CodeParamErr, err.Error(), err)
+	}
 
-		if err = json.Unmarshal(res, &resp); err != nil {
-			return serializer.Err(consts.CodeParamErr, err.Error(), err)
-		}
+	if err = json.Unmarshal(res, &resp); err != nil {
+		return serializer.Err(consts.CodeParamErr, err.Error(), err)
+	}
 
-		rpc_share.LogChan <- rpc_share.LogMsg{
-			MsgID: msg.MsgId,
-			Data:  resp,
-		}
+	rpc_share.LogChan <- rpc_share.LogMsg{
+		MsgID: msg.MsgId,
+		Data:  resp,
 	}
 
 	return serializer.Suc(req)
 }
 
-func NewFullChapters(pass bool) []int64 {
-	var chapters []int64
-	if !pass {
-		return chapters
+func NewFullChapters(pass bool) map[int64]int64 {
+	chapters := make(map[int64]int64, 3)
+	if pass {
+		chapters = gmdata.GetMaxChapterForType()
 	}
-	for _, chapter := range gmdata.Chapters {
-		chapters = append(chapters, chapter.Uid)
-	}
-
 	return chapters
 }
 
-func NewPassChapters(chapterStr []string) []int64 {
-	var chapters []int64
+func NewPassChapters(chapterStr []string) map[int64]int64 {
+	chapters := make(map[int64]int64, 3)
 	chapterMap := gmdata.GetChaptersMap()
 	for _, chapter := range chapterStr {
 		if data, ok := chapterMap[chapter]; ok {
-			chapters = append(chapters, data.Uid)
+			if _, ok1 := chapters[data.Type]; !ok1 || data.Uid > chapters[data.Type] {
+				chapters[data.Type] = data.Uid
+			}
 		}
 	}
 	return chapters

+ 10 - 0
server/package/gmdata/chapter.go

@@ -78,6 +78,16 @@ func GetChaptersMap() map[string]*model2.LevelListItem {
 	return data
 }
 
+func GetMaxChapterForType() map[int64]int64 {
+	maxChapters := make(map[int64]int64)
+	for _, chapter := range Chapters {
+		if _, ok := maxChapters[chapter.Type]; !ok || chapter.Uid > maxChapters[chapter.Type] {
+			maxChapters[chapter.Type] = chapter.Uid
+		}
+	}
+	return maxChapters
+}
+
 func GetChapterById(id int32) *model2.LevelListItem {
 	for _, v := range Chapters {
 		if v.Uid == int64(id) {

+ 4 - 4
server/package/graveserver/leafstalk/covenant/msg/chapter.go

@@ -198,10 +198,10 @@ type InviteCoopData struct {
 
 // 修改章节通过数、是否通关
 type GmUpdateChapter struct {
-	MsgId      string  `json:"msgId"`
-	PlayerID   int64   `json:"userId"`
-	Chapters   []int64 `json:"chapters"`
-	OperatorId int64   `json:"operatorId"`
+	MsgId      string          `json:"msgId"`
+	PlayerID   int64           `json:"userId"`
+	Chapters   map[int64]int64 `json:"chapters"` // {类型:通关到的关卡id}
+	OperatorId int64           `json:"operatorId"`
 }
 
 type ResponseGmUpdateChapter struct {

+ 81 - 123
web/src/views/account/accountList/components/BaseInfo.vue

@@ -56,17 +56,12 @@
         </n-descriptions-item>
         <n-descriptions-item label="玩家体力">
           <n-space>
-            <span class="default_text_value">{{ userInfo.stamina }}</span>
+            <span class="default_text_value">{{ userInfo.materials['16001'] }}</span>
           </n-space>
         </n-descriptions-item>
-        <!--        <n-descriptions-item label="下次增加体力时间">-->
-        <!--          <n-space>-->
-        <!--            <span class="default_text_value">lastStamTick</span>-->
-        <!--          </n-space>-->
-        <!--        </n-descriptions-item>-->
         <n-descriptions-item label="玩家精力">
           <n-space>
-            <span class="default_text_value">{{ userInfo.energy ?? 0 }}</span>
+            <span class="default_text_value">{{ userInfo.materials['16001'] }}</span>
           </n-space>
         </n-descriptions-item>
         <n-descriptions-item label="玩家经验">
@@ -74,26 +69,16 @@
             <span class="default_text_value">{{ userInfo.userExp }}</span>
           </n-space>
         </n-descriptions-item>
-        <n-descriptions-item label="天赋点">
-          <n-space>
-            <span class="default_text_value">{{ userInfo.talentPoint }}</span>
-          </n-space>
-        </n-descriptions-item>
         <n-descriptions-item label="玩家金币">
           <n-space>
-            <span class="default_text_value">{{ userInfo.coin }}</span>
+            <span class="default_text_value">{{ userInfo.materials['3001'] }}</span>
           </n-space>
         </n-descriptions-item>
         <n-descriptions-item label="玩家钻石">
           <n-space>
-            <span class="default_text_value">{{ userInfo.diamond }}</span>
+            <span class="default_text_value">{{ userInfo.materials['3002'] }}</span>
           </n-space>
         </n-descriptions-item>
-        <!--        <n-descriptions-item label="VIP信息">-->
-        <!--          <n-space>-->
-        <!--            <span class="default_text_value">无</span>-->
-        <!--          </n-space>-->
-        <!--        </n-descriptions-item>-->
       </n-descriptions>
 
       <!-- 修改属性 -->
@@ -168,7 +153,7 @@
 
           <n-descriptions-item label="账号ID">
             <n-space>
-              <span class="default_text_value">{{ attr.accId ?? '' }}</span>
+              <span class="default_text_value">{{ userInfo.accId ?? '' }}</span>
             </n-space>
           </n-descriptions-item>
 
@@ -184,30 +169,15 @@
           </n-descriptions-item>
           <n-descriptions-item label="昵称">
             <n-space>
-              <span class="default_text_value">{{ user.nickname }}</span>
+              <span class="default_text_value">{{ userInfo.nick }}</span>
             </n-space>
           </n-descriptions-item>
-          <!--          <n-descriptions-item label="账号">-->
-          <!--            <n-space>-->
-          <!--              <span class="default_text_value">{{ user.account }}</span>-->
-          <!--            </n-space>-->
-          <!--          </n-descriptions-item>-->
-          <!--          <n-descriptions-item label="邀请人ID">-->
-          <!--            <n-space>-->
-          <!--              <span class="default_text_value">570262</span>-->
-          <!--            </n-space>-->
-          <!--          </n-descriptions-item>-->
           <n-descriptions-item label="注册时间(当前服)">
             <n-space>
               <span class="default_text_value">{{ user.createtime }}</span>
             </n-space>
           </n-descriptions-item>
 
-          <!--          <n-descriptions-item label="账号状态">-->
-          <!--            <n-space>-->
-          <!--              <span class="default_text_value">{{ user.ban }}</span>-->
-          <!--            </n-space>-->
-          <!--          </n-descriptions-item>-->
           <n-descriptions-item label="累计签到次数">
             <n-space>
               <span class="default_text_value">{{ attr.signinCount }}</span>
@@ -243,19 +213,6 @@
           </n-descriptions-item>
         </n-descriptions>
       </template>
-
-      <!--      <template #header-extra>
-        <n-space>
-          <n-button
-            strong
-            secondary
-            type="warning"
-            v-show="useUserStore.config.mode !== 'release'"
-            @click="openUpdateNickname"
-            >修改昵称
-          </n-button>
-        </n-space>
-      </template>-->
     </n-card>
 
     <!--    <n-card
@@ -581,31 +538,30 @@
   import { timestampToTime } from '@/utils/dateUtil';
   import {
     getPlayerAttr,
-    getSigninCount,
+    // getSigninCount,
     getUserAccountInfo,
     openAccount,
-    orderStatistics,
-    playerAccountBan,
+    // orderStatistics,
+    // playerAccountBan,
     updatePlayerBase,
-    playerSingleBan,
+    // playerSingleBan,
     UpdateNickname,
     CompatibilityTestVerify,
     CompatibilityTestMigrate,
-    playerPaymentSwitch,
+    // playerPaymentSwitch,
     addGift,
-    playerChatBan,
+    // playerChatBan,
   } from '@/api/account/list';
   import { useModal } from '@/components/Modal';
   import Level from '@/views/modal/Level.vue';
   import SetDanScore from './SetDanScore.vue';
-  import { UtilsTool } from '@/utils/macd/UtilsTool';
   import { addPlayerRetrofit, RetrofitGroupOptions } from '@/api/echarts/rechargeList';
   import { ArrowForwardCircleOutline as ArrowForward } from '@vicons/ionicons5';
   import { useRouter } from 'vue-router';
-  import { useUserStoreWidthOut } from '@/store/modules/user';
+  // import { useUserStoreWidthOut } from '@/store/modules/user';
   import { getServerName } from '@/utils/admin';
 
-  const useUserStore = useUserStoreWidthOut();
+  // const useUserStore = useUserStoreWidthOut();
 
   const serviceList = [
     {
@@ -626,7 +582,7 @@
     },
   ];
 
-  const [modalRegister, { openModal, closeModal }] = useModal({
+  const [modalRegister, { closeModal }] = useModal({
     title: '账号等级对照表',
   });
 
@@ -634,10 +590,6 @@
     closeModal();
   }
 
-  function showModal() {
-    openModal();
-  }
-
   const singleBan = reactive({
     ban: false,
     banReason: '',
@@ -718,26 +670,29 @@
     diamond: 0,
   });
 
-  let user = reactive({
-    openid: '',
-    nickname: '',
-    account: '',
-    createtime: '',
-    ban: '',
-  });
-
-  let attr = reactive({
-    lastlogintick: '',
-    lastlogouttick: '',
-    location: '',
-    signinCount: 0,
-    advCount: 0,
-    onlineDuration: '',
-    serverId: 0,
-    accId: 0,
-    openId: '',
-    loginCount: 0,
-  });
+  const user = ref(
+    reactive({
+      openid: '',
+      nickname: '',
+      account: '',
+      createtime: '',
+      ban: '',
+    })
+  );
+
+  const attr = ref(
+    reactive({
+      lastlogintick: '',
+      lastlogouttick: '',
+      signinCount: 0,
+      advCount: 0,
+      onlineDuration: '',
+      serverId: 0,
+      accId: 0,
+      openId: '',
+      loginCount: 0,
+    })
+  );
 
   /*const order = reactive({
     playerid: 0,
@@ -841,17 +796,17 @@
     });
   }*/
 
-  function openUpdatePlayerBase() {
-    formValue.value = {
-      stamina: 0,
-      energy: 0,
-      userExp: 0,
-      talentPoint: 0,
-      coin: 0,
-      diamond: 0,
-    };
-    showModifyBase.value = true;
-  }
+  // function openUpdatePlayerBase() {
+  //   formValue.value = {
+  //     stamina: 0,
+  //     energy: 0,
+  //     userExp: 0,
+  //     talentPoint: 0,
+  //     coin: 0,
+  //     diamond: 0,
+  //   };
+  //   showModifyBase.value = true;
+  // }
 
   function handleValidateClick(e: MouseEvent) {
     e.preventDefault();
@@ -879,7 +834,7 @@
           // 用户信息
           // user.openid = res.openid;
           // user.nickname = res.nickname;
-          user.account = res.account;
+          user.value.account = res.account;
           // user.createtime = res.createtime > 0 ? timestampToTime(res.createtime) : '';
           // user.ban = res.ban == 1 ? '禁用' : '正常';
           userBan.ban = res.ban == 1;
@@ -900,23 +855,25 @@
     new Promise((_resolve, _reject) => {
       getPlayerAttr({ playerid: props.userId })
         .then((res) => {
+          console.log('=======res:', res);
           // 属性
-          attr.lastlogintick = res.lastlogintick > 0 ? timestampToTime(res.lastlogintick) : '';
-          attr.lastlogouttick = res.lastlogouttick > 0 ? timestampToTime(res.lastlogouttick) : '';
-          if (res.location !== null && res.location !== '') {
-            attr.location = res.location.slice(0, -2);
-          }
-
-          attr.advCount = res.advCount;
-          attr.onlineDuration = res.onlineDuration;
-          attr.accId = res.accId;
-          attr.serverId = res.line;
-          attr.openId = res.openId;
-          user.nickname = res.nickName;
-          user.createtime = res.create_time > 0 ? timestampToTime(res.create_time) : '';
+          attr.value.lastlogintick =
+            res.lastlogintick > 0 ? timestampToTime(res.lastlogintick) : '';
+          attr.value.lastlogouttick =
+            res.lastlogouttick > 0 ? timestampToTime(res.lastlogouttick) : '';
+
+          attr.value.advCount = res.advCount;
+          attr.value.onlineDuration = res.onlineDuration;
+          attr.value.accId = res.accId;
+          attr.value.serverId = res.line;
+          attr.value.openId = res.openId;
+          user.value.nickname = res.nickName;
+          user.value.createtime = res.create_time > 0 ? timestampToTime(res.create_time) : '';
 
           paySwitch.pay = res.paySwitch == 1;
           paySwitch.banReason = paySwitch.pay ? paySwitch.banReason : '';
+
+          console.log('========attr:', attr.value);
         })
         .catch((error) => {
           // message.error(error.toString());
@@ -1023,10 +980,10 @@
     });
   }
 
-  function openUpdateNickname() {
-    showModalUpdateNickname.value = true;
-    formParamsUpdateNickname.value.nickname = user.nickname;
-  }
+  // function openUpdateNickname() {
+  //   showModalUpdateNickname.value = true;
+  //   formParamsUpdateNickname.value.nickname = user.nickname;
+  // }
 
   function updateNicknameConfirmForm(e) {
     e.preventDefault();
@@ -1043,7 +1000,7 @@
         UpdateNickname({ nickname: formParamsUpdateNickname.value.nickname, userId: props.userId })
           .then((_res) => {
             console.log('_res:' + JSON.stringify(_res));
-            user.nickname = formParamsUpdateNickname.value.nickname;
+            user.value.nickname = formParamsUpdateNickname.value.nickname;
             message.success('修改成功');
           })
           .catch((e: Error) => {
@@ -1088,13 +1045,13 @@
     showModalOpenAccount.value = false;
   }
 
-  function openCompatibilityTest() {
-    showModalCompatibilityTest.value = true;
-    formCompatibilityTestParams.value.nickname = null;
-    formCompatibilityTestParams.value.server = null;
-    formCompatibilityTestParams.value.has = false;
-    formCompatibilityTestParams.value.serverName = '';
-  }
+  // function openCompatibilityTest() {
+  //   showModalCompatibilityTest.value = true;
+  //   formCompatibilityTestParams.value.nickname = null;
+  //   formCompatibilityTestParams.value.server = null;
+  //   formCompatibilityTestParams.value.has = false;
+  //   formCompatibilityTestParams.value.serverName = '';
+  // }
 
   function compatibilityTestVerify() {
     if (
@@ -1157,9 +1114,10 @@
   }
 
   const showSetDanScoreModal = ref(false);
-  function openSetDanScoreModal() {
-    showSetDanScoreModal.value = true;
-  }
+
+  // function openSetDanScoreModal() {
+  //   showSetDanScoreModal.value = true;
+  // }
 
   function updateSetDanScoreModal(value) {
     showSetDanScoreModal.value = value;

+ 1 - 2
web/src/views/account/accountList/components/Chapter.vue

@@ -18,7 +18,7 @@
             ref="formRef"
             class="py-8"
           >
-            <n-form-item label="通关关卡" path="matter">
+            <n-form-item label="通关" path="matter">
               <n-select
                 placeholder="请选择要通关的关卡"
                 :options="matterList"
@@ -26,7 +26,6 @@
                 multiple
               />
             </n-form-item>
-
             <div style="margin-left: 80px">
               <n-space>
                 <n-button type="primary" @click="formSubmit">提交</n-button>

+ 1 - 1
web/src/views/account/accountList/components/SetDanScore.vue

@@ -47,7 +47,7 @@
 
   interface Props {
     showModal: boolean;
-    userId?: number;
+    userId?: number | string;
   }
 
   const props = withDefaults(defineProps<Props>(), {

+ 2 - 1
web/src/views/account/accountList/info.vue

@@ -130,7 +130,8 @@
       return;
     }
     userInfo.value = JSON.parse(data.msg);
-    refreshDate.value = timestampToTime(userInfo.value.timeStamp);
+    refreshDate.value = timestampToTime(userInfo.value.serverts);
+
     triggerRefresh();
   };
 

+ 1 - 1
web/src/views/account/accountList/userInfo.ts

@@ -4,7 +4,7 @@ export const userInfoObj = {
   diamond: 0,
   userLevel: 0,
   userExp: 0,
-  timeStamp: 0,
+  serverts: 0,
   stamina: 0,
   energy: 0,
   lastLogoutTick: 0,

+ 7 - 7
web/src/views/email/index.vue

@@ -684,9 +684,9 @@
   const allMaterials = ref<any>([]);
 
   onMounted(async () => {
-    getAllEquipments({}).then((res) => {
-      allEquipments.value = res.list;
-    });
+    // getAllEquipments({}).then((res) => {
+    //   allEquipments.value = res.list;
+    // });
 
     getAllMaterials({}).then((res) => {
       allMaterials.value = res;
@@ -745,10 +745,10 @@
   }
 
   function getItemLabel(key) {
-    const eq = allEquipments.value[key];
-    if (eq) {
-      return eq.name + ' 星级:' + eq.star;
-    }
+    // const eq = allEquipments.value[key];
+    // if (eq) {
+    //   return eq.name + ' 星级:' + eq.star;
+    // }
 
     const name = findItemNameById(key);
     if (name) {