|
@@ -67,7 +67,7 @@ class OrderService extends BaseService
|
|
|
*/
|
|
|
public function getDataList($params, $pageSize = 15)
|
|
|
{
|
|
|
- $where = ['a.mark' => 1];
|
|
|
+ $where = ['a.mark' => 1,'a.is_hide'=>0];
|
|
|
$merchId = isset($params['merch_id']) ? $params['merch_id'] : 0;
|
|
|
if ($merchId > 0) {
|
|
|
$where['a.merch_id'] = $merchId;
|
|
@@ -127,6 +127,7 @@ class OrderService extends BaseService
|
|
|
$item['status_text'] = isset($statusArr[$status])? $statusArr[$status] : '';
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$refundStatus = isset($item['refund_status'])? $item['refund_status'] : 0;
|
|
|
if($refundStatus && $status != 4){
|
|
|
$item['refund_status_text'] = isset($refundStatusArr[$refundStatus])? $refundStatusArr[$refundStatus] : '';
|
|
@@ -946,7 +947,6 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 详情
|
|
|
* @param $id
|
|
@@ -993,6 +993,11 @@ class OrderService extends BaseService
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
|
+ public function pay($userId, $params)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 申请退款
|
|
|
* @param $userId
|
|
@@ -1051,34 +1056,34 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 检查
|
|
|
- foreach ($orderGoods as $item){
|
|
|
- if($item['status'] == 0){
|
|
|
- $this->error = 2919;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 站外申请售后
|
|
|
- foreach ($orderGoods as $item){
|
|
|
- $data = [
|
|
|
- 'goods_sku'=> $item['goods_sku'],
|
|
|
- 'after_type'=> $refundType,
|
|
|
- 'after_num'=> $item['after_num'],
|
|
|
- 'explain'=> $refundRemark,
|
|
|
- 'order_goods_id'=> $refundRemark,
|
|
|
- ];
|
|
|
- $result = SupplyService::make()->getApiData('applyAfter',$data);
|
|
|
- if($item['status'] == 0){
|
|
|
- $this->error = 2919;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 处理
|
|
|
- if(!$this->model->where(['id'=> $id,'mark'=>1])->update(['status'=> 5,'refund_status'=>1,'refund_type'=> $refundType,'refund_remark'=> $refundRemark,'refund_result'=>'','update_time'=>time()])){
|
|
|
- $this->error = 2917;
|
|
|
- return false;
|
|
|
- }
|
|
|
+// foreach ($orderGoods as $item){
|
|
|
+// if($item['status'] == 0){
|
|
|
+// $this->error = 2919;
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 站外申请售后
|
|
|
+// foreach ($orderGoods as $item){
|
|
|
+// $data = [
|
|
|
+// 'goods_sku'=> $item['goods_sku'],
|
|
|
+// 'after_type'=> $refundType,
|
|
|
+// 'after_num'=> $item['after_num'],
|
|
|
+// 'explain'=> $refundRemark,
|
|
|
+// 'order_goods_id'=> $refundRemark,
|
|
|
+// ];
|
|
|
+// $result = SupplyService::make()->getApiData('applyAfter',$data);
|
|
|
+// if($item['status'] == 0){
|
|
|
+// $this->error = 2919;
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 处理
|
|
|
+// if(!$this->model->where(['id'=> $id,'mark'=>1])->update(['status'=> 5,'refund_status'=>1,'refund_type'=> $refundType,'refund_remark'=> $refundRemark,'refund_result'=>'','update_time'=>time()])){
|
|
|
+// $this->error = 2917;
|
|
|
+// return false;
|
|
|
+// }
|
|
|
|
|
|
$this->error = 2916;
|
|
|
return true;
|
|
@@ -1096,18 +1101,21 @@ class OrderService extends BaseService
|
|
|
$merchId = isset($params['merch_id']) ? $params['merch_id'] : 0; // 商家
|
|
|
$mechId = isset($params['mech_id']) ? $params['mech_id'] : 0; //技师
|
|
|
$info = $this->model->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id','user_id','merch_id','source_id','pay_money','reception_at','coupon_id','status','refund_status','pay_time'])
|
|
|
+ ->select(['id','user_id','merch_id','pay_money','coupon_id','status','refund_status','refund_temp_status','pay_time'])
|
|
|
->first();
|
|
|
$status = isset($info['status']) ? $info['status'] : 0;
|
|
|
$orderUserId = isset($info['user_id']) ? $info['user_id'] : 0;
|
|
|
$orderMerchId = isset($info['merch_id']) ? $info['merch_id'] : 0;
|
|
|
$orderMechId = isset($info['source_id']) ? $info['source_id'] : 0;
|
|
|
$refundStatus = isset($info['refund_status']) ? $info['refund_status'] : 0;
|
|
|
+ $tempStatus = isset($info['refund_temp_status']) ? $info['refund_temp_status'] : 0;
|
|
|
if (!$id || empty($info)) {
|
|
|
$this->error = 2656;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ var_dump($info);
|
|
|
+ return false;
|
|
|
// 非法操作
|
|
|
if($merchId != $orderMerchId && $userId != $orderUserId && $mechId != $orderMechId){
|
|
|
$this->error = 2667;
|
|
@@ -1136,403 +1144,6 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 申请退款审核
|
|
|
- * @param $userId
|
|
|
- * @param $params
|
|
|
- * @return bool
|
|
|
- * @throws \Yansongda\Pay\Exception\ContainerException
|
|
|
- * @throws \Yansongda\Pay\Exception\InvalidParamsException
|
|
|
- * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
|
|
|
- */
|
|
|
- public function refundConfirm($userId, $params)
|
|
|
- {
|
|
|
- $id = isset($params['id']) ? $params['id'] : 0;
|
|
|
- $checkStatus = isset($params['status']) ? $params['status'] : 0;
|
|
|
- $remark = isset($params['remark']) ? $params['remark'] : '';
|
|
|
- $merchId = isset($params['merch_id']) ? $params['merch_id'] : 0; // 商家
|
|
|
- $info = $this->model->with(['goods'])
|
|
|
- ->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id','user_id','order_no','merch_id','source_id','type','coupon_id','pay_money','order_no','pay_type','appoint_time','reception_at','coupon_id','status','refund_status','pay_time'])
|
|
|
- ->first();
|
|
|
- $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
- $orderMerchId = isset($info['merch_id']) ? $info['merch_id'] : 0;
|
|
|
- $couponId = isset($info['coupon_id']) ? $info['coupon_id'] : 0;
|
|
|
- $orderType = isset($info['type']) ? $info['type'] : 0;
|
|
|
- $payType = isset($info['pay_type']) ? $info['pay_type'] : 0;
|
|
|
- $goods = isset($info['goods']) ? $info['goods'] : [];
|
|
|
- $refundStatus = isset($info['refund_status']) ? $info['refund_status'] : 0;
|
|
|
- $appointTime = isset($info['appoint_time']) ? $info['appoint_time'] : '';
|
|
|
- if (!$id || empty($info)) {
|
|
|
- $this->error = 2656;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 非法操作
|
|
|
- if($merchId != $orderMerchId){
|
|
|
- $this->error = 2667;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if($status != 5){
|
|
|
- $this->error = 2668;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if($refundStatus<=0){
|
|
|
- $this->error = 2669;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if(!in_array($checkStatus, [2,3])){
|
|
|
- $this->error = 2639;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 支付信息
|
|
|
- $orderNo = isset($info['order_no'])? $info['order_no'] : '';
|
|
|
- $paymentInfo = PaymentModel::where(['order_no'=> $orderNo,'status'=>1,'mark'=>1])->first();
|
|
|
- $totalFee = isset($paymentInfo['total_fee'])? $paymentInfo['total_fee'] : 0;
|
|
|
- if($checkStatus == 2 && (empty($paymentInfo) || $totalFee<=0)){
|
|
|
- $this->error = 2637;
|
|
|
- return false;
|
|
|
- }
|
|
|
- $order = [
|
|
|
- 'total_fee' => $totalFee,
|
|
|
- 'type' => isset($info['type'])? $info['type'] : 2,
|
|
|
- 'pay_type' => isset($info['pay_type'])? $info['pay_type'] : 0,
|
|
|
- 'out_trade_no' => isset($paymentInfo['out_trade_no'])? $paymentInfo['out_trade_no'] : '',
|
|
|
- 'transaction_id' => isset($paymentInfo['transaction_id'])? $paymentInfo['transaction_id'] : '',
|
|
|
- 'order_no' => $orderNo
|
|
|
- ];
|
|
|
-
|
|
|
- // 退款打款请求
|
|
|
- DB::beginTransaction();
|
|
|
- // 审核成功,打款
|
|
|
- $refundAmount = $totalFee;
|
|
|
- if($checkStatus == 2){
|
|
|
- // 超时扣费
|
|
|
- $deductRate = ConfigService::make()->getConfigByCode('refund_deduct_rate');
|
|
|
- $deductRate = $deductRate>0? $deductRate : 0;
|
|
|
- // 扣除给平台
|
|
|
- if($deductRate && $orderType == 2 && $appointTime && $appointTime<= date('m-d H:i')){
|
|
|
- $deductMoney = moneyFormat($refundAmount * $deductRate/100, 2);
|
|
|
- if($deductMoney>0){
|
|
|
- // 平台入账,财务统计
|
|
|
- $log = [
|
|
|
- 'user_id'=> 0,
|
|
|
- 'merch_id'=> 0,
|
|
|
- 'source_uid'=> $info['user_id'],
|
|
|
- 'source_order_no'=> $info['order_no'],
|
|
|
- 'type'=> 13,
|
|
|
- 'coin_type'=> 2,
|
|
|
- 'user_type'=> 5,
|
|
|
- 'money'=> $deductMoney,
|
|
|
- 'balance'=> 0,
|
|
|
- 'create_time'=> time(),
|
|
|
- 'update_time'=> time(),
|
|
|
- 'remark'=> '平台订单退款收入',
|
|
|
- 'status'=>1,
|
|
|
- 'mark'=>1
|
|
|
- ];
|
|
|
- if(!AccountLogModel::insertGetId($log)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2641;
|
|
|
- return false;
|
|
|
- }
|
|
|
- FinanceService::make()->saveLog(0, $deductMoney, 1, 4);
|
|
|
- $refundAmount = moneyFormat($refundAmount - $deductMoney, 2);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!PaymentService::make()->refund($order, $payType,'', $refundAmount)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = PaymentService::make()->getError();
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 处理
|
|
|
- $updateData = ['status'=> 5,'refund_status'=> $checkStatus,'refund_result'=> $remark?$remark : ($checkStatus==2? '商家审核退款成功' : '退款审核失败'),'update_time'=>time()];
|
|
|
- if(!$this->model->where(['id'=> $id,'mark'=>1])->update($updateData)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2676;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 退还优惠券
|
|
|
- if($checkStatus == 2 && $couponId){
|
|
|
- if(!MemberCouponModel::where(['id'=> $couponId,'mark'=>1])->update(['status'=> 1,'update_time'=>time()])){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2643;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 若退款成功,商品库存返还
|
|
|
- if($goods && $checkStatus == 2 && in_array($orderType, [1,6])){
|
|
|
- foreach($goods as $item){
|
|
|
- $goodsId = isset($item['goods_id'])? $item['goods_id'] : 0;
|
|
|
- $goodsNum = isset($item['num'])? $item['num'] : 0;
|
|
|
- if($goodsId && $goodsNum && !GoodsModel::where(['id'=> $goodsId])->increment('stock', $goodsNum)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2680;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $params = [
|
|
|
- 'title' => "订单退款审核通知",
|
|
|
- 'body' => "您申请退款的订单已经审核,请即时查看进度",
|
|
|
- 'type' => 2, // 1-公告通知,2-订单通知,3-交易通知,4-其他
|
|
|
- 'content' => [
|
|
|
- 'order_no' => ['name' => '订单号', 'text' => $info['order_no']],
|
|
|
- 'pay_time' => ['name' => '审核时间', 'text' => $info['pay_time']],
|
|
|
- 'money' => ['name' => '订单金额', 'text' => $info['pay_money']],
|
|
|
- 'refund_money' => ['name' => '退款金额', 'text' => $refundAmount],
|
|
|
- 'status' => ['name' => '状态', 'text' => $checkStatus==2? '已退款':'退款失败'],
|
|
|
- ],
|
|
|
- 'click_type' => 'payload',
|
|
|
- 'url' => '/pages/order/detail?id=' . $info['id'],
|
|
|
- ];
|
|
|
- if(!PushService::make()->pushMessageByUser($info['user_id'], $params, 0)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = PushService::make()->getError();
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- $this->error = 2677;
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发货
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function delivery()
|
|
|
- {
|
|
|
- try {
|
|
|
- $params = request()->all();
|
|
|
- $id = isset($params['id']) ? $params['id'] : 0;
|
|
|
- $merchId = isset($params['merch_id']) ? intval($params['merch_id']) : 0;
|
|
|
- $express = isset($params['express_company']) ? $params['express_company'] : '';
|
|
|
- $expressCode = isset($params['express_code']) ? $params['express_code'] : '';
|
|
|
- $expressNo = isset($params['express_no']) ? $params['express_no'] : '';
|
|
|
- $info = $this->model->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id', 'user_id', 'order_no', 'merch_id', 'source_id', 'pay_money', 'reception_at', 'coupon_id', 'status', 'refund_status', 'pay_time'])
|
|
|
- ->first();
|
|
|
- $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
- $orderMerchId = isset($info['merch_id']) ? $info['merch_id'] : 0;
|
|
|
- if (!$id || empty($info)) {
|
|
|
- $this->error = 2636;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-// if ($merchId != $orderMerchId) {
|
|
|
-// $this->error = 2667;
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-
|
|
|
- if ($status != 2) {
|
|
|
- $this->error = 2668;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::beginTransaction();
|
|
|
- if ($this->model->where(['id' => $id])->update(['status' => 3, 'express_code' => $expressCode, 'express_company' => $express, 'express_no' => $expressNo, 'update_time' => time()])) {
|
|
|
-
|
|
|
- $params = [
|
|
|
- 'title' => "订单发货配送通知",
|
|
|
- 'body' => "您的订单商家已配送,请即时查看订单进度",
|
|
|
- 'type' => 2, // 1-公告通知,2-订单通知,3-交易通知,4-其他
|
|
|
- 'content' => [
|
|
|
- 'order_no' => ['name' => '订单号', 'text' => $info['order_no']],
|
|
|
- 'time' => ['name' => '下单时间', 'text' => $info['pay_time']],
|
|
|
- 'delivery_time' => ['name' => '配送时间', 'text' => date('Y-m-d H:i:s')],
|
|
|
- 'money' => ['name' => '订单金额', 'text' => $info['pay_money']],
|
|
|
- 'status' => ['name' => '状态', 'text' => '待收货'],
|
|
|
- ],
|
|
|
- 'click_type' => 'payload',
|
|
|
- 'url' => '/pages/order/detail?id=' . $id,
|
|
|
- ];
|
|
|
-
|
|
|
- if(!PushService::make()->pushMessageByUser($info['user_id'], $params, 0)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = PushService::make()->getError();
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- $this->error = 2673;
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2672;
|
|
|
- return false;
|
|
|
- }
|
|
|
- } catch (\Exception $exception){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = $exception->getMessage();
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 接单
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function picker()
|
|
|
- {
|
|
|
- $params = request()->all();
|
|
|
- $id = isset($params['id']) ? $params['id'] : 0;
|
|
|
- $mechId = isset($params['mech_id']) ? intval($params['mech_id']) : 0;
|
|
|
- $merchId = isset($params['merch_id']) ? intval($params['merch_id']) : 0;
|
|
|
- $info = $this->model->with(['mechanic','merchant'])
|
|
|
- ->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id','user_id','order_no','merch_id','source_id','pay_money','reception_at','coupon_id','status','refund_status','pay_time','appoint_time'])
|
|
|
- ->first();
|
|
|
- $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
- $merchant = isset($info['merchant']) ? $info['merchant'] : [];
|
|
|
- $merchType = isset($merchant['type']) ? $merchant['type'] : 1;
|
|
|
- if (!$id || empty($info)) {
|
|
|
- $this->error = 2636;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if ($status != 2) {
|
|
|
- $this->error = 2668;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 验证技师或个体商家是否已经存在未完成订单
|
|
|
- $checkId = $this->model->where(['status' =>3,'mark'=>1])->where(function($query) use($mechId, $merchId, $merchType){
|
|
|
- // 技师
|
|
|
- if($mechId){
|
|
|
- $query->where(['source_id'=> $mechId]);
|
|
|
- }
|
|
|
- // 个体商家
|
|
|
- else if($merchId){
|
|
|
- $query->where(['merch_id'=> $merchId]);
|
|
|
- }
|
|
|
- })->value('id');
|
|
|
- if(($mechId && $checkId) || ($merchType==2 && $checkId)){
|
|
|
- $this->error = 2698;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 处理
|
|
|
- DB::beginTransaction();
|
|
|
- if ($this->model->where(['id' => $id])->update(['status' => 3, 'update_time' => time()])) {
|
|
|
- $params = [
|
|
|
- 'title' => "订单成功接单通知",
|
|
|
- 'body' => "您的订单已被接单,请即时查看订单进度",
|
|
|
- 'type' => 2, // 1-公告通知,2-订单通知,3-交易通知,4-其他
|
|
|
- 'content' => [
|
|
|
- 'order_no' => ['name' => '订单号', 'text' => $info['order_no']],
|
|
|
- 'time' => ['name' => '下单时间', 'text' => $info['pay_time']],
|
|
|
- 'appoint_time' => ['name' => '预约时间', 'text' => $info['appoint_time']],
|
|
|
- 'picker_time' => ['name' => '接单时间', 'text' => date('Y-m-d H:i:s')],
|
|
|
- 'mechanic' => [],
|
|
|
- 'money' => ['name' => '订单金额', 'text' => $info['pay_money']],
|
|
|
- 'status' => ['name' => '状态', 'text' => '待服务'],
|
|
|
- ],
|
|
|
- 'click_type' => 'payload',
|
|
|
- 'url' => '/pages/order/detail?id=' . $id,
|
|
|
- ];
|
|
|
- $mechanic = isset($info['mechanic'])? $info['mechanic'] : [];
|
|
|
- $code = isset($mechanic['code'])? $mechanic['code'] : '';
|
|
|
- if($code){
|
|
|
- $params['content']['mechanic'] = ['name' => '接单技师', 'text' => "{$code}号技师"];
|
|
|
- }
|
|
|
- if(!PushService::make()->pushMessageByUser($info['user_id'], $params, 0)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = PushService::make()->getError();
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- $this->error = 2674;
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2675;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 接单/上钟
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function inService()
|
|
|
- {
|
|
|
- $params = request()->all();
|
|
|
- $id = isset($params['id']) ? $params['id'] : 0;
|
|
|
- $mechId = isset($params['mech_id']) ? intval($params['mech_id']) : 0;
|
|
|
- $merchId = isset($params['merch_id']) ? intval($params['merch_id']) : 0;
|
|
|
- $info = $this->model->with(['mechanic'])->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id','user_id','order_no','merch_id','source_id','pay_money','reception_at','coupon_id','status','is_service','refund_status','pay_time'])
|
|
|
- ->first();
|
|
|
- $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
- $isService = isset($info['is_service']) ? $info['is_service'] : 0;
|
|
|
- $orderMechId = isset($info['source_id']) ? $info['source_id'] : 0;
|
|
|
- $orderMerchId = isset($info['merch_id']) ? $info['merch_id'] : 0;
|
|
|
- if (!$id || empty($info)) {
|
|
|
- $this->error = 2636;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-// if($mechId != $orderMechId && $merchId != $orderMerchId){
|
|
|
-// $this->error = 2667;
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-
|
|
|
- if ($status != 3 || $isService == 1) {
|
|
|
- $this->error = 2668;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 处理
|
|
|
- DB::beginTransaction();
|
|
|
- if ($this->model->where(['id' => $id])->update(['is_service' => 1, 'update_time' => time()])) {
|
|
|
- $params = [
|
|
|
- 'title' => "订单开始服务通知",
|
|
|
- 'body' => "您的订单已开始服务,请即时查看进度",
|
|
|
- 'type' => 2, // 1-公告通知,2-订单通知,3-交易通知,4-其他
|
|
|
- 'content' => [
|
|
|
- 'order_no' => ['name' => '订单号', 'text' => $info['order_no']],
|
|
|
- 'time' => ['name' => '下单时间', 'text' => $info['pay_time']],
|
|
|
- 'picker_time' => ['name' => '开始时间', 'text' => date('Y-m-d H:i:s')],
|
|
|
- 'mechanic' => [],
|
|
|
- 'money' => ['name' => '订单金额', 'text' => $info['pay_money']],
|
|
|
- 'status' => ['name' => '状态', 'text' => '服务中'],
|
|
|
- ],
|
|
|
- 'click_type' => 'payload',
|
|
|
- 'url' => '/pages/order/detail?id=' . $id,
|
|
|
- ];
|
|
|
- $mechanic = isset($info['mechanic'])? $info['mechanic'] : [];
|
|
|
- $code = isset($mechanic['code'])? $mechanic['code'] : '';
|
|
|
- if($code){
|
|
|
- $params['content']['mechanic'] = ['name' => '服务技师', 'text' => "{$code}号技师"];
|
|
|
- }
|
|
|
- if(!PushService::make()->pushMessageByUser($info['user_id'], $params, 0)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = PushService::make()->getError();
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- $this->error = 1003;
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 1002;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 收货/已完成
|
|
|
* @return bool
|
|
|
*/
|
|
@@ -1556,6 +1167,9 @@ class OrderService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ var_dump($info);
|
|
|
+ return false;
|
|
|
+
|
|
|
// 非法操作
|
|
|
if($userId && $merchId != $orderMerchId && $orderUserId != $userId){
|
|
|
$this->error = 2667;
|
|
@@ -1802,127 +1416,37 @@ class OrderService extends BaseService
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 评论
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function comment($userId, $params)
|
|
|
- {
|
|
|
- $orderId = isset($params['order_id']) ? $params['order_id'] : 0;
|
|
|
- $info = $this->model->where(['id' => $orderId, 'mark' => 1])->first();
|
|
|
- $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
- if (!$orderId || empty($info)) {
|
|
|
- $this->error = 2689;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if (!in_array($status, [3, 4])) {
|
|
|
- $this->error = 2668;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- $score = isset($params['score'])? intval($params['score']) : 0;
|
|
|
- $score = $score>0 && $score<=5? $score : 0;
|
|
|
- if($score<=0){
|
|
|
- $this->error = 2691;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 是否已经评论
|
|
|
- $comment = MerchantCommentModel::where(['user_id'=> $userId,'order_id'=> $orderId,'mark'=>1])
|
|
|
- ->select(['id','status'])
|
|
|
- ->first();
|
|
|
- $status = isset($comment['status'])? $comment['status'] : 0;
|
|
|
- $commentId = isset($comment['id'])? $comment['id'] : 0;
|
|
|
- if($comment && $status == 1){
|
|
|
- $this->error = 2690;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- $content = isset($params['content'])? $params['content'] : '';
|
|
|
- $content = $content? MessageService::make()->filterMessage($content) : '';
|
|
|
- $albums = isset($params['albums'])? get_format_images($params['albums']) : '';
|
|
|
- $merchId = isset($info['merch_id'])? $info['merch_id'] : 0;
|
|
|
-
|
|
|
- $publishTime = ConfigService::make()->getConfigByCode('publish_auto_check_time');
|
|
|
- $publishTime = $publishTime? $publishTime : 0;
|
|
|
- $publishAt = date('Y-m-d H:i:s', time() + $publishTime * 60);
|
|
|
- $orderGoodsId = OrderGoodsModel::where(['order_no'=> $info['order_no'],'status'=>1,'mark'=>1])->pluck('goods_id');
|
|
|
- $orderGoodsId = $orderGoodsId? $orderGoodsId->toArray() : [];
|
|
|
- $data = [
|
|
|
- 'user_id'=> $userId,
|
|
|
- 'order_id'=> $orderId,
|
|
|
- 'merch_id'=> $merchId,
|
|
|
- 'mech_id'=> isset($info['source_id'])? $info['source_id'] : 0,
|
|
|
- 'reply_id'=> isset($params['reply_id'])? $params['reply_id'] : 0,
|
|
|
- 'content'=> $content,
|
|
|
- 'albums'=> $albums,
|
|
|
- 'score'=> $score,
|
|
|
- 'goods'=> $orderGoodsId? implode(',', $orderGoodsId) : '',
|
|
|
- 'update_time'=> time(),
|
|
|
- 'publish_time'=> $publishAt,
|
|
|
- 'status'=> 1,
|
|
|
- ];
|
|
|
-
|
|
|
- DB::beginTransaction();
|
|
|
- if($comment){
|
|
|
- if(!MerchantCommentModel::where(['id'=> $commentId])->update($data)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2693;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }else{
|
|
|
- $data['create_time'] = time();
|
|
|
- if(!$commentId = MerchantCommentModel::insertGetId($data)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2693;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $updateData = ['score_rate'=> DB::raw("(score_rate+{$score})/2"),'update_time'=>time()];
|
|
|
- if(!MerchantModel::where(['id'=> $merchId])->update($updateData)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = 2693;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- $this->error = lang('2692',['time'=> $publishTime? $publishTime:'0']);
|
|
|
- return ['id'=> $commentId];
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
- * 隐藏订单
|
|
|
+ * 隐藏删除
|
|
|
* @return false
|
|
|
*/
|
|
|
- public function hide()
|
|
|
+ public function hide($userId, $params)
|
|
|
{
|
|
|
- $params = request()->all();
|
|
|
$id = isset($params['id']) ? $params['id'] : 0;
|
|
|
$info = $this->model->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id','user_id','order_no','merch_id','source_id','status','user_delete'])
|
|
|
+ ->select(['id','user_id','order_no','status','is_hide'])
|
|
|
->first();
|
|
|
if (!$id || empty($info)) {
|
|
|
- $this->error = 2636;
|
|
|
+ $this->error = 2912;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $userDelete = isset($info['user_delete'])? $info['user_delete'] : 0;
|
|
|
- if($userDelete == 2){
|
|
|
- $this->error = 2235;
|
|
|
+ $isHide = isset($info['is_hide'])? $info['is_hide'] : 0;
|
|
|
+ if($isHide >0){
|
|
|
+ $this->error = 2914;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if($this->model->where(['id'=> $id])->update(['user_delete'=>2,'update_time'=>time()]))
|
|
|
+ if($this->model->where(['id'=> $id])->update(['is_hide'=>2,'update_time'=>time()]))
|
|
|
{
|
|
|
- $this->error = 2236;
|
|
|
+ $this->error = 1002;
|
|
|
return true;
|
|
|
}else{
|
|
|
- $this->error = 2237;
|
|
|
+ $this->error = 1003;
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|