MerchantExtendService.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace biz\sj\services;
  3. use biz\base\services\BaseService;
  4. use biz\sj\classes\MerchantExtendClass;
  5. use common\components\arrayUtil;
  6. use common\components\util;
  7. use Yii;
  8. class MerchantExtendService extends BaseService
  9. {
  10. public static $baseFile = '\biz\Sj\classes\MerchantExtendClass';
  11. public static function getBySjId($id, $returnType = false)
  12. {
  13. return MerchantExtendClass::getBySjId($id, $returnType);
  14. }
  15. //积分等级列表,带索引 ssh 2019.12.1
  16. public static function getGradeList($extend, $order = 'asc', $indexBy = true)
  17. {
  18. $gradeStr = $extend['gradeList'];
  19. $data = [];
  20. if (!empty($gradeStr)) {
  21. $arr = explode("I", $gradeStr);
  22. $arr = array_filter($arr);
  23. foreach ($arr as $key => $val) {
  24. $son = explode("_", $val);
  25. $discount = $son[2];
  26. $data[$son[0]] = ['level' => $son[0], 'growth' => $son[1], 'discount' => $discount];
  27. }
  28. }
  29. $data = arrayUtil::sort($data, 'level', $order);
  30. return $indexBy == false ? array_values($data) : $data;
  31. }
  32. //运费计算方式
  33. public static function getFreight($extend)
  34. {
  35. return ['first' => $extend['freeDistance'], 'add' => $extend['freight']];
  36. }
  37. //拓展信息列表
  38. public static function getExtendByMerchantIds($ids)
  39. {
  40. return MerchantExtendClass::getAllByCondition(['sjId' => ['in', $ids]], null, '*', 'sjId');
  41. }
  42. }