Browse Source

这是新增消费的接口还有退款为负的修改

Hongxilin
donghaolin 5 months ago
parent
commit
888864506f
  1. 230
      vue/gold-system/src/views/consume/addConsume.vue
  2. 3
      vue/gold-system/src/views/refund/addRefund.vue

230
vue/gold-system/src/views/consume/addConsume.vue

@ -6,14 +6,19 @@ import { Plus } from "@element-plus/icons-vue";
import axios from "axios";
import { ElMessageBox } from "element-plus";
//
const addConsume = ref({});
//
//
const addConsume = ref({
freeCoin: 0,
rechargeCoin: 0,
taskCoin: 0,
updateType: "消费",
});
//
const add = async function () {
try {
// POST
const result = await axios.post(
"http://192.168.8.93:10010/recharge/recharge/add",
"http://192.168.8.147:10030/consume/add",
addConsume.value
);
@ -59,7 +64,7 @@ const checkEndTime = function (rule, value, callback) {
};
const rules = reactive({
jwcode: [{ required: true, message: "请输入精网号", trigger: "blur" }],
refundGoods: [{ required: true, message: "请选择退款商品", trigger: "blur" }],
goods: [{ required: true, message: "请选择消费商品", trigger: "blur" }],
taskCoin: [{ required: true, message: "请输入任务金币", trigger: "blur" }],
freeCoin: [{ required: true, message: "请输入免费金币", trigger: "blur" }],
rechargeCoin: [
@ -94,97 +99,70 @@ const getUser = async function (jwcode) {
}
};
//
const activity = ref([]);
const getActivity = async function () {
//
const goods = ref([]);
const getGoods = async function () {
try {
// POST
const result = await axios.post(
"http://192.168.8.93:10010/recharge/activity/select",
{}
);
const result = await axios.post("http://192.168.8.93:10020/product", {});
//
console.log("请求成功", result);
//
activity.value = result.data.data;
console.log("活动信息", activity.value);
//
goods.value = result.data.data;
console.log("allData", allData.value);
console.log("地区", area.value);
} catch (error) {
console.log("请求失败", error);
//
}
};
getActivity();
getGoods();
//
const currency = ref([]);
const getCurrency = async function () {
//
const userGold = ref({});
const getUserGold = async function (jwcode) {
try {
// POST
const result = await axios.post(
"http://192.168.8.174:10010/rates/search",
{}
"http://192.168.8.147:10070/statistics/getMess/" + jwcode
);
//
console.log("货币请求成功", result);
//
currency.value = result.data.data;
console.log("tableData", currency.value);
// UI
console.log("请求成功", result);
//
userGold.value = result.data.data;
console.log("userGold", userGold.value);
} catch (error) {
console.log("请求失败", error);
//
}
};
getCurrency();
//
const imageUrl = ref("");
function calculateCoins() {
// allGold
const originalAllGold = addConsume.value.allGold;
//
const handleAvatarSuccess = (response, uploadFile) => {
imageUrl.value = URL.createObjectURL(uploadFile.raw);
console.log("图片上传成功", response, uploadFile);
addConsume.value.rechargeVoucher =
"http://192.168.8.93:10010/upload/" + response.data;
console.log("图片名称", addConsume.value.rechargeVoucher);
};
//
const beforeAvatarUpload = (rawFile) => {
if (rawFile.type !== "image/jpeg") {
ElMessage.error("Avatar picture must be JPG format!");
return false;
} else if (rawFile.size / 1024 / 1024 > 2) {
ElMessage.error("Avatar picture size can not exceed 2MB!");
return false;
}
return true;
};
// todayTasktodayFree
const todayTask =
typeof userGold.value.todayTask === "number" ? userGold.value.todayTask : 0;
const todayFree =
typeof userGold.value.todayFree === "number" ? userGold.value.todayFree : 0;
//
const options = [
{
value: "现金充值",
label: "现金充值",
},
{
value: "龙鳞卡",
label: "龙鳞卡",
},
{
value: "弘粉卡",
label: "弘粉卡",
},
];
//
addConsume.value.taskCoin = Math.min(originalAllGold, todayTask);
let remainingGold = originalAllGold - addConsume.value.taskCoin;
const calculatedFreeGold = computed(() => {
return addConsume.value.paidGold * addConsume.value.activityId;
});
addConsume.value.freeCoin = Math.min(remainingGold, todayFree);
remainingGold -= addConsume.value.freeCoin;
watch(calculatedFreeGold, (newVal) => {
addConsume.value.freeGold = newVal;
});
addConsume.value.rechargeCoin = remainingGold; //
// allGold
addConsume.value.allGold = originalAllGold;
// taskCoin, freeCoin, rechargeCoinNaN0
if (isNaN(addConsume.value.taskCoin)) addConsume.value.taskCoin = 0;
if (isNaN(addConsume.value.freeCoin)) addConsume.value.freeCoin = 0;
if (isNaN(addConsume.value.rechargeCoin)) addConsume.value.rechargeCoin = 0;
console.log("计算结果", addConsume.value);
}
</script>
<template>
@ -196,9 +174,14 @@ watch(calculatedFreeGold, (newVal) => {
:rules="rules"
label-width="auto"
style="max-width: 750px"
class="form-style"
>
<el-form-item prop="jwcode" label="精网号">
<el-input v-model="addConsume.jwcode" style="width: 220px" />
<el-input
v-model="addConsume.jwcode"
style="width: 220px"
@change="getUserGold(addConsume.jwcode)"
/>
<el-button
type="primary"
@click="getUser(addConsume.jwcode)"
@ -208,53 +191,59 @@ watch(calculatedFreeGold, (newVal) => {
</el-form-item>
<el-form-item prop="goods" label="商品名称">
<el-select
v-model="addConsume.goods"
v-model="addConsume.productId"
placeholder="请选择"
style="width: 300px"
>
<el-option
v-for="item in activity"
v-for="item in goods"
:key="item.value"
:label="item.activityName"
:value="item.rechargeRatio"
:label="item.name"
:value="item.productId"
/>
</el-select>
</el-form-item>
<el-form-item prop="allGold" label="消费金币总数">
<el-input v-model="addConsume.paidGold" style="width: 100px" />
</el-form-item>
<el-form-item prop="taskCoin" label="任务金币" style="float: left">
<el-input
disabled
v-model="addConsume.taskCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="freeCoin"
label="免费金币"
style="float: left; margin-left: -10px; margin-right: -10px"
>
<el-input
disabled
v-model="addConsume.freeCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="rechargeCoin"
label="充值金币"
style="margin-left: -20px"
>
<el-input
disabled
v-model="addConsume.rechargeCoin"
style="width: 100px; margin-left: -5px"
v-model="addConsume.allGold"
style="width: 100px"
@change="calculateCoins()"
/>
<p style="margin-right: 20px"></p>
</el-form-item>
<div style="display: flex; align-items: center">
<el-form-item prop="taskCoin" label="任务金币" style="float: left">
<el-input
disabled
v-model="addConsume.taskCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="freeCoin"
label="免费金币"
style="float: left; margin-left: -20px"
>
<el-input
disabled
v-model="addConsume.freeCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="rechargeCoin"
label="充值金币"
style="margin-left: -20px"
>
<el-input
disabled
v-model="addConsume.rechargeCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 20px"></p>
</el-form-item>
</div>
<el-form-item prop="remark" label="备注">
<el-input
v-model="addConsume.remark"
@ -273,17 +262,14 @@ watch(calculatedFreeGold, (newVal) => {
placeholder="提交人姓名"
/>
</el-form-item>
<el-button @click="closeAddActivityVisible" style="margin-left: 280px"
>取消</el-button
>
<el-button type="primary" @click="addBefore"> 提交 </el-button>
</el-form>
<el-button @click="closeAddActivityVisible" style="margin-left: 280px"
>取消</el-button
>
<el-button type="primary" @click="addBefore"> 提交 </el-button>
<!-- 客户信息栏 -->
<el-card
style="width: 700px; float: right; margin-top: -330px; margin-right: 100px"
>
<el-card style="width: 700px; float: right" class="form-style2">
<el-form
:model="user"
label-width="auto"
@ -368,4 +354,12 @@ p {
height: 50px;
text-align: center;
}
.form-style {
margin-top: 50px;
max-width: 50%;
float: left;
}
.form-style2 {
max-width: 50%;
}
</style>

3
vue/gold-system/src/views/refund/addRefund.vue

@ -40,6 +40,9 @@ const addBefore = () => {
if (valid) {
ElMessageBox.confirm("确认添加?")
.then(() => {
addRefund.value.freeCoin = Number(-addRefund.value.freeCoin);
addRefund.value.rechargeCoin = Number(-addRefund.value.rechargeCoin);
addRefund.value.taskCoin = Number(-addRefund.value.taskCoin);
add();
console.log("添加成功");
addRefund.value = {};

Loading…
Cancel
Save