Exemple #1
0
 /**
  * get qrcodeId name:struct array(qrcodeId=>value)
  * @param $qrcodeIds,array
  */
 public static function getQrcodeName($qrcodeIds)
 {
     $data = [];
     //promotion qrcode only check in store and staff
     if (!empty($qrcodeIds)) {
         $where = Store::createStoreChannelCondition($qrcodeIds);
         $storeInfos = Store::findAll($where);
         $storeIds = [];
         if (!empty($storeInfos)) {
             $model = new Store();
             $channels = $model->storeChannels;
             foreach ($storeInfos as $storeInfo) {
                 foreach ($channels as $channel) {
                     if (!empty($channel = $storeInfo->{$channel})) {
                         $storeIds[] = $channel['qrcodeId'];
                         $data[$channel['qrcodeId']] = $storeInfo->name;
                     }
                 }
             }
         }
         //get staff qrcode
         $staffIds = array_values(array_diff($qrcodeIds, $storeIds));
         $where = ['qrcodeId' => ['$in' => $staffIds]];
         $staffInfos = Staff::findAll($where);
         if (!empty($staffIds)) {
             foreach ($staffInfos as $staffInfo) {
                 $name = '';
                 if (!empty($staffInfo->name)) {
                     $name = $staffInfo->name;
                 }
                 $data[$staffInfo->qrcodeId] = '店员' . $name . '二维码';
             }
         }
     }
     return $data;
 }