ProductAttrValue.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\store\product;
  12. use app\common\model\BaseModel;
  13. class ProductAttrValue extends BaseModel
  14. {
  15. /**
  16. * @Author:Qinii
  17. * @Date: 2020/5/8
  18. * @return string
  19. */
  20. public static function tablePk(): string
  21. {
  22. return '';
  23. }
  24. /**
  25. * @Author:Qinii
  26. * @Date: 2020/5/8
  27. * @return string
  28. */
  29. public static function tableName(): string
  30. {
  31. return 'store_product_attr_value';
  32. }
  33. public function getDetailAttr($value)
  34. {
  35. return json_decode($value);
  36. }
  37. public function getBcExtensionOneAttr()
  38. {
  39. if(!intval(systemConfig('extension_status'))) return 0;
  40. if($this->extension_one > 0) return $this->extension_one;
  41. return floatval(round(bcmul(systemConfig('extension_one_rate'), $this->price, 3),2));
  42. }
  43. public function getBcExtensionTwoAttr()
  44. {
  45. if(!intval(systemConfig('extension_status'))) return 0;
  46. if($this->extension_two > 0) return $this->extension_two;
  47. return floatval(round(bcmul(systemConfig('extension_two_rate'), $this->price, 3),2));
  48. }
  49. public function searchUniqueAttr($query,$value)
  50. {
  51. $query->where('unique',$value);
  52. }
  53. public function searchSkuAttr($query,$value)
  54. {
  55. $query->where('sku',$value);
  56. }
  57. public function searchProductIdAttr($query,$value)
  58. {
  59. $query->where('product_id',$value);
  60. }
  61. }