From a9a4ebe1542d5d6e005a8d5b75e4d382279a3a0e Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Wed, 16 Apr 2025 18:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=B5=81=E7=A8=8B=EF=BC=9A?= =?UTF-8?q?=20=E5=90=8E=E5=8F=B0=E6=9C=80=E7=BB=88=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=8C=82=E8=B5=B7=E8=AE=A2=E5=8D=95=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=20=E5=94=AE=E5=90=8E=E5=8D=95=E8=B6=85=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8C=82=E8=B5=B7=20=E5=94=AE=E5=90=8E=E5=90=8C?= =?UTF-8?q?=E6=84=8F=E7=BB=93=E7=AE=97=E5=8D=95=E6=94=B6=E7=9B=8A=E9=87=8A?= =?UTF-8?q?=E6=94=BE=EF=BC=88=E4=BD=99=E7=95=99=E6=9C=AA=E9=80=80=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E6=83=85=E5=86=B5=E4=B8=8B=20=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=B8=AE=E5=95=86=E6=88=B7=E5=94=AE=E5=90=8E=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20=E5=90=8E=E5=8F=B0=E5=B8=AE=E7=94=A8=E6=88=B7=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=92=8C=E7=94=B3=E8=AF=B7=E5=94=AE=E5=90=8E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=E5=90=8E=E5=8F=B0=E7=94=A8=E6=88=B7=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E6=8F=90=E7=8E=B0=EF=BC=8C=E7=BB=93?= =?UTF-8?q?=E7=AE=97=EF=BC=8C=E8=AE=A2=E5=8D=95=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8D=95=EF=BC=8C=E6=B4=BB=E5=8A=A8=E5=8D=95?= =?UTF-8?q?=EF=BC=8C=E6=B4=BB=E5=8A=A8=EF=BC=8C=E6=8F=90=E7=8E=B0=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=A2=9E=E5=8A=A0=20=E4=B8=87=E4=BB=A5=E4=B8=8A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=87=BAexcel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../school/activity/order/Order.php | 115 ++++++++ application/admin/controller/user/User.php | 5 + .../user/withdrawal/Userwithdrawal.php | 6 +- .../view/school/activity/activity/add.html | 1 + .../view/school/activity/activity/copy.html | 2 + .../view/school/activity/activity/edit.html | 1 + .../order/order/admin_confirmation.html | 42 +++ .../activity/order/order/after_sales.html | 31 +++ .../order/order/shop_confirmation.html | 47 ++++ .../user/withdrawal/userwithdrawal/add.html | 2 +- application/common/hooks.php | 3 + .../common/listener/activity/OrderHook.php | 60 ++++- .../common/model/school/activity/Activity.php | 2 +- .../model/school/activity/order/Order.php | 245 ++++++++++++++++-- .../model/school/activity/order/SettleLog.php | 4 + .../js/backend/school/activity/activity.js | 66 +++++ .../js/backend/school/activity/order/order.js | 73 ++++++ .../school/activity/order/settle_log.js | 2 + public/assets/js/backend/user/user.js | 130 ++++++++-- .../backend/user/withdrawal/userwithdrawal.js | 4 +- 20 files changed, 796 insertions(+), 45 deletions(-) create mode 100644 application/admin/view/school/activity/order/order/admin_confirmation.html create mode 100644 application/admin/view/school/activity/order/order/after_sales.html create mode 100644 application/admin/view/school/activity/order/order/shop_confirmation.html diff --git a/application/admin/controller/school/activity/order/Order.php b/application/admin/controller/school/activity/order/Order.php index 94f167b..c8ce152 100644 --- a/application/admin/controller/school/activity/order/Order.php +++ b/application/admin/controller/school/activity/order/Order.php @@ -205,4 +205,119 @@ class Order extends Backend + + + + + /**发布者售后确认 + * @return string + * @throws \think\Exception + * @throws \think\exception\DbException + */ + public function shop_confirmation($ids = ""){ + + if($this->request->isPost()) + { + try{ + $params = $this->request->post("row/a"); + $order_no = $params["order_no"]; + $reject_reason = $params["reject_reason"]; + $price = $params["price"]; + $status = $params["status"]; + $model = (new \app\common\model\school\activity\order\Order()); + $model->shopConfirmation($order_no,$status,$price,$reject_reason,0,true,'admin',$this->auth->id,true); + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + + $this->success("已完成售后审核"); + } + + $row = $this->model->where(array('id'=>$ids))->find(); + if (!$row) { + $this->error(__('No Results were found')); + } + +// $row = $this->model->get($param['ids']); + $this->view->assign("statusList", ["yes"=>"同意", "no"=>"拒绝(订单将被挂起)"]); + $this->view->assign('row', $row); + return $this->view->fetch(); + } + + + + /**系统确认 + * @return string + * @throws \think\Exception + * @throws \think\exception\DbException + */ + public function admin_confirmation($ids = ""){ + + if($this->request->isPost()) + { + try{ + $params = $this->request->post("row/a"); + $order_no = $params["order_no"]; + $status = $params["status"]; + $price = $params["price"]; + $model = (new \app\common\model\school\activity\order\Order()); + $model->adminConfirmation($order_no,$status,$price,0,true,'admin',$this->auth->id,true); + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + + $this->success("已完成审核"); + } + + $row = $this->model->where(array('id'=>$ids))->find(); + if (!$row) { + $this->error(__('No Results were found')); + } + +// $row = $this->model->get($param['ids']); + + $this->view->assign("statusList", ["yes"=>"同意", "no"=>"拒绝(订单将按完成走结算)"]); + $this->view->assign('row', $row); + return $this->view->fetch(); + } + + + + /**发起售后 + * @return string + * @throws \think\Exception + * @throws \think\exception\DbException + */ + public function after_sales($ids = ""){ + + if($this->request->isPost()) + { + try{ + $params = $this->request->post("row/a"); + $classes_order = $params["id"]; + $reason = $params["reason"]; + $num = $params["num"]; + + $model = (new \app\common\model\school\activity\order\Order()); + $order = $model->afterSales($classes_order,$num,$reason,0 ,false,'admin',$this->auth->id,true); + + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + $this->success("执行成功"); + } + + $row = $this->model->where(array('id'=>$ids))->find(); + if (!$row) { + $this->error(__('No Results were found')); + } + $order_info = \app\common\model\school\activity\order\Order::getDetail($row["id"]); +// $row = $this->model->get($param['ids']); + $this->view->assign('row',$order_info); + return $this->view->fetch(); + } + + + + } diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index 12db2f0..2a206d2 100644 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -4,6 +4,7 @@ namespace app\admin\controller\user; use app\common\controller\Backend; use app\common\library\Auth; +use app\common\model\school\activity\order\SettleLog; use fast\Tree; use think\Model; @@ -53,6 +54,10 @@ class User extends Backend ->paginate($limit); foreach ($list as $k => $v) { $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname); + + //结算钱包信息 + $v["settle_info"] = SettleLog::getUserSettleInfo($v->id); + $v->hidden(['password', 'salt']); } $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/application/admin/controller/user/withdrawal/Userwithdrawal.php b/application/admin/controller/user/withdrawal/Userwithdrawal.php index ab20bbd..f80eb69 100644 --- a/application/admin/controller/user/withdrawal/Userwithdrawal.php +++ b/application/admin/controller/user/withdrawal/Userwithdrawal.php @@ -18,10 +18,14 @@ class Userwithdrawal extends Backend */ protected $model = null; + protected $qSwitch = true; + protected $qFields = ["user_id"]; + public function _initialize() { - parent::_initialize(); + $this->model = new \app\admin\model\user\withdrawal\Userwithdrawal; + parent::_initialize(); } diff --git a/application/admin/view/school/activity/activity/add.html b/application/admin/view/school/activity/activity/add.html index 5471656..926b152 100644 --- a/application/admin/view/school/activity/activity/add.html +++ b/application/admin/view/school/activity/activity/add.html @@ -30,6 +30,7 @@ + ( 推荐图片比例为 690*580 )
diff --git a/application/admin/view/school/activity/activity/copy.html b/application/admin/view/school/activity/activity/copy.html index 191712a..6f14a3b 100644 --- a/application/admin/view/school/activity/activity/copy.html +++ b/application/admin/view/school/activity/activity/copy.html @@ -33,6 +33,8 @@
+ ( 推荐图片比例为 690*580 ) + diff --git a/application/admin/view/school/activity/activity/edit.html b/application/admin/view/school/activity/activity/edit.html index 191712a..e12c44b 100644 --- a/application/admin/view/school/activity/activity/edit.html +++ b/application/admin/view/school/activity/activity/edit.html @@ -33,6 +33,7 @@ + ( 推荐图片比例为 690*580 ) diff --git a/application/admin/view/school/activity/order/order/admin_confirmation.html b/application/admin/view/school/activity/order/order/admin_confirmation.html new file mode 100644 index 0000000..e7deba6 --- /dev/null +++ b/application/admin/view/school/activity/order/order/admin_confirmation.html @@ -0,0 +1,42 @@ +
+ +
+

平台处理挂起单(如果拒绝退款,则视为订单完成将正常结算给商家,如果同意退款,提交后需等待微信退款回调,回调成功才会更新订单状态!)

+ +
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+
+ +
+ + ( 如果未全退,剩余未退金额将正常结算给商家 ) +
+
+
+ + + + + + +
\ No newline at end of file diff --git a/application/admin/view/school/activity/order/order/after_sales.html b/application/admin/view/school/activity/order/order/after_sales.html new file mode 100644 index 0000000..7365832 --- /dev/null +++ b/application/admin/view/school/activity/order/order/after_sales.html @@ -0,0 +1,31 @@ +
+ +
+

帮用户售后需填写原因!

+ +
+ +
+ +
+
+
+ +
+
+ +
+ + ( 当前订单数量为 {$row.num|htmlentities} 当前单人单价为 {$row.detail.price|htmlentities} ) +
+
+
+ + + +
\ No newline at end of file diff --git a/application/admin/view/school/activity/order/order/shop_confirmation.html b/application/admin/view/school/activity/order/order/shop_confirmation.html new file mode 100644 index 0000000..b8b4d82 --- /dev/null +++ b/application/admin/view/school/activity/order/order/shop_confirmation.html @@ -0,0 +1,47 @@ +
+ +
+

代商家处理售后

+ +
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+
+ +
+ + ( 当前订单损耗比为 {$row.loss_proportion|htmlentities}% | 忽略损耗应退全额为 {$row.auto_price|htmlentities} [若为0说明课时已用完或计算应退金额小于0.01,请自行决定是否退全款] | 退款金额不能超过订单应退全额{$row.sub_refundprice|htmlentities} ) +
+
+
+ + + + + + +
\ No newline at end of file diff --git a/application/admin/view/user/withdrawal/userwithdrawal/add.html b/application/admin/view/user/withdrawal/userwithdrawal/add.html index 7e20cb1..2e83fe2 100644 --- a/application/admin/view/user/withdrawal/userwithdrawal/add.html +++ b/application/admin/view/user/withdrawal/userwithdrawal/add.html @@ -3,7 +3,7 @@
- + (没找到用户则点击按钮创建用户后重新下拉框选用户) diff --git a/application/common/hooks.php b/application/common/hooks.php index 56d4157..df705d0 100644 --- a/application/common/hooks.php +++ b/application/common/hooks.php @@ -323,6 +323,9 @@ $newactivityOrderHooks = [ 'activity_order_shop_reject_after' => [ // 订单售后拒绝 'app\\common\\listener\\activity\\OrderHook' ], + 'activity_order_timeout_reject_after'=> [ // 订单售后拒绝 + 'app\\common\\listener\\activity\\OrderHook' + ], ]; diff --git a/application/common/listener/activity/OrderHook.php b/application/common/listener/activity/OrderHook.php index 704ce36..d09429e 100644 --- a/application/common/listener/activity/OrderHook.php +++ b/application/common/listener/activity/OrderHook.php @@ -586,7 +586,7 @@ class OrderHook $to_id = $order["user_id"]; $status ="activity"; $params=[ - "event"=>"activity_order_after_sales_after", + "event"=>"activity_order_shop_confirm_after", "order_id"=>$order["id"], "order_no"=>$order["order_no"], "activity_id"=>$order["activity_id"], @@ -644,7 +644,7 @@ class OrderHook $to_id = $order["user_id"]; $status ="activity"; $params=[ - "event"=>"activity_order_after_sales_after", + "event"=>"activity_order_shop_reject_after", "order_id"=>$order["id"], "order_no"=>$order["order_no"], "activity_id"=>$order["activity_id"], @@ -688,6 +688,62 @@ class OrderHook + // 订单售后超时自动拒绝 + public function activityOrderTimeoutRejectAfter(&$params) + { + ["order"=>$order] = $params; + + $order = Order::where("id" , $order["id"])->find(); + + $detail = $order->detail; + $user = $order->user; + //记录订单日志 + $mini_type = "activity_order"; + $to_id = $order["user_id"]; + $status ="activity"; + $params=[ + "event"=>"activity_order_timeout_reject_after", + "order_id"=>$order["id"], + "order_no"=>$order["order_no"], + "activity_id"=>$order["activity_id"], + "title"=>$detail["title"], + "images"=>$detail["images"], + ]; + $param = [ + "title"=>$detail["title"], + "order_no" => $order["order_no"], + "nickname" => $user["nickname"], + "realname" => $user["realname"], + "mobile" => $user["mobile"], + "price" => $order["totalprice"], + "payprice" => $order["payprice"], + "real_refundprice" => $order["real_refundprice"], + "sub_refundprice" => $order["sub_refundprice"], + "total_refundprice" => $order["total_refundprice"], + "reason" => $order["reason"], + "auth_reason" => $order["auth_reason"], + "address"=>$detail["address"]."(".$detail["address_detail"].")", + "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式 + "end_time" => date("Y-m-d H:i",$detail["end_time"]), + "sign_start_time" => date("Y-m-d H:i",$detail["sign_start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式 + "sign_end_time" => date("Y-m-d H:i",$detail["sign_end_time"]), + ]; + + //发用户 + (new MessageConfig) + ->setTemplate($params["event"]) + ->setTemplateData($param) + ->setToUid($to_id) + ->setMessageStatus($status) + ->setMessageMiniType($mini_type) + ->setMessageParams($params) + ->sendMessage(); + + } + + + + } \ No newline at end of file diff --git a/application/common/model/school/activity/Activity.php b/application/common/model/school/activity/Activity.php index b7f5688..9c874cb 100644 --- a/application/common/model/school/activity/Activity.php +++ b/application/common/model/school/activity/Activity.php @@ -1238,7 +1238,7 @@ class Activity extends BaseModel if($trans){ self::rollbackTrans(); } - throw new \Exception($e->getMessage()); + throw new \Exception($e->getMessage().$e->getFile().$e->getLine()); } return $row; } diff --git a/application/common/model/school/activity/order/Order.php b/application/common/model/school/activity/order/Order.php index b7206fe..4f57ff1 100644 --- a/application/common/model/school/activity/order/Order.php +++ b/application/common/model/school/activity/order/Order.php @@ -734,7 +734,7 @@ class Order extends BaseModel self::paySetData($order,$notify); //释放结算订单 -// (new SettleLog)->generatorLog($order['id']); + (new SettleLog)->timeoutSettleActivityCheck($order["activity_id"]); // //如果需要快捷预约 // $classes_lib_spec_id = $order['classes_lib_spec_id']; @@ -1239,7 +1239,7 @@ class Order extends BaseModel //释放结算订单 -// (new SettleLog)->generatorLog($order['id']); + (new SettleLog)->timeoutSettleActivityCheck($order["activity_id"]); //调用支付成功事件 $data = ['order' => $order]; @@ -1825,19 +1825,23 @@ class Order extends BaseModel $order->refundtime = time(); $order->refund_json = json_encode($pay_json); $order->save(); - + //报废旧的结算单 + SettleLog::where("activity_order_id",$order['id']) + ->where("status" ,"in",["1","2"]) + ->update([ + "status"=>"-1", + "canceltime" => time() + ]); //若存在剩余金额,结算给发布者 if($order->sub_refundprice > $order->fee_scale){ - //报废旧的结算单 - SettleLog::where("activity_order_id",$order['id']) - ->where("status" ,"in",["1","2"]) - ->update([ - "status"=>"-1", - "canceltime" => time() - ]); + //插入新结算单 - (new SettleLog)->generatorLog($order['id']); +// (new SettleLog)->generatorLog($order['id']); + //对活动订单进行结算记录插入 + (new SettleLog)->timeoutSettleActivityCheck($order["activity_id"]); + + } @@ -2062,8 +2066,9 @@ class Order extends BaseModel public static function updateShopConfirmationOrder($order,$price){ if(is_string($order))$order = self::getHaveShopConfirmationOrder($order); $order->status = "5";//refund_status - $order->service_stauts = "6"; + $order->server_status = "6"; $order->auth_status = 1; + $order['suspend_status'] = '1'; $order->total_refundprice = $price; $order->refundtime = time(); $order->save(); @@ -2081,11 +2086,11 @@ class Order extends BaseModel */ public static function updateShopConfirmationFailOrder($order,$reason){ if(is_string($order))$order = self::getHaveShopConfirmationOrder($order); - $order->status = "7";//refund_status - $order->service_stauts = "6"; - $order->auth_status = 2; - $order->reason = $reason; - $order->suspend_status = '1'; + $order["status"] = "7";//refund_status + $order["server_status"] = "6"; + $order["auth_status"] = 2; + $order["reason"] = $reason; + $order['suspend_status'] = '1'; $order->save(); return $order; } @@ -2106,6 +2111,10 @@ class Order extends BaseModel */ public function shopConfirmation($order_no,$status,$price,$reject_reason,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + + //得到机构售后提交确认订单 + $order = self::getHaveShopConfirmationOrder($order_no); + $this->timeoutSuspension($order['id'],$trans); //得到机构售后提交确认订单 $order = self::getHaveShopConfirmationOrder($order_no); if($check){ @@ -2156,6 +2165,8 @@ class Order extends BaseModel } $res = true; try{ + + //事务逻辑 //更新售后为取消状态 switch ($status){ @@ -2195,9 +2206,9 @@ class Order extends BaseModel //插入订单日志 if(!$user_id ||$order["user_id"] !=$user_id ){ - $order::log($order['id'],"[系统操作]活动订单售后驳回,订单挂起,等待官方处理",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + OrderLog::log($order['id'],"[系统操作]活动订单售后驳回,订单挂起,等待官方处理",$oper_type ?: 'user', $oper_id ?: $order['user_id']); }else{ - $order::log($order['id'],"活动订单售后驳回,订单挂起,等待官方处理",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + OrderLog::log($order['id'],"活动订单售后驳回,订单挂起,等待官方处理",$oper_type ?: 'user', $oper_id ?: $order['user_id']); } //调用订单取消事件 @@ -2210,7 +2221,200 @@ class Order extends BaseModel throw new \Exception("参数错误!"); } //执行课时数更新 - $res1 = order::statisticsAndUpdateClassesNumber($order['classes_order_id']); + $res1 = order::statisticsAndUpdateClassesNumber($order); + + + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage()); + } + return $res1; + } + + + /** 检测售后订单超时未处理自动挂起定时任务 + * @param $id 售后订单id非必填,不填则检测所有超时未处理的 + * @param $trans + * @return true + * @throws \Exception + */ + public function timeoutSuspension($id=0,$trans=false){ + //去超时时间戳配置 + $timeout = config('site.activity_end_sales'); + //当前时间 + $time = time(); + //延期时间过了当前时间的时间点(用时间戳相减特性) + $delay_time = $time - $timeout; + //初始查询model + $as = $this->getWithAlisaName(); + $model = self::with(["detail"]) + ->where("{$as}.server_status",'3') + ->where("{$as}.suspend_status",'0') + ->where("{$as}.status",'4'); + if($id){ + $model = $model->where("{$as}.id",$id); + } + //查询条件2:过了活动结束时间加延期时间的订单 + $model = $model->where("detail.end_time","<",$delay_time); + $list = $model->select(); + + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + //遍历订单,执行挂起操作 + foreach ($list as $row){ + //执行挂起操作 + $row["status"] = "7"; + $row["server_status"] = "6"; + $row["suspend_status"] = "2"; + $row["auth_status"] = 2; + $row["auth_time"] = time(); + $row->save(); + + //写订单日志 + OrderLog::log($row['id'],"活动订单售后超时自动驳回,订单挂起,等待官方处理",'admin', 0); + //调用挂起事件 + $data = ['order' => self::where("id",$row['id'])->find(),"user_id"=>0,"oper_type"=>"admin","oper_id"=>0]; + \think\Hook::listen('activity_order_timeout_reject_after', $data); + + + + } + if($trans){ + self::commitTrans(); + } + }catch (\Exception $e){ + if($trans){ + self::rollbackTrans(); + } + throw new \Exception($e->getMessage().$e->getFile().$e->getLine()); + } + return $res; + } + + + + + + + /**总后台最后处理售后挂起的订单 + * @param $order_no + * @param int $user_id + * @param string $status yes同意 no拒绝(即订单按完成算) + * @param string $price 商定价格 + * @param bool $check + * @param bool $trans + * @return bool + * @throws \Exception + */ + public function adminConfirmation($order_no,$status,$price,$user_id=0,$check=false,$oper_type='user',$oper_id=0,$trans=false){ + //得到机构售后提交确认订单 + $order = self::getHaveShopConfirmationOrder($order_no); + + if($check){ + //用户操作权限检测 + Order::checkOptionAuth($order['id'],$user_id ?: $oper_id,$oper_type,false,false,true); + } + $classesorder = $order; + if(!$classesorder)throw new \Exception("订单不存在!"); + + switch ($status){ + case 'yes': + //同意 + //验证价格正确性 + //金额必须小于等于剩余未退全额 + $price = floatval($price); + if($price > $classesorder['sub_refundprice']){ + throw new \Exception("价格必须小于等于剩余应退全额!"); + } + //数据修正大于剩余未退全额 则等于剩余未退 + $price = $price > $classesorder['sub_refundprice'] ? $classesorder['sub_refundprice'] : $price; + if($price<=0)throw new \Exception("同意退款必须大于0!"); + + //如果非全额退款,剩余金额必须大于订单支付时的手续费 + if($price < $classesorder['sub_refundprice']){ + $sub_price = bcsub($classesorder['sub_refundprice'] , $price,2); + if($sub_price <= $classesorder['fee_price']){ + throw new \Exception("如果未退全款,剩余未退金额必须大于订单支付时的手续费{$classesorder['fee_price']}!"); + } + } + + break; + case 'no': + //拒绝 + + break; + default: + throw new \Exception("参数错误!"); + } + + + //判断逻辑 + if($trans){ + self::beginTrans(); + } + $res = true; + try{ + + + //事务逻辑 + //更新售后为取消状态 + switch ($status){ + case 'yes': + //同意 + + //更新订单状态为同意 + $order = self::updateShopConfirmationOrder($order,$price); + + //插入订单日志 + if(!$user_id ||$order["user_id"] !=$user_id ){ + OrderLog::log($order['id'],"[系统操作]活动订单售后最终处理结果:用户发起金额为{$order['first_refundprice']},确认退款金额为{$price}元,等待退款到账",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + }else{ + OrderLog::log($order['id'],"活动订单售后最终处理结果:用户发起金额为{$order['first_refundprice']},确认退款金额为{$price}元,等待退款到账",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + } + + //调用订单事件 + $data = ['order' => self::where("id",$order['id'])->find(),"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id]; + \think\Hook::listen('activity_order_shop_confirm_after', $data); + + + //执行退款 + //执行退款 + self::orderRefund($order['order_no'],$price,$oper_type,$oper_id); + + + + + + break; + case 'no': + //拒绝 + + //插入订单日志 + if(!$user_id ||$order["user_id"] !=$user_id ){ + OrderLog::log($order['id'],"[系统操作]活动订单售后最终判定为不进行售后,将不退款,按订单完成处理",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + }else{ + OrderLog::log($order['id'],"活动订单售后最终判定为不进行售后,将不退款,按订单完成处理",$oper_type ?: 'user', $oper_id ?: $order['user_id']); + } + + //调用订单完成 + //执行订单完成的更新逻辑 + self::updateFinish($order); + + + break; + default: + throw new \Exception("参数错误!"); + } + //执行课时数更新 + $res1 = order::statisticsAndUpdateClassesNumber($order); if($trans){ @@ -2230,5 +2434,4 @@ class Order extends BaseModel - } diff --git a/application/common/model/school/activity/order/SettleLog.php b/application/common/model/school/activity/order/SettleLog.php index 7e684b4..f97002b 100644 --- a/application/common/model/school/activity/order/SettleLog.php +++ b/application/common/model/school/activity/order/SettleLog.php @@ -180,6 +180,10 @@ class SettleLog extends BaseModel try { //查询更新所有活动状态 Activity::timeoutCheck(); + + //执行售后单挂起操作 + (new order)->timeoutSuspension(); + //延后时间(秒) $delay = config("site.activity_end_settle") ?: 0; $time = time(); diff --git a/public/assets/js/backend/school/activity/activity.js b/public/assets/js/backend/school/activity/activity.js index 473eb6a..712afeb 100644 --- a/public/assets/js/backend/school/activity/activity.js +++ b/public/assets/js/backend/school/activity/activity.js @@ -129,6 +129,55 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde // } }, + { + name: 'activity_order', + text: __('参与的活动订单'), + title: __('参与的活动订单'), + classname: 'btn btn-dialog', + icon: 'fa fa-cart-arrow-down', + dropdown : '更多', + url: activity_order_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + { + name: 'user', + text: __('发布用户查看'), + title: __('发布用户查看'), + classname: 'btn btn-dialog', + icon: 'fa fa-cart-arrow-down', + dropdown : '更多', + url: user_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + + { + name: 'settle_log', + text: __('活动生成的结算日志'), + title: __('活动生成的结算日志'), + classname: 'btn btn-dialog', + icon: 'fa fa-cart-arrow-down', + dropdown : '更多', + url: settle_log_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + ], events: Table.api.events.operate, formatter: Table.api.formatter.operate}, @@ -299,5 +348,22 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde } } }; + + + + var activity_order_url = function (row,dom) { + return 'school/activity/order/order/index?activity_id='+row.id; + } + + var user_url = function (row,dom) { + return 'user/user/index?id='+row.user_id; + } + + + var settle_log_url = function (row,dom) { + return 'school/activity/order/settle_log/index?activity_id='+row.id; + } + + return Controller; }); diff --git a/public/assets/js/backend/school/activity/order/order.js b/public/assets/js/backend/school/activity/order/order.js index c919bba..995e751 100644 --- a/public/assets/js/backend/school/activity/order/order.js +++ b/public/assets/js/backend/school/activity/order/order.js @@ -15,6 +15,10 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde import_url: 'school/activity/order/order/import', verification_url: 'school/activity/order/order/verification', refund_url: 'school/activity/order/order/refund', + shop_confirmation_url: 'school/activity/order/order/shop_confirmation', + after_sales_url: 'school/activity/order/order/after_sales', + admin_confirmation_url: 'school/activity/order/order/admin_confirmation', + table: 'school_activity_order', } }); @@ -87,6 +91,54 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde {field: 'operate', title: __('Operate'), table: table , buttons: [ + { + name: 'after_sales', + text: __('帮用户发起售后'), + title: __('帮用户发起售后'), + classname: 'btn btn-xs btn-danger btn-dialog', + icon: 'fa fa-sign-in', + url: $.fn.bootstrapTable.defaults.extend.after_sales_url, + callback: function (data) { + + }, + visible: function (row) { + //只有付费订单有售后 + return (row.status == '2' || row.status == '3') && row.detail.feel == '0'; + } + }, + + + { + name: 'shop_confirmation', + text: __('代商家处理售后'), + title: __('代商家处理售后'), + classname: 'btn btn-xs btn-danger btn-dialog', + icon: 'fa fa-sign-in', + url: $.fn.bootstrapTable.defaults.extend.shop_confirmation_url, + callback: function (data) { + + }, + visible: function (row) { + return row.status == '4'; + } + }, + { + name: 'admin_confirmation', + text: __('处理挂起单'), + title: __('处理挂起单'), + classname: 'btn btn-xs btn-danger btn-dialog', + icon: 'fa fa-sign-in', + url: $.fn.bootstrapTable.defaults.extend.admin_confirmation_url, + callback: function (data) { + + }, + visible: function (row) { + return row.status == '7'; + } + }, + + + {name: 'freecancel', text: '取消订单', icon: 'fa fa-user-times', @@ -462,6 +514,27 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde edit: function () { Controller.api.bindevent(); }, + admin_confirmation: function(){ + $("#admin_confirmation").on('click', function() { + $("#admin_confirmation-form").attr("action",'school/activity/order/order/admin_confirmation').submit(); + }); + Controller.api.bindevent(); + }, + shop_confirmation: function(){ + $("#shop_confirmation").on('click', function() { + $("#shop_confirmation-form").attr("action",'school/activity/order/order/shop_confirmation').submit(); + }); + Controller.api.bindevent(); + }, + + after_sales: function(){ + $("#after_sales").on('click', function() { + $("#after_sales-form").attr("action",'school/activity/order/order/after_sales').submit(); + }); + Controller.api.bindevent(); + }, + + api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); diff --git a/public/assets/js/backend/school/activity/order/settle_log.js b/public/assets/js/backend/school/activity/order/settle_log.js index d8409bf..2d1ef3c 100644 --- a/public/assets/js/backend/school/activity/order/settle_log.js +++ b/public/assets/js/backend/school/activity/order/settle_log.js @@ -30,6 +30,8 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'activity_order_id', title: __('Activity_order_id') ,visible:false}, + {field: 'activity_id', title: __('活动id') ,visible:false}, + {field: 'activity_order_detail_id', title: __('订单详情id') ,visible:false}, {field: 'withdrawal_log_id',visible:false, title: __('Withdrawal_log_id') }, {field: 'to_user_id', title: __('To_user_id')}, {field: 'touser.nickname', title: __('Touser.nickname'), operate: 'LIKE'}, diff --git a/public/assets/js/backend/user/user.js b/public/assets/js/backend/user/user.js index 68a4984..f980b22 100644 --- a/public/assets/js/backend/user/user.js +++ b/public/assets/js/backend/user/user.js @@ -34,6 +34,13 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde {field: 'username', title: __('Username'), operate: 'LIKE'}, {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, {field: 'realname', title: __('真实姓名'), operate: 'LIKE'}, + + {field: 'settle_info.settled_amount', title: __('可提现金额'), operate: false}, + {field: 'settle_info.expected_incoming_amount', title: __('预期收益'), operate: false}, + {field: 'settle_info.accumulated_incoming_amount', title: __('累计收入'), operate: false}, + + + {field: 'work', title: __('职业'), operate: 'LIKE'}, {field: 'email', title: __('Email'), operate: 'LIKE'}, {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, @@ -135,6 +142,22 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde // } }, + { + name: 'activity', + text: __('发布的活动'), + title: __('发布的活动'), + classname: 'btn btn-dialog', + icon: 'fa fa-calendar', + dropdown : '更多', + url: activity_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + // { // name: 'classes_order', @@ -152,25 +175,76 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde // // } // }, // - // { - // name: 'classes_hourorder', - // text: __('课时预约单'), - // title: __('课时预约单'), - // classname: 'btn btn-dialog', - // icon: 'fa fa-calendar', - // dropdown : '更多', - // url: classes_hourorder_url, - // callback: function (data) { - // - // }, - // // visible: function (row) { - // // return row.status == '2'||row.status == '3'; - // // } - // }, + { + name: 'userwithdrawal', + text: __('用户提现银行卡'), + title: __('用户提现银行卡'), + classname: 'btn btn-dialog', + icon: 'fa fa-calendar', + dropdown : '更多', + url: userwithdrawal_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + { + name: 'userwithdrawal_log', + text: __('用户提现记录'), + title: __('用户提现记录'), + classname: 'btn btn-dialog', + icon: 'fa fa-calendar', + dropdown : '更多', + url: userwithdrawal_log_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + + { + name: 'pay_user', + text: __('贡献资金结算'), + title: __('贡献资金结算'), + classname: 'btn btn-dialog', + icon: 'fa fa-calendar', + dropdown : '更多', + url: settle_log_pay_user_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + { + name: 'to_user', + text: __('获取的资金结算'), + title: __('获取的资金结算'), + classname: 'btn btn-dialog', + icon: 'fa fa-calendar', + dropdown : '更多', + url: settle_log_to_user_url, + callback: function (data) { + + }, + // visible: function (row) { + // return row.status == '2'||row.status == '3'; + // } + }, + + + + { name: 'activity_order', - text: __('活动订单'), - title: __('活动订单'), + text: __('参与的活动订单'), + title: __('参与的活动订单'), classname: 'btn btn-dialog', icon: 'fa fa-cart-arrow-down', dropdown : '更多', @@ -182,6 +256,7 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde // return row.status == '2'||row.status == '3'; // } }, + // { // name: 'evaluate', // text: __('查看用户评价'), @@ -310,5 +385,26 @@ define(['jquery', 'bootstrap', 'backend', 'csmtable', 'form'], function ($, unde } + var userwithdrawal_url = function (row,dom) { + return 'user/withdrawal/userwithdrawal/index?user_id='+row.id; + } + + var userwithdrawal_log_url = function (row,dom) { + return 'user/withdrawal/userwithdrawal_log/index?user_id='+row.id; + } + + var settle_log_to_user_url = function (row,dom) { + return 'school/activity/order/settle_log/index?to_user_id='+row.id; + } + + var settle_log_pay_user_url = function (row,dom) { + return 'school/activity/order/settle_log/index?pay_user_id='+row.id; + } + + var activity_url = function (row,dom) { + return 'school/activity/activity/index?user_id='+row.id; + } + + return Controller; }); \ No newline at end of file diff --git a/public/assets/js/backend/user/withdrawal/userwithdrawal.js b/public/assets/js/backend/user/withdrawal/userwithdrawal.js index 19562e4..c130bf8 100644 --- a/public/assets/js/backend/user/withdrawal/userwithdrawal.js +++ b/public/assets/js/backend/user/withdrawal/userwithdrawal.js @@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin Table.api.init({ extend: { index_url: 'user/withdrawal/userwithdrawal/index' + location.search, - add_url: 'user/withdrawal/userwithdrawal/add', - edit_url: 'user/withdrawal/userwithdrawal/edit', + add_url: 'user/withdrawal/userwithdrawal/add'+ location.search, + edit_url: 'user/withdrawal/userwithdrawal/edit'+ location.search, del_url: 'user/withdrawal/userwithdrawal/del', multi_url: 'user/withdrawal/userwithdrawal/multi', import_url: 'user/withdrawal/userwithdrawal/import',