setProducts() public method

Формат массива:
array(
   '45' => array( //реальный id или сгенерированный новый, у новых внутри массива нет id
       'id' => '10', //если нет id, то новый
       'variant_ids' => array('10', '20, '30'), // массив с id вариантов
       'quantity' = > '5',
       'price' => '1000',
       'product_id' => '123',
   )
)
public setProducts ( $orderProducts )
$orderProducts Array
Exemplo n.º 1
0
 public function getOrderByOrderTime($campaignId, $orderStatTime, $orderEndTime)
 {
     if (empty($campaignId) || empty($orderStatTime) || empty($orderEndTime)) {
         echo "campaignId ,orderStatTime or orderEndTime is null";
         exit;
     }
     $sql = "SELECT p.order_id,order_sn,add_time,order_status,pay_status,pay_name,order_time,cid,wi,order_status,pay_status,pay_name,shipping_fee,surplus,bonus,order_amount FROM `cps` as p LEFT OUTER JOIN ecs_order_info as i on i.order_id=p.order_id where p.cid=" . $campaignId . " and order_time>" . $orderStatTime . " and order_time<" . $orderEndTime;
     $dborder = $GLOBALS['db']->getAll($sql);
     if (empty($dborder)) {
         return NULL;
     }
     foreach ($dborder as $k => $v) {
         $order = new Order();
         $order->setOrderNo($v['order_sn']);
         $order_time = date('Y-m-d H:i:s', $v['order_time']);
         $order->setOrderTime($order_time);
         // 设置下单时间
         $order->setUpdateTime($order_time);
         // 设置订单更新时间,如果没有下单时间,要提前对接人提前说明
         $order->setCampaignId($v['cid']);
         // 测试时使用"101",正式上线之后活动id必须要从数据库里面取
         $order->setFeedback($v['wi']);
         $order->setFare($v['shipping_fee']);
         $order->setFavorable($v['bonus'] + $v['surplus']);
         //$orderStatus = new OrderStatus();
         //$orderStatus -> setOrderNo($order -> getOrderNo());
         $order->setOrderStatus($v['order_status']);
         // 设置订单状态
         $order->setPaymentStatus($v['pay_status']);
         // 设置支付状态
         $order->setPaymentType($v['pay_name']);
         // 支付方式
         $sql = "select * from ecs_order_goods where order_id=" . $v['order_id'] . " and goods_price>100";
         $order_goods = $GLOBALS['db']->getAll($sql);
         //echo "<pre>";print_r($order_goods);
         foreach ($order_goods as $k1 => $v1) {
             $pro = new Product();
             //$pro -> setOrderNo($order -> getOrderNo());
             $pro->setProductNo($v1['goods_sn']);
             $pro->setName($v1['goods_name']);
             $pro->setCategory("蛋糕");
             $pro->setCommissionType("");
             $pro->setAmount($v1['goods_number']);
             $a = number_format($v1['goods_price'] * (1 - ($v['bonus'] + $v['surplus']) / ($v['bonus'] + $v['surplus'] + $v['order_amount'])), 2, ".", "");
             $pro->setPrice($a);
             $products[] = $pro;
         }
         $order->setProducts($products);
         $orderlist[] = $order;
         $products = array();
     }
     //print_r($orderlist);
     //echo json_encode($orderlist);
     return $orderlist;
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function actionCreate()
 {
     $model = new Order();
     if (Yii::app()->getRequest()->getIsPostrequest() && Yii::app()->getRequest()->getPost('Order')) {
         $model->setAttributes(Yii::app()->getRequest()->getPost('Order'));
         $model->setProducts(Yii::app()->getRequest()->getPost('OrderProduct', 'null'));
         if ($model->save()) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('OrderModule.order', 'Record created!'));
             if (!isset($_POST['submit-type'])) {
                 $this->redirect(['update', 'id' => $model->id]);
             }
             $this->redirect([$_POST['submit-type']]);
         }
     }
     $this->render('create', ['model' => $model]);
 }
Exemplo n.º 3
0
     // 支付方式
     foreach ($cart_goods as $k => $v) {
         if ($v['goods_price'] > 0) {
             $pro = new Product();
             // $pro2 -> setOrderNo($order -> getOrderNo());
             $pro->setProductNo($v['goods_sn']);
             $pro->setName($v['goods_name']);
             $pro->setCategory("蛋糕");
             $pro->setCommissionType("");
             $pro->setAmount($v['goods_number']);
             $a = number_format($v['goods_price'] * (1 - ($order['bonus'] + $order['surplus']) / ($order['bonus'] + $order['surplus'] + $order['order_amount'])), 2, ".", "");
             $pro->setPrice($a);
             $products[] = $pro;
         }
     }
     $cps->setProducts($products);
     //var_dump(get_object_vars($cps));
     $sender = new Sender();
     $sender->setOrder($cps);
     $sender->sendOrder();
     $ordertime = $order['add_time'] + 8 * 3600;
     $sql = "INSERT INTO cps ( " . "order_id,src,channel,cid,wi,order_time)" . " values('{$new_order_id}','emar','cps'," . $arr[2] . ",'" . $arr[3] . "','" . $ordertime . "') ";
     $db->query($sql);
 }
 /* 修改拍卖活动状态 
     if ($order['extension_code']=='auction')
     {
         $sql = "UPDATE ". $ecs->table('goods_activity') ." SET is_finished='2' WHERE act_id=".$order['extension_id'];
         $db->query($sql);
     }
 	*/
Exemplo n.º 4
0
$pro->setCategory("asdf");
// 设置商品类型
$pro->setCommissionType("A");
// 设置佣金类型,如:普通商品 佣金比例是10%、佣金编号(可自行定义然后通知双方商务)A
$pro->setAmount("1");
// 设置商品数量
$pro->setPrice("3000");
// 设置商品价格
$pro1 = new Product();
// $pro1 -> setOrderNo($order -> getOrderNo());
$pro1->setProductNo("1002");
$pro1->setName("测试商品5");
$pro1->setCategory("a");
$pro1->setCommissionType("B");
$pro1->setAmount("3");
$pro1->setPrice("100");
$pro2 = new Product();
// $pro2 -> setOrderNo($order -> getOrderNo());
$pro2->setProductNo("1003");
$pro2->setName("测试商品4");
$pro2->setCategory("2");
$pro2->setCommissionType("B");
$pro2->setAmount("5");
$pro2->setPrice("500");
$products = array($pro, $pro1, $pro2);
// 实现商品信息集合
$order->setProducts($products);
//var_dump(get_object_vars($order));
$sender = new Sender();
$sender->setOrder($order);
$sender->sendOrder();
Exemplo n.º 5
0
                 $addy->save();
                 //$info_msg .= 'Saved new address.';
                 $aid = $addy->id;
             } catch (PDOException $e) {
                 $error_msg = 'Could not save address';
             }
         }
     }
     if ($aid) {
         //store the order
         $order = new Order();
         //set order properties
         $order->customer_id = $customer_id;
         $order->order_date = time();
         $order->address_id = $aid;
         $order->setProducts($cart);
         try {
             $order->save();
             if (!isset($addy)) {
                 $addy = new Address($aid);
             }
             $info_msg .= '<p>Successfully completed your order.</p>';
             $content .= '<p>We will ship your order to:</p><br/><p>';
             $content .= $addy->getFullAddress() . '</p>';
             //remove items from session cart
             unset($_SESSION['cart']);
         } catch (PDOException $e) {
             $error_msg = 'Could not save order.';
         }
     }
 }