MyOrder.php
26.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
<?php
namespace app\api\controller;
use app\admin\model\order\Log;
use app\admin\model\Third;
use app\api\model\Contract;
use app\api\model\Description;
use app\api\model\goods\GoodsSku;
use app\api\model\order\OrderItem;
use app\api\model\promoter\PromoterLast;
use addons\epay\library\Service;
use app\api\validate\OrderValidate;
use app\common\controller\Api;
use think\Db;
use think\Model;
/**
* 订单接口
*/
class MyOrder extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* 我的订单
* @ApiTitle (我的订单)
* @ApiParams (name="owner_name", type="int", description="车主姓名")
* @ApiParams (name="order_type", type="int", description="下单类型:self=自己下单,replace=待客户下单")
* @ApiParams (name="order_status", type="string", description="订单状态:all=全部,0=待支付,1=待审核,2=购买成功")
* @ApiReturnParams (name="id", type="string", description="订单id")
* @ApiReturnParams (name="title", type="string", description="商品标题")
* @ApiReturnParams (name="status", type="string", description="订单状态:-2=已驳回,-1=已取消,0=待支付,1=已支付(待审核),2=已完成,3=已退款")
* @ApiReturnParams (name="rejection_type", type="string", description="驳回类型:edit=驳回修改,refund=驳回退款")
* @ApiReturnParams (name="goods_sku_text", type="string", description="下单规格")
* @ApiReturnParams (name="pay_price", type="string", description="支付价格")
*/
public function order_list()
{
$owner_name = $this->request->param('owner_name');
$order_type = $this->request->param('order_type', 'self');
$order_status = $this->request->param('order_status', 'all');
$orderModel = new \app\api\model\order\Order();
$field = ['order.id,order.order_type,goods.title,status,rejection_type,goods_sku_text,pay_price'];
//如果当前登陆者是普通用户
if ($this->auth->is_promoter != 2) {
$where['order_type'] = ['=', $order_type];
//如果自己下单,下单人和支付人必然都是自己
$where['order.user_id|order.pay_user_id'] = $this->auth->id;
}else{
$where['order.user_id|order.pay_user_id'] = $this->auth->id;
}
if (!empty($owner_name)) {
$where['item.owner_name'] = ['like', '%' . $owner_name . '%'];
}
if ($order_status == 'all') {
if ($this->auth->is_promoter == 2) {
$where['status'] = ['<>', 0];
}
$list = $orderModel->alias('order')
->join('fa_order_item item', 'order.id = item.order_id', 'LEFT')
->join('fa_goods goods', 'order.goods_id = goods.id', 'LEFT')
->where($where)
->whereNull('delete_time')
->field($field)
->order('order.createtime', 'desc')
->paginate();
$this->success('全部订单', $list);
}
switch ($order_status) {
case 0: //待支付
$where['status'] = ['=', 0];
//普通用户没有待支付
if ($this->auth->is_promoter == 2) {
$this->success('全部订单',[]);
}
break;
case 1: //待审核
$where['status'] = ['=', 1];
break;
case 2: //购买成功
$where['status'] = ['=', 2];
break;
}
$list = $orderModel->alias('order')
->join('fa_order_item item', 'order.id = item.order_id', 'LEFT')
->join('fa_goods goods', 'order.goods_id = goods.id', 'LEFT')
->where($where)
->whereNull('delete_time')
->field($field)
->order('order.createtime', 'desc')
->paginate();
$this->success('全部订单', $list);
}
/**
* 订单详情
* @ApiTitle (订单详情)
* @ApiParams (name="order_id", type="int", description="订单id")
* @ApiReturnParams (name="goods_sku_id", type="int", description="规格ID")
* @ApiReturnParams (name="order_type", type="int", description="下单类型:self=自己下单,replace=待客户下单")
* @ApiReturnParams (name="invoice_image", type="int", description="购车发票")
* @ApiReturnParams (name="purchase_price", type="int", description="查购车价格")
* @ApiReturnParams (name="mileage_image", type="int", description="表显里程图")
* @ApiReturnParams (name="mileage", type="int", description="表显里程")
* @ApiReturnParams (name="driving_license_image", type="int", description="行驶证")
* @ApiReturnParams (name="vin", type="int", description="VIN码")
* @ApiReturnParams (name="plate_number", type="int", description="车牌号")
* @ApiReturnParams (name="brand", type="int", description="品牌型号")
* @ApiReturnParams (name="engine_number", type="int", description="发动机型号")
* @ApiReturnParams (name="register_time", type="int", description="注册日期")
* @ApiReturnParams (name="issue_time", type="int", description="发证日期")
* @ApiReturnParams (name="owner_name", type="int", description="车主姓名")
* @ApiReturnParams (name="mobile", type="int", description="联系电话")
* @ApiReturnParams (name="id_number", type="int", description="身份证号")
* @ApiReturnParams (name="id_number_image", type="int", description="身份证图片")
* @ApiReturnParams (name="exterior_images", type="int", description="车辆外观")
* @ApiReturnParams (name="promotion_code", type="int", description="推广码")
* @ApiReturnParams (name="order_sn", type="int", description="订单编号")
* @ApiReturnParams (name="status", type="int", description="订单状态:-2=已驳回,-1=已取消,0=待支付,1=已支付(待审核),2=已完成,3=已退款")
* @ApiReturnParams (name="rejection_type", type="int", description="驳回类型:edit=驳回修改,refund=驳回退款")
* @ApiReturnParams (name="goods_sku_text", type="int", description="产品规格")
* @ApiReturnParams (name="goods_price", type="int", description="产品价格")
* @ApiReturnParams (name="pay_price", type="int", description="支付价格")
* @ApiReturnParams (name="memo", type="int", description="商户备注")
* @ApiReturnParams (name="paytime", type="int", description="支付时间")
* @ApiReturnParams (name="createtime", type="int", description="订单创建时间")
* @ApiReturnParams (name="reject_time", type="int", description="驳回时间")
* @ApiReturnParams (name="adopt_time", type="int", description="审核通过时间")
* @ApiReturnParams (name="cancel_time", type="int", description="取消时间")
* @ApiReturnParams (name="refund_time", type="int", description="退款时间")
* @ApiReturnParams (name="apply_time", type="int", description="申请时间")
* @ApiReturnParams (name="edit_time", type="int", description="修改时间")
* @ApiReturnParams (name="refund_memo", type="int", description="订单创建时间")
*/
public function order_detail()
{
$order_id = $this->request->param('order_id');
if (empty($order_id)) {
$this->error('订单ID缺失');
}
$orderModel = new \app\api\model\order\Order();
$order_info = $orderModel->alias('order')
->field(['order.*', 'goods.title'])
->join('fa_goods goods', 'order.goods_id = goods.id', 'LEFT')
->where('order.id', $order_id)->find();
if (empty($order_info)) {
$this->error('您查找的订单不存在');
}
$order_info['item'] = OrderItem::where('order_id', $order_id)
->field('id,user_id,order_id,createtime', true)->find();
$this->success('订单详情', $order_info);
}
/**
* 取消订单
* @ApiTitle (取消订单)
* @ApiParams (name="order_id", type="int", description="订单id")
*/
public function cancel_order()
{
$order_id = $this->request->param('order_id');
if (empty($order_id)) {
$this->error('订单ID缺失');
}
$orderModel = new \app\api\model\order\Order();
$logModel = new Log();
$order_info = $orderModel->where('id', $order_id)->find();
if (empty($order_info)) {
$this->error('您要取消的订单不存在');
}
Db::startTrans();
$order_update = $orderModel->where('id', $order_id)->update(['cancel_time' => time(), 'status' => -1]);
//记录订单日志
$log = $logModel->save([
'order_id' => $order_id,
'remarks' => '用户取消订单',
'order_status' => '-1',
'updatetime' => time(),
]);
if (!$order_update || !$log) {
Db::rollback();
$this->error('取消失败,请重试');
}
Db::commit();
$this->success('已取消订单');
}
/**
* 驳回退款-申请退款
* @ApiTitle (驳回退款-申请退款)
* @ApiParams (name="order_id", type="int", description="订单id")
* @ApiParams (name="memo", type="int", description="退款理由")
*/
public function apply_refund()
{
$order_id = $this->request->param('order_id');
$memo = $this->request->param('memo');
if (empty($order_id)) {
$this->error('订单ID缺失');
}
if (empty($memo)) {
$this->error('请填写退款理由');
}
$orderModel = new \app\api\model\order\Order();
// $order_info = $orderModel->where( 'id', $order_id )->where( 'rejection_type', 'refund' )->find();
$order_info = $orderModel->where('id', $order_id)->find();
if (empty($order_info)) {
$this->error('您要申请退款的订单不存在');
}
Db::startTrans();
if ($order_info['status'] == 2){
$order_update = $orderModel->where('id', $order_id)->update(['apply_time' => time(), 'apply_refund' => 1,'refund_memo'=>$memo]);
//记录订单日志
$logModel = new Log();
$log = $logModel->save([
'order_id' => $order_id,
'remarks' => '用户申请退款',
'order_status' => '2',
'change_status' => '2',
'updatetime' => time(),
]);
if (!$order_update || !$log) {
Db::rollback();
$this->error('取消失败,请重试');
}
}else{
$order_update = $orderModel->where('id', $order_id)->update(['apply_time' => time(), 'apply_refund' => 1,'reject_refund_memo'=>$memo]);
//记录订单日志
$logModel = new Log();
$log = $logModel->save([
'order_id' => $order_id,
'remarks' => '用户申请退款',
'order_status' => '-2',
'change_status' => '-2',
'updatetime' => time(),
]);
if (!$order_update || !$log) {
Db::rollback();
$this->error('取消失败,请重试');
}
}
Db::commit();
$this->success('已申请');
}
/**
* 删除订单
* @ApiTitle (删除订单)
* @ApiParams (name="order_id", type="int", description="订单id")
*/
public function delete_order()
{
$order_id = $this->request->param('order_id');
if (empty($order_id)) {
$this->error('订单ID缺失');
}
$orderModel = new \app\api\model\order\Order();
$order_info = $orderModel->where('id', $order_id)->whereNull('delete_time')->find();
if (empty($order_info)) {
$this->error('您要删除的订单不存在');
}
Db::startTrans();
$order_update = $orderModel->where('id', $order_id)->update(['delete_time' => time()]);
//记录订单日志
$logModel = new Log();
$log = $logModel->save([
'order_id' => $order_id,
'remarks' => '用户删除订单',
'order_status' => $order_info['status'],
'updatetime' => time(),
]);
if (!$order_update || !$log) {
Db::rollback();
$this->error('删除失败,请重试');
}
Db::commit();
$this->success('已删除订单');
}
/**
* 查询订单
* @ApiTitle (查询订单)
* @ApiParams (name="vin", type="int", description="vin码")
* @ApiReturnParams (name="id", type="int", description="订单ID")
* @ApiReturnParams (name="plate_number", type="int", description="车牌号")
*/
public function search_order()
{
$vin = $this->request->param('vin');
$orderModel = new \app\api\model\order\Order();
//判断用户身份 推广员:1=是,2=否
$where['item.vin'] = ['=', $vin];
$where['order.status'] = ['<>', 3];
// if ( $this->auth->is_promoter == 2 ) {
// $where['order.pay_user_id'] = ['=', $this->auth->id];
// }
$order = $orderModel->alias('order')
->field(['order.id,order.order_sn', 'item.plate_number'])
->join('fa_order_item item', 'item.order_id = order.id', 'LEFT')
->where($where)
->whereNull('order.delete_time')
->paginate();
$this->success('查询订单列表', $order);
}
/**
* 查询订单详情
* @ApiTitle (查询订单详情)
* @ApiParams (name="order_id", type="int", description="订单ID")
*
* @ApiReturnParams (name="id", type="int", description="订单ID")
* @ApiReturnParams (name="vin", type="int", description="VIN码")
* @ApiReturnParams (name="sign_tip", type="string", description="签约提示")
* @ApiReturnParams (name="title", type="string", description="购买产品")
* @ApiReturnParams (name="purchase_price", type="int", description="购车价格")
* @ApiReturnParams (name="plate_number", type="int", description="车牌号")
* @ApiReturnParams (name="brand", type="int", description="品牌型号")
* @ApiReturnParams (name="engine_number", type="int", description="发动机型号")
* @ApiReturnParams (name="register_time", type="int", description="注册日期")
* @ApiReturnParams (name="issue_time", type="int", description="发证日期")
* @ApiReturnParams (name="mileage", type="int", description="表显里程")
*
* @ApiReturnParams (name="exterior_images", type="int", description="车辆外观")
* @ApiReturnParams (name="owner_name", type="int", description="车主姓名")
* @ApiReturnParams (name="mobile", type="int", description="联系电话")
* @ApiReturnParams (name="id_number", type="int", description="身份证号")
* @ApiReturnParams (name="id_number", type="int", description="身份证号")
*
* @ApiReturnParams (name="expire_time", type="int", description="服务到期日期:起始日期+服务期限")
* @ApiReturnParams (name="service_period", type="int", description="服务期限")
* @ApiReturnParams (name="service_mileage", type="int", description="服务里程 数据库万公里,显示*10000")
* @ApiReturnParams (name="expire_mileage", type="int", description="服务到期里程:表显里程+服务里程")
* @ApiReturnParams (name="service_claims", type="int", description="服务理赔限额:服务期限*3万元")
* @ApiReturnParams (name="contract_description", type="int", description="协议说明")
* @ApiReturnParams (name="agreement_cycle", type="int", description="本协议的生效和终止")
* @ApiReturnParams (name="contract", type="int", description="附件")
*/
public function search_order_detail()
{
$order_id = $this->request->param('order_id');
$orderModel = new \app\api\model\order\Order();
//判断用户身份 推广员:1=是,2=否
$where['order.id'] = ['=', $order_id];
// $where['order.status'] = ['=', '2'];
$order = $orderModel->alias('order')
->join('fa_order_item item', 'item.order_id = order.id', 'LEFT')
->where($where)
->whereNull('order.delete_time')
->find();
if (empty($order)) {
$this->error('您查找的订单不存在');
}
//购买产品title
$order['title'] = Db::name('goods')->where('id', $order['goods_id'])->value('title');
//签约提示
$order['sign_tip'] = config('site.sign_tip');
//车辆外观
$order['exterior_images'] = explode(',', $order['exterior_images']);
//购车价格
$order['purchase_price'] = self::format_money($order['purchase_price']);
//服务到期日期:起始日期+服务期限
$order['expire_time'] = date('Y-m-d H:i:s', strtotime("+{$order['service_period']}years", $order['paytime']));
//服务期限
$order['service_period'] = $order['service_period'] . '年期';
//服务起始日期 支付成功时间
//服务里程 数据库万公里,显示*10000
$order['service_mileage'] = $order['service_mileage'] * 10000;
//服务到期里程:表显里程+服务里程
$order['expire_mileage'] = $order['service_mileage'] + $order['mileage'];
//服务理赔限额:服务期限*3万元
$order['service_claims'] = $order['service_claims'] * 10000;
//协议说明
$order['contract_description'] = set_img_style(config('site.contract_description'));
//本协议的生效和终止
$order['agreement_cycle'] = set_img_style(config('site.agreement_cycle'));
//附件
$order['contract'] = Contract::WhereIn('id', explode(',', $order['contract_ids']))->field('id,title')->select();
//注册时间
$order['register_time'] = datetime($order['register_time']);
//发证时间
$order['issue_time'] = datetime($order['issue_time']);
$this->success('查询订单列表', $order);
}
/**
* 附件详情
* @ApiTitle (附件详情)
* @ApiParams (name="id", type="int", description="附件ID")
* @ApiReturnParams (name="title", type="int", description="标题")
* @ApiReturnParams (name="content", type="int", description="内容")
*/
public function contract_detail()
{
$id = $this->request->param('id');
if (empty($id) || $id == 0) {
$this->error('参数缺失');
}
$res = Contract::get(['id' => $id]);
$this->success('附件内容', $res);
}
/**
* 修改订单
* @ApiTitle (修改订单)
* @ApiParams (name="goods_id", type="int", description="商品id")
* @ApiParams (name="order_id", type="int", description="订单ID")
* @ApiParams (name="goods_sku_id", type="int", description="规格ID")
* @ApiParams (name="order_type", type="int", description="下单类型:self=自己下单,replace=待客户下单")
* @ApiParams (name="invoice_image", type="int", description="购车发票")
* @ApiParams (name="purchase_price", type="int", description="查购车价格")
* @ApiParams (name="mileage_image", type="int", description="表显里程图")
* @ApiParams (name="mileage", type="int", description="表显里程")
* @ApiParams (name="driving_license_image", type="int", description="行驶证")
* @ApiParams (name="vin", type="int", description="VIN码")
* @ApiParams (name="plate_number", type="int", description="车牌号")
* @ApiParams (name="brand", type="int", description="品牌型号")
* @ApiParams (name="engine_number", type="int", description="发动机型号")
* @ApiParams (name="register_time", type="int", description="注册日期")
* @ApiParams (name="issue_time", type="int", description="发证日期")
* @ApiParams (name="owner_name", type="int", description="车主姓名")
* @ApiParams (name="mobile", type="int", description="联系电话")
* @ApiParams (name="id_number", type="int", description="身份证号")
* @ApiParams (name="id_number_image", type="int", description="身份证图片")
* @ApiParams (name="exterior_images", type="int", description="车辆外观")
* @ApiParams (name="promotion_code", type="int", description="推广码")
* @ApiReturnParams (name="order_id", type="string", description="订单id")
*/
public function edit_order()
{
$validate = new OrderValidate();
if (!$validate->scene('edit_order')->check($this->param)) {
$this->error($validate->getError());
}
$order_info = \db('order')->where('id', $this->param['order_id'])->find();
if (empty($order_info)) {
$this->error('你要修改的订单不存在');
}
//查找商品
$goodsModel = new \app\api\model\goods\Goods();
$goods_info = $goodsModel->field('service_type,cart_type,contract_ids,service_claims,service_period,service_mileage')
->where(['id' => $this->param['goods_id'], 'goods_status' => '10'])->find();
if (empty($goods_info)) {
$this->error('您所购买的商品不存在或已下架');
}
//查找商品规格
$skuModel = new GoodsSku();
$goods_sku = $skuModel->where('id', $this->param['goods_sku_id'])->find();
if (empty($goods_sku)) {
$this->error('您所选的规格不存在');
}
//判断购车价格是否在规格区间
$purchase_price = $this->param['purchase_price'];
if ($purchase_price < $goods_sku['minimum'] * 10000 || $purchase_price > $goods_sku['max'] * 10000) {
$this->error('您的购车金额不在所选服务区间内');
}
$promotion_code = $this->param['promotion_code'];
//判断推荐码
if ( !empty( $promotion_code ) ) {
$user = \app\api\model\User::get( ['promotion_no' => $promotion_code] );
if ( !$user ) {
$this->error( '您所填写的推广码不存在' );
}
//判断自己身份为推广员 填写了自己的推广码时 绑定自己的身份
if ($user['id'] == $this->auth->id){
$this->error( '不能绑定自己!' );
}
//判断当前用户有没有上级,没有则绑定关系
if ( empty( $this->auth->up_user_id ) && $this->auth->up_user_id == 0 ) {
Db::startTrans();
try {
//绑定上下级
$promoterModel = new PromoterLast();
$promoterModel->save( [
'user_id' => $user['id'],
'last_user_id' => $this->auth->id,
'binding_time' => time(),
] );
\app\api\model\User::where( 'id', $this->auth->id )->update( [
'up_user_id' => $user['id'],
'binding_time' => time(),
] );
Db::commit();
} catch ( \Exception $e ) {
Db::rollBack();
$this->error( $e->getMessage() );
}
}
}
if (count($this->param['exterior_images']) != 2) {
$this->error('车辆外观照片需两张');
}
//开启事务
Db::startTrans();
//开始下单
$order_data = [
'user_id' => $this->auth->id,
'order_type' => $this->param['order_type'],
// 'order_sn' => getOrderNo($this->auth->id),
'status' => '1',
'rejection_type' => '',
'memo' => '',
'edit_time' => time(),
'goods_id' => $this->param['goods_id'],
'goods_sku_id' => $this->param['goods_sku_id'],
'goods_sku_text' => $goods_sku['level'] . $goods_sku['minimum'] . '-' . $goods_sku['max'] . '万元',
'goods_price' => $goods_sku['price'],
'pay_price' => $goods_sku['price'],
'service_type' => $goods_info['service_type'],
'cart_type' => $goods_info['cart_type'],
'contract_ids' => $goods_info['contract_ids'],
'service_claims' => $goods_info['service_claims'],
'service_period' => $goods_info['service_period'],
'service_mileage' => $goods_info['service_mileage'],
];
$orderModel = new \app\api\model\order\Order();
$order_return = $orderModel->save($order_data, ['id' => $this->param['order_id']]);
//获取ID
$order_id = $this->param['order_id'];
//记录订单表单信息
$item_data = [
'user_id' => $this->auth->id,
'order_id' => $order_id,
'invoice_image' => implode(',', $this->param['invoice_image']),
'purchase_price' => $this->param['purchase_price'],
'mileage_image' => implode(',', $this->param['mileage_image']),
'mileage' => $this->param['mileage'],
'driving_license_image' => implode(',', $this->param['driving_license_image']),
'vin' => $this->param['vin'],
'plate_number' => $this->param['plate_number'],
'brand' => $this->param['brand'],
'engine_number' => $this->param['engine_number'],
'register_time' => strtotime($this->param['register_time']),
'issue_time' => strtotime($this->param['issue_time']),
'owner_name' => $this->param['owner_name'],
'mobile' => $this->param['mobile'],
'id_number' => $this->param['id_number'],
'id_number_image' => implode(',', $this->param['id_number_image']),
'exterior_images' => implode(',', $this->param['exterior_images']),
];
$itemModel = new OrderItem();
$item_return = $itemModel->save($item_data, ['order_id' => $order_id]);
$logModel = new Log();
//记录订单日志
$log = $logModel->save([
'order_id' => $order_id,
'remarks' => '用户修改订单',
'order_status' => '-2',
'change_status' => '1',
'updatetime' => time(),
]);
Db::commit();
if (!$order_return || !$item_return || !$log) {
Db::rollBack();
$this->error('修改失败');
}
$this->success('修改成功', ['id' => $order_id]);
}
/**
*购车价格格式化
*/
private function format_money($price)
{
if ($price < 10000) {
return $price;
} else {
return round($price / 10000, 2) . '万';
}
}
}