新增药品订单接口
This commit is contained in:
parent
9a311d78f3
commit
9fd87ac071
@ -103,4 +103,26 @@ class PatientOrderController extends AbstractController
|
||||
$data = $PatientOrderService->getPatientProductOrderInfo();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 药品订单取消支付
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function putPatientProductOrderCancelPay(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->putPatientProductOrderCancelPay();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除药品订单
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function deletePatientProductOrder(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->deletePatientProductOrder();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -152,23 +152,32 @@ class UserController extends AbstractController
|
||||
|
||||
// 发送消息
|
||||
// $arg = array();
|
||||
// $arg['From_Account'] = "10000"; // 发送方user_id 如系统发送,无需填写
|
||||
// $arg['To_Account'] = "123456"; // 接收方user_id
|
||||
// $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback'];
|
||||
// $arg['SendMsgControl'] = [];
|
||||
//// $arg['From_Account'] = "10000"; // 发送方user_id 如系统发送,无需填写
|
||||
// $arg['To_Account'] = "10000"; // 接收方user_id
|
||||
//// $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback'];
|
||||
//// $arg['SendMsgControl'] = [];
|
||||
//
|
||||
// $arg['MsgBody'] = [
|
||||
//// [
|
||||
//// "MsgType" => "TIMTextElem",
|
||||
//// "MsgContent" => [
|
||||
//// "Text" => "ceshi",
|
||||
//// ],
|
||||
//// ]
|
||||
// [
|
||||
// "MsgType" => "TIMTextElem",
|
||||
// "MsgType" => "TIMCustomElem",
|
||||
// "MsgContent" => [
|
||||
// "Text" => "发送11122",
|
||||
// "Data" => "{\"message_type\":1,\"content\":\"\"}",
|
||||
// "Desc" => "自定义消息",
|
||||
// "Ext" => "url",
|
||||
// "Sound" => "dingdong.aiff",
|
||||
// ],
|
||||
// ]
|
||||
// ];
|
||||
//
|
||||
// // 自定义消息
|
||||
// $cloud_custom_data = array();
|
||||
// $cloud_custom_data['order_inquiry_id'] = 491963820554948608;
|
||||
// $cloud_custom_data['order_inquiry_id'] = 1;
|
||||
// $cloud_custom_data['is_system'] = 0;
|
||||
// $cloud_custom_data['inquiry_type'] = 2;
|
||||
//
|
||||
|
||||
@ -32,6 +32,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $pay_time 支付时间
|
||||
* @property string $remarks 订单备注
|
||||
* @property int $refund_status 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
* @property string $cancel_time 订单取消时间
|
||||
* @property string $cancel_remarks 订单取消备注(自动添加)
|
||||
* @property int $province_id 省份id
|
||||
* @property string $province 省份
|
||||
@ -47,6 +48,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $consignee_tel_mask 收货人电话(掩码)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderProductItem[] $OrderProductItem
|
||||
*/
|
||||
class OrderProduct extends Model
|
||||
{
|
||||
@ -60,7 +62,7 @@ class OrderProduct extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'pay_time', 'remarks', 'refund_status', 'cancel_remarks', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_product_id";
|
||||
|
||||
@ -139,4 +141,15 @@ class OrderProduct extends Model
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @return int
|
||||
*/
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,4 +282,20 @@ class UserDoctor extends Model
|
||||
{
|
||||
return self::where($params)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生数据
|
||||
* 关联医院表
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getWithHospitalOne(array $params,array $fields = ['*']): object|null
|
||||
{
|
||||
return self::with([
|
||||
"Hospital:hospital_id,hospital_name,hospital_level_name"
|
||||
])
|
||||
->where($params)
|
||||
->first($fields);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,9 @@ use App\Constants\HttpEnumCode;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\UserDoctor;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
@ -277,6 +279,7 @@ class PatientOrderService extends BaseService
|
||||
$inquiryService->inquiryRefund($order_inquiry['order_inquiry_id'],"取消问诊");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
@ -287,6 +290,9 @@ class PatientOrderService extends BaseService
|
||||
|
||||
/**
|
||||
* 删除问诊订单
|
||||
* 支付超时
|
||||
* 取消问诊
|
||||
* 问诊结束
|
||||
* @return array
|
||||
*/
|
||||
public function deletePatientInquiryOrder(): array
|
||||
@ -306,16 +312,11 @@ class PatientOrderService extends BaseService
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if (!in_array($order_inquiry['inquiry_status'],[1,5])) {
|
||||
if (!in_array($order_inquiry['inquiry_status'],[6,7])) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单正在退款中");
|
||||
}
|
||||
|
||||
// 修改订单删除状态
|
||||
$data = array();
|
||||
$data['is_delete'] = 1;
|
||||
@ -349,9 +350,9 @@ class PatientOrderService extends BaseService
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if (!in_array($order_inquiry['inquiry_status'],[1])) {
|
||||
if ($order_inquiry['inquiry_status'] != 1) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法取消支付");
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
||||
@ -359,12 +360,12 @@ class PatientOrderService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单正在退款中");
|
||||
}
|
||||
|
||||
// 修改订单删除状态
|
||||
// 修改订单状态
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 7;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s",time());
|
||||
$data['cancel_reason'] = 2; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$data['cancel_remarks'] = "未支付取消";
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
|
||||
$params = array();
|
||||
@ -447,12 +448,157 @@ class PatientOrderService extends BaseService
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_product = OrderInquiry::getOne($params);
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
$order_product_item = OrderProductItem::getList($params);
|
||||
if (empty($order_product_item)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 处理商品图片
|
||||
foreach ($order_product_item as &$item){
|
||||
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
||||
}
|
||||
|
||||
if (!empty($order_product['doctor_id'])){
|
||||
// 获取问诊医生数据
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'user_name',
|
||||
'multi_point_status',
|
||||
'avatar',
|
||||
'doctor_title',
|
||||
'department_custom_name',
|
||||
'be_good_at',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_product['doctor_id'];
|
||||
$user_doctor = UserDoctor::getWithHospitalOne($params,$fields);
|
||||
if (empty($user_doctor)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
$user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['user_doctor'] = $user_doctor ?? [];
|
||||
$result['order_product'] = $order_product;
|
||||
$result['order_product_item'] = $order_product_item;
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 药品订单取消支付
|
||||
* @return array
|
||||
*/
|
||||
public function putPatientProductOrderCancelPay(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_product_id = $this->request->route('order_product_id');
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
// 获取药品订单数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_product['order_product_status'] != 1) {
|
||||
Db::rollBack();
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
if ($order_product['pay_status'] != 1) {
|
||||
Db::rollBack();
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
if (!in_array($order_product['refund_status'],[0,4,5])) {
|
||||
Db::rollBack();
|
||||
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单正在退款中");
|
||||
}
|
||||
|
||||
// 修改订单状态
|
||||
$data = array();
|
||||
$data['order_product_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s",time());
|
||||
$data['cancel_reason'] = 1; // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除药品订单
|
||||
* 已收货
|
||||
* 取消订单
|
||||
* @return array
|
||||
*/
|
||||
public function deletePatientProductOrder(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_product_id = $this->request->route('order_product_id');
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
if (!in_array($order_product['order_product_status'],[4,5])) {
|
||||
Db::rollBack();
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
// 修改订单状态
|
||||
$data = array();
|
||||
$data['order_product_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s",time());
|
||||
$data['cancel_reason'] = 1; // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@ -301,12 +301,15 @@ Router::addGroup('/patient', function () {
|
||||
Router::get('', [PatientOrderController::class, 'getPatientProductOrderList']);
|
||||
|
||||
// 获取药品订单详情
|
||||
Router::post('/{order_product_id:\d+}', [PatientOrderController::class, 'getPatientProductOrderInfo']);
|
||||
Router::get('/{order_product_id:\d+}', [PatientOrderController::class, 'getPatientProductOrderInfo']);
|
||||
|
||||
// 药品订单取消支付-1未支付
|
||||
Router::put('/cancel-pay/{order_inquiry_id:\d+}', [PatientOrderController::class, 'putPatientInquiryOrderCancelPay']);
|
||||
// 药品订单取消支付
|
||||
Router::put('/cancel-pay/{order_product_id:\d+}', [PatientOrderController::class, 'putPatientProductOrderCancelPay']);
|
||||
|
||||
// 创建处方订单
|
||||
// 删除药品订单
|
||||
Router::delete('/{order_product_id:\d+}', [PatientOrderController::class, 'deletePatientProductOrder']);
|
||||
|
||||
// 创建药品订单
|
||||
Router::post('/121212da', [PatientOrderController::class, 'imCallBack']);
|
||||
});
|
||||
|
||||
|
||||
@ -75,7 +75,6 @@ class Message extends Base
|
||||
'CloudCustomData' => "",
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user