mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改订单
This commit is contained in:
parent
ad6144c544
commit
c86830a491
@ -66,7 +66,7 @@ class ShopOrder extends Controller
|
||||
if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}");
|
||||
// 推荐人搜索查询
|
||||
$db = $this->_query('DataUser')->like('phone#from_phone,nickname#from_nickname')->db();
|
||||
if ($db->getOptions('where')) $query->whereRaw("from in {$db->field('id')->buildSql()}");
|
||||
if ($db->getOptions('where')) $query->whereRaw("puid1 in {$db->field('id')->buildSql()}");
|
||||
// 列表选项卡
|
||||
if (is_numeric($this->type = trim(input('type', 'ta'), 't'))) {
|
||||
$query->where(['status' => $this->type]);
|
||||
@ -85,11 +85,9 @@ class ShopOrder extends Controller
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
UserService::instance()->buildByUid($data);
|
||||
UserService::instance()->buildByUid($data, 'from', 'fromer');
|
||||
OrderService::instance()->buildItemData($data);
|
||||
foreach ($data as &$vo) {
|
||||
$vo['payment_name'] = PaymentService::name($vo['payment_type']);
|
||||
}
|
||||
UserService::instance()->buildByUid($data, 'puid1', 'fromer');
|
||||
OrderService::instance()->buildOrderData($data);
|
||||
foreach ($data as &$vo) $vo['payment_name'] = PaymentService::name($vo['payment_type']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ class ShopOrderSend extends Controller
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
OrderService::instance()->buildItemData($data, false);
|
||||
OrderService::instance()->buildOrderData($data, false);
|
||||
$orders = array_unique(array_column($data, 'order_no'));
|
||||
$orderList = $this->app->db->name('ShopOrder')->whereIn('order_no', $orders)->column('*', 'order_no');
|
||||
foreach ($data as &$vo) $vo['order'] = $orderList[$vo['order_no']] ?? [];
|
||||
|
@ -40,7 +40,7 @@ class Order extends Auth
|
||||
$map = ['uid' => $this->uuid, 'deleted' => 0];
|
||||
$query = $this->_query('ShopOrder')->in('status')->equal('order_no');
|
||||
$result = $query->where($map)->order('id desc')->page(true, false, false, 20);
|
||||
if (count($result['list']) > 0) OrderService::instance()->buildItemData($result['list']);
|
||||
if (count($result['list']) > 0) OrderService::instance()->buildOrderData($result['list']);
|
||||
$this->success('获取订单数据成功!', $result);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class OrderService extends Service
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function buildItemData(array &$data = [], $fromer = true): array
|
||||
public function buildOrderData(array &$data = [], $fromer = true): array
|
||||
{
|
||||
// 关联发货信息
|
||||
$nobs = array_unique(array_column($data, 'order_no'));
|
||||
@ -57,11 +57,9 @@ class OrderService extends Service
|
||||
// 关联用户数据
|
||||
$fields = 'username,phone,nickname,headimg,status';
|
||||
UserService::instance()->buildByUid($data, 'uid', 'user', $fields);
|
||||
if ($fromer) UserService::instance()->buildByUid($data, 'from', 'fromer', $fields);
|
||||
if ($fromer) UserService::instance()->buildByUid($data, 'puid1', 'fromer', $fields);
|
||||
foreach ($data as &$vo) {
|
||||
$vo['sales'] = 0;
|
||||
$vo['truck'] = $trucks[$vo['order_no']] ?? [];
|
||||
$vo['items'] = [];
|
||||
[$vo['sales'], $vo['truck'], $vo['items']] = [0, $trucks[$vo['order_no']] ?? [], []];
|
||||
foreach ($items as $item) if ($vo['order_no'] === $item['order_no']) {
|
||||
$vo['sales'] += $item['stock_sales'];
|
||||
$vo['items'][] = $item;
|
||||
|
@ -256,8 +256,8 @@ class UserService extends Service
|
||||
$orderAmountTotal = $this->app->db->name('ShopOrder')->whereRaw("uid={$uid} and status in (3,4,5)")->sum('amount_goods');
|
||||
// 统计团队业绩
|
||||
$usql = $this->app->db->name('DataUser')->field('id')->whereRaw("`pid1`={$uid}")->buildSql();
|
||||
$teamsAmountDirect = $this->app->db->name('ShopOrder')->whereRaw("`from`={$uid} and status in (3,4,5)")->sum('amount_goods');
|
||||
$teamsAmountIndirect = $this->app->db->name('ShopOrder')->whereRaw("`from` in {$usql} and status in (3,4,5)")->sum('amount_goods');
|
||||
$teamsAmountDirect = $this->app->db->name('ShopOrder')->whereRaw("`puid1`={$uid} and status in (3,4,5)")->sum('amount_goods');
|
||||
$teamsAmountIndirect = $this->app->db->name('ShopOrder')->whereRaw("`puid1` in {$usql} and status in (3,4,5)")->sum('amount_goods');
|
||||
// 更新用户数据
|
||||
$data = [
|
||||
'vip_name' => $vipName,
|
||||
|
Loading…
x
Reference in New Issue
Block a user