1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace task;
- use Exception;
- class handler
- {
- public function refill_order_stat($condition)
- {
- try
- {
- $items = Model('')->table('refill_order,vr_order')
- ->field('count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
- ->join('inner')
- ->on('refill_order.order_id=vr_order.order_id')
- ->where($condition)
- ->group('order_state')
- ->select();
- $all = [];
- $data['order_count'] = $data['refill_amounts'] = $data['channel_amounts'] = $data['mch_amounts'] = 0;
- $sending = $success = $cancel = $data;
- foreach ($items as $item)
- {
- if ($item['order_state'] == ORDER_STATE_SEND) {
- $sending = $item;
- } elseif ($item['order_state'] == ORDER_STATE_SUCCESS) {
- $success = $item;
- } elseif ($item['order_state'] == ORDER_STATE_CANCEL) {
- $cancel = $item;
- }
- $all['order_count'] += $item['order_count'];
- $all['refill_amounts'] += ncPriceFormat($item['refill_amounts']);
- $all['channel_amounts'] += ncPriceFormat($item['channel_amounts']);
- $all['mch_amounts'] += ncPriceFormat($item['mch_amounts']);
- }
- $result = ['all' => $all, 'sending' => $sending, 'success' => $success, 'cancel' => $cancel];
- return [true,$result];
- }
- catch (Exception $ex)
- {
- return [false,false];
- }
- }
- public function refill_order_stat_title($condition)
- {
- return md5("refill_order_stat-".serialize($condition));
- }
- }
|