已使用商品数量

This commit is contained in:
wucongxing8150 2024-04-17 11:46:59 +08:00
parent f83580508a
commit df935b6c82
3 changed files with 30 additions and 26 deletions

View File

@ -16,9 +16,10 @@ use Hyperf\Snowflake\Concern\Snowflake;
* @property int $product_id 商品id * @property int $product_id 商品id
* @property string $product_name 商品名称 * @property string $product_name 商品名称
* @property int $quantity 商品数量 * @property int $quantity 商品数量
* @property int $used_quantity 已使用数量
* @property string $discount_product_price 折扣商品价格 * @property string $discount_product_price 折扣商品价格
* @property Carbon $created_at 创建时间 * @property \Carbon\Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间 * @property \Carbon\Carbon $updated_at 修改时间
*/ */
class OrderServicePackageProduct extends Model class OrderServicePackageProduct extends Model
{ {
@ -32,7 +33,7 @@ class OrderServicePackageProduct extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
*/ */
protected array $fillable = ['service_product_id', 'order_service_id', 'product_id', 'product_name', 'quantity', 'discount_product_price', 'created_at', 'updated_at']; protected array $fillable = ['service_product_id', 'order_service_id', 'product_id', 'product_name', 'quantity', 'used_quantity', 'discount_product_price', 'created_at', 'updated_at'];
protected string $primaryKey = "service_product_id"; protected string $primaryKey = "service_product_id";

View File

@ -1002,6 +1002,11 @@ class InquiryService extends BaseService
} }
// 获取服务包当月剩余次数
// 获取服务包到期天数
$result = array(); $result = array();
$result['doctor_user_id'] = $user_doctor['user_id']; $result['doctor_user_id'] = $user_doctor['user_id'];
$result['patient_user_id'] = $order_inquiry['user_id']; $result['patient_user_id'] = $order_inquiry['user_id'];

View File

@ -2887,30 +2887,28 @@ class PatientOrderService extends BaseService
$result['order_product'] = $order_products->toArray(); $result['order_product'] = $order_products->toArray();
} }
// 已使用商品数量 // // 已使用商品数量
$used_quantity = 0; // $used_quantity = 0;
foreach ($order_products as $order_product){ // foreach ($order_products as $order_product){
// 获取详情item // // 获取详情item
$params = array(); // $params = array();
$params['order_product_id'] = $order_product['order_product_id']; // $params['order_product_id'] = $order_product['order_product_id'];
$order_product_items = OrderProductItem::getList($params); // $order_product_items = OrderProductItem::getList($params);
if (empty($order_product_items)){ // if (empty($order_product_items)){
return fail(HttpEnumCode::SERVER_ERROR); // return fail(HttpEnumCode::SERVER_ERROR);
} // }
//
foreach ($order_product_items as $order_product_item){ // foreach ($order_product_items as $order_product_item){
$used_quantity = $order_product_item["amount"]; // $used_quantity = $order_product_item["amount"];
} // }
} // }
//
if ($used_quantity > 30){ // if ($used_quantity > 30){
$used_quantity = 30; // $used_quantity = 30;
} // }
//
$result['order_service_package_product']['used_quantity'] = $used_quantity; // $result['order_service_package_product'][0]['remaining_quantity'] = $used_quantity;
} }
// 获取药品剩余数量
} }
return success($result); return success($result);