diff --git a/app/data/controller/UserRebate.php b/app/data/controller/UserRebate.php index f7b5837ce..3589443ba 100644 --- a/app/data/controller/UserRebate.php +++ b/app/data/controller/UserRebate.php @@ -13,6 +13,60 @@ use think\admin\Controller; class UserRebate extends Controller { + /** + * 绑定数据表 + * @var string + */ + private $table = 'DataUserRebate'; + + /** + * 用户返利记录 + * @auth true + * @menu true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function index() + { + $this->title = '用户返利记录'; + $query = $this->_query($this->table)->equal('type')->like('order_no,description'); + // 会员查询 + $db = $this->_query('DataUser')->like('nickname#order_nickname,phone#order_phone')->db(); + if ($db->getOptions('where')) $query->whereRaw("order_uid in {$db->field('id')->buildSql()}"); + // 代理查询 + $db = $this->_query('DataUser')->like('nickname#agent_nickname,phone#agent_phone')->db(); + if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}"); + // 查询分页 + $query->dateBetween('create_at')->order('id desc')->page(); + } + + /** + * 商城订单列表处理 + * @param array $data + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + protected function _index_page_filter(array &$data) + { + $uids = array_merge(array_column($data, 'uid'), array_column($data, 'order_uid')); + $userList = $this->app->db->name('DataUser')->whereIn('id', array_unique($uids))->select(); + $goodsList = $this->app->db->name('ShopOrderItem')->whereIn('order_no', array_unique(array_column($data, 'order_no')))->select(); + foreach ($data as &$vo) { + [$vo['user'], $vo['agent'], $vo['list']] = [[], [], []]; + foreach ($goodsList as $goods) if ($goods['order_no'] === $vo['order_no']) { + $vo['list'][] = $goods; + } + foreach ($userList as $user) if ($user['id'] === $vo['order_uid']) { + $vo['user'] = $user; + } + foreach ($userList as $user) if ($user['id'] === $vo['uid']) { + $vo['agent'] = $user; + } + } + } + /** * 返利奖励配置 * @auth true diff --git a/app/data/view/user_rebate/index.html b/app/data/view/user_rebate/index.html new file mode 100644 index 000000000..b219a8018 --- /dev/null +++ b/app/data/view/user_rebate/index.html @@ -0,0 +1,68 @@ +{extend name="../../admin/view/main"} + +{block name="content"} +
+ + | +代理会员 | +交易会员 | +订单信息 | +商品信息 | +
---|---|---|---|---|
+ + | +
+ {notempty name='vo.agent.headimg'}
+
+ 代理昵称:{$vo.agent.nickname|default='--'}
+ + 代理手机:{$vo.agent.phone|default='--'} + 代理等级:{notempty name='vo.agent.vip_code'}[ VIP{$vo.agent.vip_code} ] {$vo.agent.vip_name}{else}--{/notempty} + |
+
+ {notempty name='vo.user.headimg'}
+
+ 会员昵称:{$vo.user.nickname|default='--'}
+ + 会员手机:{$vo.user.phone|default='--'} + 会员级别:{notempty name='vo.user.vip_code'}[ VIP{$vo.user.vip_code} ] {$vo.user.vip_name}{else}--{/notempty} + |
+
+ 订单单号:{$vo.order_no|default='--'} + 订单交易 {$vo.order_amount+0} 元获得收益 {$vo.amount+0} 元 + {notempty name='vo.description'}{$vo.description|default=''}{/notempty} + 返拥时间:{$vo.create_at|format_datetime} + |
+
+ {foreach $vo.list as $g}
+ {$g.goods_name|default=''} x{$g.stock_sales|default=0}
+ {/foreach}
+ |
+