定价管理修改

This commit is contained in:
邓皓元 2019-03-28 18:21:29 +08:00
parent 179a0cb37c
commit f62736ba84
13 changed files with 33 additions and 19 deletions

View File

@ -107,33 +107,32 @@ class ProductService extends Service
$message = [
'name.required' => '请输入定价名称',
'name.between' => '请输入2-32个字符',
'name.unique' => '定价名称已存在,请新输入',
'name.unique' => '定价名称已存在,请新输入',
'company_id.required' => '请输入企业ID',
'company_id.exists' => '企业不存在或已删除',
'package_id.required' => '请输入套餐ID',
];
Validator::validate($attributes, $rule, $message);
DB::beginTransaction();
if (!$package = app(PackageRepository::class)->find($attributes['package_id'])) {
throw new NotExistException('套餐不存在或已删除');
}
DB::beginTransaction();
// 上一次定价
$newest = $this->productRepository->where('company_id', $attributes['company_id'])->where('package_id', $attributes['package_id'])->first();
if ($newest && (isset($attributes['price']) && $newest->price !== $attributes['price']) || (isset($attributes['renew_price']) && $newest->renew_price !== $attributes['renew_price'])) {
unset($attributes['id']);
$newest->delete();
$attributes['renew_price'] = $attributes['renew_price'] ?? $newest->renew_price;
$attributes['price'] = $attributes['price'] ?? $newest->price;
}
Validator::validate($attributes, $rule, $message);
try {
// 上一次定价
$newest = $this->productRepository->where('company_id', $attributes['company_id'])
->where('package_id', $attributes['package_id'])->first();
if ($newest && (isset($attributes['price']) && $newest->price !== $attributes['price']) || (isset($attributes['renew_price']) && $newest->renew_price !== $attributes['renew_price'])) {
unset($attributes['id']);
$newest->delete();
$attributes['renew_price'] = $attributes['renew_price'] ?? $newest->renew_price;
$attributes['price'] = $attributes['price'] ?? $newest->price;
}
if ($attributes['id']) {
if (!$node = $this->productRepository->find($attributes['id'])) {
throw new NotExistException('定价不存在或已删除');
@ -154,7 +153,6 @@ class ProductService extends Service
$node = $this->productRepository->create($attributes);
}
DB::commit();
} catch (\Exception $e) {
DB::rollback();

View File

@ -38,7 +38,6 @@
<div class="ui-list-title">销售价格</div>
<div class="ui-list-content">
<InputNumber
:disabled="isUpdate"
:active-change="false"
:max="100000"
:min="0"

View File

@ -57,7 +57,10 @@ export default {
{
title: '销售价格',
key: 'price',
width: 100
width: 100,
render: (h, { row, column, index }) => {
return h('span', Number(row.price).toFixed(2));
}
},
{
title: '运营商',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-6ac03f5f.b16f7faa.css rel=prefetch><link href=/css/chunk-996b1e80.5cadf3d0.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-6ac03f5f.9af49aa9.js rel=prefetch><link href=/js/chunk-996b1e80.d3b45e46.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.8cc6aaf9.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.8cc6aaf9.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-63ee4df4.78afaf5b.css rel=prefetch><link href=/css/chunk-996b1e80.5cadf3d0.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-63ee4df4.87a99f35.js rel=prefetch><link href=/js/chunk-996b1e80.d3b45e46.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.77e8188a.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.77e8188a.js></script></body></html>