1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace app\common\model;
- use app\common\service\InstallService;
- use app\common\service\OrderService;
- use think\Model;
- /**
- */
- class ProgrammeGoods extends Model
- {
- protected $append=[
- 'amount',
- 'amount_install',
- 'amount_total',
- ];
- public function skuObj(){
- return $this->belongsTo(GoodsSku::class,'sku_id');
- }
- public function getAmountAttr($_,$model){
- list($amount,$__,$single)=OrderService::getAmount($this['skuObj'],$this['skuObj']['goods'],$model['num']);
- return $single;
- }
- public function getAmountInstallAttr($_,$model){
- $single=InstallService::getFee([$model['sku_id']=>$model],'num_install',true);
- return $single;
- }
- public function getAmountTotalAttr($_,$model){
- return bcAddAll($this['amount']*$model['num'],$this['amount_install']*$model['num_install']);
- }
- }
|