Example #1
0
 public function doDone(ZOL_Request $input, ZOL_Response $output)
 {
     $otherProIdArr = $input->post("otherProId");
     //所有商品
     $staffid = (int) $input->post("staffid");
     //员工
     $remark = $input->post("remark");
     //填写的备注
     $memberId = (int) $input->post("memberId");
     //会员ID
     if (!$staffid || empty($otherProIdArr)) {
         $this->showErrMsg();
     }
     //获得会员信息
     $memberInfo = Helper_Member::getMemberInfo(array("id" => $memberId));
     if (!$memberInfo) {
         $this->showErrMsg();
     }
     //获得商品列表
     $proInfoArr = array();
     foreach ($otherProIdArr as $id) {
         $info = Helper_Product::getMemberOtherPro(array('id' => $id, 'memberId' => $memberId));
         if ($info && $info["num"] > 0) {
             //筛选一下商品
             $proInfoArr[] = $info;
         }
     }
     //生成一个单号
     $bno = Helper_Bill::getCommonMaxBno();
     $db = Db_Andyou::instance();
     if ($proInfoArr) {
         foreach ($proInfoArr as $info) {
             //数量减少
             $sql = "update memeberotherpro set num = num - 1 where id = " . $info["id"];
             $db->query($sql);
             //记录消费日志
             $tmpLogRow = array('memberId' => $memberId, 'phone' => $memberInfo["phone"], 'otherproId' => $info["id"], 'name' => $info["name"], 'direction' => 1, 'cvalue' => 1, 'orgcvalue' => $info["num"], 'ctype' => $info["ctype"], 'dateTm' => SYSTEM_TIME, 'staffid' => $staffid, 'bno' => $bno, 'remark' => $remark);
             Helper_Dao::insertItem(array('addItem' => $tmpLogRow, 'dbName' => 'Db_Andyou', 'tblName' => 'log_useotherpro'));
         }
     }
     $staffArr = Helper_Staff::getStaffPairs();
     //准备进入打印页面
     $output->proInfoArr = $proInfoArr;
     $output->bno = $bno;
     $output->memberId = $memberId;
     $output->memberInfo = $memberInfo;
     //会员信息
     $output->staffid = $staffid;
     $output->staffName = $staffArr[$staffid];
     Helper_Bill::createOneCommonBno();
     //生成一个通用订单号
     $output->setTemplate('OtherProPrint');
 }