|
@@ -37,6 +37,7 @@ use support\exception\BusinessException;
|
|
|
use support\Redis;
|
|
|
use support\Request;
|
|
|
use support\Response;
|
|
|
+use Tinywan\Jwt\JwtToken;
|
|
|
use Webman\Event\Event;
|
|
|
use Yansongda\Pay\Pay;
|
|
|
use function Qiniu\Http\Middleware\compose;
|
|
@@ -377,6 +378,20 @@ class WholeController extends Curd
|
|
|
$payDetail = PayDetail::where('join_pay_order_id', $order->order_groupby)
|
|
|
->select('pay_id', 'pay_category', 'pay_prepayid', 'pay_paytimes', 'pay_status', 'pay_amount')
|
|
|
->first();
|
|
|
+ $refund = OrderReturn::where('join_return_order_id',$orderId)
|
|
|
+ ->select('order_return_status','order_return_apply_datetime','order_return_apply_json','order_return_accept_datetime','order_return_refund_json','order_return_extend_json')
|
|
|
+ ->first();
|
|
|
+ if (!empty($refund->order_return_refund_json)){
|
|
|
+ $returnRefundJson = json_decode($refund->order_return_refund_json,true);
|
|
|
+ if (isset($returnRefundJson['user_id'])){
|
|
|
+ $userName = SysUser::where('user_id',$returnRefundJson['user_id'])->value('user_name');
|
|
|
+ $returnRefundJson['person'] = $userName;
|
|
|
+ unset($returnRefundJson['user_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $refund->order_return_refund_json = json_encode($returnRefundJson);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (!empty($payDetail->pay_prepayid)) {
|
|
|
$categoryArray = explode('-', $payDetail->pay_prepayid);
|
|
@@ -414,6 +429,7 @@ class WholeController extends Curd
|
|
|
$order->premises = $premises;
|
|
|
$data = [
|
|
|
'order' => $order,
|
|
|
+ 'refund' => $refund,
|
|
|
'sheet' => $orderSheet,
|
|
|
'express' => $express,
|
|
|
'payDetail' => $payDetail
|
|
@@ -431,7 +447,8 @@ class WholeController extends Curd
|
|
|
|
|
|
// 修改主订单
|
|
|
$this->updateMain($params);
|
|
|
-
|
|
|
+ // 修改sheet表
|
|
|
+ $this->updateSheet($params);
|
|
|
// 修改物流
|
|
|
$this->updateExpress($params);
|
|
|
|
|
@@ -446,6 +463,52 @@ class WholeController extends Curd
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改主订单
|
|
|
+ */
|
|
|
+ public function updateMain($params)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $order = Order::where('order_id',$params['order_id'])->first();
|
|
|
+ $orderConfigJson = [];
|
|
|
+ if(!empty($order->order_config_json)){
|
|
|
+ $orderConfigJson = json_decode($order->order_config_json,true);
|
|
|
+ }
|
|
|
+ // 优惠
|
|
|
+ if (!empty($params['preferential'])){
|
|
|
+ $orderConfigJson['preferential'] = $params['preferential'];
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'order_amount_pay'=>$params['order_amount_pay'],
|
|
|
+ 'order_amount_total'=>$params['order_amount_total'],
|
|
|
+ 'order_config_json' => json_encode($orderConfigJson)
|
|
|
+ ];
|
|
|
+ Order::where('order_id', $params['order_id'])->update($data);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ throw new BusinessException('修改订单失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单sheet
|
|
|
+ */
|
|
|
+ public function updateSheet($params)
|
|
|
+ {
|
|
|
+ try{
|
|
|
+ foreach ($params['goodsContentList'] as $sheet){
|
|
|
+ $data=[
|
|
|
+ 'order_sheet_num'=>$sheet['nbr'],
|
|
|
+ 'join_sheet_goods_sku_id'=>$sheet['sku_id']
|
|
|
+ ];
|
|
|
+ OrderSheet::where('order_sheet_id',$sheet['order_sheet_id'])->update($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch(\Exception $e){
|
|
|
+ dump($e->getMessage());
|
|
|
+ throw new BusinessException('修改订单详情失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function updateExpress($params)
|
|
|
{
|
|
|
$express = OrderExpress::where('join_express_order_id', $params['order_id'])->first();
|
|
@@ -1118,7 +1181,7 @@ class WholeController extends Curd
|
|
|
}
|
|
|
$params['order_amount_pay'] = $params['order_amount_pay'] + $qrcodePayAmount;
|
|
|
|
|
|
- if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS'){
|
|
|
+ if (in_array($params['delivery'],['PICKUP','ARRIVAL']) && !empty($params['dept_premises_id'])){
|
|
|
$premises = SysDept::where('dept_name',$params['dept_premises_id'])->where('dept_category','营业场所')->first();
|
|
|
if (!$premises){
|
|
|
Db::rollBack();
|
|
@@ -1126,6 +1189,8 @@ class WholeController extends Curd
|
|
|
return json_fail('门店不存在,请重新选择');
|
|
|
}
|
|
|
$params['submit_premises_id'] = $premises->dept_id;
|
|
|
+ }
|
|
|
+ if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS'){
|
|
|
$orderConfigJson['premises'] = $params['dept_premises_id'];
|
|
|
$orderConfigJson['dept'] = $premises->dept_id;
|
|
|
$orderConfigJson['reach'] = "00:00";
|
|
@@ -1299,9 +1364,11 @@ class WholeController extends Curd
|
|
|
$price = floatval($goods['goods_sales_price']);
|
|
|
$extendJson['unit'] = $goods['sku_name'];
|
|
|
if (isset($params['submit_premises_id'])){
|
|
|
- $extendJson['table'] = null;
|
|
|
$extendJson['premises'] = $params['submit_premises_id'];
|
|
|
}
|
|
|
+ if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS'){
|
|
|
+ $extendJson['table'] = null;
|
|
|
+ }
|
|
|
$data = [
|
|
|
'join_sheet_member_id' => $params['join_order_member_id'],
|
|
|
'join_sheet_order_id' => $params['orderId'],
|
|
@@ -1491,35 +1558,6 @@ class WholeController extends Curd
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改主订单
|
|
|
- */
|
|
|
- public function updateMain($params)
|
|
|
- {
|
|
|
- // $params['order_express_goods'] = json_encode(['sheet' => [$params['sheet_id']]]);
|
|
|
- // if ($params['delivery'] == 'PICKUP') { // 自提
|
|
|
- // // $params['order_config_json'] = json_encode([
|
|
|
- // // 'express' => 'S',
|
|
|
- // // 'premises' => $params['dept_premises_id']
|
|
|
- // // ]);
|
|
|
- // } else if ($params['delivery'] == 'LOGISTICS') {
|
|
|
- // // $params['order_express_json'] = json_encode([
|
|
|
- // // 'express' => 'Y',
|
|
|
- // // ]);
|
|
|
- // $params['orderId'] = $params['order_id'];
|
|
|
-
|
|
|
- // $this->saveExpress($params);
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- try {
|
|
|
- Order::where('order_id', $params['order_id'])->update(['order_config_json' => $params['order_config_json'] ?? '[]']);
|
|
|
- } catch (\Exception $e) {
|
|
|
- throw new BusinessException('修改订单失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @Desc 发货
|
|
|
* @Author Gorden
|
|
@@ -2040,7 +2078,7 @@ class WholeController extends Curd
|
|
|
Order::where('order_id', $return->join_return_order_id)->update(['order_is_complete' => 'R']);
|
|
|
// return 表
|
|
|
$return->order_return_status = 'DONE';
|
|
|
- $return->order_return_refund_json = json_encode(['amount' => $amount]);
|
|
|
+ $return->order_return_refund_json = json_encode(['amount' => $amount,'datetime'=>date('Y-m-d H:i:s'),'user_id'=>JwtToken::getCurrentId()]);
|
|
|
$return->save();
|
|
|
$payType = explode('-', $payDetail->pay_prepayid);
|
|
|
// 区分账户余额支付和在线支付
|