作者 jinglong
1 个管道 的构建 通过 耗费 6 秒

增加物流接口

@@ -3,7 +3,8 @@ @@ -3,7 +3,8 @@
3 namespace app\admin\controller; 3 namespace app\admin\controller;
4 4
5 use app\common\controller\Backend; 5 use app\common\controller\Backend;
6 - 6 +use think\Db;
  7 +use EasyWeChat\Factory;
7 /** 8 /**
8 * 订单管理 9 * 订单管理
9 * 10 *
@@ -73,4 +74,107 @@ class Order extends Backend @@ -73,4 +74,107 @@ class Order extends Backend
73 } 74 }
74 return $this->view->fetch(); 75 return $this->view->fetch();
75 } 76 }
  77 +
  78 + /**
  79 + * 录入物流单号
  80 + */
  81 + public function code($ids = null)
  82 + {
  83 + $row = $this->model->get($ids);
  84 + if (!$row) {
  85 + $this->error(__('No Results were found'));
  86 + }
  87 + $adminIds = $this->getDataLimitAdminIds();
  88 + if (is_array($adminIds)) {
  89 + if (!in_array($row[$this->dataLimitField], $adminIds)) {
  90 + $this->error(__('You have no permission'));
  91 + }
  92 + }
  93 + if ($this->request->isPost()) {
  94 + $params = $this->request->post("row/a");
  95 + if ($params) {
  96 + $params = $this->preExcludeFields($params);
  97 + $params['status'] = config('verify.status')[5];
  98 + //查询快递公司名称
  99 + $company = Db::name('logistics')->where(['logi_code'=>$params['LogisticCode']])->field('id,logi_name')->find();
  100 + $params['LogisticCompany'] = $company['logi_name'];
  101 + $result = $row->allowField(true)->save($params);
  102 + if($result){
  103 + $this->success('发货成功');
  104 + }else{
  105 + $this->error('失败');
  106 + }
  107 + }
  108 + $this->error(__('Parameter %s can not be empty', ''));
  109 + }
  110 + $arr = [];
  111 + $ship = Db::name('logistics')->select();
  112 + foreach($ship as $value){
  113 + $arr[$value['logi_code']] = $value['logi_name'];
  114 + }
  115 + $this->view->assign('order_id',$ids);
  116 + $this->view->assign('ship',$arr);
  117 + return $this->view->fetch();
  118 + }
  119 +
  120 + /**
  121 + * 申请退款
  122 + */
  123 + public function adoptRefund($ids)
  124 + {
  125 + if ($ids) {
  126 + $pk = $this->model->getPk();
  127 + $res = Db::name('order')->where($pk,$ids)->field('id,pay_order_sn,total_goods_price')->find();
  128 + $status = config('verify.status');
  129 + $res1 = $this->model->where($pk, '=', $ids)->update(['status'=>$status[4]]);
  130 + if($res1){
  131 + $this->success('成功');
  132 + }else{
  133 + $this->error('失败');
  134 + }
  135 + //处理退款逻辑
  136 +// $config = config('verify.wx_pay');
  137 +// $app = Factory::payment($config);
  138 +// $security_price = $res['total_goods_price']*100;
  139 +// $refundNumber = $this->genPayOrderSn('refund');//商户退款单号
  140 +// $result = $app->refund->byOutTradeNumber($res['pay_order_sn'], $refundNumber, $security_price, $security_price, [
  141 +// // 可在此处传入其他参数,详细参数见微信支付文档
  142 +// ]);
  143 +// if($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS'){
  144 +// $this->model->where($pk, '=', $ids)->update(['status'=>$status[4]]);
  145 +// $this->success('成功');
  146 +// }else{
  147 +// $this->error('退款失败');
  148 +// }
  149 +
  150 + }
  151 + $this->error(__('Parameter %s can not be empty', 'ids'));
  152 + }
  153 +
  154 + /**
  155 + * 申请退换货
  156 + */
  157 + public function adoptReturn($ids)
  158 + {
  159 + if ($ids) {
  160 + $pk = $this->model->getPk();
  161 + $status = config('verify.status');
  162 + $res = $this->model->where($pk, '=', $ids)->update(['status'=>$status[7]]);
  163 + if($res){
  164 + $this->success('成功');
  165 + }else{
  166 + $this->error('失败');
  167 + }
  168 + }
  169 + $this->error(__('Parameter %s can not be empty', 'ids'));
  170 + }
  171 +
  172 + //支付订单号
  173 + public static function genPayOrderSn($letter = '') {
  174 + $time = explode (" ", microtime ());
  175 + $timeArr = explode('.',$time [0]);
  176 + $mtime = array_pop($timeArr);
  177 + $fulltime = $letter.$time[1].$mtime.mt_rand(1000,9999);
  178 + return $fulltime;
  179 + }
76 } 180 }
@@ -9,11 +9,15 @@ return [ @@ -9,11 +9,15 @@ return [
9 'Receive_name' => '收货人', 9 'Receive_name' => '收货人',
10 'Receive_mobile' => '收获联系方式', 10 'Receive_mobile' => '收获联系方式',
11 'Receive_address' => '收货地址', 11 'Receive_address' => '收货地址',
  12 + 'ShipperCode' => '快递单号',
  13 + 'LogisticCompany' => '快递公司',
  14 + 'Refund_reason' => '退款原因',
  15 + 'Return_reason' => '退换货原因',
12 'Leave_message' => '留言', 16 'Leave_message' => '留言',
13 'Discount_price' => '优惠价格', 17 'Discount_price' => '优惠价格',
14 'Total_goods_price' => '商品总金额', 18 'Total_goods_price' => '商品总金额',
15 'Total_expense_price' => '运费总金额', 19 'Total_expense_price' => '运费总金额',
16 - 'Total_price' => '支付总金额(商+运-优惠)', 20 + 'Total_price' => '支付总金额',
17 'Coupon_id' => '优惠券id', 21 'Coupon_id' => '优惠券id',
18 'Createtime' => '创建时间', 22 'Createtime' => '创建时间',
19 'Updatetime' => '更新时间', 23 'Updatetime' => '更新时间',
@@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
7 <div class="widget-body no-padding"> 7 <div class="widget-body no-padding">
8 <div id="toolbar" class="toolbar"> 8 <div id="toolbar" class="toolbar">
9 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> 9 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
10 - <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('ogoods/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>  
11 - <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('ogoods/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> 10 + <!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('ogoods/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
  11 + <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('ogoods/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
12 <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('ogoods/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> 12 <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('ogoods/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
13 <!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('ogoods/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>--> 13 <!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('ogoods/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
14 14
  1 +<form id="code-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 + <input type="hidden" name="row[id]" data-rule="required" value="{$order_id}">
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">快递公司</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + {:build_select('row[LogisticCode]', $ship, null, ['class'=>'form-control', 'required'=>''])}
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">单号</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-ShipperCode" data-rule="required" class="form-control" name="row[ShipperCode]" type="text" value="" placeholder="请录入快递单号">
  13 + </div>
  14 + </div>
  15 + <div class="form-group layer-footer">
  16 + <label class="control-label col-xs-12 col-sm-2"></label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>
  19 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  20 + </div>
  21 + </div>
  22 +</form>
1 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> 1 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
2 -  
3 - <div class="form-group">  
4 - <label class="control-label col-xs-12 col-sm-2">{:__('Uid')}:</label>  
5 - <div class="col-xs-12 col-sm-8">  
6 - <input id="c-uid" data-rule="required" class="form-control" name="row[uid]" type="number" value="{$row.uid|htmlentities}">  
7 - </div>  
8 - </div>  
9 - <div class="form-group">  
10 - <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>  
11 - <div class="col-xs-12 col-sm-8">  
12 - <input id="c-status" data-rule="required" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}">  
13 - </div>  
14 - </div>  
15 <div class="form-group"> 2 <div class="form-group">
16 <label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label> 3 <label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
17 <div class="col-xs-12 col-sm-8"> 4 <div class="col-xs-12 col-sm-8">
@@ -43,6 +30,30 @@ @@ -43,6 +30,30 @@
43 </div> 30 </div>
44 </div> 31 </div>
45 <div class="form-group"> 32 <div class="form-group">
  33 + <label class="control-label col-xs-12 col-sm-2">{:__('ShipperCode')}:</label>
  34 + <div class="col-xs-12 col-sm-8">
  35 + <input id="c-ShipperCode" data-rule="required" class="form-control" name="row[ShipperCode]" type="text" value="{$row.ShipperCode|htmlentities}">
  36 + </div>
  37 + </div>
  38 + <div class="form-group">
  39 + <label class="control-label col-xs-12 col-sm-2">{:__('LogisticCompany')}:</label>
  40 + <div class="col-xs-12 col-sm-8">
  41 + <input id="c-LogisticCompany" data-rule="required" class="form-control" name="row[LogisticCompany]" type="text" value="{$row.LogisticCompany|htmlentities}">
  42 + </div>
  43 + </div>
  44 + <div class="form-group">
  45 + <label class="control-label col-xs-12 col-sm-2">{:__('Refund_reason')}:</label>
  46 + <div class="col-xs-12 col-sm-8">
  47 + <input id="c-refund_reason" data-rule="required" class="form-control" name="row[refund_reason]" type="text" value="{$row.refund_reason|htmlentities}">
  48 + </div>
  49 + </div>
  50 + <div class="form-group">
  51 + <label class="control-label col-xs-12 col-sm-2">{:__('Return_reason')}:</label>
  52 + <div class="col-xs-12 col-sm-8">
  53 + <input id="c-return_reason" data-rule="required" class="form-control" name="row[return_reason]" type="text" value="{$row.return_reason|htmlentities}">
  54 + </div>
  55 + </div>
  56 + <div class="form-group">
46 <label class="control-label col-xs-12 col-sm-2">{:__('Leave_message')}:</label> 57 <label class="control-label col-xs-12 col-sm-2">{:__('Leave_message')}:</label>
47 <div class="col-xs-12 col-sm-8"> 58 <div class="col-xs-12 col-sm-8">
48 <input id="c-leave_message" data-rule="required" class="form-control" name="row[leave_message]" type="text" value="{$row.leave_message|htmlentities}"> 59 <input id="c-leave_message" data-rule="required" class="form-control" name="row[leave_message]" type="text" value="{$row.leave_message|htmlentities}">
@@ -72,16 +83,10 @@ @@ -72,16 +83,10 @@
72 <input id="c-total_price" class="form-control" step="0.01" name="row[total_price]" type="number" value="{$row.total_price|htmlentities}"> 83 <input id="c-total_price" class="form-control" step="0.01" name="row[total_price]" type="number" value="{$row.total_price|htmlentities}">
73 </div> 84 </div>
74 </div> 85 </div>
75 - <div class="form-group">  
76 - <label class="control-label col-xs-12 col-sm-2">{:__('Coupon_id')}:</label>  
77 - <div class="col-xs-12 col-sm-8">  
78 - <input id="c-coupon_id" data-rule="required" data-source="coupon/index" class="form-control selectpage" name="row[coupon_id]" type="text" value="{$row.coupon_id|htmlentities}">  
79 - </div>  
80 - </div>  
81 <div class="form-group layer-footer"> 86 <div class="form-group layer-footer">
82 <label class="control-label col-xs-12 col-sm-2"></label> 87 <label class="control-label col-xs-12 col-sm-2"></label>
83 <div class="col-xs-12 col-sm-8"> 88 <div class="col-xs-12 col-sm-8">
84 - <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> 89 + <!--<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>-->
85 <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> 90 <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
86 </div> 91 </div>
87 </div> 92 </div>
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <div class="widget-body no-padding"> 7 <div class="widget-body no-padding">
8 <div id="toolbar" class="toolbar"> 8 <div id="toolbar" class="toolbar">
9 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> 9 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
10 - <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> 10 + <!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
11 <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> 11 <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
12 <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> 12 <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
13 <!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>--> 13 <!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: 老猫 <thinkcmf@126.com>
  10 +// +----------------------------------------------------------------------
  11 +namespace app\api\controller;
  12 +
  13 +use app\admin\model\Order;
  14 +use app\common\controller\Api;
  15 +use think\Db;
  16 +use think\Validate;
  17 +/**
  18 + * 物流接口
  19 + */
  20 +class Express extends Api
  21 +{
  22 + protected $noNeedLogin = [];
  23 + protected $noNeedRight = '*';
  24 + protected $uid = '';//token存贮user_id
  25 + public function _initialize()
  26 + {
  27 + parent::_initialize();
  28 + $this->uid = $this->auth->getUserId();
  29 + }
  30 +
  31 + /**
  32 + * @ApiTitle (调用查询物流轨迹)
  33 + * @ApiSummary (调用查询物流轨迹)
  34 + * @ApiMethod (GET)
  35 + * @ApiRoute (/api/express/getExpress)
  36 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  37 + *
  38 + * @ApiParams (name="order_id", type="inter", required=true, description="订单id")
  39 + *
  40 + * @ApiReturn({
  41 + "code": 1,
  42 + "msg": "成功",
  43 + "time": "1575532542",
  44 + "data": {
  45 + "LogisticCode": "75317246876602",//快递单号
  46 + "ShipperCode": "ZTO",//快递编码
  47 + "Traces": [
  48 + {
  49 + "AcceptStation": "【东莞市】 【东莞厚街】(0769-86947628) 的 张小姐(18027104980) 已揽收",//轨迹
  50 + "AcceptTime": "2019-12-03 18:43:03"//时间
  51 + },
  52 + {
  53 + "AcceptStation": "【东莞市】 快件离开 【东莞厚街】 已发往 【天津中转部】",
  54 + "AcceptTime": "2019-12-04 00:18:01"
  55 + },
  56 + {
  57 + "AcceptStation": "【天津市】 快件离开 【天津中转部】 已发往 【天津南开六部】",
  58 + "AcceptTime": "2019-12-05 14:35:03"
  59 + }
  60 + ],
  61 + "State": "2",
  62 + "EBusinessID": "1442433",
  63 + "Success": true,
  64 + "LogisticCompany": "中通快递"//快递公司
  65 + }
  66 + })
  67 + *
  68 + */
  69 + public function getExpress(){
  70 + $order_id = $this->request->get('order_id');
  71 +
  72 + $rule = config('verify.order_detail');
  73 + $validate = new Validate($rule['rule'],$rule['msg']);
  74 + if (!$validate->check(['order_id'=>$order_id])) {
  75 + $this->error($validate->getError());
  76 + }
  77 +
  78 + $where = ['id'=>$order_id,'uid'=>$this->uid];
  79 + $order = Common::findSoftWhereData('order',$where,'id,ShipperCode,LogisticCode,LogisticCompany');
  80 + if($order){
  81 + $logisticResult = $this->getOrderTracesByJson($order['LogisticCode'],$order['ShipperCode']);//快递编码,单号
  82 + $data = json_decode($logisticResult,true);
  83 + if($data['Success'] == true){//返回信息成功
  84 + $data['LogisticCompany'] = $order['LogisticCompany'];
  85 + $this->success('成功',$data);
  86 + }
  87 + $this->error('未找到物流踪迹');
  88 + }
  89 + $this->error('未找到物流踪迹');
  90 + }
  91 +
  92 + /**
  93 + * 物流
  94 + * @ApiInternal
  95 + */
  96 + public function getOrderTracesByJson($kgs,$number){
  97 + $express = config('verify.express');
  98 + $EBusinessID = $express['EBusinessID'];
  99 + $appKey = $express['appKey'];
  100 + $url = $express['url'];
  101 + $requestData= "{'OrderCode':'','ShipperCode':'$kgs','LogisticCode':'$number'}";
  102 + $data = array(
  103 + 'EBusinessID' => $EBusinessID,
  104 + 'RequestType' => '1002',
  105 + 'RequestData' => urlencode($requestData) ,
  106 + 'DataType' => '2',
  107 + );
  108 + $data['DataSign'] = $this->encrypt($requestData.$appKey);
  109 + $result = $this->auth->http_post($url, $data);
  110 + return $result;
  111 + }
  112 +
  113 + /**
  114 + * 签名
  115 + * @ApiInternal
  116 + */
  117 + public function encrypt($str) {
  118 + return urlencode(base64_encode(md5($str)));
  119 + }
  120 +}
@@ -5,6 +5,12 @@ return [ @@ -5,6 +5,12 @@ return [
5 'app_id' => 'wx322817859bfe5db1',//app_id 5 'app_id' => 'wx322817859bfe5db1',//app_id
6 'secret' => '9166e17b56427e9eae2a5f49cfd3aeaf',//秘钥 6 'secret' => '9166e17b56427e9eae2a5f49cfd3aeaf',//秘钥
7 ], 7 ],
  8 + //快递鸟配置
  9 + 'express'=>[
  10 + 'EBusinessID' =>'1442433',
  11 + 'appKey' =>'59387773-4d1c-4006-a5c6-159261ed4fef',
  12 + 'url' =>'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',//请求地址
  13 + ],
8 //微信支付配置 14 //微信支付配置
9 'wx_pay' => [ 15 'wx_pay' => [
10 'app_id' => 'wx322817859bfe5db1', 16 'app_id' => 'wx322817859bfe5db1',
此 diff 太大无法显示。
@@ -7,7 +7,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -7,7 +7,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
7 extend: { 7 extend: {
8 index_url: 'ogoods/index' + location.search, 8 index_url: 'ogoods/index' + location.search,
9 add_url: 'ogoods/add', 9 add_url: 'ogoods/add',
10 - edit_url: 'ogoods/edit', 10 + // edit_url: 'ogoods/edit',
11 del_url: 'ogoods/del', 11 del_url: 'ogoods/del',
12 multi_url: 'ogoods/multi', 12 multi_url: 'ogoods/multi',
13 table: 'ogoods', 13 table: 'ogoods',
@@ -34,7 +34,71 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -34,7 +34,71 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
34 {field: 'user.nickname', title: __('User.nickname')}, 34 {field: 'user.nickname', title: __('User.nickname')},
35 {field: 'user.avatar', title: __('User.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image}, 35 {field: 'user.avatar', title: __('User.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
36 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 36 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
37 - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 37 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[
  38 + {
  39 + name: 'detail',
  40 + text: __('录入单号'),
  41 + title: __('录入单号'),
  42 + classname: 'btn btn-xs btn-primary btn-dialog',
  43 + icon: 'fa fa-list',
  44 + url: 'order/code',
  45 + callback: function (data) {
  46 + //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  47 + },
  48 + visible: function (row) {
  49 + //返回true时按钮显示,返回false隐藏
  50 + if(row.status == 2){
  51 + return true;
  52 + }else{
  53 + return false;
  54 + }
  55 + }
  56 + },
  57 + {
  58 + name: 'detail',
  59 + text: __('同意'),
  60 + title: __('申请退款'),
  61 + classname: 'btn btn-xs btn-primary btn-ajax',
  62 + icon: 'fa fa-magic',
  63 + url: 'order/adoptRefund',
  64 + confirm: '确认通过?',
  65 + success: function (data, ret) {
  66 + $(".btn-refresh").trigger("click");
  67 + },
  68 + error: function (data, ret) {
  69 + return false;
  70 + },
  71 + visible: function (row) {
  72 + if(row.status == 3){
  73 + return true;
  74 + }else{
  75 + return false;
  76 + }
  77 + }
  78 + },
  79 + {
  80 + name: 'detail',
  81 + text: __('同意'),
  82 + title: __('申请退换货'),
  83 + classname: 'btn btn-xs btn-primary btn-ajax',
  84 + icon: 'fa fa-magic',
  85 + url: 'order/adoptReturn',
  86 + confirm: '确认通过?',
  87 + success: function (data, ret) {
  88 + $(".btn-refresh").trigger("click");
  89 + },
  90 + error: function (data, ret) {
  91 + return false;
  92 + },
  93 + visible: function (row) {
  94 + if(row.status == 6){
  95 + return true;
  96 + }else{
  97 + return false;
  98 + }
  99 + }
  100 + }
  101 + ]}
38 ] 102 ]
39 ] 103 ]
40 }); 104 });
@@ -107,6 +171,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -107,6 +171,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
107 edit: function () { 171 edit: function () {
108 Controller.api.bindevent(); 172 Controller.api.bindevent();
109 }, 173 },
  174 + code: function () {
  175 + Controller.api.bindevent();
  176 + },
110 api: { 177 api: {
111 bindevent: function () { 178 bindevent: function () {
112 Form.api.bindevent($("form[role=form]")); 179 Form.api.bindevent($("form[role=form]"));