ZaActivityRelation.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\common\model\za;
  4. use app\common\model\Goods;
  5. use app\common\model\GoodsSku;
  6. use app\common\model\BaseModel;
  7. use app\common\model\UploadFile;
  8. /**
  9. * 活动中心 ▸买一赠一活动 关联数据
  10. * Class Ad
  11. * @package app\common\model
  12. */
  13. class ZaActivityRelation extends BaseModel
  14. {
  15. protected $name = 'za_activity_relations';
  16. // protected $append = ['image'];
  17. // public function getImageAttr(){
  18. // $a = UploadFile::field('file_id,file_type,storage,domain,file_path')->find($this->image_id)->external_url??'';
  19. // return $a;
  20. // }
  21. // public function file(){
  22. // return $this->hasOne('app\common\model\UploadFile', 'file_id', 'image_id');
  23. // }
  24. // /**
  25. // * 一对多关联商品表
  26. // */
  27. // public function activity(){
  28. // return $this->belongsTo('MsActivity', 'id','ms_activity_id');
  29. // }
  30. // public function add($activity_id, $data){
  31. // // 先删除全部
  32. // static::deleteAll(['ms_activity_id' => $activity_id]);
  33. // if (!empty($data)) {
  34. // // 添加
  35. // $dataset = [];
  36. // foreach ($data as $item) {
  37. // // 商品信息
  38. // // $goodsInfo = Goods::detail($item['goods_id']);
  39. // // if (empty($goodsInfo)) {
  40. // // $this->error = "商品信息错误";
  41. // // return false;
  42. // // }
  43. // $goods = Goods::where("goods_no",$item['goods_sku_no'])->find();
  44. // if (empty($goods)) {
  45. // $this->error = "图片skuno错误";
  46. // return false;
  47. // }
  48. // $dataset[] = [
  49. // 'ms_activity_id' => $activity_id,
  50. // 'goods_id' => $goods['goods_id'],
  51. // 'image_id'=>$item['image_id'],
  52. // 'goods_sku_no'=>$item['goods_sku_no']
  53. // ];
  54. // }
  55. // (new static)->addAll($dataset);
  56. // return true;
  57. // }
  58. // }
  59. }