public function editAction() { list($userid, $mastername, $choosenSchoolId, $shopName, $description, $address, $packingprice, $areaid, $phoneNumber, $contactNumber, $openOrder, $orderBegin, $orderEnd, $isActive, $isAudit, $isPartner, $hasTerminal, $hasPrint, $isShopOpen, $ifRebate, $rebateFromShop, $openOrderToUser, $actualmakeordertime, $actualbakeouttime, $actualtocentertime, $actualdeliverytime, $deliveryprice, $lat, $lng, $startingprice) = $this->getInput(array('choosenUserid', 'mastername', 'choosenSchoolId', 'shopname', 'description', 'address', 'packingprice', 'area', 'phonenumber', 'contactnumber', 'openorder', 'orderbegin', 'orderend', 'isactive', 'isaudit', 'ispartner', 'hasterminal', 'hasprint', 'isshopopen', 'ifrebate', 'rebatefromshop', 'openordertouser', 'actualmakeordertime', 'actualbakeouttime', 'actualtocentertime', 'actualdeliverytime', 'deliveryprice', 'lat', 'lng', 'startingprice'), 'post'); if ($this->getInput('type', 'post') === 'do') { $rebateFromShop = !$ifRebate ? 0 : $rebateFromShop; if (empty($shopName)) { $this->showError('请输入商家名称.'); return; } if (empty($address)) { $this->showError('请输入地址.'); return; } if (empty($phoneNumber)) { $this->showError('请输入手机号码'); return; } if ($rebateFromShop >= 1) { $this->showError('商家返利不能大于1'); return; } $shopId = $this->getInput('id', 'request'); $nameDuplicate = $this->_getShopDs()->checkDuplicateInfo('name', $shopName, $shopId); if ($nameDuplicate) { $this->showError('商家名:' . '"' . $shopName . '"' . '已存在'); return; } $dm = new App_Shop_Dm(); $dm->setUserId($userid)->setMasterId($mastername)->setShopName($shopName)->setAddress($address)->setPackingPrice($packingprice)->setArea($areaid)->setPhoneNumber($phoneNumber)->setContactNumber($contactNumber)->setOpenOrder($openOrder)->setOrderBegin($orderBegin)->setOrderEnd($orderEnd)->setLastUpdateTime(Pw::getTime())->setDescription($description)->setIsActive($isActive)->setIsAudit($isAudit)->setIsPartner($isPartner)->setHasTerminal($hasTerminal)->setHasPrint($hasPrint)->setIsShopOpen($isShopOpen)->setIfRebate($ifRebate)->setRebateFromShop($rebateFromShop)->setIsOpenOrderToUser($openOrderToUser)->setActualmakeorder($actualmakeordertime)->setActualbakeout($actualbakeouttime)->setActualtocenter($actualtocentertime)->setActualdelivery($actualdeliverytime)->setDeliveryprice($deliveryprice)->setLatitude($lat)->setLongitude($lng)->setStartingPrice($startingprice); $r = $this->_getShopDs()->update($shopId, $dm); if ($r == 1 && $this->shopDeliveryTimeHandle($shopId)) { $this->showMessage('更新成功'); } else { $this->showError('更新失败,请联系管理员'); } } else { $isChange = $this->getInput('isChange'); $shopId = $this->getInput('id', 'request'); $shop = $this->_getShopDs()->getByShopId($shopId); if (empty($shop)) { $this->showError("Invalid data"); } $choosenProvinceid = isset($isChange) ? $this->getInput('choosenProvinceid') : $shop['provinceid']; $choosenSchoolid = isset($isChange) ? $this->getInput('choosenSchoolid') : $shop['schoolid']; $agents = $this->_getShopSchoolPeople()->getPeopleByType('master'); $userList = $this->_getSchoolPeopleDS()->getSchoolPeople($choosenSchoolid, 'shopaccount'); $allProvince = $this->_getAreaDs()->getAreaByParentid(0); $allProvince = array_values($allProvince); $allSchool = $this->_get4TSchoolDS()->getOpenedSchools(); $allSchool = array_values($allSchool); Wind::import('EXT:4tschool.service.dm.App_SchoolArea_Dm'); $areaList = Wekit::load('EXT:4tschool.service.schoolarea.App_SchoolArea')->getBySchoolid(empty($choosenSchoolid) ? $allSchool[0]['schoolid'] : $choosenSchoolid); $shopSchoolMsg = $this->_getShopAreaDs()->getShopAreaByShopId($shopId); $schoolnameMsg = array(); foreach ($shopSchoolMsg as $key => $value) { array_push($schoolnameMsg, $value['schoolname']); } $schoolnamestring = implode(', ', $schoolnameMsg); $this->setOutput($userList, 'userList'); $this->setOutput($choosenProvinceid, "choosenProvinceid"); $this->setOutput($choosenSchoolid, "choosenSchoolid"); $this->setOutput($allProvince, 'allProvince'); $this->setOutput($allSchool, 'allSchool'); $this->setOutput($areaList, 'areaList'); $this->setOutput($shop, 'shop'); $this->setOutput($agents, 'agents'); $this->setOutput($schoolnamestring, 'schoolnamestring'); $shopDeliveryTimeList = $this->_getShopDs()->getShopDeliveryTimeByShopId($shopId); $this->setOutput($shopDeliveryTimeList, 'shopDeliveryTimeList'); } }
public function shopManageAddAction() { $schoolId = $this->getCurrentSchoolId(); $this->getWebStatus($schoolId); $masterId = $userId = $this->loginUser->uid; $this->isSchoolManage($schoolId, $userId); $this->getNoCommentSum($schoolId, $userId); if ($this->getInput('type', 'post') === 'do') { list($choosenUserid, $shopName, $description, $address, $packingPrice, $areaid, $phoneNumber, $contactNumber, $openOrder, $orderBegin, $orderEnd, $isActive, $isPartner, $hasTerminal, $hasPrint, $openOrderToUser, $actualmakeordertime, $actualbakeouttime, $actualtocentertime, $actualdeliverytime, $deliveryprice, $lat, $lng, $startingprice) = $this->getInput(array('choosenUserid', 'shopname', 'description', 'address', 'packingprice', 'area', 'phonenumber', 'contactnumber', 'openorder', 'orderbegin', 'orderend', 'isactive', 'ispartner', 'hasterminal', 'hasprint', 'openordertouser', 'actualmakeordertime', 'actualbakeouttime', 'actualtocentertime', 'actualdeliverytime', 'deliveryprice', 'lat', 'lng', 'startingprice'), 'post'); if (empty($shopName)) { $this->showError('请输入商家名称.'); return; } if (empty($address)) { $this->showError('请输入地址.'); return; } if (empty($phoneNumber)) { $this->showError('请输入手机号码'); return; } $nameDuplicate = $this->_getShopDs()->checkDuplicateInfo('name', $shopName, 'new'); if ($nameDuplicate) { $this->showError('商家名:' . '"' . $shopName . '"' . '已存在'); return; } // $phoneNumberDuplicate = $this->_getShopDs()->checkDuplicateInfo('phonenumber', $phoneNumber, 'new'); // if ($phoneNumberDuplicate) { // $this->showError('手机号码:' . '"' . $phoneNumber . '"' . '已存在'); // return; // } $dm = new App_Shop_Dm(); $dm->setUserId($choosenUserid)->setMasterId($masterId)->setShopName($shopName)->setAddress($address)->setPackingPrice($packingPrice)->setArea($areaid)->setPhoneNumber($phoneNumber)->setContactNumber($contactNumber)->setOpenOrder($openOrder)->setOrderBegin($orderBegin)->setOrderEnd($orderEnd)->setCreateDate(Pw::getTime())->setLastUpdateTime(Pw::getTime())->setDescription($description)->setOrderCount(0)->setIsActive($isActive)->setIsPartner($isPartner)->setHasTerminal($hasTerminal)->setHasPrint($hasPrint)->setIsOpenOrderToUser($openOrderToUser)->setActualmakeorder($actualmakeordertime)->setActualbakeout($actualbakeouttime)->setActualtocenter($actualtocentertime)->setActualdelivery($actualdeliverytime)->setDeliveryprice($deliveryprice)->setLatitude($lat)->setLongitude($lng)->setStartingPrice($startingprice); $id = $this->_getShopDs()->add($dm); if ($id > 0 && $this->shopDeliveryTimeHandle($id) && $this->saveShopSchool($id, $schoolId)) { echo "<script>alert('添加成功')</script>"; } else { echo "<script>alert('添加成功,请联系管理员')</script>"; } echo "<script language=JavaScript> location.replace(location.href);</script>"; } $allProvince = $this->_getAreaDs()->getAreaByParentid(0); $allProvince = array_values($allProvince); //check if has province id or not, if has, then school list need to based on that //get province from url $choosenProvinceid = $this->getInput('choosenProvinceid'); if (!isset($choosenProvinceid) || $choosenProvinceid <= 0) { $choosenProvinceid = $allProvince[0]['areaid']; } $allSchool = $this->_get4TSchoolDS()->getOpenedSchools(); $allSchool = array_values($allSchool); $this->setOutput($allSchool, 'allSchool'); $choosenSchoolid = $this->getInput('schoolid'); if (!isset($choosenSchoolid) || $choosenSchoolid <= 0) { $choosenSchoolid = $allSchool[0]['schoolid']; } $userList = $this->_getSchoolPeopleDS()->getSchoolPeople($choosenSchoolid, 'shopaccount'); Wind::import('EXT:4tschool.service.dm.App_SchoolArea_Dm'); $areaList = Wekit::load('EXT:4tschool.service.schoolarea.App_SchoolArea')->getBySchoolid($choosenSchoolid); $agents = $this->_getShopSchoolPeople()->getPeopleByType('master'); $this->setOutput($userList, 'userList'); $this->setOutput($choosenProvinceid, 'choosenProvinceid'); $this->setOutput($choosenSchoolid, 'choosenSchoolid'); $this->setOutput($areaList, 'areaList'); $this->setOutput($agents, 'agents'); $this->setOutput($allProvince, 'allProvince'); $myMenus = $this->_getMyOrderDS()->getMyMenus($schoolId, $this->loginUser->uid); $this->setOutput($myMenus, 'myMenus'); $this->setOutput($this->loginUser->username, 'mastername'); $this->setOutput($schoolId, 'schoolId'); }