Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用户管理页:主动查询用户的小茅运&体力值,兼容多选和单个查询 #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,13 @@ public R edit(@RequestBody IUser iUser) {
public R remove(@PathVariable Long[] mobiles) {
return R.ok(iUserMapper.deleteIUser(mobiles));
}

/**
* 实时获取I茅台用户的小茅运&体力值
*/
@PreAuthorize("@ss.resourceAuth()")
@GetMapping(value = "/coin/{mobiles}", name = "获取I茅台用户详细信息")
public R getUserCoin(@PathVariable Long[] mobiles) {
return R.ok(imtService.getUserCoin(mobiles));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.oddfar.campus.business.domain;

import com.oddfar.campus.business.entity.IUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class UserCoinInfo extends IUser {
private Float xmyNum;
private Integer energy;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.oddfar.campus.business.service;

import com.oddfar.campus.business.domain.UserCoinInfo;
import com.oddfar.campus.business.entity.IUser;

import java.util.List;

public interface IMTService {
/**
* 获取i茅台app版本号
Expand Down Expand Up @@ -77,5 +80,9 @@ public interface IMTService {
*/
void appointmentResults();

/**
* 获取I茅台用户的小茅运&体力值
*/
List<UserCoinInfo> getUserCoin(Long[] mobiles);

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.oddfar.campus.business.domain.UserCoinInfo;
import com.oddfar.campus.business.entity.IUser;
import com.oddfar.campus.business.mapper.IUserMapper;
import com.oddfar.campus.business.service.IMTLogFactory;
Expand All @@ -24,6 +25,7 @@
import com.oddfar.campus.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
Expand All @@ -32,6 +34,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand All @@ -40,6 +43,7 @@
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@Service
public class IMTServiceImpl implements IMTService {
Expand Down Expand Up @@ -550,6 +554,40 @@ public void appointmentResults() {
logger.info("申购结果查询结束=========================");
}

@Override
public List<UserCoinInfo> getUserCoin(Long[] mobiles) {
List<IUser> iUsers = iUserMapper.selectBatchIds(Arrays.asList(mobiles));
return iUsers.parallelStream().map(this::getUserCoin).collect(Collectors.toList());
}

private UserCoinInfo getUserCoin(IUser iUser){
UserCoinInfo userCoinInfo = new UserCoinInfo();
BeanUtils.copyProperties(iUser, userCoinInfo);
long timestamp = System.currentTimeMillis();
// 获取I茅台用户的小茅运&体力值
String url = "https://h5.moutai519.com.cn/game/userinfo/getUserCoin?csrf_token&__timestamp="+timestamp;
HttpRequest request = HttpUtil.createRequest(Method.GET, url);
try{
request.header("MT-Device-ID", iUser.getDeviceId())
.header("MT-APP-Version", getMTVersion())
.header("User-Agent", "iOS;16.3;Apple;?unrecognized?")
.cookie("MT-Token-Wap=" + iUser.getCookie() + ";MT-Device-ID-Wap=" + iUser.getDeviceId() + ";");
String body = request.execute().body();
JSONObject jsonObject = JSONObject.parseObject(body);
if (jsonObject.getInteger("code") != 2000) {
String message = jsonObject.getString("message");
throw new ServiceException(message);
}
JSONObject data = jsonObject.getJSONObject("data");
userCoinInfo.setXmyNum(data.getFloat("xmyNum"));
userCoinInfo.setEnergy(data.getInteger("energy"));
}catch (Exception e){
logger.error("获取I茅台用户的小茅运&体力值失败:user->{},失败原因->{}",iUser.getMobile(), e.getMessage());
}
return userCoinInfo;
}


public JSONObject reservation(IUser iUser, String itemId, String shopId) {
Map<String, Object> map = new HashMap<>();
JSONArray itemArray = new JSONArray();
Expand Down
8 changes: 8 additions & 0 deletions vue_campus_admin/src/api/imt/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ export function delUser(mobile) {
method: 'delete'
})
}

// 删除I茅台用户
export function getUserCoin(mobile) {
return request({
url: '/imt/user/coin/' + mobile,
method: 'get'
})
}
36 changes: 36 additions & 0 deletions vue_campus_admin/src/components/UserCoin/Query.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<el-dialog title="小茅运&体力值" :visible.sync="dialogVisible" width="500px">
<el-table :data="userCoinInfoList" style="width: 100%" :max-height="600" stripe :close-on-click-modal="false">
<el-table-column prop="mobile" label="手机号" width="140" />
<el-table-column prop="xmyNum" label="小茅运" width="100" />
<el-table-column prop="energy" label="体力值" width="100" />
<el-table-column prop="remark" label="备注" />
</el-table>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dialogVisible = false;" style="width: 100%;">确 定</el-button>
</span>
</el-dialog>
</template>

<script>
import * as imtUserService from "@/api/imt/user";
export default {
data() {
return {
dialogVisible: false,
userCoinInfoList: []
};
},
methods: {
/** 查询用户小茅运&体力值 */
queryUserCoin(mobiles) {
imtUserService.getUserCoin(mobiles).then(response => {
this.userCoinInfoList = response?.data || []
this.dialogVisible = true
})
},
},
};
</script>

<style lang="scss" scoped></style>
33 changes: 30 additions & 3 deletions vue_campus_admin/src/views/imt/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,18 @@
</el-button
>
</el-col>

<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-magic-stick"
size="mini"
:disabled="multiple"
@click="queryUserCoin"
>查询用户小茅运&体力值
</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
Expand Down Expand Up @@ -283,8 +294,14 @@
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除
</el-button
>
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-magic-stick"
@click="queryUserCoin(scope.row)"
>查小茅运&体力值
</el-button>
</template>
</el-table-column>
</el-table>
Expand Down Expand Up @@ -518,6 +535,7 @@
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<UserCoinQuery ref="userCoinQuery"/>
</div>
</template>

Expand All @@ -535,10 +553,14 @@ import {
} from "@/api/imt/user";

import {listItem} from "@/api/imt/item";
import UserCoinQuery from "@/components/UserCoin/Query.vue";

export default {
name: "User",
dicts: ["sys_normal_disable"],
components: {
UserCoinQuery,
},
data() {
return {
// 遮罩层
Expand Down Expand Up @@ -803,6 +825,11 @@ export default {
.catch(() => {
});
},
/** 查询用户小茅运&体力值 */
queryUserCoin(row) {
const mobiles = row.mobile || this.ids;
this.$refs.userCoinQuery.queryUserCoin(mobiles)
},
refresh(mobile, code, deviceId, status) {
const msg = status ? "刷新成功" : "登录成功";
login(mobile, code, deviceId).then((response) => {
Expand Down