资产明细接口

main
fengxinyhyl 10 months ago
parent e2bacc76b8
commit 7ec28298de
  1. 6
      app/common/dao/user/UserAssetsLogDao.php
  2. 2
      app/common/repositories/system/merchant/MerchantRepository.php
  3. 42
      app/common/repositories/user/UserAssetsLogRepository.php
  4. 10
      app/common/repositories/user/UserAssetsRepository.php
  5. 28
      app/controller/admin/user/User.php
  6. 4
      route/admin/user.php
  7. 9
      view/admin/src/api/marketing.js
  8. 27
      view/admin/src/router/modules/marketing.js
  9. 297
      view/admin/src/views/marketing/assets/index.vue

@ -39,7 +39,11 @@ class UserAssetsLogDao extends BaseDao
public function search(int $uid, array $where)
{
$query = UserAssetsLog::getDB()->where('uid', $uid)->where($where);
$userWhere = array();
if($uid){
$userWhere[] = array('uid', '=', $uid);
}
$query = UserAssetsLog::getDB()->where($userWhere)->where($where);
return $query;
}

@ -319,6 +319,7 @@ class MerchantRepository extends BaseRepository
$item['distance'] = $distance;
}
$item['recommend'] = isset($where['delivery_way']) ? $item['CityRecommend'] : $item['AllRecommend'];
$item['mer_phone'] = substr($item['mer_phone'], 0, 3) . '****' . substr($item['mer_phone'], -4);
return $item;
});
@ -353,6 +354,7 @@ class MerchantRepository extends BaseRepository
$merchant['care'] = false;
if ($userInfo)
$merchant['care'] = $this->getCareByUser($id, $userInfo->uid);
$merchant['mer_phone'] = substr($merchant['mer_phone'], 0, 3) . '****' . substr($merchant['mer_phone'], -4);
return $merchant;
}

@ -85,6 +85,16 @@ class UserAssetsLogRepository extends BaseRepository
);
}
public function getAssetType(){
return array(
self::ASSET_TYPE_CONSUME => '消费积分',
self::ASSET_TYPE_SHARE_POINT => '分红点',
self::ASSET_TYPE_WELFARE => '福利积分',
self::ASSET_TYPE_HUITONG => '惠通宝',
self::ASSET_TYPE_CONTRIBUTION => '贡献值',
);
}
public function getList(array $where, $page, $limit)
{
$query = $this->dao->search($where);
@ -514,14 +524,17 @@ class UserAssetsLogRepository extends BaseRepository
$welfare = $huitong = $contribution = 0;
// 1. 本人的消费积分
$logList[] = array(
'uid' => $orderItem['uid'],
'asset_type' => self::ASSET_TYPE_CONSUME,
'type' => self::CHANGE_TYPE_ORDER,
'status' => self::STATUS_FROZEN,
'order_id' => $orderItem['order_id'],
'count' => $orderItem['pay_price'],
);
if($orderItem['pay_price']){
$logList[] = array(
'uid' => $orderItem['uid'],
'asset_type' => self::ASSET_TYPE_CONSUME,
'type' => self::CHANGE_TYPE_ORDER,
'status' => self::STATUS_FROZEN,
'order_id' => $orderItem['order_id'],
'count' => $orderItem['pay_price'],
);
}
$consume = $orderItem['pay_price'];
// 如果该订单奖励基数大于0
@ -731,11 +744,22 @@ class UserAssetsLogRepository extends BaseRepository
$data = $query->page($page, $limit)->order('id desc')->select();
$list = array();
$changeType = $this->getChangeType();
$assetsType = $this->getAssetType();
$userRepository = app(UserRepository::class);
foreach ($data as $item) {
$item['type'] = $changeType[$item['type']];
$item['type'] = $changeType[$item['type']] ?? '未知';
$item['asset_type'] = $assetsType[$item['asset_type']] ?? '未知';
if($item['count'] > 0){
$item['count'] = "+".$item['count'];
}
$user = $userRepository->get($item['uid']);
if($user){
$item['user_nickname'] = $user['nickname'];
$item['user_phone'] = $user['phone'];
}else{
$item['user_nickname'] = '未知';
$item['user_phone'] = '未知';
}
$list[] = $item;
}
return compact('count', 'list');

@ -267,12 +267,18 @@ class UserAssetsRepository extends BaseRepository
throw new \Exception('用户不存在');
}
$fromUser = $userRepository->get($uid);
$logList[] = array(
'uid' => $toUser['uid'],
'asset_type' => UserAssetsLogRepository::ASSET_TYPE_HUITONG,
'type' => UserAssetsLogRepository::CHANGE_TYPE_HUITONG_GET,
'status' => UserAssetsLogRepository::STATUS_SUCCESS,
'count' => $count,
'ext' => array(
'from_uid' => $uid,
'from_phone' => $fromUser['phone'],
),
);
$logList[] = array(
'uid' => $uid,
@ -280,6 +286,10 @@ class UserAssetsRepository extends BaseRepository
'type' => UserAssetsLogRepository::CHANGE_TYPE_HUITONG_SEND,
'status' => UserAssetsLogRepository::STATUS_SUCCESS,
'count' => -1 * $count,
'ext' => array(
'to_uid' => $toUser['uid'],
'to_phone' => $toUser['phone'],
),
);
app()->make(UserAssetsLogRepository::class)->addLog($logList);
$this->dao->update($toUser['uid'], array('huitong' => $assets['huitong'] - $count));

@ -246,6 +246,34 @@ class User extends BaseController
return app('json')->success('修改成功');
}
public function assetsList(){
$page = $this->request->param('page', 1);
$limit = $this->request->param('limit', 10);
$asset_type = $this->request->param('asset_type');
$type = $this->request->param('type');
$phone = $this->request->param('phone');
$nickname = $this->request->param('nickname');
$date = $this->request->param('date');
$userWhere = array();
if($phone) $userWhere[] = array('phone','=',$phone);
if($nickname) $userWhere[] = array('nickname','=',$nickname);
$user = $this->repository->getWhere($userWhere);
$where = array();
if($asset_type)$where[] = array('asset_type','=',$asset_type);
if($type) $where[] = array('type','=',$type);
if($date){
$date = explode('-', $date);
$where[] = array('create_time','between',[date('Y-m-d', strtotime($date[0])),date('Y-m-d', strtotime($date[1]) +86400)]);
}
if($user) $where[] = array('uid','=',$user['uid']);
$where[] = array('status','in',[UserAssetsLogRepository::STATUS_FROZEN, UserAssetsLogRepository::STATUS_SUCCESS, UserAssetsLogRepository::STATUS_USED]);
return app('json')->success(app(UserAssetsLogRepository::class)->list(0, $where, $page, $limit));
}
/**
* @param UserLabelRepository $labelRepository
* @return mixed

@ -52,6 +52,10 @@ Route::group(function () {
Route::get('lst', '/lst')->name('systemUserLst')->option([
'_alias' => '用户列表',
]);
//用户资产明细
Route::get('assets_list', '/assetsList')->name('systemUserAssetsList')->option([
'_alias' => '用户资产列表',
]);
Route::get('update/form/:id', '/updateForm')->name('systemUserUpdateForm')->option([
'_alias' => '用户编辑表单',
'_auth' => false,

@ -412,6 +412,13 @@ export function updateIntegralConfig(data) {
return request.get(`discounts/lst`,data)
}
/**
* @description 资产明细 -- 列表数据
*/
export function assetsLogList(data) {
return request.get(`user/assets_list`,data)
}
/**
* @description 套餐列表 -- 显示状态上下架
*/
@ -507,4 +514,4 @@ export function updateIntegralConfig(data) {
*/
export function borderDelete(id) {
return request.delete(`activity/border/delete/${id}`)
}
}

@ -316,7 +316,7 @@ const marketingRouter =
},
component: () => import('@/views/marketing/integral/sign/index')
}
]
},
{
@ -401,9 +401,30 @@ const marketingRouter =
component: () => import('@/views/marketing/border/borderList/addBorder')
}
]
}
},
{
path: 'assets',
name: 'assets',
meta: {
title: '资产',
noCache: true
},
redirect: 'noRedirect',
component: () => import('@/views/marketing/integral/index'),
children: [
{
path: 'index',
name: `assetsIndex`,
meta: {
title: '数据明细',
noCache: true
},
component: () => import('@/views/marketing/assets/index')
}
]
}
],
}
export default marketingRouter

@ -0,0 +1,297 @@
<template>
<div class="divBox">
<el-card class="box-card">
<div slot="header" class="clearfix">
<div class="container">
<el-form size="small" inline label-width="100px">
<el-form-item label="昵称:">
<el-input
style="width: 200px"
placeholder="请输入昵称"
v-model="tableFrom.nickname"
/>
</el-form-item>
<el-form-item label="手机号:">
<el-input
style="width: 200px"
placeholder="请输入手机号"
v-model="tableFrom.phone"
/>
</el-form-item>
<el-form-item label="货币类型:" clearable>
<el-select
v-model="tableFrom.asset_type"
placeholder="请选择货币类型"
clearable
>
<el-option value="1" label="消费积分">消费积分</el-option>
<el-option value="2" label="分红点">分红点</el-option>
<el-option value="3" label="福利积分">福利积分</el-option>
<el-option value="4" label="惠通宝">惠通宝</el-option>
<el-option value="5" label="贡献值">贡献值</el-option>
</el-select>
</el-form-item>
<el-form-item label="分值来源:">
<el-select
placeholder="请选择"
v-model="tableFrom.type"
clearable
>
<el-option value="1" label="个人下单">个人下单</el-option>
<el-option value="2" label="签到">签到</el-option>
<el-option value="3" label="消费积分兑换分红点">消费积分兑换分红点</el-option>
<el-option value="4" label="分红点返佣">分红点返佣</el-option>
<el-option value="5" label="推广返佣">推广返佣</el-option>
<el-option value="6" label="培育奖">培育奖</el-option>
<el-option value="7" label="区域代理奖">区域代理奖</el-option>
<el-option value="8" label="惠通宝兑换消费积分">惠通宝兑换消费积分</el-option>
<el-option value="9" label="转让他人">转让他人</el-option>
<el-option value="10" label="他人转让">他人转让</el-option>
</el-select>
</el-form-item>
<el-form-item label="时间选择:" class="width100">
<el-date-picker
v-model="timeVal"
value-format="yyyy/MM/dd"
format="yyyy/MM/dd"
size="small"
type="daterange"
placement="bottom-end"
placeholder="自定义时间"
style="width: 250px;"
@change="onchangeTime"
/>
</el-form-item>
<el-button size="small" type="primary" icon="el-icon-search" @click="getList()">搜索</el-button>
</el-form>
</div>
</div>
<el-table v-loading="loading" :data="tableData.data" style="width: 100%" size="small">
<el-table-column label="ID" prop="id" min-width="80"/>
<el-table-column label="用户昵称" prop="user_nickname" min-width="120"/>
<el-table-column label="手机" prop="user_phone" min-width="120"/>
<el-table-column label="货币类型" prop="asset_type" min-width="120"/>
<el-table-column label="分值来源" prop="type" min-width="120"/>
<el-table-column label="变动情况" prop="count" min-width="120"/>
<el-table-column label="变动时间" prop="create_time" min-width="120" />
</el-table>
<div class="block">
<el-pagination
:page-sizes="[20, 40, 60, 80]"
:page-size="tableFrom.limit"
:current-page="tableFrom.page"
layout="total, sizes, prev, pager, next, jumper"
:total="tableData.total"
@size-change="handleSizeChange"
@current-change="pageChange"
/>
</div>
</el-card>
</div>
</template>
<script>
import { mapState } from "vuex";
import {discountsList, discountsChangeStatus, discountsGetDetails, assetsLogList} from "@/api/marketing";
import { formatDate } from "@/utils/validate";
import { roterPre } from '@/settings'
export default {
name: "Discounts",
filters: {
formatDate(time) {
if (time !== 0) {
let date = new Date(time * 1000);
return formatDate(date, "yyyy-MM-dd hh:mm");
}
},
},
data() {
return {
loading: false,
dialogLoading: false,
roterPre: roterPre,
dialogVisible: false,
tableData: {
data: [],
total: 0,
},
tableFrom: {
type: "",
nickname: "",
phone: "",
page: 1,
asset_type: "",
limit: 15,
},
specsMainData: [],
specsData: [],
timeVal: [],
formValidate: {
title: "", //
type: 0, //
image: "", //
is_time: 0, //
is_limit: 0, //1/0
limit_num: 0, //
link_ids: [], //
time: [], //
sort: 0, //
free_shipping: 1, //
status: 1,
products: [],
},
};
},
computed: {
},
created() {
this.getList('');
},
methods: {
//
handleDetail(id) {
this.dialogVisible = true;
this.dialogLoading = true;
discountsGetDetails(id).then((res) => {
this.formValidate = res.data;
this.formValidate.time = res.data.time || [];
this.dialogLoading = false;
for (let i = 0; i < res.data.discountsProduct.length; i++) {
const element = res.data.discountsProduct[i];
element.attr= [];
const attrArr = element['product'] && element['product']['attrValue'] || [];
for (let j = 0; j < attrArr.length; j++) {
const attr = attrArr[j];
if (attr.productSku) {
element.attr.push(attr)
}
}
if (element.type == 1) {
this.specsMainData.push(element);
} else {
this.specsData.push(element);
}
}
});
},
//
getList(num) {
this.loading = true;
this.tableFrom.page = num ? num : this.tableFrom.page;
assetsLogList(this.tableFrom)
.then(async (res) => {
this.tableData.data = res.data.list;
this.tableData.total = res.data.count;
this.loading = false;
})
.catch((res) => {
this.loading = false;
this.$message.error(res.message);
});
},
pageChange(page) {
this.tableFrom.page = page;
this.getList('');
},
handleSizeChange(val) {
this.tableFrom.limit = val;
this.getList('');
},
//
onchangeTime(e) {
this.timeVal = e;
this.tableFrom.date = this.timeVal ? this.timeVal.join("-") : "";
},
//
onchangeIsShow(row) {
discountsChangeStatus(row.discount_id,row.status)
.then(async (res) => {
this.$message.success(res.message);
this.getList('');
})
.catch((res) => {
this.$message.error(res.message);
this.getList('');
});
},
},
};
</script>
<style scoped lang="scss">
.tabBox_img {
width: 36px;
height: 36px;
border-radius: 4px;
cursor: pointer;
img {
width: 100%;
height: 100%;
}
}
.box-container {
overflow: hidden;
}
.box-container .list {
float: left;
line-height: 40px;
}
.box-container .sp {
width: 50%;
//white-space: nowrap;
//overflow: hidden;
//text-overflow: ellipsis;
}
.box-container .sp3 {
width: 33.3333%;
}
.box-container .sp100 {
width: 100%;
}
.box-container .list .name {
display: inline-block;
color: #606266;
}
.box-container .list .blue {
color: #1890ff;
}
.box-container .list.image {
margin: 20px 0;
position: relative;
}
.box-container .list.image img {
position: absolute;
top: -20px;
}
.labeltop{
max-height: 280px;
min-height: 120px;
overflow-y: auto;
}
.title{
margin-bottom: 16px;
color: #17233d;
font-size: 14px;
font-weight: bold;
padding-bottom: 2px;
border-bottom: 1px solid #dfe6ec;
}
.product-data {
display: flex;
align-items: center;
.image {
width: 50px !important;
height: 50px !important;
margin-right: 10px;
}
}
</style>
Loading…
Cancel
Save