示例#1
0
 function notify_delivery($input_data)
 {
     set_error_handler(array(&$this, '_err_handler'));
     $token = $this->system->getConf('certificate.token');
     $supplier_id = $input_data['supplier_id'];
     $dealer_orderid = $input_data['dealer_order_id'];
     $_arr_delivery_ids = array();
     $_sql = sprintf('select supplier_delivery_id from sdb_delivery where order_id=%s', $dealer_orderid);
     if ($_arr_delivery_ids = $this->db->select($_sql)) {
         $_arr_delivery_ids = array_item($_arr_delivery_ids, 'supplier_delivery_id');
     }
     if (empty($_arr_delivery_ids)) {
         $_arr_delivery_ids = array(0);
         //todo:临时解决问题,需要把php4环境下的json_encode(array())不正确的情况解决掉
     }
     $_send = array('id' => $supplier_id, 'dealer_order_id' => $dealer_orderid, 'exists' => $_arr_delivery_ids, 'exists_type' => 'json');
     $api_utility = $this->system->api_call(PLATFORM, PLATFORM_HOST, PLATFORM_PATH, PLATFORM_PORT, $token);
     $delivery_items = $api_utility->getApiData('getLogisticsList', API_VERSION, $_send, true, true, 'json');
     //        exit;
     $api_utility->trigger_all_errors();
     $this->ww($delivery_items);
     //        $this->ww($_send);
     if (!$delivery_items) {
         $this->api_response('true');
     }
     //获取order信息
     $_sql = sprintf('select member_id from sdb_orders where order_id=%s', $dealer_orderid);
     if ($_order_data = $this->db->selectrow($_sql)) {
         $_order_info['member_id'] = $_order_data['member_id'];
         $_order_info['supplier_id'] = $supplier_id;
         $_order_info['order_id'] = $dealer_orderid;
     } else {
         $this->api_response('fail', 'data fail', null, '无此订单');
     }
     foreach ($delivery_items as $delivery_item) {
         if ($delivery_item['type'] == 'delivery') {
             $this->_delivery($_order_info, $delivery_item);
         } else {
             if ($delivery_item['type'] == 'return') {
                 $this->_return($_order_info, $delivery_item);
             }
         }
     }
     $this->api_response('true');
 }
示例#2
0
 function getBondGoods($pmtId)
 {
     $aTmp = $this->db->select('select * from sdb_pmt_goods where pmt_id=' . intval($pmtId));
     return array_item($aTmp, 'goods_id');
 }
 function recycle($filter)
 {
     $arrId = $filter['cpns_id'];
     if ($arrId) {
         $sSql = 'select pmt_id from sdb_coupons where cpns_id in (' . implode($arrId, ',') . ')';
         $aData = $this->db->select('select pmt_id from sdb_coupons where cpns_id in (' . implode($arrId, ',') . ')');
         if ($aData) {
             $aPmtIds = array_item($aData, 'pmt_id');
             $this->db->exec('delete from sdb_promotion where pmt_id in (' . implode($aPmtIds, ',') . ')');
         }
         $sSql = 'delete from sdb_coupons where  cpns_id in (' . implode($arrId, ',') . ')';
         if ($this->db->exec($sSql)) {
             $related_tables = array('sdb_member_coupon', 'sdb_pmt_gen_coupon');
             foreach ($related_tables as $table) {
                 $this->db->exec('delete from ' . $table . ' where  cpns_id in (' . implode($arrId, ',') . ')');
             }
             return true;
         } else {
             $msg = __('数据删除失败!');
             return false;
         }
     } else {
         $msg = 'no select';
         return false;
     }
 }
示例#4
0
 /**
  * 读取购物车中积分换赠品的兑换积分数
  * @return integer
  */
 function getCartCPoint()
 {
     $aCart = $this->getCart('f');
     $giftIds = array_keys($aCart);
     $nums = array_item($aCart, 'num');
     $count = 0;
     if ($giftIds) {
         $oGift =& $this->system->loadModel('trading/gift');
         $aGift = $oGift->getGiftByIds($giftIds);
         foreach ($aGift as $k => $item) {
             $count += $item['point'] * $nums[$k];
         }
     }
     return $count;
 }
</span>
                    </th>
                    <th>Columna</th>
                    <th>Label</th>
                    <th>Tipo</th>
                    <th>Configuraciones</th>
                    <th>PK</th>
                </tr>
                <?php 
foreach ($columnas as $oColumna) {
    $columna = (array) $oColumna;
    $es_pk = (int) $columna["primary_key"] === 1;
    $tipo_input_default = $es_pk ? "hidden" : array_item($relacion_input_tipo_columna, $columna["type"], "");
    $destacar_tr = $es_pk ? " info " : "";
    $generar_checked = (int) array_item($saved["campos"][$columna["name"]], "generar_input", 0) === 1 ? " checked " : "";
    $saved_label = array_item($saved["campos"][$columna["name"]], "label", $columna["name"]);
    ?>
                    <tr class="js-contenedor-columna <?php 
    echo $destacar_tr;
    ?>
" >
                        <td>
                            <input type="checkbox" class="js-chk-generar-campo" name='campos[<?php 
    echo $columna["name"];
    ?>
][generar_input]' value='1' <?php 
    echo $generar_checked;
    ?>
 <?php 
    echo $es_pk ? "checked readonly" : "";
    ?>
示例#6
0
 function inquiry($supplierId, $orderid, $bns)
 {
     if (empty($bns) || !is_array($bns)) {
         return false;
     }
     $api_utility =& $this->system->api_call(PLATFORM, PLATFORM_HOST, PLATFORM_PATH, PLATFORM_PORT, $this->_token);
     $result_items = array();
     $send = array('id' => $supplierId, 'bns' => array_keys($bns));
     $inquiry_result = $api_utility->getApiData('inquiry', API_VERSION, $send);
     $api_utility->trigger_all_errors();
     $store_mark = 0;
     //询价单是否有货
     foreach ($inquiry_result as $k => $item) {
         $result_items[$k] = array('supplier_bn' => $item['bn'], 'po_price' => $item['price'], 'stock' => $item['stock']);
         if ($item['status'] == 'normal') {
             if ($item['stock'] === null || $item['store'] === '') {
                 $result_items[$k]['stock_status'] = 0;
                 //库存充足
                 $store_mark = 1;
             } else {
                 if ($item['stock'] > $bns[$item['bn']] + $item['threshold']) {
                     //库存充足
                     $result_items[$k]['stock_status'] = 0;
                     $store_mark = 1;
                 } else {
                     if ($item['stock'] > $bns[$item['bn']]) {
                         //库存紧张
                         $result_items[$k]['stock_status'] = 1;
                         $store_mark = 1;
                     } else {
                         if ($item['stock'] > 0) {
                             $result_items[$k]['stock_status'] = 2;
                             $store_mark = 1;
                         } else {
                             $result_items[$k]['stock_status'] = 3;
                         }
                     }
                 }
             }
         }
         $result_items[$k]['status'] = $item['status'];
     }
     $_s2l_cr = $this->get_s2lBns(array_item($result_items, 'supplier_bn'), true);
     $_where_bns = array();
     // 成本价同步
     $oCostSync = $this->system->loadModel('distribution/costsync');
     foreach ($result_items as $_k => $_item) {
         $result_items[$_k]['dealer_bn'] = $_s2l_cr[$_item['supplier_bn']];
         $result_items[$_k]['nums'] = $bns[$_item['supplier_bn']];
         $_where_bns[] = sprintf('\'%s\'', addslashes($result_items[$_k]['dealer_bn']));
         // 获取到货品的goods_id 因为有人来商品链接要用到 2009-12-16 11:12 wubin
         $sSql = 'SELECT i.name,i.price, i.product_id,p.goods_id FROM sdb_order_items AS i
                 LEFT JOIN sdb_products AS p ON p.product_id = i.product_id WHERE i.bn=\'' . $result_items[$_k]['dealer_bn'] . '\' and i.order_id=' . $orderid;
         $aProduct = $this->db->selectrow($sSql);
         // 如果产品被删除除的话 产品信息从sdb_order_items上取 2010-01-26 18:56 wubin
         if (empty($aProduct)) {
             $sSql = 'SELECT i.name,i.price, i.product_id,i.bn 
                      FROM sdb_order_items AS i 
                      LEFT JOIN sdb_supplier_pdtbn AS s ON s.local_bn = i.bn 
                      WHERE s.source_bn=\'' . $_item['supplier_bn'] . '\' and i.order_id=' . $orderid;
             $aProduct = $this->db->selectrow($sSql);
             // 更新sdb_order_items 2010-01-28 14:46 wubin 将原订单的货BN号更新成最新的BN
             $sSql = "SELECT product_id FROM sdb_products WHERE bn ='" . $result_items[$_k]['dealer_bn'] . "'";
             $aTemp = $this->db->selectrow($sSql);
             // 如果能在数据库中找到对应的货品数据,将订单的bn,product_id 更新
             if ($aTemp) {
                 $aTemp['bn'] = $result_items[$_k]['dealer_bn'];
                 $rs = $this->db->exec("SELECT * FROM sdb_order_items WHERE order_id='" . $orderid . "' AND bn='" . $aProduct['bn'] . "'");
                 $sSql = $this->db->getUpdateSql($rs, $aTemp);
                 $this->db->exec($sSql);
             }
             unset($aProduct['bn']);
         }
         $result_items[$_k] = array_merge((array) $aProduct, $result_items[$_k]);
         // 更新货品成本价 wubin 2009-09-15 14:29:12
         $oCostSync->updateAloneProductCost($aProduct['product_id'], $_item['po_price']);
     }
     $_sql = sprintf('select bn as dealer_bn,nums,supplier_id from sdb_order_items where order_id=%s and bn in(%s)', $orderid, implode(',', $_where_bns));
     $_order_items = $this->db->select($_sql);
     $_order_items = array_change_key($_order_items, 'dealer_bn');
     $result_total_amount = 0;
     //总价
     foreach ($result_items as $_k => $_item) {
         //如果货品已经指定为某个供应商货品,
         if ($_order_items[$_item['dealer_bn']]['supplier_id'] !== null) {
             $result_items[$_k]['store'] += $_order_items[$_item['dealer_bn']]['nums'];
         }
         //通过更新的库存计算amount
         if ($_item['stock'] <= 0) {
             $result_items[$_k]['stock'] = 0;
         }
         $result_items[$_k]['amount'] = $bns[$_item['supplier_bn']] * $_item['po_price'];
         $result_total_amount += $result_items[$_k]['amount'];
         //如果库存为''/null 则将库存状态置为-1
         if ($_item['stock'] == null || $_item['stock'] == '') {
             $result_items[$_k]['stock'] = -1;
         }
         $_data = array('store' => $result_items[$_k]['stock'] != -1 ? $result_items[$_k]['stock'] : null);
         $_sql = sprintf('SELECT * FROM sdb_products WHERE bn=\'%s\'', addslashes($_item['dealer_bn']));
         $rs = $this->db->exec($_sql);
         $_sql = $this->db->getUpdateSql($rs, $_data);
         $this->db->exec($_sql);
     }
     $result_items = array_change_key($result_items, 'dealer_bn');
     $result = array('items' => $result_items, 'store_status' => $store_mark, 'total_amount' => $result_total_amount);
     return $result;
 }