| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace bizGhs\custom\classes;
- use bizGhs\merchant\classes\MerchantClass;
- use common\components\business;
- use common\components\util;
- use Yii;
- use biz\base\classes\BaseClass;
- class CustomClass extends BaseClass
- {
- public static $baseFile = '\bizGhs\custom\models\Custom';
- //获取客户信息 shish 2021.2.4
- public static function getCustom($id)
- {
- $info = self::getById($id);
- $respond = self::groupBaseInfo([$info]);
- return current($respond);
- }
- public static function getCustomByIds($ids)
- {
- $list = self::getByIds($ids, null, 'id');
- return self::groupBaseInfo($list);
- }
- //整合头像等信息 shish 2021.1.8
- public static function groupBaseInfo($list)
- {
- if (empty($list)) {
- return $list;
- }
- //获取客户信息
- $downIdList = array_unique(array_filter(array_column($list, 'downId')));
- $retailInfo = MerchantClass::getByIds($downIdList, null, 'id');
- foreach ($list as $key => $val) {
- $downId = $val['downId'];
- $currentInfo = isset($retailInfo[$downId]) ? $retailInfo[$downId] : [];
- //组合头像
- $currentInfo = business::formatMerchantLogo($currentInfo);
- $list[$key]['smallAvatar'] = isset($currentInfo['smallLogoUrl']) ? $currentInfo['smallLogoUrl'] : '';
- $list[$key]['avatar'] = isset($currentInfo['logoUrl']) ? $currentInfo['logoUrl'] : '';
- $list[$key]['visitTime'] = '06-11 12:50';
- $list[$key]['level'] = 0;
- }
- return $list;
- }
- //欠款权限开关 shish 2021.1.8
- public static function debt($custom, $debt)
- {
- $id = isset($custom['id']) ? $custom['id'] : 0;
- self::updateById($id, ['debt' => $debt]);
- return true;
- }
- //权限判断 shish 2021.1.8
- public static function valid($custom, $merchantId)
- {
- if (empty($custom)) {
- util::fail('没有找到客户');
- }
- if ($custom['merchantId'] != $merchantId) {
- util::fail('您没有权限操作此客户');
- }
- }
- }
|