|
@@ -45,7 +45,7 @@ class PayDetailController extends Curd
|
|
|
|
|
|
protected function doSelect(array $where, string $field = null, string $order = 'desc')
|
|
protected function doSelect(array $where, string $field = null, string $order = 'desc')
|
|
{
|
|
{
|
|
- $model = $this->model->with(['member', 'cert','memberAccount']);
|
|
|
|
|
|
+ $model = $this->model->with(['member', 'cert', 'memberAccount']);
|
|
foreach ($where as $column => $value) {
|
|
foreach ($where as $column => $value) {
|
|
if (is_array($value)) {
|
|
if (is_array($value)) {
|
|
if ($value[0] === 'like' || $value[0] === 'not like') {
|
|
if ($value[0] === 'like' || $value[0] === 'not like') {
|
|
@@ -75,18 +75,91 @@ class PayDetailController extends Curd
|
|
$model = $model->where($column, $value);
|
|
$model = $model->where($column, $value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ $model = $model->where(function ($query) {
|
|
|
|
+ $query->whereIn('pay_prepayid',['ALIPAY','WXPAY'])
|
|
|
|
+ ->orWhere('pay_prepayid','like','%CASH%');
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if ($field) {
|
|
|
|
+ $model = $model->orderBy($field, $order);
|
|
|
|
+ }
|
|
|
|
+ return $model;
|
|
|
|
+ }
|
|
|
|
+ public function selectWelfare(Request $request): Response
|
|
|
|
+ {
|
|
|
|
+ [$where, $format, $limit, $field, $order] = $this->selectInput($request);
|
|
|
|
+ $order = $request->get('order', 'desc');
|
|
|
|
+ $field = $field ?? 'pay_addtimes';
|
|
|
|
+// $where['pay_status'] = 'SUCCESS';
|
|
|
|
+ if ($where['pay_category'] == 'OTHER') {
|
|
|
|
+ $where['pay_status'] = 'SUCCESS';
|
|
|
|
+ $where['pay_category'] = ['<>', 'RECHARGE'];
|
|
|
|
+ }
|
|
|
|
+ // else if ($where['pay_category'] == 'RECHARGE') {
|
|
|
|
+ // $where['pay_status'] = 'SUCCESS';
|
|
|
|
+ // $where['pay_category'] = 'RECHARGE';
|
|
|
|
+ // $where['pay_prepayid'] = ['in','WXPAY,ALIPAY'];
|
|
|
|
+ // }
|
|
|
|
+ $query = $this->doSelectWelfare($where, $field, $order);
|
|
|
|
+ return $this->doFormat($query, $format, $limit);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected function doSelectWelfare(array $where, string $field = null, string $order = 'desc')
|
|
|
|
+ {
|
|
|
|
+ $model = $this->model->with(['member', 'cert', 'memberAccount']);
|
|
|
|
+ foreach ($where as $column => $value) {
|
|
|
|
+ if (is_array($value)) {
|
|
|
|
+ if ($value[0] === 'like' || $value[0] === 'not like') {
|
|
|
|
+ $model = $model->where($column, $value[0], "%$value[1]%");
|
|
|
|
+ } elseif (in_array($value[0], ['>', '=', '<', '<>'])) {
|
|
|
|
+ $model = $model->where($column, $value[0], $value[1]);
|
|
|
|
+ } elseif ($value[0] == 'in' && !empty($value[1])) {
|
|
|
|
+ $valArr = $value[1];
|
|
|
|
+ if (is_string($value[1])) {
|
|
|
|
+ $valArr = explode(",", trim($value[1]));
|
|
|
|
+ }
|
|
|
|
+ $model = $model->whereIn($column, $valArr);
|
|
|
|
+ } elseif ($value[0] == 'not in' && !empty($value[1])) {
|
|
|
|
+ $valArr = $value[1];
|
|
|
|
+ if (is_string($value[1])) {
|
|
|
|
+ $valArr = explode(",", trim($value[1]));
|
|
|
|
+ }
|
|
|
|
+ $model = $model->whereNotIn($column, $valArr);
|
|
|
|
+ } elseif ($value[0] == 'null') {
|
|
|
|
+ $model = $model->whereNull($column);
|
|
|
|
+ } elseif ($value[0] == 'not null') {
|
|
|
|
+ $model = $model->whereNotNull($column);
|
|
|
|
+ } elseif ($value[0] !== '' || $value[1] !== '') {
|
|
|
|
+ $model = $model->whereBetween($column, $value);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $model = $model->where($column, $value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $model = $model->where(function ($query) {
|
|
|
|
+ $query->Where('pay_prepayid','like','%WELFARE%');
|
|
|
|
+ });
|
|
|
|
+
|
|
if ($field) {
|
|
if ($field) {
|
|
$model = $model->orderBy($field, $order);
|
|
$model = $model->orderBy($field, $order);
|
|
}
|
|
}
|
|
return $model;
|
|
return $model;
|
|
}
|
|
}
|
|
|
|
|
|
- public function afterQuery($items)
|
|
|
|
|
|
+ public function afterQuery($items)
|
|
{
|
|
{
|
|
- foreach($items as $item){
|
|
|
|
- $prepayId = explode('-',$item['pay_prepayid']);
|
|
|
|
- if (count($prepayId) > 1){
|
|
|
|
- $item['pay_prepayid'] = $prepayId[1];
|
|
|
|
|
|
+ foreach ($items as &$item) {
|
|
|
|
+ $prepayId = explode('-', $item->pay_prepayid);
|
|
|
|
+ if (count($prepayId) > 1) {
|
|
|
|
+ $item->pay_prepayid = $prepayId[1];
|
|
|
|
+ }
|
|
|
|
+ $memberAccount = [];
|
|
|
|
+ if(!empty($item->memberAccount)){
|
|
|
|
+ foreach($item->memberAccount as $account){
|
|
|
|
+ $memberAccount[strtolower($account->member_account_classify)] = $account;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $item->memberAccount = $memberAccount;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -133,15 +206,15 @@ class PayDetailController extends Curd
|
|
return json_fail($this->validateClass->getError());
|
|
return json_fail($this->validateClass->getError());
|
|
}
|
|
}
|
|
|
|
|
|
- $password = $request->post('recharge_password','');
|
|
|
|
- if(!$password || $password != '123456'){
|
|
|
|
|
|
+ $password = $request->post('recharge_password', '');
|
|
|
|
+ if (!$password || $password != '123456') {
|
|
return json_fail('充值密码错误');
|
|
return json_fail('充值密码错误');
|
|
}
|
|
}
|
|
|
|
|
|
Db::beginTransaction();
|
|
Db::beginTransaction();
|
|
try {
|
|
try {
|
|
$data = $this->insertRechargeInput($request);
|
|
$data = $this->insertRechargeInput($request);
|
|
- $data['pay_prepayid'] = $data['join_pay_member_id'].'-CASH';
|
|
|
|
|
|
+ $data['pay_prepayid'] = $data['join_pay_member_id'] . '-CASH';
|
|
|
|
|
|
$payDetailId = $this->doInsert($data);
|
|
$payDetailId = $this->doInsert($data);
|
|
(new RechargeController)->disposePaySuccess($payDetailId);
|
|
(new RechargeController)->disposePaySuccess($payDetailId);
|
|
@@ -158,7 +231,7 @@ class PayDetailController extends Curd
|
|
return json_success('success');
|
|
return json_success('success');
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 福利账户充值
|
|
* 福利账户充值
|
|
*/
|
|
*/
|
|
@@ -168,20 +241,20 @@ class PayDetailController extends Curd
|
|
return json_fail($this->validateClass->getError());
|
|
return json_fail($this->validateClass->getError());
|
|
}
|
|
}
|
|
|
|
|
|
- $password = $request->post('recharge_password','');
|
|
|
|
- if(!$password || $password != '123456'){
|
|
|
|
|
|
+ $password = $request->post('recharge_password', '');
|
|
|
|
+ if (!$password || $password != '123456') {
|
|
return json_fail('充值密码错误');
|
|
return json_fail('充值密码错误');
|
|
}
|
|
}
|
|
|
|
|
|
Db::beginTransaction();
|
|
Db::beginTransaction();
|
|
try {
|
|
try {
|
|
- $data = $this->insertRechargeInput($request,'WELFARE');
|
|
|
|
- $data['pay_prepayid'] = $data['join_pay_member_id'].'-WELFARE';
|
|
|
|
-
|
|
|
|
|
|
+ $data = $this->insertRechargeInput($request, 'WELFARE');
|
|
|
|
+ $data['pay_prepayid'] = $data['join_pay_member_id'] . '-WELFARE';
|
|
|
|
+
|
|
$this->doInsert($data);
|
|
$this->doInsert($data);
|
|
|
|
|
|
// 金额累加到福利账户
|
|
// 金额累加到福利账户
|
|
- $memberAccount = MemberAccount::where('join_account_member_id',$data['join_pay_member_id'])->where('member_account_classify','WELFARE')->first();
|
|
|
|
|
|
+ $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_income = $memberAccount->member_account_income + $data['pay_amount'];
|
|
$memberAccount->member_account_surplus = $memberAccount->member_account_surplus + $data['pay_amount'];
|
|
$memberAccount->member_account_surplus = $memberAccount->member_account_surplus + $data['pay_amount'];
|
|
$memberAccount->save();
|
|
$memberAccount->save();
|
|
@@ -207,7 +280,7 @@ class PayDetailController extends Curd
|
|
* @return array
|
|
* @return array
|
|
* @throws BusinessException
|
|
* @throws BusinessException
|
|
*/
|
|
*/
|
|
- protected function insertRechargeInput(Request $request,$type="CASH"): array
|
|
|
|
|
|
+ protected function insertRechargeInput(Request $request, $type = "CASH"): array
|
|
{
|
|
{
|
|
$params = $request->post();
|
|
$params = $request->post();
|
|
$data = $this->inputFilter($params);
|
|
$data = $this->inputFilter($params);
|
|
@@ -215,71 +288,71 @@ class PayDetailController extends Curd
|
|
$extendJson = [];
|
|
$extendJson = [];
|
|
// if (!$params['is_custom']) {
|
|
// if (!$params['is_custom']) {
|
|
Db::beginTransaction();
|
|
Db::beginTransaction();
|
|
- try {
|
|
|
|
- if (!$params['is_custom']){
|
|
|
|
- $data['pay_amount'] = $goods->goods_sales_price;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $orderId = "OD" . date("YmdHis") . random_string(6, 'up');
|
|
|
|
- $orderGroupId = "OD" . date("YmdHis") . random_string(6, '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_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("数据错误");
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (!$params['is_custom']) {
|
|
|
|
+ $data['pay_amount'] = $goods->goods_sales_price;
|
|
}
|
|
}
|
|
- $data['join_pay_order_id'] = $orderGroupId;
|
|
|
|
- $data['join_pay_object_json'] = json_encode(['order_id' => $orderId]);
|
|
|
|
-
|
|
|
|
- $rate = 0;
|
|
|
|
- if (!empty($goods->goods_attribute_json)) {
|
|
|
|
- $attributeJson = json_decode($goods->goods_attribute_json, true);
|
|
|
|
- if (isset($attributeJson['added'])){
|
|
|
|
- $rate = $attributeJson['added'] ? $attributeJson['added']['nbr'] : 0;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ $orderId = "OD" . date("YmdHis") . random_string(6, 'up');
|
|
|
|
+ $orderGroupId = "OD" . date("YmdHis") . random_string(6, '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_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'] = $orderGroupId;
|
|
|
|
+ $data['join_pay_object_json'] = json_encode(['order_id' => $orderId]);
|
|
|
|
+
|
|
|
|
+ $rate = 0;
|
|
|
|
+ if (!empty($goods->goods_attribute_json)) {
|
|
|
|
+ $attributeJson = json_decode($goods->goods_attribute_json, true);
|
|
|
|
+ if (isset($attributeJson['added'])) {
|
|
|
|
+ $rate = $attributeJson['added'] ? $attributeJson['added']['nbr'] : 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- $extendJson['added_amount'] = number_format($data['pay_amount'] * $rate, 2, '.', '');
|
|
|
|
- $extendJson['added_rate'] = $rate;
|
|
|
|
|
|
+ $extendJson['added_amount'] = number_format($data['pay_amount'] * $rate, 2, '.', '');
|
|
|
|
+ $extendJson['added_rate'] = $rate;
|
|
// } else {
|
|
// } else {
|
|
// // $extendJson['notify'] = 'success';
|
|
// // $extendJson['notify'] = 'success';
|
|
// $extendJson['is_custom'] = $params['is_custom'];
|
|
// $extendJson['is_custom'] = $params['is_custom'];
|