ProductAttrValue.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\common\model\store\product;
  3. use app\common\model\BaseModel;
  4. class ProductAttrValue extends BaseModel
  5. {
  6. /**
  7. * @Author:Qinii
  8. * @Date: 2020/5/8
  9. * @return string
  10. */
  11. public static function tablePk(): string
  12. {
  13. return '';
  14. }
  15. /**
  16. * @Author:Qinii
  17. * @Date: 2020/5/8
  18. * @return string
  19. */
  20. public static function tableName(): string
  21. {
  22. return 'store_product_attr_value';
  23. }
  24. public function getDetailAttr($value)
  25. {
  26. return json_decode($value);
  27. }
  28. public function getBcExtensionOneAttr()
  29. {
  30. if(!intval(systemConfig('extension_status'))) return 0;
  31. if($this->extension_one > 0) return $this->extension_one;
  32. return floatval(round(bcmul(systemConfig('extension_one_rate'), $this->price, 3),2));
  33. }
  34. public function getBcExtensionTwoAttr()
  35. {
  36. if(!intval(systemConfig('extension_status'))) return 0;
  37. if($this->extension_two > 0) return $this->extension_two;
  38. return floatval(round(bcmul(systemConfig('extension_two_rate'), $this->price, 3),2));
  39. }
  40. public function searchUniqueAttr($query,$value)
  41. {
  42. $query->where('unique',$value);
  43. }
  44. public function searchSkuAttr($query,$value)
  45. {
  46. $query->where('sku',$value);
  47. }
  48. public function searchProductIdAttr($query,$value)
  49. {
  50. $query->where('product_id',$value);
  51. }
  52. }