Commit da3a04d6 by lizhilin

更新

parent 7badbbc0
......@@ -31,7 +31,9 @@ protected function grid()
}
return Merchant::find($vel)->name ?? '';
});
$grid->column('phone', '手机号');
$grid->column('phone', '手机号')->display(function ($val) {
return $val ? $val : '';
});
$grid->column('amount');
//$grid->column('status');
$grid->column('status')
......
......@@ -100,7 +100,7 @@ protected function form()
$forms->select('cityId', '城市');
$forms->text('contacts', '联系人');
$forms->text('phone', '手机号');
$forms->text('lat_lng', '经纬度')->help('<a href="https://lbs.amap.com/tools/picker" target="_blank">点击获取高德地图坐标</a>');
$forms->text('lat_lng', '经纬度')->help('<a href="https://lbs.qq.com/getPoint/" target="_blank">点击获取腾讯地图坐标</a>');
$forms->text('address', '详细地址');
$forms->text('distance', '配送范围(Km)');
$forms->image('business_license', '营业执照')
......
......@@ -12,8 +12,10 @@
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Forms\VerifierCodeForm;
use Dcat\Admin\Admin;
class OrderInfoController extends AdminController
......@@ -36,17 +38,35 @@ protected function grid()
return OrderGoodsList::make(['order_id' => $this->id]);
});
$grid->column('goods_amount', '订单总金额');
$grid->column('merchant.name', '所属商家');
$grid->column('merchant.province_id', '所在省市')->display(function ($val) {
if ($val) {
$proObj = City::where("city_id", $val)->first();
// $grid->column('merchant.name', '所属商家');
// $grid->column('merchant.province_id', '所在省市')->display(function ($val) {
// if ($val) {
// $proObj = City::where("city_id", $val)->first();
// $cityObj = City::where("city_id", $this->merchant->city_id)->first();
// $proname = $proObj->name ?? '';
// $cityname = $cityObj->name ?? '';
// return $proname . " " . $cityname;
// } else {
// return '';
// }
// });
$grid->column('merchant.province_id', '商家信息')->display('点击查看')->modal(function ($modal) {
//设置弹窗标题
$modal->title('商家信息');
$company = $this->merchant->name ?? '';
$content = $company . "<br/>";
$province_id = $this->merchant->province_id ?? '';
if ($province_id) {
$proObj = City::where("city_id", $province_id)->first();
$cityObj = City::where("city_id", $this->merchant->city_id)->first();
$proname = $proObj->name ?? '';
$cityname = $cityObj->name ?? '';
return $proname . " " . $cityname;
} else {
return '';
$content .= $proname . " " . $cityname;
}
$card = new Card(null, $content);
return "<div style='padding:10px 10px 0;width:100%;'>$card</div>";
});
$grid->column('store_id', '快递代收点')->display(function ($val) {
......@@ -56,14 +76,32 @@ protected function grid()
$res = $obj->address;
}
return $res;
});
})->limit(10);
// $grid->column('store_id', '快递代收点222')->if(function ($column) {
// $val = $column->getValue();
// return $val ? $val : '';
// })->display('点击查看')->modal(function ($modal) {
// //设置弹窗标题
// $modal->title('详情');
// $res = null;
// if ($this->store_id) {
// $obj = Store::where('id', $this->store_id)->first();
// $res = $obj->address;
// }
// $card = new Card(null, $res);
// return "<div style='padding:10px 10px 0;width:100%;'>$card</div>";
// })->else(function ($column) {
// return '';
// });
$grid->column('address_id', '送货上门')->display(function ($val) {
$res = '';
if ($this->area) {
$res = $this->area . "(" . $this->address . ")";
}
return $res;
});
})->limit(10);
$grid->column('created_at', '下单时间');
$grid->column('order_status', '状态')->display(function ($val) {
$options = OrderInfo::STATUS_OPTIONS;
......@@ -79,8 +117,25 @@ protected function grid()
return VerifierCodeForm::make()->payload(['id' => $this->id]);
});
$grid->column('verification_code', '核销码')->limit(10);
$grid->column('verifier', '核销员');
$grid->column('verification_at', '核销时间');
$grid->column('verifier', '核销信息')->if(function ($column) {
return $column->getValue();
})->display('点击查看')->modal(function ($modal) {
//设置弹窗标题
$modal->title('核销信息');
$content = "";
if ($this->verifier) {
$content .= "核销员:" . $this->verifier . "<br/>";
}
if ($this->verification_at) {
$content .= "核销时间:" . $this->verification_at . "<br/>";
}
$card = new Card(null, $content);
return "<div style='padding:10px 10px 0;width:100%;'>$card</div>";
})->else(function ($column) {
return '';
});
//$grid->column('updated_at')->sortable();
//$grid->disableActions();
......
......@@ -31,41 +31,33 @@ protected function grid()
$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']);
if ($phone && $name && $sp_type) {
$where = [];
if ($phone) {
$where['phone'] = $phone;
}
if ($name) {
$where['name'] = $name;
}
if ($phone || $name || $sp_type) {
if ($sp_type == 1) {
$grid->model()->where('spuid', $uid)
->where('phone', $phone)
->where('name', $name)
->where($where)
->orderBy('created_at', 'DESC');
} else {
} elseif ($sp_type == 2) {
$grid->model()->where('second_spuid', $uid)
->where('phone', $phone)
->where('name', $name)
->where($where)
->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)
->where($where)
->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', '手机号');
......
......@@ -35,7 +35,7 @@ protected function grid()
return $column->getValue() == 0;
})->display('点击审批')->modal(function (Grid\Displayers\Modal $modal) {
// 标题
$modal->title('提现审核');
$modal->title('直购码审核');
// 自定义图标
$modal->icon('feather icon-edit');
// 传递当前行字段值
......
......@@ -43,14 +43,14 @@ public function handle(array $input)
try {
$status = (int)$input['status']; //审核状态 0:审核中 1:通过 2:拒绝
$checkObj->status = $status;
if ($checkObj->save()) {
if ($status == 1) {
$uObj = User::find($userId);
$uObj->buycode = $checkObj->after_code;
$uObj->merchant_id = $merObj->id;
$uObj->save();
}
$checkObj->save();
DB::commit();
Log::add('直购码变更', $checkObj->toArray());
} catch (\Exception $exception) {
......
......@@ -17,7 +17,7 @@ public function grid(): Grid
$mgs_id = $this->payload['mgs_id'] ?? 0;
return Grid::make(MerchantGoodSku::with(['attr']), function (Grid $grid) use ($mgs_id, $merid) {
return Grid::make(MerchantGoodSku::with(['attr']), function (Grid $grid) use ($mgs_id) {
$grid->addTableClass(['table-text-center']);
$grid->model()->where('mgs_id', $mgs_id);
......
......@@ -263,7 +263,7 @@ public function getDetail(Request $request)
'id' => $goods->id,
'goods_img' => $cover,
'goods_price' => $mer_id ? $dg_price : $market_price,
'market_price' => $userObj ? $market_price : '',
'market_price' => $mer_id ? $market_price : '',
'stock' => $stock,
'goods_name' => $goods->goods_name,
'sale' => $goods->sale ?? 0,
......
......@@ -6,6 +6,7 @@
use App\Models\Carousel;
use App\Models\User;
use App\Models\Income;
use App\Models\Merchant;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
......@@ -48,14 +49,26 @@ public function add(Request $request)
$useObj = $request->user();
$type = $request->type ?? 0;
$money = $request->money ? (float)$request->money : 0;
Log::add('提现用户信息', $useObj->toArray());
if (!in_array($type, [1, 2,])) {
return $this->JsonResponse('', '参数错误', 201);
}
if ($money < 1) {
return $this->JsonResponse('', '提现金额1元起', 500);
}
if ($useObj->balance < $money) {
$balance = $useObj->balance ?? '';
$phone = $useObj->phone ?? '';
$um_id = $useObj->id;
$role_id = $useObj->role_id ?? '';
if ($role_id == 1) { //商家
$merId = $useObj->merchant_id;
$merObj = Merchant::find($merId);
$um_id = $merId;
$phone = $merObj->phone;
$balance = $merObj->balance;
}
if ($balance < $money) {
return $this->JsonResponse('', '余额不足', 500);
}
......@@ -64,12 +77,14 @@ public function add(Request $request)
$comObj = new Income();
$comObj->user_type = $type;
$comObj->um_id = $useObj->id;
$comObj->um_id = $um_id;
$comObj->openid = $useObj->openid;
$comObj->phone = $phone;
$comObj->amount = $money;
$comObj->status = 0;
$comObj->save();
DB::commit();
return $this->JsonResponse('');
} catch (\Exception $exception) {
Log::add('添加提现失败', $exception->getMessage());
......
......@@ -68,6 +68,7 @@ public function getOpenid(Request $request)
]);
}
//用户端登录
public function login(Request $request)
{
$code = $request->code ?? '';
......@@ -82,7 +83,7 @@ public function login(Request $request)
$res = $this->decryptData($session_key, $encryptedData, $iv, $data);
if ($res != 0) {
Log::add('登录截取结果', $res);
return $this->JsonResponse('', '参数异常', 201);
return $this->JsonResponse('', '参数异常' . $res, 201);
}
$user = User::where(['phone' => $data->phoneNumber])->first();
if (!$user) {
......@@ -105,6 +106,33 @@ public function login(Request $request)
]);
}
//商户端授权绑定账号密码(提现时)
public function merchantLogin(Request $request)
{
$muser = $request->user();
$appid = env('XCX_MERCHENT_APPID');
$secret = env('XCX_MERCHENT_SECRET');
$code = $request->code ?? '';
if (!$code) {
return $this->JsonResponse('', '无效参数Code', 201);
}
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' . $appid . '&secret=' . $secret . '&js_code=' . $code . '&grant_type=authorization_code';
$result = json_decode(file_get_contents($url), true);
if (isset($result['errcode'])) {
Log::add('商户端授权请求微信接口异常', $result);
return $this->JsonResponse('', '请求微信接口异常', 201);
}
$openId = $result['openid'];
if (!$muser->openid && $openId) {
$muser->openid = $openId;
$muser->save();
}
return $this->JsonResponse('');
}
public function logout(Request $request)
{
$request->user()->tokens()->delete();
......
......@@ -518,8 +518,8 @@ public function scanCodeDetail(Request $request)
$delivery['contacts'] = $sObj->contacts;
$delivery['phone'] = $sObj->phone;
$delivery['address'] = $sObj->address;
$delivery['lat'] = isset($latlngArr[1]) ? $latlngArr[1] : '';
$delivery['lng'] = isset($latlngArr[0]) ? $latlngArr[0] : '';
$delivery['lat'] = isset($latlngArr[0]) ? $latlngArr[0] : '';
$delivery['lng'] = isset($latlngArr[1]) ? $latlngArr[1] : '';
}
$data = [
......@@ -570,8 +570,8 @@ public function OrderInfo(Request $request)
$delivery['contacts'] = $sObj->contacts;
$delivery['phone'] = $sObj->phone;
$delivery['address'] = $sObj->address;
$delivery['lat'] = isset($latlngArr[1]) ? $latlngArr[1] : '';
$delivery['lng'] = isset($latlngArr[0]) ? $latlngArr[0] : '';
$delivery['lat'] = isset($latlngArr[0]) ? $latlngArr[0] : '';
$delivery['lng'] = isset($latlngArr[1]) ? $latlngArr[1] : '';
}
//订单状态
$order_status = $orderObj->order_status;
......@@ -665,15 +665,16 @@ public function orderCollect(Request $request)
//上月数据统计
$lastMonth = [];
if (date('d') < 10) {
$firstDayOfLastMonth = date('Y-m-01 00:00:00', strtotime('-1 month', time()));
$ninthDayOfLastMonth = date('Y-m-t 23:59:59', strtotime('-1 month', time()));
$lastMonth['buyCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
$lastMonth['pickedCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->whereIn('order_status', [3, 4])->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
$lastMonth['waitCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->where("order_status", 2)->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
//本月订单商品销量
$goods_number = OrderGoods::where('merchant_id', $merchant_id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->sum('goods_number');
$lastMonth['stockCount'] = $goods_number + $currentStock;
}
$firstDayOfLastMonth = date('Y-m-01 00:00:00', strtotime('-1 month', time()));
$ninthDayOfLastMonth = date('Y-m-t 23:59:59', strtotime('-1 month', time()));
$lastMonth['buyCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
$lastMonth['pickedCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->whereIn('order_status', [3, 4])->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
$lastMonth['waitCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->where("order_status", 2)->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
//本月订单商品销量
$goods_number = OrderGoods::where('merchant_id', $merchant_id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->sum('goods_number');
$lastMonth['stockCount'] = $goods_number + $currentStock;
return $this->JsonResponse(['current' => $currentMonth ? $currentMonth : new \stdClass(), 'last' => $lastMonth ? $lastMonth : new \stdClass()]);
}
}
......@@ -64,11 +64,12 @@ public function info(Request $request)
$merchant_id = $muser->merchant_id;
$store_id = $muser->store_id;
$total_revenue = $balance = $cashout = 0;
$store_name = '';
$store_name = $merchant_name = '';
if ($merchant_id) {
$merObj = Merchant::where('id', $merchant_id)->first();
$buycode = $merObj->buycode;
$phone = $merObj->phone;
$merchant_name = $merObj->name;
$total_revenue = $merObj->total_revenue ?? 0;
$balance = $merObj->balance ?? 0;
$cashout = $total_revenue - $balance;
......@@ -81,8 +82,9 @@ public function info(Request $request)
return $this->JsonResponse([
'user_id' => $muser->id,
'username' => $muser->username,
'merchant_name' => $muser->name,
'merchant_name' => $merchant_name,
'phone' => $phone,
'openid' => $muser->openid ?? '',
'avatar' => $muser->avatar ? env('IMAGE_URL') . $muser->avatar : env('NO_AVATAR_IMAGE_URL'),
'merchant_id' => $muser->merchant_id,
'buycode' => $buycode,
......
......@@ -51,8 +51,8 @@ public function checkDistance(Request $request)
->select(['id', 'title', 'lat_lng', 'distance'])->get();
foreach ($list as $key => $val) {
$atng = $val->lat_lng ? explode(',', $val->lat_lng) : [];
$lat2 = $atng[1];
$lng2 = $atng[0];
$lat2 = $atng[0];
$lng2 = $atng[1];
$res = ($lat1 && $lat2) ? $this->haversineDistance($lat1, $lng1, $lat2, $lng2) : '';
if ($res <= $val->distance) {
$flag = true;
......
......@@ -96,7 +96,7 @@ public function showShoppingCart(Request $request)
foreach ($shoppingCart as $key => $item) {
$tmp = [];
$goodsAttrObj = GoodSku::where("goods_id", $item['goods_id'])->where("attr_sn", $item['attr_sn'])->first();
$goodsObj = Good::where("id", $item['goods_id'])->first();
$goodsObj = Good::where("id", $item['goods_id'])->where('is_show', 1)->first();
if (!$goodsAttrObj || !$goodsObj) {
unset($shoppingCart[$key]);
continue;
......@@ -172,7 +172,7 @@ public function info(Request $request)
return $this->JsonResponse([
'user_id' => $user->id,
'nickname' => $user->name,
'avatar' => $user->avatar ? env('IMAGE_URL') . $user->avatar : env('IMAGE_URL') . '/wximg/my.png',
'avatar' => $user->avatar ? env('IMAGE_URL') . $user->avatar : env('NO_AVATAR_IMAGE_URL'),
'phone' => $user->phone,
'phone_sec' => $user->phone ? substr($user->phone, 0, 3) . "****" . substr($user->phone, 7) : '',
//'status' => $user->status,
......
......@@ -7,11 +7,14 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\SoftDeletes;
use Dcat\Admin\Traits\HasDateTimeFormatter;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasDateTimeFormatter;
use SoftDeletes;
public const USER_STATUS = [
......
......@@ -23,7 +23,7 @@
Route::post('get-openid', 'LoginController@getOpenid'); //获取openid
Route::post('login', 'LoginController@login')->name('login'); //授权登录
Route::post('login', 'LoginController@login')->name('login'); //用户端授权登录
Route::get('test-login', 'LoginController@testLogin'); //测试登录
......@@ -80,6 +80,8 @@
Route::get('merchant-info', 'StoreAdminUsersController@info'); //获取商户端用户资料
Route::post('merchant-login', 'LoginController@merchantLogin'); //商户端授权登录
Route::get('logout', 'LoginController@logout'); //登出
Route::get('home', 'UserController@home'); //首页数据
......
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