测试和后台优化

main
ztt 1 year ago
parent 4cd2ff17e8
commit 94e1f5a7b4
  1. 16
      addons/shopro/controller/Category.php
  2. 3
      addons/shopro/controller/Pay.php
  3. 29
      addons/shopro/controller/commission/Agent.php
  4. 4
      addons/shopro/controller/user/User.php
  5. 18
      addons/shopro/service/CommissionScoreLog.php
  6. 3
      addons/shopro/service/pay/PayOper.php
  7. 46
      application/admin/controller/shopro/Category.php
  8. 42
      application/admin/controller/shopro/Coupon.php
  9. 55
      application/admin/controller/shopro/user/User.php
  10. 4
      application/admin/model/shopro/Coupon.php
  11. 166
      application/admin/view/shopro/category/add.html
  12. 203
      application/admin/view/shopro/coupon/add.html
  13. 78
      application/admin/view/shopro/coupon/index.html
  14. 20
      application/admin/view/shopro/goods/goods/add.html
  15. 50
      application/admin/view/shopro/user/user/detail.html
  16. 27
      application/admin/view/shopro/user/user/index.html
  17. 20
      application/admin/view/shopro/user/user/my_team.html
  18. 20
      public/assets/js/backend/shopro/coupon.js
  19. 14
      public/assets/js/backend/shopro/goods/goods.js
  20. 8
      public/assets/js/backend/shopro/user/user.js

@ -36,16 +36,18 @@ class Category extends Common
*/
public function goodsList() {
$category = CategoryModel::where('parent_id', 0)->normal()->order('weigh', 'desc')->order('id', 'desc')->select();
$category_ids = [];
foreach ($category as $item) {
$categories = CategoryModel::where('parent_id', $item['id'])->column('id');
$category_ids = array_merge($category_ids, $categories);
}
$category = CategoryModel::where('id', 'in', $category_ids)->normal()->order('weigh', 'desc')->order('id', 'desc')->select();
// $category_ids = [];
// foreach ($category as $item) {
// $categories = CategoryModel::where('parent_id', $item['id'])->column('id');
// $category_ids = array_merge($category_ids, $categories);
// }
// $category = CategoryModel::where('id', 'in', $category_ids)->normal()->order('weigh', 'desc')->order('id', 'desc')->select();
foreach ($category as &$row) {
$row['image'] = formatImage($row['image']);
$row['goods_list'] = Goods::where('category_ids', 'in', $row['id'])->show()->select();
$row['goods_list'] = Goods::
whereOrRaw("find_in_set({$row['id']}, category_ids)")
->show()->select();
foreach ($row['goods_list'] as $v) {
$v->image = formatImage($v->image);
$v->images = array_map('formatImage', $v->images);

@ -121,7 +121,8 @@ class Pay extends Common
$order = Db::transaction(function () use ($payOper, $order, $order_type) {
// 加锁读订单
$order = $order->lock(true)->find($order->id);
Log::info(json_encode($order_type, true));
Log::info('订单信息'.json_encode($order, true));
$order = $payOper->score($order, $order->remain_pay_fee, $order_type);
return $order;

@ -164,13 +164,15 @@ class Agent extends Commission
$son_total = UserModel::where('parent_user_id', $user_id)->count('id');
$list = UserModel::with('agent.levelInfo')->where('parent_user_id', $user_id)->select();
$count = 0;
$result = [
'team_total' => $this->runNextUserCount($this->getParent($user_id)),
'team_total' => $this->runNextUserCount($this->getParent($user_id),$count),
'son_total' => $son_total,
'list' => $list
];
$count = 0;
foreach ($list as &$item) {
$item['nextUserCount'] = $this->runNextUserCount2($this->getParent($item['id']));
$item['nextUserCount'] = $this->runNextUserCount($this->getParent($item['id']), $count);
}
$this->success('success', $result);
@ -235,29 +237,16 @@ class Agent extends Commission
* @param int $pid
* @return mixed
*/
public function runNextUserCount($user) {
static $count = 0;
if (count($user) > 0) {
$count += count($user);
}
foreach ($user as $item) {
$nexUserData = $this->getParent($item['id']);
if (is_array($nexUserData)) {
$this->runNextUserCount($nexUserData);
}
}
return $count;
}
public function runNextUserCount2($user) {
$count = 0;
public function runNextUserCount($user, &$count)
{
// static $count = 0;
if (count($user) > 0) {
$count += count($user);
}
foreach ($user as $item) {
foreach ($user as $item) {
$nexUserData = $this->getParent($item['id']);
if (is_array($nexUserData)) {
$this->runNextUserCount($nexUserData);
$this->runNextUserCount($nexUserData, $count);
}
}
return $count;

@ -78,7 +78,7 @@ class User extends Common
//TODO @ldh: 1.账号被禁用 2.连表查group
$user = auth_user(true);
$user = UserModel::with(['parent_user', 'third_oauth'])->where('id', $user->id)->find();
$user = UserModel::with(['parent_user', 'third_oauth', 'agent.level_info'])->where('id', $user->id)->find();
$user->hidden(['password', 'salt', 'createtime', 'updatetime', 'deletetime', 'remember_token', 'login_fail', 'login_ip', 'login_time']);
@ -145,7 +145,7 @@ class User extends Common
if ($user->status != 'normal') {
$this->error(__('Account is locked'));
}
//登录注册根据注册码绑定上级
if (!empty($params['user_code'])) {
$parent_user_id = UserModel::where('user_code', $params['user_code'])->value('id');

@ -127,6 +127,7 @@ class CommissionScoreLog
$parentAgent = new Agent($parentUserId);
$parentLevel = $this->getAgentLevel($parentAgent);
$parent_level_price = $this->getGoodPriceByLevel($order->goods_id, $parentLevel);
$current_level_price = $this->getGoodPriceByLevel($order->goods_id, $currentAgent);
$crrentLevel = $this->getAgentLevel($currentAgent);
//只有上级分销等级 比自己高才算佣金
if ($parentLevel > $initLevel) {
@ -134,14 +135,21 @@ class CommissionScoreLog
if ($parentLevel == self::LEVEL_2) {
return true;
}
//2.向上反佣金
$amount = bcsub($order->pay_fee, $parent_level_price, 2);
if ($parentLevel == self::LEVEL_5 && $crrentLevel == self::LEVEL_5) {//用户的上上级是高级 算团队2%
$amount = bcmul($amount, '0.02', 2);
if ($parentLevel > $crrentLevel) {
$amount = bcsub($current_level_price, $parent_level_price, 2);
}
//3.用户的上上级是高级 算团队2%
if ($parentLevel == self::LEVEL_5 && $crrentLevel == self::LEVEL_5) {
$amount = bcmul($order->pay_fee, '0.02', 2);
}
//算积分
Wallet::change($parentAgent->user->id, 'score', $amount, 'team_order', [], '团队下单');
if (!empty($amount) && $amount> 0) {
//算积分
Wallet::change($parentAgent->user->id, 'score', $amount, 'team_order', [], '团队下单');
}
}
$this->userBackScorePlan($order, $parentAgent, $currentCommissionLevel, $initLevel);

@ -124,7 +124,8 @@ class PayOper
public function score($order, $score, $order_type = 'order')
{
if ($order_type == 'order') {
if ($order['type'] == 'score') {
// if ($order['type'] == 'score') {
if (in_array($order['type'], ['score', 'goods'])) {
$log_type = 'score_shop_pay';
$real_fee = $score; // 积分商城真实抵扣,就是积分
} else {

@ -130,18 +130,20 @@ class Category extends Common
$this->error(__('Parameter %s can not be empty', 'id'));
}
$list = $this->model->with('children')->where('id', 'in', $id)->select();
$result = Db::transaction(function () use ($list) {
$count = 0;
foreach ($list as $item) {
if ($item->children) {
$this->error('请先删除子分类');
}
$count += $item->delete();
}
return $count;
});
// $list = $this->model->with('children')->where('id', 'in', $id)->select();
// $result = Db::transaction(function () use ($list) {
// $count = 0;
// foreach ($list as $item) {
// if ($item->children) {
// $this->error('请先删除子分类');
// }
// $count += $item->delete();
// }
//
// return $count;
// });
$this->model->where('parent_id', 'in', $id)->delete();
$result = $this->model->where('id', 'in', $id)->delete();
if ($result) {
$this->success('删除成功', null, $result);
@ -162,11 +164,21 @@ class Category extends Common
return $this->view->fetch();
}
$categories = (new Tree(function () {
// 组装搜索条件,排序等
return $this->model->field("id, name, parent_id, status, weigh")->normal()
->order('weigh', 'desc')->order('id', 'asc');
}))->getTree(0);
// $categories = (new Tree(function () {
// // 组装搜索条件,排序等
// return $this->model->field("id, name, parent_id, status, weigh")->normal()
// ->order('weigh', 'desc')->order('id', 'asc');
// }))->getTree(0);
$categories = Db::name('shopro_category')->field("id, name, parent_id, status, weigh")
->where('parent_id', 0)
->where('status', 'normal')
->order('weigh', 'desc')
->order('id', 'asc')
->select();
foreach ($categories as &$item) {
$item['children'][0] = $item;
}
$this->success('获取成功', null, $categories);
}

@ -2,6 +2,7 @@
namespace app\admin\controller\shopro;
use app\admin\model\shopro\goods\Goods;
use think\Db;
use app\admin\model\shopro\Coupon as CouponModel;
use app\admin\model\shopro\user\Coupon as UserCouponModel;
@ -78,7 +79,7 @@ class Coupon extends Common
'use_time_type', 'use_time', 'start_days', 'days',
'is_double_discount', 'description', 'status'
]);
$this->svalidate($params, ".add");
// $this->svalidate($params, ".add");
// 时间转换
$getTime = explode(' - ', $params['get_time']);
@ -89,6 +90,11 @@ class Coupon extends Common
$params['use_start_time'] = $useTime[0] ?? 0;
$params['use_end_time'] = $useTime[1] ?? 0;
$params = $this->initCouponData($params);
// dd($params);
if (empty($params['items'])) {
$this->error('请绑定商品!');
}
$this->model->save($params);
$this->success('保存成功');
@ -132,7 +138,7 @@ class Coupon extends Common
'use_time_type', 'use_time', 'start_days', 'days',
'is_double_discount', 'description', 'status'
]);
$this->svalidate($params);
// $this->svalidate($params);
// 时间转换
if (isset($params['get_time'])) {
@ -156,10 +162,42 @@ class Coupon extends Common
$this->error(__('No Results were found'));
}
if (empty($params['items'])) {
$this->error('请绑定商品!');
}
$params = $this->initCouponData($params);
$coupon->save($params);
$this->success('更新成功');
}
/**
* 初始化商品数据
* 时间设置有效期一年
*/
public function initCouponData($params) {
$amount = Goods::whereIn('id', $params['items'])->value('price');
$start_time = time();
$end_time = strtotime('+1 year', time());
$data = [
'name' => $params['name'] ?? '',
'description' => $params['description'] ?? '',
'get_start_time' => $start_time,
'get_end_time' => $end_time,
'use_start_time' => $params['use_start_time'],
'use_end_time' => $params['use_end_time'],
'limit_num' => 1,
'items'=> $params['items'],
'stock' => 10000,
'use_time_type' => 'range',
'days' => 365,
'type' => 'reduce',
'amount' => $amount,//优惠券面值金额
'enough' => 0,//消费门槛
];
return $data;
}
/**

@ -2,6 +2,8 @@
namespace app\admin\controller\shopro\user;
use app\admin\model\shopro\commission\Agent;
use app\admin\model\shopro\commission\Level;
use think\Db;
use app\admin\controller\shopro\Common;
use addons\shopro\service\Wallet as WalletService;
@ -31,9 +33,62 @@ class User extends Common
$data = $this->model->sheepFilter()->paginate($this->request->param('list_rows', 10));
foreach ($data as $key=>$row) {
$user_info = UserModel::with(['agent.level_info'])->find()->toArray();
// dd($user_info);
$agent = Agent::with('level_info')->where('user_id', $row['id'])->find();
if (!empty($agent)) {
$row['user_level'] = $agent['level_info']['name'];
}
$count = 0;
$row['nextUserCount'] = $this->getNextTeamCount($this->getParent($row['id']), $count);;
}
$this->success('获取成功', null, $data);
}
public function myTeam($id) {
if (!$this->request->isAjax()) {
return $this->view->fetch();
}
$list = $this->getParent($id);
$this->success('success', $list);
}
public function getNexTeamCountDetail($user) {
static $count = 0;
if (count($user) > 0) {
$count += count($user);
}
foreach ($user as $item) {
$nexUserData = $this->getParent($item['id']);
if (is_array($nexUserData)) {
$this->getNexTeamCountDetail($nexUserData);
}
}
return $count;
}
public function getNextTeamCount($user, &$count) {
if (count($user) > 0) {
$count += count($user);
}
foreach ($user as $item) {
$nexUserData = $this->getParent($item['id']);
if (is_array($nexUserData)) {
$this->getNextTeamCount($nexUserData, $count);
}
}
return $count;
}
public function getParent($user_id) {
return UserModel::where('parent_user_id', $user_id)->select();
}
/**
* 用户详情
*

@ -18,8 +18,8 @@ class Coupon extends Common
protected $type = [
'get_start_time' => 'timestamp',
'get_end_time' => 'timestamp',
// 'use_start_time' => 'timestamp',
// 'use_end_time' => 'timestamp',
// 'use_start_time' => 'timestamp',
// 'use_end_time' => 'timestamp',
];
// 追加属性

@ -171,89 +171,89 @@
<el-input class="sa-w-360" v-model="form.model.weigh" type="number" :min="0"
placeholder="请输入分类权重"></el-input>
</el-form-item>
<div class="title sa-flex sa-row-between">
<div>分类数据</div>
<el-button v-if="state.level" type="primary" link @click="onAdd">+ 插入一级分类</el-button>
</div>
<div class="template-wrap">
<div class="template-header sa-flex">
<div v-if="state.type == 'edit'" class="template-item id"> ID </div>
<div class="template-item input">分类名称</div>
<div class="template-item image sa-flex sa-row-center"> 分类图片 </div>
<div class="template-item description">描述</div>
<div class="template-item weigh">
<el-popover placement="bottom" title="" width="120" trigger="hover">
<template #reference> 排序 </template>
<div class="popover-container">
权重以倒序排列,默认值为0,相同权重则以ID优先
</div>
</el-popover>
</div>
<div class="template-item oper">操作</div>
</div>
<div class="sa-flex">
<el-tree :data="state.treeData" node-key="id" default-expand-all
:expand-on-click-node="false" :props="defaultProps" :indent="0">
<template #default="{ node, data }">
<div v-if="!(data.deleted && data.deleted == 1)" class="sa-flex">
<div v-if="state.type == 'edit'" class="template-item id">
<span
v-if="(data.id + '').indexOf('add') == -1 && (data.id + '').substring(0, 3) !== 'new'">{{
data.id }}</span>
</div>
<div class="template-item input sa-flex"
:style="{'padding-left':`${node.level*16}px`}">
<div class="expanded-icon sa-flex">
<div v-if="data.children && data.children.length > 0">
<el-icon v-if="node.expanded"
@click="node.expanded = !node.expanded">
<semi-select />
</el-icon>
<el-icon v-if="!node.expanded"
@click="node.expanded = !node.expanded">
<plus />
</el-icon>
</div>
</div>
<div style="margin-left: 16px">
<el-input v-model="data.name" placeholder="请输入分类名称" />
</div>
<el-button v-if="node.level == 1 && state.level != 1" class="append-title"
type="primary" link @click="onAppend(data)">
+ 插入二级分类
</el-button>
<el-button v-if="node.level == 2 && state.level == 3" class="append-title"
type="primary" link @click="onAppend(data)">
+ 插入三级分类
</el-button>
</div>
<div class="template-item image sa-flex sa-row-center">
<el-popover popper-class="sa-popper" trigger="hover"
content="建议尺寸:缩略图150X150">
<template #reference>
<sa-uploader v-model="data.image" size="32">
</sa-uploader>
</template>
</el-popover>
</div>
<div class="template-item description">
<el-input v-model="data.description" placeholder="请输入分类描述" />
</div>
<div class="template-item weigh">
<el-input v-model="data.weigh" type="number" :min="0" placeholder="请输入排序" />
</div>
<div class="template-item oper">
<el-button :type="data.status == 'normal'?'info':'success'" link
@click="data.status == 'normal'?data.status = 'hidden':data.status = 'normal'">
{{data.status == 'normal'?'隐藏':'显示'}}
</el-button>
<el-button type="danger" link @click="onRemove(node, data)">删除</el-button>
</div>
</div>
</template>
</el-tree>
</div>
</div>
<!-- <div class="title sa-flex sa-row-between">-->
<!-- <div>分类数据</div>-->
<!-- <el-button v-if="state.level" type="primary" link @click="onAdd">+ 插入一级分类</el-button>-->
<!-- </div>-->
<!-- <div class="template-wrap">-->
<!-- <div class="template-header sa-flex">-->
<!-- <div v-if="state.type == 'edit'" class="template-item id"> ID </div>-->
<!-- <div class="template-item input">分类名称</div>-->
<!-- <div class="template-item image sa-flex sa-row-center"> 分类图片 </div>-->
<!-- <div class="template-item description">描述</div>-->
<!-- <div class="template-item weigh">-->
<!-- <el-popover placement="bottom" title="" width="120" trigger="hover">-->
<!-- <template #reference> 排序 </template>-->
<!-- <div class="popover-container">-->
<!-- 权重以倒序排列,默认值为0,相同权重则以ID优先-->
<!-- </div>-->
<!-- </el-popover>-->
<!-- </div>-->
<!-- <div class="template-item oper">操作</div>-->
<!-- </div>-->
<!-- <div class="sa-flex">-->
<!-- <el-tree :data="state.treeData" node-key="id" default-expand-all-->
<!-- :expand-on-click-node="false" :props="defaultProps" :indent="0">-->
<!-- <template #default="{ node, data }">-->
<!-- <div v-if="!(data.deleted && data.deleted == 1)" class="sa-flex">-->
<!-- <div v-if="state.type == 'edit'" class="template-item id">-->
<!-- <span-->
<!-- v-if="(data.id + '').indexOf('add') == -1 && (data.id + '').substring(0, 3) !== 'new'">{{-->
<!-- data.id }}</span>-->
<!-- </div>-->
<!-- <div class="template-item input sa-flex"-->
<!-- :style="{'padding-left':`${node.level*16}px`}">-->
<!-- <div class="expanded-icon sa-flex">-->
<!-- <div v-if="data.children && data.children.length > 0">-->
<!-- <el-icon v-if="node.expanded"-->
<!-- @click="node.expanded = !node.expanded">-->
<!-- <semi-select />-->
<!-- </el-icon>-->
<!-- <el-icon v-if="!node.expanded"-->
<!-- @click="node.expanded = !node.expanded">-->
<!-- <plus />-->
<!-- </el-icon>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div style="margin-left: 16px">-->
<!-- <el-input v-model="data.name" placeholder="请输入分类名称" />-->
<!-- </div>-->
<!-- <el-button v-if="node.level == 1 && state.level != 1" class="append-title"-->
<!-- type="primary" link @click="onAppend(data)">-->
<!-- + 插入二级分类-->
<!-- </el-button>-->
<!-- <el-button v-if="node.level == 2 && state.level == 3" class="append-title"-->
<!-- type="primary" link @click="onAppend(data)">-->
<!-- + 插入三级分类-->
<!-- </el-button>-->
<!-- </div>-->
<!-- <div class="template-item image sa-flex sa-row-center">-->
<!-- <el-popover popper-class="sa-popper" trigger="hover"-->
<!-- content="建议尺寸:缩略图150X150">-->
<!-- <template #reference>-->
<!-- <sa-uploader v-model="data.image" size="32">-->
<!-- </sa-uploader>-->
<!-- </template>-->
<!-- </el-popover>-->
<!-- </div>-->
<!-- <div class="template-item description">-->
<!-- <el-input v-model="data.description" placeholder="请输入分类描述" />-->
<!-- </div>-->
<!-- <div class="template-item weigh">-->
<!-- <el-input v-model="data.weigh" type="number" :min="0" placeholder="请输入排序" />-->
<!-- </div>-->
<!-- <div class="template-item oper">-->
<!-- <el-button :type="data.status == 'normal'?'info':'success'" link-->
<!-- @click="data.status == 'normal'?data.status = 'hidden':data.status = 'normal'">-->
<!-- {{data.status == 'normal'?'隐藏':'显示'}}-->
<!-- </el-button>-->
<!-- <el-button type="danger" link @click="onRemove(node, data)">删除</el-button>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-tree>-->
<!-- </div>-->
<!-- </div>-->
</el-form>
</el-scrollbar>
</el-main>

@ -33,81 +33,81 @@
<el-form-item label="名称备注" prop="description">
<el-input class="sa-w-360" v-model="form.model.description" placeholder="请输入名称备注"></el-input>
</el-form-item>
<el-form-item label="券类型" prop="type">
<el-radio-group v-model="form.model.type" :disabled="state.type == 'edit'">
<el-radio label="reduce">满减券</el-radio>
<el-radio label="discount">折扣券</el-radio>
</el-radio-group>
</el-form-item>
<div class="el-form-item-inner">
<el-form-item>
<el-form-item label="消费满" prop="enough">
<el-input class="w-120" type="number" v-model="form.model.enough" :min="0"
:disabled="state.type == 'edit'">
<template #append></template>
</el-input>
</el-form-item>
<el-form-item v-if="form.model.type == 'reduce'" class="is-no-asterisk ml-2" label="立减"
prop="amount">
<el-input class="w-120" type="number" v-model="form.model.amount" :min="0"
:disabled="state.type == 'edit'">
<template #append></template>
</el-input>
</el-form-item>
<el-form-item v-if="form.model.type == 'discount'" class="is-no-asterisk ml-2" label="打"
prop="amount">
<el-input class="w-120" type="number" v-model="form.model.amount" :min="0" :max="10"
:disabled="state.type == 'edit'">
<template #append></template>
</el-input>
</el-form-item>
</el-form-item>
<el-form-item v-if="form.model.type == 'discount'">
<el-form-item label="最多优惠" prop="max_amount">
<el-input class="w-120" type="number" v-model="form.model.max_amount" :min="0"
:disabled="state.type == 'edit'">
<template #append></template>
</el-input>
</el-form-item>
</el-form-item>
</div>
<el-form-item label="发券总量" prop="stock">
<el-input class="w-120" type="number" v-model="form.model.stock" :min="0">
<template #append></template>
</el-input>
</el-form-item>
<el-form-item label="每人限领次数">
<el-input class="w-120" type="number" v-model="form.model.limit_num" :min="0">
<template #append></template>
</el-input>
</el-form-item>
<el-form-item label="领券时间" prop="get_time">
<el-date-picker v-model="form.model.get_time" type="datetimerange"
value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" prefix-icon="Calendar"
:editable="false"></el-date-picker>
</el-form-item>
<!-- <el-form-item label="券类型" prop="type">-->
<!-- <el-radio-group v-model="form.model.type" :disabled="state.type == 'edit'">-->
<!-- <el-radio label="reduce">满减券</el-radio>-->
<!-- <el-radio label="discount">折扣券</el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- <div class="el-form-item-inner">-->
<!-- <el-form-item>-->
<!-- <el-form-item label="消费满" prop="enough">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.enough" :min="0"-->
<!-- :disabled="state.type == 'edit'">-->
<!-- <template #append>元</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item v-if="form.model.type == 'reduce'" class="is-no-asterisk ml-2" label="立减"-->
<!-- prop="amount">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.amount" :min="0"-->
<!-- :disabled="state.type == 'edit'">-->
<!-- <template #append>元</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item v-if="form.model.type == 'discount'" class="is-no-asterisk ml-2" label="打"-->
<!-- prop="amount">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.amount" :min="0" :max="10"-->
<!-- :disabled="state.type == 'edit'">-->
<!-- <template #append>折</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- </el-form-item>-->
<!-- <el-form-item v-if="form.model.type == 'discount'">-->
<!-- <el-form-item label="最多优惠" prop="max_amount">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.max_amount" :min="0"-->
<!-- :disabled="state.type == 'edit'">-->
<!-- <template #append>元</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- </el-form-item>-->
<!-- </div>-->
<!-- <el-form-item label="发券总量" prop="stock">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.stock" :min="0">-->
<!-- <template #append>张</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="每人限领次数">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.limit_num" :min="0">-->
<!-- <template #append>张</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="领券时间" prop="get_time">-->
<!-- <el-date-picker v-model="form.model.get_time" type="datetimerange"-->
<!-- value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"-->
<!-- :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"-->
<!-- range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" prefix-icon="Calendar"-->
<!-- :editable="false"></el-date-picker>-->
<!-- </el-form-item>-->
<el-form-item label="券有效期" prop="use_time_type">
<el-radio-group v-model="form.model.use_time_type">
<el-radio label="days">相对天数</el-radio>
<!-- <el-radio label="days">相对天数</el-radio>-->
<el-radio label="range">固定区间</el-radio>
</el-radio-group>
</el-form-item>
<div class="el-form-item-inner">
<el-form-item>
<template v-if="form.model.use_time_type == 'days'">
<el-form-item class="is-no-asterisk" label="领券" prop="start_days">
<el-input class="w-120" type="number" v-model="form.model.start_days" :min="0">
<template #append></template>
</el-input>
</el-form-item>
<el-form-item class="is-no-asterisk ml-2" label="后生效,有效期" prop="days">
<el-input class="w-120" type="number" v-model="form.model.days" :min="0">
<template #append></template>
</el-input>
</el-form-item>
</template>
<!-- <template v-if="form.model.use_time_type == 'days'">-->
<!-- <el-form-item class="is-no-asterisk" label="领券" prop="start_days">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.start_days" :min="0">-->
<!-- <template #append>天</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item class="is-no-asterisk ml-2" label="后生效,有效期" prop="days">-->
<!-- <el-input class="w-120" type="number" v-model="form.model.days" :min="0">-->
<!-- <template #append>天</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- </template>-->
<el-form-item v-if="form.model.use_time_type == 'range'" class="is-no-asterisk" label="固定时间"
prop="useTime">
<el-date-picker v-model="form.model.use_time" type="datetimerange"
@ -118,45 +118,46 @@
</el-form-item>
</el-form-item>
</div>
<el-form-item label="优惠叠加">
<div>
<div class="sa-flex">
<el-switch v-model="form.model.is_double_discount" :active-value="1"
:inactive-value="0">
</el-switch>
<div class="ml-2" :class="form.model.is_double_discount == 1?'sa-color--primary':''">
{{form.model.is_double_discount == 1?'开启':'关闭'}}
</div>
</div>
<div class="tip"> 开启优惠叠加,优惠券将可以和活动一起使用 </div>
</div>
</el-form-item>
<el-form-item label="券状态" prop="status">
<div>
<el-radio-group v-model="form.model.status">
<el-radio label="normal">公开发放</el-radio>
<el-radio label="hidden">后台发放</el-radio>
<el-radio label="disabled">禁止使用</el-radio>
</el-radio-group>
<div class="tip">
后台发放状态改为别的状态,将导致满赠活动无法赠送该优惠券
</div>
</div>
</el-form-item>
<!-- <el-form-item label="优惠叠加">-->
<!-- <div>-->
<!-- <div class="sa-flex">-->
<!-- <el-switch v-model="form.model.is_double_discount" :active-value="1"-->
<!-- :inactive-value="0">-->
<!-- </el-switch>-->
<!-- <div class="ml-2" :class="form.model.is_double_discount == 1?'sa-color&#45;&#45;primary':''">-->
<!-- {{form.model.is_double_discount == 1?'开启':'关闭'}}-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="tip"> 开启优惠叠加,优惠券将可以和活动一起使用 </div>-->
<!-- </div>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="券状态" prop="status">-->
<!-- <div>-->
<!-- <el-radio-group v-model="form.model.status">-->
<!-- <el-radio label="normal">公开发放</el-radio>-->
<!-- <el-radio label="hidden">后台发放</el-radio>-->
<!-- <el-radio label="disabled">禁止使用</el-radio>-->
<!-- </el-radio-group>-->
<!-- <div class="tip">-->
<!-- 后台发放状态改为别的状态,将导致满赠活动无法赠送该优惠券-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="可用范围" prop="use_scope">-->
<el-form-item label="可用范围" prop="use_scope">
<el-radio-group v-model="form.model.use_scope" @change="form.model.items_value = []">
<el-radio label="all_use">全场通用</el-radio>
<!-- <el-radio label="all_use">全场通用</el-radio>-->
<el-radio label="goods">指定商品可用</el-radio>
<el-radio label="disabled_goods">指定商品不可用</el-radio>
<el-radio label="category">指定分类可用</el-radio>
<!-- <el-radio label="disabled_goods">指定商品不可用</el-radio>-->
<!-- <el-radio label="category">指定分类可用</el-radio>-->
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button v-if="form.model.use_scope == 'goods' || form.model.use_scope == 'disabled_goods'"
type="primary" link @click="onSelectGoods">选择商品</el-button>
<el-button v-if="form.model.use_scope == 'category'" type="primary" link
@click="onSelectCategory">选择分类
</el-button>
<!-- <el-button v-if="form.model.use_scope == 'goods' || form.model.use_scope == 'disabled_goods'"-->
<el-button type="primary" link @click="onSelectGoods">选择商品</el-button>
<!-- <el-button v-if="form.model.use_scope == 'category'" type="primary" link-->
<!-- @click="onSelectCategory">选择分类-->
<!-- </el-button>-->
</el-form-item>
<el-form-item>
<div v-if="form.model.use_scope == 'goods' || form.model.use_scope == 'disabled_goods'"

@ -92,11 +92,11 @@
<div class="sa-table-line-1">{{ scope.row.name }}</div>
</template>
</el-table-column>
<el-table-column label="类型" min-width="74">
<template #default="scope">
<div class="sa-table-line-1">{{ scope.row.type_text }}</div>
</template>
</el-table-column>
<!-- <el-table-column label="类型" min-width="74">-->
<!-- <template #default="scope">-->
<!-- <div class="sa-table-line-1">{{ scope.row.type_text }}</div>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="可用范围" min-width="116">
<template #default="scope">
<div class="sa-table-line-1">{{ scope.row.use_scope_text }}</div>
@ -146,45 +146,45 @@
<div class="sa-table-line-1">{{ scope.row.stock }}</div>
</template>
</el-table-column>
<el-table-column label="状态" min-width="130">
<template #default="scope">
{if $auth->check('shopro/coupon/edit')}
<el-dropdown trigger="click" @command="onCommand">
<el-button link>
<el-tag type="info">
{{ scope.row.status_text }}
<el-icon>
<arrow-down />
</el-icon>
</el-tag>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item :command="{
id: scope.row.id,
type: 'normal',
}">公开发放</el-dropdown-item>
<el-dropdown-item :command="{
id: scope.row.id,
type: 'hidden',
}">后台发放</el-dropdown-item>
<el-dropdown-item :command="{
id: scope.row.id,
type: 'disabled',
}">禁止使用</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
{/if}
</template>
</el-table-column>
<!-- <el-table-column label="状态" min-width="130">-->
<!-- <template #default="scope">-->
<!-- {if $auth->check('shopro/coupon/edit')}-->
<!-- <el-dropdown trigger="click" @command="onCommand">-->
<!-- <el-button link>-->
<!-- <el-tag type="info">-->
<!-- {{ scope.row.status_text }}-->
<!-- <el-icon>-->
<!-- <arrow-down />-->
<!-- </el-icon>-->
<!-- </el-tag>-->
<!-- </el-button>-->
<!-- <template #dropdown>-->
<!-- <el-dropdown-menu>-->
<!-- <el-dropdown-item :command="{-->
<!-- id: scope.row.id,-->
<!-- type: 'normal',-->
<!-- }">公开发放</el-dropdown-item>-->
<!-- <el-dropdown-item :command="{-->
<!-- id: scope.row.id,-->
<!-- type: 'hidden',-->
<!-- }">后台发放</el-dropdown-item>-->
<!-- <el-dropdown-item :command="{-->
<!-- id: scope.row.id,-->
<!-- type: 'disabled',-->
<!-- }">禁止使用</el-dropdown-item>-->
<!-- </el-dropdown-menu>-->
<!-- </template>-->
<!-- </el-dropdown>-->
<!-- {/if}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" min-width="260" fixed="right">
<template #default="scope">
{if $auth->check('shopro/coupon/send')}
<el-button type="primary" link @click="onSend(scope.row.id)">手动发放</el-button>
<!-- <el-button type="primary" link @click="onSend(scope.row.id)">手动发放</el-button>-->
{/if}
{if $auth->check('shopro/user/coupon/index')}
<el-button type="primary" link @click="onCoupon(scope.row.id)">领取记录</el-button>
<!-- <el-button type="primary" link @click="onCoupon(scope.row.id)">领取记录</el-button>-->
{/if}
{if $auth->check('shopro/coupon/edit')}
<el-button type="primary" link @click="onEdit(scope.row.id)">编辑</el-button>

@ -609,15 +609,15 @@
<el-input v-model="item.price" placeholder="请输入价格" size="small"
type="number" :step="0.01" :min="0" :precision="2"></el-input>
</td>
<td>
<el-input v-model="item.original_price" placeholder="请输入划线价格"
size="small" type="number" :step="0.01" :min="0" :precision="2">
</el-input>
</td>
<td>
<el-input v-model="item.cost_price" placeholder="请输入成本价" size="small"
type="number" :step="0.01" :min="0" :precision="2"></el-input>
</td>
<!-- <td>-->
<!-- <el-input v-model="item.original_price" placeholder="请输入划线价格"-->
<!-- size="small" type="number" :step="0.01" :min="0" :precision="2">-->
<!-- </el-input>-->
<!-- </td>-->
<!-- <td>-->
<!-- <el-input v-model="item.cost_price" placeholder="请输入成本价" size="small"-->
<!-- type="number" :step="0.01" :min="0" :precision="2"></el-input>-->
<!-- </td>-->
<td class="stock">
<el-input v-if="state.type == 'add'" v-model="item.stock"
placeholder="请输入库存" size="small" type="number" :step="1" :min="0">
@ -803,7 +803,7 @@
</div>
</el-form-item>
<!-- <el-form-item v-if="form.model.dispatch_type == 'shopZt'" label="自提地址" prop="dispatch_id">-->
<el-form-item label="自提地址" prop="dispatch_id">
<el-form-item label="自提地址" prop="warehouse_ids">
<div class="sa-w-360">
<el-checkbox-group v-model="form.model.warehouse_ids">
<el-checkbox style="width: 230px;"

@ -173,31 +173,31 @@
<div class="bottom">
<div class="info">
<el-row>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<div class="left">推荐人</div>
<div class="right sa-flex">
<sa-user-profile type="agent" :user="state.detail.parent_user"
:id="state.detail.parent_user_id"></sa-user-profile>
{if $is_pro}
<el-button class="ml-2" type="primary" link @click="onChangeParentUser">
更换</el-button>
{/if}
</div>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<div class="left">佣金</div>
<div class="right">{{ state.detail.commission }}</div>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<div class="left">余额</div>
<div class="right sa-flex">
{{ state.detail.money }}
{if $auth->check('shopro/user/user/recharge')}
<el-button class="ml-2" type="primary" link
@click="onRecharge('money')">充值</el-button>
{/if}
</div>
</el-col>
<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">-->
<!-- <div class="left">推荐人</div>-->
<!-- <div class="right sa-flex">-->
<!-- <sa-user-profile type="agent" :user="state.detail.parent_user"-->
<!-- :id="state.detail.parent_user_id"></sa-user-profile>-->
<!-- {if $is_pro}-->
<!-- <el-button class="ml-2" type="primary" link @click="onChangeParentUser">-->
<!-- 更换</el-button>-->
<!-- {/if}-->
<!-- </div>-->
<!-- </el-col>-->
<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">-->
<!-- <div class="left">佣金</div>-->
<!-- <div class="right">{{ state.detail.commission }}</div>-->
<!-- </el-col>-->
<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">-->
<!-- <div class="left">余额</div>-->
<!-- <div class="right sa-flex">-->
<!-- {{ state.detail.money }}-->
<!-- {if $auth->check('shopro/user/user/recharge')}-->
<!-- <el-button class="ml-2" type="primary" link-->
<!-- @click="onRecharge('money')">充值</el-button>-->
<!-- {/if}-->
<!-- </div>-->
<!-- </el-col>-->
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<div class="left">上次登陆时间</div>
<div class="right">{{ state.detail.logintime }}</div>

@ -25,25 +25,32 @@
</el-table-column>
<el-table-column prop="username" label="用户名" min-width="120"></el-table-column>
<el-table-column prop="mobile" label="手机号" min-width="120"></el-table-column>
<el-table-column sortable="custom" prop="commission" label="佣金" min-width="110"></el-table-column>
<!-- <el-table-column sortable="custom" prop="commission" label="佣金" min-width="110"></el-table-column>-->
<el-table-column prop="user_level" label="用户等级" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="total_consume" label="总消费" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="score" label="积分" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="money" label="余额" min-width="110"></el-table-column>
<!-- <el-table-column sortable="custom" prop="money" label="余额" min-width="110"></el-table-column>-->
<el-table-column prop="nextUserCount" label="下级团队人数" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="createtime" label="注册时间" min-width="172"></el-table-column>
<el-table-column sortable="custom" prop="logintime" label="上次登录" min-width="172"></el-table-column>
<el-table-column fixed="right" label="操作" min-width="120">
<template #default="scope">
{if $auth->check('shopro/user/user/detail')}
<el-button type="primary" link @click="onDetail(scope.row.id)">查看</el-button>
<el-button type="primary" link @click="onNextTeam(props.row.id)">下级团队
</el-button>
<!--
{/if}
<el-popconfirm width="fit-content" confirm-button-text="确认" cancel-button-text="取消"
title="确认删除这条记录?" @confirm="onDelete(scope.row.id)">
<template #reference>
{if $auth->check('shopro/user/user/delete')}
<el-button type="danger" link>删除</el-button>
{/if}
</template>
</el-popconfirm>
<!-- <el-popconfirm width="fit-content" confirm-button-text="确认" cancel-button-text="取消"-->
<!-- title="确认删除这条记录?" @confirm="onDelete(scope.row.id)">-->
<!-- <template #reference>-->
<!-- {if $auth->check('shopro/user/user/delete')}-->
<!-- <el-button type="danger" link>删除</el-button>-->
<!-- {/if}-->
<!-- </template>-->
<!-- </el-popconfirm>-->
</template>
</el-table-column>
</el-table>

@ -0,0 +1,20 @@
{include file="/shopro/common/script" /}
<div id="team" class="order-action" v-cloak>
<el-container class="panel-block">
<el-main>
<el-table height="100%" class="sa-table" :data="state.data" stripe>
<el-table-column prop="id" label="用户ID" min-width="90"></el-table-column>
<el-table-column label="用户信息" min-width="150">
<template #default="scope">
<sa-user-profile :user="scope.row" :id="scope.row.id"></sa-user-profile>
</template>
</el-table-column>
<el-table-column prop="username" label="用户名" min-width="120"></el-table-column>
<el-table-column prop="mobile" label="手机号" min-width="120"></el-table-column>
<el-table-column prop="user_level" label="用户等级" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="join_time" label="上次登录" min-width="172"></el-table-column>
</el-table>
</el-main>
</el-container>
</div>

@ -234,7 +234,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
model: {
name: '',
type: 'reduce', // 优惠券类型:reduce=满减券,discount=折扣券
use_scope: 'all_use', // 可用范围:all=全场通用,goods=指定商品可用,disabled_goods=指定商品不可用,category=指定分类可用
use_scope: 'goods', // 可用范围:all=全场通用,goods=指定商品可用,disabled_goods=指定商品不可用,category=指定分类可用
items: '',
items_value: [],
amount: '',
@ -243,7 +243,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
stock: '',
limit_num: '',
get_time: '',
use_time_type: 'days',
// use_time_type: 'days',
use_time_type: 'range',
use_time: '',
start_days: '',
days: '',
@ -318,13 +319,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
let submitForm = JSON.parse(JSON.stringify(form.model));
if (Number(submitForm.enough) < Number(submitForm.amount)) {
ElMessage({
message: '请输入正确的使用门槛',
type: 'warning',
});
return;
}
// if (Number(submitForm.enough) < Number(submitForm.amount)) {
// ElMessage({
// message: '请输入正确的使用门槛',
// type: 'warning',
// });
// return;
// }
if (
submitForm.use_scope == 'goods' ||
submitForm.use_scope == 'disabled_goods' ||
@ -359,6 +360,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
onMounted(() => {
console.log(form.model.use_scope)
state.type == 'edit' && getDetail()
})

@ -408,7 +408,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
limit_type: 'none',
limit_num: 0,
status: 'up',
dispatch_type: 'express',
dispatch_type: ['express', 'shopZt'],
dispatch_id: '',
is_offline: 0,
is_sku: 0,
@ -459,8 +459,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
image: [{ required: true, message: '请选择商品主图', trigger: 'blur' }],
images: [{ required: true, message: '请选择轮播图', trigger: 'blur' }],
title: [{ required: true, message: '请输入商品标题', trigger: 'blur' }],
// category_ids: [{ required: true, message: '请输入商品分类', trigger: 'blur' }],
dispatch_id: [{ required: true, message: '请选择物流快递', trigger: 'blur' }],
category_ids: [{ required: true, message: '请输入商品分类', trigger: 'blur' }],
// dispatch_id: [{ required: true, message: '请选择物流快递', trigger: 'blur' }],
price: [{ required: true, message: '请输入售卖价格', trigger: 'blur' }],
},
})
@ -501,7 +501,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
function onChangeGoodsType(type) {
console.log(type, 'type')
form.model.type = type;
form.model.dispatch_type = type == 'normal' ? 'express' : 'autosend';
// form.model.dispatch_type = type == 'normal' ? 'express' : 'autosend';
form.model.dispatch_type = type == 'normal' ? ['express', 'shopZt'] : [];
form.model.dispatch_id = ''
getDispatchSelect()
}
@ -1073,7 +1074,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
const state = reactive({
data_type: new URLSearchParams(location.search).get('data_type'),
multiple: new URLSearchParams(location.search).get('multiple') || false,
max: new URLSearchParams(location.search).get('max') || 0,
max: new URLSearchParams(location.search).get('max') || 1,
ids: new URLSearchParams(location.search).get('ids'), // 选中的商品ids
goods_ids: new URLSearchParams(location.search).get('goods_ids'), // 需要搜索的商品id列表
data: [],
@ -1181,6 +1182,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
})
function onSelect(selection, row) {
console.log('selection', selection)
console.log('row', row.id)
console.log('max', state.max)
if (
!state.max ||
(state.max && state.max > state.ids.length)

@ -117,6 +117,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
})
}
function onNextTeam(id) {
Fast.api.open(`shopro/user/user/myTeam?id=${id}`, "下级团队", {
callback() {
getData()
}
})
}
function onDelete(id) {
Fast.api.ajax({
url: `shopro/user/user/delete/id/${id}`,

Loading…
Cancel
Save