Skip to content

Commit

Permalink
每日申购 (#47)
Browse files Browse the repository at this point in the history
* 增价每日申购定时任务

* 判断错误修改

* 增加刷新token 信息
  • Loading branch information
wuhbin authored Aug 6, 2023
1 parent f5f0244 commit 3085181
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ public interface IMTService {
* 刷新版本号,预约item,门店shop列表,
*/
void refreshAll();

/**
* 每日预约申购结果
*/
void appointmentResults();



}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.oddfar.campus.business.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
Expand Down Expand Up @@ -456,6 +457,40 @@ public void refreshAll() {
iShopService.refreshItem();
}

@Override
public void appointmentResults() {
logger.info("申购结果查询开始=========================");
List<IUser> iUsers = iUserService.selectReservationUser();
for (IUser iUser : iUsers) {
try {
String url = "https://app.moutai519.com.cn/xhr/front/mall/reservation/list/pageOne/query";
String body = HttpUtil.createRequest(Method.GET, url)
.header("MT-Device-ID", iUser.getDeviceId())
.header("MT-APP-Version", getMTVersion())
.header("MT-Token", iUser.getToken())
.header("User-Agent", "iOS;16.3;Apple;?unrecognized?").execute().body();
JSONObject jsonObject = JSONObject.parseObject(body);
if (jsonObject.getInteger("code") != 2000) {
String message = jsonObject.getString("message");
throw new ServiceException(message);
}
for (Object itemVOs : jsonObject.getJSONObject("data").getJSONArray("reservationItemVOS")) {
JSONObject item = JSON.parseObject(itemVOs.toString());
// 预约时间在24小时内的
if (item.getInteger("status") == 2 && DateUtil.between(item.getDate("reservationTime"), new Date(), DateUnit.HOUR) < 24) {
String logContent = DateUtil.formatDate(item.getDate("reservationTime")) + " 申购" + item.getString("itemName") + "成功";
IMTLogFactory.reservation(iUser, logContent);
}

}
} catch (Exception e) {
logger.error("查询申购结果失败:失败原因{}", e.getMessage());
}

}
logger.info("申购结果查询结束=========================");
}

public JSONObject reservation(IUser iUser, String itemId, String shopId) {
Map<String, Object> map = new HashMap<>();
JSONArray itemArray = new JSONArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ public void refresh() {
}


/**
* 18.05分获取申购结果
*/
@Async
@Scheduled(cron = "0 5 18 ? * * ")
public void appointmentResults() {
imtService.appointmentResults();
}


}
91 changes: 80 additions & 11 deletions vue_campus_admin/src/views/imt/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@
@click="handleUpdate(scope.row)"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-refresh"
@click="handleUpdateToken(scope.row)"
>
刷新token
</el-button>
<el-button
size="mini"
type="text"
Expand Down Expand Up @@ -445,9 +453,12 @@
<el-form-item label="手机号" prop="mobile">
<el-input v-model="form.mobile" placeholder="请输入I茅台用户手机号" />
<div style="margin-top: 10px">
<el-button type="primary" @click="sendCode(form.mobile)"
>发送验证码</el-button
>
<el-button
type="primary"
@click="sendCode(form.mobile)"
:disabled="state"
>发送验证码<span v-if="state">({{ stateNum }})</span>
</el-button>
</div>
</el-form-item>

Expand All @@ -462,6 +473,39 @@
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>

<el-dialog :title="title" :visible.sync="refreshToken" width="500px">
<el-form ref="form" :model="form">
<el-form-item label="手机号" prop="mobile">
<el-input
v-model="form.mobile"
readonly
placeholder="请输入I茅台用户手机号"
/>
<div style="margin-top: 10px">
<el-button
type="primary"
@click="sendCode(form.mobile, form.deviceId)"
:disabled="state"
>发送验证码<span v-if="state">({{ stateNum }})</span>
</el-button>
</div>
</el-form-item>

<el-form-item label="验证码" prop="code">
<el-input v-model="form.code" placeholder="请输入验证码"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
@click="refresh(form.mobile, form.code, form.deviceId, 1)"
>刷 新
</el-button
>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>

Expand Down Expand Up @@ -506,6 +550,10 @@ export default {
// 是否显示弹出层
open: false,
openUser: false,
refreshToken: false,
// 发送短信按钮倒计时
state: false,
stateNum: 60,
// 查询参数
queryParams: {
pageNum: 1,
Expand Down Expand Up @@ -590,6 +638,7 @@ export default {
cancel() {
this.open = false;
this.openUser = false;
this.refreshToken = false;
this.reset();
},
// 表单重置
Expand Down Expand Up @@ -706,20 +755,23 @@ export default {
});
},
//发生验证码
sendCode(mobile) {
this.form.deviceId = this.guid();
sendCode(mobile, deviceId) {
this.form.deviceId = deviceId == "" ? this.guid() : deviceId;
sendCode(mobile, this.form.deviceId).then((response) => {
this.$modal.msgSuccess("发送成功");
this.state = true;
let timer = setInterval(() => {
this.stateNum--;
if (this.stateNum === 0) {
clearInterval(timer);
this.state = false;
}
}, 1000);
});
},
//登录
login(mobile, code) {
login(mobile, code, this.form.deviceId).then((response) => {
this.$modal.msgSuccess("登录成功");
this.open = false;
this.openUser = false;
this.getList();
});
this.refresh(mobile, code, this.form.deviceId, 0)
},
/** 删除按钮操作 */
handleDelete(row) {
Expand All @@ -735,6 +787,23 @@ export default {
})
.catch(() => {});
},
refresh(mobile, code, deviceId, status) {
const msg = status ? "刷新成功" : "登录成功";
login(mobile, code, deviceId).then((response) => {
this.$modal.msgSuccess(msg);
this.open = false;
this.openUser = false;
this.getList();
});
},
handleUpdateToken(row) {
this.refreshToken = true;
this.form = {
mobile: row.mobile,
deviceId: row.deviceId,
};
this.title = "刷新用户:" + row.remark + "(" + row.mobile + ")登录信息";
},
},
};
</script>
Expand Down

0 comments on commit 3085181

Please sign in to comment.