CustomerSpec.php 817 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\common\model;
  4. use think\Model;
  5. class CustomerSpec Extends Model
  6. {
  7. const NORMAL = 1;
  8. const DELETE = 0;
  9. //customer
  10. public function customer()
  11. {
  12. return $this->hasOne(Customer::class,'id','customer_id');
  13. }
  14. //获取客户规格
  15. public static function getBoxId(int $customer_id, int $type_id, int $spec_id): object
  16. {
  17. return self::alias('a')
  18. ->leftjoin('stock_config b', 'a.box_id = b.id')
  19. ->leftjoin('stock_config c', 'a.type_id = c.id')
  20. ->where('a.customer_id', $customer_id)->where('a.type_id', $type_id)->where('a.product_id', $spec_id)
  21. ->field('a.price,b.id,b.title as box_name,c.title as variety_name')
  22. ->findOrEmpty();
  23. }
  24. }