mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-28 05:11:39 +08:00
增加原始价格,市场价改名为优惠价
This commit is contained in:
parent
ed9e5f1159
commit
491c5d3688
@ -46,6 +46,7 @@ class PackageCourseList extends Cache
|
||||
'id' => $course->id,
|
||||
'title' => $course->title,
|
||||
'cover' => $course->cover,
|
||||
'origin_price' => $course->origin_price,
|
||||
'market_price' => $course->market_price,
|
||||
'vip_price' => $course->vip_price,
|
||||
'model' => $course->model,
|
||||
|
@ -164,6 +164,7 @@ class Course extends Service
|
||||
$data['market_price'] = 0;
|
||||
$data['vip_price'] = 0;
|
||||
} else {
|
||||
$data['origin_price'] = $validator->checkMarketPrice($post['origin_price']);
|
||||
$data['market_price'] = $validator->checkMarketPrice($post['market_price']);
|
||||
$data['vip_price'] = $validator->checkVipPrice($post['vip_price']);
|
||||
$validator->checkComparePrice($post['market_price'], $post['vip_price']);
|
||||
|
@ -12,7 +12,16 @@
|
||||
<div id="price-block" style="{{ price_display }}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">市场价格</label>
|
||||
<label class="layui-form-label">原始价格</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="origin_price" value="{{ course.origin_price }}" lay-verify="number">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">元</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">优惠价格</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="market_price" value="{{ course.market_price }}" lay-verify="number">
|
||||
</div>
|
||||
|
@ -100,8 +100,9 @@
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<p>市场:{{ '¥%0.2f'|format(item.market_price) }}</p>
|
||||
<p>会员:{{ '¥%0.2f'|format(item.vip_price) }}</p>
|
||||
<p>原始价:{{ '¥%0.2f'|format(item.origin_price) }}</p>
|
||||
<p>优惠价:{{ '¥%0.2f'|format(item.market_price) }}</p>
|
||||
<p>会员价:{{ '¥%0.2f'|format(item.vip_price) }}</p>
|
||||
</td>
|
||||
<td><input type="checkbox" name="featured" value="1" lay-skin="switch" lay-text="是|否" lay-filter="featured" data-url="{{ update_url }}" {% if item.featured == 1 %}checked="checked"{% endif %}></td>
|
||||
<td><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked="checked"{% endif %}></td>
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% set course = order.item_info['course'] %}
|
||||
<div class="kg-order-item">
|
||||
<p>课程名称:{{ course['title'] }}</p>
|
||||
<p>市场价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}</p>
|
||||
<p>优惠价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}</p>
|
||||
<p>学习期限:{{ date('Y-m-d H:i:s',course['study_expiry_time']) }},退款期限:{{ date('Y-m-d H:i:s',course['refund_expiry_time']) }}</p>
|
||||
</div>
|
||||
{% elseif order.item_type == 2 %}
|
||||
@ -11,7 +11,7 @@
|
||||
{% for course in courses %}
|
||||
<div class="kg-order-item">
|
||||
<p>课程名称:{{ course['title'] }}</p>
|
||||
<p>市场价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}</p>
|
||||
<p>优惠价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}</p>
|
||||
<p>学习期限:{{ date('Y-m-d H:i:s',course['study_expiry_time']) }},退款期限:{{ date('Y-m-d H:i:s',course['refund_expiry_time']) }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">市场价格</label>
|
||||
<label class="layui-form-label">优惠价格</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="market_price" value="{{ package.market_price }}" lay-verify="number">
|
||||
</div>
|
||||
|
@ -26,7 +26,7 @@
|
||||
<td><span class="layui-badge layui-bg-gray">{{ item.lesson_count }}</span></td>
|
||||
<td>{{ study_expiry_info(item.study_expiry) }}</td>
|
||||
<td>
|
||||
<p>市场价:{{ '¥%0.2f'|format(item.market_price) }}</p>
|
||||
<p>优惠价:{{ '¥%0.2f'|format(item.market_price) }}</p>
|
||||
<p>会员价:{{ '¥%0.2f'|format(item.vip_price) }}</p>
|
||||
</td>
|
||||
</tr>
|
||||
@ -37,7 +37,7 @@
|
||||
<br>
|
||||
|
||||
<div class="kg-price-guiding">
|
||||
建议市场价:<span class="layui-badge layui-bg-red">¥{{ guiding_price.market_price }}</span>
|
||||
建议优惠价:<span class="layui-badge layui-bg-red">¥{{ guiding_price.market_price }}</span>
|
||||
|
||||
建议会员价:<span class="layui-badge layui-bg-red">¥{{ guiding_price.vip_price }}</span>
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<th>编号</th>
|
||||
<th>标题</th>
|
||||
<th>课程数</th>
|
||||
<th>市场价</th>
|
||||
<th>优惠价</th>
|
||||
<th>会员价</th>
|
||||
<th>发布</th>
|
||||
<th>操作</th>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<span>总价 <i>{{ '¥%0.2f'|format(package.origin_price) }}</i></span>
|
||||
</div>
|
||||
<div class="price">
|
||||
<span>市场价 <i>{{ '¥%0.2f'|format(package.market_price) }}</i></span>
|
||||
<span>优惠价 <i>{{ '¥%0.2f'|format(package.market_price) }}</i></span>
|
||||
</div>
|
||||
<div class="price">
|
||||
<span>会员价 <i>{{ '¥%0.2f'|format(package.vip_price) }}</i></span>
|
||||
|
@ -34,10 +34,11 @@
|
||||
|
||||
{%- macro meta_price_info(course) %}
|
||||
<p class="item">
|
||||
<span class="key">原始价格</span><span class="value origin-price">{{ '¥%0.2f'|format(course.origin_price) }}</span>
|
||||
{% if course.market_price > 0 %}
|
||||
<span class="key">市场价格</span><span class="value price">{{ '¥%0.2f'|format(course.market_price) }}</span>
|
||||
<span class="key">优惠价格</span><span class="value price">{{ '¥%0.2f'|format(course.market_price) }}</span>
|
||||
{% else %}
|
||||
<span class="key">市场价格</span><span class="value free">免费</span>
|
||||
<span class="key">优惠价格</span><span class="value free">免费</span>
|
||||
{% endif %}
|
||||
{% if course.vip_price > 0 %}
|
||||
<span class="key">会员价格</span><span class="value price">{{ '¥%0.2f'|format(course.vip_price) }}</span>
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% set course = order.item_info.course %}
|
||||
<div class="order-item">
|
||||
<p>课程名称:<span>{{ course.title }}</span></p>
|
||||
<p>市场价格:<span class="price">{{ '¥%0.2f'|format(course.market_price) }}</span>会员价格:<span class="price">{{ '¥%0.2f'|format(course.vip_price) }}</span></p>
|
||||
<p>优惠价格:<span class="price">{{ '¥%0.2f'|format(course.market_price) }}</span>会员价格:<span class="price">{{ '¥%0.2f'|format(course.vip_price) }}</span></p>
|
||||
<p>学习期限:<span>{{ date('Y-m-d',course.study_expiry_time) }}</span>退款期限:<span>{{ date('Y-m-d',course.refund_expiry_time) }}</span></p>
|
||||
</div>
|
||||
{% elseif order.item_type == 2 %}
|
||||
@ -11,7 +11,7 @@
|
||||
{% for course in courses %}
|
||||
<div class="order-item">
|
||||
<p>课程名称:<span>{{ course.title }}</span></p>
|
||||
<p>市场价格:<span class="price">{{ '¥%0.2f'|format(course.market_price) }}</span>会员价格:<span class="price">{{ '¥%0.2f'|format(course.vip_price) }}</span></p>
|
||||
<p>优惠价格:<span class="price">{{ '¥%0.2f'|format(course.market_price) }}</span>会员价格:<span class="price">{{ '¥%0.2f'|format(course.vip_price) }}</span></p>
|
||||
<p>学习期限:<span>{{ date('Y-m-d',course.study_expiry_time) }}</span>退款期限:<span>{{ date('Y-m-d',course.refund_expiry_time) }}</span></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
@ -13,7 +13,8 @@
|
||||
<div class="info">
|
||||
<p><a href="{{ course_url }}" target="_blank">{{ course.title }}</a></p>
|
||||
<p>
|
||||
市场价格 <span class="price">{{ '¥%0.2f'|format(course.market_price) }}</span>
|
||||
原始价格 <span class="origin-price">{{ '¥%0.2f'|format(course.origin_price) }}</span>
|
||||
优惠价格 <span class="price">{{ '¥%0.2f'|format(course.market_price) }}</span>
|
||||
会员价格 <span class="price">{{ '¥%0.2f'|format(course.vip_price) }}</span>
|
||||
</p>
|
||||
<p>
|
||||
|
@ -104,7 +104,14 @@ class Course extends Model
|
||||
public $teacher_id;
|
||||
|
||||
/**
|
||||
* 市场价格
|
||||
* 原始价格
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $origin_price;
|
||||
|
||||
/**
|
||||
* 优惠价格
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
@ -323,6 +330,10 @@ class Course extends Model
|
||||
$this->attrs = kg_json_encode($this->attrs);
|
||||
}
|
||||
|
||||
if (empty($this->origin_price)) {
|
||||
$this->origin_price = 1.5 * $this->market_price;
|
||||
}
|
||||
|
||||
if ($this->deleted == 1) {
|
||||
$this->published = 0;
|
||||
}
|
||||
@ -339,6 +350,7 @@ class Course extends Model
|
||||
|
||||
public function afterFetch()
|
||||
{
|
||||
$this->origin_price = (float)$this->origin_price;
|
||||
$this->market_price = (float)$this->market_price;
|
||||
$this->vip_price = (float)$this->vip_price;
|
||||
$this->rating = (float)$this->rating;
|
||||
|
@ -30,7 +30,7 @@ class Package extends Model
|
||||
public $summary;
|
||||
|
||||
/**
|
||||
* 市场价格
|
||||
* 优惠价格
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ class BasicInfo extends Service
|
||||
'summary' => $course->summary,
|
||||
'details' => $course->details,
|
||||
'keywords' => $course->keywords,
|
||||
'origin_price' => $course->origin_price,
|
||||
'market_price' => $course->market_price,
|
||||
'vip_price' => $course->vip_price,
|
||||
'study_expiry' => $course->study_expiry,
|
||||
|
@ -40,7 +40,7 @@ class PackageList extends Service
|
||||
|
||||
if ($courses) {
|
||||
foreach ($courses as $course) {
|
||||
$package['origin_price'] += $course['market_price'];
|
||||
$package['origin_price'] += $course['origin_price'];
|
||||
}
|
||||
$package['courses'] = $this->sortCourses($courses, $firstCourseId);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class OrderConfirm extends Service
|
||||
|
||||
$result['item_info']['course'] = $this->handleCourseInfo($course);
|
||||
|
||||
$result['total_amount'] = $course->market_price;
|
||||
$result['total_amount'] = $course->origin_price;
|
||||
$result['pay_amount'] = $user->vip ? $course->vip_price : $course->market_price;
|
||||
$result['discount_amount'] = $result['total_amount'] - $result['pay_amount'];
|
||||
|
||||
@ -46,7 +46,7 @@ class OrderConfirm extends Service
|
||||
$result['total_amount'] = 0;
|
||||
|
||||
foreach ($result['item_info']['package']['courses'] as $course) {
|
||||
$result['total_amount'] += $course['market_price'];
|
||||
$result['total_amount'] += $course['origin_price'];
|
||||
}
|
||||
|
||||
$result['pay_amount'] = $user->vip ? $package->vip_price : $package->market_price;
|
||||
@ -138,6 +138,7 @@ class OrderConfirm extends Service
|
||||
'lesson_count' => $course->lesson_count,
|
||||
'study_expiry' => $course->study_expiry,
|
||||
'refund_expiry' => $course->refund_expiry,
|
||||
'origin_price' => $course->origin_price,
|
||||
'market_price' => $course->market_price,
|
||||
'vip_price' => $course->vip_price,
|
||||
];
|
||||
|
@ -161,6 +161,17 @@ class Course extends Validator
|
||||
return implode(',', $list);
|
||||
}
|
||||
|
||||
public function checkGuidePrice($price)
|
||||
{
|
||||
$value = $this->filter->sanitize($price, ['trim', 'float']);
|
||||
|
||||
if ($value < 0 || $value > 10000) {
|
||||
throw new BadRequestException('course.invalid_origin_price');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function checkMarketPrice($price)
|
||||
{
|
||||
$value = $this->filter->sanitize($price, ['trim', 'float']);
|
||||
|
@ -109,9 +109,10 @@ $error['course.details_too_long'] = '详情太长(多于5000个字符)';
|
||||
$error['course.invalid_model'] = '无效的模型类别';
|
||||
$error['course.invalid_level'] = '无效的难度级别';
|
||||
$error['course.invalid_cover'] = '无效的封面';
|
||||
$error['course.invalid_market_price'] = '无效的市场价格(范围:0-10000)';
|
||||
$error['course.invalid_origin_price'] = '无效的指导价格(范围:0-10000)';
|
||||
$error['course.invalid_market_price'] = '无效的优惠价格(范围:0-10000)';
|
||||
$error['course.invalid_vip_price'] = '无效的会员价格(范围:0-10000)';
|
||||
$error['course.invalid_compare_price'] = '无效的比较定价(会员价格高于市场价格)';
|
||||
$error['course.invalid_compare_price'] = '无效的比较定价(会员价格高于优惠价格)';
|
||||
$error['course.invalid_study_expiry'] = '无效的学习期限';
|
||||
$error['course.invalid_refund_expiry'] = '无效的退款期限';
|
||||
$error['course.invalid_feature_status'] = '无效的推荐状态';
|
||||
@ -135,7 +136,7 @@ $error['package.not_found'] = '套餐不存在';
|
||||
$error['package.title_too_short'] = '标题太短(少于5个字符)';
|
||||
$error['package.title_too_long'] = '标题太长(多于50个字符)';
|
||||
$error['package.summary_too_long'] = '简介太长(多于255个字符)';
|
||||
$error['package.invalid_market_price'] = '无效的市场价格';
|
||||
$error['package.invalid_market_price'] = '无效的优惠价格';
|
||||
$error['package.invalid_vip_price'] = '无效的会员价格';
|
||||
$error['package.invalid_publish_status'] = '无效的发布状态';
|
||||
|
||||
|
@ -1236,7 +1236,7 @@ class InitTable extends Phinx\Migration\AbstractMigration
|
||||
'default' => '0.00',
|
||||
'precision' => '10',
|
||||
'scale' => '2',
|
||||
'comment' => '市场价格',
|
||||
'comment' => '优惠价格',
|
||||
'after' => 'teacher_id',
|
||||
])
|
||||
->addColumn('vip_price', 'decimal', [
|
||||
@ -3124,7 +3124,7 @@ class InitTable extends Phinx\Migration\AbstractMigration
|
||||
'default' => '0.00',
|
||||
'precision' => '10',
|
||||
'scale' => '2',
|
||||
'comment' => '市场价格',
|
||||
'comment' => '优惠价格',
|
||||
'after' => 'summary',
|
||||
])
|
||||
->addColumn('vip_price', 'decimal', [
|
||||
|
27
db/migrations/20210203081614_schema_202102031615.php
Normal file
27
db/migrations/20210203081614_schema_202102031615.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class Schema202102031615 extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
|
||||
public function change()
|
||||
{
|
||||
$this->table('kg_course')
|
||||
->addColumn('origin_price', 'decimal', [
|
||||
'null' => false,
|
||||
'default' => '0.00',
|
||||
'precision' => '10',
|
||||
'scale' => '2',
|
||||
'comment' => '原始价格',
|
||||
'after' => 'teacher_id',
|
||||
])
|
||||
->save();
|
||||
|
||||
$this->updateOriginPrice();
|
||||
}
|
||||
|
||||
protected function updateOriginPrice()
|
||||
{
|
||||
$this->execute("UPDATE kg_course SET origin_price = round(1.5 * market_price)");
|
||||
}
|
||||
|
||||
}
|
@ -4130,7 +4130,7 @@ return array(
|
||||
'COLUMN_KEY' => '',
|
||||
'EXTRA' => '',
|
||||
'PRIVILEGES' => 'select,insert,update,references',
|
||||
'COLUMN_COMMENT' => '市场价格',
|
||||
'COLUMN_COMMENT' => '优惠价格',
|
||||
'GENERATION_EXPRESSION' => '',
|
||||
'SRS_ID' => NULL,
|
||||
),
|
||||
@ -10669,7 +10669,7 @@ return array(
|
||||
'COLUMN_KEY' => '',
|
||||
'EXTRA' => '',
|
||||
'PRIVILEGES' => 'select,insert,update,references',
|
||||
'COLUMN_COMMENT' => '市场价格',
|
||||
'COLUMN_COMMENT' => '优惠价格',
|
||||
'GENERATION_EXPRESSION' => '',
|
||||
'SRS_ID' => NULL,
|
||||
),
|
||||
|
@ -71,7 +71,7 @@ function xmCourse(data, url) {
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'market_price', title: '市场价', width: 50, templet: function (d) {
|
||||
field: 'market_price', title: '优惠价', width: 50, templet: function (d) {
|
||||
return '¥' + d.market_price;
|
||||
}
|
||||
},
|
||||
|
@ -501,6 +501,10 @@
|
||||
color: red;
|
||||
}
|
||||
|
||||
.course-meta .info .origin-price {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.course-meta .info .free {
|
||||
color: green;
|
||||
}
|
||||
@ -1071,6 +1075,10 @@
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.cart-course-card .origin-price {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.cart-course-card .price {
|
||||
color: red;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user