1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- declare (strict_types=1);
- namespace app\common\model\za;
- use app\common\model\Goods;
- use app\common\model\GoodsSku;
- use app\common\model\BaseModel;
- use app\common\model\UploadFile;
- /**
- * 活动中心 ▸买一赠一活动 关联数据
- * Class Ad
- * @package app\common\model
- */
- class ZaActivityRelation extends BaseModel
- {
-
- protected $name = 'za_activity_relations';
- // protected $append = ['image'];
- // public function getImageAttr(){
- // $a = UploadFile::field('file_id,file_type,storage,domain,file_path')->find($this->image_id)->external_url??'';
- // return $a;
- // }
- // public function file(){
- // return $this->hasOne('app\common\model\UploadFile', 'file_id', 'image_id');
- // }
- // /**
- // * 一对多关联商品表
- // */
- // public function activity(){
- // return $this->belongsTo('MsActivity', 'id','ms_activity_id');
- // }
- // public function add($activity_id, $data){
- // // 先删除全部
- // static::deleteAll(['ms_activity_id' => $activity_id]);
- // if (!empty($data)) {
- // // 添加
- // $dataset = [];
- // foreach ($data as $item) {
- // // 商品信息
- // // $goodsInfo = Goods::detail($item['goods_id']);
- // // if (empty($goodsInfo)) {
- // // $this->error = "商品信息错误";
- // // return false;
- // // }
- // $goods = Goods::where("goods_no",$item['goods_sku_no'])->find();
- // if (empty($goods)) {
- // $this->error = "图片skuno错误";
- // return false;
- // }
- // $dataset[] = [
- // 'ms_activity_id' => $activity_id,
- // 'goods_id' => $goods['goods_id'],
- // 'image_id'=>$item['image_id'],
- // 'goods_sku_no'=>$item['goods_sku_no']
- // ];
- // }
- // (new static)->addAll($dataset);
- // return true;
- // }
- // }
- }
|