Ejemplo n.º 1
0
 public function actionAjaxGet()
 {
     $modules = UtilD::read_modules(\Yii::getAlias('@ext') . '/shipping');
     for ($i = 0; $i < count($modules); $i++) {
         $sql = "SELECT id, shipping_name, shipping_desc, insure, support_cod,shipping_order FROM " . Shipping::tableName() . " WHERE shipping_code='" . $modules[$i]['code'] . "' ORDER BY shipping_order";
         $row = \Yii::$app->getDb()->createCommand($sql)->queryOne();
         if ($row) {
             //如果已安装插件
             $modules[$i]['id'] = $row['id'];
             $modules[$i]['name'] = $row['shipping_name'];
             $modules[$i]['desc'] = $row['shipping_desc'];
             $modules[$i]['insure_fee'] = $row['insure'] ? doubleval($row['insure']) . "%" : 0;
             $modules[$i]['cod'] = $row['support_cod'];
             $modules[$i]['shipping_order'] = $row['shipping_order'];
             $modules[$i]['install'] = 1;
             if (isset($modules[$i]['insure']) && $modules[$i]['insure'] === false) {
                 $modules[$i]['is_insure'] = 0;
             } else {
                 $modules[$i]['is_insure'] = 1;
             }
             $modules[$i]['manage'] = '<a href="' . Url::toRoute(['/shipping/uninstall', 'code' => $modules[$i]['code']]) . '">' . \Yii::t('shipping', 'uninstall') . '</a>';
             $modules[$i]['manage'] .= ' | <a href="' . Url::toRoute(['/shipping-area/list', 'shipping' => $row['id']]) . '">' . \Yii::t('shipping', 'shipping_area') . '</a>';
             $modules[$i]['manage'] .= ' | <a href="' . Url::toRoute(['/shipping/edit-print-template', 'shipping' => $row['id']]) . '">' . \yii::t('shipping', 'shipping_print_edit') . '</a>';
         } else {
             $modules[$i]['name'] = \Yii::t($modules[$i]['code'], $modules[$i]['code']);
             $modules[$i]['desc'] = \Yii::t($modules[$i]['code'], $modules[$i]['desc']);
             $modules[$i]['insure_fee'] = empty($modules[$i]['insure']) ? 0 : doubleval($modules[$i]['insure']) . "%";
             $modules[$i]['cod'] = $modules[$i]['cod'];
             $modules[$i]['install'] = 0;
             $modules[$i]['manage'] = '<a href="' . Url::toRoute(['/shipping/install', 'code' => $modules[$i]['code']]) . '">' . \yii::t('shipping', 'install') . '</a>';
         }
     }
     exit(Json::encode($modules));
 }
Ejemplo n.º 2
0
 public function actionAjaxGet()
 {
     $mode = new Payment();
     $pay_list = $mode->getEnabledPay();
     $modules = UtilD::read_modules(\Yii::getAlias('@ext') . '/payment');
     $data = ['total' => 0, 'rows' => []];
     foreach ($modules as $key => $val) {
         $code = $val['code'];
         $data['rows'][$key] = $val;
         $data['rows'][$key]['pay_code'] = $code;
         //如果数据库中有支付方式,取数据库中的名称和描述
         if (isset($pay_list[$code])) {
             $data['rows'][$key]['name'] = $pay_list[$code]['pay_name'];
             $data['rows'][$key]['pay_fee'] = $pay_list[$code]['pay_fee'];
             $data['rows'][$key]['is_cod'] = $pay_list[$code]['is_cod'];
             $data['rows'][$key]['desc'] = $pay_list[$code]['pay_desc'];
             $data['rows'][$key]['pay_order'] = $pay_list[$code]['pay_order'];
             $data['rows'][$key]['install'] = true;
             $data['rows'][$key]['manage'] = '<a href="' . Url::to(['/payment/uninstall', 'code' => $code]) . '" onclick="if(confirm(\'确定删除吗?\') == false) return false">卸载</a>
                 &nbsp;&nbsp;<a href="' . Url::to(['/payment/edit', 'code' => $code]) . '">编辑</a>';
         } else {
             $data['rows'][$key]['name'] = \Yii::t($val['code'], $val['code']);
             if (!isset($val['pay_fee'])) {
                 $data['rows'][$key]['pay_fee'] = 0;
             } else {
                 $data['rows'][$key]['pay_fee'] = $val['pay_fee'];
             }
             $data['rows'][$key]['is_cod'] = $val['is_cod'];
             $data['rows'][$key]['pay_order'] = 1;
             $data['rows'][$key]['desc'] = \Yii::t($val['code'], $val['desc']);
             $data['rows'][$key]['install'] = false;
             if (in_array($code, ['tenpay', 'tenpayc2c'])) {
                 if ($code == 'tenpay') {
                     $data['rows'][$key]['manage'] = '<a href="' . Url::to(['/payment/install', 'code' => $code]) . '">安装即时到账</a><br>';
                 } else {
                     $data['rows'][$key]['manage'] = '<a href="' . Url::to(['/payment/install', 'code' => $code]) . '">安装中介担保</a><br>';
                 }
             } else {
                 $data['rows'][$key]['manage'] = '<a href="' . Url::to(['/payment/install', 'code' => $code]) . '">安装</a>';
             }
         }
         $data['total']++;
     }
     exit(Json::encode($data));
 }