Пример #1
0
 /**
  * 订单商品表提交数据
  *
  * @param $order_id
  * @param $order_item
  * @return bool
  */
 public function ItemParams($order_id, $order_item)
 {
     $product_ids = Help::ArrayToString($order_item, 'product_id');
     if (!$product_ids) {
         return false;
     }
     $Spec = new ModelSpec();
     $product_spec = $Spec->ProductSpec($product_ids);
     foreach ($order_item as $v) {
         $object = array('order_id' => $order_id, 'obj_type' => 'goods', 'obj_alias' => '商品区块', 'goods_id' => $v['goods_id'], 'bn' => $v['bn'], 'name' => $v['name'], 'price' => $v['price'], 'amount' => 0, 'quantity' => $v['quantity'], 'weight' => 0, 'score' => 0);
         $params[$v['product_id']]['object'] = $object;
         $spec['product_attr'] = isset($product_spec[$v['product_id']]) ? $product_spec[$v['product_id']] : '';
         !empty($spec['product_attr']) ? $addon = serialize($spec) : ($addon = '');
         $item = array('order_id' => $order_id, 'obj_id' => 0, 'product_id' => $v['product_id'], 'goods_id' => $v['goods_id'], 'type_id' => $v['type_id'], 'bn' => $v['bn'], 'name' => $v['name'], 'cost' => $v['cost'], 'price' => $v['price'], 'g_price' => $v['price'], 'amount' => $v['price'] * $v['quantity'], 'score' => 0, 'weight' => 0, 'nums' => $v['quantity'], 'sendnum' => 0, 'addon' => $addon, 'item_type' => 'product');
         $params[$v['product_id']]['item'] = $item;
     }
     return $params;
 }