pull/1/head
wanghousheng 12 months ago
parent ce3a6fa489
commit 1e922f3595
  1. 31
      app/common/enum/coupon/TypeCase.php
  2. 15
      app/common/model/Coupon.php
  3. 25
      app/common/model/server/Server.php
  4. 13
      app/store/controller/Server.php

@ -0,0 +1,31 @@
<?php
namespace app\common\enum\coupon;
use app\common\enum\EnumBasics;
class TypeCase extends EnumBasics
{
const SHOP = 10;//商品券
const SERVER = 20;//服务券
/**
* @notes:优惠券类别
* @return array[]
* @author: wanghousheng
*/
public static function data(): array
{
return [
self::SHOP => [
'name' => '商品券',
'value' => self::SHOP
],
self::SERVER => [
'name' => '服务券',
'value' => self::SERVER
]
];
}
}

@ -12,8 +12,9 @@ declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use app\common\enum\coupon\TypeCase;
use app\common\library\helper;
use cores\BaseModel;
/**
* 优惠券模型
@ -32,7 +33,7 @@ class Coupon extends BaseModel
* 追加字段
* @var array
*/
protected $append = ['state'];
protected $append = ['state', 'coupon_case_text'];
/**
* 优惠券状态 (是否可领取)
@ -54,6 +55,16 @@ class Coupon extends BaseModel
return ['text' => '正常', 'value' => 1];
}
public function getCouponCaseTextAttr($value, $data)
{
// 订单状态
$result = TypeCase::data();
if (!empty($result[$data['coupon_case']]['name'])) {
return $result[$data['coupon_case']]['name'];
}
return '未知';
}
/**
* 获取器:格式化折扣率
* @param $value

@ -74,6 +74,31 @@ class Server extends BaseModel
->paginate($listRows);
}
/**
* 根据商品id集获取服务列表
* @param array $serverIds
* @param null $status
* @return mixed
*/
public function getListByIds(array $serverIds, $status = null)
{
// 筛选条件
$filter = [['server_id', 'in', $serverIds]];
// 商品状态
$status > 0 && $filter[] = ['status', '=', $status];
// 获取商品列表数据
$result = $this->withoutField(['content'])
->with(['image'])
->withJoin(['category' => ['category_id', 'name']])
->where($filter)
->orderRaw('field(server_id, ' . implode(',', $serverIds) . ')')
->select();
if (!empty($result)) {
return $result->toArray();
}
return [];
}
/**
* 文章详情:HTML实体转换回普通字符
* @param $value

@ -171,6 +171,19 @@ class Server extends Controller
return $this->renderError('删除失败');
}
/**
* 根据服务ID集获取列表记录
* @param $serverIds
* @return Json
*/
public function listByIds($serverIds): Json
{
// 获取列表记录
$model = new ServerModel();
$list = $model->getListByIds($serverIds);
return $this->renderSuccess(compact('list'));
}
/**
* 修改服务状态(上下架)
* @param array $serverIds 商品id集

Loading…
Cancel
Save