李浩杰 4 years ago
parent
commit
b9097ee708

+ 1 - 1
app/Http/Controllers/Admin/TestController.php

xqd
@@ -20,7 +20,7 @@ class TestController extends Controller
 {
     public function index(Request $request)
     {
-        dd(Order::where('type', 1)->groupBy('project_id')->selectRaw('sum(money) as sum, project_id')->pluck('sum', 'project_id'));
+        dd(User::find(1)->projects);
 //    	return view('admin.test.index');
     }
 }

+ 6 - 1
app/Models/Order.php

xqd
@@ -170,16 +170,21 @@ class Order extends BaseModel
             }
             $this->update(['money' => $total]);
         } else {
+            $using_id = Option::get('inner_devices', 'status', 'using');
             foreach($devices as $device) {
                 OrderDevice::create([
                     'name' => $device['name'],
                     'order_id' => $this['id'],
-                    'device_id' => $device['id'],
+                    'project_id' => $this['project_id'],
+                    'user_id' => $this['user_id'],
+                    'inner_device_id' => $device['id'],
                     'start_date' => $device['start_date'],
                     'end_date' => $device['end_date']
                 ]);
                 if($device['id']) {
                     InnerDevice::find($device['id'])->update([
+                        'project_id' => $this['project_id'],
+                        'status' => $using_id,
                         'start_date' => $device['start_date'],
                         'end_date' => $device['end_date'],
                         'work_point_id' => $this['work_point_id']

+ 1 - 1
mini/pages/create-order/index.wxml

xqd
@@ -36,7 +36,7 @@
     </view>
   </view>
   <van-calendar show="{{ showDate }}" bind:close="switchShowDate" bind:confirm="confirmDate" data-show="{{false}}"
-    type="range" class="sg-calendar" default-date="{{default_dates}}" />
+    type="range" class="sg-calendar" default-date="{{default_dates}}" allow-same-day="{{true}}"/>
   <view class="sg-device-box" wx:if="{{tabIndex == 1}}">
     <view class="sg-device-list sg-top-border">
       <block wx:if="{{devices.length <= 0}}">