106
if($order==NULL)
exit();
$options=Wmoptions::model()->findByPk(1);
if($_POST['LMI_PAYMENT_NO'] == $order->id&& $_POST['LMI_PAYEE_PURSE'] == $options-
>sum&& $_POST['LMI_PAYMENT_AMOUNT'] == $order->sum)
echo 'YES';
}else{
$wmForm=new WmForm;
$wmForm->LMI_PAYEE_PURSE=$_POST['LMI_PAYEE_PURSE'];
$wmForm->LMI_PAYMENT_AMOUNT=$_POST['LMI_PAYMENT_AMOUNT'];
$wmForm->LMI_PAYMENT_NO=$_POST['LMI_PAYMENT_NO'];
$wmForm->LMI_MODE=$_POST['LMI_MODE'];
$wmForm->LMI_SYS_INVS_NO=$_POST['LMI_SYS_INVS_NO'];
$wmForm->LMI_SYS_TRANS_NO=$_POST['LMI_SYS_TRANS_NO'];
$wmForm->LMI_SYS_TRANS_DATE=$_POST['LMI_SYS_TRANS_DATE'];
$wmForm->LMI_SECRET_KEY=$_POST['LMI_SECRET_KEY'];
$wmForm->LMI_PAYER_PURSE=$_POST['LMI_PAYER_PURSE'];
$wmForm->LMI_PAYER_WM=$_POST['LMI_PAYER_WM'];
if($wmForm->validate()){
$order=$this->module->getOrderModel()->findByPk(intval($_POST['LMI_PAYMENT_NO']));
$order->updateByPk($order->id,array('status'=>2));
exit('OK');
}
}
}
public function loadModel($id){
$model=$this->module->getBasketModel()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
public function actionBasket($id){
$model=$this->module->getBasketModel();
if(isset($_POST['delete'])&&isset($_POST['id']))
foreach ($_POST['id'] as $one)
$this->loadModel($one)->delete();
if(isset($_POST['delivery'])&&isset($_POST['id'])){
$this->buy(1);
Yii::app()->end();
}
if(isset($_POST['justBuy'])&&isset($_POST['id'])){
$this->buy(0);
Yii::app()->end();
}
$this->render('basket',array(
'model'=>$model,
));
}
public function buy($delivery){
$mes="";
$quantity=0;
$model=$this->module->getBasketModel();
$product=$this->module->getProductModel();
$sum=0.0;
foreach ($_POST['id'] as $one){
$bas=$model->findByPk($one);
$pr=$product->findByPk($bas->productID);
if($pr->quantity!=0){
if($pr->quantity<$bas->quantity){
$quantity=$pr->quantity;
$bas->updateByPk($bas-
>id,array('quantity'=>$quantity));
}else
if($pr->quantity!=0)
$quantity=$bas->quantity;
else{
$timestamp = time();
$date_time_array =
getdate($timestamp);
$timestamp =
mktime($date_time_array['hours'],$date_time_array['minutes'] - 10,$date_time_array['seconds'],
$date_time_array['mon'],$date_time_array['mday'],$date_time_array['year']
);
$b=$model-
>findAll(array('condition'=> 'order.created>=:created AND product.id =:productID', 'params'=>
array(
':created' =>
$timestamp, ':productID' => $bas->productID,