layTable(function () { $this->title = '代理库存管理'; }, static function (QueryHelper $query) { // 查询条件排序 $query->with(['agent', 'bindGoods']); // 产品搜索查询 $gdb = PluginWemallGoods::mQuery()->like('code|name#gname')->db(); if (!empty($gdb->getOptions()['where'] ?? [])) { $db2 = PluginWemallGoodsItem::mk()->whereRaw("gcode in {$gdb->field('code')->buildSql()}"); $query->whereRaw("ghash in {$db2->field('ghash')->buildSql()}"); } // 代理搜索查询 $db = PluginWumaSalesUser::mQuery()->like('phone,username')->db(); if (!empty($db->getOptions()['where'] ?? [])) { $query->whereRaw("auid in {$db->field('id')->buildSql()}"); } }); } /** * 仓库出入库明细. * @auth true * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function show() { $data = $this->_vali([ 'auid.require' => '代理用户不能为空!', 'product_code.require' => '产品编号不能为空!', 'product_spec.require' => '产品规格不能为空!', ]); PluginWumaSalesOrder::mQuery()->layTable(function () use ($data) { $this->assign($data); $this->stock = PluginWumaSalesUserStock::mk()->where($data)->find(); $this->agent = PluginWumaSalesUser::mk()->where(['id' => $data['auid']])->find(); // $this->product = DataBrandProduct::mk()->where(['code' => $data['product_code']])->find(); }, static function (QueryHelper $query) use ($data) { $data['auid|xuid'] = $data['auid']; unset($data['auid']); $query->where($data)->field('mode,auid,xuid,code,num_need,num_used,vir_need,vir_used,create_time'); }); } }