|
@@ -25,7 +25,7 @@ use think\Loader;
|
|
|
*/
|
|
|
class MobileOrder extends Backend
|
|
|
{
|
|
|
- protected $noNeedRight=['status','pay_type'];
|
|
|
+ protected $noNeedRight = ['status', 'pay_type'];
|
|
|
/**
|
|
|
* MobileOrder模型对象
|
|
|
* @var \app\admin\model\MobileOrder
|
|
@@ -37,12 +37,12 @@ class MobileOrder extends Backend
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
$this->model = new \app\admin\model\MobileOrder;
|
|
|
- $this->assign('status',\app\common\model\MobileOrder::$status);
|
|
|
- $this->assign('logistics_list',json_encode(LogisticsCompany::all()));
|
|
|
-
|
|
|
- if(in_array(2, $this->auth->getGroupIds())){
|
|
|
+ $this->assign('status', \app\common\model\MobileOrder::$status);
|
|
|
+ $this->assign('logistics_list', json_encode(LogisticsCompany::all()));
|
|
|
+
|
|
|
+ if (in_array(2, $this->auth->getGroupIds())) {
|
|
|
$this->proxy = 1;
|
|
|
- $this->assign('status',\app\common\model\MobileOrder::$GongYSStatus);
|
|
|
+ $this->assign('status', \app\common\model\MobileOrder::$GongYSStatus);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -68,33 +68,33 @@ class MobileOrder extends Backend
|
|
|
//设置过滤方法
|
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
|
|
|
|
- $map=[];
|
|
|
- if($this->admin('is_sub')){
|
|
|
- $map['s_id']=$this->admin('id');
|
|
|
+ $map = [];
|
|
|
+ if ($this->admin('is_sub')) {
|
|
|
+ $map['s_id'] = $this->admin('id');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//if(!$this->admin('is_manager')){
|
|
|
// $map['s_id']=$this->admin('id');
|
|
|
//}
|
|
|
|
|
|
- $export=input('export');
|
|
|
- if($export){
|
|
|
+ $export = input('export');
|
|
|
+ if ($export) {
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
|
|
$list = $this->model
|
|
|
- ->with(['info','operation','operation.admin','admin','admin.admin'])
|
|
|
+ ->with(['info', 'operation', 'operation.admin', 'admin', 'admin.admin'])
|
|
|
->where($where)
|
|
|
->where($map)
|
|
|
- ->where('type',1)
|
|
|
- ->where(function($q) {
|
|
|
+ ->where('type', 1)
|
|
|
+ ->where(function ($q) {
|
|
|
//供应商
|
|
|
- if($this->proxy){
|
|
|
+ if ($this->proxy) {
|
|
|
return $q->where('mobile_order.admin_id', $this->auth->id);
|
|
|
}
|
|
|
})
|
|
|
->order($sort, $order)
|
|
|
->paginate($limit);
|
|
|
- return MobileOrderExport::export($list,$this->admin());
|
|
|
+ return MobileOrderExport::export($list, $this->admin());
|
|
|
}
|
|
|
if ($this->request->isAjax()) {
|
|
|
//如果发送的来源是Selectpage,则转发到Selectpage
|
|
@@ -102,75 +102,75 @@ class MobileOrder extends Backend
|
|
|
return $this->selectpage();
|
|
|
}
|
|
|
// status需要组装的搜索条件
|
|
|
- $filter = json_decode($this->request->get('filter'),true);
|
|
|
- $op = json_decode($this->request->get('op'),true);
|
|
|
-
|
|
|
+ $filter = json_decode($this->request->get('filter'), true);
|
|
|
+ $op = json_decode($this->request->get('op'), true);
|
|
|
+
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
- if($this->admin('is_manager')){
|
|
|
- $relation=['info','operation','operation.admin','admin','admin.admin','refund_log','refund_log.refunduser',
|
|
|
- 'sub_remark','sub_remark.admin','anchor','sub_anchor','sub_anchor.mobileAnchor','proxy','payment'];
|
|
|
- }else{
|
|
|
- $relation=['info','admin','admin.admin','refund_log','refund_log.refunduser','sub_remark'=>function(Query $query){
|
|
|
- $query->where('sub_admin_id',$this->auth->id);
|
|
|
- },'sub_remark.admin','anchor','sub_anchor','sub_anchor.mobileAnchor','proxy','payment'];
|
|
|
+ if ($this->admin('is_manager')) {
|
|
|
+ $relation = ['info', 'operation', 'operation.admin', 'admin', 'admin.admin', 'refund_log', 'refund_log.refunduser',
|
|
|
+ 'sub_remark', 'sub_remark.admin', 'anchor', 'sub_anchor', 'sub_anchor.mobileAnchor', 'proxy', 'payment'];
|
|
|
+ } else {
|
|
|
+ $relation = ['info', 'admin', 'admin.admin', 'refund_log', 'refund_log.refunduser', 'sub_remark' => function (Query $query) {
|
|
|
+ $query->where('sub_admin_id', $this->auth->id);
|
|
|
+ }, 'sub_remark.admin', 'anchor', 'sub_anchor', 'sub_anchor.mobileAnchor', 'proxy', 'payment'];
|
|
|
}
|
|
|
|
|
|
$list = $this->model
|
|
|
->with($relation)
|
|
|
->where($where)
|
|
|
->where($map)
|
|
|
- ->where('type',1)
|
|
|
- ->where(function($q) {
|
|
|
+ ->where('type', 1)
|
|
|
+ ->where(function ($q) {
|
|
|
//供应商
|
|
|
- if($this->proxy){
|
|
|
+ if ($this->proxy) {
|
|
|
return $q->where('mobile_order.admin_id', $this->auth->id);
|
|
|
}
|
|
|
})
|
|
|
->order($sort, $order)
|
|
|
->paginate($limit);
|
|
|
|
|
|
- $upStatus=[];
|
|
|
- if($list->items()) {
|
|
|
- $upStatus = \app\admin\model\Mobile::whereIn('id', array_column($list->items(), 'mobile_id'))->where('status', '<>',0)->column('id');
|
|
|
+ $upStatus = [];
|
|
|
+ if ($list->items()) {
|
|
|
+ $upStatus = \app\admin\model\Mobile::whereIn('id', array_column($list->items(), 'mobile_id'))->where('status', '<>', 0)->column('id');
|
|
|
}
|
|
|
|
|
|
foreach ($list as $row) {
|
|
|
- $row['pay_link']=h5_link("oder-detail/{$row['id']}");
|
|
|
+ $row['pay_link'] = h5_link("oder-detail/{$row['id']}");
|
|
|
$row->append(['phone_order_count']);
|
|
|
- $row['mobile_can_up']=!in_array($row['mobile_id'],$upStatus);
|
|
|
- if($row['s_id']) {
|
|
|
+ $row['mobile_can_up'] = !in_array($row['mobile_id'], $upStatus);
|
|
|
+ if ($row['s_id']) {
|
|
|
$row['s_name'] = Admin::where('id', $row['s_id'])->value('nickname');
|
|
|
- }else{
|
|
|
- $row['s_name']='';
|
|
|
+ } else {
|
|
|
+ $row['s_name'] = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $extend=[];
|
|
|
- $amountMap=[];
|
|
|
- $amountMap['type']=1;
|
|
|
- if(!$this->admin('is_manager')){
|
|
|
- $amountMap['s_id']=$this->admin('id');
|
|
|
+ $extend = [];
|
|
|
+ $amountMap = [];
|
|
|
+ $amountMap['type'] = 1;
|
|
|
+ if (!$this->admin('is_manager')) {
|
|
|
+ $amountMap['s_id'] = $this->admin('id');
|
|
|
}
|
|
|
/*$amountBase=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_base');
|
|
|
$amountDi=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_di');
|
|
|
$extend['total']=bcsub($amountBase,$amountDi);*/
|
|
|
- $extend['total']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_base');
|
|
|
- $extend['alipay']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',2)->sum('amount');
|
|
|
- $extend['wechat']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',1)->sum('amount');
|
|
|
- $extend['jd']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',3)->sum('amount');
|
|
|
- $extend['dy']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',4)->sum('amount');
|
|
|
- $extend['ks']=$this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type',5)->sum('amount');
|
|
|
- $extend['di']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_di');
|
|
|
- $extend['profit']=$this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_profit');
|
|
|
- $extend['refund']=$this->model->where($where)->where($amountMap)->sum('amount_refund');
|
|
|
+ $extend['total'] = $this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_base');
|
|
|
+ $extend['alipay'] = $this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type', 2)->sum('amount');
|
|
|
+ $extend['wechat'] = $this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type', 1)->sum('amount');
|
|
|
+ $extend['jd'] = $this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type', 3)->sum('amount');
|
|
|
+ $extend['dy'] = $this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type', 4)->sum('amount');
|
|
|
+ $extend['ks'] = $this->model->filterSaled()->where($where)->where($amountMap)->where('pay_type', 5)->sum('amount');
|
|
|
+ $extend['di'] = $this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_di');
|
|
|
+ $extend['profit'] = $this->model->filterSaled()->where($where)->where($amountMap)->sum('amount_profit');
|
|
|
+ $extend['refund'] = $this->model->where($where)->where($amountMap)->sum('amount_refund');
|
|
|
|
|
|
// select count(id) as total,status from mobile_order where type=1 GROUP BY status; 角标查询
|
|
|
- if (isset($filter['status'])){
|
|
|
+ if (isset($filter['status'])) {
|
|
|
unset($filter['status']);
|
|
|
unset($op['status']);
|
|
|
}
|
|
|
- $this->request->get(['filter'=>json_encode($filter)]);
|
|
|
- $this->request->get(['op'=>json_encode($op)]);
|
|
|
+ $this->request->get(['filter' => json_encode($filter)]);
|
|
|
+ $this->request->get(['op' => json_encode($op)]);
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
// if($this->admin('is_manager')){
|
|
|
// $relation=['mobile','anchor'];
|
|
@@ -182,28 +182,29 @@ class MobileOrder extends Backend
|
|
|
->field('count(mobile_order.id) as total,mobile_order.status')
|
|
|
->where($where)
|
|
|
->where($map)
|
|
|
- ->where('mobile_order.type',1)
|
|
|
- ->where(function($q) {
|
|
|
+ ->where('mobile_order.type', 1)
|
|
|
+ ->where(function ($q) {
|
|
|
//供应商
|
|
|
- if($this->proxy){
|
|
|
+ if ($this->proxy) {
|
|
|
return $q->where('mobile_order.admin_id', $this->auth->id);
|
|
|
}
|
|
|
})
|
|
|
->group('mobile_order.status')
|
|
|
->select();
|
|
|
|
|
|
- $result = array("total" => $list->total(), "rows" => $list->items(),'extend'=>$extend,'status_list'=>$status_list);
|
|
|
- $result['link']=$this->request->url().'&export=1';
|
|
|
+ $result = array("total" => $list->total(), "rows" => $list->items(), 'extend' => $extend, 'status_list' => $status_list);
|
|
|
+ $result['link'] = $this->request->url() . '&export=1';
|
|
|
|
|
|
return json($result);
|
|
|
}
|
|
|
- $this->assign('admins',Admin::getAdmins());
|
|
|
- $this->assign('subs',Admin::getSubs());
|
|
|
-
|
|
|
- $this->assign('is_proxy',$this->proxy);
|
|
|
- $this->assignconfig('is_proxy',$this->proxy);
|
|
|
+ $this->assign('admins', Admin::getAdmins());
|
|
|
+ $this->assign('subs', Admin::getSubs());
|
|
|
+
|
|
|
+ $this->assign('is_proxy', $this->proxy);
|
|
|
+ $this->assignconfig('is_proxy', $this->proxy);
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
+
|
|
|
protected function buildparams($searchfields = null, $relationSearch = null)
|
|
|
{
|
|
|
$searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
|
|
@@ -369,23 +370,23 @@ class MobileOrder extends Backend
|
|
|
}
|
|
|
foreach ($where as $k => $v) {
|
|
|
if (is_array($v)) {
|
|
|
- if($v[0]=='rules.rule'){
|
|
|
+ if ($v[0] == 'rules.rule') {
|
|
|
$query->whereExists("select * from mobile_order_rules where mobile_order_rules.mobile_order_id=mobile_order.id and rule='{$v[2]}'");
|
|
|
continue;
|
|
|
- }elseif ($v[0]=='admin.admin_id'){
|
|
|
+ } elseif ($v[0] == 'admin.admin_id') {
|
|
|
$query->whereExists("select * from mobile_order_admin where mobile_order_admin.mobile_order_id=mobile_order.id and admin_id={$v[2]}");
|
|
|
continue;
|
|
|
- }elseif ($v[0]=='mobile_order.sub_mobile_anchor_id'){
|
|
|
+ } elseif ($v[0] == 'mobile_order.sub_mobile_anchor_id') {
|
|
|
$query->whereExists("select * from mobile_order_sub_anchor where mobile_order_sub_anchor.mobile_order_id=mobile_order.id and sub_mobile_anchor_id={$v[2]}");
|
|
|
continue;
|
|
|
- }elseif ($v[0]=='status'){
|
|
|
- $v[0]='mobile_order.status';
|
|
|
- }elseif ($v[0]=='create_time'){
|
|
|
- $v[0]='mobile_order.create_time';
|
|
|
- }elseif ($v[0]=='update_time'){
|
|
|
- $v[0]='mobile_order.update_time';
|
|
|
- }elseif ($v[0]=='mobile_order.status' && $v[2]==10){
|
|
|
- $query->whereNotIn('status',[0,50,90]);
|
|
|
+ } elseif ($v[0] == 'status') {
|
|
|
+ $v[0] = 'mobile_order.status';
|
|
|
+ } elseif ($v[0] == 'create_time') {
|
|
|
+ $v[0] = 'mobile_order.create_time';
|
|
|
+ } elseif ($v[0] == 'update_time') {
|
|
|
+ $v[0] = 'mobile_order.update_time';
|
|
|
+ } elseif ($v[0] == 'mobile_order.status' && $v[2] == 10) {
|
|
|
+ $query->whereNotIn('status', [0, 50, 90]);
|
|
|
continue;
|
|
|
}
|
|
|
call_user_func_array([$query, 'where'], $v);
|
|
@@ -396,18 +397,19 @@ class MobileOrder extends Backend
|
|
|
};
|
|
|
return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
|
|
|
}
|
|
|
+
|
|
|
public function edit($ids = null)
|
|
|
{
|
|
|
- $model=$this->model->find($ids);
|
|
|
- $originStatus=$model['status'];
|
|
|
- $row=$model->toArray();
|
|
|
- if($this->request->isGet()){
|
|
|
- $row['address']=$model->originData()['address'];
|
|
|
- $row['city']=\app\common\model\Area::getNameString($row['city'],'/');
|
|
|
- $this->assign('row',$row);
|
|
|
+ $model = $this->model->find($ids);
|
|
|
+ $originStatus = $model['status'];
|
|
|
+ $row = $model->toArray();
|
|
|
+ if ($this->request->isGet()) {
|
|
|
+ $row['address'] = $model->originData()['address'];
|
|
|
+ $row['city'] = \app\common\model\Area::getNameString($row['city'], '/');
|
|
|
+ $this->assign('row', $row);
|
|
|
return view();
|
|
|
- }else{
|
|
|
- $field=[
|
|
|
+ } else {
|
|
|
+ $field = [
|
|
|
'name',
|
|
|
'phone',
|
|
|
'id_no',
|
|
@@ -417,257 +419,277 @@ class MobileOrder extends Backend
|
|
|
'status',
|
|
|
'city',
|
|
|
];
|
|
|
- $data=input('row/a');
|
|
|
+ $data = input('row/a');
|
|
|
Db::startTrans();
|
|
|
- if(isset($data['city'])){
|
|
|
- $data['city']=\app\common\model\Area::whereIn('name|shortname',str_replace('/',',',$data['city']))->column('id');
|
|
|
+ if (isset($data['city'])) {
|
|
|
+ $data['city'] = \app\common\model\Area::whereIn('name|shortname', str_replace('/', ',', $data['city']))->column('id');
|
|
|
}
|
|
|
- $this->validate($data,[
|
|
|
- 'status'=>'in:'.implode(',',array_keys(\app\common\model\MobileOrder::$status))
|
|
|
+ $this->validate($data, [
|
|
|
+ 'status' => 'in:' . implode(',', array_keys(\app\common\model\MobileOrder::$status))
|
|
|
]);
|
|
|
- foreach ($data as $key=>$value){
|
|
|
- if(in_array($key,$field)) {
|
|
|
+ foreach ($data as $key => $value) {
|
|
|
+ if (in_array($key, $field)) {
|
|
|
$model[$key] = $value;
|
|
|
}
|
|
|
}
|
|
|
- MobileOrderAdmin::add($model,$originStatus!=$model['status'],$this->auth->id);
|
|
|
+ MobileOrderAdmin::add($model, $originStatus != $model['status'], $this->auth->id);
|
|
|
$model->save();
|
|
|
Db::commit();
|
|
|
$this->success('');
|
|
|
}
|
|
|
}
|
|
|
- public function refund($ids){
|
|
|
- $model=$this->model->find($ids);
|
|
|
- $this->assign('row',$model);
|
|
|
- if($this->request->isGet()){
|
|
|
+
|
|
|
+ public function refund($ids)
|
|
|
+ {
|
|
|
+ $model = $this->model->find($ids);
|
|
|
+ $this->assign('row', $model);
|
|
|
+ if ($this->request->isGet()) {
|
|
|
return view();
|
|
|
- }else{
|
|
|
- $data=input('row/a');
|
|
|
- $this->validate($data,RefundValidate::class);
|
|
|
+ } else {
|
|
|
+ $data = input('row/a');
|
|
|
+ $this->validate($data, RefundValidate::class);
|
|
|
Db::startTrans();
|
|
|
- $model=$this->model->where('id',$ids)->lock(true)->findOrFail();
|
|
|
- $model->makeRefund('admin',$this->admin(),$data);
|
|
|
+ $model = $this->model->where('id', $ids)->lock(true)->findOrFail();
|
|
|
+ $model->makeRefund('admin', $this->admin(), $data);
|
|
|
Db::commit();
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
- public function status(){
|
|
|
+
|
|
|
+ public function status()
|
|
|
+ {
|
|
|
return \app\common\model\MobileOrder::$status;
|
|
|
}
|
|
|
- public function pay_type(){
|
|
|
+
|
|
|
+ public function pay_type()
|
|
|
+ {
|
|
|
return \app\common\model\MobileOrder::$payTypes;
|
|
|
}
|
|
|
- public function add_operation(){
|
|
|
- $id=input('ids/d');
|
|
|
- if($this->request->isGet()){
|
|
|
- $this->assign('shortcut',ShortcutContent::getList());
|
|
|
+
|
|
|
+ public function add_operation()
|
|
|
+ {
|
|
|
+ $id = input('ids/d');
|
|
|
+ if ($this->request->isGet()) {
|
|
|
+ $this->assign('shortcut', ShortcutContent::getList());
|
|
|
return view();
|
|
|
- }else{
|
|
|
- $content=input('row.content');
|
|
|
- $this->validate(compact('content'),[
|
|
|
- 'content'=>'max:250',
|
|
|
+ } else {
|
|
|
+ $content = input('row.content');
|
|
|
+ $this->validate(compact('content'), [
|
|
|
+ 'content' => 'max:250',
|
|
|
]);
|
|
|
MobileOrderOperation::create([
|
|
|
- 'mobile_order_id'=>$id,
|
|
|
- 'admin_id'=>$this->auth->id,
|
|
|
- 'content'=>$content,
|
|
|
+ 'mobile_order_id' => $id,
|
|
|
+ 'admin_id' => $this->auth->id,
|
|
|
+ 'content' => $content,
|
|
|
]);
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function send(){
|
|
|
- $id=input('ids/d');
|
|
|
- if($this->request->isGet()){
|
|
|
- $row=$this->model->find($id);
|
|
|
- $this->assign('row',$row);
|
|
|
+ public function send()
|
|
|
+ {
|
|
|
+ $id = input('ids/d');
|
|
|
+ if ($this->request->isGet()) {
|
|
|
+ $row = $this->model->find($id);
|
|
|
+ $this->assign('row', $row);
|
|
|
return view();
|
|
|
- }else{
|
|
|
- $data=input('row/a');
|
|
|
+ } else {
|
|
|
+ $data = input('row/a');
|
|
|
Db::startTrans();
|
|
|
- $row=$this->model->lock(true)->findOrFail($id);
|
|
|
- $row->dealSend($data['trans_no'],$data['trans_id']);
|
|
|
+ $row = $this->model->lock(true)->findOrFail($id);
|
|
|
+ $row->dealSend($data['trans_no'], $data['trans_id']);
|
|
|
Db::commit();
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
#展示开卡资料
|
|
|
- public function show_open_data($id){
|
|
|
- $row=$this->model->find($id);
|
|
|
- return view('',compact('row'));
|
|
|
+ public function show_open_data($id)
|
|
|
+ {
|
|
|
+ $row = $this->model->find($id);
|
|
|
+ return view('', compact('row'));
|
|
|
}
|
|
|
- public function see_logistics($ids){
|
|
|
- $order=$this->model->find($ids);
|
|
|
- $data=TransferCheck::instance()->setNo($order['trans_no'])->setName($order['name'])->setPhone($order['phone'])->setLogisticsCompany(LogisticsCompany::get($order['trans_id']))->get();
|
|
|
- $this->assign('data',$data);
|
|
|
+
|
|
|
+ public function see_logistics($ids)
|
|
|
+ {
|
|
|
+ $order = $this->model->find($ids);
|
|
|
+ $data = TransferCheck::instance()->setNo($order['trans_no'])->setName($order['name'])->setPhone($order['phone'])->setLogisticsCompany(LogisticsCompany::get($order['trans_id']))->get();
|
|
|
+ $this->assign('data', $data);
|
|
|
return view('mobile_order/see_logistics');
|
|
|
}
|
|
|
+
|
|
|
#备注
|
|
|
- public function sub_remark($id){
|
|
|
- $order=$this->model->find($id);
|
|
|
- if($this->admin('is_sub') && $this->auth->id!=$order['s_id']){
|
|
|
+ public function sub_remark($id)
|
|
|
+ {
|
|
|
+ $order = $this->model->find($id);
|
|
|
+ if ($this->admin('is_sub') && $this->auth->id != $order['s_id']) {
|
|
|
$this->error('操作失败(a)');
|
|
|
}
|
|
|
- if($this->request->isGet()){
|
|
|
+ if ($this->request->isGet()) {
|
|
|
return view();
|
|
|
- }else{
|
|
|
- $data=input('row/a');
|
|
|
- $this->validate($data,[
|
|
|
- 'content|备注'=>['require','max:50'],
|
|
|
+ } else {
|
|
|
+ $data = input('row/a');
|
|
|
+ $this->validate($data, [
|
|
|
+ 'content|备注' => ['require', 'max:50'],
|
|
|
]);
|
|
|
$order->subRemark()->save([
|
|
|
- 'sub_admin_id'=>$this->auth->id,
|
|
|
- 'content'=>$data['content'],
|
|
|
+ 'sub_admin_id' => $this->auth->id,
|
|
|
+ 'content' => $data['content'],
|
|
|
]);
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
- public function set_anchor($ids){
|
|
|
- $order=$this->model->find($ids);
|
|
|
- if(!$order){
|
|
|
+
|
|
|
+ public function set_anchor($ids)
|
|
|
+ {
|
|
|
+ $order = $this->model->find($ids);
|
|
|
+ if (!$order) {
|
|
|
$this->error('订单不存在');
|
|
|
}
|
|
|
- if($this->request->isGet()){
|
|
|
- if($this->admin('is_manager')){
|
|
|
- $anchor_id=$order['mobile_anchor_id'];
|
|
|
- $this->assign('mobile_anchor_id',$anchor_id);
|
|
|
+ if ($this->request->isGet()) {
|
|
|
+ if ($this->admin('is_manager')) {
|
|
|
+ $anchor_id = $order['mobile_anchor_id'];
|
|
|
+ $this->assign('mobile_anchor_id', $anchor_id);
|
|
|
}
|
|
|
- $sub_anchor_id=$order->subAnchor()->value('sub_mobile_anchor_id');
|
|
|
- $this->assign('sub_mobile_anchor_id',$sub_anchor_id);
|
|
|
- $this->assign('order',$order);
|
|
|
+ $sub_anchor_id = $order->subAnchor()->value('sub_mobile_anchor_id');
|
|
|
+ $this->assign('sub_mobile_anchor_id', $sub_anchor_id);
|
|
|
+ $this->assign('order', $order);
|
|
|
return view('sub_anchor');
|
|
|
- }else{
|
|
|
- $data=input('row/a');
|
|
|
- if(!empty($data['mobile_anchor_id']) && !\app\admin\model\MobileAnchor::find($data['mobile_anchor_id'])){
|
|
|
+ } else {
|
|
|
+ $data = input('row/a');
|
|
|
+ if (!empty($data['mobile_anchor_id']) && !\app\admin\model\MobileAnchor::find($data['mobile_anchor_id'])) {
|
|
|
$this->error('主播不存在');
|
|
|
}
|
|
|
- if(!empty($data['sub_mobile_anchor_id']) && !\app\admin\model\MobileAnchor::find($data['sub_mobile_anchor_id'])){
|
|
|
+ if (!empty($data['sub_mobile_anchor_id']) && !\app\admin\model\MobileAnchor::find($data['sub_mobile_anchor_id'])) {
|
|
|
$this->error('主播不存在');
|
|
|
}
|
|
|
- if($this->admin('is_manager')){
|
|
|
- if(!empty($data['mobile_anchor_id'])){
|
|
|
- $order['mobile_anchor_id']=$data['mobile_anchor_id'];
|
|
|
- if(!$order->save()){
|
|
|
+ if ($this->admin('is_manager')) {
|
|
|
+ if (!empty($data['mobile_anchor_id'])) {
|
|
|
+ $order['mobile_anchor_id'] = $data['mobile_anchor_id'];
|
|
|
+ if (!$order->save()) {
|
|
|
$this->error('保存失败');
|
|
|
}
|
|
|
}
|
|
|
- if(!empty($data['sub_mobile_anchor_id'])){
|
|
|
- MobileOrderSubAnchor::sync($order,$data['sub_mobile_anchor_id']);
|
|
|
+ if (!empty($data['sub_mobile_anchor_id'])) {
|
|
|
+ MobileOrderSubAnchor::sync($order, $data['sub_mobile_anchor_id']);
|
|
|
}
|
|
|
|
|
|
- }elseif ($this->admin('is_sub') && $this->admin('id')==$order['s_id']){
|
|
|
- if(!empty($data['sub_mobile_anchor_id'])){
|
|
|
- if($order->subAnchor()->find()){
|
|
|
+ } elseif ($this->admin('is_sub') && $this->admin('id') == $order['s_id']) {
|
|
|
+ if (!empty($data['sub_mobile_anchor_id'])) {
|
|
|
+ if ($order->subAnchor()->find()) {
|
|
|
$this->error('无法再次设置');
|
|
|
}
|
|
|
- MobileOrderSubAnchor::sync($order,$data['sub_mobile_anchor_id']);
|
|
|
+ MobileOrderSubAnchor::sync($order, $data['sub_mobile_anchor_id']);
|
|
|
}
|
|
|
}
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function mobile_up($ids){
|
|
|
- $order=$this->model->find($ids);
|
|
|
- $mobile=$order->mobile()->find();
|
|
|
- if($this->request->isGet()) {
|
|
|
+ public function mobile_up($ids)
|
|
|
+ {
|
|
|
+ $order = $this->model->find($ids);
|
|
|
+ $mobile = $order->mobile()->find();
|
|
|
+ if ($this->request->isGet()) {
|
|
|
$this->assign('row', $mobile);
|
|
|
$this->assign('disabled', 1);
|
|
|
$this->assign('otherSubDisabled', 1);
|
|
|
return view();
|
|
|
- }else{
|
|
|
- if($mobile){
|
|
|
+ } else {
|
|
|
+ if ($mobile) {
|
|
|
$mobile->again_sell();
|
|
|
}
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function refund_log(){
|
|
|
- if($this->request->isAjax()){
|
|
|
+ public function refund_log()
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
- $this->relationSearch=true;
|
|
|
+ $this->relationSearch = true;
|
|
|
/*$limit=input('limit',10);
|
|
|
$offset=input('offset',0);*/
|
|
|
- $filter=json_decode(input('filter'),true)?:[];
|
|
|
- $map=[];
|
|
|
- if(!empty($filter['od.mobile_id'])){
|
|
|
- $map['mobile_order.mobile_id']=['eq',$filter['od.mobile_id']];
|
|
|
+ $filter = json_decode(input('filter'), true) ?: [];
|
|
|
+ $map = [];
|
|
|
+ if (!empty($filter['od.mobile_id'])) {
|
|
|
+ $map['mobile_order.mobile_id'] = ['eq', $filter['od.mobile_id']];
|
|
|
}
|
|
|
- if(!empty($filter['od.s_id'])){
|
|
|
- $map['mobile_order.s_id']=['eq',$filter['od.s_id']];
|
|
|
+ if (!empty($filter['od.s_id'])) {
|
|
|
+ $map['mobile_order.s_id'] = ['eq', $filter['od.s_id']];
|
|
|
}
|
|
|
- if(isset($filter['pass'])){
|
|
|
- $map['pass']=['eq',$filter['pass']];
|
|
|
+ if (isset($filter['pass'])) {
|
|
|
+ $map['pass'] = ['eq', $filter['pass']];
|
|
|
}
|
|
|
- if(!empty($filter['od.no'])){
|
|
|
- $map['mobile_order.no']=['like',"%{$filter['od.no']}%"];
|
|
|
+ if (!empty($filter['od.no'])) {
|
|
|
+ $map['mobile_order.no'] = ['like', "%{$filter['od.no']}%"];
|
|
|
}
|
|
|
- if(!empty($filter['od.order_no'])){
|
|
|
- $map['mobile_order.order_no']=['like',"%{$filter['od.order_no']}%"];
|
|
|
+ if (!empty($filter['od.order_no'])) {
|
|
|
+ $map['mobile_order.order_no'] = ['like', "%{$filter['od.order_no']}%"];
|
|
|
}
|
|
|
- if(!empty($filter['reason'])){
|
|
|
- $map['reason']=['like',"%{$filter['reason']}%"];
|
|
|
+ if (!empty($filter['reason'])) {
|
|
|
+ $map['reason'] = ['like', "%{$filter['reason']}%"];
|
|
|
}
|
|
|
- if(!empty($filter['admin.nickname'])){
|
|
|
- $map['admin.nickname']=['like',"%{$filter['admin.nickname']}%"];
|
|
|
+ if (!empty($filter['admin.nickname'])) {
|
|
|
+ $map['admin.nickname'] = ['like', "%{$filter['admin.nickname']}%"];
|
|
|
}
|
|
|
- if(!empty($filter['od.amount'])){
|
|
|
- $amountArr=explode(',',$filter['od.amount']);
|
|
|
- if(empty($amountArr[0])){
|
|
|
- $amountArr[0]=0;
|
|
|
+ if (!empty($filter['od.amount'])) {
|
|
|
+ $amountArr = explode(',', $filter['od.amount']);
|
|
|
+ if (empty($amountArr[0])) {
|
|
|
+ $amountArr[0] = 0;
|
|
|
}
|
|
|
- if(empty($amountArr[1])){
|
|
|
- $amountArr[1]=10000000000000;
|
|
|
+ if (empty($amountArr[1])) {
|
|
|
+ $amountArr[1] = 10000000000000;
|
|
|
}
|
|
|
- $map['mobile_order.amount']=['between',$amountArr];
|
|
|
+ $map['mobile_order.amount'] = ['between', $amountArr];
|
|
|
}
|
|
|
- if(!empty($filter['amount_backend'])){
|
|
|
- $amountArr=explode(',',$filter['amount_backend']);
|
|
|
- if(empty($amountArr[0])){
|
|
|
- $amountArr[0]=0;
|
|
|
+ if (!empty($filter['amount_backend'])) {
|
|
|
+ $amountArr = explode(',', $filter['amount_backend']);
|
|
|
+ if (empty($amountArr[0])) {
|
|
|
+ $amountArr[0] = 0;
|
|
|
}
|
|
|
- if(empty($amountArr[1])){
|
|
|
- $amountArr[1]=10000000000000;
|
|
|
+ if (empty($amountArr[1])) {
|
|
|
+ $amountArr[1] = 10000000000000;
|
|
|
}
|
|
|
- $map['amount_backend']=['between',$amountArr];
|
|
|
+ $map['amount_backend'] = ['between', $amountArr];
|
|
|
}
|
|
|
- $log=(new MobileOrderRefundLog)->getTable();
|
|
|
- if(!empty($filter['create_time'])){
|
|
|
- list($s,$e)=explode(' - ',$filter['create_time']);
|
|
|
- $map["{$log}.create_time"]=['between',[strtotime($s),strtotime($e)]];
|
|
|
+ $log = (new MobileOrderRefundLog)->getTable();
|
|
|
+ if (!empty($filter['create_time'])) {
|
|
|
+ list($s, $e) = explode(' - ', $filter['create_time']);
|
|
|
+ $map["{$log}.create_time"] = ['between', [strtotime($s), strtotime($e)]];
|
|
|
}
|
|
|
//$page=$offset/$limit+1;
|
|
|
- $data=MobileOrderRefundLog::where($map)
|
|
|
- ->where(function (Query $query){
|
|
|
- if(!$this->admin('is_manager')){
|
|
|
- $query->where('mobile_order.s_id',$this->admin('id'));
|
|
|
+ $data = MobileOrderRefundLog::where($map)
|
|
|
+ ->where(function (Query $query) {
|
|
|
+ if (!$this->admin('is_manager')) {
|
|
|
+ $query->where('mobile_order.s_id', $this->admin('id'));
|
|
|
}
|
|
|
})
|
|
|
- ->with(['od','admin'])
|
|
|
- ->order('id','desc')
|
|
|
- ->paginate($limit,false);
|
|
|
- /* foreach ($data as $model){
|
|
|
- $model->setAttr('s_name',Admin::where('id',$model['od']['s_id'])->value('nickname'));
|
|
|
- }*/
|
|
|
+ ->with(['od', 'admin'])
|
|
|
+ ->order('id', 'desc')
|
|
|
+ ->paginate($limit, false);
|
|
|
+ /* foreach ($data as $model){
|
|
|
+ $model->setAttr('s_name',Admin::where('id',$model['od']['s_id'])->value('nickname'));
|
|
|
+ }*/
|
|
|
return json([
|
|
|
- 'total'=>$data->total(),
|
|
|
- 'rows'=>$data->items(),
|
|
|
- 'filter'=>$filter,
|
|
|
+ 'total' => $data->total(),
|
|
|
+ 'rows' => $data->items(),
|
|
|
+ 'filter' => $filter,
|
|
|
]);
|
|
|
}
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
#dy结算
|
|
|
- public function dy_settle(){
|
|
|
- $id=input('ids');
|
|
|
- if(empty($id)){
|
|
|
+ public function dy_settle()
|
|
|
+ {
|
|
|
+ $id = input('ids');
|
|
|
+ if (empty($id)) {
|
|
|
$this->error('id必须');
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
- $order=$this->model->lock(true)->find($id);
|
|
|
- if(!$order){
|
|
|
+ $order = $this->model->lock(true)->find($id);
|
|
|
+ if (!$order) {
|
|
|
$this->error('订单不存在');
|
|
|
}
|
|
|
$order->dySettle();
|