# Conflicts: # application/admin/view/order_main/add.htmldev
@@ -1,7 +1,11 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ChangeListManager"> | |||
<list default="true" id="648f7d15-dc9f-4b1e-bba1-58d66fbf1157" name="Default Changelist" comment="" /> | |||
<list default="true" id="648f7d15-dc9f-4b1e-bba1-58d66fbf1157" name="Default Changelist" comment=""> | |||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/runtime/cache/4e/819c837d54a6ed09abc77a8560a66f.php" beforeDir="false" /> | |||
<change beforePath="$PROJECT_DIR$/runtime/log/202110/10.log" beforeDir="false" /> | |||
</list> | |||
<option name="SHOW_DIALOG" value="false" /> | |||
<option name="HIGHLIGHT_CONFLICTS" value="true" /> | |||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | |||
@@ -15,6 +19,13 @@ | |||
</component> | |||
<component name="Git.Settings"> | |||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | |||
<option name="UPDATE_TYPE" value="MERGE" /> | |||
</component> | |||
<component name="PhpDebugGeneral" xdebug_debug_port="9006" listening_started="true" /> | |||
<component name="PhpServers"> | |||
<servers> | |||
<server host="cz.com" id="e1f06fd7-deb9-41a7-9d36-436111235361" name="Unnamed" /> | |||
</servers> | |||
</component> | |||
<component name="PhpWorkspaceProjectConfiguration"> | |||
<include_path> | |||
@@ -62,6 +73,7 @@ | |||
<path value="$PROJECT_DIR$/vendor/composer" /> | |||
</include_path> | |||
</component> | |||
<component name="PhpXdebugProxy" ide_key="PHPSTORM" /> | |||
<component name="ProjectId" id="1zIjzuEvZDgQhcf3g2PuCHgwZVc" /> | |||
<component name="ProjectViewState"> | |||
<option name="hideEmptyMiddlePackages" value="true" /> | |||
@@ -71,7 +83,13 @@ | |||
<component name="PropertiesComponent"> | |||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> | |||
<property name="WebServerToolWindowFactoryState" value="false" /> | |||
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> | |||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../xs" /> | |||
<property name="settings.editor.selected.configurable" value="reference.settings.php.debug.xdebug.proxy" /> | |||
</component> | |||
<component name="RunManager"> | |||
<configuration name="Unnamed" type="PhpWebAppRunConfigurationType" factoryName="PHP Web Application" nameIsGenerated="true" server_name="Unnamed"> | |||
<method v="2" /> | |||
</configuration> | |||
</component> | |||
<component name="ServiceViewManager"> | |||
<option name="viewStates"> | |||
@@ -96,17 +114,216 @@ | |||
<option name="presentableId" value="Default" /> | |||
<updated>1633842761564</updated> | |||
<workItem from="1633842763299" duration="460000" /> | |||
<workItem from="1633843542476" duration="336000" /> | |||
<workItem from="1633843542476" duration="7474000" /> | |||
<workItem from="1633967176055" duration="7788000" /> | |||
<workItem from="1634461088170" duration="4763000" /> | |||
<workItem from="1634567190291" duration="34134000" /> | |||
</task> | |||
<task id="LOCAL-00001" summary="init"> | |||
<created>1633847937612</created> | |||
<option name="number" value="00001" /> | |||
<option name="presentableId" value="LOCAL-00001" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1633847937613</updated> | |||
</task> | |||
<task id="LOCAL-00002" summary="init"> | |||
<created>1633849299831</created> | |||
<option name="number" value="00002" /> | |||
<option name="presentableId" value="LOCAL-00002" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1633849299831</updated> | |||
</task> | |||
<task id="LOCAL-00003" summary="init"> | |||
<created>1634464377345</created> | |||
<option name="number" value="00003" /> | |||
<option name="presentableId" value="LOCAL-00003" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1634464377345</updated> | |||
</task> | |||
<task id="LOCAL-00004" summary="init"> | |||
<created>1634464901063</created> | |||
<option name="number" value="00004" /> | |||
<option name="presentableId" value="LOCAL-00004" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1634464901063</updated> | |||
</task> | |||
<task id="LOCAL-00005" summary="hotel"> | |||
<created>1634742511624</created> | |||
<option name="number" value="00005" /> | |||
<option name="presentableId" value="LOCAL-00005" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1634742511624</updated> | |||
</task> | |||
<task id="LOCAL-00006" summary="init"> | |||
<created>1634832520863</created> | |||
<option name="number" value="00006" /> | |||
<option name="presentableId" value="LOCAL-00006" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1634832520863</updated> | |||
</task> | |||
<task id="LOCAL-00007" summary="11111"> | |||
<created>1634984788225</created> | |||
<option name="number" value="00007" /> | |||
<option name="presentableId" value="LOCAL-00007" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1634984788225</updated> | |||
</task> | |||
<task id="LOCAL-00008" summary="init"> | |||
<created>1635042420768</created> | |||
<option name="number" value="00008" /> | |||
<option name="presentableId" value="LOCAL-00008" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1635042420769</updated> | |||
</task> | |||
<task id="LOCAL-00009" summary="init"> | |||
<created>1635063977093</created> | |||
<option name="number" value="00009" /> | |||
<option name="presentableId" value="LOCAL-00009" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1635063977093</updated> | |||
</task> | |||
<task id="LOCAL-00010" summary="init"> | |||
<created>1635067483089</created> | |||
<option name="number" value="00010" /> | |||
<option name="presentableId" value="LOCAL-00010" /> | |||
<option name="project" value="LOCAL" /> | |||
<updated>1635067483089</updated> | |||
</task> | |||
<option name="localTasksCounter" value="11" /> | |||
<servers /> | |||
</component> | |||
<component name="TypeScriptGeneratedFilesManager"> | |||
<option name="version" value="1" /> | |||
</component> | |||
<component name="Vcs.Log.Tabs.Properties"> | |||
<option name="TAB_STATES"> | |||
<map> | |||
<entry key="MAIN"> | |||
<value> | |||
<State /> | |||
</value> | |||
</entry> | |||
</map> | |||
</option> | |||
</component> | |||
<component name="VcsManagerConfiguration"> | |||
<MESSAGE value="hotel" /> | |||
<MESSAGE value="11111" /> | |||
<MESSAGE value="init" /> | |||
<option name="LAST_COMMIT_MESSAGE" value="init" /> | |||
</component> | |||
<component name="WindowStateProjectService"> | |||
<state x="222" y="0" key="#Servers" timestamp="1634445412897"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="222" y="0" key="#Servers/0.0.1280.680@0.0.1280.680" timestamp="1634445412897" /> | |||
<state x="96" y="0" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1634462037912"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="96" y="0" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1280.680@0.0.1280.680" timestamp="1634462037912" /> | |||
<state x="365" y="143" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1634985372691"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="365" y="143" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1280.680@0.0.1280.680" timestamp="1634985372691" /> | |||
<state x="371" y="96" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1635064055100"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="371" y="96" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.1280.680@0.0.1280.680" timestamp="1635064055100" /> | |||
<state x="247" y="0" key="CommitChangelistDialog2" timestamp="1635067780648"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="247" y="0" key="CommitChangelistDialog2/0.0.1280.680@0.0.1280.680" timestamp="1635067780648" /> | |||
<state x="421" y="96" key="FileChooserDialogImpl" timestamp="1634453017169"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="421" y="96" key="FileChooserDialogImpl/0.0.1280.680@0.0.1280.680" timestamp="1634453017169" /> | |||
<state width="1238" height="149" key="GridCell.Tab.0.bottom" timestamp="1634462364022"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.0.bottom/0.0.1280.680@0.0.1280.680" timestamp="1634462364022" /> | |||
<state width="1238" height="149" key="GridCell.Tab.0.center" timestamp="1634462364020"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.0.center/0.0.1280.680@0.0.1280.680" timestamp="1634462364020" /> | |||
<state width="1238" height="149" key="GridCell.Tab.0.left" timestamp="1634462364019"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.0.left/0.0.1280.680@0.0.1280.680" timestamp="1634462364019" /> | |||
<state width="1238" height="149" key="GridCell.Tab.0.right" timestamp="1634462364021"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.0.right/0.0.1280.680@0.0.1280.680" timestamp="1634462364021" /> | |||
<state width="1238" height="149" key="GridCell.Tab.1.bottom" timestamp="1634462364026"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.1.bottom/0.0.1280.680@0.0.1280.680" timestamp="1634462364026" /> | |||
<state width="1238" height="149" key="GridCell.Tab.1.center" timestamp="1634462364024"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.1.center/0.0.1280.680@0.0.1280.680" timestamp="1634462364024" /> | |||
<state width="1238" height="149" key="GridCell.Tab.1.left" timestamp="1634462364023"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.1.left/0.0.1280.680@0.0.1280.680" timestamp="1634462364023" /> | |||
<state width="1238" height="149" key="GridCell.Tab.1.right" timestamp="1634462364025"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state width="1238" height="149" key="GridCell.Tab.1.right/0.0.1280.680@0.0.1280.680" timestamp="1634462364025" /> | |||
<state x="350" y="56" key="MultipleFileMergeDialog" timestamp="1634829448022"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="350" y="56" key="MultipleFileMergeDialog/0.0.1280.680@0.0.1280.680" timestamp="1634829448022" /> | |||
<state x="500" y="51" key="RollbackChangesDialog" timestamp="1634222863596"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="500" y="51" key="RollbackChangesDialog/0.0.1280.680@0.0.1280.680" timestamp="1634222863596" /> | |||
<state x="142" y="0" key="SettingsEditor" timestamp="1634462282710"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="142" y="0" key="SettingsEditor/0.0.1280.680@0.0.1280.680" timestamp="1634462282710" /> | |||
<state x="371" y="90" width="591" height="524" key="StructurePopup" timestamp="1635064046155"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="371" y="90" width="591" height="524" key="StructurePopup/0.0.1280.680@0.0.1280.680" timestamp="1635064046155" /> | |||
<state x="233" y="74" key="Vcs.Push.Dialog.v2" timestamp="1635067861265"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="233" y="74" key="Vcs.Push.Dialog.v2/0.0.1280.680@0.0.1280.680" timestamp="1635067861265" /> | |||
<state x="335" y="237" width="760" height="312" maximized="true" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1634222692562"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="335" y="237" width="760" height="312" maximized="true" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.0.1280.680@0.0.1280.680" timestamp="1634222692562" /> | |||
<state x="436" y="258" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1634829543368"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="436" y="258" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.1280.680@0.0.1280.680" timestamp="1634829543368" /> | |||
<state x="319" y="72" width="779" height="600" key="find.popup" timestamp="1634984161512"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="319" y="72" width="779" height="600" key="find.popup/0.0.1280.680@0.0.1280.680" timestamp="1634984161512" /> | |||
<state x="305" y="4" width="672" height="678" key="search.everywhere.popup" timestamp="1635063310208"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="305" y="4" width="672" height="678" key="search.everywhere.popup/0.0.1280.680@0.0.1280.680" timestamp="1635063310208" /> | |||
<state x="439" y="306" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1633843159458"> | |||
<screen x="0" y="0" width="1280" height="680" /> | |||
</state> | |||
<state x="439" y="306" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.0.1280.680@0.0.1280.680" timestamp="1633843159458" /> | |||
</component> | |||
<component name="XDebuggerManager"> | |||
<breakpoint-manager> | |||
<breakpoints> | |||
<line-breakpoint enabled="true" type="php"> | |||
<url>file://$PROJECT_DIR$/public/index.php</url> | |||
<line>13</line> | |||
<option name="timeStamp" value="3" /> | |||
</line-breakpoint> | |||
<line-breakpoint enabled="true" type="php"> | |||
<url>file://$PROJECT_DIR$/public/hotel.php</url> | |||
<line>15</line> | |||
<option name="timeStamp" value="4" /> | |||
</line-breakpoint> | |||
</breakpoints> | |||
</breakpoint-manager> | |||
</component> | |||
</project> |
@@ -35,6 +35,54 @@ class Deposit extends Backend | |||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | |||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | |||
*/ | |||
/** | |||
* 查看 | |||
*/ | |||
public function index() | |||
{ | |||
//设置过滤方法 | |||
$this->request->filter(['strip_tags', 'trim']); | |||
if ($this->request->isAjax()) { | |||
//如果发送的来源是Selectpage,则转发到Selectpage | |||
if ($this->request->request('keyField')) { | |||
return $this->selectpage(); | |||
} | |||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||
$group_id=$this->auth->getGroupId(); | |||
$list = $this->model | |||
->alias("a") | |||
->join('hbp_admin c','a.create_id = c.id','left') | |||
->join('hbp_cf_suplier_info d','a.payee_id = d.id','left') | |||
->field("a.*,c.nickname,d.supplier_name") | |||
->where($where); | |||
if ($group_id){ | |||
$list = $list | |||
->where("group_id","=",$group_id) | |||
->order($sort, $order) | |||
->paginate($limit); | |||
}else{ | |||
$list = $list | |||
->order($sort, $order) | |||
->paginate($limit); | |||
} | |||
$result = $list->items(); | |||
foreach ($result as $k=>$item){ | |||
switch ($item["status"]){ | |||
case 1: | |||
$result[$k]["status"]="已付款"; | |||
break; | |||
case 2: | |||
$result[$k]["status"]="回收中"; | |||
break; | |||
case 3: | |||
$result[$k]["status"]="已回收"; | |||
break; | |||
} | |||
} | |||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||
return json($result); | |||
} | |||
return $this->view->fetch(); | |||
} | |||
} |
@@ -71,7 +71,28 @@ class OrderMain extends Backend | |||
->order($sort, $order) | |||
->paginate($limit); | |||
} | |||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||
$result = $list->items(); | |||
foreach ($result as $k=>$item){ | |||
switch ($item["order_status"]){ | |||
case 0: | |||
$result[$k]["order_status"]="待处理"; | |||
break; | |||
case 1: | |||
$result[$k]["order_status"]="已确认"; | |||
break; | |||
case 2: | |||
$result[$k]["order_status"]="部分取消"; | |||
break; | |||
case 10: | |||
$result[$k]["order_status"]="已完成"; | |||
break; | |||
case 11: | |||
$result[$k]["order_status"]="已取消"; | |||
break; | |||
} | |||
} | |||
$result = array("total" => $list->total(), "rows" =>$result); | |||
return json($result); | |||
} | |||
return $this->view->fetch(); | |||
@@ -126,4 +147,78 @@ class OrderMain extends Backend | |||
return $this->view->fetch(); | |||
} | |||
/** | |||
* 编辑 | |||
*/ | |||
public function edit($ids = null) | |||
{ | |||
$row = $this->model->get($ids); | |||
if (!$row) { | |||
$this->error(__('No Results were found')); | |||
} | |||
$adminIds = $this->getDataLimitAdminIds(); | |||
if (is_array($adminIds)) { | |||
if (!in_array($row[$this->dataLimitField], $adminIds)) { | |||
$this->error(__('You have no permission')); | |||
} | |||
} | |||
if ($this->request->isPost()) { | |||
$params = $this->request->post("row/a"); | |||
if ($params) { | |||
$params = $this->preExcludeFields($params); | |||
$result = false; | |||
Db::startTrans(); | |||
try { | |||
//是否采用模型验证 | |||
if ($this->modelValidate) { | |||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | |||
$row->validateFailException(true)->validate($validate); | |||
} | |||
$result = $row->allowField(true)->save($params); | |||
Db::commit(); | |||
} catch (ValidateException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (PDOException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (Exception $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} | |||
if ($result !== false) { | |||
$this->success(); | |||
} else { | |||
$this->error(__('No rows were updated')); | |||
} | |||
} | |||
$this->error(__('Parameter %s can not be empty', '')); | |||
} | |||
$this->view->assign("row", $row); | |||
return $this->view->fetch(); | |||
} | |||
public function newAdd($id =null){ | |||
$orderMain = $this->model->find($id); | |||
if (!$orderMain){ | |||
return null; | |||
} | |||
$orderHotelList=(new \app\admin\model\OrderHotel()) | |||
->where("order_id","=",$id) | |||
->find(); | |||
$orderItemList=(new \app\admin\model\OrderItem()) | |||
->where("order_id","=",$id) | |||
->find(); | |||
$result = [ | |||
"orderMain"=>$orderMain, | |||
"hotel"=>$orderHotelList, | |||
"item"=>$orderItemList | |||
]; | |||
return json($result); | |||
} | |||
} |
@@ -3,6 +3,9 @@ | |||
namespace app\admin\controller; | |||
use app\common\controller\Backend; | |||
use think\Db; | |||
use think\exception\PDOException; | |||
use think\exception\ValidateException; | |||
/** | |||
* 收款账单管理 | |||
@@ -35,6 +38,150 @@ class ReceiptOrder extends Backend | |||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | |||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | |||
*/ | |||
/** | |||
* 查看 | |||
*/ | |||
public function index() | |||
{ | |||
//设置过滤方法 | |||
$this->request->filter(['strip_tags', 'trim']); | |||
if ($this->request->isAjax()) { | |||
//如果发送的来源是Selectpage,则转发到Selectpage | |||
if ($this->request->request('keyField')) { | |||
return $this->selectpage(); | |||
} | |||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||
$group_id=$this->auth->getGroupId(); | |||
$list = $this->model | |||
->alias("a") | |||
->join('hbp_admin c','a.create_id = c.id','left') | |||
->field("a.*,c.nickname") | |||
->where($where); | |||
if ($group_id){ | |||
$list = $list | |||
->where("group_id","=",$group_id) | |||
->order($sort, $order) | |||
->paginate($limit); | |||
}else{ | |||
$list = $list | |||
->order($sort, $order) | |||
->paginate($limit); | |||
} | |||
$result = $list->items(); | |||
foreach ($result as $k=>$item){ | |||
switch ($item["status"]){ | |||
case 0: | |||
$result[$k]["status"]="未付款"; | |||
break; | |||
case 1: | |||
$result[$k]["status"]="已付款"; | |||
break; | |||
} | |||
} | |||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||
return json($result); | |||
} | |||
return $this->view->fetch(); | |||
} | |||
/** | |||
* 添加 | |||
*/ | |||
public function add() | |||
{ | |||
if ($this->request->isPost()) { | |||
$params = $this->request->post("row/a"); | |||
if ($params) { | |||
$params = $this->preExcludeFields($params); | |||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | |||
$params[$this->dataLimitField] = $this->auth->id; | |||
} | |||
$result = false; | |||
Db::startTrans(); | |||
try { | |||
//是否采用模型验证 | |||
if ($this->modelValidate) { | |||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | |||
$this->model->validateFailException(true)->validate($validate); | |||
} | |||
$params['create_id']=$this->auth->id; | |||
$params['group_id']=$this->auth->getGroupId(); | |||
$result = $this->model->allowField(true)->save($params); | |||
Db::commit(); | |||
} catch (ValidateException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (PDOException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (Exception $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} | |||
if ($result !== false) { | |||
$this->success(); | |||
} else { | |||
$this->error(__('No rows were inserted')); | |||
} | |||
} | |||
$this->error(__('Parameter %s can not be empty', '')); | |||
} | |||
return $this->view->fetch(); | |||
} | |||
/** | |||
* 编辑 | |||
*/ | |||
public function edit($ids = null) | |||
{ | |||
$row = $this->model->get($ids); | |||
if (!$row) { | |||
$this->error(__('No Results were found')); | |||
} | |||
$adminIds = $this->getDataLimitAdminIds(); | |||
if (is_array($adminIds)) { | |||
if (!in_array($row[$this->dataLimitField], $adminIds)) { | |||
$this->error(__('You have no permission')); | |||
} | |||
} | |||
if ($this->request->isPost()) { | |||
$params = $this->request->post("row/a"); | |||
if ($params) { | |||
$params = $this->preExcludeFields($params); | |||
$result = false; | |||
Db::startTrans(); | |||
try { | |||
//是否采用模型验证 | |||
if ($this->modelValidate) { | |||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | |||
$row->validateFailException(true)->validate($validate); | |||
} | |||
$result = $row->allowField(true)->save($params); | |||
Db::commit(); | |||
} catch (ValidateException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (PDOException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (Exception $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} | |||
if ($result !== false) { | |||
$this->success(); | |||
} else { | |||
$this->error(__('No rows were updated')); | |||
} | |||
} | |||
$this->error(__('Parameter %s can not be empty', '')); | |||
} | |||
$this->view->assign("row", $row); | |||
return $this->view->fetch(); | |||
} | |||
} |
@@ -0,0 +1,89 @@ | |||
<?php | |||
namespace app\admin\service; | |||
use app\admin\model\OrderHotel; | |||
use app\admin\model\OrderItem; | |||
use app\admin\model\OrderMain; | |||
use app\admin\model\Purchase; | |||
use app\admin\model\PurchasePrice; | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/10/24 | |||
* Time: 15:55 | |||
*/ | |||
class OrderMainService | |||
{ | |||
/** | |||
* 设置主订单金额 | |||
* @param int $orderId | |||
* @throws | |||
*/ | |||
private static function setOrderAmount(int $orderId){ | |||
$itemModel = new OrderItem(); | |||
$hotelModel = new OrderHotel(); | |||
$itemList =$itemModel->where(["order_id"=>$orderId])->select()->toArray(); | |||
$hotelList = $hotelModel->where(["order_id"=>$orderId])->select()->toArray(); | |||
$amount = 0; | |||
$cost = 0; | |||
foreach ($itemList as $item) { | |||
$amount += $item['total_price']; | |||
$cost+= $item['total_cost']; | |||
} | |||
foreach ($hotelList as $hotel) { | |||
$amount += $hotel['total_price']; | |||
$cost += $hotel["total_cost"]; | |||
} | |||
//更新金额 | |||
OrderMain::update(["total_amount"=>$amount,"cost_amount"=>$cost])->where(["id"=>$orderId]); | |||
} | |||
/** | |||
* 设置子订单金额 | |||
* @param int $subOrderId | |||
* @param string $prodType | |||
* @throws \think\db\exception\DataNotFoundException | |||
* @throws \think\db\exception\ModelNotFoundException | |||
* @throws \think\exception\DbException | |||
*/ | |||
private static function setSubOrderAmount( int $subOrderId,string $prodType) { | |||
$purchaseModel = new Purchase(); | |||
$purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select()->toArray(); | |||
$cost = 0; | |||
$amount = 0; | |||
foreach ($purchaseList as $purchase) { | |||
$cost += $purchase['total_cost']; | |||
$amount += $purchase['total_price']; | |||
} | |||
if ($prodType == "hotel") { | |||
OrderHotel::update(["total_price"=>$amount,"total_cost"=>$cost])->where(["id"=>$subOrderId]); | |||
} else { | |||
OrderItem::update(["total_price"=>$amount,"total_cost"=>$cost])->where(["id"=>$subOrderId]); | |||
} | |||
} | |||
/** | |||
* 设置采购单/子订单/主订单 金额 | |||
* @param Purchase $purchase | |||
* @throws \think\db\exception\DataNotFoundException | |||
* @throws \think\db\exception\ModelNotFoundException | |||
* @throws \think\exception\DbException | |||
*/ | |||
public function setPurchase(Purchase $purchase){ | |||
$purchasePrice = new PurchasePrice(); | |||
$purchasePriceList = $purchasePrice->where(["purchase_id"=>$purchase["id"],"del_flag"=>0])->select()->toArray(); | |||
$cost = 0; | |||
$amount = 0; | |||
foreach ($purchasePriceList as $price) { | |||
$cost += $price['cost'] * $price["cnt"]; | |||
$amount += $price['price'] * $price["cnt"]; | |||
} | |||
Purchase::update(["total_price"=>$amount,["total_cost"=>$cost]])->where(["id"=>$purchase['id']]); | |||
//更新子表 | |||
static::setSubOrderAmount($purchase['order_detail_id'], $purchase['prod_type']); | |||
//更新主表金额 | |||
static::setOrderAmount($purchase['order_id']); | |||
} | |||
} |
@@ -1,39 +1,21 @@ | |||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Del_flag')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-del_flag" data-rule="required" class="form-control" name="row[del_flag]" type="number" value="0"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:date('Y-m-d H:i:s')}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('收款状态')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-status" data-rule="required" class="form-control" name="row[status]" type="number" value="0"> | |||
{:Form::radios('row[status]', [0=>"未收款",1=>"已收款"],0, ['data-rule'=>'required'])} | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Order_ids')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-order_ids" data-rule="required" data-source="order/index" data-multiple="true" class="form-control selectpage" name="row[order_ids]" type="text" value=""> | |||
<input id="c-order_ids" data-rule="required" class="form-control" name="row[order_ids]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -1,33 +1,15 @@ | |||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Del_flag')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-del_flag" data-rule="required" class="form-control" name="row[del_flag]" type="number" value="{$row.del_flag|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:$row.update_time?datetime($row.update_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('收款状态')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-status" data-rule="required" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}"> | |||
{:Form::radios('row[status]', [0=>"未收款",1=>"已收款"],$row.status, ['data-rule'=>'required'])} | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | |||
{field: 'payee_id', title: __('Payee_id')}, | |||
{field: 'memo', title: __('Memo'), operate: 'LIKE'}, | |||
{field: 'status', title: __('Status')}, | |||
{field: 'status', title: __('押金状态')}, | |||
{field: 'amount', title: __('Amount'), operate:'BETWEEN'}, | |||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | |||
] | |||
@@ -24,14 +24,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
sortName: 'id', | |||
columns: [ | |||
[ | |||
{checkbox: true}, | |||
{field: 'id', title: __('Id')}, | |||
{field: 'del_flag', title: __('Del_flag'), formatter: Table.api.formatter.flag}, | |||
{field: 'nickname', title: __('创建人')}, | |||
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | |||
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | |||
{field: 'name', title: __('Name'), operate: 'LIKE'}, | |||
{field: 'status', title: __('Status')}, | |||
{field: 'order_ids', title: __('Order_ids'), operate: 'LIKE'}, | |||
{field: 'status', title: __('收款状态')}, | |||
{field: 'order_ids', title: __('管理的订单id'), operate: 'LIKE'}, | |||
{field: 'money', title: __('Money'), operate:'BETWEEN'}, | |||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | |||
] | |||
@@ -1,4 +0,0 @@ | |||
<?php | |||
//000000000000 | |||
exit();?> | |||
a:0:{} |
@@ -1,9 +0,0 @@ | |||
--------------------------------------------------------------- | |||
[ 2021-10-10T13:27:23+08:00 ] 127.0.0.1 GET cz.com/eQUzkcVpyX.php/dashboard?ref=addtabs | |||
[ error ] [1049]SQLSTATE[HY000] [1049] Unknown database 'hbb' | |||
--------------------------------------------------------------- | |||
[ 2021-10-10T13:27:29+08:00 ] 127.0.0.1 GET cz.com/eQUzkcVpyX.php/dashboard?ref=addtabs | |||
[ error ] [1049]SQLSTATE[HY000] [1049] Unknown database 'hbb' | |||
--------------------------------------------------------------- | |||
[ 2021-10-10T13:27:35+08:00 ] 127.0.0.1 GET cz.com/eQUzkcVpyX.php/dashboard?ref=addtabs | |||
[ error ] [1049]SQLSTATE[HY000] [1049] Unknown database 'hbb' |