|
@@ -11,6 +11,8 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
|
use App\Models\Manager\Process\LowPriceGoodsMember as LowPriceGoodsMemberModel;
|
|
use App\Models\Manager\Process\LowPriceGoodsMember as LowPriceGoodsMemberModel;
|
|
|
|
|
+use App\Models\manager\Process\LowPriceGoodsRecord as LowPriceGoodsRecordModel;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 违规处理-低价商品
|
|
* 违规处理-低价商品
|
|
@@ -596,4 +598,168 @@ class LowPriceGoods extends Controller
|
|
|
// 告知结果
|
|
// 告知结果
|
|
|
return json_send(['code' => 'success', 'msg' => '执行成功']);
|
|
return json_send(['code' => 'success', 'msg' => '执行成功']);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理买药中的业务
|
|
|
|
|
+ * @author 唐远望
|
|
|
|
|
+ * @version 1.0
|
|
|
|
|
+ * @date 2025-12-23
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ public function buying_business(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, LowPriceGoodsRecordModel $LowPriceGoodsRecordModel)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 验证参数
|
|
|
|
|
+ $request->scene('buying_business')->validate();
|
|
|
|
|
+ $access_token = request('access_token', '');
|
|
|
|
|
+ $admin_id = $access_token['uid'];
|
|
|
|
|
+ // 接收数据
|
|
|
|
|
+ $all_data = request()->all();
|
|
|
|
|
+ $id = request('id', 0);
|
|
|
|
|
+ $where = ['id' => $id];
|
|
|
|
|
+ $LowPriceGoods = $LowPriceGoodsModel->where($where)->first();
|
|
|
|
|
+ if (!$LowPriceGoods) return json_send(['code' => 'error', 'msg' => '违规记录不存在']);
|
|
|
|
|
+ if ($LowPriceGoods->processing_status != '1') return json_send(['code' => 'error', 'msg' => '当前状态不是待处理,流程调用错误']);
|
|
|
|
|
+ if ($all_data['processing_status'] != '2') return json_send(['code' => 'error', 'msg' => '流程状态参数值错误']);
|
|
|
|
|
+ // 查询是否存在流程中的记录
|
|
|
|
|
+ $map = ['lowprice_product_logid' => $id, 'processing_status' => $all_data['processing_status']];
|
|
|
|
|
+ $record = $LowPriceGoodsRecordModel->where($map)->first();
|
|
|
|
|
+ if ($record) return json_send(['code' => 'error', 'msg' => '当前状态已存在流程中,请勿重复提交']);
|
|
|
|
|
+ $record_content = [
|
|
|
|
|
+ 'purchase_quantity' => $all_data['purchase_quantity'], //购买数量
|
|
|
|
|
+ 'totle_amount' => $all_data['totle_amount'], //总金额
|
|
|
|
|
+ 'buy_date' => $all_data['buy_date'], //购买日期
|
|
|
|
|
+ 'screenshot_images' => $all_data['screenshot_images'], // 截图图片
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 写入流程记录
|
|
|
|
|
+ $insert_data = [
|
|
|
|
|
+ 'lowprice_product_logid' => $id,
|
|
|
|
|
+ 'admin_id' => $admin_id,
|
|
|
|
|
+ 'record_content' => json_encode($record_content),
|
|
|
|
|
+ 'processing_status' => $all_data['processing_status'], //处理状态1=待处理2=购买中3=已溯源4=回收凭据已上传5=已回收6=拒绝回收7=已下架8=无法处理
|
|
|
|
|
+ ];
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $LowPriceGoodsRecordModel->addLowPriceGoodsRecord_content($insert_data);
|
|
|
|
|
+ //更新违规记录状态
|
|
|
|
|
+ $LowPriceGoods->processing_status = $all_data['processing_status'];
|
|
|
|
|
+ $LowPriceGoods->update_time = time();
|
|
|
|
|
+ $LowPriceGoods->save();
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '流转成功']);
|
|
|
|
|
+ // 成功处理...
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ // 错误处理...
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '流转失败', 'data' => $e->getMessage()]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理已下架/无法处理中的业务
|
|
|
|
|
+ * @author 唐远望
|
|
|
|
|
+ * @version 1.0
|
|
|
|
|
+ * @date 2025-12-23
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ public function unprocessed_business(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, LowPriceGoodsRecordModel $LowPriceGoodsRecordModel)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 验证参数
|
|
|
|
|
+ $request->scene('unprocessed_business')->validate();
|
|
|
|
|
+ $access_token = request('access_token', '');
|
|
|
|
|
+ $admin_id = $access_token['uid'];
|
|
|
|
|
+ // 接收数据
|
|
|
|
|
+ $all_data = request()->all();
|
|
|
|
|
+ $id = request('id', 0);
|
|
|
|
|
+ $where = ['id' => $id];
|
|
|
|
|
+ $LowPriceGoods = $LowPriceGoodsModel->where($where)->first();
|
|
|
|
|
+ if (!$LowPriceGoods) return json_send(['code' => 'error', 'msg' => '违规记录不存在']);
|
|
|
|
|
+ if ($LowPriceGoods->processing_status != '1') return json_send(['code' => 'error', 'msg' => '当前状态不是待处理,流程调用错误']);
|
|
|
|
|
+ if (!in_array($all_data['processing_status'],[7,8])) return json_send(['code' => 'error', 'msg' => '流程状态参数值错误']);
|
|
|
|
|
+ // 查询是否存在流程中的记录
|
|
|
|
|
+ $map = ['lowprice_product_logid' => $id, 'processing_status' => $all_data['processing_status']];
|
|
|
|
|
+ $record = $LowPriceGoodsRecordModel->where($map)->first();
|
|
|
|
|
+ if ($record) return json_send(['code' => 'error', 'msg' => '当前状态已存在流程中,请勿重复提交']);
|
|
|
|
|
+ $record_content = [
|
|
|
|
|
+ 'description' => $all_data['description'], //情况描述
|
|
|
|
|
+ 'screenshot_images' => $all_data['screenshot_images'], // 截图图片
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 写入流程记录
|
|
|
|
|
+ $insert_data = [
|
|
|
|
|
+ 'lowprice_product_logid' => $id,
|
|
|
|
|
+ 'admin_id' => $admin_id,
|
|
|
|
|
+ 'record_content' => json_encode($record_content),
|
|
|
|
|
+ 'processing_status' => $all_data['processing_status'], //处理状态1=待处理2=购买中3=已溯源4=回收凭据已上传5=已回收6=拒绝回收7=已下架8=无法处理
|
|
|
|
|
+ ];
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $LowPriceGoodsRecordModel->addLowPriceGoodsRecord_content($insert_data);
|
|
|
|
|
+ //更新违规记录状态
|
|
|
|
|
+ $LowPriceGoods->processing_status = $all_data['processing_status'];
|
|
|
|
|
+ $LowPriceGoods->update_time = time();
|
|
|
|
|
+ $LowPriceGoods->save();
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '流转成功']);
|
|
|
|
|
+ // 成功处理...
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ // 错误处理...
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '流转失败', 'data' => $e->getMessage()]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理已溯源中的业务
|
|
|
|
|
+ * @author 唐远望
|
|
|
|
|
+ * @version 1.0
|
|
|
|
|
+ * @date 2025-12-23
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ public function trace_business(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, LowPriceGoodsRecordModel $LowPriceGoodsRecordModel)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 验证参数
|
|
|
|
|
+ $request->scene('trace_business')->validate();
|
|
|
|
|
+ $access_token = request('access_token', '');
|
|
|
|
|
+ $admin_id = $access_token['uid'];
|
|
|
|
|
+ // 接收数据
|
|
|
|
|
+ $all_data = request()->all();
|
|
|
|
|
+ $id = request('id', 0);
|
|
|
|
|
+ $where = ['id' => $id];
|
|
|
|
|
+ $LowPriceGoods = $LowPriceGoodsModel->where($where)->first();
|
|
|
|
|
+ if (!$LowPriceGoods) return json_send(['code' => 'error', 'msg' => '违规记录不存在']);
|
|
|
|
|
+ if ($LowPriceGoods->processing_status != '2') return json_send(['code' => 'error', 'msg' => '当前状态不是购买中,流程调用错误']);
|
|
|
|
|
+ if ($all_data['processing_status'] != '3') return json_send(['code' => 'error', 'msg' => '流程状态参数值错误']);
|
|
|
|
|
+ // 查询是否存在流程中的记录
|
|
|
|
|
+ $map = ['lowprice_product_logid' => $id, 'processing_status' => $all_data['processing_status']];
|
|
|
|
|
+ $record = $LowPriceGoodsRecordModel->where($map)->first();
|
|
|
|
|
+ if ($record) return json_send(['code' => 'error', 'msg' => '当前状态已存在流程中,请勿重复提交']);
|
|
|
|
|
+ $record_content = [
|
|
|
|
|
+ 'trace_company_name' => $all_data['trace_company_name'], //溯源公司名称
|
|
|
|
|
+ 'trace_description' => $all_data['trace_description'], //溯源情况描述
|
|
|
|
|
+ 'screenshot_images' => $all_data['screenshot_images'], // 截图图片
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 写入流程记录
|
|
|
|
|
+ $insert_data = [
|
|
|
|
|
+ 'lowprice_product_logid' => $id,
|
|
|
|
|
+ 'admin_id' => $admin_id,
|
|
|
|
|
+ 'record_content' => json_encode($record_content),
|
|
|
|
|
+ 'processing_status' => $all_data['processing_status'], //处理状态1=待处理2=购买中3=已溯源4=回收凭据已上传5=已回收6=拒绝回收7=已下架8=无法处理
|
|
|
|
|
+ ];
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $LowPriceGoodsRecordModel->addLowPriceGoodsRecord_content($insert_data);
|
|
|
|
|
+ //更新违规记录状态
|
|
|
|
|
+ $LowPriceGoods->processing_status = $all_data['processing_status'];
|
|
|
|
|
+ $LowPriceGoods->update_time = time();
|
|
|
|
|
+ $LowPriceGoods->save();
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '流转成功']);
|
|
|
|
|
+ // 成功处理...
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ // 错误处理...
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '流转失败', 'data' => $e->getMessage()]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|