ActivityProductModel.php 870 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\model;
  3. class ActivityProductModel extends BaseModel
  4. {
  5. protected $table = 'erp_activity_product';
  6. protected function genSchema(array $schema)
  7. {
  8. // TODO: Implement genSchema() method.
  9. }
  10. public function product() {
  11. return $this->hasOne(ProductModel::class,'id','product_id');
  12. }
  13. public function doesItExist($activity_id,$product_id) {
  14. return $this->where([
  15. ["product_id", '=', $product_id],
  16. ["activity_id", '=', $activity_id],
  17. ["is_delete", '=', 0]
  18. ])->find();
  19. }
  20. public function fetchByProductIds(array $p_ids) {
  21. return $this->where([
  22. ['is_delete', '=', 0],
  23. ['product_id', 'in', $p_ids],
  24. ['start_time', '<=', time()],
  25. ['end_time', '>=', time()],
  26. ])->select();
  27. }
  28. }