Exemplo n.º 1
0
 public static function getBookingno()
 {
     $booking_no = OrderService::createOrderno();
     $booking_count = MemberBooking::find()->where(['booking_no' => $booking_no])->count();
     if ($booking_count > 0) {
         return OrderService::getBookingno();
     } else {
         return $booking_no;
     }
 }
Exemplo n.º 2
0
 public function actionUpdateProductCheckInventory()
 {
     $this->setauth();
     //检查有无权限
     $p_db = Yii::app()->p_db;
     $code = isset($_POST['code']) ? $_POST['code'] : '';
     $name = isset($_POST['name']) ? $_POST['name'] : '';
     $status = isset($_POST['status']) ? $_POST['status'] : '';
     $inventory_old = isset($_POST['inventory_old']) ? $_POST['inventory_old'] : '';
     $inventory = isset($_POST['inventory']) ? $_POST['inventory'] : '';
     $time = date('Y-m-d H:i:s', time());
     $this_user_name = Yii::app()->user->name;
     $flag = 0;
     if ($code != '') {
         $transaction = $p_db->beginTransaction();
         try {
             $check_code = OrderService::createOrderno();
             //新增盘点记录
             $sql = "INSERT INTO `vcos_product_check` (check_code,check_time,check_type,check_people) VALUES ('{$check_code}','{$time}','{$status[0]}','{$this_user_name}')";
             Yii::app()->p_db->createCommand($sql)->execute();
             for ($i = 0; $i < count($code); $i++) {
                 $sql = "INSERT INTO `vcos_product_check_detail` (check_code,product_name,inventory_num,check_num,product_code) VALUES ('{$check_code}','{$name[$i]}','{$inventory_old[$i]}','{$inventory[$i]}','{$code[$i]}')";
                 Yii::app()->p_db->createCommand($sql)->execute();
                 $sql = "UPDATE `vcos_product` SET inventory_num='{$inventory[$i]}' WHERE product_code='{$code[$i]}'";
                 Yii::app()->p_db->createCommand($sql)->execute();
             }
             $transaction->commit();
             $flag = 1;
         } catch (Exception $e) {
             $transaction->rollBack();
             $flag = 0;
         }
     }
     if ($flag == 1) {
         Helper::show_message(yii::t('vcos', '提交成功。'), Yii::app()->createUrl("Product/product_check"));
     } else {
         Helper::show_message(yii::t('vcos', '提交失败。'), Yii::app()->createUrl("Product/product_check"));
     }
 }