| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace bizHd\member\classes;
- use common\components\dict;
- use Yii;
- use bizHd\base\classes\BaseClass;
- class MemberLevelClass extends BaseClass
- {
- public static $baseFile = '\bizHd\member\models\MemberLevel';
- public static function initData($shop)
- {
- $mainId = $shop['mainId'];
- $shopId = $shop['id'];
- $has = self::getByCondition(['mainId' => $mainId], true);
- if (!empty($has)) {
- return true;
- }
- $map = dict::getDict('memberLevelMap');
- foreach ($map as $k => $v) {
- $v['mainId'] = $mainId;
- $v['shopId'] = $shopId;
- if (!isset($v['discount'])) {
- $v['discount'] = 10;
- }
- if (!isset($v['birthdayBenefit'])) {
- $v['birthdayBenefit'] = '';
- }
- if (!isset($v['benefitDesc'])) {
- $v['benefitDesc'] = '';
- }
- self::add($v);
- }
- return true;
- }
- }
|