|
@@ -3,7 +3,9 @@
|
|
|
namespace app\admin\service\order;
|
|
|
|
|
|
use app\model\Appointment;
|
|
|
+use app\model\Goods;
|
|
|
use app\model\MemberBenefit;
|
|
|
+use app\model\SysSerial;
|
|
|
use support\Db;
|
|
|
use support\Request;
|
|
|
use function _PHPStan_cc8d35ffb\RingCentral\Psr7\str;
|
|
@@ -33,11 +35,11 @@ class AppointmentService
|
|
|
});
|
|
|
|
|
|
$total = $rows->count('member.member_id');
|
|
|
- $rows = $rows->select( 'appointment.*',
|
|
|
+ $rows = $rows->select('appointment.*',
|
|
|
'member.member_mobile',
|
|
|
'member_cert.member_cert_name',
|
|
|
'member_info.member_info_nickname',
|
|
|
- 'goods.goods_name', 'goods.goods_cover','goods.goods_sales_price',
|
|
|
+ 'goods.goods_name', 'goods.goods_cover', 'goods.goods_sales_price',
|
|
|
'order.order_name', 'goods_sku.goods_sku_specs_json', 'order.order_amount_total', 'order.order_amount_pay',
|
|
|
'order.order_category', 'order.order_status_system', 'order.order_status_payment', 'order.order_status_storage',
|
|
|
'order.order_addtimes',
|
|
@@ -52,6 +54,9 @@ class AppointmentService
|
|
|
$row->goods_sku_specs_json = !empty($row->goods_sku_specs_json) ? json_decode($row->goods_sku_specs_json, true) : [];
|
|
|
$row->order_addtimes = date('Y-m-d H:i:s', $row->order_addtimes);
|
|
|
$row->appointment_addtimes = date('Y-m-d H:i:s', $row->appointment_addtimes);
|
|
|
+ if ($row->appointment_category == 'NOFEE') {
|
|
|
+ $row->member_benefit_name = "后付费预约";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return json_success('', compact('rows', 'page', 'pageSize', 'total'));
|
|
@@ -75,6 +80,38 @@ class AppointmentService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function add(Request $request)
|
|
|
+ {
|
|
|
+ $params = $request->post();
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $data = [
|
|
|
+ 'appointment_id' => "AP" . str_pad(SysSerial::getSerial(), 16, '0') . random_string(6,'up'),
|
|
|
+ 'join_appointment_member_id' => $params['join_appointment_member_id'] ?? '',
|
|
|
+ 'join_appointment_goods_id' => $params['join_appointment_goods_id'] ?? '',
|
|
|
+ 'appointment_status' => $params['appointment_status'] ?? '',
|
|
|
+ 'appointment_datetime' => isset($params['appointment_datetime']) ? date('Y-m-d H:i:s', strtotime($params['appointment_datetime'])) : '',
|
|
|
+ 'appointment_apply_datetime' => isset($params['appointment_apply_datetime']) ? date('Y-m-d H:i:s', strtotime($params['appointment_apply_datetime'])) : '',
|
|
|
+ 'appointment_doing_datetime' => isset($params['appointment_doing_datetime']) ? date('Y-m-d H:i:s', strtotime($params['appointment_doing_datetime'])) : '',
|
|
|
+ 'appointment_done_datetime' => isset($params['appointment_done_datetime']) ? date('Y-m-d H:i:s', strtotime($params['appointment_done_datetime'])) : '',
|
|
|
+ 'appointment_cancel_datetime' => isset($params['appointment_cancel_datetime']) ? date('Y-m-d H:i:s', strtotime($params['appointment_cancel_datetime'])) : '',
|
|
|
+ 'appointment_remark' => $params['appointment_remark'] ?? '',
|
|
|
+ 'appointment_category' => 'NOFEE',
|
|
|
+ 'appointment_addtimes' => time(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ Appointment::insert($data);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ return json_success("添加预约成功");
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollBack();
|
|
|
+ dump($e->getMessage());
|
|
|
+ return json_fail("添加预约失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static function update(Request $request)
|
|
|
{
|
|
|
$appointmentId = $request->post('appointment_id');
|
|
@@ -86,24 +123,24 @@ class AppointmentService
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
$data = [
|
|
|
- 'appointment_status'=>$params['appointment_status'],
|
|
|
- 'appointment_datetime'=>$params['appointment_datetime'] ? date('Y-m-d H:i:s',strtotime($params['appointment_datetime'])) : null,
|
|
|
- 'appointment_apply_datetime'=>$params['appointment_apply_datetime'] ? date('Y-m-d H:i:s',strtotime($params['appointment_apply_datetime'])) : null,
|
|
|
- 'appointment_doing_datetime'=>$params['appointment_doing_datetime'] ? date('Y-m-d H:i:s',strtotime($params['appointment_doing_datetime'])) : null,
|
|
|
- 'appointment_done_datetime'=>$params['appointment_done_datetime'] ? date('Y-m-d H:i:s',strtotime($params['appointment_done_datetime'])) : null,
|
|
|
- 'appointment_cancel_datetime'=>$params['appointment_cancel_datetime'] ? date('Y-m-d H:i:s',strtotime($params['appointment_cancel_datetime'])) : null,
|
|
|
- 'appointment_remark'=>$params['appointment_remark'] ?? '',
|
|
|
+ 'appointment_status' => $params['appointment_status'],
|
|
|
+ 'appointment_datetime' => $params['appointment_datetime'] ? date('Y-m-d H:i:s', strtotime($params['appointment_datetime'])) : null,
|
|
|
+ 'appointment_apply_datetime' => $params['appointment_apply_datetime'] ? date('Y-m-d H:i:s', strtotime($params['appointment_apply_datetime'])) : null,
|
|
|
+ 'appointment_doing_datetime' => $params['appointment_doing_datetime'] ? date('Y-m-d H:i:s', strtotime($params['appointment_doing_datetime'])) : null,
|
|
|
+ 'appointment_done_datetime' => $params['appointment_done_datetime'] ? date('Y-m-d H:i:s', strtotime($params['appointment_done_datetime'])) : null,
|
|
|
+ 'appointment_cancel_datetime' => $params['appointment_cancel_datetime'] ? date('Y-m-d H:i:s', strtotime($params['appointment_cancel_datetime'])) : null,
|
|
|
+ 'appointment_remark' => $params['appointment_remark'] ?? '',
|
|
|
];
|
|
|
|
|
|
Appointment::where('appointment_id', $appointmentId)->update($data);
|
|
|
// 如果是完成状态
|
|
|
- if ($params['appointment_status'] == 'DONE' && $appointment->appointment_status != 'DONE'){
|
|
|
- MemberBenefit::where('member_benefit_id',$appointment->join_appointment_member_benefit_id)->increment('member_benefit_used_count');
|
|
|
+ if ($params['appointment_status'] == 'DONE' && $appointment->appointment_status != 'DONE') {
|
|
|
+ MemberBenefit::where('member_benefit_id', $appointment->join_appointment_member_benefit_id)->increment('member_benefit_used_count');
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
|
return json_success("数据更新成功");
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
dump($e->getMessage());
|
|
|
return json_fail("数据更新失败");
|