本文整理汇总了PHP中utils::array_change_key方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::array_change_key方法的具体用法?PHP utils::array_change_key怎么用?PHP utils::array_change_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::array_change_key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _init_config
/**
* 初始化商品促销过滤.
*
* @param array $aGoodsId // array(xxx,xxx,xxx);
*/
private function _init_config($goods_id_arr, $filter = array())
{
if (empty($goods_id_arr)) {
return false;
}
$filter['goods_id'] = $goods_id_arr;
$current_member = vmc::singleton('b2c_cart_stage')->get_member();
if (!$filter['member_lv']) {
$filter['member_lv'] = $current_member['member_lv'] ? $current_member['member_lv'] : -1;
}
//开启的促销
$where[] = "pref.status = 'true'";
//一定商品范围的促销
$where[] = 'pref.goods_id IN (' . implode(',', $filter['goods_id']) . ')';
//一定会员级别的促销
$where[] = ' (find_in_set(\'' . $filter['member_lv'] . '\', pref.member_lv_ids))';
//促销时间限制
if (!empty($filter['current_time'])) {
$where[] = sprintf('(%s >= pref.from_time or pref.from_time=0)', $filter['current_time']);
$where[] = sprintf('(%s <= pref.to_time or pref.to_time=0)', $filter['current_time']);
}
$SQL = 'SELECT pref.*,srg.name,srg.s_template
FROM vmc_b2c_sales_rule_goods AS srg
JOIN vmc_b2c_goods_promotion_ref AS pref ON pref.rule_id = srg.rule_id
WHERE ' . implode(' AND ', $where) . '
ORDER BY pref.sort_order ASC,pref.ref_id DESC';
$res = vmc::database()->select($SQL);
if (empty($res)) {
return false;
}
return utils::array_change_key($res, 'goods_id', true);
}
示例2: index
public function index($status = 'all', $page = 1)
{
$mdl_order = app::get('b2c')->model('orders');
$mdl_order_items = app::get('b2c')->model('order_items');
$limit = 5;
$status_filter = $mdl_order->filter();
$this->pagedata['status'] = $status;
$filter = $status_filter[$status];
$filter['store_id'] = $this->store['store_id'];
$order_list = $mdl_order->getList('*', $filter, ($page - 1) * $limit, $limit);
foreach ($order_list as $key => $value) {
//所属店铺信息
$store_info = vmc::singleton('store_store_object')->store_info($value['store_id'], 'store_id, store_name');
$order_list[$key]['store_name'] = $store_info['store_name'];
}
$oids = array_keys(utils::array_change_key($order_list, 'order_id'));
$order_items = $mdl_order_items->getList('*', array('order_id' => $oids));
$order_items_group = utils::array_change_key($order_items, 'order_id', true);
$order_count = $mdl_order->count($filter);
$this->pagedata['type'] = 'orders';
$this->pagedata['current_status'] = $status;
$this->pagedata['status_map'] = $status_filter;
$this->pagedata['order_list'] = $order_list;
$this->pagedata['order_count'] = $order_count;
$this->pagedata['order_items_group'] = $order_items_group;
$this->pagedata['pager'] = array('total' => ceil($order_count / $limit), 'current' => $page, 'link' => array('app' => 'b2c', 'ctl' => 'site_member', 'act' => 'orders', 'args' => array($status, $token = time())), 'token' => $token);
$this->output();
}
示例3: check_favs
/**
*批量确认收藏及数量
*/
public function check_favs($member_id = null, $goods_id = null)
{
if (!$goods_id || !is_array($goods_id)) {
return false;
}
$filter['goods_id'] = $goods_id;
$filter['type'] = 'fav';
$fav_list = $this->getList('member_id,goods_id', $filter);
$fav_list_group = utils::array_change_key($fav_list, 'goods_id', true);
foreach ($fav_list_group as $gid => $fav_group) {
$tmp_fav_group = utils::array_change_key($fav_group, 'member_id');
$tmp_fav_group = array_keys($tmp_fav_group);
$fav_count = count($tmp_fav_group);
if (in_array($member_id, $tmp_fav_group)) {
$is_fav = true;
} else {
$is_fav = false;
}
unset($fav_list_group[$gid]);
$fav_list_group[$gid]['goods_id'] = $gid;
$fav_list_group[$gid]['is_fav'] = $is_fav;
$fav_list_group[$gid]['fav_count'] = $fav_count;
}
return array_values($fav_list_group);
}
示例4: column_tag
public function column_tag(&$colList, $list)
{
//todo 如果list为空则 retunn
if (!$list) {
return;
}
$idColumnKey = $list[0]['idColumn'];
$appId = $list[0]['app_id'];
$tagType = $list[0]['tag_type'];
$list = utils::array_change_key($list, $idColumnKey);
// 获取所有当前finder主键列表
$relatedIds = array_keys(utils::array_change_key($list, $idColumnKey));
$filter = array('rel_id' => $relatedIds, 'tag_type' => $tagType, 'app_id' => $appId);
// 获取tag列表
$tagRows = app::get('desktop')->model('tag_rel')->getList('tag_id, rel_id', $filter);
/*-----start------>*/
$tagIds = array_keys(utils::array_change_key($tagRows, 'tag_id'));
if ($tagIds) {
$tagList = app::get('desktop')->model('tag')->getList('*', array('tag_id' => $tagIds));
$tagList = utils::array_change_key($tagList, 'tag_id');
}
/*<----end-------->*/
foreach ($tagRows as $row) {
$relatedRows[$row['rel_id']][] = $tagList[$row['tag_id']];
}
$i = 0;
foreach ($relatedIds as $id) {
$colList[$i] = $this->getColumnTagHtml($relatedRows[$id]);
$i++;
}
}
示例5: index
public function index()
{
$mdl_brand = $this->app->model('brand');
$brand_list = $mdl_brand->getList();
$this->pagedata['brand_list'] = utils::array_change_key($brand_list, 'brand_initial', true);
$this->set_tmpl('brand');
$this->page('mobile/brand/index.html');
}
示例6: avg_mark
public function avg_mark($gids)
{
$sql = 'SELECT avg(mark_star) as num,goods_id FROM ' . $this->table_name(1) . ' WHERE goods_id in (' . implode(',', (array) $gids) . ') group by goods_id';
$res = $this->db->select($sql);
if (!$res || empty($res) || count($res) < 1) {
return $res;
}
return utils::array_change_key($res, 'goods_id');
}
示例7: exec
/**
* 订单发货操作完成时.
*
* @delivery_sdf array - 发货单据SDF
* @msg 异常消息
*
* @return bool - 执行成功与否
*/
public function exec($delivery_sdf, &$msg = '')
{
$order_id = $delivery_sdf['order_id'];
if (!$order_id) {
$msg = '未知订单id';
return false;
}
$all_send = true;
$order_items = app::get('b2c')->model('order_items')->getList('*', array('order_id' => $order_id));
$order_items = utils::array_change_key($order_items, 'item_id');
foreach ($delivery_sdf['delivery_items'] as $item) {
$order_items[$item['order_item_id']]['sendnum'] += $item['sendnum'];
if ($order_items[$item['order_item_id']]['sendnum'] > $order_items[$item['order_item_id']]['nums']) {
$msg = '发货异常,超出应发数量';
return false;
}
if ($order_items[$item['order_item_id']]['sendnum'] < $order_items[$item['order_item_id']]['nums']) {
$all_send = false;
//部分发货
}
}
$order_sdf = array('order_id' => $order_id, 'items' => $order_items, 'ship_status' => $all_send ? '1' : '2');
if (!app::get('b2c')->model('orders')->save($order_sdf)) {
$msg = '订单状态修改失败!';
return false;
}
//库存冻结释放,真实扣除库存
$stock_data = array();
foreach ($delivery_sdf['delivery_items'] as $key => $value) {
$stock_data[] = array('sku' => $value['bn'], 'quantity' => $value['sendnum']);
}
if (!vmc::singleton('b2c_goods_stock')->unfreeze($stock_data, $msg)) {
logger::error('库存冻结释放异常!ORDER_ID:' . $order_sdf['order_id'] . ',' . $msg);
}
if (!vmc::singleton('b2c_goods_stock')->delivery($stock_data, $msg)) {
logger::error('库存扣减异常!ORDER_ID:' . $order_sdf['order_id'] . ',' . $msg);
}
//订单日志记录
vmc::singleton('b2c_order_log')->set_operator(array('ident' => $delivery_sdf['op_id'], 'model' => 'shopadmin', 'name' => '操作员'))->set_order_id($order_sdf['order_id'])->success('shipment', '订单' . (!$all_send ? '部分' : '') . '发货成功!', $delivery_sdf);
/*
* 消息通知
* @args1 事件名称
* @args2 消息模板数据填充
* @args3 消息目标
*/
$pam_data = vmc::singleton('b2c_user_object')->get_pam_data('*', $delivery_sdf['member_id']);
logger::debug('pam_data' . var_export($pam_data, 1));
$dlycorp = app::get('b2c')->model('dlycorp')->dump($delivery_sdf['dlycorp_id']);
$consignee_area = $delivery_sdf['consignee']['area'];
$consignee_area = explode(':', $consignee_area);
$consignee_area = $consignee_area[1];
//消息模板参数
$env_list = array('order_id' => $delivery_sdf['order_id'], 'consignee_name' => $delivery_sdf['consignee']['name'], 'consignee_area' => $consignee_area, 'consignee_addr' => $delivery_sdf['consignee']['addr'], 'consignee_tel' => $delivery_sdf['consignee']['tel'], 'consignee_mobile' => $delivery_sdf['consignee']['mobile'], 'dlycorp_name' => $dlycorp['name'], 'dlycorp_code' => $dlycorp['corp_code'], 'dlycorp_website' => $dlycorp['website'], 'logistics_no' => $delivery_sdf['logistics_no'], 'timestr' => date('Y-m-d H:i:s', $delivery_sdf['last_modify']));
vmc::singleton('b2c_messenger_stage')->trigger('orders-shipping', $env_list, array('mobile' => $pam_data['mobile'] ? $pam_data['mobile']['login_account'] : $order_sdf['consignee']['mobile'], 'email' => $pam_data['email'] ? $pam_data['email']['login_account'] : $order_sdf['consignee']['email'], 'member_id' => $delivery_sdf['member_id']));
return true;
}
示例8: _get_member_list
private function _get_member_list($filter = false, $limit = array(0, -1), $orderby = null)
{
$mdl_members = app::get('b2c')->model('members');
$mdl_member_account = app::get('pam')->model('members');
$members = $mdl_members->getList('member_id,regtime,member_lv_id,name,order_num,mobile,tel,email', $filter, $limit[0], $limit[1], $orderby);
$member_ids = array_keys(utils::array_change_key($members, 'member_id'));
$accounts = $mdl_member_account->getList('login_account,member_id', array('member_id' => $member_ids));
$accounts = utils::array_change_key($accounts, 'member_id');
foreach ($members as $key => $value) {
$members[$key]['login_account'] = $accounts[$value['member_id']]['login_account'];
}
return $members;
}
示例9: detail_products
public function detail_products($gid)
{
$mdl_products = app::get('b2c')->model('products');
$products = $mdl_products->getList('*', array('goods_id' => $gid));
$mdl_stock = app::get('b2c')->model('stock');
$sku_bn = array_keys(utils::array_change_key($products, 'bn'));
$stock_list = $mdl_stock->getList('*', array('sku_bn' => $sku_bn));
$stock_list = utils::array_change_key($stock_list, 'sku_bn');
$render = $this->app->render();
$render->pagedata['data_detail'] = app::get('b2c')->model('goods')->dump($gid, '*', 'default');
$render->pagedata['products'] = $products;
$render->pagedata['stock_list'] = $stock_list;
$render->pagedata['gpromotion_openapi'] = vmc::openapi_url('openapi.goods', 'promotion', array('goods_id' => $gid));
return $render->fetch('admin/goods/detail/detail.html');
}
示例10: confirm
public function confirm($args = array())
{
$args = array_merge((array) $args, $this->req_params);
$sku = $args['sku'];
if (!$sku) {
$this->_failure('缺少参数');
}
$_echo = array();
$sku_bn = explode(',', $sku);
if (count($sku_bn) > 0) {
$result = app::get('b2c')->model('stock')->getList('sku_bn,warehouse,quantity-freez_quantity as num', array('sku_bn' => $sku_bn));
$_echo = utils::array_change_key($result, 'sku_bn');
}
$this->_success($_echo);
}
示例11: _init_rule
/**
* 初始化商品过滤规
*
* @param array $aGoodsId // array(xxx,xxx,xxx);
*/
private function _init_rule($aGoodsId, $filter = array())
{
if (empty($aGoodsId)) {
return false;
}
$filter['goods_id'] = $aGoodsId;
$arrMemberInfo = kernel::single("b2c_frontpage")->get_current_member();
$filter['member_lv'] = $arrMemberInfo['member_lv'] ? $arrMemberInfo['member_lv'] : -1;
$filter['member_lv'] = -1;
$sSql = "SELECT * FROM sdb_b2c_goods_promotion_ref\n WHERE " . $this->_filter_sql($filter) . "\n ORDER BY sort_order DESC";
$aResult = $this->app->model('cart')->db->select($sSql);
if (empty($aResult)) {
return false;
}
//是否允许同一商品有多个预过滤规则
return utils::array_change_key($aResult, 'goods_id', 1);
}
示例12: generate_seo_data
/**
* 组织SEO数据,更换动态占位符 ENV_key.
*/
public function generate_seo_data($goods_detail)
{
$keywords = '';
if (isset($goods_detail['keywords'])) {
foreach ($goods_detail['keywords'] as $key => $value) {
$keywords .= $value['keyword'] . ',';
}
}
$tags = array();
if (isset($goods_detail['tag'])) {
foreach ($goods_detail['tag'] as $key => $value) {
$tags[] = $key;
}
$tags = app::get('desktop')->model('tag')->getList('tag_name', array('tag_id' => $tags));
$tags = utils::array_change_key($tags, 'tag_name');
$tags = array_keys($tags);
}
return array('goods_name' => $goods_detail['name'] . '_' . $goods_detail['product']['spec_info'], 'goods_brand' => $goods_detail['brand']['brand_name'], 'goods_bn' => $goods_detail['product']['bn'], 'goods_cat' => $goods_detail['category']['cat_name'], 'goods_intro' => $goods_detail['brief'], 'goods_barcode' => $goods_detail['product']['barcode'], 'goods_keywords' => $keywords, 'goods_tags' => implode(',', $tags));
}
示例13: index
public function index($goods_id, $product_id)
{
#更新货品表到库存维护表
//vmc::singleton('b2c_goods_stock')->refresh($msg);
if (!empty($goods_id)) {
$sku = app::get('b2c')->model('products')->getList('bn', array('goods_id' => $goods_id));
$goods = app::get('b2c')->model('goods')->getRow('name,image_default_id', array('goods_id' => $goods_id));
} elseif ($product_id) {
$sku = app::get('b2c')->model('products')->getList('*', array('product_id' => $product_id));
$goods = $sku[0];
}
if ($sku) {
$base_filter = array('sku_bn' => array_keys(utils::array_change_key($sku, 'bn')));
}
$finder_options = array('title' => '商品库存管理', 'use_buildin_import' => true, 'use_buildin_export' => true, 'actions' => array(array('label' => '批量编辑', 'icon' => 'fa-edit', 'data-submit' => 'index.php?app=b2c&ctl=admin_stock&act=batch_edit', 'data-target' => '_ACTION_MODAL_')), 'finder_extra_view' => array(array('app' => 'b2c', 'view' => '/admin/goods/stock/finder_extra.html', 'extra_pagedata' => $goods)));
if ($base_filter) {
$finder_options['base_filter'] = $base_filter;
}
$this->finder('b2c_mdl_stock', $finder_options);
}
示例14: product_filter
function product_filter()
{
$filter = $_POST['filter'];
$f_value = array_values($filter);
$f_value = $f_value[0];
if (trim($f_value) == '') {
die('');
}
$mdl_goods = app::get('b2c')->model('goods');
$mdl_product = app::get('b2c')->model('products');
$products = $mdl_product->getList('*', $filter, 0, 100);
foreach ($products as $key => $value) {
$item_group[$value['goods_id']][] = $value;
}
$gids = array_keys($item_group);
$gimages = $mdl_goods->getList('goods_id,image_default_id', array('goods_id' => $gids));
$this->pagedata['item_group'] = $item_group;
$this->pagedata['gimages'] = utils::array_change_key($gimages, 'goods_id');
$this->display('admin/pos/item_group.html');
}
示例15: groupList
/**
* 获得分组详细评价列表
*/
public function groupList($cols = '*', $filter = array(), $offset = 0, $limit = -1, $orderType = null, $group_by = 'product_id')
{
$orderType = ' createtime DESC';
//fixOrder
$list = parent::getList($cols = '*', $filter, $offset, $limit, $orderType);
$list = utils::array_change_key($list, $group_by, true);
foreach ($list as $group => &$items) {
$items = utils::array_change_key($items, 'comment_id');
foreach ($items as $key => &$comment) {
if (!empty($comment['for_comment_id'])) {
$items[$comment['for_comment_id']]['reply'][$comment['comment_id']] = $comment;
$items[$comment['for_comment_id']]['lastreply'] = $items[$comment['for_comment_id']]['lastreply'] ? $items[$comment['for_comment_id']]['lastreply'] : $comment['createtime'];
unset($items[$key]);
continue;
}
$comment['mark'] = app::get('b2c')->model('goods_mark')->getRow('mark_star', array('comment_id' => $comment['comment_id']));
$comment['images'] = app::get('image')->model('image_attach')->getList('image_id', array('target_id' => $comment['comment_id']));
}
}
return $list;
}