同步订单的时候同步退货
This commit is contained in:
parent
387c050a5d
commit
55151f5933
@ -30,7 +30,10 @@ class OrderBaseSync extends Command
|
|||||||
$this->packages = app(PackageRepository::class)->withTrashed()->get()->keyBy('sn');
|
$this->packages = app(PackageRepository::class)->withTrashed()->get()->keyBy('sn');
|
||||||
|
|
||||||
$orders = $this->getOrders();
|
$orders = $this->getOrders();
|
||||||
$cards = $this->getCards($orders);
|
|
||||||
|
$refunds = $this->getRefunds();
|
||||||
|
|
||||||
|
$cards = $this->getCards($orders, $refunds);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::transaction(function () use ($orders, $cards) {
|
DB::transaction(function () use ($orders, $cards) {
|
||||||
@ -57,7 +60,9 @@ class OrderBaseSync extends Command
|
|||||||
$value['virtual_order_id'] = $orders[$value['sim']] ?? 0;
|
$value['virtual_order_id'] = $orders[$value['sim']] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::table('real_order_cards')->upsert($data, ['sim', 'order_id']);
|
$only = ['company_id', 'package_id', 'counts', 'unit_price'];
|
||||||
|
|
||||||
|
DB::table('real_order_cards')->upsert($data, ['sim', 'order_id'], $only);
|
||||||
}
|
}
|
||||||
|
|
||||||
app(OrderCardPartitionRepository::class)->forgetCached();
|
app(OrderCardPartitionRepository::class)->forgetCached();
|
||||||
@ -136,8 +141,27 @@ class OrderBaseSync extends Command
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询退货
|
||||||
|
protected function getRefunds()
|
||||||
|
{
|
||||||
|
$this->line('查询退货记录');
|
||||||
|
$datetime = $this->getDateTime();
|
||||||
|
|
||||||
|
$starttime = $datetime->copy()->startOfMonth()->startOfDay()->format('Y-m-d H:i:s');
|
||||||
|
$endtime = $datetime->copy()->endOfMonth()->endOfDay()->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
$refunds = DB::connection('real')->table('jxc_back_card')
|
||||||
|
->select(['sim', 'create_time'])
|
||||||
|
->where('status', 2)
|
||||||
|
->where('create_time', '>=', $starttime)
|
||||||
|
->where('create_time', '<=', $endtime)
|
||||||
|
->get()->collect()->keyBy('sim')->toArray();
|
||||||
|
|
||||||
|
return $refunds;
|
||||||
|
}
|
||||||
|
|
||||||
// 获取月销售卡数据
|
// 获取月销售卡数据
|
||||||
protected function getCards($orders)
|
protected function getCards($orders, $refunds)
|
||||||
{
|
{
|
||||||
$orders = array_keyBy($orders, 'sn');
|
$orders = array_keyBy($orders, 'sn');
|
||||||
$orderRows = $this->getOrderRows($orders);
|
$orderRows = $this->getOrderRows($orders);
|
||||||
@ -162,6 +186,7 @@ class OrderBaseSync extends Command
|
|||||||
'package_id' => $order['package_id'],
|
'package_id' => $order['package_id'],
|
||||||
'counts' => 1,
|
'counts' => 1,
|
||||||
'unit_price' => $order['unit_price'],
|
'unit_price' => $order['unit_price'],
|
||||||
|
'refunded_at' => $refunds[$sim]['create_time'] ?? null,
|
||||||
'created_at' => $order['created_at'],
|
'created_at' => $order['created_at'],
|
||||||
'updated_at' => $order['updated_at'],
|
'updated_at' => $order['updated_at'],
|
||||||
'deleted_at' => $order['deleted_at'],
|
'deleted_at' => $order['deleted_at'],
|
||||||
|
@ -42,9 +42,9 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "同步退货",
|
title: "同步退货",
|
||||||
content: "同步本月退之前的订单",
|
content: "同步上月退货的数据",
|
||||||
command: "real:sync-refund",
|
command: "real:sync-refund",
|
||||||
max: 25,
|
max: 21,
|
||||||
datePicker: true
|
datePicker: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -54,13 +54,6 @@ export default {
|
|||||||
max: 60,
|
max: 60,
|
||||||
datePicker: true
|
datePicker: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "同步退货",
|
|
||||||
content: "同步本月退当月的订单",
|
|
||||||
command: "real:sync-refund",
|
|
||||||
max: 65,
|
|
||||||
datePicker: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "同步企业订单",
|
title: "同步企业订单",
|
||||||
content: "指定月份的续费及增值包数据",
|
content: "指定月份的续费及增值包数据",
|
||||||
|
1
public/js/app.b0954383.js
Normal file
1
public/js/app.b0954383.js
Normal file
File diff suppressed because one or more lines are too long
14
public/js/chunk-8064e07e.aa7bc13d.js
Normal file
14
public/js/chunk-8064e07e.aa7bc13d.js
Normal file
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-6ea47298.6166dab5.css rel=prefetch><link href=/css/chunk-8064e07e.03f6c57e.css rel=prefetch><link href=/js/chunk-00ae0766.d130b440.js rel=prefetch><link href=/js/chunk-07a274ec.55e1b3b0.js rel=prefetch><link href=/js/chunk-6ea47298.b6a301d0.js rel=prefetch><link href=/js/chunk-8064e07e.3468404c.js rel=prefetch><link href=/css/app.be09e36f.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.2b8e6a09.js rel=preload as=script><link href=/js/chunk-vendors.f1169dcc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.be09e36f.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.f1169dcc.js></script><script src=/js/app.2b8e6a09.js></script></body></html>
|
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-6ea47298.6166dab5.css rel=prefetch><link href=/css/chunk-8064e07e.03f6c57e.css rel=prefetch><link href=/js/chunk-00ae0766.d130b440.js rel=prefetch><link href=/js/chunk-07a274ec.55e1b3b0.js rel=prefetch><link href=/js/chunk-6ea47298.b6a301d0.js rel=prefetch><link href=/js/chunk-8064e07e.aa7bc13d.js rel=prefetch><link href=/css/app.be09e36f.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.b0954383.js rel=preload as=script><link href=/js/chunk-vendors.f1169dcc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.be09e36f.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有启用JavaScript,程序不能正常工作,若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.f1169dcc.js></script><script src=/js/app.b0954383.js></script></body></html>
|
Loading…
x
Reference in New Issue
Block a user