Files
duolamaojiazhen/application/admin/controller/Ordersel.php
2025-12-22 13:59:40 +08:00

176 lines
4.9 KiB
PHP

<?php
namespace app\admin\controller;
use app\admin\logic\OrderserLogic;
use app\common\model\Order as CommonOrder;
use app\common\model\Pay;
use app\admin\logic\StaffLogic;
use app\common\server\ConfigServer;
use think\Db;
class Ordersel extends AdminBase {
/**
* order: 哆啦猫订单渠道
* Desc: 服务订单管理
*/
public function Orderselists(){
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists=OrderserLogic::lists($get);
$this->_success('',$lists);
}
$this->assign('order_status', CommonOrder::getOrderStatus(true));
$this->assign('order_type', CommonOrder::getOrderType(true));
$this->assign('pay_way', Pay::getPayWay(true));
$this->assign('delivery_type', CommonOrder::getDeliveryType(true));
$this->assign('order_source', OrderserLogic::stafftype(true));
return $this->fetch();
}
/**
* order: 哆啦猫订单渠道
* Desc: 服务订单的详情
*/
public function Orderinfo(){
$get = $this->request->get();
$this->assign('info',OrderserLogic::info($get));
return $this->fetch();
}
public function getList(){
$post = $this->request->get('');
$lists = OrderserLogic::getList($post);
$this->_success('',$lists);
}
public function edit(){
$get = $this->request->get();
$this->assign('info',OrderserLogic::info($get));
return $this->fetch();
}
public function orderstaffadd(){
$get= $this->request->get('id');
$this->assign('info',OrderserLogic::orderinfo($get));
$this->assign('order_id',$get);
return $this->fetch();
}
public function staffadd(){
$post= $this->request->post();
$staff=Db::name('order_cleaner')->where('cleaner_id',$post['id'])->where('order_id',$post['order_id'])->find();
if($staff){
$this->_error('已经派单,不能重复派单');
}else{
$data=[
'cleaner_id'=>$post['id'],
'order_id'=>$post['order_id'],
'status'=>0,
'createtime'=>time(),
'send_message'=>0,
];
$datas = Db::name('order_cleaner')->insertGetId($data);
$this->_success('增加保洁成功');
}
}
//删除订单绑定的保洁师
public function staffdel(){
$post = $this->request->post();
$lists = OrderserLogic::staffdel($post);
if($lists){
$this->_success('取消保洁成功');
}else{
$this->_error('无法取消,订单服务之中或已完成');
}
}
//保洁列表 不包含请假和离职员工
public function stafflist(){
$get = $this->request->get();
$lists = OrderserLogic::stafflist($get);
$this->_success('',$lists);
}
//恢复保洁数据
public function date(){
$id = $this->request->post('order_id');
$order=Db::name('order_service')->where('id',$id)->find();
$user=Db::name('user_address')->where('telephone',$order['phone'])->find();
if($order['goods_amount']==419){
$goods_id=18;
}
if($order['goods_amount']==199){
$goods_id=17;
}
if($order['goods_amount']==259){
$goods_id=16;
}
if($order['goods_amount']==239){
$goods_id=21;
}
if($order['goods_amount']==269){
$goods_id=19;
}
if($order['goods_amount']==299){
$goods_id=27;
}
if($order['goods_amount']==159){
$goods_id=26;
}
if($order['goods_amount']==89){
$goods_id=25;
}
if($order['goods_amount']==149){
$goods_id=24;
}
if($order['goods_amount']==799){
$goods_id=61;
}
if($order['status']==-1){
return 20;
}
$order_sn=createSn('order', 'order_sn', '', 4);
$data=[
'order_sn'=> $order_sn,
'goods_id'=>$goods_id,
'user_id'=>$order['user_id'],
'code'=>0,
'order_status'=>1,
'pay_status'=>1,
'pay_way'=>3,
'pay_time'=>$order['paytime'],
'consignee'=>$user['contact'],
'province'=>$user['province_id'],
'city'=>$user['city_id'],
'district'=>$user['district_id'],
'lat'=>$user['lat'],
'lng'=>$user['lng'],
'mobile'=>$user['telephone'],
'address'=>$user['address'],
'goods_price'=>$order['goods_amount'],
'order_amount'=>$order['goods_amount'],
'total_amount'=>$order['goods_amount'],
'total_num'=>1,
'type'=>0,
'number'=>1,
'create_time'=>$order['createtime'],
'update_time'=>$order['updatetime'],
];
$inser=Db::name('order')->data($data)->insert();
if($inser){
$order=Db::name('order_service')->where('id',$id)->update(['static'=>1]);
$this->_success('添加成功');
}
}
}
?>