Browse Source

Merge branch 'qs_local_order' into develop

# Conflicts:
#	app/Models/LanzuGoods.php
master
lanzu_qinsheng 5 years ago
parent
commit
d452f48794
  1. 21
      app/Admin/Common/LinkUrl.php
  2. 18
      app/Admin/Common/Rpc.php
  3. 14
      app/Admin/Controllers/ImsCjdcOrderMainController.php
  4. 1
      app/Admin/Controllers/Type.php
  5. 69
      app/Admin/Extensions/MyDetailPage.php
  6. 12
      app/Admin/Extensions/OrderDetail.php
  7. 22
      app/Admin/Extensions/OrderStateHandle.php
  8. 17
      app/Models/ImsCjdcOrder.php
  9. 11
      app/Models/ImsCjdcOrderMain.php
  10. 20
      app/Models/LanzuOrderGoods.php
  11. 2
      app/Models/LanzuServiceHorseman.php
  12. 4
      public/css/detail.css
  13. 5
      resources/lang/zh-CN/ims-cjdc-order-main.php
  14. 45
      resources/views/orderdetail.php

21
app/Admin/Common/LinkUrl.php

@ -0,0 +1,21 @@
<?php
namespace App\Admin\Common;
class LinkUrl
{
/**
* js
*/
const VUE_JS = 'https://cdn.jsdelivr.net/npm/vue';
const ELEMENT_UI_JS = 'https://unpkg.com/element-ui/lib/index.js';
/**
* css
*/
const ELEMENT_UI_CSS="https://unpkg.com/element-ui/lib/theme-chalk/index.css";
const DETAIL_CSS = 'css/detail.css';
}

18
app/Admin/Common/Rpc.php

@ -9,7 +9,9 @@ use Graze\GuzzleHttp\JsonRpc\Client;
class Rpc
{
const SEPARATE_ACCOUNTS = "/separateaccounts/orderOnlineCompleted";
const SEPARATE_ACCOUNTS = "/order/onlineComplete";
const ORDER_REFUND = "/order/onlineRefund";
/**
@ -18,15 +20,23 @@ class Rpc
* @param $uid
* @return string
*/
public static function separateAccounts($oid,$uid){
public static function separateAccounts($global_order_id,$uid){
$client = Client::factory(env('RPC_SITE_HOST'));
$request = $client->request(
uniqid(),
self::SEPARATE_ACCOUNTS,
['orderMainId' => $oid,'userId'=>$uid]);
['global_order_id' => $global_order_id,'user_id'=>$uid]);
$response = $client->send($request);
return $response->getBody()->getContents();
}
public static function orderRefund($global_order_id,$uid){
$client = Client::factory(env('RPC_SITE_HOST'));
$request = $client->request(
uniqid(),
self::ORDER_REFUND,
['global_order_id' => $global_order_id,'user_id'=>$uid]);
$response = $client->send($request);
return $response->getBody()->getContents();
}
}

14
app/Admin/Controllers/ImsCjdcOrderMainController.php

@ -72,7 +72,7 @@ class ImsCjdcOrderMainController extends AdminController
$actions->append(new OrderStateHandle('同意退款',9));
$actions->append(new OrderRefund($actions->row->id,$grid->model()->getCurrentPage(),'拒绝退款'));
}
$actions->append(new OrderDetail($actions->row->id,'详情'));
$actions->append(new OrderDetail($actions->row->id,$grid->model()->getCurrentPage(),'详情'));
});
@ -138,8 +138,18 @@ class ImsCjdcOrderMainController extends AdminController
public function orderDetail(Content $content)
{
$oid = request()->get('order_id');
$page = request()->get('page');
// 实例化表单类并传递自定义参数
$detail = MyDetailPage::make(['order_id'=>$oid]);
return $content->header('订单详情')->body(Lazy::make($detail));
return $content->header('订单详情')
->breadcrumb(
['text'=>'列表','url'=>"order?page={$page}"],
['text' => '详情', 'url' => 'detail'],
)
->body(Lazy::make($detail));
}
}

1
app/Admin/Controllers/Type.php

@ -36,4 +36,5 @@ class Type
const BALANCE_USER_TYPE_CS = 4; //社区提现类型
const BALANCE_USER_TYPE_STORE= 5; //商户提现类型
}

69
app/Admin/Extensions/MyDetailPage.php

@ -3,49 +3,51 @@
namespace App\Admin\Extensions;
use App\Admin\Common\LinkUrl;
use App\Models\ImsCjdcOrder;
use App\Models\ImsCjdcOrderMain;
use App\Models\LanzuOrderGoods;
use App\Models\LanzuServiceHorseman;
use Dcat\Admin\Admin;
use Dcat\Admin\Support\LazyRenderable;
use Endroid\QrCode\Exceptions\DataDoesntExistsException;
class MyDetailPage extends LazyRenderable
{
protected static $js = ['https://cdn.jsdelivr.net/npm/vue'];
protected static $css = ['css/deatail.css'];
protected static $js = [LinkUrl::VUE_JS, LinkUrl::ELEMENT_UI_JS];
protected static $css = [LinkUrl::DETAIL_CSS, LinkUrl::ELEMENT_UI_CSS];
public function render()
{
$order = ImsCjdcOrderMain::where('id',$this->order_id)->first()->toArray();
if ($order){
$order['created_at'] = date('Y-m-d H:i:s',$order['created_at']);
$order['updated_at'] =$order['updated_at'] ? date('Y-m-d H:i:s',$order['updated_at']):null;
$order['pay_type'] = config('order.pay_type')[$order['pay_type']];
$order['shipping_type'] = config('order.shipping_type')[$order['shipping_type']];
$order['horseman_name'] = LanzuServiceHorseman::getName($order['horseman_id']);
}
//配送距离
//配送费
//拒绝退款理由
//退款总备注原因,单个商品或者单个子订单
//dd($order);
Admin::script(
<<<JS
//>>1.主订单数据
$order = ImsCjdcOrderMain::getOrderData($this->order_id);
if ($order) {
//>>2.获取子订单
$orders = ImsCjdcOrder::getOrdersData($order['id']);
//配送距离
//配送费
//拒绝退款理由
//退款总备注原因,单个商品或者单个子订单
Admin::script(
<<<JS
var orders = JSON.stringify($orders)
var app = new Vue({
el:"#detail",
data:{
dialogFormVisible: false,
order_num: "{$order['order_num']}",
name: "{$order['name']}",
state: "{$order['state']}",
created_at: "{$order['created_at']}",
updated_at: "{$order['updated_at']}",
pay_type: "{$order['pay_type']}",
shipping_type: "{$order['shipping_type']}",
tel: "{$order['tel']}",
delivery_time_note: "{$order['delivery_time_note']}",
refuse_refund_note: "{$order['refuse_refund_note']}",
total_refund_note: "{$order['total_refund_note']}",
address: "{$order['address']}",
note: "{$order['note']}",
money: "{$order['money']}",
@ -53,12 +55,35 @@ class MyDetailPage extends LazyRenderable
services_money: "{$order['services_money']}",
coupon_money: "{$order['coupon_money']}",
delivery_money: "{$order['delivery_money']}",
horseman_name: "{$order['horseman_name']}"
horseman_name: "{$order['horseman_name']}",
orders: JSON.parse(orders),
refund_2:"退款",
refund_3:"已同意退款",
refund_goods_name:"",
},
methods: {
refundNote(name) {
this.dialogFormVisible = true;
this.refund_goods_name ="退款备注商品 ["+name+"]" ;
},
refundConfirm() {
this.\$confirm('是否同意该商品退款?', '提示', {
confirmButtonText: '同意',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.dialogFormVisible = false;
alert(this.total_refund_note)
}).catch(() => {
});
}
}
});
JS
);
);
}
return view('orderdetail');
}

12
app/Admin/Extensions/OrderDetail.php

@ -3,20 +3,18 @@
namespace App\Admin\Extensions;
use App\Admin\Forms\RefundNote;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Modal;
class OrderDetail extends RowAction
{
protected $title;
protected $order_id;
public function __construct($orderId,$title=null)
protected $currentPage;
public function __construct($orderId,$currentPage,$title=null)
{
$this->order_id = $orderId;
$this->currentPage = $currentPage;
parent::__construct($title);
}
@ -28,7 +26,7 @@ class OrderDetail extends RowAction
{
return <<<JS
$('.detail_{$this->order_id}').on('click', function () {
window.location.href ="detail?order_id={$this->order_id}";
window.location.href ="detail?order_id={$this->order_id}&page={$this->currentPage}";
});
JS;
}

22
app/Admin/Extensions/OrderStateHandle.php

@ -36,21 +36,25 @@ class OrderStateHandle extends RowAction
$id = $this->getKey();
$orderMain = new ImsCjdcOrderMain();
$state = $request->get('state');
$res = $orderMain->modifyState($id,$state);
if ($res&&$state==4){
if ($state==4){
$order = $orderMain::where('id',$id)->first();
//记录分账流水
$result = json_decode(Rpc::separateAccounts($id,$order->user_id));
if ($result->result){
return $this->response()->success('操作成功')->refresh();
}else{
$result = json_decode(Rpc::separateAccounts($order->global_order_id,$order->user_id),true)['result'];
if ($result['code']!=0){
Log::error('订单完成时分账接口调用失败',$result);
return $this->response()->error('操作失败')->refresh();
}
}elseif ($res&&$state==9){//同意退款
return $this->response()->success('操作成功')->refresh();
}elseif ($state==9){//同意退款
$order = $orderMain::where('id',$id)->first();
$result = json_decode(Rpc::orderRefund($order->global_order_id,$order->user_id),true)['result'];
if ($result['code']!=0){
Log::error('订单退款接口调用失败',$result);
return $this->response()->error('操作失败')->refresh();
}
return $this->response()->success('操作成功')->refresh();
}
$res = $orderMain->modifyState($id,$state);
if ($res==true){
return $this->response()->success('操作成功')->refresh();
}else{

17
app/Models/ImsCjdcOrder.php

@ -19,8 +19,21 @@ class ImsCjdcOrder extends Model
public function store()
{
return $this->hasOne('\App\Models\ImsCjdcStore','id','store_id');
return $this->hasOne('\App\Models\LanzuStore','id','store_id');
}
public static function getOrdersData($oid)
{
$orders = ImsCjdcOrder::with('user')->with('store')
->where('order_main_id', $oid)->get()->toArray();
if (count($orders)) {
foreach ($orders as &$or) {
if (substr($or['store']['logo'], 0, 4) != 'http') {
$or['store']['logo'] = env('IMG_HOST') . '/' . $or['store']['logo'];
}
$or['goods'] = LanzuOrderGoods::where('order_id', $or['id'])->get()->toArray();
}
}
return json_encode($orders);
}
}

11
app/Models/ImsCjdcOrderMain.php

@ -50,4 +50,15 @@ class ImsCjdcOrderMain extends Model
{
return self::where('id',$oid)->update(['shipping_type'=>$type]);
}
public static function getOrderData($oid)
{
$order = ImsCjdcOrderMain::where('id', $oid)->first()->toArray();
$order['created_at'] = date('Y-m-d H:i:s', $order['created_at']);
$order['updated_at'] = $order['updated_at'] ? date('Y-m-d H:i:s', $order['updated_at']) : null;
$order['pay_type'] = config('order.pay_type')[$order['pay_type']];
$order['shipping_type'] = config('order.shipping_type')[$order['shipping_type']];
$order['horseman_name'] = LanzuServiceHorseman::getName($order['horseman_id']);
return $order;
}
}

20
app/Models/LanzuOrderGoods.php

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class LanzuOrderGoods extends Model
{
use HasDateTimeFormatter;
protected $table = 'lanzu_order_goods';
protected $dateFormat = 'U';
public function goods()
{
return $this->belongsTo('\App\Models\LanzuGoods','goods_id','id');
}
}

2
app/Models/LanzuServiceHorseman.php

@ -35,7 +35,7 @@ class LanzuServiceHorseman extends Model
$horseman = LanzuServiceHorseman::find($hid);
return $horseman->name;
}else{
return '-';
return '--';
}
}
}

4
public/css/deatail.css → public/css/detail.css

@ -10,8 +10,8 @@
}
.logo-img {
width: 8vw;
height: 10vh;
width: 80px;
height: 80px;
margin-right: 1rem;
}

5
resources/lang/zh-CN/ims-cjdc-order-main.php

@ -1,7 +1,8 @@
<?php
<?php
return [
'labels' => [
'ImsCjdcOrderMain' => 'ImsCjdcOrderMain',
'ImsCjdcOrderMain' => '订单',
'order'=>'订单列表'
],
'fields' => [
'user_id' => '用户id',

45
resources/views/orderdetail.php

@ -17,37 +17,44 @@
<tr>
<td class="text-nowrap" scope="row">预约送达时间:{{delivery_time_note}}</td>
<td class="text-nowrap" scope="col">配送员:{{horseman_name}}</td>
</tr>
<tr>
<td class="text-nowrap" scope="row">配送距离:-- km</td>
<td colspan="5">配送费:{{delivery_money}} </td>
</tr>
<tr>
<td class="text-nowrap" scope="col">备注:{{note}}</td>
<td class="text-nowrap" scope="col">订单备注:{{note}}</td>
<td class="text-nowrap" scope="col" v-if="refuse_refund_note">拒绝退款原因:{{refuse_refund_note}}</td>
</tr>
<tr>
<td class="text-nowrap" scope="col" v-if="total_refund_note">拒绝退款原因:{{total_refund_note}}</td>
</tr>
</tbody>
</table>
<!-- 用户信息表格END -->
<!-- 店铺 -->
<div class="shop-box" v-for="">
<div class="shop-box" v-for="item in orders">
<div class="alert alert-secondary" role="alert">
<img class="shop-logo" src="https://store.lanzu.vip/attachment/zh_cjdianc/2020/06/08/0695939116515895.jpg" alt="店铺logo"/>
<span>2222</span>
<img class="shop-logo" :src="item.store.logo" alt="店铺logo"/>
<span>{{item.store.name}}</span>
</div>
店铺商品
<div class="media">
<img class="logo-img" src="https://store.lanzu.vip/attachment/zh_cjdianc/2020/06/08/0695939116515895.jpg" class="align-self-center mr-3" alt="商品图片">
店铺商品
<div class="media" v-for= "goods in item.goods">
<img class="logo-img" :src="goods.cover_img" class="align-self-center mr-3" alt="商品图片">
<div class="media-body">
<h5 class="mt-0">2222</h5>
<h5 class="mt-0">{{goods.name}}</h5>
<div>
<span class="price">222</span>
<span style="float: right;">X 2222</span>
<span class="price">/{{goods.goods_unit}}</span>
<span style="float: right;">X {{goods.number}}</span>
</div>
<p class="mb-0" style="color: red;font-size: 1.4rem;">¥222</p>
<p class="mb-0" style="color: red;font-size: 1.4rem;">{{goods.price}}</p>
<el-button type="danger" style="float: right;" @click="refundNote(goods.name)" v-if="state==4">{{refund_2}}</el-button>
<p style="float: right;" v-if="goods.status==3">{{refund_3}}</p>
</div>
</div>
<p v-if="item.note">店铺备注: ({{item.note}})</p>l
</div>
<div class="money">
总金额: {{total_money}}
@ -58,8 +65,16 @@
&ensp;&ensp;
增值服务费: <span style="color: green">+{{services_money}}</span>
&ensp;&ensp;
实付金额: {money}
实付金额: {{money}}
</div>l
<el-dialog :title="refund_goods_name" :visible.sync="dialogFormVisible">
<el-input :rows="5" v-model="total_refund_note" placehoder="请备注退款原因" type="textarea"></el-input>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="refundConfirm()"> </el-button>
</div>
</el-dialog>
</div>
<!-- 店铺END -->
</div>
Loading…
Cancel
Save