feat: config
This commit is contained in:
@@ -24,6 +24,8 @@ use Hyperf\DbConnection\Model\Model;
|
||||
* @property string $total_price
|
||||
* @property string $actual_price
|
||||
* @property string $discount_price
|
||||
* @property string $append_price
|
||||
* @property int $append_copies
|
||||
* @property int $status
|
||||
* @property int $is_refund_all
|
||||
* @property string $cancel_time
|
||||
@@ -53,7 +55,20 @@ class Order extends Model
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'cycle_id' => 'integer', 'site_id' => 'integer', 'city_id' => 'integer', 'coupon_id' => 'integer', 'meal_copies' => 'integer', 'optional_copies' => 'integer', 'status' => 'integer', 'is_refund_all' => 'integer','kitchen_id' => 'integer'];
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
'cycle_id' => 'integer',
|
||||
'site_id' => 'integer',
|
||||
'city_id' => 'integer',
|
||||
'coupon_id' => 'integer',
|
||||
'meal_copies' => 'integer',
|
||||
'optional_copies' => 'integer',
|
||||
'status' => 'integer',
|
||||
'is_refund_all' => 'integer',
|
||||
'kitchen_id' => 'integer',
|
||||
'append_copies' => 'integer'
|
||||
];
|
||||
|
||||
const string CREATED_AT = 'create_time';
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class Sku extends Model
|
||||
->orderBy('sort')
|
||||
->get();
|
||||
|
||||
if (empty($res)) return [];
|
||||
if ($res->isEmpty()) return [];
|
||||
|
||||
return $res->toArray();
|
||||
}
|
||||
|
||||
@@ -86,4 +86,20 @@ class Spu extends Model
|
||||
->select(['id','cycle_id','chef_id','title','title','sub_title','category_id'])
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @return array
|
||||
*/
|
||||
public function getDataArrByIds(array $ids): array
|
||||
{
|
||||
$res = $this
|
||||
->whereIn('id',$ids)
|
||||
->orderBy('sort')
|
||||
->get();
|
||||
|
||||
if ($res->isEmpty()) return [];
|
||||
|
||||
return $res->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,12 @@ class OrderInfoService extends BaseService
|
||||
$skuList = array_column($skuList, null,'id');
|
||||
$imageList = $this->getOssObjects(array_column($skuList,'image_ids'));
|
||||
|
||||
$spuIds = array_unique(array_column($skuList,'spu_id'));
|
||||
$spuList = $this->spuModel->getDataArrByIds($spuIds);
|
||||
$spuList = array_column($skuList, null,'id');
|
||||
|
||||
$chefId = array_unique(array_column($spuList,'chef_id'));
|
||||
|
||||
$orderCopiesList = [];
|
||||
for ($i = 1; $i <= ($orderInfo['copies'] ?? 0); $i++) {
|
||||
|
||||
@@ -123,7 +129,15 @@ class OrderInfoService extends BaseService
|
||||
$skuInfo['url'] = $imageList[$imageId]['url'] ?? '';
|
||||
$oneCopiesInfo['image_list'][] = $imageList[$imageId] ?? [];
|
||||
|
||||
$oneCopiesInfo['sku_list'][] = $skuInfo;
|
||||
$oneCopiesInfo['sku_list'][] = [
|
||||
'url' => $imageList[$imageId]['url'] ?? '',
|
||||
'title' => $skuList[$item['sku_id']]['title'] ?? '',
|
||||
'unit_price' => $item['unit_price'],
|
||||
'quantity' => $item['quantity'],
|
||||
'price' => bcmul($item['unit_price'], $item['quantity'], 2),
|
||||
'chef_name' => '123',
|
||||
'spu_title' => $spuList[$skuList[$item['sku_id']]['spu_id']]['title'] ?? '',
|
||||
];
|
||||
$oneCopiesInfo['total_price'] = bcadd($oneCopiesInfo['total_price'], bcmul($item['unit_price'],(string)$item['quantity'],2), 2);
|
||||
$oneCopiesInfo['total_quantity'] += $item['quantity'];
|
||||
}
|
||||
@@ -133,5 +147,7 @@ class OrderInfoService extends BaseService
|
||||
|
||||
$orderInfo['copies_list'] = $orderCopiesList;
|
||||
$orderInfo['site'] = $this->siteCache->getSiteInfo($orderInfo['site_id']);
|
||||
|
||||
//todo coupon
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,8 @@ class PlaceOrderService extends BaseOrderService
|
||||
$orderInsertModel->total_price = $this->orderRes['total_price'];
|
||||
$orderInsertModel->actual_price = max($this->orderRes['actual_price'], 0);
|
||||
$orderInsertModel->discount_price = $this->orderRes['favorable_sundry_price'] + $this->orderRes['favorable_good_price'];
|
||||
$orderInsertModel->append_price = $this->orderRes['sundry_price'];
|
||||
$orderInsertModel->append_copies = $this->orderRes['sundry_num'];
|
||||
$orderInsertModel->status = OrderCode::WAIT_PAY;
|
||||
$orderInsertModel->is_refund_all = OrderCode::REFUND_NULL;
|
||||
$orderInsertModel->order_json = json_encode($this->orderRes);
|
||||
|
||||
Reference in New Issue
Block a user