Beispiel #1
0
/**
 * 根据渠道id获取运输方式
 * @param int $id 运输方式id
 * @return string
 * @author lzx
 */
function get_carriernamebyid($id)
{
    $carrierlist = M('InterfaceTran')->key('id')->getCarrierList(2);
    $chenellists = M('InterfaceTran')->getChannelList();
    foreach ($chenellists as $value) {
        $chenellist[$value['id']] = $value['channelName'];
    }
    if (strpos("{$id}", ",")) {
        $idarr = explode(",", $id);
        $returnData = returnTCArrFromChannelIdArr($idarr);
        $returnDataNa = array();
        $carrnaArr = array();
        foreach ($returnData as $key => $chenel) {
            $carrnaArr = array();
            foreach ($chenel as $value) {
                $carrnaArr[] = $chenellist[$value];
            }
            $returnDataNa[$carrierlist[$key]['carrierNameCn']] = $carrnaArr;
        }
        $returnDataNa = Tarr2Str($returnDataNa, ":", ",", "   ");
        return $returnDataNa;
    } else {
        $returnData = returnTCArrFromChannelIdArr(array($id));
        $returnDataNa = array();
        foreach ($returnData as $key => $chenel) {
            $carrnaArr = array();
            foreach ($chenel as $value) {
                $carrnaArr[] = $chenellist[$value];
            }
            $returnDataNa[$carrierlist[$key]['carrierNameCn']] = $carrnaArr;
        }
        $returnDataNa = Tarr2Str($returnDataNa, ":", ",", "   ");
        return $returnDataNa;
    }
}
 /**
  * 提供错误信息列表
  * @return array
  * @author lzx
  */
 public function act_getTransportStrategyLists()
 {
     $data = array();
     $data['is_delete'] = array('$e' => 0);
     if (isset($_GET['accountId']) > 0) {
         $data['id'] = array('$e' => intval($_GET['accountId']));
     }
     $accountList = M('Account')->getAccountList($data, $this->page, $this->perpage);
     //print_r(M('InterfaceTran')->key('id')->getAllCountryList());exit;
     //print_r(C('TRANSPORT_STRATEGY_CURRENCY_ARRAY'));exit;
     if (!empty($accountList)) {
         $TSObject = M('TransportStrategy');
         $carrierlist = M('InterfaceTran')->key('id')->getCarrierList(2);
         //id=>array()
         $channelList = M('InterfaceTran')->key('id')->getChannelList();
         //id=>array()
         //print_r($channelList);exit;
         $countryList = M('InterfaceTran')->key('id')->getAllCountryList();
         $currencyList = C('TRANSPORT_STRATEGY_CURRENCY_ARRAY');
         foreach ($accountList as $k => $v) {
             $constraintTypeList = $TSObject->getAccountConstraintTypeByAccountId($v['id']);
             $constraintTypeList = $constraintTypeList[0];
             $accountList[$k]['constraintType'] = $constraintTypeList;
             $constraintTypeStrArr = array();
             if (!empty($constraintTypeList)) {
                 $constraintTypeStrArr['isSpecialSpuForce'] = $constraintTypeList['isSpecialSpuForce'] == 1 ? '允许特殊料号运输方式' : '无视特殊料号运输方式';
                 $constraintTypeStrArr['isPlatOrAccountPri'] = $constraintTypeList['isPlatOrAccountPri'] == 1 ? '平台优先' : '账号优先';
             }
             $accountList[$k]['accountConstraintTypeStr'] = implode(',', array_filter($constraintTypeStrArr));
             //账号约束/优先级显示字符串
             $conditionTransportList = $TSObject->getConditionTransportByAccountId($v['id']);
             if (!empty($conditionTransportList[0]['channelIdStr'])) {
                 $conditionTransportList[0]['transportIdArr'] = explode(',', $conditionTransportList[0]['channelIdStr']);
             }
             $accountList[$k]['conditionTransport'] = $conditionTransportList[0];
             $tmpChannelNameArr = array();
             $returnTCArr = returnTCArrFromChannelIdArr(explode(',', $conditionTransportList[0]['channelIdStr']));
             //print_r($returnTCArr);
             foreach ($returnTCArr as $tmpTransportId => $tmpChannelIdArr) {
                 foreach ($tmpChannelIdArr as $tmpChannelId) {
                     $tmpChannelNameArr[$carrierlist[$tmpTransportId]['carrierNameCn']][] = $channelList[$tmpChannelId]['channelName'];
                 }
             }
             //print_r($tmpChannelNameArr);exit;
             $accountList[$k]['conditionTransportStr'] = Tarr2Str($tmpChannelNameArr);
             //基础运输方式ids渠道ids对应名称字符串
             $conditionCountryList = $TSObject->getConditionCountryByAccountId($v['id']);
             //国家对应transportId的json字符串
             $countryTransportArr = explode('&', $conditionCountryList[0]['countryId_channelIdStr']);
             //每个数组是countryId和channelId的关系字符串
             if (!empty($countryTransportArr)) {
                 $tmpConditionCountryArr = array();
                 foreach ($countryTransportArr as $ctStr) {
                     //$ctStr 每个数组是countryId和transportId的关系字符串
                     $tmpArr = array();
                     $ctStrArr = explode(':', $ctStr);
                     //$ctStrArr 0为countryIds,1为channelIds
                     $tmpCountryIdArr = array();
                     $tmpCountryNameArr = array();
                     $tmpTransportIdArr = array();
                     $tmpTransportNameArr = array();
                     if (!empty($ctStrArr[0]) && !empty($ctStrArr[1])) {
                         //$ctStrArr 0为countryIds,1为transportIds 都不为空
                         foreach (explode(',', $ctStrArr[0]) as $tmpCountryId) {
                             $tmpCountryIdArr[] = $tmpCountryId;
                             //国家id
                             $tmpCountryNameArr[] = $countryList[$tmpCountryId]['countryNameEn'];
                             //国家英文名
                         }
                         $tmpArr['countryIdArr'] = $tmpCountryIdArr;
                         $tmpArr['countryNameArr'] = $tmpCountryNameArr;
                         foreach (explode(',', $ctStrArr[1]) as $tmpChannelId) {
                             $tmpTransportIdArr[] = $tmpChannelId;
                             //运输方式id
                             //$tmpTransportNameArr[] = $channelList[$tmpChannelId]['channelName'];//运输方式中文名
                         }
                         $tmpArr['transportIdArr'] = $tmpTransportIdArr;
                         $returnTCArr = returnTCArrFromChannelIdArr($tmpTransportIdArr);
                         $tmpChannelNameArr = array();
                         foreach ($returnTCArr as $tmpTransportId => $tmpChannelIdArr) {
                             foreach ($tmpChannelIdArr as $tmpChannelId) {
                                 $tmpChannelNameArr[$carrierlist[$tmpTransportId]['carrierNameCn']][] = $channelList[$tmpChannelId]['channelName'];
                             }
                         }
                         $tmpArr['transportNameArr'] = Tarr2Str($tmpChannelNameArr);
                         $tmpArr['priority'] = $conditionCountryList[0]['priority'];
                     }
                     if (!empty($tmpArr)) {
                         $tmpConditionCountryArr[] = $tmpArr;
                     }
                 }
                 $accountList[$k]['conditionCountry'] = $tmpConditionCountryArr;
                 $conditionCountryStr = '';
                 foreach ($tmpConditionCountryArr as $v3) {
                     $conditionCountryStr .= implode(',', $v3['countryNameArr']) . ':' . $v3['transportNameArr'] . '&';
                 }
                 if ($conditionCountryStr != '') {
                     $conditionCountryStr .= '优先级:' . $tmpConditionCountryArr[0]['priority'];
                 }
                 $accountList[$k]['conditionCountryStr'] = $conditionCountryStr;
             }
             $conditionCurrencyList = $TSObject->getConditionCurrencyByAccountId($v['id']);
             //币种对应transportId的json字符串
             $currencyTransportArr = json_decode($conditionCurrencyList[0]['currencyId_channelIdJson'], true);
             if (!empty($currencyTransportArr) && is_array($currencyTransportArr)) {
                 $currencyTransportIdStrArr = array();
                 foreach ($currencyTransportArr as $currencyId => $currencyTransportIdArr) {
                     $tmpCurrencyStr = $currencyList[$currencyId]['CN'];
                     $tmpCurrencyTransportNameArr = array();
                     $returnTCArr = returnTCArrFromChannelIdArr($currencyTransportIdArr);
                     $tmpChannelNameArr = array();
                     foreach ($returnTCArr as $tmpTransportId => $tmpChannelIdArr) {
                         foreach ($tmpChannelIdArr as $tmpChannelId) {
                             $tmpChannelNameArr[$carrierlist[$tmpTransportId]['carrierNameCn']][] = $channelList[$tmpChannelId]['channelName'];
                         }
                     }
                     $currencyTransportIdStrArr[] = $tmpCurrencyStr . '->' . Tarr2Str($tmpChannelNameArr);
                 }
                 $accountList[$k]['conditionCurrency'] = $currencyTransportArr;
                 $accountList[$k]['conditionCurrencyPriority'] = $conditionCurrencyList[0]['priority'];
                 $accountList[$k]['conditionCurrencyStr'] = implode('&', $currencyTransportIdStrArr) . '&' . '优先级:' . $conditionCurrencyList[0]['priority'];
             }
             $conditionAmountList = $TSObject->getConditionAmountByAccountId($v['id']);
             //金额
             $conditionAmountList = $conditionAmountList[0];
             $accountList[$k]['conditionAmount'] = $conditionAmountList;
             if (!empty($conditionAmountList)) {
                 $conditionStr1 = '';
                 $conditionStr2 = '';
                 if (!empty($conditionAmountList['symbolCondition1'])) {
                     $conditionStr1 = "条件:" . $conditionAmountList['symbolCondition1'] . ' ' . $conditionAmountList['amountCondition1'];
                 }
                 if (!empty($conditionAmountList['symbolCondition2'])) {
                     $conditionStr2 = "条件:" . $conditionAmountList['symbolCondition2'] . ' ' . $conditionAmountList['amountCondition2'];
                 }
                 $allowTypeStr = $conditionAmountList['allowType'] == 1 ? '满足一项' : '满足所有';
                 $tmpTransportIdArr = explode(',', $conditionAmountList['channelIdStr']);
                 $tmpTransportNameArr = array();
                 $tmpTransportStr = '';
                 if (!empty($tmpTransportIdArr)) {
                     $returnTCArr = returnTCArrFromChannelIdArr($tmpTransportIdArr);
                     $tmpChannelNameArr = array();
                     foreach ($returnTCArr as $tmpTransportId => $tmpChannelIdArr) {
                         foreach ($tmpChannelIdArr as $tmpChannelId) {
                             $tmpChannelNameArr[$carrierlist[$tmpTransportId]['carrierNameCn']][] = $channelList[$tmpChannelId]['channelName'];
                         }
                     }
                     $tmpTransportStr = Tarr2Str($tmpChannelNameArr);
                     if ($tmpTransportStr != '') {
                         $tmpTransportStr = '[' . $tmpTransportStr . ']';
                     }
                 }
                 $tmpPriorityStr = "(优先级:" . $conditionAmountList['priority'] . ")";
                 $accountList[$k]['conditionAmountTransportIdArr'] = $tmpTransportIdArr;
                 $accountList[$k]['conditionAmountStr'] = implode(',', array($conditionStr1, $conditionStr2, $allowTypeStr, $tmpPriorityStr, $tmpTransportStr));
                 //金额-约束
             }
         }
     }
     //print_r($accountList);exit;
     return $accountList;
 }