'ID', 'order_id' => 'Order ID', 'prod_id' => 'Prod ID', 'count' => 'Count', 'unit_price' => 'Unit Price', 'total_price' => 'Total Price', 'delete_flag' => 'Delete Flag', ]; } /** * Function Description:插入子订单 * Function Name: insertInfo * @param $prod_arr * @param $oderId * * @return bool * * @author 娄梦宁 */ public function insertInfo($prod_arr, $oderId) { $sql = "INSERT into order_info(order_id, total_price, count, unit_price, prod_id,commission) SELECT {$oderId}, prod_price*{$prod_arr['prod_count']} price, {$prod_arr['prod_count']},prod_price,prod_id,commission from prod_main where prod_id ={$prod_arr['prod_id']}"; $res = $this->getDb()->createCommand($sql)->execute(); if (!$res) { return false; } return true; } /** * Function Description:获取订单佣金 * Function Name: insertInfo * @param $orderId int * @return int * @author 娄梦宁 */ public function getOrderCommission($orderId) { $select = [ new Expression("IFNULL(SUM(b.commission*a.count),0) 'commission'"), 'order_id' ]; try{ $result =self::find()->select($select) ->from(self::tableName().' as a') ->innerJoin(ProdMain::tableName().' as b','a.prod_id = b.prod_id') ->where(['=','a.order_id',$orderId]) ->asArray() ->one(); }catch (Exception $e) { $result['commission'] = 0; } return $result['commission']; } /** * Des:获取产品数组 * Name: getFreeWalkProdArr * @param $order_id * @return array * @author 倪宗锋 */ public function geProdArr($order_id){ $select = [ 'prod_id'=> 'b.bus_id', 'prod_name'=> 'b.prod_name', 'prod_num' => 'a.count' ]; $where = ['=','a.order_id', $order_id]; $getProdArr = self::find()->select($select) ->from(self::tableName().' a') ->innerJoin(ProdMain::tableName().' b','a.prod_id = b.prod_id') ->where($where) ->asArray(true) ->all(); return $getProdArr; } }