|
@@ -274,6 +274,45 @@ class PayDetailController extends Curd
|
|
|
return json_success('success');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 余额账户赠送
|
|
|
+ */
|
|
|
+ public function insertGive(Request $request): Response
|
|
|
+ {
|
|
|
+ if ($this->validate && !$this->validateClass->scene('add')->check($request->post())) {
|
|
|
+ return json_fail($this->validateClass->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ $password = $request->post('recharge_password', '');
|
|
|
+ if (!$password || $password != '123456') {
|
|
|
+ return json_fail('赠送密码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $data = $this->insertGiveInput($request);
|
|
|
+ $data['pay_prepayid'] = $data['join_pay_member_id'] . '-CASH';
|
|
|
+
|
|
|
+ $this->doInsert($data);
|
|
|
+
|
|
|
+ // 金额累加到福利账户
|
|
|
+ $memberAccount = MemberAccount::where('join_account_member_id', $data['join_pay_member_id'])->where('member_account_classify', 'WELFARE')->first();
|
|
|
+ $memberAccount->member_account_income = $memberAccount->member_account_income + $data['pay_amount'];
|
|
|
+ $memberAccount->member_account_surplus = $memberAccount->member_account_surplus + $data['pay_amount'];
|
|
|
+ $memberAccount->save();
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ } catch (BusinessException $customException) {
|
|
|
+ Db::rollBack();
|
|
|
+ return json_fail($customException->getMessage());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollBack();
|
|
|
+ dump($e->getMessage());
|
|
|
+ return json_fail('数据写入失败11');
|
|
|
+ }
|
|
|
+ return json_success('success');
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 福利账户充值
|
|
@@ -407,6 +446,88 @@ class PayDetailController extends Curd
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Desc
|
|
|
+ * @Author Gorden
|
|
|
+ * @Date 2024/6/5 13:39
|
|
|
+ *
|
|
|
+ * @param Request $request
|
|
|
+ * @return array
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+ protected function insertGiveInput(Request $request, $type = "CASH"): array
|
|
|
+ {
|
|
|
+ $params = $request->post();
|
|
|
+ $data = $this->inputFilter($params);
|
|
|
+ $goods = Goods::find($params['goods_id']);
|
|
|
+ $extendJson = [];
|
|
|
+ // if (!$params['is_custom']) {
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ if (!$params['is_custom']) {
|
|
|
+ $data['pay_amount'] = $goods->goods_sales_price;
|
|
|
+ }
|
|
|
+
|
|
|
+// $orderId = "OD" . date('ymdHi') . random_string(4, 'up');
|
|
|
+// $orderGroupId = "OD" . date('ymdHi') . random_string(4, 'up');
|
|
|
+// $orderData = [
|
|
|
+// 'order_id' => $orderId,
|
|
|
+// 'order_groupby' => $orderGroupId,
|
|
|
+// 'join_order_member_id' => $data['join_pay_member_id'],
|
|
|
+// 'order_name' => date('Y-m-d H:i:s') . '-订单',
|
|
|
+// 'order_amount_total' => $data['pay_amount'],
|
|
|
+// 'order_amount_pay' => $data['pay_amount'],
|
|
|
+// 'order_amount_json' => '{"tax": 0, "freight": 0}',
|
|
|
+// 'order_status_payment' => 'SUCCESS',
|
|
|
+// 'order_classify' => 'RECHARGE',
|
|
|
+// 'order_category' => 'RECHARGE',
|
|
|
+// 'order_status_system' => 'PAYING',
|
|
|
+// 'order_status_storage' => 'PENDING',
|
|
|
+// 'order_addtimes' => time()
|
|
|
+// ];
|
|
|
+// if ($type == 'WELFARE') {
|
|
|
+// $orderData['order_is_complete'] = 'Y';
|
|
|
+// $orderData['order_status_system'] = 'DONE';
|
|
|
+// $orderData['order_status_storage'] = 'DONE';
|
|
|
+// }
|
|
|
+// $sku = GoodsSku::where('join_sku_goods_id', $params['goods_id'])->first();
|
|
|
+//
|
|
|
+// Order::insert($orderData);
|
|
|
+// $orderSheetData = [
|
|
|
+// 'join_sheet_member_id' => $data['join_pay_member_id'],
|
|
|
+// 'join_sheet_order_id' => $orderId,
|
|
|
+// 'join_sheet_goods_id' => $params['goods_id'],
|
|
|
+// 'join_sheet_goods_sku_id' => $sku ? $sku->goods_sku_id : 0,
|
|
|
+// 'order_sheet_status' => 'DONE',
|
|
|
+// 'order_sheet_category' => 'RECHARGE',
|
|
|
+// 'order_sheet_num' => 1,
|
|
|
+// 'order_sheet_price' => $data['pay_amount'],
|
|
|
+// 'order_sheet_amount' => $data['pay_amount'],
|
|
|
+// 'order_sheet_pay' => $data['pay_amount'],
|
|
|
+// 'order_sheet_addtimes' => time()
|
|
|
+// ];
|
|
|
+//
|
|
|
+// OrderSheet::insert($orderSheetData);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dump($e->getMessage());
|
|
|
+ Db::rollBack();
|
|
|
+
|
|
|
+ throw new BusinessException("数据错误");
|
|
|
+ }
|
|
|
+ $data['join_pay_order_id'] = "SYSTEM";
|
|
|
+ $data['join_pay_object_json'] = json_encode(['order_id' => 'SYSTEM']);
|
|
|
+
|
|
|
+ $rate = 0;
|
|
|
+ $extendJson['added_amount'] = number_format($data['pay_amount'] * $rate, 2, '.', '');
|
|
|
+ $extendJson['added_rate'] = $rate;
|
|
|
+ $data['pay_extend_json'] = json_encode($extendJson);
|
|
|
+ $data['pay_paytimes'] = date('Y-m-d H:i:s', strtotime($data['pay_paytimes']));
|
|
|
+ $data['pay_prepayid'] = 0;
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Desc 加备注-门店、服务人员、业务人员
|
|
|
* @Author Gorden
|