Commit 7badbbc0 by lizhilin

更新

parent 960cbdbe
......@@ -4,18 +4,52 @@
use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
use App\Models\Good;
use App\Models\OrderInfo;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Dropdown;
use Dcat\Admin\Widgets\Box;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
class HomeController extends Controller
{
public function index(Content $content)
{
// 创建表单构建器
$form = Form::make()->action(admin_url('orderInfo'));
// 添加日期范围搜索
$form->dateRange('date', '日期范围')->default(function () {
return [
date('Y-m-d 00:00:00', strtotime('-1 day')),
date('Y-m-d 23:59:59', strtotime('-1 day'))
];
});
// 添加搜索按钮
//$form->disableResetBtn();
//$form->submit('搜索');
// 使用卡片视图展示统计数据
$card123 = Card::make('统计数据')
->content(function () use ($form) {
// 获取表单提交的日期参数
$dates = $form->getFieldValue('date');
// // 查询数据库,这里以AdminLog为例
//$logs = OrderInfo::whereBetween('created_at', $dates)->get();
// // 统计数据
// $count = $logs->count();
return "共有记录 100 条";
});
//-----
// 构建下拉菜单,当点击菜单时发起请求获取数据重新渲染图表
$menu = [
......@@ -44,18 +78,36 @@ public function index(Content $content)
->id('my-box') // 设置盒子的ID
->tool($dropdown); // 设置下拉菜单按钮
//------
//商品列表
$goodsQuery = Good::where('is_show', 0)->orderBy('created_at', 'desc');
return $content
->header('Dashboard')
->description('Description...')
->body(function (Row $row) use ($box) {
$row->column(12, function (Column $column) use ($box) {
$column->row(function (Row $row) use ($box) {
->body(function (Row $row) use ($box, $goodsQuery, $card123) {
//$row->column(12, $card123);
$row->column(12, function (Column $column) use ($box, $goodsQuery) {
$column->row(function (Row $row) use ($box, $goodsQuery) {
$row->column(6, new Examples\OrderWaitCount());
$row->column(6, new Examples\OrderPickCount());
//$row->column(12, new Examples\StoreOrderChats());
//$row->column(12, Card::make('订单信息', Examples\MyBar::make()));
$row->column(12, Card::make('订单信息', $box));
$row->column(12, new Examples\Product());
// $row->column(12, function (Column $column) use ($goodsQuery) {
// $column->row(
// Grid::make($goodsQuery, function (Grid $grid) {
// $grid->disableRefreshButton();
// $grid->disableCreateButton();
// $grid->disableActions();
// $grid->disableRowSelector();
// $grid->addTableClass(['table-text-left']);
// //$grid->simplePaginate();
// $grid->column('cover_img', '商品图片')->image('', 100, 100)->width(280);
// $grid->column('goods_name', '商品名称');
// $grid->column('sale', '销量')->width(250);
// })
// );
// });
});
});
......
......@@ -7,11 +7,14 @@
use Dcat\Admin\Grid\RowAction;
use App\Models\User;
use App\Models\UserPermission;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Illuminate\Http\Request;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Select;
class ShareController extends AdminController
{
......@@ -22,11 +25,47 @@ class ShareController extends AdminController
*/
protected function grid()
{
$uid = request()->get('id');
return Grid::make(User::with(['shuser']), function (Grid $grid) use ($uid) {
$phone = request()->get('phone') ?? ''; //->orwhere('second_spuid', $uid)
$name = request()->get('name') ?? '';
$sp_type = request()->get('sp_type') ?? '';
return Grid::make(User::with(['shuser']), function (Grid $grid) use ($uid, $phone, $name, $sp_type) {
$grid->addTableClass(['table-text-center']);
$grid->model()->where('spuid', $uid)->orwhere('second_spuid', $uid)->orderBy('created_at', 'DESC');
if ($phone && $name && $sp_type) {
if ($sp_type == 1) {
$grid->model()->where('spuid', $uid)
->where('phone', $phone)
->where('name', $name)
->orderBy('created_at', 'DESC');
} else {
$grid->model()->where('second_spuid', $uid)
->where('phone', $phone)
->where('name', $name)
->orderBy('created_at', 'DESC');
}
} else {
if ($phone) {
$grid->model()->where('spuid', $uid)
->where('phone', $phone)
->orderBy('created_at', 'DESC');
} elseif ($name) {
$grid->model()->where('spuid', $uid)
->where('name', $name)
->orderBy('created_at', 'DESC');
} elseif ($sp_type) {
if ($sp_type == 1) {
$grid->model()->where('spuid', $uid)
->orderBy('created_at', 'DESC');
} else {
$grid->model()->where('second_spuid', $uid)
->orderBy('created_at', 'DESC');
}
} else {
$grid->model()->where('spuid', $uid)->orWhere('second_spuid', $uid)
->orderBy('created_at', 'DESC');
}
}
//$grid->column('id')->sortable();
$grid->column('name', '昵称');
$grid->column('phone', '手机号');
......@@ -43,24 +82,29 @@ protected function grid()
$grid->disableRowSelector();
//$grid->simplePaginate();
$grid->filter(function (Grid\Filter $filter) {
$grid->filter(function (Grid\Filter $filter) use ($uid) {
// 更改为 panel 布局
$filter->panel();
$filter->like('name', '昵称')->width(3);
$filter->like('phone', '用户手机号')->width(3);
$filter->equal('custom_field', '自定义字段')->select(['1' => '直推', '2' => '间推'])->where(function ($query) {
// 自定义查询逻辑
$sp_type = request('sp_type');
if ($sp_type == 1) {
$query->where('spuid', $sp_type);
} else {
$query->where('second_spuid', $sp_type);
}
});
$filter->where('sp_type', function ($query) use ($uid) {}, '选项')->select(['1' => '直推', '2' => '间推'])->width(3);
//$filter->between('created_at', '注册时间')->datetime()->width(4);
});
});
}
protected function getCustomFilterScript()
{
return <<<JS
$('select[name="status"]').change(function() {
var value = $(this).val();
console.log('asdfadf'+value);
Dcat.getData().filter('#your_custom_filter_field', 'value');
});
JS;
}
/**
* Make a show builder.
......
......@@ -37,6 +37,13 @@ public function handle(array $input)
$aftercode = trim($input['buycode']); //修改后直购码
$uid = trim($input['userid']);
$uObj = User::find($uid);
if (!is_numeric($aftercode)) {
throw new Exception('该直购码不是数字!');
}
$isExist = Merchant::where('buycode', $aftercode)->count();
if (!$isExist) {
throw new Exception('该直购码错误!');
}
if ($uObj) {
if (!$uObj->buycode) {
throw new Exception('该用户还没绑定直购码!');
......@@ -62,7 +69,7 @@ public function handle(array $input)
public function form()
{
$this->display('current', '当前直购码');
$this->text('buycode', '修改直购码')->help('输入4位随机数字');
$this->text('buycode', '修改直购码')->help('输入商家直购码');
$this->hidden('userid');
}
......
......@@ -39,6 +39,7 @@ public function handle(array $input)
//商品库存信息
$msgObj = MerchantGoodsStore::find($mgs_id);
$merchant_id = $msgObj->merchant_id;
$goods_id = $msgObj->goods_id;
$logData = [];
foreach ($attr_ids as $kk => $vv) {
......
......@@ -52,7 +52,7 @@ public function handle(array $input)
//记录操作日志
$logData[$kk]['mgs_id'] = $mgs_id;
$logData[$kk]['attr_id'] = $skuObj->attr_id;
$logData[$kk]['goods_id'] = $goods_id;
$logData[$kk]['goods_id'] = $skuObj->goods_id;
$logData[$kk]['change'] = -$store_num;
$logData[$kk]['created_at'] = date('Y-m-d H:i:s');
}
......
......@@ -81,7 +81,7 @@ public function handle(Request $request)
$this->withChart($data['list']);
break;
default:
$data = OrderInfo::getNumDayData(7, [3, 4]);
$data = OrderInfo::getNumDayData(1, [3, 4]);
// 卡片内容
$this->withContent($data['total']);
// 图表数据
......
......@@ -2,10 +2,13 @@
namespace App\Admin\Metrics\Examples;
use App\Models\User;
use Dcat\Admin\Widgets\Metrics\Round;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Dcat\Admin\Widgets\Metrics\Line;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Table;
class Product extends Line
{
......@@ -41,7 +44,7 @@ public function handle(Request $request)
case '28':
case '7':
default:
$list = DB::table('li_goods')->where('is_show', 1)->orderBy('sale', 'desc')->limit(10)->get();
$list = DB::table('li_goods')->where('is_show', 1)->where('sale', '>', 0)->orderBy('sale', 'desc')->limit(10)->get();
$html = '';
foreach ($list as $kk => $vv) {
$html .= '<tr>';
......@@ -87,6 +90,14 @@ public function withChart(array $data)
*/
public function withContent($finished, $dataList)
{
// $card2 = Card::make('自定义数据列表2')
// ->content(Table::make(User::query(), function ($table) {
// // 自定义列表字段
// $table->columns('id', 'email', 'created_at');
// // 启用分页
// $table->paginate(10);
// }));
return $this->content(
<<<HTML
<div class="col-sm-12 d-flex flex-column flex-wrap text-center">
......
......@@ -8,7 +8,7 @@
class ArticleController extends BaseController
{
public function getList()
public function getList(Request $request)
{
$page = $request->page ?? 1;
$limit = $request->limit ?? 10;
......
......@@ -81,6 +81,7 @@ public function login(Request $request)
$res = $this->decryptData($session_key, $encryptedData, $iv, $data);
if ($res != 0) {
Log::add('登录截取结果', $res);
return $this->JsonResponse('', '参数异常', 201);
}
$user = User::where(['phone' => $data->phoneNumber])->first();
......
......@@ -18,7 +18,9 @@ public function getList(Request $request)
if (!in_array($type, [1, 2, 3])) {
return $this->JsonResponse('', '参数错误', 201);
}
$sql = OrderDivideRecord::where(['um_id' => $request->user()->id, 'sh_type' => $type, 'deleted_at' => null]);
$userObj = $request->user();
$um_id = ($type == 3) ? $userObj->merchant_id : $userObj->id;
$sql = OrderDivideRecord::where(['um_id' => $um_id, 'sh_type' => $type, 'deleted_at' => null]);
$total = $sql->count();
$data = [
......
......@@ -23,13 +23,16 @@ public function getDeliveryList(Request $request)
$mid = $request->user()->merchant_id;
$lat1 = $request->lat ?? '';
$lng1 = $request->lng ?? '';
$list = Store::where(['merchant_id' => $mid])
->select(['id', 'title', 'lat_lng', 'address', 'contacts', 'phone'])->get();
foreach ($list as $key => $val) {
$atng = $val->lat_lng ? explode(',', $val->lat_lng) : [];
$lat2 = $atng[1];
$lng2 = $atng[0];
$list[$key]['distance'] = ($lat1 && $lat2) ? $this->haversineDistance($lat1, $lng1, $lat2, $lng2) : '';
$list = [];
if ($mid) {
$list = Store::where(['merchant_id' => $mid])
->select(['id', 'title', 'lat_lng', 'address', 'contacts', 'phone'])->get();
foreach ($list as $key => $val) {
$atng = $val->lat_lng ? explode(',', $val->lat_lng) : [];
$lat2 = $atng[1];
$lng2 = $atng[0];
$list[$key]['distance'] = ($lat1 && $lat2) ? $this->haversineDistance($lat1, $lng1, $lat2, $lng2) : '';
}
}
return $this->JsonResponse($list);
......
......@@ -5,6 +5,8 @@
use App\Command\Log;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\DB;
use App\Models\Good as GoodModel;
use App\Models\GoodSku;
class Pay
{
......@@ -74,7 +76,41 @@ public static function payNotify($fields = [])
if ($orderObj->pay_status == 0) {
$orderObj->order_status = 1;
$orderObj->pay_status = 1;
$orderObj->save();
if ($orderObj->save()) {
//更新商品销量、库存
$goodsList = OrderGoods::where("order_id", $orderObj->id)->get();
foreach ($goodsList as $item) {
$gid = $item->goods_id;
$attr_id = $item->attr_id;
$mer_id = $item->merchant_id;
$goods_number = $item->goods_number;
$goodsObj = GoodModel::find($gid);
//更新商品规格库存
$attrObj = GoodSku::find($attr_id);
$attr_stock = ($attrObj->stock - $goods_number) >= 0 ? $attrObj->stock - $goods_number : 0;
$attrObj->stock = $attr_stock;
$attrObj->save();
//更新商品sku
$skuArr = json_decode($goodsObj->sku, true);
if ($skuArr['sku']) {
foreach ($skuArr['sku'] as $kk => $vv) {
if (isset($vv['attr_sn']) && $vv['attr_sn'] == $attrObj->attr_sn) {
$skuArr['sku'][$kk]['stock'] = $attr_stock;
}
}
$goodsObj->sku = json_encode($skuArr, JSON_UNESCAPED_UNICODE);
$goodsObj->save();
}
//商户规格库存
$mgsObj = MerchantGoodSku::where(['goods_id' => $gid, 'attr_id' => $attr_id, 'merchant_id' => $mer_id])->first();
if ($mer_id && $mgsObj) {
$changeStock = ($mgsObj->stock >= $goods_number) ? $mgsObj->stock - $goods_number : 0;
$mgsObj->stock = $changeStock;
$mgsObj->save();
}
}
}
}
//支付记录
$pay_cord = new PaymentRecord();
......
<?php
namespace App\Models;
use WeChatPay\Builder;
......@@ -31,14 +32,14 @@ public function __construct()
// v3api秘钥
$this->v3_key = env('WX_XCX_MCH_KEY_V3');
// 「商户API证书」的「证书序列号」 商户平台【API安全】->【API证书】->【查看证书】,可查看商户API证书序列号
$this->merchantCertificateSerial = '45A5D415AAB9AAAF37E7336CE582B4D980CF6B9B';
$this->merchantCertificateSerial = '75BFCD14831525581A301D0CD190330606153F0E';
// 商户API私钥
//$this->merchantPrivateKeyFilePath = $pay_config['apiclient_key']; //"file://"
$this->merchantPrivateKeyFilePath = "file://" .public_path().'/cert/apiclient_key.pem'; //
$this->merchantPrivateKeyFilePath = "file://" . public_path() . '/cert/apiclient_key.pem'; //
;
// 微信支付平台证书 首次通过命令行生成 https://github.com/wechatpay-apiv3/wechatpay-php/tree/main/bin
//$this->platformCertificateFilePath = $pay_config['apiclient_cert'];
$this->platformCertificateFilePath ="file:///www/wwwroot/pz/public/cert//wechatpay_4F2000519B652DAF957614D1D6E7879E40DA6EC3.pem" ;
$this->platformCertificateFilePath = "file://" . public_path() . "/cert//wechatpay_38D2255A4177BE40747CE1ECAF6ED0812E7D00C8.pem";
// 构建客户端实例
$this->instance = $this->buildInstance();
......@@ -61,7 +62,7 @@ public function transfer(string $batch_sn, string $out_detail_no, float $money,
{
$trans_detail = [
'out_detail_no' => $out_detail_no,
'transfer_amount' => intval($money*100) ,
'transfer_amount' => intval($money * 100),
'transfer_remark' => $remark,
'openid' => $openid,
];
......@@ -77,7 +78,7 @@ public function transfer(string $batch_sn, string $out_detail_no, float $money,
'out_batch_no' => $batch_sn,
'batch_name' => '提现转账',
'batch_remark' => '提现转账',
'total_amount' => intval($money*100),
'total_amount' => intval($money * 100),
'total_num' => 1,
'transfer_detail_list' => [
$trans_detail
......
......@@ -73,4 +73,15 @@ public static function getYearData()
}
return $data;
}
public function getCustomFieldOptionsAttribute()
{
// 这里你可以自定义查询来获取你想要的option值
// 例如从关联表或者缓存中获取
return [
'option1' => '显示值1',
'option2' => '显示值2',
// 更多选项...
];
}
}
......@@ -23,13 +23,14 @@
"league/flysystem": "^3.15",
"lty5240/dcat-easy-sku": "^1.1",
"maatwebsite/excel": "~3.1.0",
"overtrue/wechat": "~5.0",
"phpoffice/phpspreadsheet": "^1.29",
"predis/predis": "^2.1",
"qcloud/cos-sdk-v5": "^2.6",
"qcloudsms/qcloudsms_php": "^0.1.4",
"simplesoftwareio/simple-qrcode": "^4.2",
"slowlyo/dcat-diy-form": "^2.2",
"overtrue/wechat": "~5.0",
"wechatpay/wechatpay": "^1.4",
"zhy/dcat-admin-sku": "dev-master"
},
"require-dev": {
......
<style>
.row {
margin: 0;
}
.col-md-12,
.col-md-3 {
padding: 0;
}
@media screen and (min-width: 1000px) and (max-width: 1150px) {
.col-lg-3,
.col-lg-9 {
flex: 0 0 50%;
max-width: 50%;
}
}
@media screen and (min-width: 1151px) and (max-width: 1300px) {
.col-lg-3 {
flex: 0 0 40%;
max-width: 40%;
}
.col-lg-9 {
flex: 0 0 60%;
max-width: 60%;
}
}
@media screen and (min-width: 1301px) and (max-width: 1700px) {
.col-lg-3 {
flex: 0 0 35%;
max-width: 35%;
}
.col-lg-9 {
flex: 0 0 65%;
max-width: 65%;
}
}
.login-page {
height: auto;
}
.login-main {
position: relative;
display: flex;
min-height: 100vh;
flex-direction: row;
align-items: stretch;
margin: 0;
}
.login-main .login-page {
background-color: #fff;
}
.login-main .card {
box-shadow: none;
}
.login-main .auth-brand {
margin: 4rem 0 4rem;
font-size: 26px;
width: 325px;
}
@media (max-width: 576px) {
.login-main .auth-brand {
width: 90%;
margin-left: 24px
}
}
.login-main .login-logo {
font-size: 2.1rem;
font-weight: 300;
margin-bottom: 0.9rem;
text-align: left;
margin-left: 20px;
}
.login-main .login-box-msg {
margin: 0;
padding: 0 0 20px;
font-size: 0.9rem;
font-weight: 400;
text-align: left;
}
.login-main .btn {
width: 100%;
}
.login-page-right {
padding: 6rem 3rem;
flex: 1;
position: relative;
color: #fff;
background-color: rgba(0, 0, 0, 0.3);
text-align: center !important;
background: url(/vendor/dcat-admin/images/bg.jpg) center;
background-size: cover;
}
.login-description {
position: absolute;
margin: 0 auto;
padding: 0 1.75rem;
bottom: 3rem;
left: 0;
right: 0;
}
.content-front {
position: absolute;
left: 0;
right: 0;
height: 100vh;
background: rgba(0, 0, 0, .1);
margin-top: -6rem;
}
body.dark-mode .content-front {
background: rgba(0, 0, 0, .3);
}
body.dark-mode .auth-brand {
color: #cacbd6
}
</style>
<form id="form-table" action="" method="get" class="form-horizontal" accept-charset="UTF-8" pjax-container="1">
<div class="row">
<div class="col-md-12">
<table class="table">
<thead>
<tr>
<th width="20%" style="text-align:center;">商品名称</th>
<th width="20%" style="text-align:center;">商品规格</th>
<th width="20%" style="text-align:center;">增加库存</th>
<th width="20%" style="text-align:center;">剩余库存</th>
</tr>
</thead>
<tbody>
<!-- 表格数据 -->
<tr>
<td style="text-align:center;vertical-align: middle;">数据1</td>
<td style="text-align:center;vertical-align: middle;">蓝色、大号</td>
<td><input type="text" name="remark" value="" class="form-control field_remark _normal_" placeholder=""></td>
<td style="text-align:center;vertical-align: middle;">123</td>
</tr>
<!-- 更多行数据 -->
</tbody>
</table>
</div>
<div class="col-md-8"><button type="button" id="submit-form" class="btn btn-primary pull-right"><i class="feather icon-save"></i> 提交</button></div>
</div>
</form>
<!--<form id="login-form" method="POST" action="{{ admin_url('auth/login') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<fieldset class="form-label-group form-group position-relative has-icon-left">
<input
type="text"
class="form-control {{ $errors->has('username') ? 'is-invalid' : '' }}"
name="username"
placeholder="{{ trans('admin.username') }}"
value=""
required
autofocus>
<div class="form-control-position">
<i class="feather icon-user"></i>
</div>
<label for="email">{{ trans('admin.username') }}</label>
<div class="help-block with-errors"></div>
@if($errors->has('username'))
<span class="invalid-feedback text-danger" role="alert">
@foreach($errors->get('username') as $message)
<span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
@endforeach
</span>
@endif
</fieldset>
<fieldset class="form-label-group form-group position-relative has-icon-left">
<input
minlength="5"
maxlength="20"
id="password"
type="password"
class="form-control {{ $errors->has('password') ? 'is-invalid' : '' }}"
name="password"
placeholder="{{ trans('admin.password') }}"
required
value=""
autocomplete="current-password">
<div class="form-control-position">
<i class="feather icon-lock"></i>
</div>
<label for="password">{{ trans('admin.password') }}</label>
<div class="help-block with-errors"></div>
@if($errors->has('password'))
<span class="invalid-feedback text-danger" role="alert">
@foreach($errors->get('password') as $message)
<span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
@endforeach
</span>
@endif
</fieldset>
<div class="form-group d-flex justify-content-between align-items-center">
<div class="text-left">
<fieldset class="checkbox">
<div class="vs-checkbox-con vs-checkbox-primary">
<input id="remember" name="remember" value="1" type="checkbox" {{ old('remember') ? 'checked' : '' }}>
<span class="vs-checkbox">
<span class="vs-checkbox--check">
<i class="vs-icon feather icon-check"></i>
</span>
</span>
<span> {{ trans('admin.remember_me') }}</span>
</div>
</fieldset>
</div>
</div>
<button type="submit" class="btn btn-primary float-right login-btn">
{{ __('admin.login') }}
&nbsp;
<i class="feather icon-arrow-right"></i>
</button>
</form>-->
<script>
Dcat.ready(function() {
// ajax表单提交
$('#login-form').form({
validate: true,
});
// 前端 JS 代码处理异步提交
});
</script>
<script data-exec-on-popstate="">
(function() {
try {
Dcat.wait()
} catch (e) {
console.error(e)
}
})();
Dcat.ready(function() {
try {
Dcat.token = "GQ11udjNxjua45vZwdgc5AlhnAGg0NQ7RKkEE1bx";;
$("#form-41c1e3EN").form({
validate: true,
confirm: [],
validationErrorToastr: true,
success: function(data) {
},
error: function(response) {
}
});
} catch (e) {
console.error(e)
}
})
</script>
\ No newline at end of file
......@@ -43,7 +43,7 @@
Route::get('get-cate-list', 'CategoryController@getList'); //一级分类列表
Route::get('article-list', 'ArticleController@getList'); //文章列表
Route::post('article-list', 'ArticleController@getList'); //文章列表
Route::get('article-detail', 'ArticleController@getDetail'); //文章详情
// Route::get('get-seccate-list', 'CategoryController@getSecList'); //二级分类列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment