本文整理汇总了PHP中Help::ArrayListByKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Help::ArrayListByKey方法的具体用法?PHP Help::ArrayListByKey怎么用?PHP Help::ArrayListByKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Help
的用法示例。
在下文中一共展示了Help::ArrayListByKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OrderProduct
/**
* 订单商品
*
* @param $order_idArr
* @return array|bool|string
*/
public function OrderProduct($order_idArr)
{
if (!$order_idArr) {
return '';
}
$item_sql = "SELECT i.order_id,i.product_id,i.goods_id,i.bn,i.name,i.price,i.nums,i.addon,i.cost,p.mktprice\n FROM {{b2c_order_items}} as i left join {{b2c_products}}\n as p on p.product_id = i.product_id";
if (is_array($order_idArr)) {
$order_ids = implode(',', $order_idArr);
$item_sql .= " WHERE order_id IN ({$order_ids})";
} else {
$item_sql .= " WHERE order_id = {$order_idArr}";
}
$items = $this->ModelQueryAll($item_sql);
$itemsOrder = $goods_ids = $goods_image = array();
foreach ($items as $k => $v) {
$goods_ids[] = $v['goods_id'];
$items[$k]['price'] = number_format($v['price'], '2', '.', '');
$items[$k]['cost'] = number_format($v['cost'], '2', '.', '');
$items[$k]['mktprice'] = number_format($v['mktprice'], '2', '.', '');
}
$itemProduct = Help::ArrayListByKey($items, 'goods_id');
if (!$goods_ids) {
return $itemsOrder;
}
$goods_str = implode(',', $goods_ids);
$Product = new ModelProduct();
$goods_image = $Product->GoodsDefaultImage($goods_str);
foreach ($goods_image as $k => $v) {
$itemProduct[$k]['image'] = $this->img_url . $v['s_url'];
}
foreach ($items as $v) {
$item = $v;
$item['image'] = isset($itemProduct[$v['goods_id']]['image']) ? $itemProduct[$v['goods_id']]['image'] : '';
$itemsOrder[$v['order_id']][] = $item;
}
if (!is_array($order_idArr)) {
return $itemsOrder[$order_idArr];
}
return $itemsOrder;
}