0
데이터베이스 쿼리에 문제가 있습니다.
먼저 과 같은 두 개의 항목을 가져오고 데이터가 올바르게 삽입되었습니다.데이터가있는 경우 업데이트하는 방법, 존재하지 않는 경우 만들지 않는 방법, Laravel 5
도매업 _ 목표 | 주 | total_transaction | 환불 | 내가 추가 행 다시 가져올 때 total_voucher
11223344 | 100.000| 1.2017| 50.000 | 2,25 | 0 11223344 | 100.000| 2.2017| 120.000 | 2,25 | 2700 11223344 | 100.000| 3.2017| 185.000 | 2,25 | 1462,5 11223344 | 100.000| 4.2017| 248.000 | 2,25 | 1417,5
그러나, 결과는 다음과 같다 : wholesaler_id
| 목표 | 주 | total_transaction | 환불 | 내가 원하는 결과는 다음과 같다 total_voucher
11223344 | 100.000| 1.2017| 50.000 | 2,25 | 0 11223344 | 100.000| 2.2017| 120.000 | 2,25 | 2700 11223344 | 100.000| 3.2017| 185.000 | 2,25 | 1462,5 11223344 | 100.000| 4.2017| 248.000 | 2,25 | 1417,5 11223344 | 100.000| 1.2017| 63.100 | 2,25 | 0 11223344 | 100.000| 2.2017| 142.700 | 2,25 | 2700 11223344 | 100.000| 3.2017| 205.000 | 2,25 | 1462,5 11223344 | 100.000| 4.2017| 279.400 | 2,25 | 1417,5
:
wholesaler_id | target | week | total_transaction | rebate | total_voucher 11223344 | 100.000| 1.2017| 63.100 | 2,25 | 0 11223344 | 100.000| 2.2017| 155.800 | 2,25 | 2700 11223344 | 100.000| 3.2017| 240.800 | 2,25 | 1462,5 11223344 | 100.000| 4.2017| 332.200 | 2,25 | 1417,5
리베이트 및 총 바우처 열이 문제가되지는 큰 문제는 total_transaction
입니다.
이 내 컨트롤러 함수에서 코드 importCsv
$voucher = Voucher::firstOrCreate(array( 'wholesaler_id' => $wholesaler_id, 'target' => $target, 'week' => $week . '.' . date("Y"), 'total_transaction' => $sum, 'rebate' => $wholesaler_type->rebate_percentage, 'total_voucher' => $total_voucher ));