修改预订单创建

This commit is contained in:
DESKTOP-GMUNQ1B\Administrator 2024-12-06 13:40:35 +08:00
parent 444b011d0f
commit a034ae5ec1
9 changed files with 138 additions and 1 deletions

View File

@ -52,7 +52,8 @@ class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchIn
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$find = StoreProduct::where('id', $item['product_id'])->field('image,store_name,store_info')->find();
$find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,store_name,store_info,unit')->find();
$item['unit_name']=$find['unitName']['name'];
$item['store_name']=$find['store_name'];
$item['store_info']=$find['store_info'];
$item['image']=$find['image'];

View File

@ -70,6 +70,13 @@ class BeforehandOrderLogic extends BaseLogic
$total_num = 0;
$total_price = 0;
$uid = $params['uid'] ?? 0;
if (!empty($uid) && empty($params['other_data']['nickname'])) {
$user = User::where('id', $uid)->field('nickname,mobile')->find();
$userAddress = UserAddress::getDefaultAddress($uid);
$params['other_data']['nickname'] = $user['nickname'];
$params['other_data']['phone'] = $user['mobile'];
$params['other_data']['address'] = !empty($userAddress) ? $userAddress['area']['area_name'] . $userAddress['street']['street_name'] . $userAddress['village']['village_name'] . $userAddress['brigade']['brigade_name'] . $userAddress['detail'] : '';
}
foreach ($params['product_arr'] as $k => $v) {
if ($v['product_id'] <= 0) {
unset($params['product_arr'][$k]);

View File

@ -0,0 +1,16 @@
<?php
namespace app\common\model\geo;
use app\common\model\BaseModel;
/**
* Class GeoArea
* @package app\common\model\geo\GeoArea
*/
class GeoArea extends BaseModel
{
protected $name = 'geo_area';
}

View File

@ -0,0 +1,16 @@
<?php
namespace app\common\model\geo;
use app\common\model\BaseModel;
/**
* Class GeoBrigade
* @package app\common\model\geo\GeoBrigade
*/
class GeoBrigade extends BaseModel
{
protected $name = 'geo_brigade';
}

View File

@ -0,0 +1,16 @@
<?php
namespace app\common\model\geo;
use app\common\model\BaseModel;
/**
* Class GeoCity
* @package app\common\model\geo\GeoCity
*/
class GeoCity extends BaseModel
{
protected $name = 'geo_city';
}

View File

@ -0,0 +1,16 @@
<?php
namespace app\common\model\geo;
use app\common\model\BaseModel;
/**
* Class GeoProvince
* @package app\common\model\geo\GeoProvince
*/
class GeoProvince extends BaseModel
{
protected $name = 'geo_province';
}

View File

@ -0,0 +1,16 @@
<?php
namespace app\common\model\geo;
use app\common\model\BaseModel;
/**
* Class GeoStreet
* @package app\common\model\geo\GeoStreet
*/
class GeoStreet extends BaseModel
{
protected $name = 'geo_street';
}

View File

@ -0,0 +1,16 @@
<?php
namespace app\common\model\geo;
use app\common\model\BaseModel;
/**
* Class GeoVillage
* @package app\common\model\geo\GeoVillage
*/
class GeoVillage extends BaseModel
{
protected $name = 'geo_village';
}

View File

@ -5,6 +5,10 @@ namespace app\common\model\user;
use app\common\model\BaseModel;
use app\common\model\geo\GeoArea;
use app\common\model\geo\GeoBrigade;
use app\common\model\geo\GeoStreet;
use app\common\model\geo\GeoVillage;
use think\model\concern\SoftDelete;
/**
@ -19,4 +23,33 @@ class UserAddress extends BaseModel
protected $deleteTime = 'delete_time';
public static function getDefaultAddress($uid)
{
$address = self::with(['area', 'street', 'village', 'brigade'])->where(['uid' => $uid, 'is_default' => 1])->find();
if (empty($address)) {
$address = self::with(['area', 'street', 'village', 'brigade'])->where(['uid' => $uid])->find();
}
return empty($address) ? [] : $address->toArray();
}
public function area()
{
return $this->hasOne(GeoArea::class, 'area_code', 'area')->field('area_code,area_name');
}
public function street()
{
return $this->hasOne(GeoStreet::class, 'street_code', 'street')->field('street_code,street_name');
}
public function village()
{
return $this->hasOne(GeoVillage::class, 'village_code', 'village')->field('village_code,village_name');
}
public function brigade()
{
return $this->hasOne(GeoBrigade::class, 'id', 'brigade')->field('id,brigade_name');
}
}