123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- // +----------------------------------------------------------------------
- // | likeshop开源商城系统
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | gitee下载:https://gitee.com/likeshop_gitee
- // | github下载:https://github.com/likeshop-github
- // | 访问官网:https://www.likeshop.cn
- // | 访问社区:https://home.likeshop.cn
- // | 访问手册:http://doc.likeshop.cn
- // | 微信公众号:likeshop技术社区
- // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
- // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
- // | 禁止对系统程序代码以任何目的,任何形式的再发布
- // | likeshop团队版权所有并拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeshop.cn.team
- // +----------------------------------------------------------------------
-
- namespace app\common\model\live;
-
- use app\common\basics\Models;
- use app\common\enum\LiveGoodsEnum;
- use app\common\model\goods\Goods;
- use app\common\model\shop\Shop;
-
-
- /**
- * 直播商品
- * Class LiveGoods
- * @package app\common\model\live
- */
- class LiveGoods extends Models
- {
-
- /**
- * @notes 关联商家
- * @return \think\model\relation\HasOne
- * @author 段誉
- * @date 2023/2/16 12:10
- */
- public function shop()
- {
- return $this->hasOne(Shop::class, 'id', 'shop_id')
- ->field(['id','logo','type','name'])->append(['type_desc']);
- }
-
-
- /**
- * @notes 审核状态描述
- * @param $value
- * @param $data
- * @return string|string[]
- * @author 段誉
- * @date 2023/2/16 9:45
- */
- public function getAuditStatusTextAttr($value, $data)
- {
- return LiveGoodsEnum::getAuditStatusDesc($data['sys_audit_status']);
- }
-
-
- /**
- * @notes 价格描述
- * @param $value
- * @param $data
- * @return string
- * @author 段誉
- * @date 2023/2/16 20:45
- */
- public function getPriceTextAttr($value, $data)
- {
- if ($data['price_type'] == LiveGoodsEnum::PRICE_ONE) {
- return '¥' . $data['price'];
- } else {
- return '¥' . $data['price'] . '~ ¥' .$data['price2'];
- }
- }
-
-
- /**
- * @notes 价格形式
- * @param $value
- * @param $data
- * @return string|string[]
- * @author 段誉
- * @date 2023/2/16 21:55
- */
- public function getPriceTypeTextAttr($value, $data)
- {
- return LiveGoodsEnum::getPriceTypeDesc($data['price_type']);
- }
-
-
- /**
- * @notes 价格描述
- * @param $value
- * @param $data
- * @return string|void
- * @author 段誉
- * @date 2023/2/16 21:59
- */
- public function getPriceTipsAttr($value, $data)
- {
- if ($data['price_type'] == LiveGoodsEnum::PRICE_ONE) {
- return '价格 ' . $data['price'] . '元';
- }
- if ($data['price_type'] == LiveGoodsEnum::PRICE_RANGE) {
- return '价格 ' . $data['price'] . '元 ~ ' .$data['price2'] . '元';
- }
- if ($data['price_type'] == LiveGoodsEnum::PRICE_DISCOUNT) {
- return '价格 ' . $data['price'] . '元 现价 ' .$data['price2'] . '元';
- }
- }
-
-
- /**
- * @notes 来源类型
- * @param $value
- * @param $data
- * @return string|string[]
- * @author 段誉
- * @date 2023/2/17 9:36
- */
- public function getSourceTypeTextAttr($value, $data)
- {
- return LiveGoodsEnum::getSourceTypeDesc($data['source_type']);
- }
-
-
- /**
- * @notes 商品库存
- * @param $value
- * @param $data
- * @return int|mixed
- * @author 段誉
- * @date 2023/2/17 12:12
- */
- public function getGoodsStockAttr($value, $data)
- {
- $stock = 0;
- if ($data['source_type'] == LiveGoodsEnum::SOURCE_TYPE_GOODS) {
- $stock = Goods::where('id', $data['source_id'])->value('stock');
- $stock = empty($stock) ? 0 : $stock;
- }
- return $stock;
- }
-
-
-
- }
|