瀏覽代碼

扫码录入

dong025 3 天之前
父節點
當前提交
aa8fb8df38

+ 10 - 3
app/admin/controller/shop/ShopDelivery.php

@@ -38,10 +38,17 @@ class ShopDelivery extends Backend
             return $this->selectpage();
         }
         [$where, $order, $limit, $with] = $this->buildparams();
+        // $list = $this->model
+        //     ->withJoin($with,'left')
+        //     //如果没有使用operate filter过滤的情况下,推荐使用with关联,可以提高查询效率
+        //     //->with($with)
+        //     ->where($where)
+        //     ->order($order)
+        //     ->paginate($limit);
         $list = $this->model
-            ->withJoin($with,'left')
-            //如果没有使用operate filter过滤的情况下,推荐使用with关联,可以提高查询效率
-            //->with($with)
+            ->alias('d')
+            ->join('user u',"d.user_id = u.id", "LEFT")
+            ->field('d.*,COALESCE(u.nickname, "无") as nickname')
             ->where($where)
             ->order($order)
             ->paginate($limit);

+ 1 - 1
app/admin/service/FengsuService.php

@@ -94,7 +94,7 @@ class FengsuService {
                         'waybill_no'    => $item['waybillNo'],
                         'region'        => $item['receiverProvince'].' '.$item['receiverCity'],
                         'other_price'   => $other_price,
-                        'ship_date'     => substr($item['consignTime'], 0, 10),
+                        'ship_date'     => $item['consignTime'],
                         'incubator'   => $getPackSpecsFee['pack_specs_type'],
                         'insulation_money'   => $getPackSpecsFee['surcharge_money'],
                         'labor_cost_money'   => $getPackSpecsFee['data']['labor_cost_money']

+ 2 - 2
app/admin/service/JuShuiTanService.php

@@ -88,7 +88,7 @@ class JuShuiTanService {
                         'waybill_no'    => ltrim($item['trackNo'], '@'),
                         'region'        => $item['receiverState'].' '.$item['receiverCity'],
                         'other_price'   => $other_price,
-                        'ship_date'     => substr($item['deliveryDate'], 0, 10),
+                        'ship_date'     => $item['deliveryDate'],
                         'incubator'   => $getPackSpecsFee['pack_specs_type'],
                         'insulation_money'   => $getPackSpecsFee['surcharge_money'],
                         'labor_cost_money'   => $getPackSpecsFee['data']['labor_cost_money']
@@ -174,7 +174,7 @@ class JuShuiTanService {
             'waybill_no'    => $item['waybill_no'],
             'region'        => $item['province'].' '.$item['city'],
             'other_price'   => $other_price,
-            'ship_date'     => substr($item['consign_time'], 0, 10),
+            'ship_date'     => $item['deliveryDate'],
             'incubator'   => $getPackSpecsFee['pack_specs_type'],
             'insulation_money'   => $getPackSpecsFee['surcharge_money'],
             'labor_cost_money'   => $getPackSpecsFee['data']['labor_cost_money']

+ 4 - 3
app/admin/view/shop/shop_delivery/index.html

@@ -75,12 +75,13 @@
                         return tag;
                     } },
                 {field: 'insulation_money', title: __('保温加收金额'),operate: false},
-                
-                {field: 'ship_date', title: __('录入时间'), width:80, operate:"date" },
+                {field: 'ship_date', title: __('发货时间'),operate: 'LIKE'},
+                {field: 'nickname', title: __('录入人'),operate: 'LIKE'},
+                {field: 'entry_time', title: __('录入时间'),operate: 'LIKE',formatter: Yunqi.formatter.datetime},
                 {field: 'settlement_data', title: __('结算时间'),width: 100,operate:'date'},
                 {field: 'status', title: __('结算状态'), operate: 'select', width:85,searchList: {1: __('待结算'),2: __('已结算')},formatter:Yunqi.formatter.tag},
                 {field: 'createtime', title: __('创建时间'), width:120,formatter: Yunqi.formatter.datetime,operate:false,sortable: true},
-                {field: 'user.nickname', title: __('录入人'),operate: false},
+                
             ],
             totalArr: [
                 

+ 47 - 12
app/api/controller/Worker.php

@@ -13,12 +13,14 @@ use app\api\validate\Worker as WorkerValidate;
 use think\facade\Cache;
 use think\facade\Db;
 use think\Response;
+use app\common\model\ShopDelivery as ShopDeliveryModel;
 
 /**
  * 打包工人相关接口
  */
 class Worker extends Base
 {
+    protected $shopDeliveryModel = null;
 
     /**
      * 判断权限
@@ -27,7 +29,8 @@ class Worker extends Base
     protected function _initialize()
     {
         parent::_initialize();
-        if(!str_contains($this->userinfo['role'], "4")){
+        $this->shopDeliveryModel = new ShopDeliveryModel();
+        if (!str_contains($this->userinfo['role'], "4")) {
             $this->error(__('没有权限' . $this->userinfo['role']));
         }
     }
@@ -51,16 +54,51 @@ class Worker extends Base
             validate(WorkerValidate::class)->scene('scan')->check($data);
 
             //$resData = $stockService::setGoOutStock($this->userinfo['id'], $data);
-
+            $time = time();
             $insert_data = [
-            'user_id'    => $this->userinfo['id'],
+                'user_id'    => $this->userinfo['id'],
                 'code'       => $data['code'],
                 'order_status' => 0,
                 'remark' => '未找到单号',
+                'order_data' => [],
+                'createtime'=>date('Y-m-d H:i:s',$time)
             ];
+            $sql_data = $this->shopDeliveryModel->where('waybill_no', $data['code'])->find();
+            if (!empty($sql_data)) {
+                
+                $result = $sql_data->save([
+                    'user_id'    =>   $this->userinfo['id'],
+                    'entry_time'    =>    $time,
+                    'updatetime' =>    $time
+                ]);
+                if ($result) {
+                    $insert_data['order_status'] = 1;
+                    $insert_data['remark'] = '录入成功';
+                } else {
+                    $insert_data['remark'] = '录入失败';
+                }
+                $entry_time=$sql_data['entry_time'];
+                if(!empty($sql_data['entry_time'])){
+                    $entry_time=date('Y-m-d H:i:s',$sql_data['entry_time']);
+                }
+                switch ($sql_data['incubator']) {
+                    case 1:
+                        $sql_data['incubator_title']='单层保温';
+                        break;
+                    case 2:
+                        $sql_data['incubator_title']='双层保温';
+                        break;
+                    default:
+                        $sql_data['incubator_title']='不是保温箱';
+                        break;
+                }
+                $sql_data['entry_time']=$entry_time;
+                $insert_data['order_data']=$sql_data;
+            }
             $result = $scanLog->save($insert_data);
+
             Db::commit();
-        }catch (ValidateException $e) {
+        } catch (ValidateException $e) {
             return $this->error($e->getError());
         } catch (\Exception $e) {
             Db::rollback();
@@ -78,10 +116,10 @@ class Worker extends Base
         $where = [];
         $limit = $this->request->post('limit/d', 10);  //条数
         $time = $this->request->post('create_time/s'); //日期
-        if(!empty($type))    $where[] = ['a.type', '=', $type];
-        if(!empty($type_id)) $where[] = ['a.type_id', '=',$type_id];
-        if(!empty($spec_id)) $where[] = ['a.variety_id', '=',$spec_id];
-        if(!empty($time)){
+        if (!empty($type))    $where[] = ['a.type', '=', $type];
+        if (!empty($type_id)) $where[] = ['a.type_id', '=', $type_id];
+        if (!empty($spec_id)) $where[] = ['a.variety_id', '=', $spec_id];
+        if (!empty($time)) {
             $arr = explode(',', $time);
             $where[] = ['a.createtime', '>=', strtotime($arr[0])];
             $where[] = ['a.createtime', '<=', strtotime($arr[1])];
@@ -92,7 +130,4 @@ class Worker extends Base
             ->paginate($limit);
         $this->success('ok', $list);
     }
-
-   
-   
-}
+}