后台处理开票流程

搜索里,平台活动类别,也能搜索
This commit is contained in:
qinzexin 2025-06-18 18:29:31 +08:00
parent 9814f3b0ed
commit 32e079b44f
14 changed files with 607 additions and 136 deletions

View File

@ -400,13 +400,13 @@ class Index extends Backend
if($order)throw new \Exception("存在正在使用中的课程订单或存在正在售后中的课程订单无法继续操作!");
// 课程存在售后订单则不允许操作
//有课程不允许删
$classesLib = ClassesLib::where("manystore_id",$id)->find();
if($classesLib)throw new \Exception("请先删除课程后再删除机构!");
// $classesLib = ClassesLib::where("manystore_id",$id)->find();
// if($classesLib)throw new \Exception("请先删除课程后再删除机构!");
// 课程存在售后订单则不允许操作
$order = \app\common\model\school\classes\activity\order\Order::where("manystore_id",$id)->where("status","not in","-3,6,9")->find();
if($order)throw new \Exception("存在正在使用中的活动订单报名学员,无法继续操作!");
// $order = \app\common\model\school\classes\activity\order\Order::where("manystore_id",$id)->where("status","not in","-3,6,9")->find();
// if($order)throw new \Exception("存在正在使用中的活动订单报名学员,无法继续操作!");
$activity = Activity::where("manystore_id",$id)->find();
if($activity)throw new \Exception("请先删除活动后再删除机构!");
@ -741,42 +741,42 @@ class Index extends Backend
exception('账号信息删除失败');
}
$result = $this->shopModel->where(array('id'=>$row['shop_id']))->delete();
\app\common\model\manystore\UserAuth::where(array('shop_id'=>$row['shop_id']))->delete();
\app\common\model\school\classes\Teacher::where(array('shop_id'=>$row['shop_id']))->delete();
\app\common\model\school\classes\Verification::where(array('shop_id'=>$row['shop_id']))->delete();
Order::where(array('shop_id'=>$row['shop_id']))->delete();
OrderDetail::where(array('shop_id'=>$row['shop_id']))->delete();
// \app\common\model\manystore\UserAuth::where(array('shop_id'=>$row['shop_id']))->delete();
// \app\common\model\school\classes\Teacher::where(array('shop_id'=>$row['shop_id']))->delete();
// \app\common\model\school\classes\Verification::where(array('shop_id'=>$row['shop_id']))->delete();
// Order::where(array('shop_id'=>$row['shop_id']))->delete();
// OrderDetail::where(array('shop_id'=>$row['shop_id']))->delete();
\app\admin\model\school\classes\activity\order\Order::where(array('shop_id'=>$row['shop_id']))->delete();
\app\admin\model\school\classes\activity\order\OrderDetail::where(array('shop_id'=>$row['shop_id']))->delete();
\app\admin\model\school\classes\hour\Order::where(array('shop_id'=>$row['shop_id']))->delete();
ServiceOrder::where(array('shop_id'=>$row['shop_id']))->delete();
$classesLibs = \app\common\model\school\classes\ClassesLib::where(array('shop_id'=>$row['shop_id']))->select();
foreach( $classesLibs as $lib){
$specs = $lib->specs;
foreach ($specs as $spec){
$spec->delete();
}
$lib->delete();
}
//删除活动及其规格
$activitys = \app\common\model\school\classes\activity\Activity::where(array('shop_id'=>$row['shop_id']))->select();
foreach ($activitys as $activity){
$specs = $activity->items;
foreach ($specs as $spec){
$spec->delete();
}
$activity->delete();
}
$activityauths = \app\common\model\school\classes\activity\ActivityAuth::where(array('shop_id'=>$row['shop_id']))->select();
foreach ($activityauths as $activity){
$specs = $activity->itemauths;
foreach ($specs as $spec){
$spec->delete();
}
$activity->delete();
}
// \app\admin\model\school\classes\activity\order\Order::where(array('shop_id'=>$row['shop_id']))->delete();
// \app\admin\model\school\classes\activity\order\OrderDetail::where(array('shop_id'=>$row['shop_id']))->delete();
//
// \app\admin\model\school\classes\hour\Order::where(array('shop_id'=>$row['shop_id']))->delete();
// ServiceOrder::where(array('shop_id'=>$row['shop_id']))->delete();
// $classesLibs = \app\common\model\school\classes\ClassesLib::where(array('shop_id'=>$row['shop_id']))->select();
// foreach( $classesLibs as $lib){
// $specs = $lib->specs;
// foreach ($specs as $spec){
// $spec->delete();
// }
// $lib->delete();
// }
// //删除活动及其规格
// $activitys = \app\common\model\school\classes\activity\Activity::where(array('shop_id'=>$row['shop_id']))->select();
// foreach ($activitys as $activity){
// $specs = $activity->items;
// foreach ($specs as $spec){
// $spec->delete();
// }
// $activity->delete();
// }
// $activityauths = \app\common\model\school\classes\activity\ActivityAuth::where(array('shop_id'=>$row['shop_id']))->select();
// foreach ($activityauths as $activity){
// $specs = $activity->itemauths;
// foreach ($specs as $spec){
// $spec->delete();
// }
// $activity->delete();
// }
Admin::where(array('admin_shop_id'=>$row['shop_id']))->update(['admin_shop_id'=>0]);

View File

@ -325,4 +325,11 @@ class Order extends Backend
}

View File

@ -3,6 +3,10 @@
namespace app\admin\controller\user\invoice;
use app\common\controller\Backend;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 个人发票申请管理
@ -74,4 +78,149 @@ class Apply extends Backend
return $this->view->fetch();
}
// if($this->request->isPost())
// {
// try{
// $params = $this->request->post("row/a");
//// $order_no = $params["order_no"];
//// $reject_reason = $params["reject_reason"] ?? "";
//// $price = $params["price"] ?? 0;
//// $status = $params["status"];
// $model = (new \app\common\model\user\invoice\Apply());
// $model->add($row["order_no"],$params,$this->auth->id,'admin',false,true);
//
// }catch (\Exception $e){
// $this->error($e->getMessage());
// }
//
// $this->success("已完成售后审核");
// }
/**
* 添加
*
* @return string
* @throws \think\Exception
*/
public function add()
{
if (false === $this->request->isPost()) {
return $this->view->fetch();
}
$params = $this->request->post('row/a');
$order_no = $this->request->param('order_no/s');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
try{
$model = (new \app\common\model\user\invoice\Apply());
$model->add($order_no,$params,$this->auth->id,'admin',false,true);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("申请成功!");
// $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()->validate($validate);
// }
// $result = $this->model->allowField(true)->save($params);
// Db::commit();
// } catch (ValidateException|PDOException|Exception $e) {
// Db::rollback();
// $this->error($e->getMessage());
// }
// if ($result === false) {
// $this->error(__('No rows were inserted'));
// }
// $this->success();
}
/**
* 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
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) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
try{
$desc = $params["desc"];
$model = (new \app\common\model\user\invoice\Apply());
$model->examine($ids,$desc,$this->auth->id,'admin',false,true);
$row->allowField(true)->save($params);
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success("设置成功!");
// 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()->validate($validate);
// }
// $result = $row->allowField(true)->save($params);
// Db::commit();
// } catch (ValidateException|PDOException|Exception $e) {
// Db::rollback();
// $this->error($e->getMessage());
// }
// if (false === $result) {
// $this->error(__('No rows were updated'));
// }
// $this->success();
}
}

View File

@ -10,7 +10,9 @@ return [
'Apply_type' => '申请类型',
'Apply_type 1' => '单开',
'Apply_type 2' => '连开',
'Price' => '申请金额',
'Price' => '申请实付金额',
'Fee_price' => '平台手续费',
'Desc' => '开票备注',
'Head_type' => '抬头类型',
'Head_type personal' => '个人或事业单位',
'Head_type corporate' => '企业',

View File

@ -1,47 +1,47 @@
<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">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="mobile" data-format-item="{id} - {nickname} - {mobile}" class="form-control selectpage" name="row[user_id]" type="text" value="{$q_user_id}">
<!-- <span style="color: red">-->
<!-- <div class="form-group">-->
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="mobile" data-format-item="{id} - {nickname} - {mobile}" class="form-control selectpage" name="row[user_id]" type="text" value="{$q_user_id}">-->
<!--&lt;!&ndash; <span style="color: red">&ndash;&gt;-->
<!-- (没找到用户则点击按钮创建用户后重新下拉框选用户)-->
<!-- <a data-url="user/user/changeuser" href="javascript:;" class="btn btn-success btn-changeuser {:$auth->check('user/user/changeuser')?'':'hide'}" title="根据手机号生成用户" ><i class="fa fa-plus"></i> 根据手机号生成用户</a>-->
<!--&lt;!&ndash; (没找到用户则点击按钮创建用户后重新下拉框选用户)&ndash;&gt;-->
<!--&lt;!&ndash; <a data-url="user/user/changeuser" href="javascript:;" class="btn btn-success btn-changeuser {:$auth->check('user/user/changeuser')?'':'hide'}" title="根据手机号生成用户" ><i class="fa fa-plus"></i> 根据手机号生成用户</a>&ndash;&gt;-->
<!-- </span>-->
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
<!--&lt;!&ndash; </span>&ndash;&gt;-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="form-group">-->
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- -->
<!-- <div class="radio">-->
<!-- {foreach name="statusList" item="vo"}-->
<!-- <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label> -->
<!-- {/foreach}-->
<!-- </div>-->
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Apply_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-apply_type" data-rule="required" class="form-control selectpicker" name="row[apply_type]">
{foreach name="applyTypeList" item="vo"}
<option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
{/foreach}
</select>
<!-- </div>-->
<!-- </div>-->
<!-- <div class="form-group">-->
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Apply_type')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- -->
<!-- <select id="c-apply_type" data-rule="required" class="form-control selectpicker" name="row[apply_type]">-->
<!-- {foreach name="applyTypeList" item="vo"}-->
<!-- <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>-->
<!-- {/foreach}-->
<!-- </select>-->
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-price" data-rule="required" class="form-control" step="0.01" name="row[price]" type="number" value="0.00">
</div>
</div>
<!-- </div>-->
<!-- </div>-->
<!-- <div class="form-group">-->
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Price')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- <input id="c-price" data-rule="required" class="form-control" step="0.01" name="row[price]" type="number" value="0.00">-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Head_type')}:</label>
<div class="col-xs-12 col-sm-8">
@ -72,10 +72,13 @@
<input id="c-invoice_header" data-rule="required" class="form-control" name="row[invoice_header]" type="text">
</div>
</div>
<span id="enterprise_data">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Tax_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-tax_id" data-rule="required" class="form-control" name="row[tax_id]" type="text" value="">
<input id="c-tax_id" class="form-control" name="row[tax_id]" type="text" value="">
</div>
</div>
<div class="form-group">
@ -102,6 +105,8 @@
<input id="c-enterprise_phone" class="form-control" name="row[enterprise_phone]" type="text">
</div>
</div>
</span>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_reservation_phone')}:</label>
<div class="col-xs-12 col-sm-8">
@ -114,12 +119,12 @@
<input id="c-invoice_reservation_email" data-rule="required" class="form-control" name="row[invoice_reservation_email]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Invoicingtime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-invoicingtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[invoicingtime]" 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">{:__('Invoicingtime')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- <input id="c-invoicingtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[invoicingtime]" type="text" value="{:date('Y-m-d H:i:s')}">-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">

View File

@ -1,37 +1,26 @@
<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">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="mobile" data-format-item="{id} - {nickname} - {mobile}" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
<!-- <div class="form-group">-->
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="mobile" data-format-item="{id} - {nickname} - {mobile}" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">-->
<!-- <span style="color: red">-->
<!--&lt;!&ndash; <span style="color: red">&ndash;&gt;-->
<!-- (没找到用户则点击按钮创建用户后重新下拉框选用户)-->
<!-- <a data-url="user/user/changeuser" href="javascript:;" class="btn btn-success btn-changeuser {:$auth->check('user/user/changeuser')?'':'hide'}" title="根据手机号生成用户" ><i class="fa fa-plus"></i> 根据手机号生成用户</a>-->
<!--&lt;!&ndash; (没找到用户则点击按钮创建用户后重新下拉框选用户)&ndash;&gt;-->
<!--&lt;!&ndash; <a data-url="user/user/changeuser" href="javascript:;" class="btn btn-success btn-changeuser {:$auth->check('user/user/changeuser')?'':'hide'}" title="根据手机号生成用户" ><i class="fa fa-plus"></i> 根据手机号生成用户</a>&ndash;&gt;-->
<!-- </span>-->
<!--&lt;!&ndash; </span>&ndash;&gt;-->
</div>
<!-- </div>-->
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
<!-- </div>-->
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Apply_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-apply_type" data-rule="required" class="form-control selectpicker" name="row[apply_type]">
<select id="c-apply_type" disabled data-rule="required" class="form-control selectpicker" name="row[apply_type]">
{foreach name="applyTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.apply_type"}selected{/in}>{$vo}</option>
{/foreach}
@ -45,11 +34,22 @@
<input id="c-price" data-rule="required" class="form-control" step="0.01" name="row[price]" type="number" value="{$row.price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Fee_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-fee_price" data-rule="required" class="form-control" step="0.01" name="row[fee_price]" type="number" value="{$row.fee_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Head_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-head_type" data-rule="required" class="form-control selectpicker" name="row[head_type]">
<select id="c-head_type" disabled data-rule="required" class="form-control selectpicker" name="row[head_type]">
{foreach name="headTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.head_type"}selected{/in}>{$vo}</option>
{/foreach}
@ -61,7 +61,7 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-invoice_type" data-rule="required" class="form-control selectpicker" name="row[invoice_type]">
<select id="c-invoice_type" disabled data-rule="required" class="form-control selectpicker" name="row[invoice_type]">
{foreach name="invoiceTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.invoice_type"}selected{/in}>{$vo}</option>
{/foreach}
@ -72,57 +72,84 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_header')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-invoice_header" data-rule="required" class="form-control" name="row[invoice_header]" type="text" value="{$row.invoice_header|htmlentities}">
<input id="c-invoice_header" disabled data-rule="required" class="form-control" name="row[invoice_header]" type="text" value="{$row.invoice_header|htmlentities}">
</div>
</div>
<span id="enterprise_data">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Tax_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-tax_id" data-rule="required" class="form-control" name="row[tax_id]" type="text" value="{$row.tax_id|htmlentities}">
<input id="c-tax_id" disabled class="form-control" name="row[tax_id]" type="text" value="{$row.tax_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Bank_deposit')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-bank_deposit" class="form-control" name="row[bank_deposit]" type="text" value="{$row.bank_deposit|htmlentities}">
<input id="c-bank_deposit" disabled class="form-control" name="row[bank_deposit]" type="text" value="{$row.bank_deposit|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Bank_number')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-bank_number" class="form-control" name="row[bank_number]" type="text" value="{$row.bank_number|htmlentities}">
<input id="c-bank_number" disabled class="form-control" name="row[bank_number]" type="text" value="{$row.bank_number|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Enterprise_address')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-enterprise_address" class="form-control" name="row[enterprise_address]" type="text" value="{$row.enterprise_address|htmlentities}">
<input id="c-enterprise_address" disabled class="form-control" name="row[enterprise_address]" type="text" value="{$row.enterprise_address|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Enterprise_phone')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-enterprise_phone" class="form-control" name="row[enterprise_phone]" type="text" value="{$row.enterprise_phone|htmlentities}">
<input id="c-enterprise_phone" disabled class="form-control" name="row[enterprise_phone]" type="text" value="{$row.enterprise_phone|htmlentities}">
</div>
</div>
</span>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_reservation_phone')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-invoice_reservation_phone" data-rule="required" class="form-control" name="row[invoice_reservation_phone]" type="text" value="{$row.invoice_reservation_phone|htmlentities}">
<input id="c-invoice_reservation_phone" disabled data-rule="required" class="form-control" name="row[invoice_reservation_phone]" type="text" value="{$row.invoice_reservation_phone|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Invoice_reservation_email')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-invoice_reservation_email" data-rule="required" class="form-control" name="row[invoice_reservation_email]" type="text" value="{$row.invoice_reservation_email|htmlentities}">
<input id="c-invoice_reservation_email" disabled data-rule="required" class="form-control" name="row[invoice_reservation_email]" type="text" value="{$row.invoice_reservation_email|htmlentities}">
</div>
</div>
<!-- <div class="form-group">-->
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Invoicingtime')}:</label>-->
<!-- <div class="col-xs-12 col-sm-8">-->
<!-- <input id="c-invoicingtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[invoicingtime]" type="text" value="{:$row.invoicingtime?datetime($row.invoicingtime):''}">-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Invoicingtime')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-invoicingtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[invoicingtime]" type="text" value="{:$row.invoicingtime?datetime($row.invoicingtime):''}">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" {in name="key" value="1"} disabled {/in} name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Desc')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-desc" data-rule="required" class="form-control" name="row[desc]" type="text" value="{$row.desc|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">

View File

@ -431,9 +431,9 @@ class Activity extends BaseModel
//活动开始和结束时间不能跨天
if(date('Y-m-d',$start_time)!=date('Y-m-d',$end_time)){
throw new \Exception("活动开始和结束时间不能跨天");
}
// if(date('Y-m-d',$start_time)!=date('Y-m-d',$end_time)){
// throw new \Exception("活动开始和结束时间不能跨天");
// }
//settlement_time 最后结算时间等于活动结束时间往后延长n秒n取配置
$activity_end_settle = config("site.activity_end_settle") ?:0;
@ -784,6 +784,19 @@ class Activity extends BaseModel
$selfetch = $selfetch->field($field);
if (isset($keywords) && $keywords) {
//查询分类名获得分类id
$keywords_cate_ids = Cate::where("name",'like', '%' . $keywords . '%')->column("id");
if($keywords_cate_ids){
$keywords_cate_ids = implode("|",$keywords_cate_ids);
$selfetch = $selfetch->whereRaw(" {$a}cate_ids REGEXP '({$keywords_cate_ids})'");
// $selfetch = $selfetch->whereOr( function ($query)use($a,$keywords_cate_ids){
// $query->whereRaw(" {$a}cate_ids REGEXP '({$keywords_cate_ids})'")
// ->where("{$a}show", '=', '1');
// });
}
$selfetch = $selfetch->where("{$a}title|{$a}address|{$a}address_detail|{$a}address_city", 'like', '%' . $keywords . '%');
}

View File

@ -277,7 +277,7 @@ class Order extends BaseModel
return $this->hasMany(OrderCode::class,'activity_order_id');
}
public function invoiceapply(){
public function invoiceaplpy(){
return $this->belongsTo(Apply::class, 'user_invoice_apply_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
@ -521,6 +521,8 @@ class Order extends BaseModel
$data['refund_desc'] = (new Activity)->refund_desc(0,$data["id"]);
//开票信息
$data->invoiceaplpy;
return $data;
}
@ -2223,6 +2225,10 @@ class Order extends BaseModel
if($total_refundprice < 0.01 || $total_refundprice > $order['sub_refundprice']) throw new \Exception("退款金额错误");
//申请了发票则无法申请售后
if($order['user_invoice_apply_id']) throw new \Exception("您已申请开票,无法再申请售后!");
//判断逻辑
if($trans){
self::beginTrans();

View File

@ -4,6 +4,7 @@ namespace app\common\model\user\invoice;
use app\common\model\BaseModel;
use app\common\model\school\activity\order\Order;
use app\common\model\school\activity\order\OrderLog;
use think\Model;
@ -107,24 +108,31 @@ class Apply extends BaseModel
}
public function activityorders()
{
return $this->hasMany(Order::class, 'user_invoice_apply_id', 'id');
}
/** 申请发票
* @param $order_no 申请发票的订单号
* @param
* @param $trans
* @return true
* @throws \Exception
*/
public function add($order_no,$params,$check=true,$trans=false){
public function add($order_no,$params,$oper_id = 0,$oper_type='user',$check=true,$trans=false){
if (empty($params)) {
throw new \Exception(__('Parameter %s can not be empty', ''));
}
$order = Order::getHaveInvoiceApplyOrder($order_no);
$rule = [
'user_id'=>'require',
// 'user_id'=>'require',
'head_type'=>'require',
'invoice_type'=>'require',
'invoice_header' => 'require',
@ -133,11 +141,10 @@ class Apply extends BaseModel
];
$rule_msg = [
"user_id.require"=>'提交用户必填',
// "user_id.require"=>'提交用户必填',
"head_type.require"=>'抬头类型必填',
"invoice_type.require"=>'发票类型必填',
'invoice_header.require' => '发票抬头必填',
'invoice_reservation_phone.require' => '发票预留电话必填',
'invoice_reservation_email.require' => '发票预留邮箱必填',
];
@ -169,6 +176,46 @@ class Apply extends BaseModel
}
//是否存在逗号隔开
$order_nos = explode(',',$order_no);
$order_ids = [];
$orders = [];
foreach ($order_nos as $orderno){
$order = Order::getHaveInvoiceApplyOrder($orderno);
if($check){
//用户操作权限检测
Order::checkOptionAuth($order['id'],$oper_id ,$oper_type);
}
$order_ids[] = $order->id;
$orders[] = $order;
$params['user_id'] = $order->user_id;
}
if(empty($order_ids)){
throw new \Exception('订单不存在或已开过发票');
}
//是单开还是连开
if(count($order_ids) >1){
$params['apply_type'] = '2';
$typeinfo = "(联合开票)";
}else{
$params['apply_type'] = '1';
$typeinfo = "(单独开票)";
}
//是否已提交发票申请
if($order->invoiceaplpy) throw new \Exception('订单已提交发票申请,请勿重复提交!');
//计算合开金额
//用户支付金额
$params['price'] = Order::where( "id","in",$order_ids)->sum("sub_refundprice");
//平台手续费
$params['fee_price'] = Order::where( "id","in",$order_ids)->sum("fee_price");
if(!$params['price']) throw new \Exception('订单金额异常,该订单无可申请发票金额');
@ -186,8 +233,28 @@ class Apply extends BaseModel
// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
// $this->validateFailException()->validate($validate);
// }
//添加发票申请
$self = new self;
$result = $self->allowField(true)->save($params);
//更新订单发票申请状态
Order::where( "id","in",$order_ids)->update([
'invoice_status'=>'1',
'user_invoice_apply_id'=> $self->id,
]);
//逐个发订单日志
foreach ($orders as $order){
OrderLog::log($order['id'],"活动订单发起了发票申请{$typeinfo},等待系统开票",$oper_id ,$oper_type);
}
//合并调用开发票事件
$data = [
'orders' => Order::where( "id","in",$order_ids)->select(),
'invoice_apply' => $self,
'oper_id' => $oper_id,
'oper_type' => $oper_type,
];
\think\Hook::listen('activity_order_invoice_apply_after', $data);
$result = $this->allowField(true)->save($params);
if($trans){
self::commitTrans();
@ -198,6 +265,83 @@ class Apply extends BaseModel
}
throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
}
return $this;
return $self;
}
/** 发票开票(线下)
* @param $id 申请的发票id
* @param $desc 开票备注
* @param $trans
* @throws \Exception
*/
public function examine($id,$desc,$oper_id = 0,$oper_type='user',$check=true,$trans=false)
{
$self = self::get($id);
if(!$self) throw new \Exception('发票申请不存在');
//已开票则直接返回
if($self["status"] == '2'){
return $self;
}
if(! $desc) throw new \Exception('请填写开票备注');
//
$params = [
'status' => '2',
'desc' => $desc,
'invoicingtime' => time(),
];
if($check){
}
if($trans){
self::beginTrans();
}
$res = true;
try{
//是否采用模型验证
// if ($this->modelValidate) {
// $name = str_replace("\\model\\", "\\validate\\", get_class($this));
// $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
// $this->validateFailException()->validate($validate);
// }
//更新发票状态
$self->allowField(true)->save($params);
$activityorders = $self->activityorders;
foreach ($activityorders as $order){
//更新订单发票申请状态
$order["invoice_status"] = '2';
$order->save();
//发订单日志
OrderLog::log($order['id'],"活动订单已开票",$oper_id ,$oper_type);
}
//调用开发票事件
$data = [
'orders' => $activityorders,
'invoice_apply' => $self,
'oper_id' => $oper_id,
'oper_type' => $oper_type,
];
//开票成功事件
\think\Hook::listen('activity_order_invoice_success_after', $data);
if($trans){
self::commitTrans();
}
}catch (\Exception $e){
if($trans){
self::rollbackTrans();
}
throw new \Exception($e->getMessage().$e->getFile().$e->getLine());
}
return $self;
}
}

View File

@ -8,7 +8,9 @@ return [
'Apply_type' => '申请类型',
'Apply_type 1' => '单开',
'Apply_type 2' => '连开',
'Price' => '申请金额',
'Price' => '申请实付金额',
'Fee_price' => '平台手续费',
'Desc' => '开票备注',
'Head_type' => '抬头类型',
'Head_type personal' => '个人或事业单位',
'Head_type corporate' => '企业',

View File

@ -36,6 +36,17 @@
<input id="c-price" data-rule="required" class="form-control" step="0.01" name="row[price]" type="number" value="{$row.price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Fee_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-fee_price" data-rule="required" class="form-control" step="0.01" name="row[fee_price]" type="number" value="{$row.fee_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Head_type')}:</label>
<div class="col-xs-12 col-sm-8">
@ -114,6 +125,15 @@
<input id="c-invoicingtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[invoicingtime]" type="text" value="{:$row.invoicingtime?datetime($row.invoicingtime):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Desc')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-desc" data-rule="required" class="form-control" name="row[desc]" type="text" value="{$row.desc|htmlentities}">
</div>
</div>
<!-- <div class="form-group layer-footer">-->
<!-- <label class="control-label col-xs-12 col-sm-2"></label>-->
<!-- <div class="col-xs-12 col-sm-8">-->

View File

@ -8,8 +8,8 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde
index_url: 'school/activity/order/order/index' + location.search,
freecancel_url: 'school/activity/order/order/freecancel',//免费和待支付取消订单
paidcancel_url: 'school/activity/order/order/paidcancel',//付费取消订单
add_url: 'school/activity/order/order/add',
edit_url: 'school/activity/order/order/edit',
add_url: 'school/activity/order/order/add'+ location.search,
edit_url: 'school/activity/order/order/edit'+ location.search,
del_url: 'school/activity/order/order/del',
multi_url: 'school/activity/order/order/multi',
import_url: 'school/activity/order/order/import',
@ -151,6 +151,41 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde
},
{
name: 'invoice_apply_add',
text: __('帮用户申请发票'),
title: __('帮用户申请发票'),
icon: 'fa fa-sign-in',
classname: 'btn btn-xs btn-danger btn-dialog',
// dropdown : '更多',
url: invoice_apply_add_url,
callback: function (data) {
},
visible: function (row) {
return !row.user_invoice_apply_id && row.status == '9' && row.sub_refundprice > 0;
}
},
{
name: 'invoice_apply',
text: __('查看|处理发票申请'),
title: __('查看|处理发票申请'),
classname: 'btn btn-dialog',
icon: 'fa fa-leanpub',
dropdown : '更多',
url: invoice_apply_url,
callback: function (data) {
},
visible: function (row) {
return row.user_invoice_apply_id;
}
},
{name: 'freecancel',
text: '取消订单',
@ -645,9 +680,16 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde
}
var invoice_apply_add_url = function (row,dom) {
return 'user/invoice/apply/add/?order_no='+row.order_no;
}
var invoice_apply_url = function (row,dom) {
return 'user/invoice/apply/edit/ids/'+row.user_invoice_apply_id;
}
var shop_confirmation = {
listen:function () {
this.offlineListen();

View File

@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Table.api.init({
extend: {
index_url: 'user/invoice/apply/index' + location.search,
add_url: 'user/invoice/apply/add',
edit_url: 'user/invoice/apply/edit',
add_url: 'user/invoice/apply/add'+ location.search,
edit_url: 'user/invoice/apply/edit'+ location.search,
del_url: 'user/invoice/apply/del',
multi_url: 'user/invoice/apply/multi',
import_url: 'user/invoice/apply/import',
@ -32,6 +32,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'apply_type', title: __('Apply_type'), searchList: {"1":__('Apply_type 1'),"2":__('Apply_type 2')}, formatter: Table.api.formatter.normal},
{field: 'price', title: __('Price'), operate:'BETWEEN'},
{field: 'fee_price', title: __('Fee_price'), operate:'BETWEEN'},
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'head_type', title: __('Head_type'), searchList: {"personal":__('Head_type personal'),"corporate":__('Head_type corporate')}, formatter: Table.api.formatter.normal},
{field: 'invoice_type', title: __('Invoice_type'), searchList: {"ordinary":__('Invoice_type ordinary'),"special":__('Invoice_type special')}, formatter: Table.api.formatter.normal},
{field: 'invoice_header', title: __('Invoice_header'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
@ -64,9 +68,55 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
api: {
bindevent: function () {
shop_apply.listen();
Form.api.bindevent($("form[role=form]"));
}
}
};
var shop_apply = {
listen:function () {
this.setOfflineType($("select[name='row[head_type]']").val());
this.offlineListen();
},
offlineListen:function () {
var that = this;
// console.log($("input:radio[name='row[address_type]']").val())
// this.setOfflineType($("input:radio[name='row[address_type]']").val());
// $("input:radio[name='row[head_type]']").change(function (){
//
// console.log(1111111);
// that.setOfflineType($(this).val());
// });
//改成下拉
$("select[name='row[head_type]']").change(function (){
that.setOfflineType($(this).val());
});
},
setOfflineType:function (val) {
switch (val) {
case 'personal': //个人
$('#enterprise_data').hide();
break;
case 'corporate': //企业
$('#enterprise_data').show();
break;
}
},
}
return Controller;
});

View File

@ -30,6 +30,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'apply_type', title: __('Apply_type'), searchList: {"1":__('Apply_type 1'),"2":__('Apply_type 2')}, formatter: Table.api.formatter.normal},
{field: 'price', title: __('Price'), operate:'BETWEEN'},
{field: 'fee_price', title: __('Fee_price'), operate:'BETWEEN'},
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'head_type', title: __('Head_type'), searchList: {"personal":__('Head_type personal'),"corporate":__('Head_type corporate')}, formatter: Table.api.formatter.normal},
{field: 'invoice_type', title: __('Invoice_type'), searchList: {"ordinary":__('Invoice_type ordinary'),"special":__('Invoice_type special')}, formatter: Table.api.formatter.normal},
{field: 'invoice_header', title: __('Invoice_header'), operate: 'LIKE'},